@rings-webgpu/core 1.0.29 → 1.0.30

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.umd.js CHANGED
@@ -7888,7 +7888,7 @@ else if (typeof exports === 'object')
7888
7888
  `;class vf{compute;constructor(){this.compute=new ye(Bf)}generateBRDFLUTTexture(){let e=new we(256,256,re.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=F.beginCommandEncoder();return F.computeCommand(t,[this.compute]),F.endCommandEncoder(t),e}}class ei{id;guiTexture;uvRec=new fe(0,0,1,1);uvBorder=new fe(0,0,0,0);offsetSize=new fe(0,0,4,4);borderSize=new fe(0,0,0,0);trimSize=new le;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||D.res.defaultGUITexture}}class ur{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=D.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,ur._maxUid++,this._staticId=ur._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class J2{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 ti=new J2;class Uf{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 yf{id=0;file=""}class Cf{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class qa extends dt{static format=He.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 ei;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),ti.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 Uf;a.trim().split(t).forEach((i,n)=>{if(n<2)qa.readLineProperty(i,r);else if(n<r.pages+2){let o=new yf;qa.readLineProperty(i,o),r.fontPage.push(o)}else if(n<r.pages+3)qa.readLineProperty(i,r);else if(r.count>0){let o=new Cf;qa.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 D.res.loadTexture(r,null,!0);let i=D.res.getTexture(r),n=new ur(i);e.push(n)}qa.parseSprite(e,t),t.fontChar[" "]||qa.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ei,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),ti.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 j2(s,e){let t=new ei;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 ur(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function Sf(s,e,t){let a=new ei;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 xf{_spriteMap=new Map;_spriteList=[];textureSize=new le;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=Sf(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 Ff extends dt{static format=He.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await D.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 xf(this._json.size),t=new ur(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);D.res.addAtlas(this.baseUrl,e),this.data=e}}var qt=Uint8Array,ai=Uint16Array,Z2=Int32Array,kf=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]),Ef=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]),Y2=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wf=function(s,e){for(var t=new ai(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new Z2(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}},Rf=wf(kf,2),If=Rf.b,X2=Rf.r;If[28]=258,X2[258]=28;for(var H2=wf(Ef,0),K2=H2.b,qs=new ai(32768),je=0;je<32768;++je){var br=(je&43690)>>1|(je&21845)<<1;br=(br&52428)>>2|(br&13107)<<2,br=(br&61680)>>4|(br&3855)<<4,qs[je]=((br&65280)>>8|(br&255)<<8)>>1}for(var ki=(function(s,e,t){for(var a=s.length,r=0,i=new ai(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new ai(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new ai(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],h=n[s[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[qs[h]>>l]=c}else for(o=new ai(a),r=0;r<a;++r)s[r]&&(o[r]=qs[n[s[r]-1]++]>>15-s[r]);return o}),Ei=new qt(288),je=0;je<144;++je)Ei[je]=8;for(var je=144;je<256;++je)Ei[je]=9;for(var je=256;je<280;++je)Ei[je]=7;for(var je=280;je<288;++je)Ei[je]=8;for(var Qf=new qt(32),je=0;je<32;++je)Qf[je]=5;var q2=ki(Ei,9,1),$2=ki(Qf,5,1),$s=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},Ba=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},eo=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},eb=function(s){return(s+7)/8|0},to=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))},tb=["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"],oa=function(s,e,t){var a=new Error(e||tb[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,oa),!t)throw a;return a},ab=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(ae){var oe=t.length;if(ae>oe){var ue=new qt(Math.max(oe*2,ae));ue.set(t),t=ue}},f=e.f||0,h=e.p||0,u=e.b||0,g=e.l,A=e.d,m=e.m,p=e.n,_=r*8;do{if(!g){f=Ba(s,h,1);var B=Ba(s,h+1,3);if(h+=3,B)if(B==1)g=q2,A=$2,m=9,p=5;else if(B==2){var x=Ba(s,h,31)+257,k=Ba(s,h+10,15)+4,E=x+Ba(s,h+5,31)+1;h+=14;for(var S=new qt(E),I=new qt(19),T=0;T<k;++T)I[Y2[T]]=Ba(s,h+T*3,7);h+=k*3;for(var Q=$s(I),G=(1<<Q)-1,q=ki(I,Q,1),T=0;T<E;){var ge=q[Ba(s,h,G)];h+=ge&15;var U=ge>>4;if(U<16)S[T++]=U;else{var ie=0,P=0;for(U==16?(P=3+Ba(s,h,3),h+=2,ie=S[T-1]):U==17?(P=3+Ba(s,h,7),h+=3):U==18&&(P=11+Ba(s,h,127),h+=7);P--;)S[T++]=ie}}var z=S.subarray(0,x),X=S.subarray(x);m=$s(z),p=$s(X),g=ki(z,m,1),A=ki(X,p,1)}else oa(1);else{var U=eb(h)+4,C=s[U-4]|s[U-3]<<8,y=U+C;if(y>r){l&&oa(0);break}o&&c(u+C),t.set(s.subarray(U,y),u),e.b=u+=C,e.p=h=y*8,e.f=f;continue}if(h>_){l&&oa(0);break}}o&&c(u+131072);for(var V=(1<<m)-1,ne=(1<<p)-1,W=h;;W=h){var ie=g[eo(s,h)&V],ce=ie>>4;if(h+=ie&15,h>_){l&&oa(0);break}if(ie||oa(2),ce<256)t[u++]=ce;else if(ce==256){W=h,g=null;break}else{var te=ce-254;if(ce>264){var T=ce-257,de=kf[T];te=Ba(s,h,(1<<de)-1)+If[T],h+=de}var he=A[eo(s,h)&ne],Ue=he>>4;he||oa(3),h+=he&15;var X=K2[Ue];if(Ue>3){var de=Ef[Ue];X+=eo(s,h)&(1<<de)-1,h+=de}if(h>_){l&&oa(0);break}o&&c(u+131072);var Ne=u+te;if(u<X){var Ke=i-X,K=Math.min(X,Ne);for(Ke+u<0&&oa(3);u<K;++u)t[u]=a[Ke+u]}for(;u<Ne;++u)t[u]=t[u-X]}}e.l=g,e.p=W,e.b=u,e.f=f,g&&(f=1,e.m=m,e.d=A,e.n=p)}while(!f);return u!=t.length&&n?to(t,0,u):t.subarray(0,u)},rb=new qt(0),Ta=function(s,e){return s[e]|s[e+1]<<8},va=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},ao=function(s,e){return va(s,e)+va(s,e+4)*4294967296};function ib(s,e){return ab(s,{i:2},e&&e.out,e&&e.dictionary)}var ro=typeof TextDecoder<"u"&&new TextDecoder,nb=0;try{ro.decode(rb,{stream:!0}),nb=1}catch{}var sb=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:to(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 Tf(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(ro)return ro.decode(s);var r=sb(s),i=r.s,t=r.r;return t.length&&oa(8),i}}var ob=function(s,e){return e+30+Ta(s,e+26)+Ta(s,e+28)},lb=function(s,e,t){var a=Ta(s,e+28),r=Tf(s.subarray(e+46,e+46+a),!(Ta(s,e+8)&2048)),i=e+46+a,n=va(s,e+20),o=t&&n==4294967295?cb(s,i):[n,va(s,e+24),va(s,e+42)],l=o[0],c=o[1],f=o[2];return[Ta(s,e+10),l,c,r,i+Ta(s,e+30)+Ta(s,e+32),f]},cb=function(s,e){for(;Ta(s,e)!=1;e+=4+Ta(s,e+2));return[ao(s,e+12),ao(s,e+4),ao(s,e+20)]};function fb(s,e){for(var t={},a=s.length-22;va(s,a)!=101010256;--a)(!a||s.length-a>65558)&&oa(13);var r=Ta(s,a+8);if(!r)return{};var i=va(s,a+16),n=i==4294967295||r==65535;if(n){var o=va(s,a-12);n=va(s,o)==101075792,n&&(r=va(s,o+32),i=va(s,o+48))}for(var l=0;l<r;++l){var c=lb(s,i,n),f=c[0],h=c[1],u=c[2],g=c[3],A=c[4],m=c[5],p=ob(s,m);i=A,f?f==8?t[g]=ib(s.subarray(p,p+h),{out:new qt(u)}):oa(14,"unknown compression type "+f):t[g]=to(s,p,p+h)}return t}class Bt extends Dt{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=D.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 Rr extends Ve{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),h=new Uint16Array(i*r*2*3),u=0,g=0,A=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,p=n*Math.cos(m),_=n*Math.sin(m);for(e=0;e<=i;++e){var B=2*Math.PI*e/i,U=_*Math.cos(B),C=_*Math.sin(B),y=1/Math.sqrt(U*U+p*p+C*C);if(l[u++]=U,l[u++]=p,l[u++]=C,c[g++]=U*y,c[g++]=p*y,c[g++]=C*y,f[A++]=e/i,f[A++]=t/r,e>0&&t>0){var x=(i+1)*t+e,k=(i+1)*t+e-1,E=(i+1)*(t-1)+e-1,S=(i+1)*(t-1)+e;t==r?(h[a++]=x,h[a++]=E,h[a++]=S):t==1?(h[a++]=x,h[a++]=k,h[a++]=E):(h[a++]=x,h[a++]=k,h[a++]=E,h[a++]=x,h[a++]=E,h[a++]=S)}}}this.setIndices(h),this.setAttribute(L.position,l),this.setAttribute(L.normal,c),this.setAttribute(L.uv,f),this.setAttribute(L.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new xe(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class wi extends d.Object3D{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),wi.register3DRepresentation)this.marker=wi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Rr(.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 Ri extends d.Object3D{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new wi(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),Ri.register3DRepresentation?(this.line=Ri.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 Ve,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(L.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new d.Object3D,o=n.addComponent(d.MeshRenderer),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=me.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class Mf extends dt{static format=He.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=fb(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(Tf(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 Ri(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 Nf{_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,_t,t):a=await i.load(e,Ls,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,rf,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,Ys,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,Ks,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 Ha;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?Ce.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(h=>{l.push(h),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 Ws;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 Bn;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 yn;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 Gs;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 Gs;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,qa,t,a),n=i.data;return ti.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new It().load(e,Ff,t,e)).data}async loadKMZ(e,t){return(await new It().load(e,Mf,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 h=new bn;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}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 vf().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Bn,this.defaultSky.createFromTexture(128,this.blackTexture),Ce.getInstance().attached(this.defaultSky,this),Ce.getInstance().attached(t,this),Ce.getInstance().attached(this.normalTexture,this),Ce.getInstance().attached(this.maskTexture,this),Ce.getInstance().attached(this.whiteTexture,this),Ce.getInstance().attached(this.blackTexture,this),Ce.getInstance().attached(this.redTexture,this),Ce.getInstance().attached(this.blueTexture,this),Ce.getInstance().attached(this.greenTexture,this),Ce.getInstance().attached(this.yellowTexture,this),Ce.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new ur(this.whiteTexture),this.defaultGUISprite=new ei(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new Kt}}class Pf extends qe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=D.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=D.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;D.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const db="1.0.28";class D{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 w.presentationSize}static get aspect(){return w.aspect}static get width(){return w.windowWidth}static get height(){return w.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",db),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Ee.init(R.allocCount,this.setting.doublePrecision),await w.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,De.getGBufferFrame(De.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),Z.init(),Xa.init(),Be.init(),Et.init(),Wt.init(),this.res=new Nf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Zo,this.inputSystem.initCanvas(w.canvas)}static startRenderJob(e){let t=new I0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Pf).addPost(xs),(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){Le.delta=e-Le.time,Le.time=e,Le.frame+=1,hr.tick(Le.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=w.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of Pe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=w.device.createCommandEncoder();for(const n of Pe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}w.device.queue.submit([r.finish()]);for(const n of Pe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const n of Pe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];o&&f.enable&&h(o)}}this._renderLoop&&await this._renderLoop(),Ee.updateAllContinueTransform(0,R.useCount,16),Be.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of Pe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let Cn=`
7891
+ `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await D.res.loadTexture(r,null,!0);let i=D.res.getTexture(r),n=new ur(i);e.push(n)}qa.parseSprite(e,t),t.fontChar[" "]||qa.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ei,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),ti.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 j2(s,e){let t=new ei;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 ur(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function Sf(s,e,t){let a=new ei;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 xf{_spriteMap=new Map;_spriteList=[];textureSize=new le;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=Sf(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 Ff extends dt{static format=He.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await D.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 xf(this._json.size),t=new ur(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);D.res.addAtlas(this.baseUrl,e),this.data=e}}var qt=Uint8Array,ai=Uint16Array,Z2=Int32Array,kf=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]),Ef=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]),Y2=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wf=function(s,e){for(var t=new ai(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new Z2(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}},Rf=wf(kf,2),If=Rf.b,X2=Rf.r;If[28]=258,X2[258]=28;for(var H2=wf(Ef,0),K2=H2.b,qs=new ai(32768),je=0;je<32768;++je){var br=(je&43690)>>1|(je&21845)<<1;br=(br&52428)>>2|(br&13107)<<2,br=(br&61680)>>4|(br&3855)<<4,qs[je]=((br&65280)>>8|(br&255)<<8)>>1}for(var ki=(function(s,e,t){for(var a=s.length,r=0,i=new ai(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new ai(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new ai(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],h=n[s[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[qs[h]>>l]=c}else for(o=new ai(a),r=0;r<a;++r)s[r]&&(o[r]=qs[n[s[r]-1]++]>>15-s[r]);return o}),Ei=new qt(288),je=0;je<144;++je)Ei[je]=8;for(var je=144;je<256;++je)Ei[je]=9;for(var je=256;je<280;++je)Ei[je]=7;for(var je=280;je<288;++je)Ei[je]=8;for(var Qf=new qt(32),je=0;je<32;++je)Qf[je]=5;var q2=ki(Ei,9,1),$2=ki(Qf,5,1),$s=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},Ba=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},eo=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},eb=function(s){return(s+7)/8|0},to=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))},tb=["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"],oa=function(s,e,t){var a=new Error(e||tb[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,oa),!t)throw a;return a},ab=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(ae){var oe=t.length;if(ae>oe){var ue=new qt(Math.max(oe*2,ae));ue.set(t),t=ue}},f=e.f||0,h=e.p||0,u=e.b||0,g=e.l,A=e.d,m=e.m,p=e.n,_=r*8;do{if(!g){f=Ba(s,h,1);var B=Ba(s,h+1,3);if(h+=3,B)if(B==1)g=q2,A=$2,m=9,p=5;else if(B==2){var x=Ba(s,h,31)+257,k=Ba(s,h+10,15)+4,E=x+Ba(s,h+5,31)+1;h+=14;for(var S=new qt(E),I=new qt(19),T=0;T<k;++T)I[Y2[T]]=Ba(s,h+T*3,7);h+=k*3;for(var Q=$s(I),G=(1<<Q)-1,q=ki(I,Q,1),T=0;T<E;){var ge=q[Ba(s,h,G)];h+=ge&15;var U=ge>>4;if(U<16)S[T++]=U;else{var ie=0,P=0;for(U==16?(P=3+Ba(s,h,3),h+=2,ie=S[T-1]):U==17?(P=3+Ba(s,h,7),h+=3):U==18&&(P=11+Ba(s,h,127),h+=7);P--;)S[T++]=ie}}var z=S.subarray(0,x),X=S.subarray(x);m=$s(z),p=$s(X),g=ki(z,m,1),A=ki(X,p,1)}else oa(1);else{var U=eb(h)+4,C=s[U-4]|s[U-3]<<8,y=U+C;if(y>r){l&&oa(0);break}o&&c(u+C),t.set(s.subarray(U,y),u),e.b=u+=C,e.p=h=y*8,e.f=f;continue}if(h>_){l&&oa(0);break}}o&&c(u+131072);for(var V=(1<<m)-1,ne=(1<<p)-1,W=h;;W=h){var ie=g[eo(s,h)&V],ce=ie>>4;if(h+=ie&15,h>_){l&&oa(0);break}if(ie||oa(2),ce<256)t[u++]=ce;else if(ce==256){W=h,g=null;break}else{var te=ce-254;if(ce>264){var T=ce-257,de=kf[T];te=Ba(s,h,(1<<de)-1)+If[T],h+=de}var he=A[eo(s,h)&ne],Ue=he>>4;he||oa(3),h+=he&15;var X=K2[Ue];if(Ue>3){var de=Ef[Ue];X+=eo(s,h)&(1<<de)-1,h+=de}if(h>_){l&&oa(0);break}o&&c(u+131072);var Ne=u+te;if(u<X){var Ke=i-X,K=Math.min(X,Ne);for(Ke+u<0&&oa(3);u<K;++u)t[u]=a[Ke+u]}for(;u<Ne;++u)t[u]=t[u-X]}}e.l=g,e.p=W,e.b=u,e.f=f,g&&(f=1,e.m=m,e.d=A,e.n=p)}while(!f);return u!=t.length&&n?to(t,0,u):t.subarray(0,u)},rb=new qt(0),Ta=function(s,e){return s[e]|s[e+1]<<8},va=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},ao=function(s,e){return va(s,e)+va(s,e+4)*4294967296};function ib(s,e){return ab(s,{i:2},e&&e.out,e&&e.dictionary)}var ro=typeof TextDecoder<"u"&&new TextDecoder,nb=0;try{ro.decode(rb,{stream:!0}),nb=1}catch{}var sb=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:to(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 Tf(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(ro)return ro.decode(s);var r=sb(s),i=r.s,t=r.r;return t.length&&oa(8),i}}var ob=function(s,e){return e+30+Ta(s,e+26)+Ta(s,e+28)},lb=function(s,e,t){var a=Ta(s,e+28),r=Tf(s.subarray(e+46,e+46+a),!(Ta(s,e+8)&2048)),i=e+46+a,n=va(s,e+20),o=t&&n==4294967295?cb(s,i):[n,va(s,e+24),va(s,e+42)],l=o[0],c=o[1],f=o[2];return[Ta(s,e+10),l,c,r,i+Ta(s,e+30)+Ta(s,e+32),f]},cb=function(s,e){for(;Ta(s,e)!=1;e+=4+Ta(s,e+2));return[ao(s,e+12),ao(s,e+4),ao(s,e+20)]};function fb(s,e){for(var t={},a=s.length-22;va(s,a)!=101010256;--a)(!a||s.length-a>65558)&&oa(13);var r=Ta(s,a+8);if(!r)return{};var i=va(s,a+16),n=i==4294967295||r==65535;if(n){var o=va(s,a-12);n=va(s,o)==101075792,n&&(r=va(s,o+32),i=va(s,o+48))}for(var l=0;l<r;++l){var c=lb(s,i,n),f=c[0],h=c[1],u=c[2],g=c[3],A=c[4],m=c[5],p=ob(s,m);i=A,f?f==8?t[g]=ib(s.subarray(p,p+h),{out:new qt(u)}):oa(14,"unknown compression type "+f):t[g]=to(s,p,p+h)}return t}class Bt extends Dt{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=D.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 Rr extends Ve{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),h=new Uint16Array(i*r*2*3),u=0,g=0,A=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,p=n*Math.cos(m),_=n*Math.sin(m);for(e=0;e<=i;++e){var B=2*Math.PI*e/i,U=_*Math.cos(B),C=_*Math.sin(B),y=1/Math.sqrt(U*U+p*p+C*C);if(l[u++]=U,l[u++]=p,l[u++]=C,c[g++]=U*y,c[g++]=p*y,c[g++]=C*y,f[A++]=e/i,f[A++]=t/r,e>0&&t>0){var x=(i+1)*t+e,k=(i+1)*t+e-1,E=(i+1)*(t-1)+e-1,S=(i+1)*(t-1)+e;t==r?(h[a++]=x,h[a++]=E,h[a++]=S):t==1?(h[a++]=x,h[a++]=k,h[a++]=E):(h[a++]=x,h[a++]=k,h[a++]=E,h[a++]=x,h[a++]=E,h[a++]=S)}}}this.setIndices(h),this.setAttribute(L.position,l),this.setAttribute(L.normal,c),this.setAttribute(L.uv,f),this.setAttribute(L.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new xe(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class wi extends d.Object3D{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),wi.register3DRepresentation)this.marker=wi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Rr(.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 Ri extends d.Object3D{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new wi(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),Ri.register3DRepresentation?(this.line=Ri.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 Ve,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(L.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new d.Object3D,o=n.addComponent(d.MeshRenderer),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=me.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class Mf extends dt{static format=He.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=fb(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(Tf(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 Ri(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 Nf{_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,_t,t):a=await i.load(e,Ls,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,rf,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,Ys,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,Ks,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 Ha;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?Ce.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(h=>{l.push(h),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 Ws;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 Bn;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 yn;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 Gs;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 Gs;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,qa,t,a),n=i.data;return ti.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new It().load(e,Ff,t,e)).data}async loadKMZ(e,t){return(await new It().load(e,Mf,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 h=new bn;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}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 vf().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Bn,this.defaultSky.createFromTexture(128,this.blackTexture),Ce.getInstance().attached(this.defaultSky,this),Ce.getInstance().attached(t,this),Ce.getInstance().attached(this.normalTexture,this),Ce.getInstance().attached(this.maskTexture,this),Ce.getInstance().attached(this.whiteTexture,this),Ce.getInstance().attached(this.blackTexture,this),Ce.getInstance().attached(this.redTexture,this),Ce.getInstance().attached(this.blueTexture,this),Ce.getInstance().attached(this.greenTexture,this),Ce.getInstance().attached(this.yellowTexture,this),Ce.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new ur(this.whiteTexture),this.defaultGUISprite=new ei(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new Kt}}class Pf extends qe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=D.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=D.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;D.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const db="1.0.29";class D{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 w.presentationSize}static get aspect(){return w.aspect}static get width(){return w.windowWidth}static get height(){return w.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",db),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Ee.init(R.allocCount,this.setting.doublePrecision),await w.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,De.getGBufferFrame(De.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),Z.init(),Xa.init(),Be.init(),Et.init(),Wt.init(),this.res=new Nf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Zo,this.inputSystem.initCanvas(w.canvas)}static startRenderJob(e){let t=new I0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Pf).addPost(xs),(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){Le.delta=e-Le.time,Le.time=e,Le.frame+=1,hr.tick(Le.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=w.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of Pe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=w.device.createCommandEncoder();for(const n of Pe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}w.device.queue.submit([r.finish()]);for(const n of Pe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const n of Pe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];o&&f.enable&&h(o)}}this._renderLoop&&await this._renderLoop(),Ee.updateAllContinueTransform(0,R.useCount,16),Be.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of Pe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let Cn=`
7892
7892
  struct BloomCfg{
7893
7893
  downSampleStep: f32,
7894
7894
  downSampleBlurSize: f32,
@@ -11816,5 +11816,5 @@ fn frag(){
11816
11816
  `);if(t<0)throw new Error("PLY: Invalid PLY header");const a=e.substring(0,t+11),r=a.split(/\r?\n/);let i="",n=0,o=0;const l=[],c=[],f=[];let h=!1,u=!1;for(const m of r)if(m.startsWith("format "))i=m.split(/\s+/)[1];else if(m.startsWith("comment TextureFile ")){const p=m.substring(20).trim();p&&f.push(p)}else if(m.startsWith("element ")){const p=m.split(/\s+/);h=p[1]==="vertex",u=p[1]==="face",h&&(n=parseInt(p[2]),u=!1),u&&(o=parseInt(p[2]),h=!1)}else if(h&&m.startsWith("property ")){const p=m.split(/\s+/),_=p[1],B=p[2];l.push({name:B,type:_})}else if(u&&m.startsWith("property ")){const p=m.split(/\s+/);if(p[1]==="list"){const _=p[2],B=p[3],U=p[4];c.push({name:U,type:`list ${_} ${B}`})}else{const _=p[1],B=p[2];c.push({name:B,type:_})}}if(i!=="binary_little_endian"&&i!=="ascii")throw new Error(`PLY: Unsupported format: ${i}. Only binary_little_endian and ascii are supported.`);let g=0,A=0;for(const m of l)Bo.includes(m.name)&&g++,bh.includes(m.name)&&A++;return{format:i,vertexCount:n,faceCount:o,properties:l,faceProperties:c.length>0?c:void 0,textureFiles:f,headerByteLength:a.length,mode:o?Dr.Mesh:g===Bo.length&&A===3?Dr.Splat:Dr.PointCloud}}function Uo(s){const e=ji(s),{format:t}=e;return t==="ascii"?Jg(s,e):Wg(s,e)}function Wg(s,e){const{vertexCount:t,properties:a,headerByteLength:r}=e,i=new DataView(s,r),n=C=>a.find(y=>y.name===C)!=null,o=C=>a.findIndex(y=>y.name===C),l=new Float32Array(t*3),c=n("scale_0")?new Float32Array(t*3):void 0,f=n("rot_0")?new Float32Array(t*4):void 0,h=n("opacity")?new Float32Array(t):void 0,u=[o("f_dc_0"),o("f_dc_1"),o("f_dc_2")],g=[];for(let C=0;C<a.length;C++)a[C].name.startsWith("f_rest_")&&g.push(C);const A=u[0]>=0&&u[1]>=0&&u[2]>=0;let m,p=0;if(A){const C=1+g.length/3;p=vo(C),m=new Float32Array(t*C*3)}const _=[];let B=0;for(const C of a)_.push(B),B+=fa(C.type);let U=0;for(let C=0;C<t;C++){const y=U,x=o("x"),k=o("y"),E=o("z");if(x<0||k<0||E<0)throw new Error("PLY: Missing x/y/z for vertex");if(l[C*3+0]=_e(i,y+_[x],a[x].type),l[C*3+1]=_e(i,y+_[k],a[k].type),l[C*3+2]=_e(i,y+_[E],a[E].type),c){const S=o("scale_0"),I=o("scale_1"),T=o("scale_2");c[C*3+0]=_e(i,y+_[S],a[S].type),c[C*3+1]=_e(i,y+_[I],a[I].type),c[C*3+2]=_e(i,y+_[T],a[T].type)}if(f){const S=o("rot_0"),I=o("rot_1"),T=o("rot_2"),Q=o("rot_3"),G=_e(i,y+_[S],a[S].type),q=_e(i,y+_[I],a[I].type),ge=_e(i,y+_[T],a[T].type),ie=_e(i,y+_[Q],a[Q].type);f[C*4+0]=q,f[C*4+1]=ge,f[C*4+2]=ie,f[C*4+3]=G}if(h){const S=o("opacity");h[C]=_e(i,y+_[S],a[S].type)}if(A&&m){const S=1+g.length/3,I=C*S*3;m[I+0]=_e(i,y+_[u[0]],a[u[0]].type),m[I+S+0]=_e(i,y+_[u[1]],a[u[1]].type),m[I+2*S+0]=_e(i,y+_[u[2]],a[u[2]].type);let T=1,Q=1,G=1;for(let q=0;q<g.length;q+=3){const ge=g[q+0],ie=g[q+1],P=g[q+2];m[I+T]=_e(i,y+_[ge],a[ge].type),m[I+S+Q]=_e(i,y+_[ie],a[ie].type),m[I+2*S+G]=_e(i,y+_[P],a[P].type),T++,Q++,G++}}U+=B}return{vertexCount:t,position:l,scale:c,rotation:f,opacity:h,sh:A&&m?{order:p,coeffs:m}:void 0}}function Jg(s,e){const{vertexCount:t,properties:a}=e,r=new TextDecoder("utf-8").decode(s),i=r.indexOf("end_header");if(i<0)throw new Error("PLY: Invalid PLY header");let n=i+10;for(;n<r.length&&(r[n]===" "||r[n]===`
11817
11817
  `||r[n]==="\r");)n++;const l=r.substring(n).split(/\s+/).filter(P=>P.length>0);let c=0;const f=P=>a.find(z=>z.name===P)!=null,h=P=>a.findIndex(z=>z.name===P),u=P=>{if(c>=l.length)throw new Error("PLY: Unexpected end of file");const z=l[c++];switch(P){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(z);case"float":case"double":case"float32":case"float64":return parseFloat(z);default:return parseFloat(z)}},g=new Float32Array(t*3),A=f("scale_0")?new Float32Array(t*3):void 0,m=f("rot_0")?new Float32Array(t*4):void 0,p=f("opacity")?new Float32Array(t):void 0,_=[h("f_dc_0"),h("f_dc_1"),h("f_dc_2")],B=[];for(let P=0;P<a.length;P++)a[P].name.startsWith("f_rest_")&&B.push(P);const U=_[0]>=0&&_[1]>=0&&_[2]>=0;let C,y=0;if(U){const P=1+B.length/3;y=vo(P),C=new Float32Array(t*P*3)}const x=h("x"),k=h("y"),E=h("z");if(x<0||k<0||E<0)throw new Error("PLY: Missing x/y/z for vertex");const S=A?h("scale_0"):-1,I=A?h("scale_1"):-1,T=A?h("scale_2"):-1,Q=m?h("rot_0"):-1,G=m?h("rot_1"):-1,q=m?h("rot_2"):-1,ge=m?h("rot_3"):-1,ie=p?h("opacity"):-1;for(let P=0;P<t;P++)for(let z=0;z<a.length;z++){const X=a[z],V=u(X.type);if(z===x?g[P*3+0]=V:z===k?g[P*3+1]=V:z===E&&(g[P*3+2]=V),A&&z===S?A[P*3+0]=V:A&&z===I?A[P*3+1]=V:A&&z===T&&(A[P*3+2]=V),m&&z===Q?m[P*4+3]=V:m&&z===G?m[P*4+0]=V:m&&z===q?m[P*4+1]=V:m&&z===ge&&(m[P*4+2]=V),p&&z===ie&&(p[P]=V),U&&C){const ne=1+B.length/3,W=P*ne*3;z===_[0]?C[W+0]=V:z===_[1]?C[W+ne+0]=V:z===_[2]&&(C[W+2*ne+0]=V);for(let ce=0;ce<B.length;ce+=3){const te=B[ce+0],de=B[ce+1],he=B[ce+2];z===te?C[W+(ce/3+1)]=V:z===de?C[W+ne+(ce/3+1)]=V:z===he&&(C[W+2*ne+(ce/3+1)]=V)}}}return{vertexCount:t,position:g,scale:A,rotation:m,opacity:p,sh:U&&C?{order:y,coeffs:C}:void 0}}function gh(s){const e=ji(s),{format:t,vertexCount:a,faceCount:r,properties:i,faceProperties:n,textureFiles:o,headerByteLength:l}=e;return t==="ascii"?Zg(s,e):jg(s,e)}function jg(s,e){const{vertexCount:t,faceCount:a,properties:r,faceProperties:i,textureFiles:n,headerByteLength:o}=e,l=new DataView(s,o),c=P=>r.find(z=>z.name===P)!=null,f=P=>r.findIndex(z=>z.name===P),h=i?.some(P=>P.name==="texcoord")||!1,u=i?.some(P=>P.name==="texnumber")||!1;i?.find(P=>P.name==="texcoord"),i?.find(P=>P.name==="texnumber");const g=new Float32Array(t*3),A=c("nx")&&c("ny")&&c("nz"),m=A?new Float32Array(t*3):new Float32Array(t*3),p=(c("red")||c("r"))&&(c("green")||c("g"))&&(c("blue")||c("b"))?new Float32Array(t*3):void 0,_=(c("u")||c("s"))&&(c("v")||c("t")),B=_||h?new Float32Array(t*2):void 0,U=new Map,C=u?new Array(a):[],y=[];let x=0;for(const P of r)y.push(x),x+=fa(P.type);let k=0;for(let P=0;P<t;P++){const z=k,X=f("x"),V=f("y"),ne=f("z");if(X<0||V<0||ne<0)throw new Error("PLY: Missing x/y/z for vertex");if(g[P*3+0]=_e(l,z+y[X],r[X].type),g[P*3+1]=_e(l,z+y[V],r[V].type),g[P*3+2]=_e(l,z+y[ne],r[ne].type),A){const W=f("nx"),ce=f("ny"),te=f("nz");m[P*3+0]=_e(l,z+y[W],r[W].type),m[P*3+1]=_e(l,z+y[ce],r[ce].type),m[P*3+2]=_e(l,z+y[te],r[te].type)}if(p){const W=f("red")>=0?f("red"):f("r"),ce=f("green")>=0?f("green"):f("g"),te=f("blue")>=0?f("blue"):f("b");if(W>=0&&ce>=0&&te>=0){let de=_e(l,z+y[W],r[W].type),he=_e(l,z+y[ce],r[ce].type),Ue=_e(l,z+y[te],r[te].type);(r[W].type==="uchar"||r[W].type==="uint8")&&(de/=255,he/=255,Ue/=255),p[P*3+0]=de,p[P*3+1]=he,p[P*3+2]=Ue}}if(B){const W=f("u")>=0?f("u"):f("s"),ce=f("v")>=0?f("v"):f("t");W>=0&&ce>=0&&(B[P*2+0]=_e(l,z+y[W],r[W].type),B[P*2+1]=_e(l,z+y[ce],r[ce].type))}k+=x}const E=[],S=[],I=[];let T=k;B&&!_&&!h&&new Array(t).fill(!1);for(let P=0;P<a;P++){let z=T,X=[],V,ne=0,W=0;if(!i||i.length===0)throw new Error("PLY: Face element must have properties");for(const te of i)if(te.name==="vertex_indices"){const de=te.type.split(" ");if(de.length!==3||de[0]!=="list")throw new Error(`PLY: Invalid vertex_indices property type: ${te.type}`);const he=de[1],Ue=de[2];if(W=_e(l,z,he),z+=fa(he),W<3)throw new Error(`PLY: Face ${P} has less than 3 vertices`);const Ne=fa(Ue);X=[];for(let Ke=0;Ke<W;Ke++){const K=_e(l,z,Ue);X.push(K),z+=Ne}}else if(te.name==="texcoord"){const de=te.type.split(" ");if(de.length!==3||de[0]!=="list")throw new Error(`PLY: Invalid texcoord property type: ${te.type}`);const he=de[1],Ue=de[2],Ne=_e(l,z,he);z+=fa(he);const Ke=fa(Ue);V=new Float32Array(Ne);for(let K=0;K<Ne;K++)V[K]=_e(l,z,Ue),z+=Ke;U.set(P,V)}else if(te.name==="texnumber")ne=_e(l,z,te.type),z+=fa(te.type),C[P]=ne;else if(te.type.startsWith("list ")){const de=te.type.split(" ");if(de.length===3){const he=de[1],Ue=de[2],Ne=_e(l,z,he);z+=fa(he);const Ke=fa(Ue);z+=Ne*Ke}}else z+=fa(te.type);T=z;const ce=u?C[P]??0:0;if(W===3)E.push(X[0],X[1],X[2]),u&&S.push(ce),h&&V&&V.length>=6&&I.push(V[0],1-V[1],V[2],1-V[3],V[4],1-V[5]);else for(let te=1;te<W-1;te++)E.push(X[0],X[te],X[te+1]),u&&S.push(ce),h&&V&&V.length>=W*2&&I.push(V[0],1-V[1],V[te*2+0],1-V[te*2+1],V[(te+1)*2+0],1-V[(te+1)*2+1])}if(!A){for(let P=0;P<t*3;P++)m[P]=0;for(let P=0;P<E.length;P+=3){const z=E[P],X=E[P+1],V=E[P+2],ne=g[z*3+0],W=g[z*3+1],ce=g[z*3+2],te=g[X*3+0],de=g[X*3+1],he=g[X*3+2],Ue=g[V*3+0],Ne=g[V*3+1],Ke=g[V*3+2],K=te-ne,ae=de-W,oe=he-ce,ue=Ue-ne,Re=Ne-W,be=Ke-ce,Se=ae*be-oe*Re,Ie=oe*ue-K*be,Me=K*Re-ae*ue;m[z*3+0]+=Se,m[z*3+1]+=Ie,m[z*3+2]+=Me,m[X*3+0]+=Se,m[X*3+1]+=Ie,m[X*3+2]+=Me,m[V*3+0]+=Se,m[V*3+1]+=Ie,m[V*3+2]+=Me}for(let P=0;P<t;P++){const z=m[P*3+0],X=m[P*3+1],V=m[P*3+2],ne=Math.sqrt(z*z+X*X+V*V);ne>1e-5?(m[P*3+0]=z/ne,m[P*3+1]=X/ne,m[P*3+2]=V/ne):(m[P*3+0]=0,m[P*3+1]=1,m[P*3+2]=0)}}let Q=g,G=m,q=p,ge,ie;if(h&&I.length>0){const P=E.length/3,z=new Float32Array(P*3*3),X=new Float32Array(P*3*3),V=p?new Float32Array(P*3*3):void 0;ge=new Float32Array(I);for(let W=0;W<P;W++){const ce=W*3,te=E[ce+0],de=E[ce+1],he=E[ce+2];z[W*9+0]=g[te*3+0],z[W*9+1]=g[te*3+1],z[W*9+2]=g[te*3+2],z[W*9+3]=g[de*3+0],z[W*9+4]=g[de*3+1],z[W*9+5]=g[de*3+2],z[W*9+6]=g[he*3+0],z[W*9+7]=g[he*3+1],z[W*9+8]=g[he*3+2],X[W*9+0]=m[te*3+0],X[W*9+1]=m[te*3+1],X[W*9+2]=m[te*3+2],X[W*9+3]=m[de*3+0],X[W*9+4]=m[de*3+1],X[W*9+5]=m[de*3+2],X[W*9+6]=m[he*3+0],X[W*9+7]=m[he*3+1],X[W*9+8]=m[he*3+2],V&&p&&(V[W*9+0]=p[te*3+0],V[W*9+1]=p[te*3+1],V[W*9+2]=p[te*3+2],V[W*9+3]=p[de*3+0],V[W*9+4]=p[de*3+1],V[W*9+5]=p[de*3+2],V[W*9+6]=p[he*3+0],V[W*9+7]=p[he*3+1],V[W*9+8]=p[he*3+2])}Q=z,G=X,q=V;const ne=new Uint32Array(P*3);for(let W=0;W<P*3;W++)ne[W]=W;ie=ne}else ie=new Uint32Array(E),ge=B;return{vertexCount:h&&I.length>0?Q.length/3:t,faceCount:a,position:Q,normal:G,color:q,uv:ge,indices:ie,textureFiles:n.length>0?n:void 0,triangleTexnumbers:S.length>0?S:void 0}}function Zg(s,e){const{vertexCount:t,faceCount:a,properties:r,faceProperties:i,textureFiles:n,headerByteLength:o}=e,l=new TextDecoder("utf-8").decode(s),c=l.indexOf("end_header");if(c<0)throw new Error("PLY: Invalid PLY header");let f=c+10;for(;f<l.length&&(l[f]===" "||l[f]===`
11818
11818
  `||l[f]==="\r");)f++;const u=l.substring(f).split(/\s+/).filter(K=>K.length>0);let g=0;const A=K=>r.find(ae=>ae.name===K)!=null,m=K=>{if(g>=u.length)throw new Error("PLY: Unexpected end of file");const ae=u[g++];switch(K){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(ae);case"float":case"double":case"float32":case"float64":return parseFloat(ae);default:return parseFloat(ae)}},p=new Float32Array(t*3),_=A("nx")&&A("ny")&&A("nz"),B=_?new Float32Array(t*3):new Float32Array(t*3),U=(A("red")||A("r"))&&(A("green")||A("g"))&&(A("blue")||A("b"))?new Float32Array(t*3):void 0,C=(A("u")||A("s"))&&(A("v")||A("t")),y=i?.some(K=>K.name==="texcoord")||!1,x=C||y?new Float32Array(t*2):void 0,k=new Map,E=i?.some(K=>K.name==="texnumber")||!1,S=E?new Array(a):[],I=[],T=[],Q=[],G=K=>r.findIndex(ae=>ae.name===K),q=G("x"),ge=G("y"),ie=G("z"),P=_?G("nx"):-1,z=_?G("ny"):-1,X=_?G("nz"):-1,V=U?G("red")>=0?G("red"):G("r"):-1,ne=U?G("green")>=0?G("green"):G("g"):-1,W=U?G("blue")>=0?G("blue"):G("b"):-1,ce=x&&C?G("u")>=0?G("u"):G("s"):-1,te=x&&C?G("v")>=0?G("v"):G("t"):-1;for(let K=0;K<t;K++)for(let ae=0;ae<r.length;ae++){const oe=r[ae],ue=m(oe.type);ae===q?p[K*3+0]=ue:ae===ge?p[K*3+1]=ue:ae===ie?p[K*3+2]=ue:ae===P?B[K*3+0]=ue:ae===z?B[K*3+1]=ue:ae===X?B[K*3+2]=ue:ae===V&&U?U[K*3+0]=oe.type==="uchar"||oe.type==="uint8"?ue/255:ue:ae===ne&&U?U[K*3+1]=oe.type==="uchar"||oe.type==="uint8"?ue/255:ue:ae===W&&U?U[K*3+2]=oe.type==="uchar"||oe.type==="uint8"?ue/255:ue:ae===ce&&x?x[K*2+0]=ue:ae===te&&x&&(x[K*2+1]=ue)}for(let K=0;K<a;K++){let ae=[],oe,ue=0;for(const Se of i||[])if(Se.name==="vertex_indices"){const Ie=Se.type.split(" "),Me=Ie[1],ze=Ie[2],Vt=m(Me);ae=[];for(let ut=0;ut<Vt;ut++)ae.push(m(ze))}else if(Se.name==="texcoord"){const Ie=Se.type.split(" "),Me=Ie[1],ze=Ie[2],Vt=m(Me);oe=new Float32Array(Vt);for(let ut=0;ut<Vt;ut++)oe[ut]=m(ze);k.set(K,oe)}else Se.name==="texnumber"&&(ue=m(Se.type),S[K]=ue);const Re=ae.length,be=E?S[K]??0:0;if(Re===3)I.push(ae[0],ae[1],ae[2]),E&&T.push(be),y&&oe&&oe.length>=6&&Q.push(oe[0],1-oe[1],oe[2],1-oe[3],oe[4],1-oe[5]);else for(let Se=1;Se<Re-1;Se++)I.push(ae[0],ae[Se],ae[Se+1]),E&&T.push(be),y&&oe&&oe.length>=Re*2&&Q.push(oe[0],1-oe[1],oe[Se*2+0],1-oe[Se*2+1],oe[(Se+1)*2+0],1-oe[(Se+1)*2+1])}if(!_){for(let K=0;K<t*3;K++)B[K]=0;for(let K=0;K<I.length;K+=3){const ae=I[K],oe=I[K+1],ue=I[K+2],Re=p[ae*3+0],be=p[ae*3+1],Se=p[ae*3+2],Ie=p[oe*3+0],Me=p[oe*3+1],ze=p[oe*3+2],Vt=p[ue*3+0],ut=p[ue*3+1],ar=p[ue*3+2],xa=Ie-Re,La=Me-be,Ga=ze-Se,ea=Vt-Re,za=ut-be,ha=ar-Se,Mt=La*ha-Ga*za,Fa=Ga*ea-xa*ha,ua=xa*za-La*ea;B[ae*3+0]+=Mt,B[ae*3+1]+=Fa,B[ae*3+2]+=ua,B[oe*3+0]+=Mt,B[oe*3+1]+=Fa,B[oe*3+2]+=ua,B[ue*3+0]+=Mt,B[ue*3+1]+=Fa,B[ue*3+2]+=ua}for(let K=0;K<t;K++){const ae=B[K*3+0],oe=B[K*3+1],ue=B[K*3+2],Re=Math.sqrt(ae*ae+oe*oe+ue*ue);Re>1e-5?(B[K*3+0]=ae/Re,B[K*3+1]=oe/Re,B[K*3+2]=ue/Re):(B[K*3+0]=0,B[K*3+1]=1,B[K*3+2]=0)}}let de=p,he=B,Ue=U,Ne,Ke;if(y&&Q.length>0){const K=I.length/3,ae=new Float32Array(K*3*3),oe=new Float32Array(K*3*3),ue=U?new Float32Array(K*3*3):void 0;Ne=new Float32Array(Q);for(let be=0;be<K;be++){const Se=be*3,Ie=I[Se+0],Me=I[Se+1],ze=I[Se+2];ae[be*9+0]=p[Ie*3+0],ae[be*9+1]=p[Ie*3+1],ae[be*9+2]=p[Ie*3+2],ae[be*9+3]=p[Me*3+0],ae[be*9+4]=p[Me*3+1],ae[be*9+5]=p[Me*3+2],ae[be*9+6]=p[ze*3+0],ae[be*9+7]=p[ze*3+1],ae[be*9+8]=p[ze*3+2],oe[be*9+0]=B[Ie*3+0],oe[be*9+1]=B[Ie*3+1],oe[be*9+2]=B[Ie*3+2],oe[be*9+3]=B[Me*3+0],oe[be*9+4]=B[Me*3+1],oe[be*9+5]=B[Me*3+2],oe[be*9+6]=B[ze*3+0],oe[be*9+7]=B[ze*3+1],oe[be*9+8]=B[ze*3+2],ue&&U&&(ue[be*9+0]=U[Ie*3+0],ue[be*9+1]=U[Ie*3+1],ue[be*9+2]=U[Ie*3+2],ue[be*9+3]=U[Me*3+0],ue[be*9+4]=U[Me*3+1],ue[be*9+5]=U[Me*3+2],ue[be*9+6]=U[ze*3+0],ue[be*9+7]=U[ze*3+1],ue[be*9+8]=U[ze*3+2])}de=ae,he=oe,Ue=ue;const Re=new Uint32Array(K*3);for(let be=0;be<K*3;be++)Re[be]=be;Ke=Re}else Ke=new Uint32Array(I),Ne=x;return{vertexCount:y&&Q.length>0?de.length/3:t,faceCount:a,position:de,normal:he,color:Ue,uv:Ne,indices:Ke,textureFiles:n.length>0?n:void 0,triangleTexnumbers:T.length>0?T:void 0}}function mh(s){const e=ji(s),{format:t}=e;return t==="ascii"?Xg(s,e):Yg(s,e)}function Yg(s,e){const{vertexCount:t,properties:a,headerByteLength:r}=e,i=new DataView(s,r),n=m=>a.find(p=>p.name===m)!=null,o=m=>a.findIndex(p=>p.name===m),l=new Float32Array(t*3),c=(n("red")||n("r"))&&(n("green")||n("g"))&&(n("blue")||n("b")),f=n("alpha")||n("a"),h=c?new Uint8Array(t*4):void 0,u=[];let g=0;for(const m of a)u.push(g),g+=fa(m.type);let A=0;for(let m=0;m<t;m++){const p=A,_=o("x"),B=o("y"),U=o("z");if(_<0||B<0||U<0)throw new Error("PLY: Missing x/y/z for vertex");if(l[m*3+0]=_e(i,p+u[_],a[_].type),l[m*3+1]=_e(i,p+u[B],a[B].type),l[m*3+2]=_e(i,p+u[U],a[U].type),h){const C=o("red")>=0?o("red"):o("r"),y=o("green")>=0?o("green"):o("g"),x=o("blue")>=0?o("blue"):o("b"),k=f?o("alpha")>=0?o("alpha"):o("a"):-1;if(C>=0&&y>=0&&x>=0){let E=_e(i,p+u[C],a[C].type),S=_e(i,p+u[y],a[y].type),I=_e(i,p+u[x],a[x].type),T=255;(a[C].type==="float"||a[C].type==="float32"||a[C].type==="double"||a[C].type==="float64")&&(E=Math.round(E*255),S=Math.round(S*255),I=Math.round(I*255)),k>=0&&(T=_e(i,p+u[k],a[k].type),(a[k].type==="float"||a[k].type==="float32"||a[k].type==="double"||a[k].type==="float64")&&(T=Math.round(T*255))),h[m*4+0]=Math.max(0,Math.min(255,E)),h[m*4+1]=Math.max(0,Math.min(255,S)),h[m*4+2]=Math.max(0,Math.min(255,I)),h[m*4+3]=Math.max(0,Math.min(255,T))}}A+=g}return{vertexCount:t,position:l,color:h}}function Xg(s,e){const{vertexCount:t,properties:a}=e,r=new TextDecoder("utf-8").decode(s),i=r.indexOf("end_header");if(i<0)throw new Error("PLY: Invalid PLY header");let n=i+10;for(;n<r.length&&(r[n]===" "||r[n]===`
11819
- `||r[n]==="\r");)n++;const l=r.substring(n).split(/\s+/).filter(E=>E.length>0);let c=0;const f=E=>a.find(S=>S.name===E)!=null,h=E=>{if(c>=l.length)throw new Error("PLY: Unexpected end of file");const S=l[c++];switch(E){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(S);case"float":case"double":case"float32":case"float64":return parseFloat(S);default:return parseFloat(S)}},u=new Float32Array(t*3),g=(f("red")||f("r"))&&(f("green")||f("g"))&&(f("blue")||f("b")),A=f("alpha")||f("a"),m=g?new Uint8Array(t*4):void 0,p=E=>a.findIndex(S=>S.name===E),_=p("x"),B=p("y"),U=p("z"),C=g?p("red")>=0?p("red"):p("r"):-1,y=g?p("green")>=0?p("green"):p("g"):-1,x=g?p("blue")>=0?p("blue"):p("b"):-1,k=A?p("alpha")>=0?p("alpha"):p("a"):-1;for(let E=0;E<t;E++){for(let S=0;S<a.length;S++){const I=a[S],T=h(I.type);if(S===_)u[E*3+0]=T;else if(S===B)u[E*3+1]=T;else if(S===U)u[E*3+2]=T;else if(S===C&&m){const Q=I.type==="uchar"||I.type==="uint8"?T:Math.round(T*255);m[E*4+0]=Math.max(0,Math.min(255,Q))}else if(S===y&&m){const Q=I.type==="uchar"||I.type==="uint8"?T:Math.round(T*255);m[E*4+1]=Math.max(0,Math.min(255,Q))}else if(S===x&&m){const Q=I.type==="uchar"||I.type==="uint8"?T:Math.round(T*255);m[E*4+2]=Math.max(0,Math.min(255,Q))}else if(S===k&&m){const Q=I.type==="uchar"||I.type==="uint8"?T:Math.round(T*255);m[E*4+3]=Math.max(0,Math.min(255,Q))}}m&&k<0&&(m[E*4+3]=255)}return{vertexCount:t,position:u,color:m}}class Hg extends dt{static format=He.BIN;async parseBuffer(e){const t=uh(e);let a;switch(t){case ci.PLY:{const r=Uo(e);a={count:r.vertexCount,position:r.position,rotation:r.rotation,scale:r.scale,opacity:r.opacity,sh:r.sh},a.bbox=_o(r.position);break}case ci.SPLAT:throw new Error("SPLAT format is not yet supported");case ci.KSPLAT:throw new Error("KSPLAT format is not yet supported");case ci.UNKNOWN:default:throw new Error("Unknown or unsupported Gaussian Splatting file format")}return this.data=a,a}verification(){return!!this.data&&this.data.count>0}}var Qn=(s=>(s.Point="Point",s.LineString="LineString",s.MultiPolygon="MultiPolygon",s))(Qn||{});class Kg extends dt{static format=He.JSON;json;async parseString(e){this.json=e,this.data=JSON.parse(e)}}class qg{static getPath(e){let t=[];for(let a=0;a<e.features.length;a++){const r=e.features[a];switch(r.geometry.type){case Qn.LineString:break;case Qn.MultiPolygon:let i=[];for(let n=0;n<r.geometry.coordinates.length;n++){const o=r.geometry.coordinates[n];for(const l of o)for(const c of l){let f=new b(c[0],0,c[1]);i.push(f)}}t.push(i);break}}return t}}class $g{name;defines;doubleSided;baseColorFactor;emissiveFactor;metallicFactor;roughnessFactor;alphaCutoff;enableBlend;baseColorTexture;metallicRoughnessTexture;normalTexture;occlusionTexture;emissiveTexture;extensions;baseMapOffsetSize;normalMapOffsetSize;emissiveMapOffsetSize;roughnessMapOffsetSize;metallicMapOffsetSize;aoMapOffsetSize}class em{}class tm{}class am extends dt{static format=He.BIN;async parseBuffer(e){switch(ji(e).mode){case Dr.Splat:{const a=Uo(e),r={count:a.vertexCount,position:a.position,rotation:a.rotation,scale:a.scale,opacity:a.opacity,sh:a.sh};r.bbox=_o(a.position);const i=new d.Object3D;i.name="GaussianSplat",i.addComponent(d.GSplatRenderer).initAsset(r),this.data=i;break}case Dr.PointCloud:{const a=mh(e),r=new d.Object3D;r.name="PLYPointCloud";const i=new d.Object3D;i.name="PLYPointCloudRoot",r.addChild(i);const n=i.addComponent(d.PointCloudRenderer);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 Dr.Mesh:{const a=gh(e),r=new d.Object3D;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 Kt,f=Rt.normalizePath(this.baseUrl+a.textureFiles[l]);o.push(D.res.loadTexture(f).then(h=>{c.baseMap=h,n.set(l,c)}))}await Promise.all(o)}n.size===0&&n.set(0,new Kt);for(const[o,l]of i){const c=[];for(const A of l){const m=A*3;c.push(a.indices[m+0],a.indices[m+1],a.indices[m+2])}const f=new Ve;f.setAttribute(L.position,a.position),f.setAttribute(L.normal,a.normal),a.uv&&f.setAttribute(L.uv,a.uv),a.color&&f.setAttribute(L.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 h=n.get(o);h||(h=n.values().next().value||new Kt);const u=new d.Object3D;u.name=`PLYMesh_Texture_${o}`;const g=u.addComponent(d.MeshRenderer);g.geometry=f,g.material=h,r.addChild(u)}this.data=r;break}}}verification(){return!!this.data}}class ph{async parse(e){const t=new DataView(e),a=Un(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,h=new xi(e,f,n,o),u=f+n+o,g=h.header.POINTS_LENGTH||0,A=new vn(e,g,u,l,c);return{version:r,featureTable:h,batchTable:A}}}class Ah extends ph{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 g=await this.parseDraco(a,o,i);l=g.positions,c=g.colors,g.normals}else l=this.parsePositions(a,i),c=this.parseColors(a,i),this.parseNormals(a,i);const f=new d.Object3D;f.addComponent(d.PointCloudRenderer).initFromData(l,c,i);const u=a.getData("RTC_CENTER",1,"FLOAT","VEC3");return u&&f.transform.localPosition.set(u[0],u[1],u[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,h=c*4;l[h+0]=r[f+0],l[h+1]=r[f+1],l[h+2]=r[f+2],l[h+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]),h=c*4;l[h+0]=f[0],l[h+1]=f[1],l[h+2]=f[2],l[h+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 h,u;f<0?(h=(l>=0?1:-1)*(1-Math.abs(c)),u=(c>=0?1:-1)*(1-Math.abs(l))):(h=l,u=c);const g=Math.sqrt(h*h+u*u+f*f),A=r*3;a[A+0]=h/g,a[A+1]=u/g,a[A+2]=f/g}return a}async parseDraco(e,t,a){throw new Error("Draco compression not yet implemented")}}class Dh extends dt{static format=He.BIN;async parseBuffer(e){const a=await new Ah().parse(e),r=new d.Object3D;r.name="PNTS",r.addChild(a),this.data=r}verification(){if(this.data)return!0;throw new Error("PNTSParser: Parse failed")}}class yo{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 Co{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 yo;a.formBytes(e.readBytesArray()),this.boneData[t]=a,this.boneMap.set(a.boneName,a)}}}class _h extends dt{static format=He.BIN;static parser(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new Co;i.formBytes(e.readBytesArray()),D.res.addObj(i.name,i)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}L.position,L.normal,L.color,L.TANGENT,L.uv,L.TEXCOORD_1,L.TEXCOORD_2,L.TEXCOORD_2,L.TEXCOORD_4,L.TEXCOORD_5,L.TEXCOORD_6,L.TEXCOORD_7,L.joints0,L.weights0;var Y=(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))(Y||{});class Tn{static GetMaterial(e){let t=e,a=t.split("/");t=a[a.length-1],a=t.split("."),t=a[a.length-1];let r=Ho(t);if(r){let i=new Dt;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 Y.color:case Y.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 Y.single:case Y.float:case Y.int:case Y.int16:case Y.int32:case Y.uint:case Y.uint32:case Y.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 Y.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 Y.vector2:case Y.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 Y.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 Y.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 Na{static parser(e){switch(e.readInt32()){case Y.single:return{t:Y.single,v:e.readFloat32()};case Y.boolean:return{t:Y.boolean,v:e.readBoolean()};case Y.int:return{t:Y.int,v:e.readInt32()};case Y.int16:return{t:Y.int16,v:e.readInt16()};case Y.int32:return{t:Y.int32,v:e.readInt32()};case Y.float:return{t:Y.float,v:e.readFloat32()};case Y.long:return{t:Y.long,v:e.readFloat64()};case Y.uint:return{t:Y.uint,v:e.readUnit32()};case Y.uint32:return{t:Y.uint32,v:e.readUnit32()};case Y.uint64:return{t:Y.uint64,v:e.readUnit32()};case Y.double:return{t:Y.double,v:e.readFloat64()};case Y.string:return{t:Y.string,v:e.readUTF()};case Y.singleArray:return{t:Y.singleArray,v:e.readFloatArray()};case Y.stringArray:return{t:Y.stringArray,v:e.readStringArray()};case Y.floatArray:return{t:Y.floatArray,v:e.readFloatArray()};case Y.vector2:return{t:Y.vector2,v:e.readVector2()};case Y.vector3:return{t:Y.vector3,v:e.readVector3()};case Y.vector4:return{t:Y.vector4,v:e.readVector4()};case Y.color:return{t:Y.color,v:e.readColor()};case Y.color32:return{t:Y.color32,v:e.readColor()};case Y.animationCurve:return{t:Y.animationCurve,v:null};case Y.quaternion:return{t:Y.quaternion,v:e.readQuaternion()};case Y.matrix4x4:return{t:Y.matrix4x4,v:null};case Y.mesh:{let o=e.readUTF(),l=D.res.getGeometry(o);return{t:Y.mesh,v:l}}case Y.texture:{let o=e.readUTF(),l=D.res.getTexture(o);return{t:Y.texture,v:l}}case Y.material:{let o=e.readUTF(),l=D.res.getMat(o);return{t:Y.material,v:l}}case Y.materials:{let o=e.readStringArray(),l=[];for(let c=0;c<o.length;c++){const f=o[c];let h=D.res.getMat(f);l.push(h)}return{t:Y.materials,v:l}}case Y.skeleton:break;case Y.animClip:{let o=[],l=e.readInt32();for(let c=0;c<l;c++){let f=new Vo;f.formBytes(e),o.push(f)}return{t:Y.animClip,v:o}}case Y.vector2Int:return{t:Y.vector2Int,v:e.readVector2int()};case Y.int32List:return{t:Y.int32List,v:e.readInt32List()};case Y.colorList:let a=e.readInt32(),r=[];for(let o=0;o<a;o++){const l=Na.parser(e).v;r.push(l)}return{t:Y.colorList,v:r};case Y.color32List:let i=e.readInt32(),n=[];for(let o=0;o<i;o++){const l=Na.parser(e).v;n.push(l)}return{t:Y.color32List,v:n}}}}class So{key;type;_data;getValue(){return this._data}formBytes(e){this.key=e.readUTF();let{t,v:a}=Na.parser(e);this.type=t,this._data=a}}class Bh{property;name;texture;texelSize;wrapModeU;wrapModeV;wrapModeW;wrapMode;anisoLevel;dimension;filterMode}class vh extends dt{static format=He.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=[],h=[],u=i.readInt32();for(let m=0;m<u;m++){let p=new So;p.formBytes(i),f.push(p)}let g=i.readInt32();for(let m=0;m<g;m++){let p=i.readBytesArray(),_=new Bh;_.property=p.readUTF(),_.name=p.readUTF(),_.texture=D.res.getTexture(_.name),_.texelSize=p.readVector2(),_.wrapModeU=p.readUnit32(),_.wrapModeV=p.readUnit32(),_.wrapModeW=p.readUnit32(),_.wrapMode=p.readUnit32(),_.anisoLevel=p.readUnit32(),_.dimension=p.readUnit32(),_.filterMode=p.readUnit32(),h.push(_)}let A=Tn.GetMaterial(c);A.name=n;for(let m=0;m<l.length;m++){const p=l[m];A.shader.setDefine(p,!0)}Tn.applyMaterialTexture(A,h),Tn.applyMaterialProperties(A,f),D.res.addMat(o,A)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class xo{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 Fo{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 xo;r.formBytes(t),this.blendShapePropertyDatas.push(r),this.blendShapeMap.set(r.shapeName,r)}return e}}class Uh{name;meshName;meshID;vertexCount;vertexStrip;vertexBuffer;indices;attributes;bones;bindPose;blendShapeData}class yh extends dt{static format=He.BIN;async parseBuffer(e){}static parserMeshs(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new Uh,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 Fo,i.blendShapeData.formBytes(n));let c=n.readBytesArray(),f=n.readBytesArray(),h=c.readInt32(),u=0,g=[];for(let B=0;B<h;B++)g[B]={},g[B].att=rm[c.readUTF()],g[B].dim=c.readInt32(),u+=g[B].dim,g[B].format=c.readUTF();i.vertexCount=c.readInt32(),i.vertexBuffer=f.getFloat32Array();let A=n.readInt32Array(),m=[],p=n.readInt32();for(let B=0;B<p;B++){let U=n.readInt32(),C=n.readInt32(),y=n.readInt32(),x=n.readInt32(),k=n.readInt32(),E=n.readInt32();n.readVector3(),n.readVector3();let S={indexStart:C,indexCount:y,vertexStart:x,vertexCount:E,firstStart:k,topology:U,index:B};m.push(S)}A.length>65535?i.indices=new Uint32Array(A):i.indices=new Uint16Array(A);let _=new Ve;if(_.vertexDim=u,_.geometryType=Ft.compose_bin,_.setIndices(i.indices),_.setAttribute(L.all,i.vertexBuffer),o&&(_.skinNames=i.bones,_.bindPose=i.bindPose),l){_.blendShapeData=i.blendShapeData,_.morphTargetsRelative=!0,_.morphTargetDictionary={};for(let B=0;B<i.blendShapeData.blendCount;B++){_.setAttribute("a_morphPositions_"+B,i.blendShapeData.blendShapePropertyDatas[B].blendPositionList),_.setAttribute("a_morphNormals_"+B,i.blendShapeData.blendShapePropertyDatas[B].blendNormalList);for(let U=0;U<i.blendShapeData.blendCount;U++){let C=i.blendShapeData.shapeNames[U],y=i.blendShapeData.shapeIndexs[U];_.morphTargetDictionary[C]=y}}}for(let B=0;B<g.length;B++){const U=g[B].att;_.setAttribute(U,null)}for(let B=0;B<m.length;B++){const U=m[B];_.addSubGeometry(U)}_.name=i.meshName,D.res.addGeometry(i.meshID,_)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}let rm={Position:L.position,Normal:L.normal,Color:L.color,Tangent:L.TANGENT,TexCoord0:L.uv,TexCoord1:L.TEXCOORD_1,TexCoord2:L.TEXCOORD_2,TexCoord3:L.TEXCOORD_2,TexCoord4:L.TEXCOORD_4,TexCoord5:L.TEXCOORD_5,TexCoord6:L.TEXCOORD_6,TexCoord7:L.vIndex,BlendIndices:L.joints0,BlendWeight:L.weights0};class Mn 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 Mn(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 le;return e.x=this.readInt32(),e.y=this.readInt32(),e}readVector2(){let e=new le;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 fe;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 ee;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 Ch extends dt{static format=He.TEXT;static async parserTexture(e,t,a){let r=e.readInt32(),i=[];for(let o=0;o<r;o++){let l=e.readUTF();Sh.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 D.res.loadBitmapTextures(i,D.setting.loader.numConcurrent,a,!0);for(const o of n)D.res.addTexture(o.name,o)}verification(){if(this.data)return!0;throw new Error("verify failed.")}}var im=Object.getOwnPropertyDescriptor,nm=(s,e,t,a)=>{for(var r=a>1?void 0:a?im(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.LitSSSShader=class extends gt{constructor(){super(),Z.register("PBRLitSSSShader",bd);let e=new Xe("PBRLitSSSShader","PBRLitSSSShader");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.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 nh(this)]}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new fe(0,0,1,1)),this.setUniformVector4("transformUV2",new fe(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformColor("emissiveColor",new J(1,1,1)),this.setUniformVector4("materialF0",new fe(.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(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _SSSMap(e){this.setTexture("sssMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Nt.none:t.shaderState.cullMode}set _SkinColor(e){this.setUniformColor("skinColor",e)}set _SkinPower(e){this.setUniformFloat("skinPower",e)}set _SkinColorIns(e){this.setUniformFloat("skinColorIns",e)}set curveFactor(e){this.setUniformFloat("curveFactor",e)}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=me.NONE:t.blendMode=me.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.LitSSSShader=nm([wa(d.LitSSSShader,"LitSSSShader")],d.LitSSSShader);var sm=Object.getOwnPropertyDescriptor,om=(s,e,t,a)=>{for(var r=a>1?void 0:a?sm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.LitShader=class extends gt{constructor(){super();let e=new Xe("PBRLItShader","PBRLItShader");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.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 fe(0,0,1,1)),this.setUniformVector4("transformUV2",new fe(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformColor("emissiveColor",new J(0,0,0)),this.setUniformVector4("materialF0",new fe(.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=D.res.grayTexture,this._BumpMap=D.res.normalTexture,this._MaskTex=D.res.maskTexture}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Nt.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=me.NONE:t.blendMode=me.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.LitShader=om([wa(d.LitShader,"LitShader")],d.LitShader);class Nn{comName;data;static parser(e){let t=e.readBytesArray(),a=new Nn;a.comName=t.readUTF(),a.data=[];let r=t.readInt32();for(let i=0;i<r;i++){let n=new So;n.formBytes(t),a.data.push(n)}return a}}class Zi{name;parentName;position;rotation;scale;comDatas;child;static parser(e){let t=e.readBytesArray(),a=new Zi;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=Nn.parser(t);a.comDatas.push(o)}let i=t.readInt32();for(let n=0;n<i;n++){const o=Zi.parser(t);a.child.push(o)}return a}}class Sh extends dt{static useWebp=!0;static format=He.BIN;avatarDic;nodeData;async parseBuffer(e){this.avatarDic={};let t=new Mn(e,0);await Ch.parserTexture(t,this,this.loaderFunctions),_h.parser(t,this),yh.parserMeshs(t,this),vh.parserMaterial(t,this),this.nodeData=this.parserPrefabNode(t),this.data=this.data=this.parserNodeTree(this.nodeData)}parserPrefabNode(e){return Zi.parser(e)}parserNodeTree(e){let t=new d.Object3D;if(t.localPosition=b.serialize(e.position),t.localQuaternion=ee.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=Xo(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 lm{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 cm=Object.getOwnPropertyDescriptor,fm=(s,e,t,a)=>{for(var r=a>1?void 0:a?cm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.FatLineShader=class extends gt{constructor(){super();const e=new Xe("FatLine_VS","FatLine_FS");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);const t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1,t.cullMode=Nt.none,t.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 le(1920,1080));const e=new R;this.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}},d.FatLineShader=fm([wa(d.FatLineShader,"FatLineShader")],d.FatLineShader);var dm=Object.getOwnPropertyDescriptor,hm=(s,e,t,a)=>{for(var r=a>1?void 0:a?dm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.UnLitShader=class extends gt{constructor(){super();let e=new Xe("UnLit","UnLit");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.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 fe(0,0,1,1)),this.setUniformVector4("transformUV2",new fe(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformFloat("alphaCutoff",0)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Nt.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=me.NONE:t.blendMode=me.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.UnLitShader=hm([wa(d.UnLitShader,"UnLitShader")],d.UnLitShader);var um=Object.getOwnPropertyDescriptor,bm=(s,e,t,a)=>{for(var r=a>1?void 0:a?um(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.UnLitTexArrayShader=class extends gt{constructor(){super(),Z.register("VertexAttributeIndexShader",dd),Z.register("UnLitTextureArray",gd);let e=new Xe("UnLitTextureArray","UnLitTextureArray");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.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 fe(0,0,1,1)),this.setUniformVector4("transformUV2",new fe(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformFloat("alphaCutoff",0)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Nt.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=me.NONE:t.blendMode=me.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.UnLitTexArrayShader=bm([wa(d.UnLitTexArrayShader,"UnLitTexArrayShader")],d.UnLitTexArrayShader);const _r=-1,Br=0,ko=1,xh=2,Pa=3,gm=6378137,mm=1/298.257223563,pm=6356752314245179e-9,Am=Symbol("PLUGIN_REGISTERED");class Eo{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 Fh=2**30;class kh{minSize=6e3;maxSize=8e3;minBytesSize=.3*Fh;maxBytesSize=.4*Fh;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 wo{maxJobs=6;autoUpdate=!0;priorityCallback=null;_items=[];_callbacks=new Map;_currJobs=0;_scheduled=!1;_schedulingCallback;constructor(){this._schedulingCallback=e=>{requestAnimationFrame(e)}}set schedulingCallback(e){this._schedulingCallback=e}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),this.autoUpdate&&this._scheduleJobRun(),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))}_scheduleJobRun(){this._scheduled||(this._scheduled=!0,this._schedulingCallback(()=>{this._scheduled=!1,this._tryRunJobs()}))}_tryRunJobs(){this.sort();const e=this.maxJobs;let t=0;const a=()=>{this._currJobs--,this.autoUpdate&&this._scheduleJobRun()};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 Eh(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 Dm(s,e){let t=s;for(;t;){const a=t.depth,r=t.parent;e(t,r,a),t=r}}const Pn={inView:!1,error:1/0,distanceFromCamera:1/0},wh=!0;function Rh(s){return s===Pa||s===_r}function vr(s,e){return s.lastFrameVisited===e&&s.used}function Ih(s){return s.childrenProcessed===s.children.length}function Ro(s){return s.hasUnrenderableContent||s.parent!==null&&s.parent.geometricError<s.geometricError}function Io(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,Pn),s.inFrustum=Pn.inView,s.error=Pn.error,s.distanceFromCamera=Pn.distanceFromCamera)}function Qo(s,e,t=!1){s.used||(t||(s.used=!0,e.stats.used++),e.markTileUsed(s),s.inFrustum===!0&&e.stats.inFrustum++)}function _m(s,e){if(s.canTraverse&&s.canTraverseFrame===e.frameCount)return s.canTraverse;let t=!1;return s.error<=e.errorTarget&&!Ro(s)||s.depth>=e.maxDepth||!s.children||s.children.length===0?t=!1:t=!0,s.canTraverse=t,s.canTraverseFrame=e.frameCount,t}function To(s,e,t=!1){if(e.ensureChildrenArePreprocessed(s),Io(s,e),Qo(s,e,t),Ro(s)&&Ih(s)){const a=s.children;for(let r=0,i=a.length;r<i;r++)To(a[r],e,t)}}function Vn(s,e){if(e.ensureChildrenArePreprocessed(s),Io(s,e),!s.inFrustum)return;if(!_m(s,e)){Qo(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];Vn(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];Vn(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++)To(a[n],e,!0);return}if(Qo(s,e),s.refine==="REPLACE"&&(r&&s.depth!==0||wh))for(let n=0,o=a.length;n<o;n++)To(a[n],e)}function Mo(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(Mo(l,e),vr(l,t)){const c=!Ro(l);let f=!l.hasContent||l.hasRenderableContent&&Rh(l.loadingState)||l.hasUnrenderableContent&&l.loadingState===_r;f=c&&f||l.allChildrenReady,i=i&&f}}s.allChildrenReady=i}}function Qh(s,e){if(e.ensureChildrenArePreprocessed(s),vr(s,e.frameCount)&&(s.hasContent&&e.queueTileForDownload(s),Ih(s))){const t=s.children;for(let a=0,r=t.length;a<r;a++)Qh(t[a],e)}}function No(s,e){const t=e.stats;if(!vr(s,e.frameCount))return;if(s.isLeaf){s.loadingState===Pa?(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=Rh(s.loadingState)&&r,n=(e.errorTarget+1)*(e.errorThreshold||1),o=s.error<=n,l=s.refine==="ADD",c=s.allChildrenReady||s.depth===0&&!wh;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,h=a.length;f<h;f++){const u=a[f];vr(u,e.frameCount)&&Qh(u,e)}else for(let f=0,h=a.length;f<h;f++)No(a[f],e)}function Po(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):Io(s,e),s.hasRenderableContent&&s.loadingState===Pa){const n=s.__wasSetVisible;s.__wasSetActive!==a&&(e.setTileActive(s,a),s.__wasSetActive=a),n!==r&&(e.setTileVisible(s,r),s.__wasSetVisible=r)}s.usedLastFrame=t;const i=s.children;for(let n=0,o=i.length;n<o;n++)Po(i[n],e)}}class Pr{static s_tmpMatrix=null;_type;_data;_box;get box(){return this._box}_sphere;_matrix;constructor(e){if(Pr.s_tmpMatrix||(Pr.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(),h=i.clone().normalize();this._matrix=new R;const u=this._matrix.rawData;u[0]=c.x,u[1]=c.y,u[2]=c.z,u[3]=0,u[4]=f.x,u[5]=f.y,u[6]=f.z,u[7]=0,u[8]=h.x,u[9]=h.y,u[10]=h.z,u[11]=0,u[12]=t.x,u[13]=t.y,u[14]=t.z,u[15]=1;const g=new b(n*2,o*2,l*2);this._box=new xe(new b(0,0,0),g)}_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 Ir(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 xe(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=Pr.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 xe;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 xe;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 xe;return this.getAABB(a,t),e.containsBox2(a)>0}else if(this._box){const a=new xe;return this.getAABB(a,t),e.containsBox2(a)>0}return!1}}const Th=(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},Mh=(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 Bm{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;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 kh,this.lruCache.unloadPriorityCallback=Mh,this.loadQueue=new wo,this.loadQueue.maxJobs=10,this.loadQueue.priorityCallback=Th,this.processNodeQueue=new wo,this.processNodeQueue.maxJobs=25,this.group=new d.Object3D,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=ko,this.isLoading=!0,this._loadRootTileSet().then(c=>{if(this.rootLoadingState=Pa,this.rootTileSet=c,c.root){const f=this._getBasePath(this.rootURL||""),h=this.preprocessNode(c.root,f,null);this._root=h;const u=new Pr(h.boundingVolume),g=new Ir;u.getSphere(g);const A=new xe;if(u.getAABB(A),this.rtcOffset=new b(-g.center.x,-g.center.y,-g.center.z),this.onRootTileLoaded)try{this.onRootTileLoaded({center:g.center,radius:g.radius,boundingBox:A,rtcOffset:this.rtcOffset})}catch(m){console.warn("Failed to calculate bounding volume for root tile:",m)}}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(),Vn(n,this),Mo(n,this),No(n,this),Po(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,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&&Eh(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,h=1/0;const u=a.worldTransform;for(let g=0,A=r.length;g<A;g++){const m=i[g];let p,_;if(m.isOrthographic){const U=m.pixelSize;p=e.geometricError/U,_=1/0}else{const U=m.sseDenominator;_=n.distanceToPoint(m.position,u),p=_===0?1/0:e.geometricError/(_*U)}const B=i[g].frustum;n.intersectsFrustum(B,u)&&(o=!0,l=Math.max(l,p),c=Math.min(c,_)),f=Math.max(f,p),h=Math.min(h,_)}o?(t.inView=!0,t.error=l,t.distanceFromCamera=c):(t.inView=!1,t.error=f,t.distanceFromCamera=h)}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 cs,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===at.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 Eo?r=e:r=new Eo(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 Pr(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,h=[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 A of h)A.applyMatrix4(n);const u=new xe;h.forEach(A=>{u.expandByPoint(A)}),n.rawData[12]=-c.x,n.rawData[13]=-c.y,n.rawData[14]=-c.z;const g=u.min;n.rawData[13]-=g.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],h=this.preprocessNode(f,t,r);r.children.push(h)}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=ko,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=xh;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,Ys,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"i3dm":{o=(await l.load(n,Ks,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"glb":case"gltf":{o=(await l.load(n,_t,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"pnts":{o=(await l.load(n,Dh,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"json":try{const c=await D.res.loadJSON(n);e.children.length=0,e.childrenProcessed=0;const f=this._getBasePath(n);if(c.root){const h=this.preprocessNode(c.root,f,e);e.children.push(h),e.childrenProcessed=1,this.dispatchEvent({type:"load-tile-set",tileSet:c,url:n})}e.loadingState=Pa;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,e.loadingState=Pa;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 h=f.cached.scene;h.parent&&h.parent.object3D.removeChild(h),h.destroy(!0),f.cached.scene=null}f.loadingState=Br}),e.active&&this.setTileActive(e,!0)}else e.loadingState=_r,this.stats.failed++}markTileUsed(e){this._usedSet.add(e),this.lruCache.markUsed(e)}setTileActive(e,t){t?this._activeTiles.add(e):this._activeTiles.delete(e);const a=e.cached.scene;a&&(t?(this.group.entityChildren.includes(a)||(a.parent&&a.parent.object3D.removeChild(a),this.group.addChild(a)),e.cached.worldTransform&&this._applyWorldTransform(a.transform,e.cached.worldTransform),a.transform.enable=!0):a.transform.enable=!1)}setTileVisible(e,t){t?this._visibleTiles.add(e):this._visibleTiles.delete(e);const a=e.cached.scene;a&&(a.transform.enable=t)}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 D.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(ra.EULER_ANGLES);e.localPosition=a[0];const r=new ee;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(ra.EULER_ANGLES);e.localPosition=a[0];const r=new ee;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===Pa&&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===Pa&&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===Pa&&t.cached.scene&&e(t.cached.scene,t),!1),null)}_estimateBytesUsed(e){let t=0;return e.forChild(a=>{const r=a.getComponent(d.MeshRenderer);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 vm{asset;extras;geometricError;properties;refine;root;extensionsUsed;extensionsRequired;extensions}class Um{boundingVolume;children;geometricError;transform;content;contents;refine;extensions;extras}class ym{boundingVolume;geometricError;refine;content;contents;children;transform;extensions;extras}class Cm{uri;group;metadata}class Sm{class;properties}function xm(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 Fm extends Dt{static count=0;constructor(){super(),Z.register("ColorLitShader",hd),this.shader=new gt;let e=new Xe("ColorLitShader","ColorLitShader");e.passType=se.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",D.res.normalTexture),e.setTexture("emissiveMap",D.res.blackTexture)}clone(){return null}debug(){}}class km extends Dt{constructor(){super(),this.shader=new d.FatLineShader,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 Em extends Dt{constructor(){super();let e=new Xe("LambertShader","LambertShader");e.setShaderEntry("VertMain","FragMain"),e.passType=se.COLOR,e.setUniformVector4("transformUV1",new fe(0,0,1,1)),e.setUniformVector4("transformUV2",new fe(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 gt;a.addRenderPass(e),this.shader=a,this.baseMap=D.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 wm(s,e){}class Rm extends Dt{constructor(){super(),this.shader=new d.UnLitTexArrayShader,this.baseMap=D.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 Vo{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 Ur;n.formBytes(e),this.positionCurves.set(n.path,n)}}let t=e.readInt32();for(let r=0;r<t;r++){let i=new Ur;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 Ur;n.formBytes(e),this.scaleCurves.set(n.path,n)}}let a=e.readInt32();for(let r=0;r<a;r++){let i=new Ur;i.formBytes(e),this.floatCurves.set(i.attribute,i)}}}class Ur{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 Qi;switch(this.k){case 1:this._cacheValue=0;break;case 2:this._cacheValue=new le;break;case 3:this._cacheValue=new b;break;case 4:this._cacheValue=new fe;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);ee.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),ee.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),ee.HELP_2.slerp(ee.HELP_0,ee.HELP_1,o),this._cacheValue.x=ee.HELP_2.x,this._cacheValue.y=ee.HELP_2.y,this._cacheValue.z=ee.HELP_2.z,this._cacheValue.w=ee.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 Hi(0);r.formBytes(e),this.addKeyFrame(r)}}}class Im 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 Qm{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 On{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,h=c.subtract(e).lengthSquared;return f<h?a=i:t=i,this.getClosestParamRec(e,t,a,r)}}var Nh=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(Nh||{});class Tm{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,h=c.lengthSquared;if(f>0&&h>0){let u=(f+h)/8,g=c.div(h).subtract(l.div(f));g.normalize(),g=g.mul(u),r[o*3-1]=e[o].subtract(g),r[o*3+1]=e[o].add(g)}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]),h=c.lengthSquared,u=f.lengthSquared,g=3*i-1,A=(3*i+1)%(this.numControlVertices-1);if(h>0&&u>0){let m=(h+u)/8,p=f.div(u).subtract(c.div(h));p.normalize(),p=p.mul(m),r[g]=e[l].subtract(p),r[A]=e[l].add(p)}else r[g]=e[l],r[A]=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=Pt.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 On(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=Pt.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 On(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 On(i);for(let o=0;o<this.controlVertices.length-1;o+=3){for(let h=0;h<4;h++)i[h]=this.controlVertices[o+h];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 Mm 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 Ph=(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))(Ph||{});const Nm=3.141592653589793;class Pm{}function Vh(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,h=f+l*l;if(h>=0){let A=Math.sqrt(h)-l;return A=A>0?Math.pow(A,a):-Math.pow(-A,a),-i-c/A+A}let u=Math.sqrt(-f),g=Math.acos(-l/u);return u=Math.pow(u,a),u=u-c/u,g=-i+u*Math.cos(g*a),g}function Ln(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 Oh(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]=Vh(n,o,l),i++;let c=e,f=t+e*s[0],h=a+t*s[0]+e*s[0]*s[0];i+=Ln(c,f,h,{r0:s[1],r1:s[2]})}else i+=Ln(t,a,r,{r0:s[1],r1:s[2]});return i}class Va{coeff=[];static EvalSegment(e,t){return e*(e*(e*t[0]+t[1])+t[2])+t[3]}}class er{static kMaxNumSegments=8;segments=[];integrationCache=[];doubleIntegrationCache=[];times=[];segmentCount;constructor(){this.segments[er.kMaxNumSegments]=new Va,this.integrationCache[er.kMaxNumSegments]=0,this.doubleIntegrationCache[er.kMaxNumSegments]=0,this.times[er.kMaxNumSegments]=0}calculateMinMax(e,t){e.x=Math.min(e.x,t),e.y=Math.max(e.y,t)}findMinMaxDoubleIntegrated(){let e=le.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=le.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=Oh(c,i,n,o,l);for(let h=0;h<f;h++){let u=c[h]+t[r];u>=t[r]&&u<a[r]&&this.calculateMinMax(e,this.evaluateIntegrated(u))}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;Oo(i);let n=t-a;e.integrationCache[r]=e.integrationCache[r-1]+Va.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+=Va.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++)Oo(this.segments[e].coeff)}doubleIntegrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)Lh(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<=er.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+Va.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]+Va.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 Va.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 Va,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 Lh(s){s[0]/=20,s[1]/=12,s[2]/=6,s[3]/=2}function Oo(s){s[0]/=4,s[1]/=3,s[2]/=2,s[3]/=1}var Gh=(s=>(s[s.kEMScalar=0]="kEMScalar",s[s.kEMOptimized=1]="kEMOptimized",s[s.kEMOptimizedMinMax=2]="kEMOptimizedMinMax",s[s.kEMSlow=3]="kEMSlow",s))(Gh||{}),zh=(s=>(s[s.kMMCScalar=0]="kMMCScalar",s[s.kMMCCurve=1]="kMMCCurve",s[s.kMMCTwoCurves=2]="kMMCTwoCurves",s[s.kMMCTwoConstants=3]="kMMCTwoConstants",s))(zh||{});class Vm{max;min}class Om{max;min;integrate(){this.max.integrate(),this.min.integrate()}doubleIntegrate(){this.max.doubleIntegrate(),this.min.doubleIntegrate()}findMinMaxIntegrated(){return null}findMinMaxDoubleIntegrated(){return null}}class Wh{minMaxState;minCurve;maxCurve;_scalar=1;_minScalar;constructor(e=1){this._scalar=e,this.minMaxState=0,this.minCurve=new Qi,this.maxCurve=new Qi}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?Cr(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?Cr(e.minCurve.getValue(t)*e.getScalar(),r,a):e.minMaxState==3?Cr(e._minScalar,e._scalar,a):e.minMaxState==2?Cr(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 Lm{value=0;mode=0;spread=0;speed=new Wh;unSerialized(e){this.value=e.value,this.mode=e.mode,this.spread=e.spread,this.speed.unSerialized(e.speed)}}function Gm(s,e){let t=er.isValidCurve(s.max);return e!=2&&e!=3?t:t&&er.isValidCurve(s.min)}function zm(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 Wm(s,e){let t=e.getKeyCount();if(t!=0)if(t==1)Yi(s,e.getKey(0).value);else{let a=t-1;Yi(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,h=[],u=Ln(n,o,l,{r0:h[0],r1:h[1]});for(let g=0;g<u;g++)h[g]>=0&&h[g]+c<f&&Yi(s,Va.EvalSegment(h[g],i.coeff));Yi(s,Va.EvalSegment(f-c,i.coeff))}}}function Yi(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 Jh{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 Jm(s,e){return Math.random()*e+Math.random()*s+(e-s)*Math.random()}function jm(s,e,t){let a=t*Math.random();return Math.random()*e*a+Math.random()*s*a+(e-s)*Math.random()*a}function jh(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=jh(s,e,t)),i=Math.pow(i,t),i*=e-s,i+=s,i}function ya(s){return s>0?Math.floor(s):Math.floor(s)-1}let ve=[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 Lo(s,e){let t=s&15,a=1+(t&7);return t&8&&(a=-a),a*e}function Gn(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 Xi(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 fi(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 $t=[[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 Zm(s){let e=ya(s),t=e+1,a=s-e,r=a-1,i,n,o=1-a*a;o*=o,i=o*o*Lo(ve[e&255],a);let l=1-r*r;return l*=l,n=l*l*Lo(ve[t&255],r),.25*(i+n)}function Ym(s,e){const t=.366025403,a=.211324865;let r,i,n,o=(s+e)*t,l=s+o,c=e+o,f=ya(l),h=ya(c),u=(f+h)*a,g=f-u,A=h-u,m=s-g,p=e-A,_,B;m>p?(_=1,B=0):(_=0,B=1);let U=m-_+a,C=p-B+a,y=m-1+2*a,x=p-1+2*a,k=f&255,E=h&255,S=.5-m*m-p*p;S<0?r=0:(S*=S,r=S*S*Gn(ve[k+ve[E]],m,p));let I=.5-U*U-C*C;I<0?i=0:(I*=I,i=I*I*Gn(ve[k+_+ve[E+B]],U,C));let T=.5-y*y-x*x;return T<0?n=0:(T*=T,n=T*T*Gn(ve[k+1+ve[E+1]],y,x)),40*(r+i+n)}function Xm(s,e,t){const a=.333333333,r=.166666667;let i,n,o,l,c=(s+e+t)*a,f=s+c,h=e+c,u=t+c,g=ya(f),A=ya(h),m=ya(u),p=(g+A+m)*r,_=g-p,B=A-p,U=m-p,C=s-_,y=e-B,x=t-U,k,E,S,I,T,Q;C>=y?y>=x?(k=1,E=0,S=0,I=1,T=1,Q=0):C>=x?(k=1,E=0,S=0,I=1,T=0,Q=1):(k=0,E=0,S=1,I=1,T=0,Q=1):y<x?(k=0,E=0,S=1,I=0,T=1,Q=1):C<x?(k=0,E=1,S=0,I=0,T=1,Q=1):(k=0,E=1,S=0,I=1,T=1,Q=0);let G=C-k+r,q=y-E+r,ge=x-S+r,ie=C-I+2*r,P=y-T+2*r,z=x-Q+2*r,X=C-1+3*r,V=y-1+3*r,ne=x-1+3*r,W=g&255,ce=A&255,te=m&255,de=.6-C*C-y*y-x*x;de<0?i=0:(de*=de,i=de*de*Xi(ve[W+ve[ce+ve[te]]],C,y,x));let he=.6-G*G-q*q-ge*ge;he<0?n=0:(he*=he,n=he*he*Xi(ve[W+k+ve[ce+E+ve[te+S]]],G,q,ge));let Ue=.6-ie*ie-P*P-z*z;Ue<0?o=0:(Ue*=Ue,o=Ue*Ue*Xi(ve[W+I+ve[ce+T+ve[te+Q]]],ie,P,z));let Ne=.6-X*X-V*V-ne*ne;return Ne<0?l=0:(Ne*=Ne,l=Ne*Ne*Xi(ve[W+1+ve[ce+1+ve[te+1]]],X,V,ne)),32*(i+n+o+l)}function Hm(s,e,t,a){const r=.309016994,i=.138196601;let n,o,l,c,f,h=(s+e+t+a)*r,u=s+h,g=e+h,A=t+h,m=a+h,p=ya(u),_=ya(g),B=ya(A),U=ya(m),C=(p+_+B+U)*i,y=p-C,x=_-C,k=B-C,E=U-C,S=s-y,I=e-x,T=t-k,Q=a-E,G=S>I?32:0,q=S>T?16:0,ge=I>T?8:0,ie=S>Q?4:0,P=I>Q?2:0,z=T>Q?1:0,X=G+q+ge+ie+P+z,V,ne,W,ce,te,de,he,Ue,Ne,Ke,K,ae;V=$t[X][0]>=3?1:0,ne=$t[X][1]>=3?1:0,W=$t[X][2]>=3?1:0,ce=$t[X][3]>=3?1:0,te=$t[X][0]>=2?1:0,de=$t[X][1]>=2?1:0,he=$t[X][2]>=2?1:0,Ue=$t[X][3]>=2?1:0,Ne=$t[X][0]>=1?1:0,Ke=$t[X][1]>=1?1:0,K=$t[X][2]>=1?1:0,ae=$t[X][3]>=1?1:0;let oe=S-V+i,ue=I-ne+i,Re=T-W+i,be=Q-ce+i,Se=S-te+2*i,Ie=I-de+2*i,Me=T-he+2*i,ze=Q-Ue+2*i,Vt=S-Ne+3*i,ut=I-Ke+3*i,ar=T-K+3*i,xa=Q-ae+3*i,La=S-1+4*i,Ga=I-1+4*i,ea=T-1+4*i,za=Q-1+4*i,ha=p&255,Mt=_&255,Fa=B&255,ua=U&255,Or=.6-S*S-I*I-T*T-Q*Q;Or<0?n=0:(Or*=Or,n=Or*Or*fi(ve[ha+ve[Mt+ve[Fa+ve[ua]]]],S,I,T,Q));let Lr=.6-oe*oe-ue*ue-Re*Re-be*be;Lr<0?o=0:(Lr*=Lr,o=Lr*Lr*fi(ve[ha+V+ve[Mt+ne+ve[Fa+W+ve[ua+ce]]]],oe,ue,Re,be));let Gr=.6-Se*Se-Ie*Ie-Me*Me-ze*ze;Gr<0?l=0:(Gr*=Gr,l=Gr*Gr*fi(ve[ha+te+ve[Mt+de+ve[Fa+he+ve[ua+Ue]]]],Se,Ie,Me,ze));let zr=.6-Vt*Vt-ut*ut-ar*ar-xa*xa;zr<0?c=0:(zr*=zr,c=zr*zr*fi(ve[ha+Ne+ve[Mt+Ke+ve[Fa+K+ve[ua+ae]]]],Vt,ut,ar,xa));let Wr=.6-La*La-Ga*Ga-ea*ea-za*za;return Wr<0?f=0:(Wr*=Wr,f=Wr*Wr*fi(ve[ha+1+ve[Mt+1+ve[Fa+1+ve[ua+1]]]],La,Ga,ea,za)),27*(n+o+l+c+f)}class Go extends le{static uv_0=new Go;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 fe(i/t,n/a,1/t,1/a)}}class Hi{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 Y.single:{let r=this.getKeyFrame(0);r[a]=t}break;case Y.float:{let r=this.getKeyFrame(0);r[a]=t}break;case Y.vector2:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y}break;case Y.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 Y.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 Y.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 xn,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}=Na.parser(e);this.split(t,a,"value")}{let{t,v:a}=Na.parser(e);this.split(t,a,"inSlope")}{let{t,v:a}=Na.parser(e);this.split(t,a,"outSlope")}this.tangentMode=e.readInt32(),this.weightedMode=e.readInt32();{let{t,v:a}=Na.parser(e);this.split(t,a,"inWeight")}{let{t,v:a}=Na.parser(e);this.split(t,a,"outWeight")}}}class Km{static sub(e,t){switch(e.constructor.name){case"number":return e-t;case"Vector2":{let r=e,i=t;return new le(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 fe(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 ee(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}}}}class Ki{_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 yr{static WalkAble=1}class qi{static SetConst(e){this.EPSILON=e,this.POWER_EPSILON=e*e}static EPSILON=.1;static POWER_EPSILON=this.EPSILON*this.EPSILON}class Tt 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)<qi.POWER_EPSILON}static calcDistance(e,t){return Tt.CALC_VECTOR3D3.setTo(e.x-t.x,e.y-t.y,e.z-t.z),Tt.CALC_VECTOR3D3.length}}class Zh{_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,yr.WalkAble,yr.WalkAble);for(a of t)if(a.closeId!=this._findIndex&&!(a==e||!a.walkAble)){var r=e.gg+Tt.calcDistance(a,e)*a.costMultiplier,i=Tt.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 Ca extends Tt{_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 Ca(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 Sa{_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=yr.WalkAble,Tt.CALC_VECTOR3D1.setTo(e.x-t.x,e.y-t.y,e.z-t.z),this._edgeSize=Tt.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 Ca(this._pointA,this),this.fatPointB=this.fatPointB||new Ca(this._pointB,this),this.fatPointA.radius!=e&&(Sa.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),Sa.CALC_FAT_VECTOR.scaleBy(e),Sa.CALC_FAT_VECTOR.incrementBy(this._pointA),this.fatPointA.copyFrom(Sa.CALC_FAT_VECTOR),this.fatPointA.radius=e),this.fatPointB.radius!=e&&(Sa.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),Sa.CALC_FAT_VECTOR.scaleBy(-e),Sa.CALC_FAT_VECTOR.incrementBy(this._pointB),this.fatPointB.copyFrom(Sa.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 Tt.equalPoint(e,this._pointA)?this._pointA:Tt.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 Tt.equalPoint(e,this._pointA)?this._pointA:Tt.equalPoint(e,this._pointB)?this._pointB:null}get pointA(){return this._pointA}get pointB(){return this._pointB}get walkAble(){return(this._edgeMask&yr.WalkAble)==yr.WalkAble}testMask(e){return(this._edgeMask&e)==e}}class pe{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=pe.RAY_1,this.rayB=pe.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(pe.TEST_RAY.setTo(a.x-this.curPoint.x,0,a.z-this.curPoint.z),this.isPointAtCenter(pe.TEST_RAY,this.rayA,this.rayB)){this.hasCrossPoint(t.pointA,t.pointB,this.rayAPoint,this.rayA)?(this.rayB.copyFrom(pe.TEST_RAY),a instanceof Tt?this.rayBPoint=a:this.rayBPoint=null):(this.rayA.copyFrom(pe.TEST_RAY),a instanceof Tt?this.rayAPoint=a:this.rayAPoint=null);var i=t.getAnotherPoint(a);pe.TEST_RAY.setTo(i.x-this.curPoint.x,0,i.z-this.curPoint.z),(i==this.rayAPoint||i==this.rayBPoint||this.isPointAtCenter(pe.TEST_RAY,this.rayA,this.rayB))&&(this.cornerEdge=t)}else{var n;if(pe.TEST_RAY_1.copyFrom(t.pointA),pe.TEST_RAY_1.decrementBy(this.curPoint),pe.TEST_RAY_2.copyFrom(t.pointB),pe.TEST_RAY_2.decrementBy(this.curPoint),pe.TEST_RAY_1.y=0,pe.TEST_RAY_2.y=0,this.isPointAtCenter(this.rayA,pe.TEST_RAY_1,pe.TEST_RAY_2)||this.isPointAtCenter(this.rayB,pe.TEST_RAY_1,pe.TEST_RAY_2)?n=!1:n=!0,n)return this.isPointAtCenter(this.rayA,pe.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1}return!0}checkEndPoint(e){return pe.TEST_RAY.setTo(e.x-this.curPoint.x,0,e.z-this.curPoint.z),this.isPointAtCenter(pe.TEST_RAY,this.rayA,this.rayB)?!0:(this.isPointAtCenter(this.rayA,pe.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){pe.CALC_CROSS_POINT.copyFrom(t),pe.CALC_CROSS_POINT.decrementBy(e);let i=pe.CALC_CROSS_POINT.x*r.z-r.x*pe.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),pe.CALC_CROSS_POINT.scaleBy(n),pe.CALC_CROSS_POINT.incrementBy(e),pe.CALC_CROSS_POINT.clone()}calcCrossPointOut(e,t,a,r){pe.CALC_CROSS_POINT.copyFrom(t),pe.CALC_CROSS_POINT.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(pe.CALC_CROSS_POINT.x*r.z-r.x*pe.CALC_CROSS_POINT.z);return i<=1&&i>=0?null:(pe.CALC_CROSS_POINT.scaleBy(i),pe.CALC_CROSS_POINT.incrementBy(e),pe.CALC_CROSS_POINT.clone())}hasCrossPoint(e,t,a,r){pe.CALC_CROSS_TEST.copyFrom(t),pe.CALC_CROSS_TEST.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(pe.CALC_CROSS_TEST.x*r.z-r.x*pe.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,pe.RAY_1.setTo(0,0,0),pe.RAY_2.setTo(0,0,0)}}class tr{_aiRadius=0;_router;_result;_tempPublicEdgeList=new Array;_tempSamePlaneList=new Array;static CROSS_TEST_DIRECTION=new b;constructor(){this._router=new pe}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,qi.EPSILON)!=Vr.INTERSECT||a[a.length-1].plane.classifyPoint(t,qi.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,qi.EPSILON)==Vr.INTERSECT);this._router.continuePass(e,t,this._tempPublicEdgeList[0]),i=this._tempPublicEdgeList.length;var f,h,u,g;for(r=0;r<i;r++)o=this._tempPublicEdgeList[r],n=a[r+1],g=r==i-1,g?l=t:l=n.getEdgeAgainstPoint(o),u=this._router.passEdge(o,this._tempPublicEdgeList[r+1],l,g),u||(f=this._router.cornerPoint,h=this._router.cornerEdge,r=this._tempPublicEdgeList.indexOf(h),this._router.continuePass(f,t,this._tempPublicEdgeList[r+1]));this.pushAllPathPoint2(e,t),this._result.length>=3&&(this.optimusTerminusFat(),this.optimusByRadius());let A=[];for(let m of this._result)A.push(new b().copyFrom(m));this._result=A}optimusTerminusFat(){var e,t,a;a=this._result[1],a instanceof Ca&&(e=a),a=this._result[this._result.length-2],a instanceof Ca&&(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 h=f+1;h<a&&(i=this._tempPublicEdgeList[h],o=i.crossPoint,!o);h++);o==null&&(o=t),l=this.getFatPoint(r,o),l?this._result.push(l):(o==n?c=o.clone():(tr.CROSS_TEST_DIRECTION.setTo(o.x-n.x,0,o.z-n.z),c=this._router.calcCrossEdge(r,n,tr.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,h,u,g,A,m;for(m=0;m<t;m++)c=f=h=null,n=o=l=null,g=!1,A=null,a=this._result[m],r=this._result[m+1],i=this._result[m+2],a instanceof Ca&&(n=a),r instanceof Ca&&(o=r),i instanceof Ca&&(l=i),n&&(c=n.ownerPoint),o&&(f=o.ownerPoint),l&&(h=l.ownerPoint),c&&f&&c==f&&f!=h&&(g=!0),h&&f&&h==f&&c!=f&&(g=!0),g&&(tr.CROSS_TEST_DIRECTION.copyFrom(a),tr.CROSS_TEST_DIRECTION.decrementBy(i),u=o.ownerEdge,g=this._router.hasCrossPoint(u.pointA,u.pointB,i,tr.CROSS_TEST_DIRECTION),g&&(A=this._router.calcCrossPointOut(f,r,i,tr.CROSS_TEST_DIRECTION)),A&&(e[m+1]=A))}getFatPoint(e,t){if(e==null)return null;var a;t instanceof Ca&&(a=t);var r;return a?r=a.ownerPoint:r=e.getEqualPoint(t),r==null?null:(a=e.getFatPoint(r),a)}}class Yh extends b{_id=0;_plane;_points=new Array;_edges=new Array;_neibourTriangles=new Ki;_pointAgainstEdge=new Ki;_edgeAgainstPoint=new Ki;_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 Qt,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=yr.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 Jh,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(yr.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 qm{_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 Ki,this.initPoints(e),this.initEdgesAndTriangles(t),this.createConnections(),this._nav3dAstar=new Zh,this._nav3dFunnel=new tr,this._terrainQuad=new ah(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 Tt(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 Yh(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 Sa(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 zo{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 zo;return e.setTo(this.x,this.y),e}normalize(){var e=length;e!=0&&this.setTo(this.x/e,this.y/e)}}class Oa extends Ve{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 xe(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(L.position,r),this.setAttribute(L.normal,i),this.setAttribute(L.uv,n),this.setAttribute(L.TEXCOORD_1,n),this.addSubGeometry({indexStart:0,indexCount:o.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Xh extends Ve{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=Gt(),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;A(),this.openEnded===!1&&(this.radiusTop>0&&m(!0),this.radiusBottom>0&&m(!1));let f=new Float32Array(t),h=new Float32Array(a),u=new Float32Array(r),g=new Uint16Array(i);this.setAttribute(L.position,f),this.setAttribute(L.normal,h),this.setAttribute(L.uv,u),this.setAttribute(L.TEXCOORD_1,u),this.setIndices(g);function A(){const p=new b,_=new b;let B=0;const U=(e.radiusBottom-e.radiusTop)/e.height;for(let C=0;C<=e.heightSegments;C++){const y=[],x=C/e.heightSegments,k=x*(e.radiusBottom-e.radiusTop)+e.radiusTop;for(let E=0;E<=e.radialSegments;E++){const S=E/e.radialSegments;let I=S*e.thetaLength+e.thetaStart;E==e.radialSegments&&Math.abs(e.thetaLength-e.thetaStart)==Math.PI*2&&(I=0);const T=Math.sin(I),Q=Math.cos(I);_.x=k*T,_.y=-x*e.height+l,_.z=k*Q,t.push(_.x,_.y,_.z),p.set(T,U,Q).normalize(),a.push(p.x,p.y,p.z),r.push(S,1-x),y.push(n++)}o.push(y)}for(let C=0;C<e.radialSegments;C++)for(let y=0;y<e.heightSegments;y++){const x=o[y][C],k=o[y+1][C],E=o[y+1][C+1],S=o[y][C+1];i.push(x,k,S),i.push(k,E,S),B+=6}e.addGroup(c,B,0),c+=B}function m(p){const _=n,B=new le,U=new b;let C=0;const y=p===!0?e.radiusTop:e.radiusBottom,x=p===!0?1:-1;for(let E=1;E<=e.radialSegments;E++)t.push(0,l*x,0),a.push(0,x,0),r.push(.5,.5),n++;const k=n;for(let E=0;E<=e.radialSegments;E++){const I=E/e.radialSegments*e.thetaLength+e.thetaStart,T=Math.cos(I),Q=Math.sin(I);U.x=y*Q,U.y=l*x,U.z=y*T,t.push(U.x,U.y,U.z),a.push(0,x,0),B.x=T*.5+.5,B.y=Q*.5*x+.5,r.push(B.x,B.y),n++}for(let E=0;E<e.radialSegments;E++){const S=_+E,I=k+E;p===!0?i.push(I,I+1,S):i.push(I+1,I,S),C+=3}e.addGroup(c,C,p===!0?1:2),c+=C}}}class Hh extends Ve{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 xe(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),h=0,u=0,g=0,A=0;for(let m=0;m<=r;m++)for(let p=0;p<=i;p++){const _=p/i,B=m/r,U=_*e,C=B*Math.PI*2;if(o[h++]=(t+a*Math.cos(C))*Math.sin(U),o[h++]=a*Math.sin(C),o[h++]=(t+a*Math.cos(C))*Math.cos(U),l[u++]=Math.sin(U)*Math.cos(C),l[u++]=Math.sin(C),l[u++]=Math.cos(U)*Math.cos(C),c[g++]=_,c[g++]=B,p<i&&m<r){const y=i+1,x=y*m+p,k=y*(m+1)+p,E=y*(m+1)+p+1,S=y*m+p+1;f[A++]=x,f[A++]=S,f[A++]=k,f[A++]=S,f[A++]=E,f[A++]=k}}this.setIndices(f),this.setAttribute(L.position,o),this.setAttribute(L.normal,l),this.setAttribute(L.uv,c),this.setAttribute(L.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class $m extends Ve{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(L.position,t),this.setAttribute(L.normal,a),this.setAttribute(L.uv,r),this.setAttribute(L.TEXCOORD_1,r),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class ep extends Ve{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(L.position,t),this.setAttribute(L.normal,a),this.setAttribute(L.uv,r),this.setAttribute(L.TEXCOORD_1,r),this.setAttribute(L.vIndex,i),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class tp extends yn{_internalTexture;_minSize=32;_skyColor;constructor(e){super(),this._skyColor=e,this._internalTexture=new As;let t=[];return D.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,D.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 ap extends d.Object3D{length=100;thickness=.1;constructor(e,t=.1){super(),this.length=e,this.thickness=t,this.init()}init(){let e=new d.Object3D,t=new d.Object3D,a=new d.Object3D,r=new Oa(2,2,2),i=new Oa(2,2,2),n=new Oa(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(d.MeshRenderer),h=t.addComponent(d.MeshRenderer),u=a.addComponent(d.MeshRenderer);f.geometry=r,f.material=o,f.castShadow=!1,h.geometry=i,h.material=l,h.castShadow=!1,u.geometry=n,u.material=c,u.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 rp{static merge(e,t,a){}static mergeNumber(e,t,a){let r=a||new Ve,i=e.getAttribute(L.position).data.length/3,n=new Float32Array(i*t);for(const f of e.vertexAttributeMap){let h=f[1].attribute;if(h==L.indices)continue;let u=e.getAttribute(h).data,g=u.length,A=new Float32Array(g*t);for(let m=0;m<t;m++){A.set(u,g*m);for(let p=0;p<i;p++)n[i*m+p]=m}r.setAttribute(h,A)}r.setAttribute(L.vIndex,n);let o=e.getAttribute(L.indices).data,l=o.length,c=new Uint32Array(o.length*t);for(let f=0;f<t;f++)for(let h=0;h<l;h++){let u=f*i,g=f*l;const A=o[h]+u;c[g+h]=A}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 ip extends d.Object3D{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 Ve;n.setIndices(t.length>Uint16Array.length?new Uint32Array(t):new Uint16Array(t)),n.setAttribute(L.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=me.ADD,o.castReflection=!1;let l=this.addComponent(d.MeshRenderer);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 Ve;r.setIndices(a),r.setAttribute(L.position,t),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});{let i=new d.Object3D,n=i.addComponent(d.MeshRenderer);n.geometry=r;let o=n.material=new Bt;o.baseColor=new J(1,0,0,.5),o.blendMode=me.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}{let i=new d.Object3D;i.rotationY=90;let n=i.addComponent(d.MeshRenderer);n.geometry=r;let o=n.material=new Bt;o.baseColor=new J(0,1,0,.5),o.blendMode=me.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}}}class np{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 sp{static boxGeo;static planeGeo;static sphere;static material;static materialMap;static initHeap(){this.boxGeo||(this.boxGeo=new Oa),this.planeGeo||(this.planeGeo=new qr(1,1,1,1,b.UP)),this.sphere||(this.sphere=new Rr(1,35,35)),this.material||(this.material=new Kt),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 d.Object3D,t=e.addComponent(d.MeshRenderer);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 Kt,t.baseMap=e,this.materialMap.set(e,t)),t.clone()}static GetPlane(e){this.initHeap();let t=new d.Object3D,a=t.addComponent(d.MeshRenderer);a.geometry=this.planeGeo;let r=this.GetMaterial(e);return r.blendMode=me.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 Kt;o.roughness=.5,o.metallic=.1,o.baseColor=new J(r,i,n,1);let l=new d.Object3D,c=l.addComponent(d.MeshRenderer);return c.castGI=!0,c.geometry=new Oa(e,t,a),c.material=o,l}static GetSingleSphere(e,t,a,r){this.initHeap();let i=new Kt;i.baseColor=new J(t,a,r,1);let n=new d.Object3D,o=n.addComponent(d.MeshRenderer);return o.castGI=!0,o.geometry=new Rr(e,20,20),o.material=i,n}static get Sphere(){this.initHeap();let e=new d.Object3D,t=e.addComponent(d.MeshRenderer);return t.geometry=this.sphere,t.material=this.material,e}static GetSingleCube2(e,t=10){this.initHeap();let a=new d.Object3D,r=a.addComponent(d.MeshRenderer);return r.castShadow=!1,r.geometry=new Oa(t,t,t),r.material=e,a}static GetPointLight(e,t,a,r,i,n,o=1,l=!0){let c=new d.Object3D,f=c.addComponent(d.PointLight);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 h=this.GetSingleSphere(.1,1,1,1);return c.addChild(h),f}}var M=(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))(M||{}),da=(s=>(s[s.Local=0]="Local",s[s.Global=1]="Global",s))(da||{});class zn extends qe{mAxis;mAxisColor;mContainer;mAxisMaterial;mAxisCollider;constructor(){super(),this._enable=!1,this.mAxis=new Array(M.MAX),this.mAxisColor=new Array(M.MAX),this.mAxisMaterial=new Array(M.MAX),this.mAxisCollider=new Array(M.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 d.Object3D;let t=new Bt;t.baseColor=new J(1,0,0),t.depthCompare=st.always,this.mAxisColor[M.X]=t.baseColor,this.mAxisMaterial[M.X]=t;let a=new Bt;a.baseColor=new J(0,1,0),a.depthCompare=st.always,this.mAxisColor[M.Y]=a.baseColor,this.mAxisMaterial[M.Y]=a;let r=new Bt;r.baseColor=new J(0,0,1),r.depthCompare=st.always,this.mAxisColor[M.Z]=r.baseColor,this.mAxisMaterial[M.Z]=r;let i=this.createCustomAxis(M.X),n=this.createCustomAxis(M.Y),o=this.createCustomAxis(M.Z);this.mContainer.addChild(this.mAxis[M.X]=i),this.mContainer.addChild(this.mAxis[M.Y]=n),this.mContainer.addChild(this.mAxis[M.Z]=o),this.mAxisCollider[M.X]=i.getComponent(ca),this.mAxisCollider[M.Y]=n.getComponent(ca),this.mAxisCollider[M.Z]=o.getComponent(ca)}start(){}onEnable(e){this.object3D.addChild(this.mContainer),this.reset()}onDisable(e){this.object3D.removeChild(this.mContainer)}reset(){switch(this.transformSpaceMode){case da.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 da.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(D.inputSystem.mouseX,D.inputSystem.mouseY),r,i;for(let n=0;n<=M.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r&&(!i||i.distance>r.distance||n==M.XYZ)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint},n==M.XYZ)))break}return i}currentAxis=M.NONE;beginPoint=new b;beginMousePos=new b;currentPoint=new b;onMouseDown(e){if(e.mouseCode!=Rn.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(D.inputSystem.mouseX,D.inputSystem.mouseY,i.z);this.beginPoint.copyFrom(n),this.beginMousePos.x=D.inputSystem.mouseX,this.beginMousePos.y=D.inputSystem.mouseY}lastMoveObj;lastMoveAxis;onMouseMove(e){if(this.currentAxis==M.NONE){let t=this.lastMoveObj.getComponent(d.MeshRenderer).material;this.lastMoveObj&&"baseColor"in t&&(t.baseColor=this.mAxisColor[this.lastMoveAxis],this.lastMoveObj=null,this.lastMoveAxis==M.XYZ&&(this.mAxis[M.X].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[M.X]),this.mAxis[M.Y].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[M.Y]),this.mAxis[M.Z].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[M.Z])),this.lastMoveAxis=M.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==M.XYZ&&(this.mAxis[M.X].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new J(1,1,1)),this.mAxis[M.Y].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new J(1,1,1)),this.mAxis[M.Z].getComponent(d.MeshRenderer).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(D.inputSystem.mouseX,D.inputSystem.mouseY,r.z);this.currentPoint.copyFrom(i);let n=i.subtract(this.beginPoint);b.HELP_0.set(D.inputSystem.mouseX,D.inputSystem.mouseY,0);let o=b.distance(b.HELP_0,this.beginMousePos);switch(this.beginMousePos.copyFrom(b.HELP_0),this.transformSpaceMode){case da.Local:this.applyLocalTransform(this.currentAxis,n,o);break;case da.Global:this.applyGlobalTransform(this.currentAxis,n,o);break}this.beginPoint.copyFrom(i),this.reset()}}onMouseUp(e){e.mouseCode==Rn.MOUSE_LEFT&&(this.currentAxis=M.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 M.X:t=1;break;case M.Y:a=1;break;case M.Z:r=1;break}let i=.4+t*20,n=.4+a*20,o=.4+r*20,l=new d.Object3D;l.x=i*.5,l.y=n*.5,l.z=o*.5;let c=l.addComponent(d.MeshRenderer);c.geometry=new Oa(i,n,o),c.material=this.mAxisMaterial[e];let f=l.addComponent(ca),h=new ni;return h.setFromCenterAndSize(new b(0,0,0),new b(i+1,n+1,o+1)),f.shape=h,l}}class Kh extends zn{init(e){super.init(e);let t=new Bt;t.doubleSide=!0,t.baseColor=new J(.9,.9,.9),t.depthCompare=st.always,this.mAxisColor[M.XYZ]=t.baseColor,this.mAxisMaterial[M.XYZ]=t;let a=new d.Object3D,r=a.addComponent(d.MeshRenderer);r.geometry=new Oa(2,2,2),r.material=this.mAxisMaterial[M.XYZ];let i=a.addComponent(ca),n=new ni;n.setFromCenterAndSize(new b(0,0,0),new b(2,2,2)),i.shape=n,this.mContainer.addChild(this.mAxis[M.XYZ]=a),this.mAxisCollider[M.XYZ]=a.getComponent(ca)}applyLocalTransform(e,t,a){switch(this.currentAxis){case M.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==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ)&&(this.mX.scaleX=Math.abs(this.mX.scaleX+t.x)),(this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.YZ)&&(this.mX.scaleY=Math.abs(this.mX.scaleY+t.y)),(this.currentAxis==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.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==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ)&&(r.x=t.x),(this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.YZ)&&(r.y=t.y),(this.currentAxis==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.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 d.Object3D;switch(e){case M.X:t=1,i.rotationZ=-90;break;case M.Y:a=1;break;case M.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(d.MeshRenderer);return c.geometry=new Oa(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 qh extends zn{applyLocalTransform(e,t,a){if(this.currentAxis==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ,this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.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==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.YZ}getAngle(){const t=this.object3D.transform.scene3D.view.camera,a=this.mZ.transform.worldPosition;if(t.screenPointToRay(D.inputSystem.mouseX,D.inputSystem.mouseY),this.currentAxis==M.X){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(D.inputSystem.mouseX,D.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==M.Y){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(D.inputSystem.mouseX,D.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==M.Z){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(D.inputSystem.mouseX,D.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==M.X||this.currentAxis==M.Y||this.currentAxis==M.Z){let r=this.getAngle();switch(R.help_matrix_0.identity(),this.currentAxis){case M.X:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.X_AXIS);break;case M.Y:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Y_AXIS);break;case M.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(ra.QUATERNION)[1];ee.HELP_0.set(n.x,n.y,n.z,n.w),this.mLastAngle=r,this.mX.transform.localRotQuat=ee.HELP_0}}onMouseDown(e){super.onMouseDown(e),this.currentAxis!=M.NONE&&(this.mAxis[M.X].getComponent(d.MeshRenderer).enable=!1,this.mAxis[M.Y].getComponent(d.MeshRenderer).enable=!1,this.mAxis[M.Z].getComponent(d.MeshRenderer).enable=!1,this.mAxis[this.currentAxis].getComponent(d.MeshRenderer).enable=!0,this.mLastAngle=this.getAngle())}onMouseUp(e){super.onMouseUp(e),this.currentAxis==M.NONE&&(this.mAxis[M.X].getComponent(d.MeshRenderer).enable=!0,this.mAxis[M.Y].getComponent(d.MeshRenderer).enable=!0,this.mAxis[M.Z].getComponent(d.MeshRenderer).enable=!0)}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=new d.Object3D;switch(e){case M.X:t.rotationZ=90;break;case M.Y:break;case M.Z:t.rotationX=90;break}let a=t.addComponent(d.MeshRenderer);a.geometry=new Hh(20,.4),a.material=this.mAxisMaterial[e];let r=t.addComponent(ca),i=new ni;return i.setFromCenterAndSize(new b,new b(40,.4,40)),r.shape=i,t}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(D.inputSystem.mouseX,D.inputSystem.mouseY),r,i;for(let n=0;n<=M.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 $h extends zn{init(e){super.init(e);let t=new Bt;t.doubleSide=!0,t.baseColor=new J(0,0,1),t.depthCompare=st.always,this.mAxisColor[M.XY]=t.baseColor,this.mAxisMaterial[M.XY]=t;let a=new Bt;a.doubleSide=!0,a.baseColor=new J(0,1,0),a.depthCompare=st.always,this.mAxisColor[M.XZ]=a.baseColor,this.mAxisMaterial[M.XZ]=a;let r=new Bt;r.doubleSide=!0,r.baseColor=new J(1,0,0),r.depthCompare=st.always,this.mAxisColor[M.YZ]=r.baseColor,this.mAxisMaterial[M.YZ]=r;let i=this.createPlane(M.XY),n=this.createPlane(M.XZ),o=this.createPlane(M.YZ);this.mContainer.addChild(this.mAxis[M.XY]=i),this.mContainer.addChild(this.mAxis[M.XZ]=n),this.mContainer.addChild(this.mAxis[M.YZ]=o),this.mAxisCollider[M.XY]=i.getComponent(ca),this.mAxisCollider[M.XZ]=n.getComponent(ca),this.mAxisCollider[M.YZ]=o.getComponent(ca)}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==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ||(b.HELP_0.x=0),this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.YZ||(b.HELP_0.y=0),this.currentAxis==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.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==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ)&&R.help_matrix_0.appendTranslation(t.x,0,0),(this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.YZ)&&R.help_matrix_0.appendTranslation(0,t.y,0),(this.currentAxis==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.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(ra.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 d.Object3D;switch(e){case M.X:t=1,i.rotationZ=-90;break;case M.Y:a=1,i.rotationY=-90;break;case M.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(d.MeshRenderer);return c.geometry=new Xh(0,1,4),c.material=this.mAxisMaterial[e],i}createPlane(e){let t=new d.Object3D,a=t.addComponent(d.MeshRenderer);a.material=this.mAxisMaterial[e];let r=t.addComponent(ca),i=new ni;switch(r.shape=i,e){case M.XY:a.geometry=new qr(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 M.XZ:a.geometry=new qr(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 M.YZ:a.geometry=new qr(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 Wo extends d.Object3D{static _instance;static get instance(){return this._instance||(this._instance=new Wo),this._instance}mTarget;mTransformMode=mt.NONE;mTransformSpaceType=da.Global;mControllers;mXObj;mYObj;mZObj;constructor(){super(),this.mControllers=[null,null,null],this.mControllers[mt.Scale]=this.addComponent(Kh),this.mControllers[mt.Rotation]=this.addComponent(qh),this.mControllers[mt.Translation]=this.addComponent($h),this.mControllers[mt.Scale].enable=!1,this.mControllers[mt.Rotation].enable=!1,this.mControllers[mt.Translation].enable=!1,this.mXObj=new d.Object3D,this.mYObj=new d.Object3D,this.mZObj=new d.Object3D,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(){D.inputSystem.addEventListener(Ea.KEY_DOWN,this.onKeyDown,this),D.inputSystem.addEventListener(j.POINTER_DOWN,this.onMouseDown,this,null,99999),D.inputSystem.addEventListener(j.POINTER_MOVE,this.onMouseMove,this,null,99999),D.inputSystem.addEventListener(j.POINTER_UP,this.onMouseUp,this,null,99999)}unactivate(){D.inputSystem.removeEventListener(Ea.KEY_DOWN,this.onKeyDown,this),D.inputSystem.removeEventListener(j.POINTER_DOWN,this.onMouseDown,this),D.inputSystem.removeEventListener(j.POINTER_MOVE,this.onMouseMove,this),D.inputSystem.removeEventListener(j.POINTER_UP,this.onMouseUp,this)}onKeyDown(e){switch(e.keyCode){case et.Key_R:this.selectTransformMode(mt.Scale),this.selectTransformSpaceMode(da.Local);break;case et.Key_E:this.selectTransformMode(mt.Rotation),this.selectTransformSpaceMode(da.Global);break;case et.Key_W:this.selectTransformMode(mt.Translation),this.selectTransformSpaceMode(da.Global);break;case et.Key_A:this.selectTransformSpaceMode(da.Local);break;case et.Key_S:this.selectTransformSpaceMode(da.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 op=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));d.AccelerateDecelerateInterpolator=M0,d.AccelerateInterpolator=Q0,d.AnimationCurve=Qi,d.AnimationCurveT=Ur,d.AnimationMonitor=Tr,d.AnimatorEventKeyframe=Nb,d.AnticipateInterpolator=V0,d.AnticipateOvershootInterpolator=Ui,d.ArrayHas=su,d.ArrayItemIndex=ou,d.AtlasParser=Ff,d.AtmosphericComponent=kb,d.AtmosphericScatteringSky=Ad,d.AtmosphericScatteringSkySetting=pd,d.AtmosphericScatteringSky_shader=md,d.AttributeAnimCurve=Sd,d.AxisObject=ap,d.B3DMLoader=Ka,d.B3DMLoaderBase=gf,d.B3DMParseUtil=Hs,d.B3DMParser=Ys,d.BRDFLUT=Bf,d.BRDFLUTGenerate=vf,d.BRDF_frag=Ul,d.BatchTable=vn,d.BiMap=Im,d.BillboardComponent=Ii,d.BillboardType=gr,d.BitUtil=Hl,d.BitmapTexture2D=Ha,d.BitmapTexture2DArray=mc,d.BitmapTextureCube=Gs,d.Blend=bc,d.BlendFactor=gc,d.BlendMode=me,d.BlendShapeData=Fo,d.BlendShapePropertyData=xo,d.BloomPost=Rg,d.BlurEffectCreatorBlur_cs=sf,d.BlurEffectCreatorSample_cs=nf,d.BlurTexture2DBufferCreator=of,d.BounceInterpolator=Ht,d.BoundUtil=_s,d.BoundingBox=xe,d.BoundingSphere=Ir,d.BoundingVolume=Pr,d.BoxColliderShape=ni,d.BoxGeometry=Oa,d.BrdfLut_frag=ul,d.BsDF_frag=Cl,d.BxDF_frag=yl,d.BxdfDebug_frag=kl,d.BytesArray=Mn,d.CEvent=bt,d.CEventDispatcher=Wa,d.CEventListener=en,d.CResizeEvent=rr,d.CSM=aa,d.Camera3D=Xr,d.CameraControllerBase=jb,d.CameraType=at,d.CameraUtil=ft,d.CapsuleColliderShape=fg,d.CastPointShadowMaterialPass=Ec,d.CastShadowMaterialPass=kc,d.Clearcoat_frag=Sl,d.ClusterBoundsSource_cs=c0,d.ClusterConfig=wt,d.ClusterDebug_frag=tl,d.ClusterLight=Nl,d.ClusterLightingBuffer=l0,d.ClusterLightingRender=d0,d.ClusterLighting_cs=f0,d.CollectInfo=Qc,d.ColliderComponent=ca,d.ColliderShape=ht,d.ColliderShapeType=ii,d.Color=J,d.ColorGradient=Qm,d.ColorLitMaterial=Fm,d.ColorLitShader=hd,d.ColorPassFragmentOutput=_b,d.ColorPassRenderer=o0,d.ColorUtil=rn,d.ComData=Nn,d.Combine_cs=nd,d.Common_frag=dl,d.Common_vert=hl,d.ComponentBase=qe,d.ComponentCollect=Pe,d.ComputeGPUBuffer=$r,d.ComputeShader=ye,d.Context3D=Yo,d.CubeCamera=Ss,d.CubeMapFaceEnum=lf,d.CubeSky_Shader=Hn,d.CubicBezierCurve=On,d.CubicBezierPath=Tm,d.CubicBezierType=Nh,d.CycleInterpolator=O0,d.CylinderGeometry=Xh,d.DDGIIrradianceComputePass=S0,d.DDGIIrradianceGPUBufferReader=Ji,d.DDGIIrradianceVolume=$c,d.DDGIIrradiance_shader=C0,d.DDGILightingPass=E0,d.DDGILighting_shader=k0,d.DDGIMultiBouncePass=F0,d.DDGIProbeRenderer=w0,d.DEGREES_TO_RADIANS=pt,d.DRACO_DECODER_GLTF_JS=z0,d.DecelerateInterpolator=T0,d.Denoising_cs=sd,d.Depth2DTextureArray=g0,d.DepthCubeArrayTexture=u0,d.DepthMaterialPass=wc,d.DepthOfFieldPost=Ig,d.DepthOfView_cs=zf,d.DoubleArray=Ki,d.EditorInspector=Jr,d.Engine3D=D,d.Entity=qc,d.EntityBatchCollect=Tc,d.EntityCollect=H,d.EnvMap_frag=bl,d.ErpImage2CubeMap=jt,d.ErpImage2CubeMapCreateCube_cs=cf,d.ErpImage2CubeMapRgbe2rgba_cs=ff,d.ExtrudeGeometry=gg,d.FAILED=_r,d.FASTFLOOR=ya,d.FXAAPost=xs,d.FXAAShader=v0,d.FastMathShader=ml,d.FatLineGeometry=mg,d.FatLineMaterial=km,d.FatLine_FS=ac,d.FatLine_VS=tc,d.FeatureTable=xi,d.FileLoader=It,d.FirstPersonCameraController=Zb,d.Float16ArrayTexture=As,d.Float32ArrayTexture=Kc,d.FlyCameraController=Yb,d.FontChar=Cf,d.FontInfo=Uf,d.FontPage=yf,d.FontParser=qa,d.ForwardRenderJob=I0,d.FragmentOutput=$n,d.FragmentVarying=Al,d.FrameCache=lo,d.Frustum=cs,d.FrustumCSM=uc,d.FrustumCulling_cs=Db,d.FullQuad_vert_wgsl=El,d.GBufferFrame=De,d.GBufferPass=Fc,d.GBufferPost=Qg,d.GBufferStand=Kl,d.GBuffer_pass=es,d.GILighting=Os,d.GIProbeMaterial=Xd,d.GIProbeMaterialType=Do,d.GIProbeShader=ud,d.GIRenderCompleteEvent=Fs,d.GIRenderStartEvent=gn,d.GLBChunk=tf,d.GLBHeader=ef,d.GLBParser=Ls,d.GLSLLexer=pc,d.GLSLLexerToken=mi,d.GLSLPreprocessor=Ac,d.GLSLSyntax=vc,d.GLTFBinaryExtension=Af,d.GLTFMaterial=$g,d.GLTFParser=_t,d.GLTFSubParser=An,d.GLTFSubParserCamera=W0,d.GLTFSubParserConverter=$0,d.GLTFSubParserMaterial=j0,d.GLTFSubParserMesh=J0,d.GLTFSubParserSkeleton=Vs,d.GLTFSubParserSkin=Z0,d.GLTFType=na,d.GLTF_Accessors=y2,d.GLTF_Info=mn,d.GLTF_Light=_2,d.GLTF_Mesh=U2,d.GLTF_Node=B2,d.GLTF_Primitives=v2,d.GLTF_Scene=D2,d.GPUAddressMode=Xt,d.GPUBlendFactor=lu,d.GPUBufferBase=Ja,d.GPUBufferType=ba,d.GPUCompareFunction=st,d.GPUContext=F,d.GPUCullMode=Nt,d.GPUFilterMode=or,d.GPUPrimitiveTopology=an,d.GPUTextureFormat=re,d.GPUVertexFormat=ui,d.GPUVertexStepMode=du,d.GSplatFormat=ci,d.GSplatGeometry=Jc,d.GSplatMaterial=Oc,d.GSplat_FS=Vc,d.GSplat_VS=Pc,d.GTAOPost=Tg,d.GTAO_cs=Wf,d.GUIAtlasTexture=xf,d.GUICanvas=Pi,d.GUIConfig=Qr,d.GUIGeometry=Rd,d.GUIGeometryRebuild=Qd,d.GUIMaterial=uo,d.GUIPassRenderer=R0,d.GUIPick=Pd,d.GUIPickHelper=Ld,d.GUIQuad=Ma,d.GUIQuadAttrEnum=it,d.GUIRenderer=Td,d.GUIShader=ho,d.GUISpace=la,d.GUISprite=ei,d.GUITexture=ur,d.GaussianSplatParser=Hg,d.GenerayRandomDir=Tl,d.GeoJsonParser=Kg,d.GeoJsonUtil=qg,d.GeoType=Qn,d.GeometryBase=Ve,d.GeometryIndicesBuffer=zc,d.GeometryUtil=rp,d.GeometryVertexBuffer=Lc,d.GeometryVertexType=Ft,d.GetComponentClass=Xo,d.GetCountInstanceID=Yn,d.GetRepeat=_u,d.GetShader=Ho,d.GlassShader=Bb,d.GlobalBindGroup=Be,d.GlobalBindGroupLayout=fs,d.GlobalFog=Mg,d.GlobalFog_shader=oo,d.GlobalIlluminationComponent=ig,d.GlobalUniform=Kn,d.GlobalUniformGroup=Bs,d.GodRayPost=Ng,d.GodRay_cs=Jf,d.GridObject=ip,d.HDRTexture=Ws,d.HDRTextureCube=Bn,d.Hair_frag=Pl,d.Hair_shader_op=vb,d.Hair_shader_tr=Ub,d.HaltonSeq=ln,d.Horizontal=Wd,d.HoverCameraController=Xb,d.I3DMLoader=_a,d.I3DMLoaderBase=Df,d.I3DMParser=Ks,d.IBLEnvMapCreator=uf,d.IBLEnvMapCreator_cs=hf,d.IESProfiles=pa,d.IESProfiles_frag=_l,d.IKDTreeUserData=Dg,d.ImageType=ri,d.IndicesGPUBuffer=Gc,d.Inline_vert=fl,d.InputSystem=Zo,d.InstanceDrawComponent=ng,d.InstanceUniform=gl,d.InstancedMesh=_f,d.Interpolator=hr,d.InterpolatorEnum=ks,d.IrradianceDataReaderCompleteEvent=lh,d.IrradianceVolumeData_frag=cl,d.Irradiance_frag=vl,d.IsEditorInspector=iu,d.IsNonSerialize=jn,d.Joint=Y0,d.JointPose=Ps,d.JumperInterpolator=P0,d.KDTreeEntity=Bg,d.KDTreeNode=pr,d.KDTreeRange=$d,d.KDTreeSpace=eh,d.KDTreeUUID=Wi,d.KHR_draco_mesh_compression=Ns,d.KHR_lights_punctual=em,d.KHR_materials_clearcoat=H0,d.KHR_materials_emissive_strength=K0,d.KHR_materials_ior=tm,d.KHR_materials_unlit=q0,d.KMZParser=Mf,d.KV=So,d.KelvinUtil=np,d.KeyCode=et,d.KeyEvent=Ea,d.Keyframe=xn,d.KeyframeT=Hi,d.LDRTextureCube=yn,d.LOADED=Pa,d.LOADING=ko,d.LRUCache=kh,d.LambertMaterial=Em,d.Lambert_shader=Ol,d.LightBase=Si,d.LightData=on,d.LightEntries=e0,d.LightType=lt,d.LightingFunction_frag=al,d.Line=vt,d.LineClassification=Vd,d.LinearInterpolator=N0,d.LitMaterial=Kt,d.Lit_shader=xl,d.LoaderBase=wr,d.LoaderEvent=vg,d.LoaderManager=In,d.MAX_VALUE=gu,d.MIN_VALUE=mu,d.Material=Dt,d.MaterialDataUniformGPUBuffer=Sc,d.MaterialUtilities=Tn,d.MathShader=rl,d.MathUtil=Pt,d.Matrix3=Mr,d.Matrix4=R,d.MatrixBindGroup=r0,d.MatrixGPUBuffer=a0,d.MatrixShader=Ml,d.MemoryDO=ir,d.MemoryInfo=qo,d.MergeRGBACreator=Cg,d.MergeRGBA_cs=jf,d.MeshColliderShape=wn,d.MinMaxAnimationCurves=Vm,d.MinMaxCurve=Wh,d.MinMaxCurveState=zh,d.MinMaxPolyCurves=Om,d.MorePassParser=kg,d.MorePassShader=sh,d.MorphTargetBlender=Ob,d.MorphTargetData=n0,d.MorphTargetFrame=Lb,d.MorphTargetTransformKey=kd,d.MorphTarget_shader=Yt,d.MouseCode=Rn,d.MultiBouncePass_cs=x0,d.Navi3DAstar=Zh,d.Navi3DConst=qi,d.Navi3DEdge=Sa,d.Navi3DFunnel=tr,d.Navi3DMaskType=yr,d.Navi3DMesh=qm,d.Navi3DPoint=Tt,d.Navi3DPoint2D=zo,d.Navi3DPointFat=Ca,d.Navi3DRouter=pe,d.Navi3DTriangle=Yh,d.NonSerialize=Jn,d.NormalMap_frag=pl,d.OAnimationEvent=X0,d.OBJParser=rf,d.Object3DEvent=Ug,d.Object3DTransformTools=Wo,d.Object3DUtil=sp,d.ObjectAnimClip=xd,d.OcclusionSystem=Cs,d.Octree=fr,d.OctreeEntity=Nc,d.OrbitController=Hb,d.OrderMap=Mm,d.Orientation3D=ra,d.OutLineBlendColor_cs=Zf,d.OutlineCalcOutline_cs=Yf,d.OutlinePass=yb,d.OutlinePost=Pg,d.OutlinePostData=fh,d.OutlinePostManager=dh,d.OutlinePostSlot=ch,d.Outline_cs=Xf,d.OvershootInterpolator=L0,d.PARSING=xh,d.PBRLItShader=Fl,d.PBRLitSSSShader=bd,d.PLUGIN_REGISTERED=Am,d.PNTSLoader=Ah,d.PNTSLoaderBase=ph,d.PNTSParser=Dh,d.ParserBase=dt,d.ParserFormat=He,d.ParticleSystemCurveEvalMode=Gh,d.ParticleSystemRandomnessIds=Ph,d.PassGenerate=Bi,d.PassShader=oh,d.PassType=se,d.PhysicMaterialUniform_frag=il,d.PickCompute=Hd,d.PickFire=Kd,d.PickGUIEvent3D=Ut,d.PickResult=hh,d.Picker_cs=Hf,d.PingPong=ts,d.PipelinePool=bs,d.Plane3D=Jh,d.PlaneClassification=Vr,d.PlaneGeometry=qr,d.PlyMode=Dr,d.PlyParser=am,d.PointClassification=Od,d.PointCloudGeometry=Ds,d.PointCloudMaterial=Hc,d.PointCloud_FS=Xc,d.PointCloud_VS=Yc,d.PointLightShadowRenderer=b0,d.PointShadowCubeCamera=h0,d.PointerEvent3D=j,d.Polynomial=Va,d.PolynomialCurve=er,d.Polynomials=Pm,d.PoolNode=Md,d.PostBase=Jt,d.PostProcessingComponent=Pf,d.PostRenderer=D0,d.PreDepthPassRenderer=p0,d.PreFilteredEnvironment_cs=_0,d.PreFilteredEnvironment_cs2=hb,d.PreIntegratedLut=Kf,d.PreIntegratedLutCompute=nh,d.PrefabAvatarData=Co,d.PrefabAvatarParser=_h,d.PrefabBoneData=yo,d.PrefabMaterialParser=vh,d.PrefabMeshData=Uh,d.PrefabMeshParser=yh,d.PrefabNode=Zi,d.PrefabParser=Sh,d.PrefabStringUtil=lm,d.PrefabTextureData=Bh,d.PrefabTextureParser=Ch,d.Preprocessor=ga,d.PriorityQueue=wo,d.Probe=Yd,d.ProbeEntries=Sg,d.ProbeGBufferFrame=y0,d.ProfilerUtil=ot,d.PropertyAnimClip=Mb,d.PropertyAnimTag=Fd,d.PropertyAnimation=co,d.PropertyAnimationClip=Vo,d.PropertyAnimationClipState=Cd,d.PropertyAnimationEvent=Mi,d.PropertyHelp=Ti,d.QuadAABB=Qt,d.QuadGlsl_fs=Gl,d.QuadGlsl_vs=Ll,d.QuadRoot=ah,d.QuadTree=th,d.QuadTreeCell=Ar,d.Quad_depth2dArray_frag_wgsl=hu,d.Quad_depth2d_frag_wgsl=Il,d.Quad_depthCube_frag_wgsl=Ql,d.Quad_frag_wgsl=Rl,d.Quad_vert_wgsl=wl,d.Quaternion=ee,d.R32UintTexture=ps,d.RADIANS_TO_DEGREES=Zr,d.RGBEErrorCode=df,d.RGBEHeader=Js,d.RGBEParser=js,d.RTDescriptor=Ge,d.RTFrame=rt,d.RTResourceConfig=Ia,d.RTResourceMap=Et,d.Rand=bi,d.RandomSeed=Bu,d.Ray=ia,d.RayCastMeshDetail=li,d.Reader=Hr,d.Rect=gi,d.Reference=Ce,d.Reflection=_d,d.ReflectionCG=$l,d.ReflectionEntries=t0,d.ReflectionMaterial=vd,d.ReflectionRenderer=B0,d.ReflectionShader=Bd,d.ReflectionShader_shader=ql,d.RegisterComponent=Lt,d.RegisterShader=wa,d.RenderContext=ys,d.RenderLayer=vi,d.RenderLayerUtil=gs,d.RenderNode=Ra,d.RenderShaderCollect=Mc,d.RenderShaderCompute=ih,d.RenderShaderPass=Xe,d.RenderTexture=kt,d.RendererBase=Qa,d.RendererJob=U0,d.RendererMap=A0,d.RendererMask=Qe,d.RendererMaskUtil=ta,d.RendererPassState=s0,d.RepeatSE=as,d.Res=Nf,d.RotationControlComponents=qh,d.SHCommon_frag=ec,d.SN_ArrayConstant=pi,d.SN_BinaryOperation=cr,d.SN_Break=qu,d.SN_CodeBlock=Aa,d.SN_Constant=Ya,d.SN_Continue=dn,d.SN_Declaration=$e,d.SN_Discard=$u,d.SN_DoWhileLoop=Ku,d.SN_Expression=Fe,d.SN_ForLoop=xr,d.SN_Function=cn,d.SN_FunctionArgs=fn,d.SN_FunctionCall=Sr,d.SN_IFBranch=kr,d.SN_Identifier=Za,d.SN_IndexOperation=Er,d.SN_Layout=_i,d.SN_ParenExpression=_c,d.SN_Precision=hn,d.SN_Return=Ai,d.SN_SelectOperation=Di,d.SN_Struct=ja,d.SN_TernaryOperation=Bc,d.SN_UnaryOperation=Kr,d.SN_WhileLoop=Fr,d.SSAO_cs=ub,d.SSGI2_cs=qf,d.SSGIPost=Vg,d.SSRPost=Og,d.SSR_BlendColor_cs=$f,d.SSR_IS_Kernel=Lg,d.SSR_IS_cs=ed,d.SSR_RayTrace_cs=td,d.ScaleControlComponents=Kh,d.Scene3D=hg,d.Shader=gt,d.ShaderAttributeInfo=us,d.ShaderConverter=Uc,d.ShaderConverterResult=yc,d.ShaderLib=Z,d.ShaderPassBase=Xn,d.ShaderReflection=St,d.ShaderStage=Da,d.ShaderState=Cc,d.ShaderUniformInfo=hs,d.ShaderUtil=Xa,d.ShadingInput=Dl,d.ShadowLightsCollect=Wt,d.ShadowMapPassRenderer=m0,d.ShadowMapping_frag=Bl,d.Skeleton=Gb,d.SkeletonAnimationClip=pn,d.SkeletonAnimationClipState=yd,d.SkeletonAnimationCompute=zb,d.SkeletonAnimation_shader=jr,d.SkeletonBlendComputeArgs=Wb,d.SkeletonPose=Ci,d.SkeletonTransformComputeArgs=Jb,d.SkyGBufferPass=xc,d.SkyGBuffer_pass=zl,d.SkyMaterial=Dd,d.SkyRenderer=Sn,d.SolidColorSky=tp,d.SphereColliderShape=dg,d.SphereGeometry=Rr,d.SphereReflection=Ud,d.StandShader=af,d.StatementNode=Oe,d.StorageGPUBuffer=Te,d.StringUtil=Rt,d.Struct=hi,d.StructStorageGPUBuffer=xg,d.SubGeometry=Wc,d.TAACopyTex_cs=ad,d.TAAPost=Gg,d.TAASharpTex_cs=rd,d.TAA_cs=id,d.TestComputeLoadBuffer=od,d.TextAnchor=Gd,d.TextFieldLayout=jd,d.TextFieldLine=Jd,d.Texture=ct,d.TextureCube=Dn,d.TextureCubeFaceData=Zs,d.TextureCubeStdCreator=_n,d.TextureCubeUtils=zs,d.TextureMipmapCompute=Fg,d.TextureMipmapGenerator=ma,d.TextureScaleCompute=rh,d.ThirdPersonCameraController=qb,d.Tile=Eo,d.TileSet=vm,d.TileSetChild=ym,d.TileSetChildContent=Cm,d.TileSetChildContentMetaData=Sm,d.TileSetRoot=Um,d.TilesRenderer=Bm,d.Time=Le,d.TokenType=v,d.TorusGeometry=Hh,d.TouchData=jo,d.TrailGeometry=$m,d.Transform=zt,d.TransformAxisEnum=M,d.TransformControllerBaseComponent=zn,d.TransformMode=mt,d.TransformSpaceMode=da,d.TranslationControlComponents=$h,d.TranslatorContext=ds,d.TriGeometry=ep,d.Triangle=Gi,d.UIButton=go,d.UIButtonTransition=Zd,d.UIComponentBase=bo,d.UIEvent=yg,d.UIImage=Nr,d.UIImageGroup=mo,d.UIInteractive=En,d.UIInteractiveStyle=tt,d.UIPanel=Li,d.UIRenderAble=Oi,d.UIShadow=po,d.UITextField=Ao,d.UITransform=$a,d.UNLOADED=Br,d.UUID=Gt,d.UV=Go,d.Uint32ArrayTexture=jc,d.Uint8ArrayTexture=bn,d.UnLit=Vl,d.UnLitMaterial=Bt,d.UnLitMaterialUniform_frag=nl,d.UnLitTexArrayMaterial=Rm,d.UnLitTextureArray=gd,d.UnLit_frag=sl,d.UniformGPUBuffer=yt,d.UniformNode=nr,d.UniformType=Ct,d.ValueEnumType=Y,d.ValueOp=Km,d.ValueParser=Na,d.ValueSpread=Lm,d.Vector2=le,d.Vector3=b,d.Vector3Ex=Ni,d.Vector4=fe,d.VertexAttribute=Ag,d.VertexAttributeIndexShader=dd,d.VertexAttributeName=L,d.VertexAttributeSize=sr,d.VertexAttributeStride=qd,d.VertexAttributes_vert=ol,d.VertexBufferLayout=pg,d.VertexFormat=el,d.VertexGPUBuffer=un,d.Vertical=zd,d.VideoUniform_frag=ll,d.View3D=ug,d.ViewPanel=Fn,d.ViewQuad=Us,d.VirtualTexture=we,d.WGS84_FLATTENING=mm,d.WGS84_HEIGHT=pm,d.WGS84_RADIUS=gm,d.WGSLTranslator=Dc,d.WayLines3D=Ri,d.WayPoint3D=wi,d.WebGPUDescriptorCreator=Je,d.WorldMatrixUniform=qn,d.WorldPanel=kn,d.WrapMode=si,d.WrapTimeMode=mr,d.ZCullingCompute=wg,d.ZPassShader_cs=fd,d.ZPassShader_fs=Xl,d.ZPassShader_vs=Yl,d.ZSorterUtil=Rc,d.append=hc,d.arrayToString=bf,d.blendComponent=cu,d.buildCurves=zm,d.byteSizeOfType=fa,d.calculateCurveRangesValue=Wm,d.calculateMinMax=Yi,d.castPointShadowMap_vert=Jl,d.clamp=Ae,d.clampRepeat=zu,d.computeAABBFromPositions=_o,d.cos=Qu,d.crossProduct=Ou,d.cubicPolynomialRoot=Vh,d.cubicPolynomialRootsGeneric=Oh,d.curvesSupportProcedural=Gm,d.deg2Rad=wu,d.detectGSplatFormat=uh,d.directionShadowCastMap_frag=Zl,d.dot=xt,d.doubleIntegrateSegment=Lh,d.downSample=Lf,d.fastInvSqrt=fc,d.floorfToIntPos=cc,d.fonts=ti,d.generateRandom=Lu,d.generateRandom3=Gu,d.getFloatFromInt=sc,d.getGLTypeFromTypedArray=M2,d.getGLTypeFromTypedArrayType=T2,d.getGlobalRandomSeed=Tu,d.getTypedArray=N2,d.getTypedArrayTypeFromGLType=Ms,d.grad1=Lo,d.grad2=Gn,d.grad3=Xi,d.grad4=fi,d.inferSHOrder=vo,d.integrateSegment=Oo,d.irradianceDataReader=Eg,d.kPI=Nm,d.lerp=Cr,d.lerpByte=Du,d.lerpColor=Au,d.lerpVector3=pu,d.lruPriorityCallback=Mh,d.magnitude=is,d.makeAloneSprite=j2,d.makeGUISprite=Sf,d.makeMatrix44=sn,d.markUsedSetLeaves=Mo,d.markUsedTiles=Vn,d.markVisibleTiles=No,d.matrixMultiply=ls,d.matrixRotate=Zu,d.matrixRotateY=ju,d.mergeFunctions=tn,d.multiplyMatrices4x4REF=dc,d.normal_distribution=jh,d.normalizeFast=Vu,d.normalizeSafe=nc,d.normalizedToByte=Pu,d.normalizedToWord=Nu,d.outlinePostData=Ua,d.outlinePostManager=zg,d.parsePlyGaussianSplat=Uo,d.parsePlyHeader=ji,d.parsePlyMesh=gh,d.parsePlyPointCloud=mh,d.perm=ve,d.post=Gf,d.priorityCallback=Th,d.quadraticPolynomialRootsGeneric=Ln,d.rad2Deg=Ru,d.random01=Yr,d.randomBarycentricCoord=Eu,d.randomPointBetweenEllipsoid=ku,d.randomPointBetweenSphere=xu,d.randomPointInsideCube=Cu,d.randomPointInsideEllipsoid=Su,d.randomPointInsideUnitCircle=Fu,d.randomPointInsideUnitSphere=lc,d.randomQuaternion=Uu,d.randomQuaternionUniformDistribution=yu,d.randomUnitVector=nn,d.randomUnitVector2=oc,d.rangedRandomFloat=At,d.rangedRandomInt=vu,d.readByType=_e,d.readMagicBytes=Un,d.registerMaterial=wm,d.repeat=os,d.rotMatrix=Ju,d.rotateVectorByQuat=bu,d.roundfToIntPos=ns,d.scale=rs,d.shadowCastMap_frag=jl,d.shadowCastMap_vert=Wl,d.simplex=$t,d.sin=Iu,d.snoise1=Zm,d.snoise2=Ym,d.snoise3=Xm,d.snoise4=Hm,d.splatColorProperties=bh,d.splatProperties=Bo,d.sqrMagnitude=ss,d.sqrtImpl=ic,d.stencilStateFace=fu,d.swap=Mu,d.textureCompress=ld,d.threshold=Of,d.throttle=xm,d.toHalfFloat=dr,d.toggleTiles=Po,d.traverseAncestors=Dm,d.traverseSet=Eh,d.tw=Ab,d.uniform_real_distribution=Jm,d.uniform_real_distribution2=jm,d.upSample=so,d.webGPUContext=w,d.zSorterUtil=Ic,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
11819
+ `||r[n]==="\r");)n++;const l=r.substring(n).split(/\s+/).filter(E=>E.length>0);let c=0;const f=E=>a.find(S=>S.name===E)!=null,h=E=>{if(c>=l.length)throw new Error("PLY: Unexpected end of file");const S=l[c++];switch(E){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(S);case"float":case"double":case"float32":case"float64":return parseFloat(S);default:return parseFloat(S)}},u=new Float32Array(t*3),g=(f("red")||f("r"))&&(f("green")||f("g"))&&(f("blue")||f("b")),A=f("alpha")||f("a"),m=g?new Uint8Array(t*4):void 0,p=E=>a.findIndex(S=>S.name===E),_=p("x"),B=p("y"),U=p("z"),C=g?p("red")>=0?p("red"):p("r"):-1,y=g?p("green")>=0?p("green"):p("g"):-1,x=g?p("blue")>=0?p("blue"):p("b"):-1,k=A?p("alpha")>=0?p("alpha"):p("a"):-1;for(let E=0;E<t;E++){for(let S=0;S<a.length;S++){const I=a[S],T=h(I.type);if(S===_)u[E*3+0]=T;else if(S===B)u[E*3+1]=T;else if(S===U)u[E*3+2]=T;else if(S===C&&m){const Q=I.type==="uchar"||I.type==="uint8"?T:Math.round(T*255);m[E*4+0]=Math.max(0,Math.min(255,Q))}else if(S===y&&m){const Q=I.type==="uchar"||I.type==="uint8"?T:Math.round(T*255);m[E*4+1]=Math.max(0,Math.min(255,Q))}else if(S===x&&m){const Q=I.type==="uchar"||I.type==="uint8"?T:Math.round(T*255);m[E*4+2]=Math.max(0,Math.min(255,Q))}else if(S===k&&m){const Q=I.type==="uchar"||I.type==="uint8"?T:Math.round(T*255);m[E*4+3]=Math.max(0,Math.min(255,Q))}}m&&k<0&&(m[E*4+3]=255)}return{vertexCount:t,position:u,color:m}}class Hg extends dt{static format=He.BIN;async parseBuffer(e){const t=uh(e);let a;switch(t){case ci.PLY:{const r=Uo(e);a={count:r.vertexCount,position:r.position,rotation:r.rotation,scale:r.scale,opacity:r.opacity,sh:r.sh},a.bbox=_o(r.position);break}case ci.SPLAT:throw new Error("SPLAT format is not yet supported");case ci.KSPLAT:throw new Error("KSPLAT format is not yet supported");case ci.UNKNOWN:default:throw new Error("Unknown or unsupported Gaussian Splatting file format")}return this.data=a,a}verification(){return!!this.data&&this.data.count>0}}var Qn=(s=>(s.Point="Point",s.LineString="LineString",s.MultiPolygon="MultiPolygon",s))(Qn||{});class Kg extends dt{static format=He.JSON;json;async parseString(e){this.json=e,this.data=JSON.parse(e)}}class qg{static getPath(e){let t=[];for(let a=0;a<e.features.length;a++){const r=e.features[a];switch(r.geometry.type){case Qn.LineString:break;case Qn.MultiPolygon:let i=[];for(let n=0;n<r.geometry.coordinates.length;n++){const o=r.geometry.coordinates[n];for(const l of o)for(const c of l){let f=new b(c[0],0,c[1]);i.push(f)}}t.push(i);break}}return t}}class $g{name;defines;doubleSided;baseColorFactor;emissiveFactor;metallicFactor;roughnessFactor;alphaCutoff;enableBlend;baseColorTexture;metallicRoughnessTexture;normalTexture;occlusionTexture;emissiveTexture;extensions;baseMapOffsetSize;normalMapOffsetSize;emissiveMapOffsetSize;roughnessMapOffsetSize;metallicMapOffsetSize;aoMapOffsetSize}class em{}class tm{}class am extends dt{static format=He.BIN;async parseBuffer(e){switch(ji(e).mode){case Dr.Splat:{const a=Uo(e),r={count:a.vertexCount,position:a.position,rotation:a.rotation,scale:a.scale,opacity:a.opacity,sh:a.sh};r.bbox=_o(a.position);const i=new d.Object3D;i.name="GaussianSplat",i.addComponent(d.GSplatRenderer).initAsset(r),this.data=i;break}case Dr.PointCloud:{const a=mh(e),r=new d.Object3D;r.name="PLYPointCloud";const i=new d.Object3D;i.name="PLYPointCloudRoot",r.addChild(i);const n=i.addComponent(d.PointCloudRenderer);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 Dr.Mesh:{const a=gh(e),r=new d.Object3D;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 Kt,f=Rt.normalizePath(this.baseUrl+a.textureFiles[l]);o.push(D.res.loadTexture(f).then(h=>{c.baseMap=h,n.set(l,c)}))}await Promise.all(o)}n.size===0&&n.set(0,new Kt);for(const[o,l]of i){const c=[];for(const A of l){const m=A*3;c.push(a.indices[m+0],a.indices[m+1],a.indices[m+2])}const f=new Ve;f.setAttribute(L.position,a.position),f.setAttribute(L.normal,a.normal),a.uv&&f.setAttribute(L.uv,a.uv),a.color&&f.setAttribute(L.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 h=n.get(o);h||(h=n.values().next().value||new Kt);const u=new d.Object3D;u.name=`PLYMesh_Texture_${o}`;const g=u.addComponent(d.MeshRenderer);g.geometry=f,g.material=h,r.addChild(u)}this.data=r;break}}}verification(){return!!this.data}}class ph{async parse(e){const t=new DataView(e),a=Un(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,h=new xi(e,f,n,o),u=f+n+o,g=h.header.POINTS_LENGTH||0,A=new vn(e,g,u,l,c);return{version:r,featureTable:h,batchTable:A}}}class Ah extends ph{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 g=await this.parseDraco(a,o,i);l=g.positions,c=g.colors,g.normals}else l=this.parsePositions(a,i),c=this.parseColors(a,i),this.parseNormals(a,i);const f=new d.Object3D,h=f.addComponent(d.PointCloudRenderer);h.initFromData(l,c,i),h.setPointShape("circle"),h.setPointSize(4);const u=a.getData("RTC_CENTER",1,"FLOAT","VEC3");return u&&f.transform.localPosition.set(u[0],u[1],u[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,h=c*4;l[h+0]=r[f+0],l[h+1]=r[f+1],l[h+2]=r[f+2],l[h+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]),h=c*4;l[h+0]=f[0],l[h+1]=f[1],l[h+2]=f[2],l[h+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 h,u;f<0?(h=(l>=0?1:-1)*(1-Math.abs(c)),u=(c>=0?1:-1)*(1-Math.abs(l))):(h=l,u=c);const g=Math.sqrt(h*h+u*u+f*f),A=r*3;a[A+0]=h/g,a[A+1]=u/g,a[A+2]=f/g}return a}async parseDraco(e,t,a){throw new Error("Draco compression not yet implemented")}}class Dh extends dt{static format=He.BIN;async parseBuffer(e){const a=await new Ah().parse(e),r=new d.Object3D;r.name="PNTS",r.addChild(a),this.data=r}verification(){if(this.data)return!0;throw new Error("PNTSParser: Parse failed")}}class yo{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 Co{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 yo;a.formBytes(e.readBytesArray()),this.boneData[t]=a,this.boneMap.set(a.boneName,a)}}}class _h extends dt{static format=He.BIN;static parser(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new Co;i.formBytes(e.readBytesArray()),D.res.addObj(i.name,i)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}L.position,L.normal,L.color,L.TANGENT,L.uv,L.TEXCOORD_1,L.TEXCOORD_2,L.TEXCOORD_2,L.TEXCOORD_4,L.TEXCOORD_5,L.TEXCOORD_6,L.TEXCOORD_7,L.joints0,L.weights0;var Y=(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))(Y||{});class Tn{static GetMaterial(e){let t=e,a=t.split("/");t=a[a.length-1],a=t.split("."),t=a[a.length-1];let r=Ho(t);if(r){let i=new Dt;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 Y.color:case Y.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 Y.single:case Y.float:case Y.int:case Y.int16:case Y.int32:case Y.uint:case Y.uint32:case Y.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 Y.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 Y.vector2:case Y.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 Y.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 Y.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 Na{static parser(e){switch(e.readInt32()){case Y.single:return{t:Y.single,v:e.readFloat32()};case Y.boolean:return{t:Y.boolean,v:e.readBoolean()};case Y.int:return{t:Y.int,v:e.readInt32()};case Y.int16:return{t:Y.int16,v:e.readInt16()};case Y.int32:return{t:Y.int32,v:e.readInt32()};case Y.float:return{t:Y.float,v:e.readFloat32()};case Y.long:return{t:Y.long,v:e.readFloat64()};case Y.uint:return{t:Y.uint,v:e.readUnit32()};case Y.uint32:return{t:Y.uint32,v:e.readUnit32()};case Y.uint64:return{t:Y.uint64,v:e.readUnit32()};case Y.double:return{t:Y.double,v:e.readFloat64()};case Y.string:return{t:Y.string,v:e.readUTF()};case Y.singleArray:return{t:Y.singleArray,v:e.readFloatArray()};case Y.stringArray:return{t:Y.stringArray,v:e.readStringArray()};case Y.floatArray:return{t:Y.floatArray,v:e.readFloatArray()};case Y.vector2:return{t:Y.vector2,v:e.readVector2()};case Y.vector3:return{t:Y.vector3,v:e.readVector3()};case Y.vector4:return{t:Y.vector4,v:e.readVector4()};case Y.color:return{t:Y.color,v:e.readColor()};case Y.color32:return{t:Y.color32,v:e.readColor()};case Y.animationCurve:return{t:Y.animationCurve,v:null};case Y.quaternion:return{t:Y.quaternion,v:e.readQuaternion()};case Y.matrix4x4:return{t:Y.matrix4x4,v:null};case Y.mesh:{let o=e.readUTF(),l=D.res.getGeometry(o);return{t:Y.mesh,v:l}}case Y.texture:{let o=e.readUTF(),l=D.res.getTexture(o);return{t:Y.texture,v:l}}case Y.material:{let o=e.readUTF(),l=D.res.getMat(o);return{t:Y.material,v:l}}case Y.materials:{let o=e.readStringArray(),l=[];for(let c=0;c<o.length;c++){const f=o[c];let h=D.res.getMat(f);l.push(h)}return{t:Y.materials,v:l}}case Y.skeleton:break;case Y.animClip:{let o=[],l=e.readInt32();for(let c=0;c<l;c++){let f=new Vo;f.formBytes(e),o.push(f)}return{t:Y.animClip,v:o}}case Y.vector2Int:return{t:Y.vector2Int,v:e.readVector2int()};case Y.int32List:return{t:Y.int32List,v:e.readInt32List()};case Y.colorList:let a=e.readInt32(),r=[];for(let o=0;o<a;o++){const l=Na.parser(e).v;r.push(l)}return{t:Y.colorList,v:r};case Y.color32List:let i=e.readInt32(),n=[];for(let o=0;o<i;o++){const l=Na.parser(e).v;n.push(l)}return{t:Y.color32List,v:n}}}}class So{key;type;_data;getValue(){return this._data}formBytes(e){this.key=e.readUTF();let{t,v:a}=Na.parser(e);this.type=t,this._data=a}}class Bh{property;name;texture;texelSize;wrapModeU;wrapModeV;wrapModeW;wrapMode;anisoLevel;dimension;filterMode}class vh extends dt{static format=He.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=[],h=[],u=i.readInt32();for(let m=0;m<u;m++){let p=new So;p.formBytes(i),f.push(p)}let g=i.readInt32();for(let m=0;m<g;m++){let p=i.readBytesArray(),_=new Bh;_.property=p.readUTF(),_.name=p.readUTF(),_.texture=D.res.getTexture(_.name),_.texelSize=p.readVector2(),_.wrapModeU=p.readUnit32(),_.wrapModeV=p.readUnit32(),_.wrapModeW=p.readUnit32(),_.wrapMode=p.readUnit32(),_.anisoLevel=p.readUnit32(),_.dimension=p.readUnit32(),_.filterMode=p.readUnit32(),h.push(_)}let A=Tn.GetMaterial(c);A.name=n;for(let m=0;m<l.length;m++){const p=l[m];A.shader.setDefine(p,!0)}Tn.applyMaterialTexture(A,h),Tn.applyMaterialProperties(A,f),D.res.addMat(o,A)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class xo{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 Fo{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 xo;r.formBytes(t),this.blendShapePropertyDatas.push(r),this.blendShapeMap.set(r.shapeName,r)}return e}}class Uh{name;meshName;meshID;vertexCount;vertexStrip;vertexBuffer;indices;attributes;bones;bindPose;blendShapeData}class yh extends dt{static format=He.BIN;async parseBuffer(e){}static parserMeshs(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new Uh,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 Fo,i.blendShapeData.formBytes(n));let c=n.readBytesArray(),f=n.readBytesArray(),h=c.readInt32(),u=0,g=[];for(let B=0;B<h;B++)g[B]={},g[B].att=rm[c.readUTF()],g[B].dim=c.readInt32(),u+=g[B].dim,g[B].format=c.readUTF();i.vertexCount=c.readInt32(),i.vertexBuffer=f.getFloat32Array();let A=n.readInt32Array(),m=[],p=n.readInt32();for(let B=0;B<p;B++){let U=n.readInt32(),C=n.readInt32(),y=n.readInt32(),x=n.readInt32(),k=n.readInt32(),E=n.readInt32();n.readVector3(),n.readVector3();let S={indexStart:C,indexCount:y,vertexStart:x,vertexCount:E,firstStart:k,topology:U,index:B};m.push(S)}A.length>65535?i.indices=new Uint32Array(A):i.indices=new Uint16Array(A);let _=new Ve;if(_.vertexDim=u,_.geometryType=Ft.compose_bin,_.setIndices(i.indices),_.setAttribute(L.all,i.vertexBuffer),o&&(_.skinNames=i.bones,_.bindPose=i.bindPose),l){_.blendShapeData=i.blendShapeData,_.morphTargetsRelative=!0,_.morphTargetDictionary={};for(let B=0;B<i.blendShapeData.blendCount;B++){_.setAttribute("a_morphPositions_"+B,i.blendShapeData.blendShapePropertyDatas[B].blendPositionList),_.setAttribute("a_morphNormals_"+B,i.blendShapeData.blendShapePropertyDatas[B].blendNormalList);for(let U=0;U<i.blendShapeData.blendCount;U++){let C=i.blendShapeData.shapeNames[U],y=i.blendShapeData.shapeIndexs[U];_.morphTargetDictionary[C]=y}}}for(let B=0;B<g.length;B++){const U=g[B].att;_.setAttribute(U,null)}for(let B=0;B<m.length;B++){const U=m[B];_.addSubGeometry(U)}_.name=i.meshName,D.res.addGeometry(i.meshID,_)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}let rm={Position:L.position,Normal:L.normal,Color:L.color,Tangent:L.TANGENT,TexCoord0:L.uv,TexCoord1:L.TEXCOORD_1,TexCoord2:L.TEXCOORD_2,TexCoord3:L.TEXCOORD_2,TexCoord4:L.TEXCOORD_4,TexCoord5:L.TEXCOORD_5,TexCoord6:L.TEXCOORD_6,TexCoord7:L.vIndex,BlendIndices:L.joints0,BlendWeight:L.weights0};class Mn 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 Mn(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 le;return e.x=this.readInt32(),e.y=this.readInt32(),e}readVector2(){let e=new le;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 fe;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 ee;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 Ch extends dt{static format=He.TEXT;static async parserTexture(e,t,a){let r=e.readInt32(),i=[];for(let o=0;o<r;o++){let l=e.readUTF();Sh.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 D.res.loadBitmapTextures(i,D.setting.loader.numConcurrent,a,!0);for(const o of n)D.res.addTexture(o.name,o)}verification(){if(this.data)return!0;throw new Error("verify failed.")}}var im=Object.getOwnPropertyDescriptor,nm=(s,e,t,a)=>{for(var r=a>1?void 0:a?im(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.LitSSSShader=class extends gt{constructor(){super(),Z.register("PBRLitSSSShader",bd);let e=new Xe("PBRLitSSSShader","PBRLitSSSShader");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.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 nh(this)]}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new fe(0,0,1,1)),this.setUniformVector4("transformUV2",new fe(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformColor("emissiveColor",new J(1,1,1)),this.setUniformVector4("materialF0",new fe(.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(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _SSSMap(e){this.setTexture("sssMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Nt.none:t.shaderState.cullMode}set _SkinColor(e){this.setUniformColor("skinColor",e)}set _SkinPower(e){this.setUniformFloat("skinPower",e)}set _SkinColorIns(e){this.setUniformFloat("skinColorIns",e)}set curveFactor(e){this.setUniformFloat("curveFactor",e)}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=me.NONE:t.blendMode=me.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.LitSSSShader=nm([wa(d.LitSSSShader,"LitSSSShader")],d.LitSSSShader);var sm=Object.getOwnPropertyDescriptor,om=(s,e,t,a)=>{for(var r=a>1?void 0:a?sm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.LitShader=class extends gt{constructor(){super();let e=new Xe("PBRLItShader","PBRLItShader");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.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 fe(0,0,1,1)),this.setUniformVector4("transformUV2",new fe(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformColor("emissiveColor",new J(0,0,0)),this.setUniformVector4("materialF0",new fe(.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=D.res.grayTexture,this._BumpMap=D.res.normalTexture,this._MaskTex=D.res.maskTexture}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Nt.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=me.NONE:t.blendMode=me.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.LitShader=om([wa(d.LitShader,"LitShader")],d.LitShader);class Nn{comName;data;static parser(e){let t=e.readBytesArray(),a=new Nn;a.comName=t.readUTF(),a.data=[];let r=t.readInt32();for(let i=0;i<r;i++){let n=new So;n.formBytes(t),a.data.push(n)}return a}}class Zi{name;parentName;position;rotation;scale;comDatas;child;static parser(e){let t=e.readBytesArray(),a=new Zi;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=Nn.parser(t);a.comDatas.push(o)}let i=t.readInt32();for(let n=0;n<i;n++){const o=Zi.parser(t);a.child.push(o)}return a}}class Sh extends dt{static useWebp=!0;static format=He.BIN;avatarDic;nodeData;async parseBuffer(e){this.avatarDic={};let t=new Mn(e,0);await Ch.parserTexture(t,this,this.loaderFunctions),_h.parser(t,this),yh.parserMeshs(t,this),vh.parserMaterial(t,this),this.nodeData=this.parserPrefabNode(t),this.data=this.data=this.parserNodeTree(this.nodeData)}parserPrefabNode(e){return Zi.parser(e)}parserNodeTree(e){let t=new d.Object3D;if(t.localPosition=b.serialize(e.position),t.localQuaternion=ee.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=Xo(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 lm{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 cm=Object.getOwnPropertyDescriptor,fm=(s,e,t,a)=>{for(var r=a>1?void 0:a?cm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.FatLineShader=class extends gt{constructor(){super();const e=new Xe("FatLine_VS","FatLine_FS");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);const t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1,t.cullMode=Nt.none,t.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 le(1920,1080));const e=new R;this.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}},d.FatLineShader=fm([wa(d.FatLineShader,"FatLineShader")],d.FatLineShader);var dm=Object.getOwnPropertyDescriptor,hm=(s,e,t,a)=>{for(var r=a>1?void 0:a?dm(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.UnLitShader=class extends gt{constructor(){super();let e=new Xe("UnLit","UnLit");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.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 fe(0,0,1,1)),this.setUniformVector4("transformUV2",new fe(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformFloat("alphaCutoff",0)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Nt.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=me.NONE:t.blendMode=me.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.UnLitShader=hm([wa(d.UnLitShader,"UnLitShader")],d.UnLitShader);var um=Object.getOwnPropertyDescriptor,bm=(s,e,t,a)=>{for(var r=a>1?void 0:a?um(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.UnLitTexArrayShader=class extends gt{constructor(){super(),Z.register("VertexAttributeIndexShader",dd),Z.register("UnLitTextureArray",gd);let e=new Xe("UnLitTextureArray","UnLitTextureArray");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.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 fe(0,0,1,1)),this.setUniformVector4("transformUV2",new fe(0,0,1,1)),this.setUniformColor("baseColor",new J),this.setUniformFloat("alphaCutoff",0)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Nt.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=me.NONE:t.blendMode=me.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.UnLitTexArrayShader=bm([wa(d.UnLitTexArrayShader,"UnLitTexArrayShader")],d.UnLitTexArrayShader);const _r=-1,Br=0,ko=1,xh=2,Pa=3,gm=6378137,mm=1/298.257223563,pm=6356752314245179e-9,Am=Symbol("PLUGIN_REGISTERED");class Eo{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 Fh=2**30;class kh{minSize=6e3;maxSize=8e3;minBytesSize=.3*Fh;maxBytesSize=.4*Fh;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 wo{maxJobs=6;autoUpdate=!0;priorityCallback=null;_items=[];_callbacks=new Map;_currJobs=0;_scheduled=!1;_schedulingCallback;constructor(){this._schedulingCallback=e=>{requestAnimationFrame(e)}}set schedulingCallback(e){this._schedulingCallback=e}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),this.autoUpdate&&this._scheduleJobRun(),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))}_scheduleJobRun(){this._scheduled||(this._scheduled=!0,this._schedulingCallback(()=>{this._scheduled=!1,this._tryRunJobs()}))}_tryRunJobs(){this.sort();const e=this.maxJobs;let t=0;const a=()=>{this._currJobs--,this.autoUpdate&&this._scheduleJobRun()};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 Eh(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 Dm(s,e){let t=s;for(;t;){const a=t.depth,r=t.parent;e(t,r,a),t=r}}const Pn={inView:!1,error:1/0,distanceFromCamera:1/0},wh=!0;function Rh(s){return s===Pa||s===_r}function vr(s,e){return s.lastFrameVisited===e&&s.used}function Ih(s){return s.childrenProcessed===s.children.length}function Ro(s){return s.hasUnrenderableContent||s.parent!==null&&s.parent.geometricError<s.geometricError}function Io(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,Pn),s.inFrustum=Pn.inView,s.error=Pn.error,s.distanceFromCamera=Pn.distanceFromCamera)}function Qo(s,e,t=!1){s.used||(t||(s.used=!0,e.stats.used++),e.markTileUsed(s),s.inFrustum===!0&&e.stats.inFrustum++)}function _m(s,e){if(s.canTraverse&&s.canTraverseFrame===e.frameCount)return s.canTraverse;let t=!1;return s.error<=e.errorTarget&&!Ro(s)||s.depth>=e.maxDepth||!s.children||s.children.length===0?t=!1:t=!0,s.canTraverse=t,s.canTraverseFrame=e.frameCount,t}function To(s,e,t=!1){if(e.ensureChildrenArePreprocessed(s),Io(s,e),Qo(s,e,t),Ro(s)&&Ih(s)){const a=s.children;for(let r=0,i=a.length;r<i;r++)To(a[r],e,t)}}function Vn(s,e){if(e.ensureChildrenArePreprocessed(s),Io(s,e),!s.inFrustum)return;if(!_m(s,e)){Qo(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];Vn(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];Vn(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++)To(a[n],e,!0);return}if(Qo(s,e),s.refine==="REPLACE"&&(r&&s.depth!==0||wh))for(let n=0,o=a.length;n<o;n++)To(a[n],e)}function Mo(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(Mo(l,e),vr(l,t)){const c=!Ro(l);let f=!l.hasContent||l.hasRenderableContent&&Rh(l.loadingState)||l.hasUnrenderableContent&&l.loadingState===_r;f=c&&f||l.allChildrenReady,i=i&&f}}s.allChildrenReady=i}}function Qh(s,e){if(e.ensureChildrenArePreprocessed(s),vr(s,e.frameCount)&&(s.hasContent&&e.queueTileForDownload(s),Ih(s))){const t=s.children;for(let a=0,r=t.length;a<r;a++)Qh(t[a],e)}}function No(s,e){const t=e.stats;if(!vr(s,e.frameCount))return;if(s.isLeaf){s.loadingState===Pa?(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=Rh(s.loadingState)&&r,n=(e.errorTarget+1)*(e.errorThreshold||1),o=s.error<=n,l=s.refine==="ADD",c=s.allChildrenReady||s.depth===0&&!wh;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,h=a.length;f<h;f++){const u=a[f];vr(u,e.frameCount)&&Qh(u,e)}else for(let f=0,h=a.length;f<h;f++)No(a[f],e)}function Po(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):Io(s,e),s.hasRenderableContent&&s.loadingState===Pa){const n=s.__wasSetVisible;s.__wasSetActive!==a&&(e.setTileActive(s,a),s.__wasSetActive=a),n!==r&&(e.setTileVisible(s,r),s.__wasSetVisible=r)}s.usedLastFrame=t;const i=s.children;for(let n=0,o=i.length;n<o;n++)Po(i[n],e)}}class Pr{static s_tmpMatrix=null;_type;_data;_box;get box(){return this._box}_sphere;_matrix;constructor(e){if(Pr.s_tmpMatrix||(Pr.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(),h=i.clone().normalize();this._matrix=new R;const u=this._matrix.rawData;u[0]=c.x,u[1]=c.y,u[2]=c.z,u[3]=0,u[4]=f.x,u[5]=f.y,u[6]=f.z,u[7]=0,u[8]=h.x,u[9]=h.y,u[10]=h.z,u[11]=0,u[12]=t.x,u[13]=t.y,u[14]=t.z,u[15]=1;const g=new b(n*2,o*2,l*2);this._box=new xe(new b(0,0,0),g)}_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 Ir(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 xe(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=Pr.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 xe;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 xe;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 xe;return this.getAABB(a,t),e.containsBox2(a)>0}else if(this._box){const a=new xe;return this.getAABB(a,t),e.containsBox2(a)>0}return!1}}const Th=(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},Mh=(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 Bm{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;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 kh,this.lruCache.unloadPriorityCallback=Mh,this.loadQueue=new wo,this.loadQueue.maxJobs=10,this.loadQueue.priorityCallback=Th,this.processNodeQueue=new wo,this.processNodeQueue.maxJobs=25,this.group=new d.Object3D,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=ko,this.isLoading=!0,this._loadRootTileSet().then(c=>{if(this.rootLoadingState=Pa,this.rootTileSet=c,c.root){const f=this._getBasePath(this.rootURL||""),h=this.preprocessNode(c.root,f,null);this._root=h;const u=new Pr(h.boundingVolume),g=new Ir;u.getSphere(g);const A=new xe;if(u.getAABB(A),this.rtcOffset=new b(-g.center.x,-g.center.y,-g.center.z),this.onRootTileLoaded)try{this.onRootTileLoaded({center:g.center,radius:g.radius,boundingBox:A,rtcOffset:this.rtcOffset})}catch(m){console.warn("Failed to calculate bounding volume for root tile:",m)}}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(),Vn(n,this),Mo(n,this),No(n,this),Po(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,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&&Eh(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,h=1/0;const u=a.worldTransform;for(let g=0,A=r.length;g<A;g++){const m=i[g];let p,_;if(m.isOrthographic){const U=m.pixelSize;p=e.geometricError/U,_=1/0}else{const U=m.sseDenominator;_=n.distanceToPoint(m.position,u),p=_===0?1/0:e.geometricError/(_*U)}const B=i[g].frustum;n.intersectsFrustum(B,u)&&(o=!0,l=Math.max(l,p),c=Math.min(c,_)),f=Math.max(f,p),h=Math.min(h,_)}o?(t.inView=!0,t.error=l,t.distanceFromCamera=c):(t.inView=!1,t.error=f,t.distanceFromCamera=h)}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 cs,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===at.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 Eo?r=e:r=new Eo(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 Pr(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,h=[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 A of h)A.applyMatrix4(n);const u=new xe;h.forEach(A=>{u.expandByPoint(A)}),n.rawData[12]=-c.x,n.rawData[13]=-c.y,n.rawData[14]=-c.z;const g=u.min;n.rawData[13]-=g.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],h=this.preprocessNode(f,t,r);r.children.push(h)}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=ko,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=xh;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,Ys,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"i3dm":{o=(await l.load(n,Ks,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"glb":case"gltf":{o=(await l.load(n,_t,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"pnts":{o=(await l.load(n,Dh,{onProgress:f=>{},onComplete:f=>{}})).data;break}case"json":try{const c=await D.res.loadJSON(n);e.children.length=0,e.childrenProcessed=0;const f=this._getBasePath(n);if(c.root){const h=this.preprocessNode(c.root,f,e);e.children.push(h),e.childrenProcessed=1,this.dispatchEvent({type:"load-tile-set",tileSet:c,url:n})}e.loadingState=Pa;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,e.loadingState=Pa;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 h=f.cached.scene;h.parent&&h.parent.object3D.removeChild(h),h.destroy(!0),f.cached.scene=null}f.loadingState=Br}),e.active&&this.setTileActive(e,!0)}else e.loadingState=_r,this.stats.failed++}markTileUsed(e){this._usedSet.add(e),this.lruCache.markUsed(e)}setTileActive(e,t){t?this._activeTiles.add(e):this._activeTiles.delete(e);const a=e.cached.scene;a&&(t?(this.group.entityChildren.includes(a)||(a.parent&&a.parent.object3D.removeChild(a),this.group.addChild(a)),e.cached.worldTransform&&this._applyWorldTransform(a.transform,e.cached.worldTransform),a.transform.enable=!0):a.transform.enable=!1)}setTileVisible(e,t){t?this._visibleTiles.add(e):this._visibleTiles.delete(e);const a=e.cached.scene;a&&(a.transform.enable=t)}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 D.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(ra.EULER_ANGLES);e.localPosition=a[0];const r=new ee;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(ra.EULER_ANGLES);e.localPosition=a[0];const r=new ee;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===Pa&&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===Pa&&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===Pa&&t.cached.scene&&e(t.cached.scene,t),!1),null)}_estimateBytesUsed(e){let t=0;return e.forChild(a=>{const r=a.getComponent(d.MeshRenderer);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 vm{asset;extras;geometricError;properties;refine;root;extensionsUsed;extensionsRequired;extensions}class Um{boundingVolume;children;geometricError;transform;content;contents;refine;extensions;extras}class ym{boundingVolume;geometricError;refine;content;contents;children;transform;extensions;extras}class Cm{uri;group;metadata}class Sm{class;properties}function xm(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 Fm extends Dt{static count=0;constructor(){super(),Z.register("ColorLitShader",hd),this.shader=new gt;let e=new Xe("ColorLitShader","ColorLitShader");e.passType=se.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",D.res.normalTexture),e.setTexture("emissiveMap",D.res.blackTexture)}clone(){return null}debug(){}}class km extends Dt{constructor(){super(),this.shader=new d.FatLineShader,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 Em extends Dt{constructor(){super();let e=new Xe("LambertShader","LambertShader");e.setShaderEntry("VertMain","FragMain"),e.passType=se.COLOR,e.setUniformVector4("transformUV1",new fe(0,0,1,1)),e.setUniformVector4("transformUV2",new fe(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 gt;a.addRenderPass(e),this.shader=a,this.baseMap=D.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 wm(s,e){}class Rm extends Dt{constructor(){super(),this.shader=new d.UnLitTexArrayShader,this.baseMap=D.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 Vo{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 Ur;n.formBytes(e),this.positionCurves.set(n.path,n)}}let t=e.readInt32();for(let r=0;r<t;r++){let i=new Ur;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 Ur;n.formBytes(e),this.scaleCurves.set(n.path,n)}}let a=e.readInt32();for(let r=0;r<a;r++){let i=new Ur;i.formBytes(e),this.floatCurves.set(i.attribute,i)}}}class Ur{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 Qi;switch(this.k){case 1:this._cacheValue=0;break;case 2:this._cacheValue=new le;break;case 3:this._cacheValue=new b;break;case 4:this._cacheValue=new fe;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);ee.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),ee.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),ee.HELP_2.slerp(ee.HELP_0,ee.HELP_1,o),this._cacheValue.x=ee.HELP_2.x,this._cacheValue.y=ee.HELP_2.y,this._cacheValue.z=ee.HELP_2.z,this._cacheValue.w=ee.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 Hi(0);r.formBytes(e),this.addKeyFrame(r)}}}class Im 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 Qm{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 On{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,h=c.subtract(e).lengthSquared;return f<h?a=i:t=i,this.getClosestParamRec(e,t,a,r)}}var Nh=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(Nh||{});class Tm{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,h=c.lengthSquared;if(f>0&&h>0){let u=(f+h)/8,g=c.div(h).subtract(l.div(f));g.normalize(),g=g.mul(u),r[o*3-1]=e[o].subtract(g),r[o*3+1]=e[o].add(g)}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]),h=c.lengthSquared,u=f.lengthSquared,g=3*i-1,A=(3*i+1)%(this.numControlVertices-1);if(h>0&&u>0){let m=(h+u)/8,p=f.div(u).subtract(c.div(h));p.normalize(),p=p.mul(m),r[g]=e[l].subtract(p),r[A]=e[l].add(p)}else r[g]=e[l],r[A]=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=Pt.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 On(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=Pt.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 On(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 On(i);for(let o=0;o<this.controlVertices.length-1;o+=3){for(let h=0;h<4;h++)i[h]=this.controlVertices[o+h];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 Mm 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 Ph=(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))(Ph||{});const Nm=3.141592653589793;class Pm{}function Vh(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,h=f+l*l;if(h>=0){let A=Math.sqrt(h)-l;return A=A>0?Math.pow(A,a):-Math.pow(-A,a),-i-c/A+A}let u=Math.sqrt(-f),g=Math.acos(-l/u);return u=Math.pow(u,a),u=u-c/u,g=-i+u*Math.cos(g*a),g}function Ln(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 Oh(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]=Vh(n,o,l),i++;let c=e,f=t+e*s[0],h=a+t*s[0]+e*s[0]*s[0];i+=Ln(c,f,h,{r0:s[1],r1:s[2]})}else i+=Ln(t,a,r,{r0:s[1],r1:s[2]});return i}class Va{coeff=[];static EvalSegment(e,t){return e*(e*(e*t[0]+t[1])+t[2])+t[3]}}class er{static kMaxNumSegments=8;segments=[];integrationCache=[];doubleIntegrationCache=[];times=[];segmentCount;constructor(){this.segments[er.kMaxNumSegments]=new Va,this.integrationCache[er.kMaxNumSegments]=0,this.doubleIntegrationCache[er.kMaxNumSegments]=0,this.times[er.kMaxNumSegments]=0}calculateMinMax(e,t){e.x=Math.min(e.x,t),e.y=Math.max(e.y,t)}findMinMaxDoubleIntegrated(){let e=le.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=le.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=Oh(c,i,n,o,l);for(let h=0;h<f;h++){let u=c[h]+t[r];u>=t[r]&&u<a[r]&&this.calculateMinMax(e,this.evaluateIntegrated(u))}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;Oo(i);let n=t-a;e.integrationCache[r]=e.integrationCache[r-1]+Va.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+=Va.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++)Oo(this.segments[e].coeff)}doubleIntegrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)Lh(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<=er.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+Va.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]+Va.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 Va.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 Va,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 Lh(s){s[0]/=20,s[1]/=12,s[2]/=6,s[3]/=2}function Oo(s){s[0]/=4,s[1]/=3,s[2]/=2,s[3]/=1}var Gh=(s=>(s[s.kEMScalar=0]="kEMScalar",s[s.kEMOptimized=1]="kEMOptimized",s[s.kEMOptimizedMinMax=2]="kEMOptimizedMinMax",s[s.kEMSlow=3]="kEMSlow",s))(Gh||{}),zh=(s=>(s[s.kMMCScalar=0]="kMMCScalar",s[s.kMMCCurve=1]="kMMCCurve",s[s.kMMCTwoCurves=2]="kMMCTwoCurves",s[s.kMMCTwoConstants=3]="kMMCTwoConstants",s))(zh||{});class Vm{max;min}class Om{max;min;integrate(){this.max.integrate(),this.min.integrate()}doubleIntegrate(){this.max.doubleIntegrate(),this.min.doubleIntegrate()}findMinMaxIntegrated(){return null}findMinMaxDoubleIntegrated(){return null}}class Wh{minMaxState;minCurve;maxCurve;_scalar=1;_minScalar;constructor(e=1){this._scalar=e,this.minMaxState=0,this.minCurve=new Qi,this.maxCurve=new Qi}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?Cr(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?Cr(e.minCurve.getValue(t)*e.getScalar(),r,a):e.minMaxState==3?Cr(e._minScalar,e._scalar,a):e.minMaxState==2?Cr(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 Lm{value=0;mode=0;spread=0;speed=new Wh;unSerialized(e){this.value=e.value,this.mode=e.mode,this.spread=e.spread,this.speed.unSerialized(e.speed)}}function Gm(s,e){let t=er.isValidCurve(s.max);return e!=2&&e!=3?t:t&&er.isValidCurve(s.min)}function zm(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 Wm(s,e){let t=e.getKeyCount();if(t!=0)if(t==1)Yi(s,e.getKey(0).value);else{let a=t-1;Yi(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,h=[],u=Ln(n,o,l,{r0:h[0],r1:h[1]});for(let g=0;g<u;g++)h[g]>=0&&h[g]+c<f&&Yi(s,Va.EvalSegment(h[g],i.coeff));Yi(s,Va.EvalSegment(f-c,i.coeff))}}}function Yi(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 Jh{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 Jm(s,e){return Math.random()*e+Math.random()*s+(e-s)*Math.random()}function jm(s,e,t){let a=t*Math.random();return Math.random()*e*a+Math.random()*s*a+(e-s)*Math.random()*a}function jh(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=jh(s,e,t)),i=Math.pow(i,t),i*=e-s,i+=s,i}function ya(s){return s>0?Math.floor(s):Math.floor(s)-1}let ve=[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 Lo(s,e){let t=s&15,a=1+(t&7);return t&8&&(a=-a),a*e}function Gn(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 Xi(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 fi(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 $t=[[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 Zm(s){let e=ya(s),t=e+1,a=s-e,r=a-1,i,n,o=1-a*a;o*=o,i=o*o*Lo(ve[e&255],a);let l=1-r*r;return l*=l,n=l*l*Lo(ve[t&255],r),.25*(i+n)}function Ym(s,e){const t=.366025403,a=.211324865;let r,i,n,o=(s+e)*t,l=s+o,c=e+o,f=ya(l),h=ya(c),u=(f+h)*a,g=f-u,A=h-u,m=s-g,p=e-A,_,B;m>p?(_=1,B=0):(_=0,B=1);let U=m-_+a,C=p-B+a,y=m-1+2*a,x=p-1+2*a,k=f&255,E=h&255,S=.5-m*m-p*p;S<0?r=0:(S*=S,r=S*S*Gn(ve[k+ve[E]],m,p));let I=.5-U*U-C*C;I<0?i=0:(I*=I,i=I*I*Gn(ve[k+_+ve[E+B]],U,C));let T=.5-y*y-x*x;return T<0?n=0:(T*=T,n=T*T*Gn(ve[k+1+ve[E+1]],y,x)),40*(r+i+n)}function Xm(s,e,t){const a=.333333333,r=.166666667;let i,n,o,l,c=(s+e+t)*a,f=s+c,h=e+c,u=t+c,g=ya(f),A=ya(h),m=ya(u),p=(g+A+m)*r,_=g-p,B=A-p,U=m-p,C=s-_,y=e-B,x=t-U,k,E,S,I,T,Q;C>=y?y>=x?(k=1,E=0,S=0,I=1,T=1,Q=0):C>=x?(k=1,E=0,S=0,I=1,T=0,Q=1):(k=0,E=0,S=1,I=1,T=0,Q=1):y<x?(k=0,E=0,S=1,I=0,T=1,Q=1):C<x?(k=0,E=1,S=0,I=0,T=1,Q=1):(k=0,E=1,S=0,I=1,T=1,Q=0);let G=C-k+r,q=y-E+r,ge=x-S+r,ie=C-I+2*r,P=y-T+2*r,z=x-Q+2*r,X=C-1+3*r,V=y-1+3*r,ne=x-1+3*r,W=g&255,ce=A&255,te=m&255,de=.6-C*C-y*y-x*x;de<0?i=0:(de*=de,i=de*de*Xi(ve[W+ve[ce+ve[te]]],C,y,x));let he=.6-G*G-q*q-ge*ge;he<0?n=0:(he*=he,n=he*he*Xi(ve[W+k+ve[ce+E+ve[te+S]]],G,q,ge));let Ue=.6-ie*ie-P*P-z*z;Ue<0?o=0:(Ue*=Ue,o=Ue*Ue*Xi(ve[W+I+ve[ce+T+ve[te+Q]]],ie,P,z));let Ne=.6-X*X-V*V-ne*ne;return Ne<0?l=0:(Ne*=Ne,l=Ne*Ne*Xi(ve[W+1+ve[ce+1+ve[te+1]]],X,V,ne)),32*(i+n+o+l)}function Hm(s,e,t,a){const r=.309016994,i=.138196601;let n,o,l,c,f,h=(s+e+t+a)*r,u=s+h,g=e+h,A=t+h,m=a+h,p=ya(u),_=ya(g),B=ya(A),U=ya(m),C=(p+_+B+U)*i,y=p-C,x=_-C,k=B-C,E=U-C,S=s-y,I=e-x,T=t-k,Q=a-E,G=S>I?32:0,q=S>T?16:0,ge=I>T?8:0,ie=S>Q?4:0,P=I>Q?2:0,z=T>Q?1:0,X=G+q+ge+ie+P+z,V,ne,W,ce,te,de,he,Ue,Ne,Ke,K,ae;V=$t[X][0]>=3?1:0,ne=$t[X][1]>=3?1:0,W=$t[X][2]>=3?1:0,ce=$t[X][3]>=3?1:0,te=$t[X][0]>=2?1:0,de=$t[X][1]>=2?1:0,he=$t[X][2]>=2?1:0,Ue=$t[X][3]>=2?1:0,Ne=$t[X][0]>=1?1:0,Ke=$t[X][1]>=1?1:0,K=$t[X][2]>=1?1:0,ae=$t[X][3]>=1?1:0;let oe=S-V+i,ue=I-ne+i,Re=T-W+i,be=Q-ce+i,Se=S-te+2*i,Ie=I-de+2*i,Me=T-he+2*i,ze=Q-Ue+2*i,Vt=S-Ne+3*i,ut=I-Ke+3*i,ar=T-K+3*i,xa=Q-ae+3*i,La=S-1+4*i,Ga=I-1+4*i,ea=T-1+4*i,za=Q-1+4*i,ha=p&255,Mt=_&255,Fa=B&255,ua=U&255,Or=.6-S*S-I*I-T*T-Q*Q;Or<0?n=0:(Or*=Or,n=Or*Or*fi(ve[ha+ve[Mt+ve[Fa+ve[ua]]]],S,I,T,Q));let Lr=.6-oe*oe-ue*ue-Re*Re-be*be;Lr<0?o=0:(Lr*=Lr,o=Lr*Lr*fi(ve[ha+V+ve[Mt+ne+ve[Fa+W+ve[ua+ce]]]],oe,ue,Re,be));let Gr=.6-Se*Se-Ie*Ie-Me*Me-ze*ze;Gr<0?l=0:(Gr*=Gr,l=Gr*Gr*fi(ve[ha+te+ve[Mt+de+ve[Fa+he+ve[ua+Ue]]]],Se,Ie,Me,ze));let zr=.6-Vt*Vt-ut*ut-ar*ar-xa*xa;zr<0?c=0:(zr*=zr,c=zr*zr*fi(ve[ha+Ne+ve[Mt+Ke+ve[Fa+K+ve[ua+ae]]]],Vt,ut,ar,xa));let Wr=.6-La*La-Ga*Ga-ea*ea-za*za;return Wr<0?f=0:(Wr*=Wr,f=Wr*Wr*fi(ve[ha+1+ve[Mt+1+ve[Fa+1+ve[ua+1]]]],La,Ga,ea,za)),27*(n+o+l+c+f)}class Go extends le{static uv_0=new Go;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 fe(i/t,n/a,1/t,1/a)}}class Hi{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 Y.single:{let r=this.getKeyFrame(0);r[a]=t}break;case Y.float:{let r=this.getKeyFrame(0);r[a]=t}break;case Y.vector2:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y}break;case Y.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 Y.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 Y.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 xn,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}=Na.parser(e);this.split(t,a,"value")}{let{t,v:a}=Na.parser(e);this.split(t,a,"inSlope")}{let{t,v:a}=Na.parser(e);this.split(t,a,"outSlope")}this.tangentMode=e.readInt32(),this.weightedMode=e.readInt32();{let{t,v:a}=Na.parser(e);this.split(t,a,"inWeight")}{let{t,v:a}=Na.parser(e);this.split(t,a,"outWeight")}}}class Km{static sub(e,t){switch(e.constructor.name){case"number":return e-t;case"Vector2":{let r=e,i=t;return new le(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 fe(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 ee(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}}}}class Ki{_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 yr{static WalkAble=1}class qi{static SetConst(e){this.EPSILON=e,this.POWER_EPSILON=e*e}static EPSILON=.1;static POWER_EPSILON=this.EPSILON*this.EPSILON}class Tt 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)<qi.POWER_EPSILON}static calcDistance(e,t){return Tt.CALC_VECTOR3D3.setTo(e.x-t.x,e.y-t.y,e.z-t.z),Tt.CALC_VECTOR3D3.length}}class Zh{_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,yr.WalkAble,yr.WalkAble);for(a of t)if(a.closeId!=this._findIndex&&!(a==e||!a.walkAble)){var r=e.gg+Tt.calcDistance(a,e)*a.costMultiplier,i=Tt.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 Ca extends Tt{_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 Ca(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 Sa{_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=yr.WalkAble,Tt.CALC_VECTOR3D1.setTo(e.x-t.x,e.y-t.y,e.z-t.z),this._edgeSize=Tt.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 Ca(this._pointA,this),this.fatPointB=this.fatPointB||new Ca(this._pointB,this),this.fatPointA.radius!=e&&(Sa.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),Sa.CALC_FAT_VECTOR.scaleBy(e),Sa.CALC_FAT_VECTOR.incrementBy(this._pointA),this.fatPointA.copyFrom(Sa.CALC_FAT_VECTOR),this.fatPointA.radius=e),this.fatPointB.radius!=e&&(Sa.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),Sa.CALC_FAT_VECTOR.scaleBy(-e),Sa.CALC_FAT_VECTOR.incrementBy(this._pointB),this.fatPointB.copyFrom(Sa.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 Tt.equalPoint(e,this._pointA)?this._pointA:Tt.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 Tt.equalPoint(e,this._pointA)?this._pointA:Tt.equalPoint(e,this._pointB)?this._pointB:null}get pointA(){return this._pointA}get pointB(){return this._pointB}get walkAble(){return(this._edgeMask&yr.WalkAble)==yr.WalkAble}testMask(e){return(this._edgeMask&e)==e}}class pe{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=pe.RAY_1,this.rayB=pe.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(pe.TEST_RAY.setTo(a.x-this.curPoint.x,0,a.z-this.curPoint.z),this.isPointAtCenter(pe.TEST_RAY,this.rayA,this.rayB)){this.hasCrossPoint(t.pointA,t.pointB,this.rayAPoint,this.rayA)?(this.rayB.copyFrom(pe.TEST_RAY),a instanceof Tt?this.rayBPoint=a:this.rayBPoint=null):(this.rayA.copyFrom(pe.TEST_RAY),a instanceof Tt?this.rayAPoint=a:this.rayAPoint=null);var i=t.getAnotherPoint(a);pe.TEST_RAY.setTo(i.x-this.curPoint.x,0,i.z-this.curPoint.z),(i==this.rayAPoint||i==this.rayBPoint||this.isPointAtCenter(pe.TEST_RAY,this.rayA,this.rayB))&&(this.cornerEdge=t)}else{var n;if(pe.TEST_RAY_1.copyFrom(t.pointA),pe.TEST_RAY_1.decrementBy(this.curPoint),pe.TEST_RAY_2.copyFrom(t.pointB),pe.TEST_RAY_2.decrementBy(this.curPoint),pe.TEST_RAY_1.y=0,pe.TEST_RAY_2.y=0,this.isPointAtCenter(this.rayA,pe.TEST_RAY_1,pe.TEST_RAY_2)||this.isPointAtCenter(this.rayB,pe.TEST_RAY_1,pe.TEST_RAY_2)?n=!1:n=!0,n)return this.isPointAtCenter(this.rayA,pe.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1}return!0}checkEndPoint(e){return pe.TEST_RAY.setTo(e.x-this.curPoint.x,0,e.z-this.curPoint.z),this.isPointAtCenter(pe.TEST_RAY,this.rayA,this.rayB)?!0:(this.isPointAtCenter(this.rayA,pe.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){pe.CALC_CROSS_POINT.copyFrom(t),pe.CALC_CROSS_POINT.decrementBy(e);let i=pe.CALC_CROSS_POINT.x*r.z-r.x*pe.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),pe.CALC_CROSS_POINT.scaleBy(n),pe.CALC_CROSS_POINT.incrementBy(e),pe.CALC_CROSS_POINT.clone()}calcCrossPointOut(e,t,a,r){pe.CALC_CROSS_POINT.copyFrom(t),pe.CALC_CROSS_POINT.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(pe.CALC_CROSS_POINT.x*r.z-r.x*pe.CALC_CROSS_POINT.z);return i<=1&&i>=0?null:(pe.CALC_CROSS_POINT.scaleBy(i),pe.CALC_CROSS_POINT.incrementBy(e),pe.CALC_CROSS_POINT.clone())}hasCrossPoint(e,t,a,r){pe.CALC_CROSS_TEST.copyFrom(t),pe.CALC_CROSS_TEST.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(pe.CALC_CROSS_TEST.x*r.z-r.x*pe.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,pe.RAY_1.setTo(0,0,0),pe.RAY_2.setTo(0,0,0)}}class tr{_aiRadius=0;_router;_result;_tempPublicEdgeList=new Array;_tempSamePlaneList=new Array;static CROSS_TEST_DIRECTION=new b;constructor(){this._router=new pe}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,qi.EPSILON)!=Vr.INTERSECT||a[a.length-1].plane.classifyPoint(t,qi.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,qi.EPSILON)==Vr.INTERSECT);this._router.continuePass(e,t,this._tempPublicEdgeList[0]),i=this._tempPublicEdgeList.length;var f,h,u,g;for(r=0;r<i;r++)o=this._tempPublicEdgeList[r],n=a[r+1],g=r==i-1,g?l=t:l=n.getEdgeAgainstPoint(o),u=this._router.passEdge(o,this._tempPublicEdgeList[r+1],l,g),u||(f=this._router.cornerPoint,h=this._router.cornerEdge,r=this._tempPublicEdgeList.indexOf(h),this._router.continuePass(f,t,this._tempPublicEdgeList[r+1]));this.pushAllPathPoint2(e,t),this._result.length>=3&&(this.optimusTerminusFat(),this.optimusByRadius());let A=[];for(let m of this._result)A.push(new b().copyFrom(m));this._result=A}optimusTerminusFat(){var e,t,a;a=this._result[1],a instanceof Ca&&(e=a),a=this._result[this._result.length-2],a instanceof Ca&&(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 h=f+1;h<a&&(i=this._tempPublicEdgeList[h],o=i.crossPoint,!o);h++);o==null&&(o=t),l=this.getFatPoint(r,o),l?this._result.push(l):(o==n?c=o.clone():(tr.CROSS_TEST_DIRECTION.setTo(o.x-n.x,0,o.z-n.z),c=this._router.calcCrossEdge(r,n,tr.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,h,u,g,A,m;for(m=0;m<t;m++)c=f=h=null,n=o=l=null,g=!1,A=null,a=this._result[m],r=this._result[m+1],i=this._result[m+2],a instanceof Ca&&(n=a),r instanceof Ca&&(o=r),i instanceof Ca&&(l=i),n&&(c=n.ownerPoint),o&&(f=o.ownerPoint),l&&(h=l.ownerPoint),c&&f&&c==f&&f!=h&&(g=!0),h&&f&&h==f&&c!=f&&(g=!0),g&&(tr.CROSS_TEST_DIRECTION.copyFrom(a),tr.CROSS_TEST_DIRECTION.decrementBy(i),u=o.ownerEdge,g=this._router.hasCrossPoint(u.pointA,u.pointB,i,tr.CROSS_TEST_DIRECTION),g&&(A=this._router.calcCrossPointOut(f,r,i,tr.CROSS_TEST_DIRECTION)),A&&(e[m+1]=A))}getFatPoint(e,t){if(e==null)return null;var a;t instanceof Ca&&(a=t);var r;return a?r=a.ownerPoint:r=e.getEqualPoint(t),r==null?null:(a=e.getFatPoint(r),a)}}class Yh extends b{_id=0;_plane;_points=new Array;_edges=new Array;_neibourTriangles=new Ki;_pointAgainstEdge=new Ki;_edgeAgainstPoint=new Ki;_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 Qt,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=yr.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 Jh,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(yr.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 qm{_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 Ki,this.initPoints(e),this.initEdgesAndTriangles(t),this.createConnections(),this._nav3dAstar=new Zh,this._nav3dFunnel=new tr,this._terrainQuad=new ah(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 Tt(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 Yh(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 Sa(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 zo{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 zo;return e.setTo(this.x,this.y),e}normalize(){var e=length;e!=0&&this.setTo(this.x/e,this.y/e)}}class Oa extends Ve{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 xe(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(L.position,r),this.setAttribute(L.normal,i),this.setAttribute(L.uv,n),this.setAttribute(L.TEXCOORD_1,n),this.addSubGeometry({indexStart:0,indexCount:o.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Xh extends Ve{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=Gt(),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;A(),this.openEnded===!1&&(this.radiusTop>0&&m(!0),this.radiusBottom>0&&m(!1));let f=new Float32Array(t),h=new Float32Array(a),u=new Float32Array(r),g=new Uint16Array(i);this.setAttribute(L.position,f),this.setAttribute(L.normal,h),this.setAttribute(L.uv,u),this.setAttribute(L.TEXCOORD_1,u),this.setIndices(g);function A(){const p=new b,_=new b;let B=0;const U=(e.radiusBottom-e.radiusTop)/e.height;for(let C=0;C<=e.heightSegments;C++){const y=[],x=C/e.heightSegments,k=x*(e.radiusBottom-e.radiusTop)+e.radiusTop;for(let E=0;E<=e.radialSegments;E++){const S=E/e.radialSegments;let I=S*e.thetaLength+e.thetaStart;E==e.radialSegments&&Math.abs(e.thetaLength-e.thetaStart)==Math.PI*2&&(I=0);const T=Math.sin(I),Q=Math.cos(I);_.x=k*T,_.y=-x*e.height+l,_.z=k*Q,t.push(_.x,_.y,_.z),p.set(T,U,Q).normalize(),a.push(p.x,p.y,p.z),r.push(S,1-x),y.push(n++)}o.push(y)}for(let C=0;C<e.radialSegments;C++)for(let y=0;y<e.heightSegments;y++){const x=o[y][C],k=o[y+1][C],E=o[y+1][C+1],S=o[y][C+1];i.push(x,k,S),i.push(k,E,S),B+=6}e.addGroup(c,B,0),c+=B}function m(p){const _=n,B=new le,U=new b;let C=0;const y=p===!0?e.radiusTop:e.radiusBottom,x=p===!0?1:-1;for(let E=1;E<=e.radialSegments;E++)t.push(0,l*x,0),a.push(0,x,0),r.push(.5,.5),n++;const k=n;for(let E=0;E<=e.radialSegments;E++){const I=E/e.radialSegments*e.thetaLength+e.thetaStart,T=Math.cos(I),Q=Math.sin(I);U.x=y*Q,U.y=l*x,U.z=y*T,t.push(U.x,U.y,U.z),a.push(0,x,0),B.x=T*.5+.5,B.y=Q*.5*x+.5,r.push(B.x,B.y),n++}for(let E=0;E<e.radialSegments;E++){const S=_+E,I=k+E;p===!0?i.push(I,I+1,S):i.push(I+1,I,S),C+=3}e.addGroup(c,C,p===!0?1:2),c+=C}}}class Hh extends Ve{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 xe(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),h=0,u=0,g=0,A=0;for(let m=0;m<=r;m++)for(let p=0;p<=i;p++){const _=p/i,B=m/r,U=_*e,C=B*Math.PI*2;if(o[h++]=(t+a*Math.cos(C))*Math.sin(U),o[h++]=a*Math.sin(C),o[h++]=(t+a*Math.cos(C))*Math.cos(U),l[u++]=Math.sin(U)*Math.cos(C),l[u++]=Math.sin(C),l[u++]=Math.cos(U)*Math.cos(C),c[g++]=_,c[g++]=B,p<i&&m<r){const y=i+1,x=y*m+p,k=y*(m+1)+p,E=y*(m+1)+p+1,S=y*m+p+1;f[A++]=x,f[A++]=S,f[A++]=k,f[A++]=S,f[A++]=E,f[A++]=k}}this.setIndices(f),this.setAttribute(L.position,o),this.setAttribute(L.normal,l),this.setAttribute(L.uv,c),this.setAttribute(L.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class $m extends Ve{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(L.position,t),this.setAttribute(L.normal,a),this.setAttribute(L.uv,r),this.setAttribute(L.TEXCOORD_1,r),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class ep extends Ve{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(L.position,t),this.setAttribute(L.normal,a),this.setAttribute(L.uv,r),this.setAttribute(L.TEXCOORD_1,r),this.setAttribute(L.vIndex,i),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class tp extends yn{_internalTexture;_minSize=32;_skyColor;constructor(e){super(),this._skyColor=e,this._internalTexture=new As;let t=[];return D.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,D.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 ap extends d.Object3D{length=100;thickness=.1;constructor(e,t=.1){super(),this.length=e,this.thickness=t,this.init()}init(){let e=new d.Object3D,t=new d.Object3D,a=new d.Object3D,r=new Oa(2,2,2),i=new Oa(2,2,2),n=new Oa(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(d.MeshRenderer),h=t.addComponent(d.MeshRenderer),u=a.addComponent(d.MeshRenderer);f.geometry=r,f.material=o,f.castShadow=!1,h.geometry=i,h.material=l,h.castShadow=!1,u.geometry=n,u.material=c,u.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 rp{static merge(e,t,a){}static mergeNumber(e,t,a){let r=a||new Ve,i=e.getAttribute(L.position).data.length/3,n=new Float32Array(i*t);for(const f of e.vertexAttributeMap){let h=f[1].attribute;if(h==L.indices)continue;let u=e.getAttribute(h).data,g=u.length,A=new Float32Array(g*t);for(let m=0;m<t;m++){A.set(u,g*m);for(let p=0;p<i;p++)n[i*m+p]=m}r.setAttribute(h,A)}r.setAttribute(L.vIndex,n);let o=e.getAttribute(L.indices).data,l=o.length,c=new Uint32Array(o.length*t);for(let f=0;f<t;f++)for(let h=0;h<l;h++){let u=f*i,g=f*l;const A=o[h]+u;c[g+h]=A}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 ip extends d.Object3D{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 Ve;n.setIndices(t.length>Uint16Array.length?new Uint32Array(t):new Uint16Array(t)),n.setAttribute(L.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=me.ADD,o.castReflection=!1;let l=this.addComponent(d.MeshRenderer);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 Ve;r.setIndices(a),r.setAttribute(L.position,t),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});{let i=new d.Object3D,n=i.addComponent(d.MeshRenderer);n.geometry=r;let o=n.material=new Bt;o.baseColor=new J(1,0,0,.5),o.blendMode=me.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}{let i=new d.Object3D;i.rotationY=90;let n=i.addComponent(d.MeshRenderer);n.geometry=r;let o=n.material=new Bt;o.baseColor=new J(0,1,0,.5),o.blendMode=me.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}}}class np{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 sp{static boxGeo;static planeGeo;static sphere;static material;static materialMap;static initHeap(){this.boxGeo||(this.boxGeo=new Oa),this.planeGeo||(this.planeGeo=new qr(1,1,1,1,b.UP)),this.sphere||(this.sphere=new Rr(1,35,35)),this.material||(this.material=new Kt),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 d.Object3D,t=e.addComponent(d.MeshRenderer);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 Kt,t.baseMap=e,this.materialMap.set(e,t)),t.clone()}static GetPlane(e){this.initHeap();let t=new d.Object3D,a=t.addComponent(d.MeshRenderer);a.geometry=this.planeGeo;let r=this.GetMaterial(e);return r.blendMode=me.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 Kt;o.roughness=.5,o.metallic=.1,o.baseColor=new J(r,i,n,1);let l=new d.Object3D,c=l.addComponent(d.MeshRenderer);return c.castGI=!0,c.geometry=new Oa(e,t,a),c.material=o,l}static GetSingleSphere(e,t,a,r){this.initHeap();let i=new Kt;i.baseColor=new J(t,a,r,1);let n=new d.Object3D,o=n.addComponent(d.MeshRenderer);return o.castGI=!0,o.geometry=new Rr(e,20,20),o.material=i,n}static get Sphere(){this.initHeap();let e=new d.Object3D,t=e.addComponent(d.MeshRenderer);return t.geometry=this.sphere,t.material=this.material,e}static GetSingleCube2(e,t=10){this.initHeap();let a=new d.Object3D,r=a.addComponent(d.MeshRenderer);return r.castShadow=!1,r.geometry=new Oa(t,t,t),r.material=e,a}static GetPointLight(e,t,a,r,i,n,o=1,l=!0){let c=new d.Object3D,f=c.addComponent(d.PointLight);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 h=this.GetSingleSphere(.1,1,1,1);return c.addChild(h),f}}var M=(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))(M||{}),da=(s=>(s[s.Local=0]="Local",s[s.Global=1]="Global",s))(da||{});class zn extends qe{mAxis;mAxisColor;mContainer;mAxisMaterial;mAxisCollider;constructor(){super(),this._enable=!1,this.mAxis=new Array(M.MAX),this.mAxisColor=new Array(M.MAX),this.mAxisMaterial=new Array(M.MAX),this.mAxisCollider=new Array(M.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 d.Object3D;let t=new Bt;t.baseColor=new J(1,0,0),t.depthCompare=st.always,this.mAxisColor[M.X]=t.baseColor,this.mAxisMaterial[M.X]=t;let a=new Bt;a.baseColor=new J(0,1,0),a.depthCompare=st.always,this.mAxisColor[M.Y]=a.baseColor,this.mAxisMaterial[M.Y]=a;let r=new Bt;r.baseColor=new J(0,0,1),r.depthCompare=st.always,this.mAxisColor[M.Z]=r.baseColor,this.mAxisMaterial[M.Z]=r;let i=this.createCustomAxis(M.X),n=this.createCustomAxis(M.Y),o=this.createCustomAxis(M.Z);this.mContainer.addChild(this.mAxis[M.X]=i),this.mContainer.addChild(this.mAxis[M.Y]=n),this.mContainer.addChild(this.mAxis[M.Z]=o),this.mAxisCollider[M.X]=i.getComponent(ca),this.mAxisCollider[M.Y]=n.getComponent(ca),this.mAxisCollider[M.Z]=o.getComponent(ca)}start(){}onEnable(e){this.object3D.addChild(this.mContainer),this.reset()}onDisable(e){this.object3D.removeChild(this.mContainer)}reset(){switch(this.transformSpaceMode){case da.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 da.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(D.inputSystem.mouseX,D.inputSystem.mouseY),r,i;for(let n=0;n<=M.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r&&(!i||i.distance>r.distance||n==M.XYZ)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint},n==M.XYZ)))break}return i}currentAxis=M.NONE;beginPoint=new b;beginMousePos=new b;currentPoint=new b;onMouseDown(e){if(e.mouseCode!=Rn.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(D.inputSystem.mouseX,D.inputSystem.mouseY,i.z);this.beginPoint.copyFrom(n),this.beginMousePos.x=D.inputSystem.mouseX,this.beginMousePos.y=D.inputSystem.mouseY}lastMoveObj;lastMoveAxis;onMouseMove(e){if(this.currentAxis==M.NONE){let t=this.lastMoveObj.getComponent(d.MeshRenderer).material;this.lastMoveObj&&"baseColor"in t&&(t.baseColor=this.mAxisColor[this.lastMoveAxis],this.lastMoveObj=null,this.lastMoveAxis==M.XYZ&&(this.mAxis[M.X].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[M.X]),this.mAxis[M.Y].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[M.Y]),this.mAxis[M.Z].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[M.Z])),this.lastMoveAxis=M.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==M.XYZ&&(this.mAxis[M.X].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new J(1,1,1)),this.mAxis[M.Y].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new J(1,1,1)),this.mAxis[M.Z].getComponent(d.MeshRenderer).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(D.inputSystem.mouseX,D.inputSystem.mouseY,r.z);this.currentPoint.copyFrom(i);let n=i.subtract(this.beginPoint);b.HELP_0.set(D.inputSystem.mouseX,D.inputSystem.mouseY,0);let o=b.distance(b.HELP_0,this.beginMousePos);switch(this.beginMousePos.copyFrom(b.HELP_0),this.transformSpaceMode){case da.Local:this.applyLocalTransform(this.currentAxis,n,o);break;case da.Global:this.applyGlobalTransform(this.currentAxis,n,o);break}this.beginPoint.copyFrom(i),this.reset()}}onMouseUp(e){e.mouseCode==Rn.MOUSE_LEFT&&(this.currentAxis=M.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 M.X:t=1;break;case M.Y:a=1;break;case M.Z:r=1;break}let i=.4+t*20,n=.4+a*20,o=.4+r*20,l=new d.Object3D;l.x=i*.5,l.y=n*.5,l.z=o*.5;let c=l.addComponent(d.MeshRenderer);c.geometry=new Oa(i,n,o),c.material=this.mAxisMaterial[e];let f=l.addComponent(ca),h=new ni;return h.setFromCenterAndSize(new b(0,0,0),new b(i+1,n+1,o+1)),f.shape=h,l}}class Kh extends zn{init(e){super.init(e);let t=new Bt;t.doubleSide=!0,t.baseColor=new J(.9,.9,.9),t.depthCompare=st.always,this.mAxisColor[M.XYZ]=t.baseColor,this.mAxisMaterial[M.XYZ]=t;let a=new d.Object3D,r=a.addComponent(d.MeshRenderer);r.geometry=new Oa(2,2,2),r.material=this.mAxisMaterial[M.XYZ];let i=a.addComponent(ca),n=new ni;n.setFromCenterAndSize(new b(0,0,0),new b(2,2,2)),i.shape=n,this.mContainer.addChild(this.mAxis[M.XYZ]=a),this.mAxisCollider[M.XYZ]=a.getComponent(ca)}applyLocalTransform(e,t,a){switch(this.currentAxis){case M.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==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ)&&(this.mX.scaleX=Math.abs(this.mX.scaleX+t.x)),(this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.YZ)&&(this.mX.scaleY=Math.abs(this.mX.scaleY+t.y)),(this.currentAxis==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.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==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ)&&(r.x=t.x),(this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.YZ)&&(r.y=t.y),(this.currentAxis==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.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 d.Object3D;switch(e){case M.X:t=1,i.rotationZ=-90;break;case M.Y:a=1;break;case M.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(d.MeshRenderer);return c.geometry=new Oa(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 qh extends zn{applyLocalTransform(e,t,a){if(this.currentAxis==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ,this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.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==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.YZ}getAngle(){const t=this.object3D.transform.scene3D.view.camera,a=this.mZ.transform.worldPosition;if(t.screenPointToRay(D.inputSystem.mouseX,D.inputSystem.mouseY),this.currentAxis==M.X){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(D.inputSystem.mouseX,D.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==M.Y){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(D.inputSystem.mouseX,D.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==M.Z){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(D.inputSystem.mouseX,D.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==M.X||this.currentAxis==M.Y||this.currentAxis==M.Z){let r=this.getAngle();switch(R.help_matrix_0.identity(),this.currentAxis){case M.X:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.X_AXIS);break;case M.Y:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Y_AXIS);break;case M.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(ra.QUATERNION)[1];ee.HELP_0.set(n.x,n.y,n.z,n.w),this.mLastAngle=r,this.mX.transform.localRotQuat=ee.HELP_0}}onMouseDown(e){super.onMouseDown(e),this.currentAxis!=M.NONE&&(this.mAxis[M.X].getComponent(d.MeshRenderer).enable=!1,this.mAxis[M.Y].getComponent(d.MeshRenderer).enable=!1,this.mAxis[M.Z].getComponent(d.MeshRenderer).enable=!1,this.mAxis[this.currentAxis].getComponent(d.MeshRenderer).enable=!0,this.mLastAngle=this.getAngle())}onMouseUp(e){super.onMouseUp(e),this.currentAxis==M.NONE&&(this.mAxis[M.X].getComponent(d.MeshRenderer).enable=!0,this.mAxis[M.Y].getComponent(d.MeshRenderer).enable=!0,this.mAxis[M.Z].getComponent(d.MeshRenderer).enable=!0)}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=new d.Object3D;switch(e){case M.X:t.rotationZ=90;break;case M.Y:break;case M.Z:t.rotationX=90;break}let a=t.addComponent(d.MeshRenderer);a.geometry=new Hh(20,.4),a.material=this.mAxisMaterial[e];let r=t.addComponent(ca),i=new ni;return i.setFromCenterAndSize(new b,new b(40,.4,40)),r.shape=i,t}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(D.inputSystem.mouseX,D.inputSystem.mouseY),r,i;for(let n=0;n<=M.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 $h extends zn{init(e){super.init(e);let t=new Bt;t.doubleSide=!0,t.baseColor=new J(0,0,1),t.depthCompare=st.always,this.mAxisColor[M.XY]=t.baseColor,this.mAxisMaterial[M.XY]=t;let a=new Bt;a.doubleSide=!0,a.baseColor=new J(0,1,0),a.depthCompare=st.always,this.mAxisColor[M.XZ]=a.baseColor,this.mAxisMaterial[M.XZ]=a;let r=new Bt;r.doubleSide=!0,r.baseColor=new J(1,0,0),r.depthCompare=st.always,this.mAxisColor[M.YZ]=r.baseColor,this.mAxisMaterial[M.YZ]=r;let i=this.createPlane(M.XY),n=this.createPlane(M.XZ),o=this.createPlane(M.YZ);this.mContainer.addChild(this.mAxis[M.XY]=i),this.mContainer.addChild(this.mAxis[M.XZ]=n),this.mContainer.addChild(this.mAxis[M.YZ]=o),this.mAxisCollider[M.XY]=i.getComponent(ca),this.mAxisCollider[M.XZ]=n.getComponent(ca),this.mAxisCollider[M.YZ]=o.getComponent(ca)}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==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ||(b.HELP_0.x=0),this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.YZ||(b.HELP_0.y=0),this.currentAxis==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.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==M.X||this.currentAxis==M.XY||this.currentAxis==M.XZ)&&R.help_matrix_0.appendTranslation(t.x,0,0),(this.currentAxis==M.Y||this.currentAxis==M.XY||this.currentAxis==M.YZ)&&R.help_matrix_0.appendTranslation(0,t.y,0),(this.currentAxis==M.Z||this.currentAxis==M.XZ||this.currentAxis==M.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(ra.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 d.Object3D;switch(e){case M.X:t=1,i.rotationZ=-90;break;case M.Y:a=1,i.rotationY=-90;break;case M.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(d.MeshRenderer);return c.geometry=new Xh(0,1,4),c.material=this.mAxisMaterial[e],i}createPlane(e){let t=new d.Object3D,a=t.addComponent(d.MeshRenderer);a.material=this.mAxisMaterial[e];let r=t.addComponent(ca),i=new ni;switch(r.shape=i,e){case M.XY:a.geometry=new qr(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 M.XZ:a.geometry=new qr(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 M.YZ:a.geometry=new qr(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 Wo extends d.Object3D{static _instance;static get instance(){return this._instance||(this._instance=new Wo),this._instance}mTarget;mTransformMode=mt.NONE;mTransformSpaceType=da.Global;mControllers;mXObj;mYObj;mZObj;constructor(){super(),this.mControllers=[null,null,null],this.mControllers[mt.Scale]=this.addComponent(Kh),this.mControllers[mt.Rotation]=this.addComponent(qh),this.mControllers[mt.Translation]=this.addComponent($h),this.mControllers[mt.Scale].enable=!1,this.mControllers[mt.Rotation].enable=!1,this.mControllers[mt.Translation].enable=!1,this.mXObj=new d.Object3D,this.mYObj=new d.Object3D,this.mZObj=new d.Object3D,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(){D.inputSystem.addEventListener(Ea.KEY_DOWN,this.onKeyDown,this),D.inputSystem.addEventListener(j.POINTER_DOWN,this.onMouseDown,this,null,99999),D.inputSystem.addEventListener(j.POINTER_MOVE,this.onMouseMove,this,null,99999),D.inputSystem.addEventListener(j.POINTER_UP,this.onMouseUp,this,null,99999)}unactivate(){D.inputSystem.removeEventListener(Ea.KEY_DOWN,this.onKeyDown,this),D.inputSystem.removeEventListener(j.POINTER_DOWN,this.onMouseDown,this),D.inputSystem.removeEventListener(j.POINTER_MOVE,this.onMouseMove,this),D.inputSystem.removeEventListener(j.POINTER_UP,this.onMouseUp,this)}onKeyDown(e){switch(e.keyCode){case et.Key_R:this.selectTransformMode(mt.Scale),this.selectTransformSpaceMode(da.Local);break;case et.Key_E:this.selectTransformMode(mt.Rotation),this.selectTransformSpaceMode(da.Global);break;case et.Key_W:this.selectTransformMode(mt.Translation),this.selectTransformSpaceMode(da.Global);break;case et.Key_A:this.selectTransformSpaceMode(da.Local);break;case et.Key_S:this.selectTransformSpaceMode(da.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 op=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));d.AccelerateDecelerateInterpolator=M0,d.AccelerateInterpolator=Q0,d.AnimationCurve=Qi,d.AnimationCurveT=Ur,d.AnimationMonitor=Tr,d.AnimatorEventKeyframe=Nb,d.AnticipateInterpolator=V0,d.AnticipateOvershootInterpolator=Ui,d.ArrayHas=su,d.ArrayItemIndex=ou,d.AtlasParser=Ff,d.AtmosphericComponent=kb,d.AtmosphericScatteringSky=Ad,d.AtmosphericScatteringSkySetting=pd,d.AtmosphericScatteringSky_shader=md,d.AttributeAnimCurve=Sd,d.AxisObject=ap,d.B3DMLoader=Ka,d.B3DMLoaderBase=gf,d.B3DMParseUtil=Hs,d.B3DMParser=Ys,d.BRDFLUT=Bf,d.BRDFLUTGenerate=vf,d.BRDF_frag=Ul,d.BatchTable=vn,d.BiMap=Im,d.BillboardComponent=Ii,d.BillboardType=gr,d.BitUtil=Hl,d.BitmapTexture2D=Ha,d.BitmapTexture2DArray=mc,d.BitmapTextureCube=Gs,d.Blend=bc,d.BlendFactor=gc,d.BlendMode=me,d.BlendShapeData=Fo,d.BlendShapePropertyData=xo,d.BloomPost=Rg,d.BlurEffectCreatorBlur_cs=sf,d.BlurEffectCreatorSample_cs=nf,d.BlurTexture2DBufferCreator=of,d.BounceInterpolator=Ht,d.BoundUtil=_s,d.BoundingBox=xe,d.BoundingSphere=Ir,d.BoundingVolume=Pr,d.BoxColliderShape=ni,d.BoxGeometry=Oa,d.BrdfLut_frag=ul,d.BsDF_frag=Cl,d.BxDF_frag=yl,d.BxdfDebug_frag=kl,d.BytesArray=Mn,d.CEvent=bt,d.CEventDispatcher=Wa,d.CEventListener=en,d.CResizeEvent=rr,d.CSM=aa,d.Camera3D=Xr,d.CameraControllerBase=jb,d.CameraType=at,d.CameraUtil=ft,d.CapsuleColliderShape=fg,d.CastPointShadowMaterialPass=Ec,d.CastShadowMaterialPass=kc,d.Clearcoat_frag=Sl,d.ClusterBoundsSource_cs=c0,d.ClusterConfig=wt,d.ClusterDebug_frag=tl,d.ClusterLight=Nl,d.ClusterLightingBuffer=l0,d.ClusterLightingRender=d0,d.ClusterLighting_cs=f0,d.CollectInfo=Qc,d.ColliderComponent=ca,d.ColliderShape=ht,d.ColliderShapeType=ii,d.Color=J,d.ColorGradient=Qm,d.ColorLitMaterial=Fm,d.ColorLitShader=hd,d.ColorPassFragmentOutput=_b,d.ColorPassRenderer=o0,d.ColorUtil=rn,d.ComData=Nn,d.Combine_cs=nd,d.Common_frag=dl,d.Common_vert=hl,d.ComponentBase=qe,d.ComponentCollect=Pe,d.ComputeGPUBuffer=$r,d.ComputeShader=ye,d.Context3D=Yo,d.CubeCamera=Ss,d.CubeMapFaceEnum=lf,d.CubeSky_Shader=Hn,d.CubicBezierCurve=On,d.CubicBezierPath=Tm,d.CubicBezierType=Nh,d.CycleInterpolator=O0,d.CylinderGeometry=Xh,d.DDGIIrradianceComputePass=S0,d.DDGIIrradianceGPUBufferReader=Ji,d.DDGIIrradianceVolume=$c,d.DDGIIrradiance_shader=C0,d.DDGILightingPass=E0,d.DDGILighting_shader=k0,d.DDGIMultiBouncePass=F0,d.DDGIProbeRenderer=w0,d.DEGREES_TO_RADIANS=pt,d.DRACO_DECODER_GLTF_JS=z0,d.DecelerateInterpolator=T0,d.Denoising_cs=sd,d.Depth2DTextureArray=g0,d.DepthCubeArrayTexture=u0,d.DepthMaterialPass=wc,d.DepthOfFieldPost=Ig,d.DepthOfView_cs=zf,d.DoubleArray=Ki,d.EditorInspector=Jr,d.Engine3D=D,d.Entity=qc,d.EntityBatchCollect=Tc,d.EntityCollect=H,d.EnvMap_frag=bl,d.ErpImage2CubeMap=jt,d.ErpImage2CubeMapCreateCube_cs=cf,d.ErpImage2CubeMapRgbe2rgba_cs=ff,d.ExtrudeGeometry=gg,d.FAILED=_r,d.FASTFLOOR=ya,d.FXAAPost=xs,d.FXAAShader=v0,d.FastMathShader=ml,d.FatLineGeometry=mg,d.FatLineMaterial=km,d.FatLine_FS=ac,d.FatLine_VS=tc,d.FeatureTable=xi,d.FileLoader=It,d.FirstPersonCameraController=Zb,d.Float16ArrayTexture=As,d.Float32ArrayTexture=Kc,d.FlyCameraController=Yb,d.FontChar=Cf,d.FontInfo=Uf,d.FontPage=yf,d.FontParser=qa,d.ForwardRenderJob=I0,d.FragmentOutput=$n,d.FragmentVarying=Al,d.FrameCache=lo,d.Frustum=cs,d.FrustumCSM=uc,d.FrustumCulling_cs=Db,d.FullQuad_vert_wgsl=El,d.GBufferFrame=De,d.GBufferPass=Fc,d.GBufferPost=Qg,d.GBufferStand=Kl,d.GBuffer_pass=es,d.GILighting=Os,d.GIProbeMaterial=Xd,d.GIProbeMaterialType=Do,d.GIProbeShader=ud,d.GIRenderCompleteEvent=Fs,d.GIRenderStartEvent=gn,d.GLBChunk=tf,d.GLBHeader=ef,d.GLBParser=Ls,d.GLSLLexer=pc,d.GLSLLexerToken=mi,d.GLSLPreprocessor=Ac,d.GLSLSyntax=vc,d.GLTFBinaryExtension=Af,d.GLTFMaterial=$g,d.GLTFParser=_t,d.GLTFSubParser=An,d.GLTFSubParserCamera=W0,d.GLTFSubParserConverter=$0,d.GLTFSubParserMaterial=j0,d.GLTFSubParserMesh=J0,d.GLTFSubParserSkeleton=Vs,d.GLTFSubParserSkin=Z0,d.GLTFType=na,d.GLTF_Accessors=y2,d.GLTF_Info=mn,d.GLTF_Light=_2,d.GLTF_Mesh=U2,d.GLTF_Node=B2,d.GLTF_Primitives=v2,d.GLTF_Scene=D2,d.GPUAddressMode=Xt,d.GPUBlendFactor=lu,d.GPUBufferBase=Ja,d.GPUBufferType=ba,d.GPUCompareFunction=st,d.GPUContext=F,d.GPUCullMode=Nt,d.GPUFilterMode=or,d.GPUPrimitiveTopology=an,d.GPUTextureFormat=re,d.GPUVertexFormat=ui,d.GPUVertexStepMode=du,d.GSplatFormat=ci,d.GSplatGeometry=Jc,d.GSplatMaterial=Oc,d.GSplat_FS=Vc,d.GSplat_VS=Pc,d.GTAOPost=Tg,d.GTAO_cs=Wf,d.GUIAtlasTexture=xf,d.GUICanvas=Pi,d.GUIConfig=Qr,d.GUIGeometry=Rd,d.GUIGeometryRebuild=Qd,d.GUIMaterial=uo,d.GUIPassRenderer=R0,d.GUIPick=Pd,d.GUIPickHelper=Ld,d.GUIQuad=Ma,d.GUIQuadAttrEnum=it,d.GUIRenderer=Td,d.GUIShader=ho,d.GUISpace=la,d.GUISprite=ei,d.GUITexture=ur,d.GaussianSplatParser=Hg,d.GenerayRandomDir=Tl,d.GeoJsonParser=Kg,d.GeoJsonUtil=qg,d.GeoType=Qn,d.GeometryBase=Ve,d.GeometryIndicesBuffer=zc,d.GeometryUtil=rp,d.GeometryVertexBuffer=Lc,d.GeometryVertexType=Ft,d.GetComponentClass=Xo,d.GetCountInstanceID=Yn,d.GetRepeat=_u,d.GetShader=Ho,d.GlassShader=Bb,d.GlobalBindGroup=Be,d.GlobalBindGroupLayout=fs,d.GlobalFog=Mg,d.GlobalFog_shader=oo,d.GlobalIlluminationComponent=ig,d.GlobalUniform=Kn,d.GlobalUniformGroup=Bs,d.GodRayPost=Ng,d.GodRay_cs=Jf,d.GridObject=ip,d.HDRTexture=Ws,d.HDRTextureCube=Bn,d.Hair_frag=Pl,d.Hair_shader_op=vb,d.Hair_shader_tr=Ub,d.HaltonSeq=ln,d.Horizontal=Wd,d.HoverCameraController=Xb,d.I3DMLoader=_a,d.I3DMLoaderBase=Df,d.I3DMParser=Ks,d.IBLEnvMapCreator=uf,d.IBLEnvMapCreator_cs=hf,d.IESProfiles=pa,d.IESProfiles_frag=_l,d.IKDTreeUserData=Dg,d.ImageType=ri,d.IndicesGPUBuffer=Gc,d.Inline_vert=fl,d.InputSystem=Zo,d.InstanceDrawComponent=ng,d.InstanceUniform=gl,d.InstancedMesh=_f,d.Interpolator=hr,d.InterpolatorEnum=ks,d.IrradianceDataReaderCompleteEvent=lh,d.IrradianceVolumeData_frag=cl,d.Irradiance_frag=vl,d.IsEditorInspector=iu,d.IsNonSerialize=jn,d.Joint=Y0,d.JointPose=Ps,d.JumperInterpolator=P0,d.KDTreeEntity=Bg,d.KDTreeNode=pr,d.KDTreeRange=$d,d.KDTreeSpace=eh,d.KDTreeUUID=Wi,d.KHR_draco_mesh_compression=Ns,d.KHR_lights_punctual=em,d.KHR_materials_clearcoat=H0,d.KHR_materials_emissive_strength=K0,d.KHR_materials_ior=tm,d.KHR_materials_unlit=q0,d.KMZParser=Mf,d.KV=So,d.KelvinUtil=np,d.KeyCode=et,d.KeyEvent=Ea,d.Keyframe=xn,d.KeyframeT=Hi,d.LDRTextureCube=yn,d.LOADED=Pa,d.LOADING=ko,d.LRUCache=kh,d.LambertMaterial=Em,d.Lambert_shader=Ol,d.LightBase=Si,d.LightData=on,d.LightEntries=e0,d.LightType=lt,d.LightingFunction_frag=al,d.Line=vt,d.LineClassification=Vd,d.LinearInterpolator=N0,d.LitMaterial=Kt,d.Lit_shader=xl,d.LoaderBase=wr,d.LoaderEvent=vg,d.LoaderManager=In,d.MAX_VALUE=gu,d.MIN_VALUE=mu,d.Material=Dt,d.MaterialDataUniformGPUBuffer=Sc,d.MaterialUtilities=Tn,d.MathShader=rl,d.MathUtil=Pt,d.Matrix3=Mr,d.Matrix4=R,d.MatrixBindGroup=r0,d.MatrixGPUBuffer=a0,d.MatrixShader=Ml,d.MemoryDO=ir,d.MemoryInfo=qo,d.MergeRGBACreator=Cg,d.MergeRGBA_cs=jf,d.MeshColliderShape=wn,d.MinMaxAnimationCurves=Vm,d.MinMaxCurve=Wh,d.MinMaxCurveState=zh,d.MinMaxPolyCurves=Om,d.MorePassParser=kg,d.MorePassShader=sh,d.MorphTargetBlender=Ob,d.MorphTargetData=n0,d.MorphTargetFrame=Lb,d.MorphTargetTransformKey=kd,d.MorphTarget_shader=Yt,d.MouseCode=Rn,d.MultiBouncePass_cs=x0,d.Navi3DAstar=Zh,d.Navi3DConst=qi,d.Navi3DEdge=Sa,d.Navi3DFunnel=tr,d.Navi3DMaskType=yr,d.Navi3DMesh=qm,d.Navi3DPoint=Tt,d.Navi3DPoint2D=zo,d.Navi3DPointFat=Ca,d.Navi3DRouter=pe,d.Navi3DTriangle=Yh,d.NonSerialize=Jn,d.NormalMap_frag=pl,d.OAnimationEvent=X0,d.OBJParser=rf,d.Object3DEvent=Ug,d.Object3DTransformTools=Wo,d.Object3DUtil=sp,d.ObjectAnimClip=xd,d.OcclusionSystem=Cs,d.Octree=fr,d.OctreeEntity=Nc,d.OrbitController=Hb,d.OrderMap=Mm,d.Orientation3D=ra,d.OutLineBlendColor_cs=Zf,d.OutlineCalcOutline_cs=Yf,d.OutlinePass=yb,d.OutlinePost=Pg,d.OutlinePostData=fh,d.OutlinePostManager=dh,d.OutlinePostSlot=ch,d.Outline_cs=Xf,d.OvershootInterpolator=L0,d.PARSING=xh,d.PBRLItShader=Fl,d.PBRLitSSSShader=bd,d.PLUGIN_REGISTERED=Am,d.PNTSLoader=Ah,d.PNTSLoaderBase=ph,d.PNTSParser=Dh,d.ParserBase=dt,d.ParserFormat=He,d.ParticleSystemCurveEvalMode=Gh,d.ParticleSystemRandomnessIds=Ph,d.PassGenerate=Bi,d.PassShader=oh,d.PassType=se,d.PhysicMaterialUniform_frag=il,d.PickCompute=Hd,d.PickFire=Kd,d.PickGUIEvent3D=Ut,d.PickResult=hh,d.Picker_cs=Hf,d.PingPong=ts,d.PipelinePool=bs,d.Plane3D=Jh,d.PlaneClassification=Vr,d.PlaneGeometry=qr,d.PlyMode=Dr,d.PlyParser=am,d.PointClassification=Od,d.PointCloudGeometry=Ds,d.PointCloudMaterial=Hc,d.PointCloud_FS=Xc,d.PointCloud_VS=Yc,d.PointLightShadowRenderer=b0,d.PointShadowCubeCamera=h0,d.PointerEvent3D=j,d.Polynomial=Va,d.PolynomialCurve=er,d.Polynomials=Pm,d.PoolNode=Md,d.PostBase=Jt,d.PostProcessingComponent=Pf,d.PostRenderer=D0,d.PreDepthPassRenderer=p0,d.PreFilteredEnvironment_cs=_0,d.PreFilteredEnvironment_cs2=hb,d.PreIntegratedLut=Kf,d.PreIntegratedLutCompute=nh,d.PrefabAvatarData=Co,d.PrefabAvatarParser=_h,d.PrefabBoneData=yo,d.PrefabMaterialParser=vh,d.PrefabMeshData=Uh,d.PrefabMeshParser=yh,d.PrefabNode=Zi,d.PrefabParser=Sh,d.PrefabStringUtil=lm,d.PrefabTextureData=Bh,d.PrefabTextureParser=Ch,d.Preprocessor=ga,d.PriorityQueue=wo,d.Probe=Yd,d.ProbeEntries=Sg,d.ProbeGBufferFrame=y0,d.ProfilerUtil=ot,d.PropertyAnimClip=Mb,d.PropertyAnimTag=Fd,d.PropertyAnimation=co,d.PropertyAnimationClip=Vo,d.PropertyAnimationClipState=Cd,d.PropertyAnimationEvent=Mi,d.PropertyHelp=Ti,d.QuadAABB=Qt,d.QuadGlsl_fs=Gl,d.QuadGlsl_vs=Ll,d.QuadRoot=ah,d.QuadTree=th,d.QuadTreeCell=Ar,d.Quad_depth2dArray_frag_wgsl=hu,d.Quad_depth2d_frag_wgsl=Il,d.Quad_depthCube_frag_wgsl=Ql,d.Quad_frag_wgsl=Rl,d.Quad_vert_wgsl=wl,d.Quaternion=ee,d.R32UintTexture=ps,d.RADIANS_TO_DEGREES=Zr,d.RGBEErrorCode=df,d.RGBEHeader=Js,d.RGBEParser=js,d.RTDescriptor=Ge,d.RTFrame=rt,d.RTResourceConfig=Ia,d.RTResourceMap=Et,d.Rand=bi,d.RandomSeed=Bu,d.Ray=ia,d.RayCastMeshDetail=li,d.Reader=Hr,d.Rect=gi,d.Reference=Ce,d.Reflection=_d,d.ReflectionCG=$l,d.ReflectionEntries=t0,d.ReflectionMaterial=vd,d.ReflectionRenderer=B0,d.ReflectionShader=Bd,d.ReflectionShader_shader=ql,d.RegisterComponent=Lt,d.RegisterShader=wa,d.RenderContext=ys,d.RenderLayer=vi,d.RenderLayerUtil=gs,d.RenderNode=Ra,d.RenderShaderCollect=Mc,d.RenderShaderCompute=ih,d.RenderShaderPass=Xe,d.RenderTexture=kt,d.RendererBase=Qa,d.RendererJob=U0,d.RendererMap=A0,d.RendererMask=Qe,d.RendererMaskUtil=ta,d.RendererPassState=s0,d.RepeatSE=as,d.Res=Nf,d.RotationControlComponents=qh,d.SHCommon_frag=ec,d.SN_ArrayConstant=pi,d.SN_BinaryOperation=cr,d.SN_Break=qu,d.SN_CodeBlock=Aa,d.SN_Constant=Ya,d.SN_Continue=dn,d.SN_Declaration=$e,d.SN_Discard=$u,d.SN_DoWhileLoop=Ku,d.SN_Expression=Fe,d.SN_ForLoop=xr,d.SN_Function=cn,d.SN_FunctionArgs=fn,d.SN_FunctionCall=Sr,d.SN_IFBranch=kr,d.SN_Identifier=Za,d.SN_IndexOperation=Er,d.SN_Layout=_i,d.SN_ParenExpression=_c,d.SN_Precision=hn,d.SN_Return=Ai,d.SN_SelectOperation=Di,d.SN_Struct=ja,d.SN_TernaryOperation=Bc,d.SN_UnaryOperation=Kr,d.SN_WhileLoop=Fr,d.SSAO_cs=ub,d.SSGI2_cs=qf,d.SSGIPost=Vg,d.SSRPost=Og,d.SSR_BlendColor_cs=$f,d.SSR_IS_Kernel=Lg,d.SSR_IS_cs=ed,d.SSR_RayTrace_cs=td,d.ScaleControlComponents=Kh,d.Scene3D=hg,d.Shader=gt,d.ShaderAttributeInfo=us,d.ShaderConverter=Uc,d.ShaderConverterResult=yc,d.ShaderLib=Z,d.ShaderPassBase=Xn,d.ShaderReflection=St,d.ShaderStage=Da,d.ShaderState=Cc,d.ShaderUniformInfo=hs,d.ShaderUtil=Xa,d.ShadingInput=Dl,d.ShadowLightsCollect=Wt,d.ShadowMapPassRenderer=m0,d.ShadowMapping_frag=Bl,d.Skeleton=Gb,d.SkeletonAnimationClip=pn,d.SkeletonAnimationClipState=yd,d.SkeletonAnimationCompute=zb,d.SkeletonAnimation_shader=jr,d.SkeletonBlendComputeArgs=Wb,d.SkeletonPose=Ci,d.SkeletonTransformComputeArgs=Jb,d.SkyGBufferPass=xc,d.SkyGBuffer_pass=zl,d.SkyMaterial=Dd,d.SkyRenderer=Sn,d.SolidColorSky=tp,d.SphereColliderShape=dg,d.SphereGeometry=Rr,d.SphereReflection=Ud,d.StandShader=af,d.StatementNode=Oe,d.StorageGPUBuffer=Te,d.StringUtil=Rt,d.Struct=hi,d.StructStorageGPUBuffer=xg,d.SubGeometry=Wc,d.TAACopyTex_cs=ad,d.TAAPost=Gg,d.TAASharpTex_cs=rd,d.TAA_cs=id,d.TestComputeLoadBuffer=od,d.TextAnchor=Gd,d.TextFieldLayout=jd,d.TextFieldLine=Jd,d.Texture=ct,d.TextureCube=Dn,d.TextureCubeFaceData=Zs,d.TextureCubeStdCreator=_n,d.TextureCubeUtils=zs,d.TextureMipmapCompute=Fg,d.TextureMipmapGenerator=ma,d.TextureScaleCompute=rh,d.ThirdPersonCameraController=qb,d.Tile=Eo,d.TileSet=vm,d.TileSetChild=ym,d.TileSetChildContent=Cm,d.TileSetChildContentMetaData=Sm,d.TileSetRoot=Um,d.TilesRenderer=Bm,d.Time=Le,d.TokenType=v,d.TorusGeometry=Hh,d.TouchData=jo,d.TrailGeometry=$m,d.Transform=zt,d.TransformAxisEnum=M,d.TransformControllerBaseComponent=zn,d.TransformMode=mt,d.TransformSpaceMode=da,d.TranslationControlComponents=$h,d.TranslatorContext=ds,d.TriGeometry=ep,d.Triangle=Gi,d.UIButton=go,d.UIButtonTransition=Zd,d.UIComponentBase=bo,d.UIEvent=yg,d.UIImage=Nr,d.UIImageGroup=mo,d.UIInteractive=En,d.UIInteractiveStyle=tt,d.UIPanel=Li,d.UIRenderAble=Oi,d.UIShadow=po,d.UITextField=Ao,d.UITransform=$a,d.UNLOADED=Br,d.UUID=Gt,d.UV=Go,d.Uint32ArrayTexture=jc,d.Uint8ArrayTexture=bn,d.UnLit=Vl,d.UnLitMaterial=Bt,d.UnLitMaterialUniform_frag=nl,d.UnLitTexArrayMaterial=Rm,d.UnLitTextureArray=gd,d.UnLit_frag=sl,d.UniformGPUBuffer=yt,d.UniformNode=nr,d.UniformType=Ct,d.ValueEnumType=Y,d.ValueOp=Km,d.ValueParser=Na,d.ValueSpread=Lm,d.Vector2=le,d.Vector3=b,d.Vector3Ex=Ni,d.Vector4=fe,d.VertexAttribute=Ag,d.VertexAttributeIndexShader=dd,d.VertexAttributeName=L,d.VertexAttributeSize=sr,d.VertexAttributeStride=qd,d.VertexAttributes_vert=ol,d.VertexBufferLayout=pg,d.VertexFormat=el,d.VertexGPUBuffer=un,d.Vertical=zd,d.VideoUniform_frag=ll,d.View3D=ug,d.ViewPanel=Fn,d.ViewQuad=Us,d.VirtualTexture=we,d.WGS84_FLATTENING=mm,d.WGS84_HEIGHT=pm,d.WGS84_RADIUS=gm,d.WGSLTranslator=Dc,d.WayLines3D=Ri,d.WayPoint3D=wi,d.WebGPUDescriptorCreator=Je,d.WorldMatrixUniform=qn,d.WorldPanel=kn,d.WrapMode=si,d.WrapTimeMode=mr,d.ZCullingCompute=wg,d.ZPassShader_cs=fd,d.ZPassShader_fs=Xl,d.ZPassShader_vs=Yl,d.ZSorterUtil=Rc,d.append=hc,d.arrayToString=bf,d.blendComponent=cu,d.buildCurves=zm,d.byteSizeOfType=fa,d.calculateCurveRangesValue=Wm,d.calculateMinMax=Yi,d.castPointShadowMap_vert=Jl,d.clamp=Ae,d.clampRepeat=zu,d.computeAABBFromPositions=_o,d.cos=Qu,d.crossProduct=Ou,d.cubicPolynomialRoot=Vh,d.cubicPolynomialRootsGeneric=Oh,d.curvesSupportProcedural=Gm,d.deg2Rad=wu,d.detectGSplatFormat=uh,d.directionShadowCastMap_frag=Zl,d.dot=xt,d.doubleIntegrateSegment=Lh,d.downSample=Lf,d.fastInvSqrt=fc,d.floorfToIntPos=cc,d.fonts=ti,d.generateRandom=Lu,d.generateRandom3=Gu,d.getFloatFromInt=sc,d.getGLTypeFromTypedArray=M2,d.getGLTypeFromTypedArrayType=T2,d.getGlobalRandomSeed=Tu,d.getTypedArray=N2,d.getTypedArrayTypeFromGLType=Ms,d.grad1=Lo,d.grad2=Gn,d.grad3=Xi,d.grad4=fi,d.inferSHOrder=vo,d.integrateSegment=Oo,d.irradianceDataReader=Eg,d.kPI=Nm,d.lerp=Cr,d.lerpByte=Du,d.lerpColor=Au,d.lerpVector3=pu,d.lruPriorityCallback=Mh,d.magnitude=is,d.makeAloneSprite=j2,d.makeGUISprite=Sf,d.makeMatrix44=sn,d.markUsedSetLeaves=Mo,d.markUsedTiles=Vn,d.markVisibleTiles=No,d.matrixMultiply=ls,d.matrixRotate=Zu,d.matrixRotateY=ju,d.mergeFunctions=tn,d.multiplyMatrices4x4REF=dc,d.normal_distribution=jh,d.normalizeFast=Vu,d.normalizeSafe=nc,d.normalizedToByte=Pu,d.normalizedToWord=Nu,d.outlinePostData=Ua,d.outlinePostManager=zg,d.parsePlyGaussianSplat=Uo,d.parsePlyHeader=ji,d.parsePlyMesh=gh,d.parsePlyPointCloud=mh,d.perm=ve,d.post=Gf,d.priorityCallback=Th,d.quadraticPolynomialRootsGeneric=Ln,d.rad2Deg=Ru,d.random01=Yr,d.randomBarycentricCoord=Eu,d.randomPointBetweenEllipsoid=ku,d.randomPointBetweenSphere=xu,d.randomPointInsideCube=Cu,d.randomPointInsideEllipsoid=Su,d.randomPointInsideUnitCircle=Fu,d.randomPointInsideUnitSphere=lc,d.randomQuaternion=Uu,d.randomQuaternionUniformDistribution=yu,d.randomUnitVector=nn,d.randomUnitVector2=oc,d.rangedRandomFloat=At,d.rangedRandomInt=vu,d.readByType=_e,d.readMagicBytes=Un,d.registerMaterial=wm,d.repeat=os,d.rotMatrix=Ju,d.rotateVectorByQuat=bu,d.roundfToIntPos=ns,d.scale=rs,d.shadowCastMap_frag=jl,d.shadowCastMap_vert=Wl,d.simplex=$t,d.sin=Iu,d.snoise1=Zm,d.snoise2=Ym,d.snoise3=Xm,d.snoise4=Hm,d.splatColorProperties=bh,d.splatProperties=Bo,d.sqrMagnitude=ss,d.sqrtImpl=ic,d.stencilStateFace=fu,d.swap=Mu,d.textureCompress=ld,d.threshold=Of,d.throttle=xm,d.toHalfFloat=dr,d.toggleTiles=Po,d.traverseAncestors=Dm,d.traverseSet=Eh,d.tw=Ab,d.uniform_real_distribution=Jm,d.uniform_real_distribution2=jm,d.upSample=so,d.webGPUContext=w,d.zSorterUtil=Ic,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
11820
11820
  //# sourceMappingURL=rings.umd.js.map