@rings-webgpu/core 1.0.40 → 1.0.41

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.
@@ -42285,7 +42285,7 @@ class PostProcessingComponent extends ComponentBase {
42285
42285
  }
42286
42286
  }
42287
42287
 
42288
- const version = "1.0.39";
42288
+ const version = "1.0.41";
42289
42289
 
42290
42290
  class Engine3D {
42291
42291
  /**
@@ -55171,7 +55171,7 @@ let GSplatStreamRenderer = class extends RenderNode {
55171
55171
  * Update node before rendering
55172
55172
  */
55173
55173
  nodeUpdate(view, passType, renderPassState, clusterLightingBuffer) {
55174
- if (this._validCount > 0 && view?.camera && this._frameCount >= 60) {
55174
+ if (this._validCount > 0 && view?.camera) {
55175
55175
  if (view.camera.viewMatrix) {
55176
55176
  this.scheduleOrder(view.camera.viewMatrix);
55177
55177
  }
package/dist/rings.umd.js CHANGED
@@ -7888,7 +7888,7 @@ else if (typeof exports === 'object')
7888
7888
  `;class Ff{compute;constructor(){this.compute=new Se(xf)}generateBRDFLUTTexture(){let e=new Ie(256,256,le.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=E.beginCommandEncoder();return E.computeCommand(t,[this.compute]),E.endCommandEncoder(t),e}}class ai{id;guiTexture;uvRec=new ue(0,0,1,1);uvBorder=new ue(0,0,0,0);offsetSize=new ue(0,0,4,4);borderSize=new ue(0,0,0,0);trimSize=new fe;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||B.res.defaultGUITexture}}class mr{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=B.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,mr._maxUid++,this._staticId=mr._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class tb{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 ri=new tb;class kf{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 Ef{id=0;file=""}class wf{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class tr extends rt{static format=Je.TEXT;static parseSprite(e,t){for(const a in t.fontChar)if(Object.prototype.hasOwnProperty.call(t.fontChar,a)){const r=t.fontChar[a];let i=new ai;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),ri.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 kf;a.trim().split(t).forEach((i,s)=>{if(s<2)tr.readLineProperty(i,r);else if(s<r.pages+2){let o=new Ef;tr.readLineProperty(i,o),r.fontPage.push(o)}else if(s<r.pages+3)tr.readLineProperty(i,r);else if(r.count>0){let o=new wf;tr.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 B.res.loadTexture(r,null,!0);let i=B.res.getTexture(r),s=new mr(i);e.push(s)}tr.parseSprite(e,t),t.fontChar[" "]||tr.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ai,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),ri.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 s=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,s)&&(o.indexOf('"')==-1?t[s]=parseFloat(i[1]):t[s]=o.replace('"',"").replace('"',""))}})}}function ab(n,e){let t=new ai;return t.id=n,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 mr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function Rf(n,e,t){let a=new ai;a.guiTexture=n,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/n.width,i=1/n.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let s=.1;return t.border.x<=s&&t.border.y<=s&&t.border.z<=s&&t.border.x<=s?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 If{_spriteMap=new Map;_spriteList=[];textureSize=new fe;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=Rf(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 Tf extends rt{static format=Je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await B.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 If(this._json.size),t=new mr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);B.res.addAtlas(this.baseUrl,e),this.data=e}}var $t=Uint8Array,ii=Uint16Array,rb=Int32Array,Qf=new $t([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]),Mf=new $t([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]),ib=new $t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pf=function(n,e){for(var t=new ii(31),a=0;a<31;++a)t[a]=e+=1<<n[a-1];for(var r=new rb(t[30]),a=1;a<30;++a)for(var i=t[a];i<t[a+1];++i)r[i]=i-t[a]<<5|a;return{b:t,r}},Nf=Pf(Qf,2),Vf=Nf.b,sb=Nf.r;Vf[28]=258,sb[258]=28;for(var nb=Pf(Mf,0),ob=nb.b,oo=new ii(32768),Xe=0;Xe<32768;++Xe){var pr=(Xe&43690)>>1|(Xe&21845)<<1;pr=(pr&52428)>>2|(pr&13107)<<2,pr=(pr&61680)>>4|(pr&3855)<<4,oo[Xe]=((pr&65280)>>8|(pr&255)<<8)>>1}for(var Ti=(function(n,e,t){for(var a=n.length,r=0,i=new ii(e);r<a;++r)n[r]&&++i[n[r]-1];var s=new ii(e);for(r=1;r<e;++r)s[r]=s[r-1]+i[r-1]<<1;var o;if(t){o=new ii(1<<e);var l=15-e;for(r=0;r<a;++r)if(n[r])for(var c=r<<4|n[r],f=e-n[r],h=s[n[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[oo[h]>>l]=c}else for(o=new ii(a),r=0;r<a;++r)n[r]&&(o[r]=oo[s[n[r]-1]++]>>15-n[r]);return o}),Qi=new $t(288),Xe=0;Xe<144;++Xe)Qi[Xe]=8;for(var Xe=144;Xe<256;++Xe)Qi[Xe]=9;for(var Xe=256;Xe<280;++Xe)Qi[Xe]=7;for(var Xe=280;Xe<288;++Xe)Qi[Xe]=8;for(var Of=new $t(32),Xe=0;Xe<32;++Xe)Of[Xe]=5;var lb=Ti(Qi,9,1),cb=Ti(Of,5,1),lo=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},Ua=function(n,e,t){var a=e/8|0;return(n[a]|n[a+1]<<8)>>(e&7)&t},co=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},fb=function(n){return(n+7)/8|0},fo=function(n,e,t){return(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length),new $t(n.subarray(e,t))},db=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ca=function(n,e,t){var a=new Error(e||db[n]);if(a.code=n,Error.captureStackTrace&&Error.captureStackTrace(a,ca),!t)throw a;return a},hb=function(n,e,t,a){var r=n.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new $t(0);var s=!t,o=s||e.i!=2,l=e.i;s&&(t=new $t(r*3));var c=function(ie){var ce=t.length;if(ie>ce){var ge=new $t(Math.max(ce*2,ie));ge.set(t),t=ge}},f=e.f||0,h=e.p||0,u=e.b||0,b=e.l,A=e.d,m=e.m,p=e.n,D=r*8;do{if(!b){f=Ua(n,h,1);var _=Ua(n,h+1,3);if(h+=3,_)if(_==1)b=lb,A=cb,m=9,p=5;else if(_==2){var S=Ua(n,h,31)+257,F=Ua(n,h+10,15)+4,k=S+Ua(n,h+5,31)+1;h+=14;for(var x=new $t(k),w=new $t(19),R=0;R<F;++R)w[ib[R]]=Ua(n,h+R*3,7);h+=F*3;for(var Q=lo(w),M=(1<<Q)-1,j=Ti(w,Q,1),R=0;R<k;){var he=j[Ua(n,h,M)];h+=he&15;var v=he>>4;if(v<16)x[R++]=v;else{var ae=0,P=0;for(v==16?(P=3+Ua(n,h,3),h+=2,ae=x[R-1]):v==17?(P=3+Ua(n,h,7),h+=3):v==18&&(P=11+Ua(n,h,127),h+=7);P--;)x[R++]=ae}}var z=x.subarray(0,S),W=x.subarray(S);m=lo(z),p=lo(W),b=Ti(z,m,1),A=Ti(W,p,1)}else ca(1);else{var v=fb(h)+4,U=n[v-4]|n[v-3]<<8,y=v+U;if(y>r){l&&ca(0);break}o&&c(u+U),t.set(n.subarray(v,y),u),e.b=u+=U,e.p=h=y*8,e.f=f;continue}if(h>D){l&&ca(0);break}}o&&c(u+131072);for(var V=(1<<m)-1,te=(1<<p)-1,J=h;;J=h){var ae=b[co(n,h)&V],K=ae>>4;if(h+=ae&15,h>D){l&&ca(0);break}if(ae||ca(2),K<256)t[u++]=K;else if(K==256){J=h,b=null;break}else{var ee=K-254;if(K>264){var R=K-257,re=Qf[R];ee=Ua(n,h,(1<<re)-1)+Vf[R],h+=re}var oe=A[co(n,h)&te],pe=oe>>4;oe||ca(3),h+=oe&15;var W=ob[pe];if(pe>3){var re=Mf[pe];W+=co(n,h)&(1<<re)-1,h+=re}if(h>D){l&&ca(0);break}o&&c(u+131072);var Te=u+ee;if(u<W){var Oe=i-W,q=Math.min(W,Te);for(Oe+u<0&&ca(3);u<q;++u)t[u]=a[Oe+u]}for(;u<Te;++u)t[u]=t[u-W]}}e.l=b,e.p=J,e.b=u,e.f=f,b&&(f=1,e.m=m,e.d=A,e.n=p)}while(!f);return u!=t.length&&s?fo(t,0,u):t.subarray(0,u)},ub=new $t(0),Pa=function(n,e){return n[e]|n[e+1]<<8},ya=function(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24)>>>0},ho=function(n,e){return ya(n,e)+ya(n,e+4)*4294967296};function bb(n,e){return hb(n,{i:2},e&&e.out,e&&e.dictionary)}var uo=typeof TextDecoder<"u"&&new TextDecoder,gb=0;try{uo.decode(ub,{stream:!0}),gb=1}catch{}var mb=function(n){for(var e="",t=0;;){var a=n[t++],r=(a>127)+(a>223)+(a>239);if(t+r>n.length)return{s:e,r:fo(n,t-1)};r?r==3?(a=((a&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|n[t++]&63):e+=String.fromCharCode((a&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(a)}};function Lf(n,e){if(e){for(var t="",a=0;a<n.length;a+=16384)t+=String.fromCharCode.apply(null,n.subarray(a,a+16384));return t}else{if(uo)return uo.decode(n);var r=mb(n),i=r.s,t=r.r;return t.length&&ca(8),i}}var pb=function(n,e){return e+30+Pa(n,e+26)+Pa(n,e+28)},Ab=function(n,e,t){var a=Pa(n,e+28),r=Lf(n.subarray(e+46,e+46+a),!(Pa(n,e+8)&2048)),i=e+46+a,s=ya(n,e+20),o=t&&s==4294967295?Db(n,i):[s,ya(n,e+24),ya(n,e+42)],l=o[0],c=o[1],f=o[2];return[Pa(n,e+10),l,c,r,i+Pa(n,e+30)+Pa(n,e+32),f]},Db=function(n,e){for(;Pa(n,e)!=1;e+=4+Pa(n,e+2));return[ho(n,e+12),ho(n,e+4),ho(n,e+20)]};function _b(n,e){for(var t={},a=n.length-22;ya(n,a)!=101010256;--a)(!a||n.length-a>65558)&&ca(13);var r=Pa(n,a+8);if(!r)return{};var i=ya(n,a+16),s=i==4294967295||r==65535;if(s){var o=ya(n,a-12);s=ya(n,o)==101075792,s&&(r=ya(n,o+32),i=ya(n,o+48))}for(var l=0;l<r;++l){var c=Ab(n,i,s),f=c[0],h=c[1],u=c[2],b=c[3],A=c[4],m=c[5],p=pb(n,m);i=A,f?f==8?t[b]=bb(n.subarray(p,p+h),{out:new $t(u)}):ca(14,"unknown compression type "+f):t[b]=fo(n,p,p+h)}return t}class Bt extends Dt{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=B.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 Ir extends Ve{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,s,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=s,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,s=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,b=0,A=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,p=s*Math.cos(m),D=s*Math.sin(m);for(e=0;e<=i;++e){var _=2*Math.PI*e/i,v=D*Math.cos(_),U=D*Math.sin(_),y=1/Math.sqrt(v*v+p*p+U*U);if(l[u++]=v,l[u++]=p,l[u++]=U,c[b++]=v*y,c[b++]=p*y,c[b++]=U*y,f[A++]=e/i,f[A++]=t/r,e>0&&t>0){var S=(i+1)*t+e,F=(i+1)*t+e-1,k=(i+1)*(t-1)+e-1,x=(i+1)*(t-1)+e;t==r?(h[a++]=S,h[a++]=k,h[a++]=x):t==1?(h[a++]=S,h[a++]=F,h[a++]=k):(h[a++]=S,h[a++]=F,h[a++]=k,h[a++]=S,h[a++]=k,h[a++]=x)}}}this.setIndices(h),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(g.ZERO,new g(this.radius*2,this.radius*2,this.radius*2))}}class Mi 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 g(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),Mi.register3DRepresentation)this.marker=Mi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Ir(.1,32,16),e.material=new Bt,e.material.baseColor=this.positionValid?new Z(0,1,0,1):new Z(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Pi 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 Mi(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),Pi.register3DRepresentation?(this.line=Pi.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new Z(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(G.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const s=new d.Object3D,o=s.addComponent(d.MeshRenderer),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=Ae.ADD,l.castReflection=!1,o.geometry=a,o.material=l,s}}class Gf extends rt{static format=Je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=_b(new Uint8Array(e));for(const i in a){const s=a[i],l=new DOMParser().parseFromString(Lf(s),"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 Pi(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,s=!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&&(s=!0)}if(i&&!s)t[r]=i;else if(s){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 zf{_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 Tt().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 Tt;r==".gltf"?a=await i.load(e,_t,t):a=await i.load(e,Hn,t);let s=a.data;return this._prefabPool.set(e,s),this._gltfPool.set(e,a.gltf),s}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new Tt;r==".obj"&&(a=await i.load(e,wi,t));let s=a.data;return this._prefabPool.set(e,s),s}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let s=(await new Tt().load(e,ro,t,a)).data;return this._prefabPool.set(e,s),s}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let s=(await new Tt().load(e,no,t,a)).data;return this._prefabPool.set(e,s),s}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $a;r.flipY=a;try{await r.load(e,t)}catch(i){return console.error(`Failed to load texture: ${e}`,i),null}return this._texturePool.set(e,r),r}destroyTexture(e){const t=this._texturePool.get(e);return t?xe.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,s)=>{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=[],s=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<s;l++){let c=await this.loadTextureCount(e,l==s-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 $n;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 xs;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 ks;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 Kn;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 Kn;return await a.loadStd(e),a}async loadJSON(e,t){return await new Tt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new Tt().load(e,tr,t,a),s=i.data;return ri.addFontData(s.face,s.size,s),i.data}async loadAtlas(e,t){return(await new Tt().load(e,Tf,t,e)).data}async loadKMZ(e,t){return(await new Tt().load(e,Gf,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,s,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,s);let h=new Si;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}fillColor(e,t,a,r,i,s,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]=s,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 Ff().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new xs,this.defaultSky.createFromTexture(128,this.blackTexture),xe.getInstance().attached(this.defaultSky,this),xe.getInstance().attached(t,this),xe.getInstance().attached(this.normalTexture,this),xe.getInstance().attached(this.maskTexture,this),xe.getInstance().attached(this.whiteTexture,this),xe.getInstance().attached(this.blackTexture,this),xe.getInstance().attached(this.redTexture,this),xe.getInstance().attached(this.blueTexture,this),xe.getInstance().attached(this.greenTexture,this),xe.getInstance().attached(this.yellowTexture,this),xe.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new mr(this.whiteTexture),this.defaultGUISprite=new ai(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new qt}}class Wf extends $e{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=B.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=B.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;B.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Bb="1.0.39";class B{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return I.presentationSize}static get aspect(){return I.aspect}static get width(){return I.windowWidth}static get height(){return I.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new Z(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",Bb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Ee.init(T.allocCount,this.setting.doublePrecision),await I.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,Be.getGBufferFrame(Be.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),X.init(),Ka.init(),ve.init(),wt.init(),Wt.init(),this.res=new zf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new tl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new O0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Wf).addPost(Mn),(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){ze.delta=e-ze.time,ze.time=e,ze.frame+=1,br.tick(ze.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const s=t[a];s.scene.waitUpdate();let[o,l]=I.presentationSize;s.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const s of Ne.componentsBeforeUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=I.device.createCommandEncoder();for(const s of Ne.componentsComputeList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}I.device.queue.submit([r.finish()]);for(const s of Ne.componentsUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const s of Ne.graphicComponent){let o=s[0],l=s[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,T.useCount,16),ve.modelMatrixBindGroup.writeBuffer(T.useCount*16),this.renderJobs.forEach((s,o)=>{s.renderState||s.start(),s.renderFrame()});for(const s of Ne.componentsLateUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let Es=`
7891
+ `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await B.res.loadTexture(r,null,!0);let i=B.res.getTexture(r),s=new mr(i);e.push(s)}tr.parseSprite(e,t),t.fontChar[" "]||tr.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new ai,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),ri.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 s=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,s)&&(o.indexOf('"')==-1?t[s]=parseFloat(i[1]):t[s]=o.replace('"',"").replace('"',""))}})}}function ab(n,e){let t=new ai;return t.id=n,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 mr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function Rf(n,e,t){let a=new ai;a.guiTexture=n,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/n.width,i=1/n.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let s=.1;return t.border.x<=s&&t.border.y<=s&&t.border.z<=s&&t.border.x<=s?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 If{_spriteMap=new Map;_spriteList=[];textureSize=new fe;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=Rf(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 Tf extends rt{static format=Je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await B.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 If(this._json.size),t=new mr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);B.res.addAtlas(this.baseUrl,e),this.data=e}}var $t=Uint8Array,ii=Uint16Array,rb=Int32Array,Qf=new $t([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]),Mf=new $t([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]),ib=new $t([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pf=function(n,e){for(var t=new ii(31),a=0;a<31;++a)t[a]=e+=1<<n[a-1];for(var r=new rb(t[30]),a=1;a<30;++a)for(var i=t[a];i<t[a+1];++i)r[i]=i-t[a]<<5|a;return{b:t,r}},Nf=Pf(Qf,2),Vf=Nf.b,sb=Nf.r;Vf[28]=258,sb[258]=28;for(var nb=Pf(Mf,0),ob=nb.b,oo=new ii(32768),Xe=0;Xe<32768;++Xe){var pr=(Xe&43690)>>1|(Xe&21845)<<1;pr=(pr&52428)>>2|(pr&13107)<<2,pr=(pr&61680)>>4|(pr&3855)<<4,oo[Xe]=((pr&65280)>>8|(pr&255)<<8)>>1}for(var Ti=(function(n,e,t){for(var a=n.length,r=0,i=new ii(e);r<a;++r)n[r]&&++i[n[r]-1];var s=new ii(e);for(r=1;r<e;++r)s[r]=s[r-1]+i[r-1]<<1;var o;if(t){o=new ii(1<<e);var l=15-e;for(r=0;r<a;++r)if(n[r])for(var c=r<<4|n[r],f=e-n[r],h=s[n[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[oo[h]>>l]=c}else for(o=new ii(a),r=0;r<a;++r)n[r]&&(o[r]=oo[s[n[r]-1]++]>>15-n[r]);return o}),Qi=new $t(288),Xe=0;Xe<144;++Xe)Qi[Xe]=8;for(var Xe=144;Xe<256;++Xe)Qi[Xe]=9;for(var Xe=256;Xe<280;++Xe)Qi[Xe]=7;for(var Xe=280;Xe<288;++Xe)Qi[Xe]=8;for(var Of=new $t(32),Xe=0;Xe<32;++Xe)Of[Xe]=5;var lb=Ti(Qi,9,1),cb=Ti(Of,5,1),lo=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},Ua=function(n,e,t){var a=e/8|0;return(n[a]|n[a+1]<<8)>>(e&7)&t},co=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},fb=function(n){return(n+7)/8|0},fo=function(n,e,t){return(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length),new $t(n.subarray(e,t))},db=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ca=function(n,e,t){var a=new Error(e||db[n]);if(a.code=n,Error.captureStackTrace&&Error.captureStackTrace(a,ca),!t)throw a;return a},hb=function(n,e,t,a){var r=n.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new $t(0);var s=!t,o=s||e.i!=2,l=e.i;s&&(t=new $t(r*3));var c=function(ie){var ce=t.length;if(ie>ce){var ge=new $t(Math.max(ce*2,ie));ge.set(t),t=ge}},f=e.f||0,h=e.p||0,u=e.b||0,b=e.l,A=e.d,m=e.m,p=e.n,D=r*8;do{if(!b){f=Ua(n,h,1);var _=Ua(n,h+1,3);if(h+=3,_)if(_==1)b=lb,A=cb,m=9,p=5;else if(_==2){var S=Ua(n,h,31)+257,F=Ua(n,h+10,15)+4,k=S+Ua(n,h+5,31)+1;h+=14;for(var x=new $t(k),w=new $t(19),R=0;R<F;++R)w[ib[R]]=Ua(n,h+R*3,7);h+=F*3;for(var Q=lo(w),M=(1<<Q)-1,j=Ti(w,Q,1),R=0;R<k;){var he=j[Ua(n,h,M)];h+=he&15;var v=he>>4;if(v<16)x[R++]=v;else{var ae=0,P=0;for(v==16?(P=3+Ua(n,h,3),h+=2,ae=x[R-1]):v==17?(P=3+Ua(n,h,7),h+=3):v==18&&(P=11+Ua(n,h,127),h+=7);P--;)x[R++]=ae}}var z=x.subarray(0,S),W=x.subarray(S);m=lo(z),p=lo(W),b=Ti(z,m,1),A=Ti(W,p,1)}else ca(1);else{var v=fb(h)+4,U=n[v-4]|n[v-3]<<8,y=v+U;if(y>r){l&&ca(0);break}o&&c(u+U),t.set(n.subarray(v,y),u),e.b=u+=U,e.p=h=y*8,e.f=f;continue}if(h>D){l&&ca(0);break}}o&&c(u+131072);for(var V=(1<<m)-1,te=(1<<p)-1,J=h;;J=h){var ae=b[co(n,h)&V],K=ae>>4;if(h+=ae&15,h>D){l&&ca(0);break}if(ae||ca(2),K<256)t[u++]=K;else if(K==256){J=h,b=null;break}else{var ee=K-254;if(K>264){var R=K-257,re=Qf[R];ee=Ua(n,h,(1<<re)-1)+Vf[R],h+=re}var oe=A[co(n,h)&te],pe=oe>>4;oe||ca(3),h+=oe&15;var W=ob[pe];if(pe>3){var re=Mf[pe];W+=co(n,h)&(1<<re)-1,h+=re}if(h>D){l&&ca(0);break}o&&c(u+131072);var Te=u+ee;if(u<W){var Oe=i-W,q=Math.min(W,Te);for(Oe+u<0&&ca(3);u<q;++u)t[u]=a[Oe+u]}for(;u<Te;++u)t[u]=t[u-W]}}e.l=b,e.p=J,e.b=u,e.f=f,b&&(f=1,e.m=m,e.d=A,e.n=p)}while(!f);return u!=t.length&&s?fo(t,0,u):t.subarray(0,u)},ub=new $t(0),Pa=function(n,e){return n[e]|n[e+1]<<8},ya=function(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24)>>>0},ho=function(n,e){return ya(n,e)+ya(n,e+4)*4294967296};function bb(n,e){return hb(n,{i:2},e&&e.out,e&&e.dictionary)}var uo=typeof TextDecoder<"u"&&new TextDecoder,gb=0;try{uo.decode(ub,{stream:!0}),gb=1}catch{}var mb=function(n){for(var e="",t=0;;){var a=n[t++],r=(a>127)+(a>223)+(a>239);if(t+r>n.length)return{s:e,r:fo(n,t-1)};r?r==3?(a=((a&15)<<18|(n[t++]&63)<<12|(n[t++]&63)<<6|n[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|n[t++]&63):e+=String.fromCharCode((a&15)<<12|(n[t++]&63)<<6|n[t++]&63):e+=String.fromCharCode(a)}};function Lf(n,e){if(e){for(var t="",a=0;a<n.length;a+=16384)t+=String.fromCharCode.apply(null,n.subarray(a,a+16384));return t}else{if(uo)return uo.decode(n);var r=mb(n),i=r.s,t=r.r;return t.length&&ca(8),i}}var pb=function(n,e){return e+30+Pa(n,e+26)+Pa(n,e+28)},Ab=function(n,e,t){var a=Pa(n,e+28),r=Lf(n.subarray(e+46,e+46+a),!(Pa(n,e+8)&2048)),i=e+46+a,s=ya(n,e+20),o=t&&s==4294967295?Db(n,i):[s,ya(n,e+24),ya(n,e+42)],l=o[0],c=o[1],f=o[2];return[Pa(n,e+10),l,c,r,i+Pa(n,e+30)+Pa(n,e+32),f]},Db=function(n,e){for(;Pa(n,e)!=1;e+=4+Pa(n,e+2));return[ho(n,e+12),ho(n,e+4),ho(n,e+20)]};function _b(n,e){for(var t={},a=n.length-22;ya(n,a)!=101010256;--a)(!a||n.length-a>65558)&&ca(13);var r=Pa(n,a+8);if(!r)return{};var i=ya(n,a+16),s=i==4294967295||r==65535;if(s){var o=ya(n,a-12);s=ya(n,o)==101075792,s&&(r=ya(n,o+32),i=ya(n,o+48))}for(var l=0;l<r;++l){var c=Ab(n,i,s),f=c[0],h=c[1],u=c[2],b=c[3],A=c[4],m=c[5],p=pb(n,m);i=A,f?f==8?t[b]=bb(n.subarray(p,p+h),{out:new $t(u)}):ca(14,"unknown compression type "+f):t[b]=fo(n,p,p+h)}return t}class Bt extends Dt{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=B.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 Ir extends Ve{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,s,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=s,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,s=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,b=0,A=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,p=s*Math.cos(m),D=s*Math.sin(m);for(e=0;e<=i;++e){var _=2*Math.PI*e/i,v=D*Math.cos(_),U=D*Math.sin(_),y=1/Math.sqrt(v*v+p*p+U*U);if(l[u++]=v,l[u++]=p,l[u++]=U,c[b++]=v*y,c[b++]=p*y,c[b++]=U*y,f[A++]=e/i,f[A++]=t/r,e>0&&t>0){var S=(i+1)*t+e,F=(i+1)*t+e-1,k=(i+1)*(t-1)+e-1,x=(i+1)*(t-1)+e;t==r?(h[a++]=S,h[a++]=k,h[a++]=x):t==1?(h[a++]=S,h[a++]=F,h[a++]=k):(h[a++]=S,h[a++]=F,h[a++]=k,h[a++]=S,h[a++]=k,h[a++]=x)}}}this.setIndices(h),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(g.ZERO,new g(this.radius*2,this.radius*2,this.radius*2))}}class Mi 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 g(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),Mi.register3DRepresentation)this.marker=Mi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Ir(.1,32,16),e.material=new Bt,e.material.baseColor=this.positionValid?new Z(0,1,0,1):new Z(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Pi 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 Mi(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),Pi.register3DRepresentation?(this.line=Pi.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new Z(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(G.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const s=new d.Object3D,o=s.addComponent(d.MeshRenderer),l=new Bt;return l.topology="line-list",l.baseColor=t,l.blendMode=Ae.ADD,l.castReflection=!1,o.geometry=a,o.material=l,s}}class Gf extends rt{static format=Je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=_b(new Uint8Array(e));for(const i in a){const s=a[i],l=new DOMParser().parseFromString(Lf(s),"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 Pi(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,s=!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&&(s=!0)}if(i&&!s)t[r]=i;else if(s){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 zf{_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 Tt().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 Tt;r==".gltf"?a=await i.load(e,_t,t):a=await i.load(e,Hn,t);let s=a.data;return this._prefabPool.set(e,s),this._gltfPool.set(e,a.gltf),s}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new Tt;r==".obj"&&(a=await i.load(e,wi,t));let s=a.data;return this._prefabPool.set(e,s),s}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let s=(await new Tt().load(e,ro,t,a)).data;return this._prefabPool.set(e,s),s}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let s=(await new Tt().load(e,no,t,a)).data;return this._prefabPool.set(e,s),s}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $a;r.flipY=a;try{await r.load(e,t)}catch(i){return console.error(`Failed to load texture: ${e}`,i),null}return this._texturePool.set(e,r),r}destroyTexture(e){const t=this._texturePool.get(e);return t?xe.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,s)=>{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=[],s=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<s;l++){let c=await this.loadTextureCount(e,l==s-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 $n;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 xs;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 ks;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 Kn;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 Kn;return await a.loadStd(e),a}async loadJSON(e,t){return await new Tt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new Tt().load(e,tr,t,a),s=i.data;return ri.addFontData(s.face,s.size,s),i.data}async loadAtlas(e,t){return(await new Tt().load(e,Tf,t,e)).data}async loadKMZ(e,t){return(await new Tt().load(e,Gf,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,s,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,s);let h=new Si;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}fillColor(e,t,a,r,i,s,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]=s,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 Ff().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new xs,this.defaultSky.createFromTexture(128,this.blackTexture),xe.getInstance().attached(this.defaultSky,this),xe.getInstance().attached(t,this),xe.getInstance().attached(this.normalTexture,this),xe.getInstance().attached(this.maskTexture,this),xe.getInstance().attached(this.whiteTexture,this),xe.getInstance().attached(this.blackTexture,this),xe.getInstance().attached(this.redTexture,this),xe.getInstance().attached(this.blueTexture,this),xe.getInstance().attached(this.greenTexture,this),xe.getInstance().attached(this.yellowTexture,this),xe.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new mr(this.whiteTexture),this.defaultGUISprite=new ai(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new qt}}class Wf extends $e{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=B.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=B.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;B.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Bb="1.0.41";class B{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return I.presentationSize}static get aspect(){return I.aspect}static get width(){return I.windowWidth}static get height(){return I.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new Z(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",Bb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Ee.init(T.allocCount,this.setting.doublePrecision),await I.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,Be.getGBufferFrame(Be.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),X.init(),Ka.init(),ve.init(),wt.init(),Wt.init(),this.res=new zf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new tl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new O0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Wf).addPost(Mn),(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){ze.delta=e-ze.time,ze.time=e,ze.frame+=1,br.tick(ze.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const s=t[a];s.scene.waitUpdate();let[o,l]=I.presentationSize;s.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const s of Ne.componentsBeforeUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=I.device.createCommandEncoder();for(const s of Ne.componentsComputeList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}I.device.queue.submit([r.finish()]);for(const s of Ne.componentsUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const s of Ne.graphicComponent){let o=s[0],l=s[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,T.useCount,16),ve.modelMatrixBindGroup.writeBuffer(T.useCount*16),this.renderJobs.forEach((s,o)=>{s.renderState||s.start(),s.renderFrame()});for(const s of Ne.componentsLateUpdateList){let o=s[0],l=s[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let Es=`
7892
7892
  struct BloomCfg{
7893
7893
  downSampleStep: f32,
7894
7894
  downSampleBlurSize: f32,
@@ -11786,7 +11786,7 @@ fn frag(){
11786
11786
  ${this.fs}
11787
11787
  `}class vo extends Dt{_scissorRect;_screenSize=new fe(1024,768);_scissorEnable=!1;constructor(e){super(),X.register("GUI_shader_view",Bo.GUI_shader_view),X.register("GUI_shader_world",Bo.GUI_shader_world);let t=new gt;this.addColorPass(t,de.COLOR,e),this.addColorPass(t,de.UI,e),this.shader=t}addColorPass(e,t,a){let r=a==fa.View?"GUI_shader_view":"GUI_shader_world",i=new qe(r,r);i.passType=t,i.setShaderEntry("VertMain","FragMain"),i.setUniformVector4("scissorRect",new ue),i.setUniformVector2("screenSize",this._screenSize),i.setUniformFloat("scissorCornerRadius",0),i.setUniformFloat("scissorFadeOutSize",0),i.setUniformFloat("pixelRatio",1),i.setUniformVector3("v3",g.ZERO);let s=i.shaderState;s.depthWriteEnabled=!1,i.blendMode=Ae.NORMAL,i.depthCompare=a==fa.View?lt.always:lt.less_equal,i.cullMode=Vt.back,e.addRenderPass(i)}setPanelRatio(e){this.shader.setUniformFloat("pixelRatio",e)}setScissorRect(e,t,a,r){this._scissorRect||=new ue,this._scissorRect.set(e,t,a,r),this.shader.setUniformVector4("scissorRect",this._scissorRect)}setScissorEnable(e){this._scissorEnable!=e&&(this._scissorEnable=e,e?this.shader.setDefine("SCISSOR_ENABLE",!0):this.shader.deleteDefine("SCISSOR_ENABLE"),this.shader.noticeValueChange())}setScissorCorner(e,t){this.shader.setUniformFloat("scissorCornerRadius",e),this.shader.setUniformFloat("scissorFadeOutSize",t)}setScreenSize(e,t){return this._screenSize.set(e,t),this.shader.setUniformVector2("screenSize",this._screenSize),this}setTextures(e){for(let t=0;t<7;t++){let a=e[t]||B.res.whiteTexture;this.shader.setTexture(`tex_${t}`,a),this.setVideoTextureDefine(t,a.isVideoTexture)}}_videoTextureFlags={};setVideoTextureDefine(e,t){let a=!1;t!=this._videoTextureFlags[e]&&(t?this.shader.setDefine(`VideoTexture${e}`,!0):this.shader.deleteDefine(`VideoTexture${e}`),this._videoTextureFlags[e]=t,a=!0),a&&this.shader.noticeValueChange()}set envMap(e){}set shadowMap(e){}set baseMap(e){}set normalMap(e){}set emissiveMap(e){}set irradianceMap(e){}set irradianceDepthMap(e){}}class Ld extends d.MeshRenderer{_guiGeometry;init(e){super.init(),this.addRendererMask(Me.UI),this.removeRendererMask(Me.Default),this.castGI=!1,this.castShadow=!1,this.alwaysRender=!0,this._ignoreEnvMap=this._ignorePrefilterMap=!0}get geometry(){return super.geometry}set geometry(e){super.geometry=e,this._guiGeometry=e}nodeUpdate(e,t,a,r){for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(t),l=this._guiGeometry.getPositionBuffer(),c=this._guiGeometry.getSpriteBuffer(),f=this._guiGeometry.getColorBuffer();if(o)for(let h=0;h<o.length;h++){const u=o[h];u.pipeline||(u.setStorageBuffer("vPositionBuffer",l),u.setStorageBuffer("vSpriteBuffer",c),u.setStorageBuffer("vColorBuffer",f))}}super.nodeUpdate(e,t,a,r)}onUpdate(e){}}class Gd{_use;_unUse;constructor(){this._use=[],this._unUse=[]}pushBack(e){let t=this._use.indexOf(e);t!=-1&&(this._use.splice(t,1),this._unUse.push(e))}getUseList(){return this._use}getOne(e,t){let a;return this._unUse.length>0?(a=this._unUse[0],this._unUse.splice(0,1),this._use.push(a),a):(a=new e(t),this._use.push(a),a)}hasFree(){return this._unUse.length>0}}let Wi;class Na{x=0;y=0;z=0;width=1;height=1;_globalX=0;_globalY=0;_globalWidth=0;_globalHeight=0;_visible=!0;_offsetX=0;_offsetY=0;_sprite=B.res.defaultGUISprite;_color=new Z(1,1,1,1);_imageType=si.Simple;dirtyAttributes=nt.MAX;cacheTextureId=-1;static textPool;static get quadPool(){return this.textPool||=new Gd,this.textPool}static recycleQuad(e){e.sprite=null,e.dirtyAttributes=nt.MAX,e.x=0,e.y=0,e.z=-1,e.cacheTextureId=-1,Na.quadPool.pushBack(e)}static spawnQuad(){return Na.quadPool.getOne(Na)}get imageType(){return this._imageType}set imageType(e){this._imageType=e,this.setAttrChange(nt.SPRITE|nt.POSITION)}get color(){return this._color}set color(e){this._color.copyFrom(e),this.setAttrChange(nt.COLOR)}get visible(){return this._visible}set visible(e){e!=this._visible&&(this._visible=e,this.setAttrChange(nt.SPRITE))}get sprite(){return this._sprite}set sprite(e){this._sprite!=e&&(this._sprite=e,this.setAttrChange(nt.SPRITE|nt.POSITION))}get left(){return this._globalX-this._offsetX}get right(){return this.left+this._globalWidth}get top(){return this._globalY-this._offsetY}get bottom(){return this.top+this._globalHeight}setSize(e,t){this.width=e,this.height=t,this.setAttrChange(nt.POSITION)}setXY(e,t){this.x=e,this.y=t,this.setAttrChange(nt.POSITION)}setAttrChange(e){this.dirtyAttributes=this.dirtyAttributes|e}applyTransform(e){this.setAttrChange(nt.POSITION);let t=this._sprite,a=e.getWorldMatrix();(this.x!=0||this.y!=0)&&(a=this.getQuadMatrix(a));let r=a.getScaleX(),i=a.getScaleY(),s=t.isSliced&&this._imageType==si.Sliced;if(this._offsetX=e.width*.5*r,this._offsetY=e.height*.5*i,s)this._globalWidth=r*(e.width-(t.offsetSize.z-t.trimSize.x)),this._globalHeight=i*(e.height-(t.offsetSize.w-t.trimSize.y)),this._globalX=a.tx+t.offsetSize.x*r,this._globalY=a.ty+t.offsetSize.y*i;else{let o=this.width/t.offsetSize.z,l=this.height/t.offsetSize.w;this._globalWidth=r*t.trimSize.x*o,this._globalHeight=i*t.trimSize.y*l,this._globalX=a.tx+t.offsetSize.x*o*r,this._globalY=a.ty+t.offsetSize.y*l*i}return this}getQuadMatrix(e){return Wi||=new Pr,Wi.identity(),Wi.setTranslate(this.x,this.y),Wi.mul(e),Wi}writeToGeometry(e,t){return e.fillQuad(this,t),this.dirtyAttributes=nt.NONE,this}}class Uo extends $e{_uiTransform;_visible=!0;destroy(){this._uiTransform.setNeedUpdateUIPanel(),super.destroy()}get uiTransform(){return this._uiTransform}get visible(){return this._visible}set visible(e){this._visible!=e&&(this._visible=e,this.onUIComponentVisible?.(this._visible))}init(e){super.init?.(e),this._uiTransform=this.object3D.getOrAddComponent(ar),this._uiTransform.setNeedUpdateUIPanel()}copyComponent(e){return this.visible=e.visible,this}}class Ji extends Uo{_mainQuads;_shadowRender;_shadowSource;isUIShadow;isShadowless;needUpdateShadow;init(e){super.init?.(e),this._mainQuads=[]}destroy(){this.detachQuads(),this._shadowRender?.setShadowSource(null),this._shadowSource?.setShadowRenderer(null),super.destroy(),this._shadowRender=null,this._shadowSource=null}start(){super.start?.(),this.isUIShadow?this.autoBindShadow(null,this):this.isShadowless||this.autoBindShadow(this,null),this.setShadowDirty()}setShadowDirty(){this._shadowRender&&(this._shadowRender.needUpdateShadow=!0)}get mainQuads(){return this._mainQuads}setShadowRenderer(e){this._shadowRender=e}setShadowSource(e){this._shadowSource=e}getShadowRender(){return this._shadowRender}autoBindShadow(e,t){let a=this.object3D.components.values();if(!e)for(let r of a){let i=r;if(!(i.isShadowless||i.isUIShadow)&&i.mainQuads){e=i;break}}if(!t)for(let r of a){let i=r;if(i.isUIShadow&&i.mainQuads){t=i;break}}return e&&t?(e.setShadowRenderer(t),t.setShadowSource(e),!0):!1}recycleQuad(e){if(e&&this._mainQuads){let t=this._mainQuads.indexOf(e);t>=0?(this._mainQuads.splice(t,1),Na.recycleQuad(e)):e=null}return e}attachQuad(e){return this._mainQuads&&this._mainQuads.push(e),this}detachQuads(){if(this._mainQuads)for(;this._mainQuads.length>0;){let e=this._mainQuads.shift();this.recycleQuad(e)}return this}copyComponent(e){return super.copyComponent(e),this.isUIShadow=e.isUIShadow,this.isShadowless=e.isShadowless,this}}class Nr extends Ji{init(e){super.init?.(e),this.attachQuad(Na.spawnQuad()),this.sprite=B.res.defaultGUISprite}cloneTo(e){e.getOrAddComponent(Nr).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.sprite=e.sprite,this.color=e.color,this.imageType=e.imageType,this}set sprite(e){e||=B.res.defaultGUISprite;for(let t of this._mainQuads)t.sprite=e,t.setSize(this._uiTransform.width,this._uiTransform.height);this.setShadowDirty()}onTransformResize(){this.applyTransformSize()}applyTransformSize(){for(let e of this._mainQuads)e.setSize(this._uiTransform.width,this._uiTransform.height);this.setShadowDirty()}get sprite(){return this._mainQuads[0].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}get color(){return this._mainQuads[0].color}set color(e){for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get imageType(){return this._mainQuads[0].imageType}set imageType(e){for(let t of this._mainQuads)t.imageType=e;this.setShadowDirty()}}class ji extends Nr{space=fa.World;needUpdateGeometry=!0;panelOrder=0;needSortOnCameraZ;_billboard;_rebuild;scissorEnable=!1;scissorCornerRadius=0;scissorFadeOutSize=0;_uiRenderer;_geometry;_maxCount=128;panelRatio=1;isUIPanel=!0;cloneTo(e){e.getOrAddComponent(ji).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.panelOrder=e.panelOrder,this.needSortOnCameraZ=e.needSortOnCameraZ,this.cullMode=e.cullMode,this.billboard=e.billboard,this.scissorEnable=e.scissorEnable,this.scissorCornerRadius=e.scissorCornerRadius,this.scissorFadeOutSize=e.scissorFadeOutSize,this}init(e){super.init(e),this._uiTransform.resize(I.canvas.width,I.canvas.height),this.create(this.space),this.visible=!1}updateDrawCallSegment(e,t,a){this._geometry.updateSubGeometry(e,t,a);let r=this._uiRenderer.material,i=this._uiRenderer.materials[e];if(!i){i=new vo(this.space);let s=this._uiRenderer.materials.slice();s.push(i),this._uiRenderer.materials=s,i.cullMode=r.cullMode,i.depthCompare=r.depthCompare}}create(e){this._maxCount=this.space==fa.World?Qr.quadMaxCountForWorld:Qr.quadMaxCountForView,this._uiRenderer=this.object3D.addComponent(Ld),this._geometry=this._uiRenderer.geometry=new Nd(this._maxCount).create(),this._uiRenderer.material=new vo(e),this._uiRenderer.renderOrder=Qr.SortOrderStartWorld,this._rebuild=new Od,this.object3D.bound=new Ce(new g,new g(1,1,1).multiplyScalar(Number.MAX_VALUE*.1))}get quadMaxCount(){return this._maxCount}get renderer(){return this._uiRenderer}set billboard(e){this.space==fa.View&&(e=Ar.None,console.warn("Cannot enable billboard in view space")),e==Ar.BillboardXYZ||e==Ar.BillboardY?(this._billboard=this.object3D.getOrAddComponent(Ni),this._billboard.type=e):(this.object3D.removeComponent(Ni),this._billboard=null)}get billboard(){return this._billboard?this._billboard.type:Ar.None}set cullMode(e){if(this.space==fa.World)for(let t of this._uiRenderer.materials)t.cullMode=e;else console.warn("Cannot change cullMode in view space")}get cullMode(){return this._uiRenderer.material.cullMode}onUpdate(e){super.onUpdate?.(e),this.rebuildGUIMesh(e)}_collectTransform=[];rebuildGUIMesh(e){let t=this,a=t._collectTransform;if(a.length=0,t.object3D.getComponents(ar,a),a.length>0){t._rebuild.build(a,t,t.needUpdateGeometry);for(const o of a)o.needUpdateQuads=!1}let r=t.object3D.getComponentFromParent(zi),i=r?r.index:0;t._uiRenderer.enable=a.length>0;let s=t.isViewPanel?Qr.SortOrderStartView:Qr.SortOrderStartWorld;if(t._uiRenderer.renderOrder=i*Qr.SortOrderCanvasSpan+s+t.panelOrder,t._uiRenderer.needSortOnCameraZ=t.needSortOnCameraZ,this.space==fa.View){let o=I.canvas.clientWidth,l=I.canvas.clientHeight,c=this._uiTransform.width,f=this._uiTransform.height;this.panelRatio=this.updateGUIPixelRatio(o,l,c,f)}else this.panelRatio=1;for(let o of t._uiRenderer.materials){let l=o;if(l.setPanelRatio(this.panelRatio),l.setScreenSize(I.canvas.clientWidth,I.canvas.clientHeight),l.setScissorEnable(t.scissorEnable),t.scissorEnable){let c=t.mainQuads[0];l.setScissorRect(c.left,c.bottom,c.right,c.top),l.setScissorCorner(t.scissorCornerRadius,t.scissorFadeOutSize)}}t.needUpdateGeometry=!1}updateGUIPixelRatio(e,t,a,r){let i=a/r,s=e/t,o=1;return i<s?o=t/r:o=e/a,o}}class Is extends ji{isViewPanel=!0;space=fa.View;constructor(){super()}cloneTo(e){e.getOrAddComponent(Is).copyComponent(this)}}class Ts extends ji{isWorldPanel=!0;space=fa.World;_depthTest=!0;constructor(){super()}cloneTo(e){e.getOrAddComponent(Ts).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.depthTest=e.depthTest,this}get depthTest(){return this._depthTest}set depthTest(e){if(this._depthTest!=e){this._depthTest=e;let t=this.depthTest?lt.less_equal:lt.always;for(let a of this._uiRenderer.materials)a.depthCompare=t}}}let zd;class ar extends $e{useParentPivot=!1;parent;pivotX=.5;pivotY=.5;_width=100;_height=100;_localVisible=!0;_globalVisible=!0;_uiInteractiveList;get uiInteractiveList(){return this._uiInteractiveList}constructor(){super(),this._localMatrix=new Pr,this._worldMatrix=new Pr}init(e){super.init(e),this.transform.eventDispatcher.addEventListener(this.transform.eventLocalChange.type,this.onTransformChange,this),this.onParentChange(null,this.object3D.parent?.object3D)}onTransformChange(e){this.onChange=!0}addUIInteractive(e){return this._uiInteractiveList||=[],this._uiInteractiveList.push(e),this}removeUIInteractive(e){if(this._uiInteractiveList){let t=this._uiInteractiveList.indexOf(e);if(t>=0)return this._uiInteractiveList.slice(t,1),e}return null}get globalVisible(){return this._globalVisible}set visible(e){if(this._localVisible!=e){this._localVisible=e;let t=this.parent?this.parent._globalVisible:!0;this.onUITransformVisible(this._localVisible&&t)}}get visible(){return this._localVisible}onUITransformVisible(e){let t=this._localVisible&&e;t!=this._globalVisible&&(this._globalVisible=t,this.object3D.components.forEach((a,r)=>{let i=a;if(i.onUITransformVisible)if(i==this)for(let s of this.object3D.entityChildren){let o=s.getComponent(ar);o&&o.onUITransformVisible(this._globalVisible)}else i.onUITransformVisible(this._globalVisible)}))}onParentChange(e,t){this.parent?.setNeedUpdateUIPanel(),this.parent=t?.getComponent(ar),this.parent?.setNeedUpdateUIPanel()}get width(){return this._width}get height(){return this._height}resize(e,t){if(this._width!=e||this._height!=t){this._width=e,this._height=t,this.onChange=!0;for(let a of this.object3D.components.values())a.onTransformResize?.();return!0}return!1}get x(){return this.object3D.x}set x(e){e!=this.object3D.x&&(this.object3D.x=e,this.onChange=!0)}get y(){return this.object3D.y}set y(e){e!=this.object3D.y&&(this.object3D.y=e,this.onChange=!0)}setXY(e,t){let a=this.object3D.localPosition;a.set(e,t,a.z),this.object3D.localPosition=a,this.onChange=!0}get z(){return this.object3D.z}set z(e){e!=this.object3D.z&&(this.object3D.z=e,this.onChange=!0)}get scaleX(){return this.object3D.scaleX}set scaleX(e){this.onChange=!0,this.object3D.scaleX=e}get scaleY(){return this.object3D.scaleY}set scaleY(e){this.onChange=!0,this.object3D.scaleY=e}get scaleZ(){return this.object3D.scaleZ}set scaleZ(e){this.onChange=!0,this.object3D.scaleZ=e}_localMatrix;_worldMatrix;_onChange=!0;needUpdateQuads=!0;get onChange(){return this._onChange}_tempTransforms=[];set onChange(e){if(this._onChange!=e&&(this._onChange=e,e)){this._tempTransforms.length=0;let t=this.object3D.getComponents(ar,this._tempTransforms,!0);for(let a of t)a._onChange=!0,a.needUpdateQuads=!0}}onEnable(){this.setNeedUpdateUIPanel(),this.onChange=!0}onDisable(){this.setNeedUpdateUIPanel(),this.onChange=!0}setNeedUpdateUIPanel(){let e;e=this.object3D.getComponentFromParent(Ts),e||(e=this.object3D.getComponentFromParent(Is)),e&&(e.needUpdateGeometry=!0)}cloneTo(e){let t=e.getOrAddComponent(ar);t.visible=this.visible,t.x=this.x,t.y=this.y,t.z=this.z,t.resize(this.width,this.height),t.pivotX=this.pivotX,t.pivotY=this.pivotY,t.scaleX=this.scaleX,t.scaleY=this.scaleY}matrix(){let e=this._localMatrix,t=this.object3D.rotationZ;return this.parent?(e.updateScaleAndRotation(this.object3D.scaleX,this.object3D.scaleY,t,t),e.tx=this.object3D.x,e.ty=this.object3D.y):e.updateScaleAndRotation(1,1,0,0),(this.pivotX!=.5||this.pivotY!=.5)&&(zd||=new Pr().identity(),e.mul(zd.setTo(1,0,0,1,-(this.pivotX-.5)*this.width,-(this.pivotY-.5)*this.height))),e}getWorldMatrix(){let e=this,t=e._worldMatrix;return this._onChange&&(t.copyFrom(e.matrix()),e.parent&&t.mul(e.parent.getWorldMatrix()),e._onChange=!1),t}beforeDestroy(e){this.transform.eventDispatcher.addEventListener(this.transform.eventLocalChange.type,this.onTransformChange,this),super.beforeDestroy?.(e)}}class Wd{_ray;_mouseCode;_clickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_view;init(e){this._view=e,this._ray=new na,this._clickEvent=new yt(yt.PICK_CLICK_GUI),this._outEvent=new yt(yt.PICK_OUT_GUI),this._overEvent=new yt(yt.PICK_OVER_GUI),this._upEvent=new yt(yt.PICK_UP_GUI),this._downEvent=new yt(yt.PICK_DOWN_GUI),B.inputSystem.addEventListener(Y.POINTER_DOWN,this.onTouchDown,this,null,1),B.inputSystem.addEventListener(Y.POINTER_UP,this.onTouchUp,this,null,1),B.inputSystem.addEventListener(Y.POINTER_MOVE,this.onTouchMove,this,null,1),B.inputSystem.addEventListener(Y.POINTER_CLICK,this.onTouchClick,this,null,1)}_lastDownTarget;_lastOverTarget;onTouchClick(e){this._lastOverTarget&&e.stopImmediatePropagation()}onTouchMove(e){this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);if(t){e.stopImmediatePropagation();let a=t.collider;a!=this._lastOverTarget&&(a.mouseStyle=at.OVER,Object.assign(this._overEvent,e),this._overEvent.type=yt.PICK_OVER_GUI,this._overEvent.target=a.object3D,this._overEvent.data=t,a.object3D.dispatchEvent(this._overEvent),this._lastOverTarget&&(this._lastOverTarget.mouseStyle=at.NORMAL,Object.assign(this._outEvent,e),this._outEvent.type=yt.PICK_OUT_GUI,this._outEvent.target=a.object3D,this._outEvent.data=t,this._lastOverTarget.object3D.dispatchEvent(this._outEvent))),this._lastOverTarget=a}else this._lastOverTarget&&(this._lastOverTarget.mouseStyle=at.NORMAL,Object.assign(this._outEvent,e),this._outEvent.type=yt.PICK_OUT_GUI,this._outEvent.target=this._lastOverTarget.object3D,this._outEvent.data=t,this._lastOverTarget.object3D.dispatchEvent(this._outEvent),this._lastOverTarget=null)}_lastDownPosition=new fe;_calcDistanceVec2=new fe;_lastDownTime=0;_clickTimeSpan=200;_clickDistanceSpan=10;onTouchDown(e){this._lastDownTime=ze.time,this._lastDownPosition.set(e.mouseX,e.mouseY),this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);t&&e.stopImmediatePropagation();let a=t?t.collider:null;a&&(a.mouseStyle=at.DOWN,Object.assign(this._downEvent,e),this._downEvent.type=yt.PICK_DOWN_GUI,this._downEvent.target=a.object3D,this._downEvent.data=t,a.object3D.dispatchEvent(this._downEvent)),this._lastDownTarget=a}onTouchUp(e){this._calcDistanceVec2.set(e.mouseX,e.mouseY),this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);t&&e.stopImmediatePropagation();let a=t?t.collider:null;this._lastDownTarget&&this._lastDownTarget.enable&&(this._lastDownTarget.mouseStyle=at.NORMAL),a&&a==this._lastDownTarget&&ze.time-this._lastDownTime<=this._clickTimeSpan&&(this._calcDistanceVec2.set(e.mouseX,e.mouseY),this._calcDistanceVec2.distance(this._lastDownPosition)<=this._clickDistanceSpan&&(Object.assign(this._clickEvent,e),this._clickEvent.type=yt.PICK_CLICK_GUI,this._clickEvent.target=a.object3D,this._clickEvent.data=t,a.object3D.dispatchEvent(this._clickEvent))),this._lastDownTarget=null}_colliderOut=[];_transformList=[];_sortWorldPanelList=[];_iteractive2PanelDict=new Map;collectEntities(){return this._colliderOut.length=0,this._sortWorldPanelList.length=0,this._iteractive2PanelDict.clear(),this._view.canvasList.slice().reverse().forEach(t=>{if(t&&t.transform&&t.transform.parent){let a=t.object3D.getComponentsByProperty("isUIPanel",!0,!0);a.sort((r,i)=>{let s=r._uiRenderer.__renderOrder,o=i._uiRenderer.__renderOrder;return s>o?-1:1});for(let r of a){this._transformList.length=0,r.object3D.getComponents(ar,this._transformList),this._transformList.reverse();for(const i of this._transformList){let s=i.uiInteractiveList;if(s&&s.length>0)for(let o of s)this._colliderOut.push(o),this._iteractive2PanelDict.set(o,r)}}}}),this._colliderOut}pick(e){this._ray=this._view.camera.screenPointToRay(B.inputSystem.mouseX,B.inputSystem.mouseY);let t=new fe(B.inputSystem.mouseX,B.inputSystem.mouseY),a=new fe(I.canvas.clientWidth,I.canvas.clientHeight),r;for(const i of e)if(i.interactive&&i.enable&&i.interactiveVisible){let s=this._iteractive2PanelDict.get(i);if(r=i.rayPick(this._ray,s,t,a),r)return r.collider=i,r}return null}}var Jd=(n=>(n[n.COLLINEAR=0]="COLLINEAR",n[n.LINES_INTERSECT=1]="LINES_INTERSECT",n[n.SEGMENTS_INTERSECT=2]="SEGMENTS_INTERSECT",n[n.A_BISECTS_B=3]="A_BISECTS_B",n[n.B_BISECTS_A=4]="B_BISECTS_A",n[n.PARALELL=5]="PARALELL",n))(Jd||{}),jd=(n=>(n[n.ON_LINE=0]="ON_LINE",n[n.LEFT_SIDE=1]="LEFT_SIDE",n[n.RIGHT_SIDE=2]="RIGHT_SIDE",n))(jd||{});class vt{static cacluteLine0=new vt(null,null);static cacluteLine1=new vt(null,null);start;end;color=new Z(1,1,1,1);_normal;_normalCalculated=!1;constructor(e,t){this.start=e,this.end=t}set(e,t){this.start=e,this.end=t}getCenter(){let e=g.HELP_0;return this.start.subtract(this.end,e),e.scaleBy(.5),e.add(this.end),e}inverse(){let e=this.start;this.start=this.end,this.end=e}equals(e){return this.start==e.start&&this.end==e.end||this.start==e.end&&this.end==e.start}toArray(){return[this.start.x,this.start.y,this.start.z,this.end.x,this.end.y,this.end.z]}static getLines(e){let t=[];for(let a=0;a<e.length;a++){let r=a,i=gn(a+1,e.length),s=e[r],o=e[i];t.push(new vt(s,o))}return t}intersection(e,t=null){var a=(e.end.z-e.start.z)*(this.end.x-this.start.x)-(e.end.x-e.start.x)*(this.end.z-this.start.z),r=(e.end.x-e.start.x)*(this.start.z-e.start.z)-(e.end.z-e.start.z)*(this.start.x-e.start.x),i=(e.start.x-this.start.x)*(this.end.z-this.start.z)-(e.start.z-this.start.z)*(this.end.x-this.start.x);if(a==0)return r==0&&i==0?0:5;r=r/a,i=i/a;var s=this.start.x+r*(this.end.x-this.start.x),o=this.start.z+r*(this.end.z-this.start.z);return t!=null&&(t.x=s,t.y=0,t.z=o),r>=0&&r<=1&&i>=0&&i<=1?2:i>=0&&i<=1?3:r>=0&&r<=1?4:1}getDirection(){var e=this.end.subtract(this.start),t=new g(e.x,e.y);return t.normalize()}copyFrom(e){this.start||(this.start=new g),this.end||(this.end=new g),this.start.copyFrom(e.start),this.end.copyFrom(e.end)}static IsEqual(e,t){return Math.abs(e-t)<1e-7}static squreDistanceSegmentToSegment(e,t,a){let r=e.start,i=e.end,s=t.start,o=t.end,l=r.x,c=r.y,f=r.z,h=i.x,u=i.y,b=i.z,A=s.x,m=s.y,p=s.z,D=o.x,_=o.y,v=o.z,U=h-l,y=u-c,S=b-f,F=D-A,k=_-m,x=v-p,w=l-A,R=c-m,Q=f-p,M=U*U+y*y+S*S,j=U*F+y*k+S*x,he=F*F+k*k+x*x,ae=U*w+y*R+S*Q,P=F*w+k*R+x*Q,z=M*he-j*j,W=z,V=z,te=0,J=0;this.IsEqual(z,0)?(te=0,W=1,J=P,V=he):(te=j*P-he*ae,J=M*P-j*ae,te<0?(te=0,J=P,V=he):te>W&&(te=W,J=P+j,V=he)),J<0?(J=0,-ae<0?te=0:-ae>M?te=W:(te=-ae,W=M)):J>V&&(J=V,-ae+j<0?te=0:-ae+j>M?te=W:(te=-ae+j,W=M));let K=0,ee=0;this.IsEqual(te,0)?K=0:K=te/W,this.IsEqual(J,0)?ee=0:ee=J/V;let re=w+K*U-ee*F,oe=R+K*y-ee*k,pe=Q+K*S-ee*x;return re*re+oe*oe+pe*pe}isNear(e,t=0,a){let r=g.HELP_0,i=g.HELP_1;r.copyFrom(e.origin),i.copyFrom(e.direction),i.scaleBy(9999),i.add(r,i),vt.cacluteLine0.set(r,i),vt.cacluteLine1.copyFrom(this),a&&(a.perspectiveMultiplyPoint3(vt.cacluteLine1.start,vt.cacluteLine1.start),a.perspectiveMultiplyPoint3(vt.cacluteLine1.end,vt.cacluteLine1.end));let s=vt.squreDistanceSegmentToSegment(vt.cacluteLine0,vt.cacluteLine1,a);return s+1e-4<=t?(e.length=s,!0):(e.length=-999999,!1)}}class Zi{static ID=-1;v1;v2;v3;u1;u2;u3;n1;n2;n3;t0;t;u;v;min=new g;max=new g;id=0;constructor(e,t,a){this.id=Zi.ID+++200,e&&t&&a&&this.set(e,t,a)}set(e,t,a){this.v1=e,this.v2=t,this.v3=a;let r=this.min,i=this.max;return r.x=Math.min(this.v1.x,this.v2.x,this.v3.x),r.y=Math.min(this.v1.y,this.v2.y,this.v3.y),r.z=Math.min(this.v1.z,this.v2.z,this.v3.z),i.x=Math.max(this.v1.x,this.v2.x,this.v3.x),i.y=Math.max(this.v1.y,this.v2.y,this.v3.y),i.z=Math.max(this.v1.z,this.v2.z,this.v3.z),this}getNormal(){let e=this.v1,t=this.v2,a=this.v3,r=new g(t.x-e.x,t.y-e.y,t.z-e.z),s=new g(a.x-e.x,a.y-e.y,a.z-e.z).crossProduct(r);return s.normalize(),s}turnBack(){let e=this.v3;this.v3=this.v1,this.v1=e}getLines(){let e=this.v1,t=this.v2,a=this.v3;return[new vt(e,t),new vt(t,a),new vt(a,e)]}equals(e){let t=this.getLines(),a=e.getLines(),r=0;for(let i=0;i<t.length;i++)for(let s=0;s<a.length;s++)t[i].equals(a[s])&&r++;return r==3}getCenter(){let e=this.min,t=this.max,a=new g;return a.x=(e.x+t.x)*.5,a.y=(e.y+t.y)*.5,a.z=(e.z+t.z)*.5,a}intersects(e){var t=this.max,a=this.min,r=e.max,i=e.min;return a.x<=r.x&&t.x>=i.x&&a.y<=r.y&&t.y>=i.y&&a.z<=r.z&&t.z>=i.z}sign2D(e,t,a){return(e.x-a.x)*(t.z-a.z)-(t.x-a.x)*(e.z-a.z)}pointInTriangle2D(e){let t=this.v1,a=this.v2,r=this.v3,i,s,o,l,c;return i=this.sign2D(e,t,a),s=this.sign2D(e,a,r),o=this.sign2D(e,r,t),l=i<0||s<0||o<0,c=i>0||s>0||o>0,!(l&&c)}toArray(){return[this.v1.x,this.v1.y,this.v1.z,this.v2.x,this.v2.y,this.v2.z,this.v3.x,this.v3.y,this.v3.z]}}class Zd{static _pt0;static _pt1;static _pt2;static _pt3;static _hitPoint;static _worldMatrix;static _ray;static _triangle;static _isInit;static init(){this._pt0=new g,this._pt1=new g,this._pt2=new g,this._pt3=new g,this._ray=new na,this._triangle=new Zi,this._hitPoint=new g,this._worldMatrix=new T}static rayPick(e,t,a,r,i,s,o){this._isInit||(this.init(),this._isInit=!0);let l=this._worldMatrix;if(r==fa.World){let c;this.calculateHotArea_World(s,this._pt0,this._pt1,this._pt2,this._pt3),l.copyFrom(o).invert();let f=this._ray;if(f.copy(e).applyMatrix(l),this._triangle.set(this._pt0,this._pt1,this._pt2),c=f.intersectTriangle(f.origin,f.direction,this._triangle),c||(this._triangle.set(this._pt1,this._pt2,this._pt3),c=f.intersectTriangle(f.origin,f.direction,this._triangle)),c)return{distance:0,intersectPoint:c}}else{this.calculateHotArea_View(s,i,this._pt0,this._pt1,this._pt2,this._pt3);let c=a.x,f=a.y,h=Math.min(this._pt0.x,this._pt1.x,this._pt2.x,this._pt3.x)+c*.5,u=Math.min(this._pt0.y,this._pt1.y,this._pt2.y,this._pt3.y)+f*.5,b=Math.max(this._pt0.x,this._pt1.x,this._pt2.x,this._pt3.x)+c*.5,A=Math.max(this._pt0.y,this._pt1.y,this._pt2.y,this._pt3.y)+f*.5;return t.x<=b&&t.x>=h&&t.y<=A&&t.y>=u?(this._hitPoint.set(t.x,t.y,0),{distance:0,intersectPoint:this._hitPoint}):null}return null}static calculateHotArea_View(e,t,a,r,i,s){let o=e.getWorldMatrix(),l=o.getScaleX(),c=o.getScaleY(),f=e.width*.5*l,h=e.height*.5*c;a.set(-f,-h,0),r.set(f,-h,0),i.set(-f,h,0),s.set(f,h,0);let u=o.tx;a.x+=u,r.x+=u,i.x+=u,s.x+=u,u=o.ty,a.y-=u,r.y-=u,i.y-=u,s.y-=u,a.multiplyScalar(t),r.multiplyScalar(t),i.multiplyScalar(t),s.multiplyScalar(t)}static calculateHotArea_World(e,t,a,r,i){let s=e.getWorldMatrix(),o=s.getScaleX(),l=s.getScaleY(),c=e.width*.5*o,f=e.height*.5*l;t.set(-c,f,0),a.set(c,f,0),r.set(-c,-f,0),i.set(c,-f,0);let h=s.tx;t.x+=h,a.x+=h,r.x+=h,i.x+=h,h=s.ty,t.y+=h,a.y+=h,r.y+=h,i.y+=h}}var Yd=(n=>(n[n.UpperLeft=0]="UpperLeft",n[n.UpperCenter=1]="UpperCenter",n[n.UpperRight=2]="UpperRight",n[n.MiddleLeft=3]="MiddleLeft",n[n.MiddleCenter=4]="MiddleCenter",n[n.MiddleRight=5]="MiddleRight",n[n.LowerLeft=6]="LowerLeft",n[n.LowerCenter=7]="LowerCenter",n[n.LowerRight=8]="LowerRight",n))(Yd||{}),Xd=(n=>(n[n.Upper=0]="Upper",n[n.Middle=1]="Middle",n[n.Lower=2]="Lower",n))(Xd||{}),Hd=(n=>(n[n.Left=0]="Left",n[n.Center=1]="Center",n[n.Right=2]="Right",n))(Hd||{});class Kd{charList=[];quadList=[];width=0;index=0}class qd{layout(e){let t=[],a=e.originSize,r=ri.getFontData(e.font,a),i=e.fontSize/a;return this.makeTextLine(e.uiTransform,e.alignment,t,e.font,r,e.text,i,a,e.lineSpacing),t}makeTextLine(e,t,a,r,i,s,o,l,c){let f=-1,h=0,u=l*o,b=u*.5,A=e.width/o,m=e.height/o,p=0,D=e.height,_=()=>{h=0,f++;let S=new Kd;return S.index=f,a.push(S),S},v=(S,F)=>{const k=S.charCodeAt(0).toString();let x=ri.getFnt(r,l,k),w=null;return x?(w=Na.spawnQuad(),w.sprite=x,w.x=(h+x.xoffset)*o-p,w.y=(i.base-x.height-x.yoffset-i.base)*o+D,w.width=x.offsetSize.width*o,w.height=x.offsetSize.height*o,h+=x.xadvance):S==`
11788
11788
  `||(S==" "?h+=u:h+=b),F.width=h,F.quadList.push(w),F.charList.push(S),w},U=()=>{let S=this.getAlignment(t);switch(S.v){case 0:for(let F=0,k=a.length;F<k;F++){let x=a[F];if(F>0){let w=F*u*c;for(let R=0,Q=x.quadList.length;R<Q;R++){let M=x.quadList[R];M&&(M.y-=w)}}}break;case 1:for(let F=0,k=a.length;F<k;F++){let x=a[F],w=(m-k*l*c)*.5*o+F*u*c;for(let R=0,Q=x.quadList.length;R<Q;R++){let M=x.quadList[R];M&&(M.y-=w)}}break;case 2:for(let F=0,k=a.length;F<k;F++){let x=a[F],w=(m-k*l*c)*o+F*u*c;for(let R=0,Q=x.quadList.length;R<Q;R++){let M=x.quadList[R];M&&(M.y-=w)}}break}switch(S.h){case 0:break;case 1:for(let F=0,k=a.length;F<k;F++){let x=a[F],w=(A-x.width)*.5*o;for(let R=0,Q=x.quadList.length;R<Q;R++){let M=x.quadList[R];M&&(M.x+=w)}}break;case 2:for(let F=0,k=a.length;F<k;F++){let x=a[F],w=(A-x.width)*o;for(let R=0,Q=x.quadList.length;R<Q;R++){let M=x.quadList[R];M&&(M.x+=w)}}break}};(()=>{let S=null,F=s.length;for(let k=0;k<F;k++){S||=_();let x=s.charAt(k);x==`
11789
- `||x==" "?S=null:(v(x,S),S.width+b>=A&&(S=_()))}})(),U()}getAlignment(e){let t={v:0,h:0};switch(e){case 1:t.v=0,t.h=1;break;case 0:t.v=0,t.h=0;break;case 2:t.v=0,t.h=2;break;case 4:t.v=1,t.h=1;break;case 3:t.v=1,t.h=0;break;case 5:t.v=1,t.h=2;break;case 7:t.v=2,t.h=1;break;case 6:t.v=2,t.h=0;break;case 8:t.v=2,t.h=2;break}return t}}class Qs extends Uo{_style=at.NORMAL;_interactive=!1;set interactive(e){this._interactive=e}get interactive(){return this._interactive}set mouseStyle(e){this._style=e}get interactiveVisible(){return this._uiTransform.globalVisible&&this._visible}init(e){super.init(e),this._uiTransform.addUIInteractive(this)}destroy(){this._uiTransform.removeUIInteractive(this),super.destroy()}rayPick(e,t,a,r){return Zd.rayPick(e,a,r,t.space,t.panelRatio,this._uiTransform,t.transform.worldMatrix)}cloneTo(e){e.getOrAddComponent(Qs).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.enable=e._enable,this.interactive=e._interactive,this.mouseStyle=e._style,this}}var $d=(n=>(n[n.NONE=0]="NONE",n[n.COLOR=1]="COLOR",n[n.SPRITE=2]="SPRITE",n))($d||{});class yo extends Qs{_spriteMap;_colorMap;_image;_isCreateImage;_transition=2;init(e){super.init(e),this._interactive=!0,this._spriteMap=new Map,this._colorMap=new Map,this._image=this.object3D.getComponent(Nr),this._isCreateImage=this._image==null,this._image||(this._image=this.object3D.addComponent(Nr)),this.imageType=si.Sliced}onEnable(){this.mouseStyle=at.NORMAL}onDisable(){this.mouseStyle=at.DISABLE}set transition(e){this._transition!=e&&(this._transition=e,this.validateStyle(this._style,!0))}get transition(){return this._transition}get imageType(){return this._image.imageType}set imageType(e){this._image.imageType=e}setStyleColor(e,t){return this._colorMap.set(e,t),this._style==e&&this.validateStyle(this._style,!0),this}getStyleColor(e){return this._colorMap.get(e)}set mouseStyle(e){super.mouseStyle=e,this.validateStyle(e,!0)}get normalSprite(){return this._spriteMap.get(at.NORMAL)}set normalSprite(e){this._spriteMap.set(at.NORMAL,e),this._style==at.NORMAL&&this.validateStyle(this._style,!0)}get overSprite(){return this._spriteMap.get(at.OVER)}set overSprite(e){this._spriteMap.set(at.OVER,e),this._style==at.OVER&&this.validateStyle(this._style,!0)}set downSprite(e){this._spriteMap.set(at.DOWN,e),this._style==at.DOWN&&this.validateStyle(this._style,!0)}get downSprite(){return this._spriteMap.get(at.DOWN)}set disableSprite(e){this._spriteMap.set(at.DISABLE,e),this._style==at.DISABLE&&this.validateStyle(this._style,!0)}get disableSprite(){return this._spriteMap.get(at.DISABLE)}validateStyle(e,t){if(this._transition&2){let a=this._spriteMap.get(e);this._image.sprite=a}if(this._transition&1){let a=this._colorMap.get(e);a&&(this._image.color=a)}}cloneTo(e){e.getOrAddComponent(yo).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.imageType=e.imageType,this.transition=e.transition,e._spriteMap.forEach((t,a)=>{t&&this._spriteMap.set(a,t)}),e._colorMap.forEach((t,a)=>{t&&this._colorMap.set(a,t.clone())}),this.mouseStyle=e.mouseStyle,this}destroy(){this._isCreateImage&&this._image&&(this.object3D.removeComponent(Nr),this._image=null),super.destroy()}}class Co extends Ji{_count=0;constructor(){super()}init(e){super.init?.(e),this._count=e?e.count:1;for(let t=0;t<this._count;t++)this.attachQuad(Na.spawnQuad());this._uiTransform.resize(0,0)}getQuad(e){return this._mainQuads[e]}cloneTo(e){e.addComponent(Co,{count:this._count}).copyComponent(this)}copyComponent(e){super.copyComponent(e);for(let t=0;t<e._count;t++)this.setSprite(t,e.getSprite(t)),this.setColor(t,e.getColor(t)),this.setImageType(t,e.getImageType(t));return this}setSprite(e,t){this._mainQuads[e].sprite=t||B.res.defaultGUISprite,this.setShadowDirty()}getSprite(e){return this._mainQuads[e].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}getColor(e){return this._mainQuads[e].color}setColor(e,t){this._mainQuads[e].color=t,this.setShadowDirty()}getImageType(e){return this._mainQuads[e].imageType}setImageType(e,t){this._mainQuads[e].imageType=t,this.setShadowDirty()}setSize(e,t,a){this._mainQuads[e].setSize(t,a),this.setShadowDirty()}setXY(e,t,a){this._mainQuads[e].setXY(t,a),this.setShadowDirty()}getXY(e,t){t||=new fe;let a=this._mainQuads[e];return t.x=a.x,t.y=a.y,t}}class So extends Ji{_shadowQuality=1;_shadowOffset;_shadowRadius;_shadowColor;_subShadowColor;needUpdateShadow=!1;init(e){super.init?.(e),this._shadowRadius=2,this._shadowQuality=1,this._shadowOffset=new fe(4,-4),this._shadowColor=new Z(.1,.1,.1,.8),this._subShadowColor=this._shadowColor.clone(),this.isUIShadow=!0}cloneTo(e){e.getOrAddComponent(So).copyComponent(this)}copyComponent(e){return super.copyComponent(this),this._shadowColor=e._shadowColor,this._shadowOffset=e._shadowOffset,this._shadowRadius=e._shadowRadius,this._shadowQuality=e.shadowQuality,this}get shadowColor(){return this._shadowColor}set shadowColor(e){this._shadowColor.copyFrom(e),this.needUpdateShadow=!0}set shadowQuality(e){e=_e(e,0,4),this._shadowQuality!=e&&(this._shadowQuality=e,this.needUpdateShadow=!0)}get shadowQuality(){return this._shadowQuality}set shadowOffset(e){this._shadowOffset=e,this.needUpdateShadow=!0}get shadowOffset(){return this._shadowOffset||=new fe(4,-4),this._shadowOffset}set shadowRadius(e){this._shadowRadius!=e&&(this._shadowRadius=e,this.applyShadow())}get shadowRadius(){return this._shadowRadius}onUpdate(e){this.needUpdateShadow&&(this.applyShadow(),this.needUpdateShadow=!1)}applyShadow(){if(this.detachQuads(),this._shadowSource&&this._shadowQuality>0){let e=this._shadowSource.mainQuads;if(e.length>0)for(let t of e)this.createQuadShadow(t)}this._uiTransform.setNeedUpdateUIPanel()}createQuadShadow(e){let t=this._shadowQuality,a=Math.PI*2;this._subShadowColor.copyFrom(this._shadowColor),this._subShadowColor.a=1/Math.max(1,t);for(let r=0;r<t;r++){let i=Na.spawnQuad(),s=0,o=0;if(r==0)i.color=this._shadowColor;else{let l=a*(r-1)/(t-1);s=Math.sin(l)*this._shadowRadius,o=Math.cos(l)*this._shadowRadius,i.color=this._subShadowColor}i.setXY(s+this._shadowOffset.x+e.x,o+this._shadowOffset.y+e.y),i.setSize(e.width,e.height),i.sprite=e.sprite,i.visible=e.visible,i.imageType=e.imageType,this.attachQuad(i)}}}class xo extends Ji{_font="\u5FAE\u8F6F\u96C5\u9ED1";_fontSize=14;_originSize=42;_alignment=0;_lineSpacing=1;_text="";_color=new Z(1,1,1,1);constructor(){super()}cloneTo(e){e.getOrAddComponent(xo).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this._font=e._font,this._fontSize=e._fontSize,this._originSize=e._originSize,this._alignment=e._alignment,this._lineSpacing=e._lineSpacing,this._color.copyFrom(e._color),this.text=e.text,this}get originSize(){return this._originSize}get font(){return this._font}set font(e){this._font=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!=e&&(this._fontSize=e,this.layoutText())}get text(){return this._text}set text(e){this._text!=e&&(e||(e=""),this._text=e,this.layoutText())}textLine=null;layoutProxy=new qd;layoutText(){this.detachQuads(),this.textLine=this.layoutProxy.layout(this);for(let e=0,t=this.textLine.length;e<t;e++){let a=this.textLine[e];for(let r=0,i=a.quadList.length;r<i;r++){let s=a.quadList[r];s&&this.attachQuad(s)}}this.color=this._color,this._uiTransform.setNeedUpdateUIPanel(),this.onUIComponentVisible(this._visible),this.setShadowDirty()}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t&&(t.visible=!e);this.setShadowDirty()}onTransformResize(){this.layoutText()}get color(){return this._color}set color(e){this._color.copyFrom(e);for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get alignment(){return this._alignment}set alignment(e){this._alignment!=e&&(this._alignment=e,this.layoutText())}get lineSpacing(){return this._lineSpacing}set lineSpacing(e){this._lineSpacing!=e&&(this._lineSpacing=e,this.layoutText())}}var fg=Object.getOwnPropertyDescriptor,dg=(n,e,t,a)=>{for(var r=a>1?void 0:a?fg(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.Light=class extends Ei{constructor(){super()}init(){super.init(),this.lightData.lightType=ft.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+Gt())}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(e){this.lightData.quadratic=e,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(e){let t=e.scene.getChildByName("graphic3D");if(!t)return;let a=t.createCustomShape(`PointLight_${this.object3D.instanceID}`,this.transform);a.buildAxis(),a.buildCircle(g.ZERO,this.range,32,g.X_AXIS),a.buildCircle(g.ZERO,this.range,32,g.Y_AXIS),a.buildCircle(g.ZERO,this.range,32,g.Z_AXIS)}debug(){}debugDraw(e){}},d.Light=dg([Nt(d.Light,"Light")],d.Light);var hg=Object.getOwnPropertyDescriptor,ug=(n,e,t,a)=>{for(var r=a>1?void 0:a?hg(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.FatLineRenderer=class extends Ba{_fatLineMaterial=null;_fatLineGeometry=null;_cachedResolution=new fe(0,0);constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(e){e.addComponent(d.FatLineRenderer).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this}set geometry(e){super.geometry=e,this._fatLineGeometry=e,e&&(this.instanceCount=e.instanceCount,this._fatLineMaterial&&e.instanceBuffer&&this._fatLineMaterial.setInstanceBuffer(e.instanceBuffer))}get geometry(){return this._fatLineGeometry}set material(e){this.materials=[e],this._fatLineMaterial=e,this._fatLineGeometry&&this._fatLineGeometry.instanceBuffer&&e.setInstanceBuffer(this._fatLineGeometry.instanceBuffer)}get material(){return this._fatLineMaterial}nodeUpdate(e,t,a,r){if(this._fatLineMaterial&&this.object3D){this._fatLineMaterial.setModelMatrix(this.object3D.transform.worldMatrix);const i=I.presentationSize[0],s=I.presentationSize[1];i>0&&s>0&&(this._cachedResolution.x!==i||this._cachedResolution.y!==s)&&(this._cachedResolution.set(i,s),this._fatLineMaterial.resolution=this._cachedResolution.clone())}super.nodeUpdate(e,t,a,r)}destroy(e){super.destroy(e)}},d.FatLineRenderer=ug([Nt(d.FatLineRenderer,"FatLineRenderer")],d.FatLineRenderer);var bg=Object.getOwnPropertyDescriptor,gg=(n,e,t,a)=>{for(var r=a>1?void 0:a?bg(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.GSplatStreamRenderer=class extends Ba{totalCount=0;size=new fe;localBoundBox=new Ce;get worldBoundBox(){const e=new Ce;e.makeEmpty();const a=this.object3D.transform.worldMatrix.rawData,r=this.localBoundBox.min,i=this.localBoundBox.max,s=[[r.x,r.y,r.z],[i.x,r.y,r.z],[r.x,i.y,r.z],[i.x,i.y,r.z],[r.x,r.y,i.z],[i.x,r.y,i.z],[r.x,i.y,i.z],[i.x,i.y,i.z]];for(const[o,l,c]of s){const f=a[0]*o+a[4]*l+a[8]*c+a[12],h=a[1]*o+a[5]*l+a[9]*c+a[13],u=a[2]*o+a[6]*l+a[10]*c+a[14];e.expandByPoint(new g(f,h,u))}return e}splatColor;transformA;transformB;texParams;_texParamDirty=!0;splatOrder;gsplatMaterial;_colorData;_transformAData;_transformBData;_orderData;_positions;_splatSetFlags;_validCount=0;_sortWorker;_lastSentTime=0;_minIntervalMs=16;_centersSent=!1;_lastViewMatrixHash=0;_lastCameraSpeed=0;_adaptiveSorting=!0;_lastPixelCullParams="";_texturesInitialized=!1;_minPixelCoverage=4;_maxPixelCoverage=0;_maxPixelCullDistance=0;_batchSize=128;instanceCount=0;_pendingUpdates=new Set;_autoFlushThreshold=100;_frameCount=0;constructor(){super()}initCount(e,t=128){if(e<=0)throw new Error("Total count must be greater than 0");this.totalCount=e,this._batchSize=t,this.size=this.evalTextureSize(e);const a=this.size.x|0,r=this.size.y|0,i=a*r;this._colorData=new Uint8Array(i*4),this._colorData.fill(0),this._transformAData=new Uint32Array(i*4),this._transformAData.fill(0),this._transformBData=new Array(i*4).fill(0),this._orderData=new Uint32Array(i);for(let s=0;s<i;s++)this._orderData[s]=s<e?s:e>0?e-1:0;this._positions=new Float32Array(e*3),this._positions.fill(0),this.localBoundBox.makeEmpty(),this._splatSetFlags=new Array(e).fill(!1),this._validCount=0,this.texParams=new Float32Array([this._validCount,this.size.x,0,1]),this.splatColor=new Si().create(a,r,this._colorData,!1),this.splatColor.name="splatColor",this.splatColor.minFilter="nearest",this.splatColor.magFilter="nearest",this.splatColor.mipmapFilter="nearest",this.splatColor.addressModeU="clamp-to-edge",this.splatColor.addressModeV="clamp-to-edge",this.transformA=new xn().create(a,r,this._transformAData),this.transformA.name="transformA",this.transformA.minFilter="nearest",this.transformA.magFilter="nearest",this.transformA.addressModeU="clamp-to-edge",this.transformA.addressModeV="clamp-to-edge",this.transformB=new _s().create(a,r,this._transformBData,!1),this.transformB.name="transformB",this.transformB.minFilter="nearest",this.transformB.magFilter="nearest",this.transformB.mipmapFilter="nearest",this.transformB.addressModeU="clamp-to-edge",this.transformB.addressModeV="clamp-to-edge",this.splatOrder=new Ds().create(a,r,this._orderData),this.splatOrder.name="splatOrder",this.splatOrder.minFilter="nearest",this.splatOrder.magFilter="nearest",this.splatOrder.addressModeU="clamp-to-edge",this.splatOrder.addressModeV="clamp-to-edge",this.gsplatMaterial=new Cn,this.geometry=new Sn(this._batchSize),this.materials=[this.gsplatMaterial],this.instanceCount=0}setSplatData(e,t){if(e<0||e>=this.totalCount)throw new Error(`Index ${e} out of range [0, ${this.totalCount})`);const a=this._splatSetFlags[e];this._positions[e*3+0]=t.position[0],this._positions[e*3+1]=t.position[1],this._positions[e*3+2]=t.position[2],this.localBoundBox.expandByPoint(new g(t.position[0],t.position[1],t.position[2]));const r=.28209479177387814;let i=.5,s=.5,o=.5;t.sh&&t.sh.coeffs&&t.sh.coeffs.length>=3&&(i=.5+t.sh.coeffs[0]*r,s=.5+t.sh.coeffs[1]*r,o=.5+t.sh.coeffs[2]*r);const l=t.opacity!==void 0?1/(1+Math.exp(-t.opacity)):1,c=e*4;this._colorData[c+0]=Math.max(0,Math.min(255,Math.floor(i*255))),this._colorData[c+1]=Math.max(0,Math.min(255,Math.floor(s*255))),this._colorData[c+2]=Math.max(0,Math.min(255,Math.floor(o*255))),this._colorData[c+3]=Math.max(0,Math.min(255,Math.floor(l*255))),this.updateTransformData(e,t),a||(this._splatSetFlags[e]=!0,this._validCount++),this._pendingUpdates.add(e)}updateTransformData(e,t){const a=e*4,r=new ArrayBuffer(4),i=new Float32Array(r),s=new Uint32Array(r),o=je=>(i[0]=je,s[0]),l=t.position[0],c=t.position[1],f=t.position[2];this._transformAData[a+0]=o(l),this._transformAData[a+1]=o(c),this._transformAData[a+2]=o(f);let h=0,u=0,b=0,A=1;if(t.rotation){h=t.rotation[0],u=t.rotation[1],b=t.rotation[2],A=t.rotation[3];const je=1/Math.hypot(h,u,b,A);h*=je,u*=je,b*=je,A*=je}let m=1,p=1,D=1;t.scale&&(m=Math.exp(t.scale[0]),p=Math.exp(t.scale[1]),D=Math.exp(t.scale[2]));const _=h+h,v=u+u,U=b+b,y=h*_,S=h*v,F=h*U,k=u*v,x=u*U,w=b*U,R=A*_,Q=A*v,M=A*U,j=1-(k+w),he=S+M,ae=F-Q,P=S-M,z=1-(y+w),W=x+R,V=F+Q,te=x-R,J=1-(y+k),K=j*m,ee=he*m,re=ae*m,oe=P*p,pe=z*p,Te=W*p,Oe=V*D,q=te*D,ie=J*D,ce=K*K+oe*oe+Oe*Oe,ge=K*ee+oe*pe+Oe*q,we=K*re+oe*Te+Oe*ie,me=ee*ee+pe*pe+q*q,ye=ee*re+pe*Te+q*ie,Qe=re*re+Te*Te+ie*ie,Re=a;this._transformBData[Re+0]=ce,this._transformBData[Re+1]=ge,this._transformBData[Re+2]=we,this._transformBData[Re+3]=Qe;const Le=qa(me)&65535,Ut=qa(ye)&65535;this._transformAData[a+3]=Le|Ut<<16}flushUpdates(){if(this._pendingUpdates.size===0)return;const e=this.size.x|0,t=this.size.y|0,a=Array.from(this._pendingUpdates);if(a.length===0)return;let r=t,i=0;for(const l of a){const c=Math.floor(l/e);c<r&&(r=c),c>i&&(i=c)}const s=i-r+1;s/t<.5&&s<t?(this.splatColor.updateTexture(e,t,this._colorData,r,s),this.transformA.updateTexture(e,t,this._transformAData,r,s),this.transformB.updateTexture(e,t,this._transformBData,!1,r,s)):(this.splatColor.updateTexture(e,t,this._colorData),this.transformA.updateTexture(e,t,this._transformAData),this.transformB.updateTexture(e,t,this._transformBData,!1)),this.updatePendingWorldPositions(),this._pendingUpdates.clear()}setAutoFlushThreshold(e){this._autoFlushThreshold=Math.max(1,e)}getStreamingStats(){return{totalCount:this.totalCount,validCount:this._validCount,pendingUpdates:this._pendingUpdates.size,progress:this.totalCount>0?this._validCount/this.totalCount*100:0}}updateWorldPositions(){!this._positions||this._validCount===0||(this._centersSent=!1)}updatePendingWorldPositions(){!this._positions||this._validCount===0||(this._centersSent=!1)}scheduleOrder(e){if(this._validCount===0)return;const t=this.object3D.transform.localChange;t&&this.updateWorldPositions();const a=e.rawData,r=a[2],i=a[6],s=a[10],o=-(a[0]*a[12]+a[1]*a[13]+a[2]*a[14]),l=-(a[4]*a[12]+a[5]*a[13]+a[6]*a[14]),c=-(a[8]*a[12]+a[9]*a[13]+a[10]*a[14]),f=performance.now(),h=(f-this._lastSentTime)/1e3,u=Math.floor(o*1e3)^Math.floor(l*1e3)^Math.floor(c*1e3),b=Math.floor(r*1e3)^Math.floor(i*1e3)^Math.floor(s*1e3),A=u^b;if(A===this._lastViewMatrixHash&&!t&&this._centersSent)return;let m=this._minIntervalMs;if(this._adaptiveSorting&&this._minIntervalMs>0){const D=Math.abs(A-this._lastViewMatrixHash)/Math.max(h,.001);D<1e3?m=this._minIntervalMs:D<1e4?m=this._minIntervalMs*.5:m=this._minIntervalMs*.2,this._lastCameraSpeed=D}if(!(f-this._lastSentTime<m)){if(this._lastViewMatrixHash=A,this._lastSentTime=f,!this._sortWorker){this._sortWorker=this.createSortWorker(),this._sortWorker.onmessage=S=>{const F=S.data.order,k=this._orderData.buffer;this._sortWorker.postMessage({order:k},[k]);const x=new Uint32Array(F),w=this.size.x*this.size.y,R=Math.min(this._validCount,x.length);if((!this._orderData||this._orderData.length!==w)&&(this._orderData=new Uint32Array(w)),this._orderData.set(x.subarray(0,R),0),R<w){const j=this._validCount>0?this._validCount-1:0;this._orderData.fill(j,R,w)}this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData);const Q=Math.max(0,Math.min(this._validCount,S.data.count|0));this.setCount(Q),this._updateTexParams();const M=Math.ceil(Q/this._batchSize);this.instanceCount=M};const p=new Float32Array(this._validCount*3);let D=0;const _=this.object3D.transform.worldMatrix,v=this._positions,U=_.rawData;for(let S=0;S<this._validCount;S++)if(this._splatSetFlags[S]){const F=S*3,k=v[F+0],x=v[F+1],w=v[F+2];p[D*3+0]=U[0]*k+U[4]*x+U[8]*w+U[12],p[D*3+1]=U[1]*k+U[5]*x+U[9]*w+U[13],p[D*3+2]=U[2]*k+U[6]*x+U[10]*w+U[14],D++}const y=new Uint32Array(this.totalCount);for(let S=0;S<this.totalCount;S++)y[S]=S<this._validCount?S:this._validCount>0?this._validCount-1:0;this._sortWorker.postMessage({order:y.buffer,centers:p.buffer},[y.buffer,p.buffer]),this._centersSent=!0}if(!this._centersSent&&this._sortWorker){const p=new Float32Array(this._validCount*3);let D=0;const _=this.object3D.transform.worldMatrix,v=this._positions,U=_.rawData;for(let y=0;y<this._validCount;y++)if(this._splatSetFlags[y]){const S=y*3,F=v[S+0],k=v[S+1],x=v[S+2];p[D*3+0]=U[0]*F+U[4]*k+U[8]*x+U[12],p[D*3+1]=U[1]*F+U[5]*k+U[9]*x+U[13],p[D*3+2]=U[2]*F+U[6]*k+U[10]*x+U[14],D++}this._sortWorker.postMessage({type:"centers",centers:p.buffer},[p.buffer]),this._centersSent=!0}this._sortWorker.postMessage({cameraPosition:{x:o,y:l,z:c},cameraDirection:{x:-r,y:-i,z:-s}})}}createSortWorker(){function e(){let o,l,c,f,h=!1;const u={x:0,y:0,z:0},b={x:0,y:0,z:0},A={x:0,y:0,z:0},m={x:0,y:0,z:0};let p,D;const _=(U,y,S)=>{for(;U<=y;){const F=y+U>>1,k=S(F);if(k>0)U=F+1;else if(k<0)y=F-1;else return F}return~U},v=()=>{if(!o||!l||!c||!f)return;const U=c.x,y=c.y,S=c.z,F=f.x,k=f.y,x=f.z,w=.001;if(!h&&Math.abs(U-u.x)<w&&Math.abs(y-u.y)<w&&Math.abs(S-u.z)<w&&Math.abs(F-b.x)<w&&Math.abs(k-b.y)<w&&Math.abs(x-b.z)<w)return;h=!1,u.x=U,u.y=y,u.z=S,b.x=F,b.y=k,b.z=x;const R=l.length/3;p?.length!==R&&(p=new Uint32Array(R));let Q,M;for(let W=0;W<8;++W){const V=(W&1?A.x:m.x)-U,te=(W&2?A.y:m.y)-y,J=(W&4?A.z:m.z)-S,K=V*F+te*k+J*x;W===0?Q=M=K:(Q=Math.min(Q,K),M=Math.max(M,K))}D?D.fill(0):D=new Uint32Array(65537);const j=M-Q,he=j<1e-6?0:1/j*2**16;for(let W=0;W<R;++W){const V=W*3,te=l[V+0]-U,J=l[V+1]-y,K=l[V+2]-S,ee=te*F+J*k+K*x,re=Math.floor((ee-Q)*he);p[W]=re,D[re]++}for(let W=1;W<65537;W++)D[W]+=D[W-1];for(let W=0;W<R;W++){const V=p[W],te=--D[V];o[te]=W}const ae=W=>p[o[W]]/he+Q,P=()=>{const W=_(0,R-1,V=>-ae(V));return Math.min(R,Math.abs(W))},z=ae(R-1)>=0?P():R;self.postMessage({order:o.buffer,count:z},[o.buffer]),o=null};self.onmessage=U=>{if(U.data.order&&(o=new Uint32Array(U.data.order)),U.data.centers){l=new Float32Array(U.data.centers),A.x=m.x=l[0],A.y=m.y=l[1],A.z=m.z=l[2];const y=l.length/3;for(let S=1;S<y;++S){const F=l[S*3+0],k=l[S*3+1],x=l[S*3+2];A.x=Math.min(A.x,F),A.y=Math.min(A.y,k),A.z=Math.min(A.z,x),m.x=Math.max(m.x,F),m.y=Math.max(m.y,k),m.z=Math.max(m.z,x)}h=!0}U.data.cameraPosition&&(c=U.data.cameraPosition),U.data.cameraDirection&&(f=U.data.cameraDirection),v()}}const t=`(${e.toString()})()`,a=new Blob([t],{type:"application/javascript"}),r=URL.createObjectURL(a);return new Worker(r)}setVisBoost(e){this.texParams[3]=Math.max(0,e),this._texParamDirty=!0}setCount(e){this.texParams[0]=Math.max(0,e),this._texParamDirty=!0}_updateTexParams(){this._texParamDirty&&(this.gsplatMaterial.setTexParams(this.texParams),this._texParamDirty=!1)}setSortThrottle(e){this._minIntervalMs=Math.max(0,e|0)}setAdaptiveSorting(e){this._adaptiveSorting=e}setPixelCulling(e,t=0,a=0){this._minPixelCoverage=Math.max(0,e),this._maxPixelCoverage=Math.max(0,t),this._maxPixelCullDistance=Math.max(0,a)}getPixelCullingStats(){return{minPixels:this._minPixelCoverage,maxPixels:this._maxPixelCoverage,maxPixelCullDistance:this._maxPixelCullDistance,maxEnabled:this._maxPixelCoverage>0,distanceEnabled:this._maxPixelCullDistance>0}}getBatchingStats(){return{enabled:!0,batchSize:this._batchSize,instanceCount:this.instanceCount,splatCount:this._validCount,reduction:this._validCount>0?(1-this.instanceCount/this._validCount)*100:0}}evalTextureSize(e){let t=Math.ceil(Math.sqrt(e));const a=64;t=Math.ceil(t/a)*a;const r=Math.ceil(e/t);return new fe(t,r)}nodeUpdate(e,t,a,r){this._validCount>0&&e?.camera&&this._frameCount>=60&&e.camera.viewMatrix&&this.scheduleOrder(e.camera.viewMatrix),this._pendingUpdates.size>0&&this._frameCount>=60&&this.flushUpdates(),this._frameCount>=60&&this._pendingUpdates.size===0&&(this._frameCount=0),this._frameCount++,this._updateTexParams();const i=this.object3D.transform.worldMatrix;this.gsplatMaterial.setTransformMatrix(i);const s=`${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;s!==this._lastPixelCullParams&&(this.gsplatMaterial.setPixelCulling(this._minPixelCoverage,this._maxPixelCoverage,this._maxPixelCullDistance,this._batchSize),this._lastPixelCullParams=s),this._texturesInitialized||(this.gsplatMaterial.setSplatTextures(this.splatColor,this.transformA,this.transformB,this.texParams,this.splatOrder),this._texturesInitialized=!0),super.nodeUpdate(e,t,a,r)}renderPass(e,t,a){const r=a.encoder;for(let i of this.materials){const s=i.getPass(t);if(!(!s||s.length===0))for(const o of s){if(!o.pipeline)continue;o.apply(this.geometry,a.rendererPassState||a),E.bindPipeline(r,o),E.bindGeometryBuffer(r,this.geometry);const c=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?E.drawIndexed(r,c.indexCount,this.instanceCount,c.indexStart,0,0):E.drawIndexed(r,c.indexCount,1,c.indexStart,0,0)}}}destroy(e){this._sortWorker&&(this._sortWorker.terminate(),this._sortWorker=null),this.splatColor&&(this.splatColor.destroy(e),this.splatColor=null),this.transformA&&(this.transformA.destroy(e),this.transformA=null),this.transformB&&(this.transformB.destroy(e),this.transformB=null),this.splatOrder&&(this.splatOrder.destroy(e),this.splatOrder=null),this._positions=null,this._orderData=null,this._colorData=null,this._transformAData=null,this._transformBData=null,this.texParams=null,this._splatSetFlags=null,this._pendingUpdates.clear(),super.destroy(e)}},d.GSplatStreamRenderer=gg([Nt(d.GSplatStreamRenderer,"GSplatStreamRenderer")],d.GSplatStreamRenderer);class eh extends d.Object3D{index=0;drawCallFrame=-1;constructor(){super()}}var Fo=(n=>(n[n.CastGI=0]="CastGI",n[n.ReceiveGI=1]="ReceiveGI",n[n.CastDepth=2]="CastDepth",n[n.Other=3]="Other",n))(Fo||{});class th extends Dt{static count=0;constructor(e=0,t=0){super(),X.register("GIProbeShader",Dd);let a=new gt,r=new qe("GIProbeShader","GIProbeShader");r.passType=de.COLOR,a.addRenderPass(r),r.setDefine("USE_BRDF",!0),r.setShaderEntry("VertMain","FragMain"),r.setUniformVector4("probeUniform",new ue(t,e,0,0));let i=r.shaderState;i.acceptShadow=!1,i.castShadow=!1,i.receiveEnv=!1,i.acceptGI=!1,i.useLight=!1,a.setTexture("baseMap",B.res.whiteTexture),a.setTexture("normalMap",B.res.normalTexture),a.setTexture("emissiveMap",B.res.blackTexture),this.shader=a}}class mg extends $e{_probes;_volume;_debugMr=[];init(e){e||=B.views[0]?.scene,B.setting.gi.enable=!0,this._volume=ve.getLightEntries(e).irradianceVolume,this.initProbe(e)}initProbe(e){let t=this._volume.setting.probeXCount,a=this._volume.setting.probeYCount,r=this._volume.setting.probeZCount,i=new Ir(4,16,16),s=new g;this._probes=[];for(let o=0;o<t;o++)for(let l=0;l<a;l++)for(let c=0;c<r;c++){let f=o+c*t+l*(t*r),h=new eh;h.index=f,h.name=`${o}_${l}_${c}`;let u=h.addComponent(d.MeshRenderer);u.material=new th(Fo.CastGI,f),u.geometry=i,u.castGI=!1,u.castShadow=!1,this._debugMr.push(u),this.object3D.addChild(h),this._volume.calcPosition(o,l,c,s),h.x=s.x,h.y=s.y,h.z=s.z,this._probes[f]=h,this._debugMr.push(u)}for(let o=0;o<this._probes.length;o++)$.instance.addGIProbe(e,this._probes[o]);this.object3D.transform.enable=!1,this._volume.setting.debug&&this.debug()}debug(){}debugProbeRay(e,t){const a=B.setting.gi.rayNumber;let r=new ne(0,-.7071067811865475,.7071067811865475,0);for(let i=0;i<a;i++){let s=e*a+i,o=new g(-t[s*4+0],-t[s*4+1],-t[s*4+2],0);r.transformVector(o,o);let l=t[s*4+3],c=this._probes[e].transform.worldPosition.clone(),f=o.scaleBy(l);f.add(c,f)}}changeProbesVolumeData(){this._volume.setVolumeDataChange()}changeProbesPosition(){this._volume.setVolumeDataChange();let e=this._volume.setting.probeXCount,t=this._volume.setting.probeYCount,a=this._volume.setting.probeZCount,r=new g;for(let i=0;i<e;i++)for(let s=0;s<t;s++)for(let o=0;o<a;o++){let l=i+o*e+s*(e*a),c=this._probes[l];this._volume.calcPosition(i,s,o,r),c.x=r.x,c.y=r.y,c.z=r.z}}onUpdate(){B.setting.gi.maxDistance=B.setting.gi.probeSpace*1.5;let e=this.transform.scene3D.view.camera,t=g.distance(e.transform.worldPosition,e.transform.targetPos)/300;if(this._debugMr&&this._debugMr.length>0)for(let a=0;a<this._debugMr.length;a++){const r=this._debugMr[a].transform;r.scaleX=t,r.scaleY=t,r.scaleZ=t}}}class pg extends Ba{_keyRenderGroup;_keyBufferGroup;_keyIdsGroup;constructor(){super()}init(e){this._keyRenderGroup=new Map,this._keyBufferGroup=new Map,this._keyIdsGroup=new Map}start(){let e=[];this.object3D.getComponents(d.MeshRenderer,e,!0);for(let t=0;t<e.length;t++){const a=e[t];a.transform.updateWorldMatrix(!0),a.enable=!1;let r=a.geometry.instanceID;for(let i=0;i<a.materials.length;i++){const s=a.materials[i];r+=s.instanceID}if(this._keyRenderGroup.has(r))this._keyRenderGroup.get(r).push(a),this._keyIdsGroup.get(r).push(a.transform.worldMatrix.index);else{let i=new Pe(e.length);i.visibility=GPUShaderStage.VERTEX,this._keyRenderGroup.set(r,[a]),this._keyBufferGroup.set(r,i),this._keyIdsGroup.set(r,[a.transform.worldMatrix.index])}}this._keyBufferGroup.forEach((t,a)=>{let r=this._keyIdsGroup.get(a),i=this._keyBufferGroup.get(a);i.setInt32Array("matrixIDs",new Int32Array(r)),i.apply()})}reset(){this._keyRenderGroup.size>0&&(this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this.start())}nodeUpdate(e,t,a,r){this._keyRenderGroup.forEach((i,s)=>{let o=this._keyBufferGroup.get(s),l=i[0];for(let c=0;c<l.materials.length;c++){let h=l.materials[c].getPass(t);if(h)for(let u=0;u<h.length;u++){const b=h[u];b.setDefine("USE_INSTANCEDRAW",!0),b.setStorageBuffer("instanceDrawID",o)}}l.nodeUpdate(e,t,a,r)})}renderPass(e,t,a){this._keyRenderGroup.forEach((r,i)=>{let s=r[0];s.instanceCount=r.length,this.renderItem(e,t,s,a)})}renderItem(e,t,a,r){let i=a.transform._worldMatrix;for(let s=0;s<a.materials.length;s++){let l=a.materials[s].getPass(t);if(!(!l||l.length==0))for(let c=0;c<l.length;c++){let f=l[c];E.bindGeometryBuffer(r.encoder,a.geometry);const h=f;h.shaderState.splitTexture&&(r.endRenderPass(),wt.WriteSplitColorTexture(a.instanceID),r.beginOpaqueRenderPass(),E.bindCamera(r.encoder,e.camera),E.bindGeometryBuffer(r.encoder,a.geometry)),E.bindPipeline(r.encoder,h);let m=a.geometry.subGeometries[s].lodLevels[a.lodLevel];a.instanceCount>0?E.drawIndexed(r.encoder,m.indexCount,a.instanceCount,m.indexStart,0,0):E.drawIndexed(r.encoder,m.indexCount,1,m.indexStart,0,i.index)}}}beforeDestroy(e){this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this._keyRenderGroup=this._keyBufferGroup=this._keyIdsGroup=void 0,Ne.removeWaitStart(this.object3D,this)}}var Ag=Object.getOwnPropertyDescriptor,Dg=(n,e,t,a)=>{for(var r=a>1?void 0:a?Ag(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.MeshFilter=class extends d.MeshRenderer{constructor(){super()}get geometry(){return null}set geometry(e){}cloneTo(e){}set meshURL(e){let t=B.res.getGeometry(e);t?this.geometry=t:console.error("no geometry set",e)}},d.MeshFilter=Dg([Nt(d.MeshFilter,"MeshFilter")],d.MeshFilter);var _g=Object.getOwnPropertyDescriptor,Bg=(n,e,t,a)=>{for(var r=a>1?void 0:a?_g(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.SkinnedMeshRenderer=class extends d.MeshRenderer{skinJointsName;mInverseBindMatrixData;mInverseBindMatrixBuffer;mSkeletonAnimation;mJointIndexTableBuffer;constructor(){super(),this.addRendererMask(Me.SkinnedMesh)}start(){if(super.start(),this.skeletonAnimation=this.object3D.getComponent(d.SkeletonAnimationComponent),!this.skeletonAnimation){let e=this.object3D.parentObject.parentObject.getComponentsInChild(d.SkeletonAnimationComponent);e.length>0&&(this.skeletonAnimation=e[0]);let t=this.object3D;for(;!this.skeletonAnimation&&t;)this.skeletonAnimation=t.getComponentFromParent(d.SkeletonAnimationComponent),t.parent&&(t=t.parent.object3D)}}onEnable(){super.onEnable()}get skeletonAnimation(){return this.mSkeletonAnimation}set skeletonAnimation(e){if(this.mSkeletonAnimation=e,!!e&&!this.mJointIndexTableBuffer){let t=this.mSkeletonAnimation.getJointIndexTable(this.skinJointsName);this.mJointIndexTableBuffer=new Pe(t.length*4,0,new Float32Array(t)),this.mJointIndexTableBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}}get skinInverseBindMatrices(){return this.mInverseBindMatrixData}set skinInverseBindMatrices(e){this.mInverseBindMatrixData=e;var t=new Float32Array(e.length*16);for(let a=0;a<e.length;a++){let r=a*16,i=e[a];t.set(i,r)}this.mInverseBindMatrixBuffer=new Pe(t.byteLength,0,t),this.mInverseBindMatrixBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}get inverseBindMatrixBuffer(){return this.mInverseBindMatrixBuffer}get jointIndexTableBuffer(){return this.mJointIndexTableBuffer.buffer}cloneTo(e){let t=e.addComponent(d.SkinnedMeshRenderer);t.geometry=this.geometry,t.material=this.material.clone(),t.castShadow=this.castShadow,t.castGI=this.castGI,t.receiveShadow=this.receiveShadow,t.rendererMask=this.rendererMask,t.skinJointsName=this.skinJointsName,t.skinInverseBindMatrices=this.skinInverseBindMatrices,t.mJointIndexTableBuffer=this.mJointIndexTableBuffer}nodeUpdate(e,t,a,r){for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(t);if(o)for(let l=0;l<o.length;l++){const c=o[l];!c.pipeline&&this.mSkeletonAnimation&&(c.setStorageBuffer("jointsMatrixIndexTable",this.mSkeletonAnimation.jointMatrixIndexTableBuffer),c.setStorageBuffer("jointsInverseMatrix",this.mInverseBindMatrixBuffer),c.setStorageBuffer("jointsIndexMapingTable",this.mJointIndexTableBuffer))}}super.nodeUpdate(e,t,a,r)}},d.SkinnedMeshRenderer=Bg([Nt(d.SkinnedMeshRenderer,"SkinnedMeshRenderer")],d.SkinnedMeshRenderer);class vg extends ut{radius=2.5;height=10;constructor(){super(),this._shapeType=ni.Capsule}}class Ms extends ut{mesh;static triangle;_pickRet;constructor(){super(),this._shapeType=ni.Mesh}rayPick(e,t){if(this.mesh){Ms.triangle||=new Zi(new g,new g,new g);let a=this.mesh.getAttribute(G.position),r=this.mesh.getAttribute(G.indices),i=ut.helpMatrix;i.copyFrom(t).invert();let s=ut.helpRay.copy(e);if(s.applyMatrix(i),s.intersectBox(this.mesh.bounds),!s.intersectBox(this.mesh.bounds,ut.v3_help_0))return null;if(r&&a&&r.data.length>0){let l=a.data;for(let c=0,f=r.data.length/3;c<f;c++){let h=c*3;const u=r.data[h+0]*3,b=r.data[h+1]*3,A=r.data[h+2]*3;let m=Ms.triangle,p=m.v1.set(l[u+0],l[u+1],l[u+2]),D=m.v2.set(l[b+0],l[b+1],l[b+2]),_=m.v3.set(l[A+0],l[A+1],l[A+2]);m.set(p,D,_);let v=s.intersectTriangle(s.origin,s.direction,m);if(v){this._pickRet||={intersectPoint:new g,distance:0},this._pickRet.intersectPoint=v,this._pickRet.distance=g.distance(s.origin,v);let U=this.mesh.getAttribute(G.normal);if(U){let y=U.data,S=new g(y[u],y[u+1],y[u+2]);t.transformVector(S,S),S.normalize(),this._pickRet.normal=S}return this._pickRet}}}}return null}}class Ug extends ut{_pickRet;box;radius=.5;constructor(e){super(),this._shapeType=ni.Sphere,this.radius=e,this.box=new Tr(new g,1)}rayPick(e,t){this.box.setFromCenterAndSize(this.center,this.radius);let r=ut.helpMatrix;r.copyFrom(t).invert();let i=ut.helpRay.copy(e);i.applyMatrix(r);let s=i.intersectSphere(i.origin,i.direction,this.box.center,this.box.radius);return s?(this._pickRet||(this._pickRet={intersect:!1,intersectPoint:new g,distance:0}),this._pickRet.intersect=!0,this._pickRet.intersectPoint=s,this._pickRet.distance=g.distance(i.origin,ut.v3_help_0),this._pickRet):null}}class yg extends d.Object3D{_envMap;skyObject;envMapChange=!0;view;constructor(){super(),this.transform.scene3D=this,this.skyObject=new d.Object3D,this.addChild(this.skyObject),this._isScene3D=!0,this.envMap||=B.res.defaultSky}get envMap(){return this._envMap}set envMap(e){this._envMap!=e&&(this.envMapChange=!0),this._envMap=e,$.instance.sky&&"map"in $.instance.sky&&($.instance.sky.map=e)}get exposure(){return $.instance.sky&&"exposure"in $.instance.sky?$.instance.sky.exposure:0}set exposure(e){$.instance.sky&&"exposure"in $.instance.sky&&($.instance.sky.exposure=e,B.setting.sky.skyExposure=e)}get roughness(){if($.instance.sky&&"roughness"in $.instance.sky)return $.instance.sky.roughness}set roughness(e){$.instance.sky&&"roughness"in $.instance.sky&&($.instance.sky.roughness=e)}}class ah{_computeShader;_outBuffer;constructor(){}init(){let e=Be.getGBufferFrame(Be.colorPass_GBuffer);this._computeShader=new Se(ad),this._outBuffer=new ei(32),this._computeShader.setStorageBuffer("outBuffer",this._outBuffer),this._computeShader.setSamplerTexture("gBufferTexture",e.getCompressGBufferTexture())}compute(e){let t=ve.getCameraGroup(e.camera);this._computeShader.setStorageBuffer("globalUniform",t.uniformGPUBuffer);let a=E.beginCommandEncoder();E.computeCommand(a,[this._computeShader]),E.endCommandEncoder(a),this._outBuffer.readBuffer()}getPickMeshID(){var e=this._outBuffer.outFloat32Array[0]+.1;return Math.floor(e)}getPickWorldPosition(e){e||=new g;var t=this._outBuffer.outFloat32Array[4],a=this._outBuffer.outFloat32Array[5],r=this._outBuffer.outFloat32Array[6];return e.set(t,a,r),e}getPickWorldNormal(e){e||=new g;var t=this._outBuffer.outFloat32Array[8],a=this._outBuffer.outFloat32Array[9],r=this._outBuffer.outFloat32Array[10];return e.set(t*2-1,a*2-1,r*2-1).normalize(),e}getPickScreenUV(e){e||=new fe;var t=this._outBuffer.outFloat32Array[2],a=this._outBuffer.outFloat32Array[3];return e.set(t,a),e}}class rh extends ja{ray;isTouching=!1;_mouseCode;_pickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_mouseMove;_pickCompute;_lastDownTarget;mouseEnableMap;_view;constructor(e){super(),this._view=e,this.init()}init(){this.ray=new na,this.mouseEnableMap=new Map,this._pickEvent=new Y(Y.PICK_CLICK),this._outEvent=new Y(Y.PICK_OUT),this._overEvent=new Y(Y.PICK_OVER),this._mouseMove=new Y(Y.PICK_MOVE),this._upEvent=new Y(Y.PICK_UP),this._downEvent=new Y(Y.PICK_DOWN)}start(){B.setting.pick.enable&&(B.inputSystem.addEventListener(Y.POINTER_DOWN,this.onTouchStart,this),B.inputSystem.addEventListener(Y.POINTER_UP,this.onTouchEnd,this),B.inputSystem.addEventListener(Y.POINTER_CLICK,this.onTouchOnce,this),B.inputSystem.addEventListener(Y.POINTER_RIGHT_CLICK,this.onTouchOnce,this),B.inputSystem.addEventListener(Y.POINTER_MOVE,this.onTouchMove,this)),B.setting.pick.mode=="pixel"&&(this._pickCompute=new ah,this._pickCompute.init())}stop(){B.inputSystem.removeEventListener(Y.POINTER_DOWN,this.onTouchStart,this),B.inputSystem.removeEventListener(Y.POINTER_UP,this.onTouchEnd,this),B.inputSystem.removeEventListener(Y.POINTER_CLICK,this.onTouchOnce,this),B.inputSystem.removeEventListener(Y.POINTER_RIGHT_CLICK,this.onTouchOnce,this),B.inputSystem.removeEventListener(Y.POINTER_MOVE,this.onTouchMove,this)}onTouchStart(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);this._lastDownTarget=t,t&&(Object.assign(this._downEvent,e),this._downEvent.type=Y.PICK_DOWN,this._downEvent.target=t.object3D,this._downEvent.data=this.getPickInfo(),this.dispatchEvent(this._downEvent),t.object3D.containEventListener(Y.PICK_DOWN)&&t.object3D.dispatchEvent(this._downEvent))}onTouchEnd(e){this.isTouching=!1,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._upEvent,e),this._upEvent.type=Y.PICK_UP,this._upEvent.target=t.object3D,this._upEvent.data=this.getPickInfo(),this.dispatchEvent(this._upEvent),t.object3D.containEventListener(Y.PICK_UP)&&t.object3D.dispatchEvent(this._upEvent))}_lastFocus;getPickInfo(){if(B.setting.pick.mode=="pixel")return{worldPos:this._pickCompute.getPickWorldPosition(),worldNormal:this._pickCompute.getPickWorldNormal(),screenUv:this._pickCompute.getPickScreenUV(),meshID:this._pickCompute.getPickMeshID()};{let e=this._interestList[0];return{worldPos:e.intersectPoint,worldNormal:e.normal,meshID:e.collider.transform.worldMatrix.index,distance:e.distance}}}onTouchMove(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._mouseMove,e),this._mouseMove.type=Y.PICK_MOVE,this._mouseMove.target=t.object3D,this._mouseMove.data=this.getPickInfo(),this.dispatchEvent(this._mouseMove),t.object3D.containEventListener(Y.PICK_MOVE)&&t.object3D.dispatchEvent(this._mouseMove)),t!=this._lastFocus&&(this._lastFocus&&this._lastFocus.object3D&&(Object.assign(this._outEvent,e),this._outEvent.type=Y.PICK_OUT,this._outEvent.target=this._lastFocus.object3D,this._outEvent.data=this.getPickInfo(),this.dispatchEvent(this._outEvent),this._lastFocus.object3D.containEventListener(Y.PICK_OUT)&&this._lastFocus.object3D.dispatchEvent(this._outEvent)),t&&(Object.assign(this._overEvent,e),this._overEvent.type=Y.PICK_OVER,this._overEvent.target=t.object3D,this._overEvent.data=this.getPickInfo(),this.dispatchEvent(this._overEvent),t.object3D.containEventListener(Y.PICK_OVER)&&t.object3D.dispatchEvent(this._overEvent))),this._lastFocus=t}onTouchOnce(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);if(t){let a=this.getPickInfo();Object.assign(this._pickEvent,e),this._pickEvent.type=Y.PICK_CLICK,this._pickEvent.target=t.object3D,this._pickEvent.data=a,this.dispatchEvent(this._pickEvent),t===this._lastDownTarget&&t.object3D.containEventListener(Y.PICK_CLICK)&&t.object3D.dispatchEvent(this._pickEvent)}this._lastDownTarget=null}findNearestObj(e,t){return e.sort((a,r)=>a.distance>r.distance?1:-1),e[0]?.collider}_interestList=[];pick(e){if(this._interestList.length=0,B.setting.pick.mode=="pixel"){this._pickCompute.compute(this._view);let t=this._pickCompute.getPickMeshID(),a=this.mouseEnableMap.get(t);if(a){let r=this._pickCompute.getPickWorldPosition(),i=g.distance(r,this.ray.origin);this._interestList.push({distance:i,collider:a,intersectPoint:r})}}else if(B.setting.pick.mode=="bound"){this.ray=e.screenPointToRay(B.inputSystem.mouseX,B.inputSystem.mouseY);let t,a=Ne.componentsEnablePickerList.get(this._view);if(a)for(const r of a){let i=r[0];i.enable&&(t=i.rayPick(this.ray),t&&(t.collider=i,this._interestList.push(t)))}}}}class Cg extends ns{_camera;_scene;_viewPort;_enablePick=!1;_enable=!0;pickFire;guiPick;canvasList;constructor(e=0,t=0,a=0,r=0){super(),this.canvasList=[],this._viewPort=new ue(e,t,a,r)}get enable(){return this._enable}set enable(e){this._enable=e}get enablePick(){return this._enablePick}set enablePick(e){this._enablePick!=e&&(this.pickFire=new rh(this),this.pickFire.start()),this._enablePick=e}get scene(){return this._scene}set scene(e){this._scene=e,e.view=this,Wt.createBuffer(this),e&&this.canvasList.forEach(t=>{t&&e.addChild(t.object3D)})}get camera(){return this._camera}set camera(e){this._camera=e}get viewPort(){return this._viewPort}set viewPort(e){this._viewPort=e}enableUICanvas(e=0){let t=this.canvasList[e];if(!t){let a=new d.Object3D;a.name="Canvas "+e,t=a.addComponent(zi),t.index=e,this.canvasList[e]=t}return this.scene.addChild(t.object3D),this.guiPick||(this.guiPick=new Wd,this.guiPick.init(this)),t}disableUICanvas(e=0){let t=this.canvasList[e];t&&t.object3D&&t.object3D.removeFromParent()}}class Sg{normal;fixNormal;center;rotateShape;distance=0;index;constructor(e){this.index=e,this.rotateShape=[]}}class xg extends Ve{vScale;uNegate;sections;build(e,t,a,r=1,i=!0){if(a.length<2)throw new Error("path length is not enough");return this.vScale=r,this.uNegate=i,e=e.slice(),t&&e.push(e[0]),this.sections=this.buildSections(e,a),this.buildGeometry(e,this.sections),this.bounds=new Ce(g.ZERO.clone(),new g(100,100,100)),this}buildSections(e,t){let a,r,i,s=[],o=t.length;for(let c=0;c<o;c++){let f=new Sg(c);a=t[c],r=t[c+1],f.center=a.clone(),r==null?(f.normal=i.clone(),f.distance=0):(i=r.subtract(a),f.distance=i.length,f.normal=i.normalize()),s.push(f)}s[0].fixNormal=s[0].normal.clone();for(let c=1;c<o;c++){let f=s[c-1],h=s[c];h.fixNormal=h.normal.add(f.normal).normalize()}let l=new T().identity();for(let c=0;c<o;c++){let f=s[c],h,u;if(c==0)h=g.UP,u=e;else{let b=s[c-1];h=b.fixNormal,u=b.rotateShape}T.fromToRotation(h,f.fixNormal,l);for(let b=0,A=e.length;b<A;b++){let m=l.multiplyPoint3(u[b]);f.rotateShape.push(m)}}return s}buildGeometry(e,t){let a=t.length,r=e.length,i=a*r,s=a-1,o=new Float32Array(i*3),l=new Float32Array(i*3),c=new Float32Array(i*2),f=new Uint32Array(s*(r-1)*6),h=r-1,u=0,b=0,A=[0];for(let p=1;p<r;p++)b+=e[p-1].subtract(e[p]).length,A.push(b);for(let p=0;p<a;p++){let D=t[p];for(let _=0;_<r;_++){let v=(p*r+_)*3,U=D.rotateShape[_].add(D.center);o[v]=U.x,o[v+1]=U.y,o[v+2]=U.z,l[v+1]=1;let y=(p*r+_)*2,S=A[_]/b;c[y]=this.uNegate?1-S:S,c[y+1]=u*this.vScale}u+=D.distance}let m=0;for(let p=0;p<s;p++){let D=p*r;for(let _=0;_<h;_++){let v=_,U=_+1,y=v+r,S=U+r;f[m++]=v+D,f[m++]=U+D,f[m++]=y+D,f[m++]=U+D,f[m++]=S+D,f[m++]=y+D}}return this.setIndices(f),this.setAttribute(G.position,o),this.setAttribute(G.normal,l),this.setAttribute(G.uv,c),this.setAttribute(G.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.computeNormals(),this}}class ih extends Ve{_instanceBuffer;_instanceData;_instanceCount=0;constructor(){super(),this.initBaseGeometry()}initBaseGeometry(){const e=new Float32Array([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0]),t=new Float32Array([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2]),a=new Uint16Array([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]);this.setIndices(a),this.setAttribute(G.position,e),this.setAttribute(G.uv,t),this.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:e.length/3,firstStart:0,index:0,topology:0})}setPositions(e){const t=e instanceof Float32Array?e:new Float32Array(e),r=t.length/3-1;if(r<=0)return console.warn("FatLineGeometry: Need at least 2 points"),this;const i=new Float32Array(r*16);for(let s=0;s<r;s++){const o=s*3,l=(s+1)*3;i[s*16+0]=t[o+0],i[s*16+1]=t[o+1],i[s*16+2]=t[o+2],i[s*16+3]=0,i[s*16+4]=t[l+0],i[s*16+5]=t[l+1],i[s*16+6]=t[l+2],i[s*16+7]=0,i[s*16+8]=1,i[s*16+9]=1,i[s*16+10]=1,i[s*16+11]=0,i[s*16+12]=1,i[s*16+13]=1,i[s*16+14]=1,i[s*16+15]=0}return this._instanceData=i,this._instanceCount=r,this.computeBoundingBox(t),this}setColors(e){const t=e instanceof Float32Array?e:new Float32Array(e);if(!this._instanceData)return console.warn("FatLineGeometry: Must call setPositions() before setColors()"),this;const r=t.length/3-1;if(r!==this._instanceCount)return console.warn("FatLineGeometry: Color array length doesn't match segment count"),this;for(let i=0;i<r;i++){const s=i*3,o=(i+1)*3;this._instanceData[i*16+8]=t[s+0],this._instanceData[i*16+9]=t[s+1],this._instanceData[i*16+10]=t[s+2],this._instanceData[i*16+12]=t[o+0],this._instanceData[i*16+13]=t[o+1],this._instanceData[i*16+14]=t[o+2]}return this}computeBoundingBox(e){const t=new g(1/0,1/0,1/0),a=new g(-1/0,-1/0,-1/0);for(let i=0;i<e.length;i+=3){const s=e[i],o=e[i+1],l=e[i+2];t.x=Math.min(t.x,s),t.y=Math.min(t.y,o),t.z=Math.min(t.z,l),a.x=Math.max(a.x,s),a.y=Math.max(a.y,o),a.z=Math.max(a.z,l)}const r=g.sub(a,t);this.bounds=new Ce(g.ZERO.clone(),r),this.bounds.setFromMinMax(t,a)}get instanceData(){return this._instanceData}get instanceCount(){return this._instanceCount}get instanceBuffer(){return!this._instanceBuffer&&this._instanceData&&(this._instanceBuffer=new Pe(this._instanceData.byteLength),this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply()),this._instanceBuffer}updateInstanceBuffer(){this._instanceBuffer&&this._instanceData&&(this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply())}}class Fg{name;offset;size;arrayStride;stepMode;attributes}class kg{name;format;offset;shaderLocation;stride}var sh=(n=>(n[n.position=3]="position",n[n.normal=3]="normal",n[n.TANGENT=4]="TANGENT",n[n.uv=2]="uv",n[n.TEXCOORD_1=2]="TEXCOORD_1",n[n.color=4]="color",n[n.joints0=4]="joints0",n[n.weights0=4]="weights0",n[n.joints1=4]="joints1",n[n.weights1=4]="weights1",n[n.vIndex=1]="vIndex",n[n.weight=1]="weight",n[n.a_morphPositions_0=3]="a_morphPositions_0",n))(sh||{});class Eg{get data(){return null}entity}class nh{min=0;max=0;set(e,t){return this.max=t,this.min=e,this}copy(e){return this.max=e.max,this.min=e.min,this}isInterestRange(e){return!(this.max>e.min||e.max<this.min)}}class oh{_spaceDesc;getRange(e){return this._spaceDesc[e]}initSpace(e){this._spaceDesc={};for(let t of e)(this._spaceDesc[t]=new nh).set(-Number.MAX_VALUE,Number.MAX_VALUE);return this}isContain(e,t){let a=this._spaceDesc[e];return t>=a.min&&t<a.max}isInterestRange(e,t){let a=this._spaceDesc[e];return a?t.isInterestRange(a):!1}splitSpace(e,t,a){let r=this._spaceDesc[e];return t?r.max=a:r.min=a,this}copySpace(e){for(let t in e._spaceDesc){let a=e._spaceDesc[t];this._spaceDesc[t].copy(a)}return this}}class Yi{static MaxEntityCountInLeaf=4;static MaxLayer=10;static ClearLeafLayer=Yi.MaxLayer-4}class Xi{static UUID=0;uuid="0";constructor(){this.uuid=(Xi.UUID++).toString()}}class wg{map={};_count=0;get count(){return this._count}push(e){return this.map[e.uuid]?!1:(this.map[e.uuid]=e,this._count++,!0)}remove(e){return this.map[e]?(delete this.map[e],this._count--,!0):!1}}class _r extends Xi{_dimensionIndex=0;_dimensions;_dimension;_left;_right;_space;_parent;_entities;layer;get dimension(){return this._dimension}constructor(e=0){super(),this.layer=e,_r.nodeCount++}initNode(e,t,a){return this._dimensions=t,this._dimensionIndex=a,this._dimension=t[a],this._space=new oh().initSpace(t),e&&this._space.copySpace(e._space),this._parent=e,this._entities=new wg,this}updateEntity(e){if(e.isInNode(this,this._dimension)&&(e.attachTreeNode(this),this.autoSplit(),this._left&&this._right)){let t=(this._dimensionIndex+1)%this._dimensions.length,a=this._dimensions[t];e.isInNode(this._right,a)?this._right.updateEntity(e):e.isInNode(this._left,a)&&this._left.updateEntity(e)}}buildRoot(e){for(const t of e)t.entity.attachTreeNode(this);this.autoSplit()}_splitEntityList=[];autoSplit(){if(this._entities.count>Yi.MaxEntityCountInLeaf&&!this._right&&!this._left&&this.layer<Yi.MaxLayer){let e=this._splitEntityList,t=(this._dimensionIndex+1)%this._dimensions.length,a=this._dimensions[t],r=0;for(const i in this._entities.map){let s=this._entities.map[i];r+=s.centerValue(a),e.push(s)}r/=this._entities.count,this._left=new _r(this.layer+1),this._right=new _r(this.layer+1),this._left.initNode(this,this._dimensions,t),this._right.initNode(this,this._dimensions,t),this._left.setSpace(!0,r),this._right.setSpace(!1,r);for(let i of e)i.isInNode(this._right,a)?i.attachTreeNode(this._right):i.isInNode(this._left,a)&&i.attachTreeNode(this._left)}this._left&&this._left.autoSplit(),this._right&&this._right.autoSplit()}setSpace(e,t){return this._parent&&this._space.splitSpace(this._dimension,e,t),this}isEmpty(){return this._left==null&&this._right==null&&this._entities.count==0}pushEntity(e){return this._entities.push(e)}removeEntity(e){return this._entities.remove(e.uuid)}static nodeCount=0;autoClear(){let e=this;for(;e&&e.layer>Yi.ClearLeafLayer&&e.clearLeaf();)e=e._parent}clearLeaf(){let e=!this._left&&!this._right,t=!e&&this._left.isEmpty()&&this._right.isEmpty();return t&&(this._left=this._right=null,_r.nodeCount-=2),e||t}isContain(e){return this._space.isContain(this._dimension,e)}static rangeBox=new Ce(new g(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),new g(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE));nodeIntersectsBox(e){let t=this._space.getRange("x"),a=this._space.getRange("y"),r=this._space.getRange("z"),i=_r.rangeBox;return i.min.set(t.min,a.min,r.min),i.max.set(t.max,a.max,r.max),i.intersectsBox(e)}nodeIntersectsRay(e){let t=this._space.getRange("x"),a=this._space.getRange("y"),r=this._space.getRange("z"),i=_r.rangeBox;return i.min.set(t.min,a.min,r.min),i.max.set(t.max,a.max,r.max),!0}pointCast(e,t=0,a){if(a=a||[],this._entities.count>0){let r=this._entities.map;for(let i in r){let s=r[i],o=s.entityContainPoint(e);!o&&t>0&&(o=s.squareDistanceTo(e,this._dimensions)<=t),o&&a.push(s)}}this._left&&this._left.isContain(e[this._left.dimension])&&this._left.pointCast(e,t,a),this._right&&this._right.isContain(e[this._right.dimension])&&this._right.pointCast(e,t,a)}boxCast(e,t){if(t=t||[],this._entities.count>0){let a=this._entities.map;for(let r in a){let i=a[r];i.entityIntersectsBox(e)&&t.push(i)}}this._left&&this._left.nodeIntersectsBox(e)&&this._left.boxCast(e,t),this._right&&this._right.nodeIntersectsBox(e)&&this._right.boxCast(e,t)}pointIntersect=new g;rayCast(e,t,a){t=t||[],a=a||[];let r=this.pointIntersect;if(this._entities.count>0){let i=this._entities.map;for(let s in i){let o=i[s];o.entityIntersectsRay(e,r)&&(a.push(new g().copyFrom(r)),t.push(o))}}this._left&&this._left.nodeIntersectsRay(e)&&this._left.rayCast(e,t,a),this._right&&this._right.nodeIntersectsRay(e)&&this._right.rayCast(e,t,a)}}class Rg extends Xi{userData;node;constructor(e){super(),this.userData=e}centerValue(e){return 0}isInNode(e,t){return!1}entityContainPoint(e){return!1}squareDistanceTo(e,t){return Number.MAX_VALUE}entityIntersectsBox(e){return!1}entityIntersectsRay(e,t){return!1}attachTreeNode(e){return this.node&&this.detachTreeNode(),this.node=e,this.node.pushEntity(this)}detachTreeNode(){let e=this.node.removeEntity(this);return this.node=null,e}updateNode(e){let t=this.node;t&&this.detachTreeNode(),e.updateEntity(this),t&&t.autoClear()}}class Qt{minPosX=0;minPosY=0;maxPosX=0;maxPosY=0;testID=0;points;offsetPosition;static TINY=1e-6;constructor(){this.points=new Array,this.offsetPosition=new g(0,0,0,0),this.clear()}setAABox(e,t,a,r){this.minPosX=e-a/2-Qt.TINY,this.maxPosX=e+a/2+Qt.TINY,this.minPosY=t-r/2-Qt.TINY,this.maxPosY=t+r/2+Qt.TINY,this.offsetPosition.setTo(0,0,0)}setOffset(e){this.maxPosX+=e.x-this.offsetPosition.x,this.minPosX+=e.x-this.offsetPosition.x,this.minPosY+=e.z-this.offsetPosition.z,this.maxPosY+=e.z-this.offsetPosition.z,this.offsetPosition.copyFrom(e)}setContainRect(e,t,a,r){this.minPosX>e&&(this.minPosX=e),this.minPosY>t&&(this.minPosY=t),this.maxPosX<a&&(this.maxPosX=a),this.maxPosY<r&&(this.maxPosY=r)}clear(){var e=1e9;this.minPosX=this.minPosY=e,this.maxPosX=this.maxPosY=-e,this.points.length=0,this.testID=0,this.offsetPosition.setTo(0,0,0)}addPoint(e){this.points.indexOf(e)==-1&&(e.x<this.minPosX&&(this.minPosX=e.x-Qt.TINY),e.x>this.maxPosX&&(this.maxPosX=e.x+Qt.TINY),e.z<this.minPosY&&(this.minPosY=e.z-Qt.TINY),e.z>this.maxPosY&&(this.maxPosY=e.z+Qt.TINY),this.points.push(e))}clone(){var e=new Qt;return e.minPosX=this.minPosX,e.minPosY=this.minPosY,e.maxPosX=this.maxPosX,e.maxPosY=this.maxPosY,e}get radius(){return Math.sqrt((this.maxPosY-this.minPosY)*(this.maxPosY-this.minPosY)+(this.maxPosX-this.minPosX)*(this.maxPosX-this.minPosX))}get sideX(){return this.maxPosX-this.minPosX}get sideY(){return this.maxPosY-this.minPosY}get centreX(){return(this.maxPosX-this.minPosX)*.5+this.minPosX}get centreY(){return(this.maxPosY-this.minPosY)*.5+this.minPosY}overlapTest(e){return!(this.minPosY>=e.maxPosY||this.maxPosY<=e.minPosY||this.minPosX>=e.maxPosX||this.maxPosX<=e.minPosX)}isPointInside(e){return e.x>=this.minPosX&&e.x<=this.maxPosX&&e.z>=this.minPosY&&e.z<=this.maxPosY}isIntersectLineSegment(e,t,a,r){var i=!1,s=t-r,o=a-e,l=e*r-a*t,c=(-l-s*this.minPosX)/o;c<=this.maxPosY&&c>=this.minPosY&&(i=!0),c=(-l-s*this.maxPosX)/o,c<=this.maxPosY&&c>=this.minPosY&&(i=!0);var f=(-l-o*this.minPosY)/s;return f<=this.maxPosX&&f>=this.minPosX&&(i=!0),f=(-l-o*this.maxPosY)/s,f<=this.maxPosX&&f>=this.minPosX&&(i=!0),i}}class Br{static NUM_CHILDREN=4;childCellIndices;nodeIndices;aabb;points;constructor(e){this.childCellIndices=new Array,this.childCellIndices.length=Br.NUM_CHILDREN,this.nodeIndices=new Array,this.clear(),e?this.aabb=e.clone():this.aabb=new Qt}isLeaf(){return this.childCellIndices[0]==-1}clear(){for(var e=0;e<Br.NUM_CHILDREN;e++)this.childCellIndices[e]=-1;this.nodeIndices.splice(0,this.nodeIndices.length)}}class lh{_cells;_rootCell;_quadNodes;_aabb;_cellsToTest;_testID;constructor(){this._testID=0,this._cells=new Array,this._quadNodes=new Array,this._cellsToTest=new Array,this._aabb=new Qt}getQuadNode(e){return this._quadNodes[e]}clear(){this._cells.length=0,this._quadNodes.length=0}initNodes(e){this.clear();for(var t=0,a=e.length;t<a;)e[t].calcGlobalQuadAABB(),this._quadNodes.push(e[t]),t++}buildQuadTree(e,t){this._aabb.clear();for(var a of this._quadNodes)if(a.isTriangle)for(var r of a.aabb.points)this._aabb.addPoint(r);else this._aabb.setContainRect(a.aabb.minPosX,a.aabb.minPosY,a.aabb.maxPosX,a.aabb.maxPosY);this._cells.length=0,this._rootCell=new Br(this._aabb),this._cells.push(this._rootCell);for(var i=this._quadNodes.length,s=0;s<i;s++)this._cells[0].nodeIndices[s]=s;var o=new Array;o.push(0);for(var l,c,f;o.length!=0;)if(c=o.pop(),!(this._cells[c].nodeIndices.length<=e||this._cells[c].aabb.radius<t)){for(s=0;s<Br.NUM_CHILDREN;s++){this._cells[c].childCellIndices[s]=this._cells.length,o.push(this._cells.length),this._cells.push(new Br(this.createAABox(this._cells[c].aabb,s))),f=this._cells[this._cells.length-1],i=this._cells[c].nodeIndices.length;for(var h=0;h<i;h++)l=this._cells[c].nodeIndices[h],this.doesNodeIntersectCell(this._quadNodes[l],f)&&f.nodeIndices.push(l)}this._cells[c].nodeIndices.length=0}}createAABox(e,t){var a=e.centreX,r=e.centreY,i=e.sideX,s=e.sideY,o=new Qt;switch(t){case 0:o.setAABox(a+i/4,r+s/4,i/2,s/2);break;case 1:o.setAABox(a-i/4,r+s/4,i/2,s/2);break;case 2:o.setAABox(a-i/4,r-s/4,i/2,s/2);break;case 3:o.setAABox(a+i/4,r-s/4,i/2,s/2);break;default:o.setAABox(a+i/4,r-s/4,i/2,s/2);break}return o}doesNodeIntersectCell(e,t){var a=e.aabb;if(!a.overlapTest(t.aabb))return!1;if(!e.isTriangle)return!0;var r=a.points,i=r[0],s=r[1],o=r[2];if(t.aabb.isPointInside(i)||t.aabb.isPointInside(s)||t.aabb.isPointInside(o))return!0;var l=this.pointInTriangle(t.aabb.minPosX,t.aabb.minPosY,i,s,o)||this.pointInTriangle(t.aabb.minPosX,t.aabb.maxPosY,i,s,o)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.maxPosY,i,s,o)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.minPosY,i,s,o);return l?!0:(l=t.aabb.isIntersectLineSegment(i.x,i.z,s.x,s.z)||t.aabb.isIntersectLineSegment(i.x,i.z,o.x,o.z)||t.aabb.isIntersectLineSegment(s.x,s.z,o.x,o.z),l)}getNodesIntersectingtAABox(e,t){if(this._cells.length==0)return 0;this._cellsToTest.length=0,this._cellsToTest.push(0),this.incrementTestCounter();for(var a,r,i,s,o=0;this._cellsToTest.length!=0;)if(a=this._cellsToTest.pop(),i=this._cells[a],!!t.overlapTest(i.aabb))if(i.isLeaf())for(r=i.nodeIndices.length,o=0;o<r;o++)s=this.getQuadNode(i.nodeIndices[o]).aabb,s.testID!=this._testID&&(s.testID=this._testID,t.overlapTest(s)&&e.push(i.nodeIndices[o]));else for(o=0;o<Br.NUM_CHILDREN;o++)this._cellsToTest.push(i.childCellIndices[o]);return e.length}pointInTriangle(e,t,a,r,i){var s=a,o=r,l=i,c=s.z-o.z,f=o.x-s.x,h=s.x*o.z-o.x*s.z,u=o.z-l.z,b=l.x-o.x,A=o.x*l.z-l.x*o.z,m=l.z-s.z,p=s.x-l.x,D=l.x*s.z-s.x*l.z,_=!1,v=c*e+f*t+h,U=u*e+b*t+A,y=m*e+p*t+D;const S=.01;return(v>=-S&&U>=-S&&y>=-S||v<=S&&U<=S&&y<=S)&&(_=!0),_}incrementTestCounter(){if(++this._testID,this._testID==0){for(var e=this._quadNodes.length,t=0;t<e;t++)this._quadNodes[t].aabb.testID=0;this._testID=1}}logDeep=0;logTree(e){if(!(e<0)){this.logDeep++;for(var t=this._cells[e],a="",r=0;r<this.logDeep-1;r++)a+="-|";console.log(a+"i="+e+" "+t.aabb.minPosX.toFixed(2)+" "+t.aabb.maxPosX.toFixed(2)+" "+t.aabb.minPosY.toFixed(2)+" "+t.aabb.maxPosY.toFixed(2));var i;for(i=0;i<t.nodeIndices.length;i++)if(t.nodeIndices[i]>=0){var s=this._quadNodes[t.nodeIndices[i]];console.log(a+" t="+t.nodeIndices[i]+" "+s.aabb.minPosX.toFixed(2)+" "+s.aabb.maxPosX.toFixed(2)+" "+s.aabb.minPosY.toFixed(2)+" "+s.aabb.maxPosY.toFixed(2))}for(i=0;i<t.childCellIndices.length;i++)t.childCellIndices[i]>=0&&this.logTree(t.childCellIndices[i]);this.logDeep--}}}class ch{_maxNodesPerCell;_minCellSize;_quadTree;_collisionNodesIdx;_segBox;_collisionNodes;constructor(e=10,t=500){this._maxNodesPerCell=e,this._minCellSize=t,this._segBox=new Qt,this._collisionNodesIdx=new Array,this._collisionNodes=new Array}createQuadTree(e){this._quadTree=new lh,this._quadTree.initNodes(e),this._quadTree.buildQuadTree(this._maxNodesPerCell,this._minCellSize)}getNodesByAABB(e,t,a,r){this._segBox.clear(),this._segBox.maxPosX=a,this._segBox.maxPosY=r,this._segBox.minPosX=e,this._segBox.minPosY=t,this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var i,s=0;s<this._collisionNodesIdx.length;s++)i=this._quadTree.getQuadNode(this._collisionNodesIdx[s]),this._collisionNodes.push(i);return this._collisionNodes}getTriangleAtPoint(e,t=5){this._segBox.clear(),this._segBox.setAABox(e.x,e.z,1,1),this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var a=4294967295,r=0,i,s,o,l,c=0;c<this._collisionNodesIdx.length;c++)s=this._quadTree.getQuadNode(this._collisionNodesIdx[c]),l=s.aabb,g.pointInsideTriangle(e,l.points[0],l.points[1],l.points[2])&&(o=s,r=Math.abs(o.plane.distance(e)),!(r>t)&&(s==null||r<=a)&&(i=o,a=r));return i}}var Ps=(n=>(n[n.MOUSE_LEFT=0]="MOUSE_LEFT",n[n.MOUSE_MID=1]="MOUSE_MID",n[n.MOUSE_RIGHT=2]="MOUSE_RIGHT",n))(Ps||{});class Ig extends bt{static LOADER_PROGRESS="loaderProgress";static LOADER_COMPLETE="loaderComplete"}class Tg extends bt{static ADDED="added";static REMOVED="removed";static CHILD_ADD_EVENT="childAddEvent";static CHILD_REMOVED="childRemoved"}class Qg extends bt{static SHOW="show";static HIDE="hide";static UPDATE="update"}class Mg{static merge(e,t,a,r){let i=0,s=0;i=Math.max(e.width,i),i=Math.max(t.width,i),i=Math.max(a.width,i),i=Math.max(r.width,i),s=Math.max(e.height,s),s=Math.max(t.height,s),s=Math.max(a.height,s),s=Math.max(r.height,s);let o=new Ie(i,s,le.rgba8unorm),l=new Se(qf);l.setSamplerTexture("textureR",e),l.setSamplerTexture("textureG",t),l.setSamplerTexture("textureB",a),l.setSamplerTexture("textureA",r),l.setStorageTexture("outTex",o),l.workerSizeX=Math.ceil(i/8),l.workerSizeY=Math.ceil(s/8);let c=E.beginCommandEncoder();return E.computeCommand(c,[l]),E.endCommandEncoder(c),o}}class fh{computeShader;setInputes(e,t,a){this.computeShader=new Se(bd(e,t,a,8,8,1));for(let r=0;r<t.length;r++)this.computeShader.setSamplerTexture(`source${r}Map`,t[r]);for(let r=0;r<a.length;r++)this.computeShader.setStorageTexture(`dest${r}Map`,a[r]);e&&this.computeShader.setSamplerTexture("colorMap",e),this.computeShader.workerSizeX=a[0].width/8,this.computeShader.workerSizeY=a[0].height/8,this.computeShader.workerSizeZ=1}}class dh{sourceShader;compute;needUpdate=!0;constructor(e,t){this.sourceShader=t,this.compute=new Se(e),this.init()}init(){}onUpdate(){this.onFrame&&this.onFrame(),this.onOnce&&this.needUpdate&&(this.needUpdate=!1,this.onFrame())}}class hh extends dh{constructor(e){super(rd,e)}init(){let e=new Ie(256,256,le.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);return this.compute.setStorageTexture("sssMap",e),this.sourceShader.setTexture("lutMap",e),e}onFrame(){this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let e=E.beginCommandEncoder();E.computeCommand(e,[this.compute]),E.endCommandEncoder(e)}}class Pg{gpuBuffer;probes;memoryDo;_probeInfoList;initDataUniform(e){this.memoryDo=new or,this.probes=e,this._probeInfoList=[],this.memoryDo.destroy(),this.memoryDo.allocation(e.length*17*4);for(let a=0;a<e.length;a++){var t=17;let r=this.memoryDo.allocation_node(t*4);this._probeInfoList.push(r);let i=e[a].transform.worldPosition;r.setArray(0,[i.x,i.y,i.z])}this.gpuBuffer=I.device.createBuffer({size:this.memoryDo.shareDataBuffer.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE,label:"ProbeBuffer",mappedAtCreation:!1})}updateGPUBuffer(){const e=this.memoryDo.shareDataBuffer;let t=this.memoryDo.shareDataBuffer.byteLength,a=0;const r=5e3*64;for(;a<t;)I.device.queue.writeBuffer(this.gpuBuffer,a,e,a,Math.floor(Math.min(r,t-a))),a+=r}}class Ng extends Za{constructor(e,t,a=0){super(),this.bufferType=ga.StructStorageGPUBuffer,this.createBufferByStruct(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|a,e,t)}}class Vg{static codeMax=`
11789
+ `||x==" "?S=null:(v(x,S),S.width+b>=A&&(S=_()))}})(),U()}getAlignment(e){let t={v:0,h:0};switch(e){case 1:t.v=0,t.h=1;break;case 0:t.v=0,t.h=0;break;case 2:t.v=0,t.h=2;break;case 4:t.v=1,t.h=1;break;case 3:t.v=1,t.h=0;break;case 5:t.v=1,t.h=2;break;case 7:t.v=2,t.h=1;break;case 6:t.v=2,t.h=0;break;case 8:t.v=2,t.h=2;break}return t}}class Qs extends Uo{_style=at.NORMAL;_interactive=!1;set interactive(e){this._interactive=e}get interactive(){return this._interactive}set mouseStyle(e){this._style=e}get interactiveVisible(){return this._uiTransform.globalVisible&&this._visible}init(e){super.init(e),this._uiTransform.addUIInteractive(this)}destroy(){this._uiTransform.removeUIInteractive(this),super.destroy()}rayPick(e,t,a,r){return Zd.rayPick(e,a,r,t.space,t.panelRatio,this._uiTransform,t.transform.worldMatrix)}cloneTo(e){e.getOrAddComponent(Qs).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.enable=e._enable,this.interactive=e._interactive,this.mouseStyle=e._style,this}}var $d=(n=>(n[n.NONE=0]="NONE",n[n.COLOR=1]="COLOR",n[n.SPRITE=2]="SPRITE",n))($d||{});class yo extends Qs{_spriteMap;_colorMap;_image;_isCreateImage;_transition=2;init(e){super.init(e),this._interactive=!0,this._spriteMap=new Map,this._colorMap=new Map,this._image=this.object3D.getComponent(Nr),this._isCreateImage=this._image==null,this._image||(this._image=this.object3D.addComponent(Nr)),this.imageType=si.Sliced}onEnable(){this.mouseStyle=at.NORMAL}onDisable(){this.mouseStyle=at.DISABLE}set transition(e){this._transition!=e&&(this._transition=e,this.validateStyle(this._style,!0))}get transition(){return this._transition}get imageType(){return this._image.imageType}set imageType(e){this._image.imageType=e}setStyleColor(e,t){return this._colorMap.set(e,t),this._style==e&&this.validateStyle(this._style,!0),this}getStyleColor(e){return this._colorMap.get(e)}set mouseStyle(e){super.mouseStyle=e,this.validateStyle(e,!0)}get normalSprite(){return this._spriteMap.get(at.NORMAL)}set normalSprite(e){this._spriteMap.set(at.NORMAL,e),this._style==at.NORMAL&&this.validateStyle(this._style,!0)}get overSprite(){return this._spriteMap.get(at.OVER)}set overSprite(e){this._spriteMap.set(at.OVER,e),this._style==at.OVER&&this.validateStyle(this._style,!0)}set downSprite(e){this._spriteMap.set(at.DOWN,e),this._style==at.DOWN&&this.validateStyle(this._style,!0)}get downSprite(){return this._spriteMap.get(at.DOWN)}set disableSprite(e){this._spriteMap.set(at.DISABLE,e),this._style==at.DISABLE&&this.validateStyle(this._style,!0)}get disableSprite(){return this._spriteMap.get(at.DISABLE)}validateStyle(e,t){if(this._transition&2){let a=this._spriteMap.get(e);this._image.sprite=a}if(this._transition&1){let a=this._colorMap.get(e);a&&(this._image.color=a)}}cloneTo(e){e.getOrAddComponent(yo).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.imageType=e.imageType,this.transition=e.transition,e._spriteMap.forEach((t,a)=>{t&&this._spriteMap.set(a,t)}),e._colorMap.forEach((t,a)=>{t&&this._colorMap.set(a,t.clone())}),this.mouseStyle=e.mouseStyle,this}destroy(){this._isCreateImage&&this._image&&(this.object3D.removeComponent(Nr),this._image=null),super.destroy()}}class Co extends Ji{_count=0;constructor(){super()}init(e){super.init?.(e),this._count=e?e.count:1;for(let t=0;t<this._count;t++)this.attachQuad(Na.spawnQuad());this._uiTransform.resize(0,0)}getQuad(e){return this._mainQuads[e]}cloneTo(e){e.addComponent(Co,{count:this._count}).copyComponent(this)}copyComponent(e){super.copyComponent(e);for(let t=0;t<e._count;t++)this.setSprite(t,e.getSprite(t)),this.setColor(t,e.getColor(t)),this.setImageType(t,e.getImageType(t));return this}setSprite(e,t){this._mainQuads[e].sprite=t||B.res.defaultGUISprite,this.setShadowDirty()}getSprite(e){return this._mainQuads[e].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}getColor(e){return this._mainQuads[e].color}setColor(e,t){this._mainQuads[e].color=t,this.setShadowDirty()}getImageType(e){return this._mainQuads[e].imageType}setImageType(e,t){this._mainQuads[e].imageType=t,this.setShadowDirty()}setSize(e,t,a){this._mainQuads[e].setSize(t,a),this.setShadowDirty()}setXY(e,t,a){this._mainQuads[e].setXY(t,a),this.setShadowDirty()}getXY(e,t){t||=new fe;let a=this._mainQuads[e];return t.x=a.x,t.y=a.y,t}}class So extends Ji{_shadowQuality=1;_shadowOffset;_shadowRadius;_shadowColor;_subShadowColor;needUpdateShadow=!1;init(e){super.init?.(e),this._shadowRadius=2,this._shadowQuality=1,this._shadowOffset=new fe(4,-4),this._shadowColor=new Z(.1,.1,.1,.8),this._subShadowColor=this._shadowColor.clone(),this.isUIShadow=!0}cloneTo(e){e.getOrAddComponent(So).copyComponent(this)}copyComponent(e){return super.copyComponent(this),this._shadowColor=e._shadowColor,this._shadowOffset=e._shadowOffset,this._shadowRadius=e._shadowRadius,this._shadowQuality=e.shadowQuality,this}get shadowColor(){return this._shadowColor}set shadowColor(e){this._shadowColor.copyFrom(e),this.needUpdateShadow=!0}set shadowQuality(e){e=_e(e,0,4),this._shadowQuality!=e&&(this._shadowQuality=e,this.needUpdateShadow=!0)}get shadowQuality(){return this._shadowQuality}set shadowOffset(e){this._shadowOffset=e,this.needUpdateShadow=!0}get shadowOffset(){return this._shadowOffset||=new fe(4,-4),this._shadowOffset}set shadowRadius(e){this._shadowRadius!=e&&(this._shadowRadius=e,this.applyShadow())}get shadowRadius(){return this._shadowRadius}onUpdate(e){this.needUpdateShadow&&(this.applyShadow(),this.needUpdateShadow=!1)}applyShadow(){if(this.detachQuads(),this._shadowSource&&this._shadowQuality>0){let e=this._shadowSource.mainQuads;if(e.length>0)for(let t of e)this.createQuadShadow(t)}this._uiTransform.setNeedUpdateUIPanel()}createQuadShadow(e){let t=this._shadowQuality,a=Math.PI*2;this._subShadowColor.copyFrom(this._shadowColor),this._subShadowColor.a=1/Math.max(1,t);for(let r=0;r<t;r++){let i=Na.spawnQuad(),s=0,o=0;if(r==0)i.color=this._shadowColor;else{let l=a*(r-1)/(t-1);s=Math.sin(l)*this._shadowRadius,o=Math.cos(l)*this._shadowRadius,i.color=this._subShadowColor}i.setXY(s+this._shadowOffset.x+e.x,o+this._shadowOffset.y+e.y),i.setSize(e.width,e.height),i.sprite=e.sprite,i.visible=e.visible,i.imageType=e.imageType,this.attachQuad(i)}}}class xo extends Ji{_font="\u5FAE\u8F6F\u96C5\u9ED1";_fontSize=14;_originSize=42;_alignment=0;_lineSpacing=1;_text="";_color=new Z(1,1,1,1);constructor(){super()}cloneTo(e){e.getOrAddComponent(xo).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this._font=e._font,this._fontSize=e._fontSize,this._originSize=e._originSize,this._alignment=e._alignment,this._lineSpacing=e._lineSpacing,this._color.copyFrom(e._color),this.text=e.text,this}get originSize(){return this._originSize}get font(){return this._font}set font(e){this._font=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!=e&&(this._fontSize=e,this.layoutText())}get text(){return this._text}set text(e){this._text!=e&&(e||(e=""),this._text=e,this.layoutText())}textLine=null;layoutProxy=new qd;layoutText(){this.detachQuads(),this.textLine=this.layoutProxy.layout(this);for(let e=0,t=this.textLine.length;e<t;e++){let a=this.textLine[e];for(let r=0,i=a.quadList.length;r<i;r++){let s=a.quadList[r];s&&this.attachQuad(s)}}this.color=this._color,this._uiTransform.setNeedUpdateUIPanel(),this.onUIComponentVisible(this._visible),this.setShadowDirty()}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t&&(t.visible=!e);this.setShadowDirty()}onTransformResize(){this.layoutText()}get color(){return this._color}set color(e){this._color.copyFrom(e);for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get alignment(){return this._alignment}set alignment(e){this._alignment!=e&&(this._alignment=e,this.layoutText())}get lineSpacing(){return this._lineSpacing}set lineSpacing(e){this._lineSpacing!=e&&(this._lineSpacing=e,this.layoutText())}}var fg=Object.getOwnPropertyDescriptor,dg=(n,e,t,a)=>{for(var r=a>1?void 0:a?fg(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.Light=class extends Ei{constructor(){super()}init(){super.init(),this.lightData.lightType=ft.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+Gt())}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(e){this.lightData.quadratic=e,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(e){let t=e.scene.getChildByName("graphic3D");if(!t)return;let a=t.createCustomShape(`PointLight_${this.object3D.instanceID}`,this.transform);a.buildAxis(),a.buildCircle(g.ZERO,this.range,32,g.X_AXIS),a.buildCircle(g.ZERO,this.range,32,g.Y_AXIS),a.buildCircle(g.ZERO,this.range,32,g.Z_AXIS)}debug(){}debugDraw(e){}},d.Light=dg([Nt(d.Light,"Light")],d.Light);var hg=Object.getOwnPropertyDescriptor,ug=(n,e,t,a)=>{for(var r=a>1?void 0:a?hg(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.FatLineRenderer=class extends Ba{_fatLineMaterial=null;_fatLineGeometry=null;_cachedResolution=new fe(0,0);constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(e){e.addComponent(d.FatLineRenderer).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this}set geometry(e){super.geometry=e,this._fatLineGeometry=e,e&&(this.instanceCount=e.instanceCount,this._fatLineMaterial&&e.instanceBuffer&&this._fatLineMaterial.setInstanceBuffer(e.instanceBuffer))}get geometry(){return this._fatLineGeometry}set material(e){this.materials=[e],this._fatLineMaterial=e,this._fatLineGeometry&&this._fatLineGeometry.instanceBuffer&&e.setInstanceBuffer(this._fatLineGeometry.instanceBuffer)}get material(){return this._fatLineMaterial}nodeUpdate(e,t,a,r){if(this._fatLineMaterial&&this.object3D){this._fatLineMaterial.setModelMatrix(this.object3D.transform.worldMatrix);const i=I.presentationSize[0],s=I.presentationSize[1];i>0&&s>0&&(this._cachedResolution.x!==i||this._cachedResolution.y!==s)&&(this._cachedResolution.set(i,s),this._fatLineMaterial.resolution=this._cachedResolution.clone())}super.nodeUpdate(e,t,a,r)}destroy(e){super.destroy(e)}},d.FatLineRenderer=ug([Nt(d.FatLineRenderer,"FatLineRenderer")],d.FatLineRenderer);var bg=Object.getOwnPropertyDescriptor,gg=(n,e,t,a)=>{for(var r=a>1?void 0:a?bg(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.GSplatStreamRenderer=class extends Ba{totalCount=0;size=new fe;localBoundBox=new Ce;get worldBoundBox(){const e=new Ce;e.makeEmpty();const a=this.object3D.transform.worldMatrix.rawData,r=this.localBoundBox.min,i=this.localBoundBox.max,s=[[r.x,r.y,r.z],[i.x,r.y,r.z],[r.x,i.y,r.z],[i.x,i.y,r.z],[r.x,r.y,i.z],[i.x,r.y,i.z],[r.x,i.y,i.z],[i.x,i.y,i.z]];for(const[o,l,c]of s){const f=a[0]*o+a[4]*l+a[8]*c+a[12],h=a[1]*o+a[5]*l+a[9]*c+a[13],u=a[2]*o+a[6]*l+a[10]*c+a[14];e.expandByPoint(new g(f,h,u))}return e}splatColor;transformA;transformB;texParams;_texParamDirty=!0;splatOrder;gsplatMaterial;_colorData;_transformAData;_transformBData;_orderData;_positions;_splatSetFlags;_validCount=0;_sortWorker;_lastSentTime=0;_minIntervalMs=16;_centersSent=!1;_lastViewMatrixHash=0;_lastCameraSpeed=0;_adaptiveSorting=!0;_lastPixelCullParams="";_texturesInitialized=!1;_minPixelCoverage=4;_maxPixelCoverage=0;_maxPixelCullDistance=0;_batchSize=128;instanceCount=0;_pendingUpdates=new Set;_autoFlushThreshold=100;_frameCount=0;constructor(){super()}initCount(e,t=128){if(e<=0)throw new Error("Total count must be greater than 0");this.totalCount=e,this._batchSize=t,this.size=this.evalTextureSize(e);const a=this.size.x|0,r=this.size.y|0,i=a*r;this._colorData=new Uint8Array(i*4),this._colorData.fill(0),this._transformAData=new Uint32Array(i*4),this._transformAData.fill(0),this._transformBData=new Array(i*4).fill(0),this._orderData=new Uint32Array(i);for(let s=0;s<i;s++)this._orderData[s]=s<e?s:e>0?e-1:0;this._positions=new Float32Array(e*3),this._positions.fill(0),this.localBoundBox.makeEmpty(),this._splatSetFlags=new Array(e).fill(!1),this._validCount=0,this.texParams=new Float32Array([this._validCount,this.size.x,0,1]),this.splatColor=new Si().create(a,r,this._colorData,!1),this.splatColor.name="splatColor",this.splatColor.minFilter="nearest",this.splatColor.magFilter="nearest",this.splatColor.mipmapFilter="nearest",this.splatColor.addressModeU="clamp-to-edge",this.splatColor.addressModeV="clamp-to-edge",this.transformA=new xn().create(a,r,this._transformAData),this.transformA.name="transformA",this.transformA.minFilter="nearest",this.transformA.magFilter="nearest",this.transformA.addressModeU="clamp-to-edge",this.transformA.addressModeV="clamp-to-edge",this.transformB=new _s().create(a,r,this._transformBData,!1),this.transformB.name="transformB",this.transformB.minFilter="nearest",this.transformB.magFilter="nearest",this.transformB.mipmapFilter="nearest",this.transformB.addressModeU="clamp-to-edge",this.transformB.addressModeV="clamp-to-edge",this.splatOrder=new Ds().create(a,r,this._orderData),this.splatOrder.name="splatOrder",this.splatOrder.minFilter="nearest",this.splatOrder.magFilter="nearest",this.splatOrder.addressModeU="clamp-to-edge",this.splatOrder.addressModeV="clamp-to-edge",this.gsplatMaterial=new Cn,this.geometry=new Sn(this._batchSize),this.materials=[this.gsplatMaterial],this.instanceCount=0}setSplatData(e,t){if(e<0||e>=this.totalCount)throw new Error(`Index ${e} out of range [0, ${this.totalCount})`);const a=this._splatSetFlags[e];this._positions[e*3+0]=t.position[0],this._positions[e*3+1]=t.position[1],this._positions[e*3+2]=t.position[2],this.localBoundBox.expandByPoint(new g(t.position[0],t.position[1],t.position[2]));const r=.28209479177387814;let i=.5,s=.5,o=.5;t.sh&&t.sh.coeffs&&t.sh.coeffs.length>=3&&(i=.5+t.sh.coeffs[0]*r,s=.5+t.sh.coeffs[1]*r,o=.5+t.sh.coeffs[2]*r);const l=t.opacity!==void 0?1/(1+Math.exp(-t.opacity)):1,c=e*4;this._colorData[c+0]=Math.max(0,Math.min(255,Math.floor(i*255))),this._colorData[c+1]=Math.max(0,Math.min(255,Math.floor(s*255))),this._colorData[c+2]=Math.max(0,Math.min(255,Math.floor(o*255))),this._colorData[c+3]=Math.max(0,Math.min(255,Math.floor(l*255))),this.updateTransformData(e,t),a||(this._splatSetFlags[e]=!0,this._validCount++),this._pendingUpdates.add(e)}updateTransformData(e,t){const a=e*4,r=new ArrayBuffer(4),i=new Float32Array(r),s=new Uint32Array(r),o=je=>(i[0]=je,s[0]),l=t.position[0],c=t.position[1],f=t.position[2];this._transformAData[a+0]=o(l),this._transformAData[a+1]=o(c),this._transformAData[a+2]=o(f);let h=0,u=0,b=0,A=1;if(t.rotation){h=t.rotation[0],u=t.rotation[1],b=t.rotation[2],A=t.rotation[3];const je=1/Math.hypot(h,u,b,A);h*=je,u*=je,b*=je,A*=je}let m=1,p=1,D=1;t.scale&&(m=Math.exp(t.scale[0]),p=Math.exp(t.scale[1]),D=Math.exp(t.scale[2]));const _=h+h,v=u+u,U=b+b,y=h*_,S=h*v,F=h*U,k=u*v,x=u*U,w=b*U,R=A*_,Q=A*v,M=A*U,j=1-(k+w),he=S+M,ae=F-Q,P=S-M,z=1-(y+w),W=x+R,V=F+Q,te=x-R,J=1-(y+k),K=j*m,ee=he*m,re=ae*m,oe=P*p,pe=z*p,Te=W*p,Oe=V*D,q=te*D,ie=J*D,ce=K*K+oe*oe+Oe*Oe,ge=K*ee+oe*pe+Oe*q,we=K*re+oe*Te+Oe*ie,me=ee*ee+pe*pe+q*q,ye=ee*re+pe*Te+q*ie,Qe=re*re+Te*Te+ie*ie,Re=a;this._transformBData[Re+0]=ce,this._transformBData[Re+1]=ge,this._transformBData[Re+2]=we,this._transformBData[Re+3]=Qe;const Le=qa(me)&65535,Ut=qa(ye)&65535;this._transformAData[a+3]=Le|Ut<<16}flushUpdates(){if(this._pendingUpdates.size===0)return;const e=this.size.x|0,t=this.size.y|0,a=Array.from(this._pendingUpdates);if(a.length===0)return;let r=t,i=0;for(const l of a){const c=Math.floor(l/e);c<r&&(r=c),c>i&&(i=c)}const s=i-r+1;s/t<.5&&s<t?(this.splatColor.updateTexture(e,t,this._colorData,r,s),this.transformA.updateTexture(e,t,this._transformAData,r,s),this.transformB.updateTexture(e,t,this._transformBData,!1,r,s)):(this.splatColor.updateTexture(e,t,this._colorData),this.transformA.updateTexture(e,t,this._transformAData),this.transformB.updateTexture(e,t,this._transformBData,!1)),this.updatePendingWorldPositions(),this._pendingUpdates.clear()}setAutoFlushThreshold(e){this._autoFlushThreshold=Math.max(1,e)}getStreamingStats(){return{totalCount:this.totalCount,validCount:this._validCount,pendingUpdates:this._pendingUpdates.size,progress:this.totalCount>0?this._validCount/this.totalCount*100:0}}updateWorldPositions(){!this._positions||this._validCount===0||(this._centersSent=!1)}updatePendingWorldPositions(){!this._positions||this._validCount===0||(this._centersSent=!1)}scheduleOrder(e){if(this._validCount===0)return;const t=this.object3D.transform.localChange;t&&this.updateWorldPositions();const a=e.rawData,r=a[2],i=a[6],s=a[10],o=-(a[0]*a[12]+a[1]*a[13]+a[2]*a[14]),l=-(a[4]*a[12]+a[5]*a[13]+a[6]*a[14]),c=-(a[8]*a[12]+a[9]*a[13]+a[10]*a[14]),f=performance.now(),h=(f-this._lastSentTime)/1e3,u=Math.floor(o*1e3)^Math.floor(l*1e3)^Math.floor(c*1e3),b=Math.floor(r*1e3)^Math.floor(i*1e3)^Math.floor(s*1e3),A=u^b;if(A===this._lastViewMatrixHash&&!t&&this._centersSent)return;let m=this._minIntervalMs;if(this._adaptiveSorting&&this._minIntervalMs>0){const D=Math.abs(A-this._lastViewMatrixHash)/Math.max(h,.001);D<1e3?m=this._minIntervalMs:D<1e4?m=this._minIntervalMs*.5:m=this._minIntervalMs*.2,this._lastCameraSpeed=D}if(!(f-this._lastSentTime<m)){if(this._lastViewMatrixHash=A,this._lastSentTime=f,!this._sortWorker){this._sortWorker=this.createSortWorker(),this._sortWorker.onmessage=S=>{const F=S.data.order,k=this._orderData.buffer;this._sortWorker.postMessage({order:k},[k]);const x=new Uint32Array(F),w=this.size.x*this.size.y,R=Math.min(this._validCount,x.length);if((!this._orderData||this._orderData.length!==w)&&(this._orderData=new Uint32Array(w)),this._orderData.set(x.subarray(0,R),0),R<w){const j=this._validCount>0?this._validCount-1:0;this._orderData.fill(j,R,w)}this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData);const Q=Math.max(0,Math.min(this._validCount,S.data.count|0));this.setCount(Q),this._updateTexParams();const M=Math.ceil(Q/this._batchSize);this.instanceCount=M};const p=new Float32Array(this._validCount*3);let D=0;const _=this.object3D.transform.worldMatrix,v=this._positions,U=_.rawData;for(let S=0;S<this._validCount;S++)if(this._splatSetFlags[S]){const F=S*3,k=v[F+0],x=v[F+1],w=v[F+2];p[D*3+0]=U[0]*k+U[4]*x+U[8]*w+U[12],p[D*3+1]=U[1]*k+U[5]*x+U[9]*w+U[13],p[D*3+2]=U[2]*k+U[6]*x+U[10]*w+U[14],D++}const y=new Uint32Array(this.totalCount);for(let S=0;S<this.totalCount;S++)y[S]=S<this._validCount?S:this._validCount>0?this._validCount-1:0;this._sortWorker.postMessage({order:y.buffer,centers:p.buffer},[y.buffer,p.buffer]),this._centersSent=!0}if(!this._centersSent&&this._sortWorker){const p=new Float32Array(this._validCount*3);let D=0;const _=this.object3D.transform.worldMatrix,v=this._positions,U=_.rawData;for(let y=0;y<this._validCount;y++)if(this._splatSetFlags[y]){const S=y*3,F=v[S+0],k=v[S+1],x=v[S+2];p[D*3+0]=U[0]*F+U[4]*k+U[8]*x+U[12],p[D*3+1]=U[1]*F+U[5]*k+U[9]*x+U[13],p[D*3+2]=U[2]*F+U[6]*k+U[10]*x+U[14],D++}this._sortWorker.postMessage({type:"centers",centers:p.buffer},[p.buffer]),this._centersSent=!0}this._sortWorker.postMessage({cameraPosition:{x:o,y:l,z:c},cameraDirection:{x:-r,y:-i,z:-s}})}}createSortWorker(){function e(){let o,l,c,f,h=!1;const u={x:0,y:0,z:0},b={x:0,y:0,z:0},A={x:0,y:0,z:0},m={x:0,y:0,z:0};let p,D;const _=(U,y,S)=>{for(;U<=y;){const F=y+U>>1,k=S(F);if(k>0)U=F+1;else if(k<0)y=F-1;else return F}return~U},v=()=>{if(!o||!l||!c||!f)return;const U=c.x,y=c.y,S=c.z,F=f.x,k=f.y,x=f.z,w=.001;if(!h&&Math.abs(U-u.x)<w&&Math.abs(y-u.y)<w&&Math.abs(S-u.z)<w&&Math.abs(F-b.x)<w&&Math.abs(k-b.y)<w&&Math.abs(x-b.z)<w)return;h=!1,u.x=U,u.y=y,u.z=S,b.x=F,b.y=k,b.z=x;const R=l.length/3;p?.length!==R&&(p=new Uint32Array(R));let Q,M;for(let W=0;W<8;++W){const V=(W&1?A.x:m.x)-U,te=(W&2?A.y:m.y)-y,J=(W&4?A.z:m.z)-S,K=V*F+te*k+J*x;W===0?Q=M=K:(Q=Math.min(Q,K),M=Math.max(M,K))}D?D.fill(0):D=new Uint32Array(65537);const j=M-Q,he=j<1e-6?0:1/j*2**16;for(let W=0;W<R;++W){const V=W*3,te=l[V+0]-U,J=l[V+1]-y,K=l[V+2]-S,ee=te*F+J*k+K*x,re=Math.floor((ee-Q)*he);p[W]=re,D[re]++}for(let W=1;W<65537;W++)D[W]+=D[W-1];for(let W=0;W<R;W++){const V=p[W],te=--D[V];o[te]=W}const ae=W=>p[o[W]]/he+Q,P=()=>{const W=_(0,R-1,V=>-ae(V));return Math.min(R,Math.abs(W))},z=ae(R-1)>=0?P():R;self.postMessage({order:o.buffer,count:z},[o.buffer]),o=null};self.onmessage=U=>{if(U.data.order&&(o=new Uint32Array(U.data.order)),U.data.centers){l=new Float32Array(U.data.centers),A.x=m.x=l[0],A.y=m.y=l[1],A.z=m.z=l[2];const y=l.length/3;for(let S=1;S<y;++S){const F=l[S*3+0],k=l[S*3+1],x=l[S*3+2];A.x=Math.min(A.x,F),A.y=Math.min(A.y,k),A.z=Math.min(A.z,x),m.x=Math.max(m.x,F),m.y=Math.max(m.y,k),m.z=Math.max(m.z,x)}h=!0}U.data.cameraPosition&&(c=U.data.cameraPosition),U.data.cameraDirection&&(f=U.data.cameraDirection),v()}}const t=`(${e.toString()})()`,a=new Blob([t],{type:"application/javascript"}),r=URL.createObjectURL(a);return new Worker(r)}setVisBoost(e){this.texParams[3]=Math.max(0,e),this._texParamDirty=!0}setCount(e){this.texParams[0]=Math.max(0,e),this._texParamDirty=!0}_updateTexParams(){this._texParamDirty&&(this.gsplatMaterial.setTexParams(this.texParams),this._texParamDirty=!1)}setSortThrottle(e){this._minIntervalMs=Math.max(0,e|0)}setAdaptiveSorting(e){this._adaptiveSorting=e}setPixelCulling(e,t=0,a=0){this._minPixelCoverage=Math.max(0,e),this._maxPixelCoverage=Math.max(0,t),this._maxPixelCullDistance=Math.max(0,a)}getPixelCullingStats(){return{minPixels:this._minPixelCoverage,maxPixels:this._maxPixelCoverage,maxPixelCullDistance:this._maxPixelCullDistance,maxEnabled:this._maxPixelCoverage>0,distanceEnabled:this._maxPixelCullDistance>0}}getBatchingStats(){return{enabled:!0,batchSize:this._batchSize,instanceCount:this.instanceCount,splatCount:this._validCount,reduction:this._validCount>0?(1-this.instanceCount/this._validCount)*100:0}}evalTextureSize(e){let t=Math.ceil(Math.sqrt(e));const a=64;t=Math.ceil(t/a)*a;const r=Math.ceil(e/t);return new fe(t,r)}nodeUpdate(e,t,a,r){this._validCount>0&&e?.camera&&e.camera.viewMatrix&&this.scheduleOrder(e.camera.viewMatrix),this._pendingUpdates.size>0&&this._frameCount>=60&&this.flushUpdates(),this._frameCount>=60&&this._pendingUpdates.size===0&&(this._frameCount=0),this._frameCount++,this._updateTexParams();const i=this.object3D.transform.worldMatrix;this.gsplatMaterial.setTransformMatrix(i);const s=`${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;s!==this._lastPixelCullParams&&(this.gsplatMaterial.setPixelCulling(this._minPixelCoverage,this._maxPixelCoverage,this._maxPixelCullDistance,this._batchSize),this._lastPixelCullParams=s),this._texturesInitialized||(this.gsplatMaterial.setSplatTextures(this.splatColor,this.transformA,this.transformB,this.texParams,this.splatOrder),this._texturesInitialized=!0),super.nodeUpdate(e,t,a,r)}renderPass(e,t,a){const r=a.encoder;for(let i of this.materials){const s=i.getPass(t);if(!(!s||s.length===0))for(const o of s){if(!o.pipeline)continue;o.apply(this.geometry,a.rendererPassState||a),E.bindPipeline(r,o),E.bindGeometryBuffer(r,this.geometry);const c=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?E.drawIndexed(r,c.indexCount,this.instanceCount,c.indexStart,0,0):E.drawIndexed(r,c.indexCount,1,c.indexStart,0,0)}}}destroy(e){this._sortWorker&&(this._sortWorker.terminate(),this._sortWorker=null),this.splatColor&&(this.splatColor.destroy(e),this.splatColor=null),this.transformA&&(this.transformA.destroy(e),this.transformA=null),this.transformB&&(this.transformB.destroy(e),this.transformB=null),this.splatOrder&&(this.splatOrder.destroy(e),this.splatOrder=null),this._positions=null,this._orderData=null,this._colorData=null,this._transformAData=null,this._transformBData=null,this.texParams=null,this._splatSetFlags=null,this._pendingUpdates.clear(),super.destroy(e)}},d.GSplatStreamRenderer=gg([Nt(d.GSplatStreamRenderer,"GSplatStreamRenderer")],d.GSplatStreamRenderer);class eh extends d.Object3D{index=0;drawCallFrame=-1;constructor(){super()}}var Fo=(n=>(n[n.CastGI=0]="CastGI",n[n.ReceiveGI=1]="ReceiveGI",n[n.CastDepth=2]="CastDepth",n[n.Other=3]="Other",n))(Fo||{});class th extends Dt{static count=0;constructor(e=0,t=0){super(),X.register("GIProbeShader",Dd);let a=new gt,r=new qe("GIProbeShader","GIProbeShader");r.passType=de.COLOR,a.addRenderPass(r),r.setDefine("USE_BRDF",!0),r.setShaderEntry("VertMain","FragMain"),r.setUniformVector4("probeUniform",new ue(t,e,0,0));let i=r.shaderState;i.acceptShadow=!1,i.castShadow=!1,i.receiveEnv=!1,i.acceptGI=!1,i.useLight=!1,a.setTexture("baseMap",B.res.whiteTexture),a.setTexture("normalMap",B.res.normalTexture),a.setTexture("emissiveMap",B.res.blackTexture),this.shader=a}}class mg extends $e{_probes;_volume;_debugMr=[];init(e){e||=B.views[0]?.scene,B.setting.gi.enable=!0,this._volume=ve.getLightEntries(e).irradianceVolume,this.initProbe(e)}initProbe(e){let t=this._volume.setting.probeXCount,a=this._volume.setting.probeYCount,r=this._volume.setting.probeZCount,i=new Ir(4,16,16),s=new g;this._probes=[];for(let o=0;o<t;o++)for(let l=0;l<a;l++)for(let c=0;c<r;c++){let f=o+c*t+l*(t*r),h=new eh;h.index=f,h.name=`${o}_${l}_${c}`;let u=h.addComponent(d.MeshRenderer);u.material=new th(Fo.CastGI,f),u.geometry=i,u.castGI=!1,u.castShadow=!1,this._debugMr.push(u),this.object3D.addChild(h),this._volume.calcPosition(o,l,c,s),h.x=s.x,h.y=s.y,h.z=s.z,this._probes[f]=h,this._debugMr.push(u)}for(let o=0;o<this._probes.length;o++)$.instance.addGIProbe(e,this._probes[o]);this.object3D.transform.enable=!1,this._volume.setting.debug&&this.debug()}debug(){}debugProbeRay(e,t){const a=B.setting.gi.rayNumber;let r=new ne(0,-.7071067811865475,.7071067811865475,0);for(let i=0;i<a;i++){let s=e*a+i,o=new g(-t[s*4+0],-t[s*4+1],-t[s*4+2],0);r.transformVector(o,o);let l=t[s*4+3],c=this._probes[e].transform.worldPosition.clone(),f=o.scaleBy(l);f.add(c,f)}}changeProbesVolumeData(){this._volume.setVolumeDataChange()}changeProbesPosition(){this._volume.setVolumeDataChange();let e=this._volume.setting.probeXCount,t=this._volume.setting.probeYCount,a=this._volume.setting.probeZCount,r=new g;for(let i=0;i<e;i++)for(let s=0;s<t;s++)for(let o=0;o<a;o++){let l=i+o*e+s*(e*a),c=this._probes[l];this._volume.calcPosition(i,s,o,r),c.x=r.x,c.y=r.y,c.z=r.z}}onUpdate(){B.setting.gi.maxDistance=B.setting.gi.probeSpace*1.5;let e=this.transform.scene3D.view.camera,t=g.distance(e.transform.worldPosition,e.transform.targetPos)/300;if(this._debugMr&&this._debugMr.length>0)for(let a=0;a<this._debugMr.length;a++){const r=this._debugMr[a].transform;r.scaleX=t,r.scaleY=t,r.scaleZ=t}}}class pg extends Ba{_keyRenderGroup;_keyBufferGroup;_keyIdsGroup;constructor(){super()}init(e){this._keyRenderGroup=new Map,this._keyBufferGroup=new Map,this._keyIdsGroup=new Map}start(){let e=[];this.object3D.getComponents(d.MeshRenderer,e,!0);for(let t=0;t<e.length;t++){const a=e[t];a.transform.updateWorldMatrix(!0),a.enable=!1;let r=a.geometry.instanceID;for(let i=0;i<a.materials.length;i++){const s=a.materials[i];r+=s.instanceID}if(this._keyRenderGroup.has(r))this._keyRenderGroup.get(r).push(a),this._keyIdsGroup.get(r).push(a.transform.worldMatrix.index);else{let i=new Pe(e.length);i.visibility=GPUShaderStage.VERTEX,this._keyRenderGroup.set(r,[a]),this._keyBufferGroup.set(r,i),this._keyIdsGroup.set(r,[a.transform.worldMatrix.index])}}this._keyBufferGroup.forEach((t,a)=>{let r=this._keyIdsGroup.get(a),i=this._keyBufferGroup.get(a);i.setInt32Array("matrixIDs",new Int32Array(r)),i.apply()})}reset(){this._keyRenderGroup.size>0&&(this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this.start())}nodeUpdate(e,t,a,r){this._keyRenderGroup.forEach((i,s)=>{let o=this._keyBufferGroup.get(s),l=i[0];for(let c=0;c<l.materials.length;c++){let h=l.materials[c].getPass(t);if(h)for(let u=0;u<h.length;u++){const b=h[u];b.setDefine("USE_INSTANCEDRAW",!0),b.setStorageBuffer("instanceDrawID",o)}}l.nodeUpdate(e,t,a,r)})}renderPass(e,t,a){this._keyRenderGroup.forEach((r,i)=>{let s=r[0];s.instanceCount=r.length,this.renderItem(e,t,s,a)})}renderItem(e,t,a,r){let i=a.transform._worldMatrix;for(let s=0;s<a.materials.length;s++){let l=a.materials[s].getPass(t);if(!(!l||l.length==0))for(let c=0;c<l.length;c++){let f=l[c];E.bindGeometryBuffer(r.encoder,a.geometry);const h=f;h.shaderState.splitTexture&&(r.endRenderPass(),wt.WriteSplitColorTexture(a.instanceID),r.beginOpaqueRenderPass(),E.bindCamera(r.encoder,e.camera),E.bindGeometryBuffer(r.encoder,a.geometry)),E.bindPipeline(r.encoder,h);let m=a.geometry.subGeometries[s].lodLevels[a.lodLevel];a.instanceCount>0?E.drawIndexed(r.encoder,m.indexCount,a.instanceCount,m.indexStart,0,0):E.drawIndexed(r.encoder,m.indexCount,1,m.indexStart,0,i.index)}}}beforeDestroy(e){this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this._keyRenderGroup=this._keyBufferGroup=this._keyIdsGroup=void 0,Ne.removeWaitStart(this.object3D,this)}}var Ag=Object.getOwnPropertyDescriptor,Dg=(n,e,t,a)=>{for(var r=a>1?void 0:a?Ag(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.MeshFilter=class extends d.MeshRenderer{constructor(){super()}get geometry(){return null}set geometry(e){}cloneTo(e){}set meshURL(e){let t=B.res.getGeometry(e);t?this.geometry=t:console.error("no geometry set",e)}},d.MeshFilter=Dg([Nt(d.MeshFilter,"MeshFilter")],d.MeshFilter);var _g=Object.getOwnPropertyDescriptor,Bg=(n,e,t,a)=>{for(var r=a>1?void 0:a?_g(e,t):e,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(r)||r);return r};d.SkinnedMeshRenderer=class extends d.MeshRenderer{skinJointsName;mInverseBindMatrixData;mInverseBindMatrixBuffer;mSkeletonAnimation;mJointIndexTableBuffer;constructor(){super(),this.addRendererMask(Me.SkinnedMesh)}start(){if(super.start(),this.skeletonAnimation=this.object3D.getComponent(d.SkeletonAnimationComponent),!this.skeletonAnimation){let e=this.object3D.parentObject.parentObject.getComponentsInChild(d.SkeletonAnimationComponent);e.length>0&&(this.skeletonAnimation=e[0]);let t=this.object3D;for(;!this.skeletonAnimation&&t;)this.skeletonAnimation=t.getComponentFromParent(d.SkeletonAnimationComponent),t.parent&&(t=t.parent.object3D)}}onEnable(){super.onEnable()}get skeletonAnimation(){return this.mSkeletonAnimation}set skeletonAnimation(e){if(this.mSkeletonAnimation=e,!!e&&!this.mJointIndexTableBuffer){let t=this.mSkeletonAnimation.getJointIndexTable(this.skinJointsName);this.mJointIndexTableBuffer=new Pe(t.length*4,0,new Float32Array(t)),this.mJointIndexTableBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}}get skinInverseBindMatrices(){return this.mInverseBindMatrixData}set skinInverseBindMatrices(e){this.mInverseBindMatrixData=e;var t=new Float32Array(e.length*16);for(let a=0;a<e.length;a++){let r=a*16,i=e[a];t.set(i,r)}this.mInverseBindMatrixBuffer=new Pe(t.byteLength,0,t),this.mInverseBindMatrixBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}get inverseBindMatrixBuffer(){return this.mInverseBindMatrixBuffer}get jointIndexTableBuffer(){return this.mJointIndexTableBuffer.buffer}cloneTo(e){let t=e.addComponent(d.SkinnedMeshRenderer);t.geometry=this.geometry,t.material=this.material.clone(),t.castShadow=this.castShadow,t.castGI=this.castGI,t.receiveShadow=this.receiveShadow,t.rendererMask=this.rendererMask,t.skinJointsName=this.skinJointsName,t.skinInverseBindMatrices=this.skinInverseBindMatrices,t.mJointIndexTableBuffer=this.mJointIndexTableBuffer}nodeUpdate(e,t,a,r){for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(t);if(o)for(let l=0;l<o.length;l++){const c=o[l];!c.pipeline&&this.mSkeletonAnimation&&(c.setStorageBuffer("jointsMatrixIndexTable",this.mSkeletonAnimation.jointMatrixIndexTableBuffer),c.setStorageBuffer("jointsInverseMatrix",this.mInverseBindMatrixBuffer),c.setStorageBuffer("jointsIndexMapingTable",this.mJointIndexTableBuffer))}}super.nodeUpdate(e,t,a,r)}},d.SkinnedMeshRenderer=Bg([Nt(d.SkinnedMeshRenderer,"SkinnedMeshRenderer")],d.SkinnedMeshRenderer);class vg extends ut{radius=2.5;height=10;constructor(){super(),this._shapeType=ni.Capsule}}class Ms extends ut{mesh;static triangle;_pickRet;constructor(){super(),this._shapeType=ni.Mesh}rayPick(e,t){if(this.mesh){Ms.triangle||=new Zi(new g,new g,new g);let a=this.mesh.getAttribute(G.position),r=this.mesh.getAttribute(G.indices),i=ut.helpMatrix;i.copyFrom(t).invert();let s=ut.helpRay.copy(e);if(s.applyMatrix(i),s.intersectBox(this.mesh.bounds),!s.intersectBox(this.mesh.bounds,ut.v3_help_0))return null;if(r&&a&&r.data.length>0){let l=a.data;for(let c=0,f=r.data.length/3;c<f;c++){let h=c*3;const u=r.data[h+0]*3,b=r.data[h+1]*3,A=r.data[h+2]*3;let m=Ms.triangle,p=m.v1.set(l[u+0],l[u+1],l[u+2]),D=m.v2.set(l[b+0],l[b+1],l[b+2]),_=m.v3.set(l[A+0],l[A+1],l[A+2]);m.set(p,D,_);let v=s.intersectTriangle(s.origin,s.direction,m);if(v){this._pickRet||={intersectPoint:new g,distance:0},this._pickRet.intersectPoint=v,this._pickRet.distance=g.distance(s.origin,v);let U=this.mesh.getAttribute(G.normal);if(U){let y=U.data,S=new g(y[u],y[u+1],y[u+2]);t.transformVector(S,S),S.normalize(),this._pickRet.normal=S}return this._pickRet}}}}return null}}class Ug extends ut{_pickRet;box;radius=.5;constructor(e){super(),this._shapeType=ni.Sphere,this.radius=e,this.box=new Tr(new g,1)}rayPick(e,t){this.box.setFromCenterAndSize(this.center,this.radius);let r=ut.helpMatrix;r.copyFrom(t).invert();let i=ut.helpRay.copy(e);i.applyMatrix(r);let s=i.intersectSphere(i.origin,i.direction,this.box.center,this.box.radius);return s?(this._pickRet||(this._pickRet={intersect:!1,intersectPoint:new g,distance:0}),this._pickRet.intersect=!0,this._pickRet.intersectPoint=s,this._pickRet.distance=g.distance(i.origin,ut.v3_help_0),this._pickRet):null}}class yg extends d.Object3D{_envMap;skyObject;envMapChange=!0;view;constructor(){super(),this.transform.scene3D=this,this.skyObject=new d.Object3D,this.addChild(this.skyObject),this._isScene3D=!0,this.envMap||=B.res.defaultSky}get envMap(){return this._envMap}set envMap(e){this._envMap!=e&&(this.envMapChange=!0),this._envMap=e,$.instance.sky&&"map"in $.instance.sky&&($.instance.sky.map=e)}get exposure(){return $.instance.sky&&"exposure"in $.instance.sky?$.instance.sky.exposure:0}set exposure(e){$.instance.sky&&"exposure"in $.instance.sky&&($.instance.sky.exposure=e,B.setting.sky.skyExposure=e)}get roughness(){if($.instance.sky&&"roughness"in $.instance.sky)return $.instance.sky.roughness}set roughness(e){$.instance.sky&&"roughness"in $.instance.sky&&($.instance.sky.roughness=e)}}class ah{_computeShader;_outBuffer;constructor(){}init(){let e=Be.getGBufferFrame(Be.colorPass_GBuffer);this._computeShader=new Se(ad),this._outBuffer=new ei(32),this._computeShader.setStorageBuffer("outBuffer",this._outBuffer),this._computeShader.setSamplerTexture("gBufferTexture",e.getCompressGBufferTexture())}compute(e){let t=ve.getCameraGroup(e.camera);this._computeShader.setStorageBuffer("globalUniform",t.uniformGPUBuffer);let a=E.beginCommandEncoder();E.computeCommand(a,[this._computeShader]),E.endCommandEncoder(a),this._outBuffer.readBuffer()}getPickMeshID(){var e=this._outBuffer.outFloat32Array[0]+.1;return Math.floor(e)}getPickWorldPosition(e){e||=new g;var t=this._outBuffer.outFloat32Array[4],a=this._outBuffer.outFloat32Array[5],r=this._outBuffer.outFloat32Array[6];return e.set(t,a,r),e}getPickWorldNormal(e){e||=new g;var t=this._outBuffer.outFloat32Array[8],a=this._outBuffer.outFloat32Array[9],r=this._outBuffer.outFloat32Array[10];return e.set(t*2-1,a*2-1,r*2-1).normalize(),e}getPickScreenUV(e){e||=new fe;var t=this._outBuffer.outFloat32Array[2],a=this._outBuffer.outFloat32Array[3];return e.set(t,a),e}}class rh extends ja{ray;isTouching=!1;_mouseCode;_pickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_mouseMove;_pickCompute;_lastDownTarget;mouseEnableMap;_view;constructor(e){super(),this._view=e,this.init()}init(){this.ray=new na,this.mouseEnableMap=new Map,this._pickEvent=new Y(Y.PICK_CLICK),this._outEvent=new Y(Y.PICK_OUT),this._overEvent=new Y(Y.PICK_OVER),this._mouseMove=new Y(Y.PICK_MOVE),this._upEvent=new Y(Y.PICK_UP),this._downEvent=new Y(Y.PICK_DOWN)}start(){B.setting.pick.enable&&(B.inputSystem.addEventListener(Y.POINTER_DOWN,this.onTouchStart,this),B.inputSystem.addEventListener(Y.POINTER_UP,this.onTouchEnd,this),B.inputSystem.addEventListener(Y.POINTER_CLICK,this.onTouchOnce,this),B.inputSystem.addEventListener(Y.POINTER_RIGHT_CLICK,this.onTouchOnce,this),B.inputSystem.addEventListener(Y.POINTER_MOVE,this.onTouchMove,this)),B.setting.pick.mode=="pixel"&&(this._pickCompute=new ah,this._pickCompute.init())}stop(){B.inputSystem.removeEventListener(Y.POINTER_DOWN,this.onTouchStart,this),B.inputSystem.removeEventListener(Y.POINTER_UP,this.onTouchEnd,this),B.inputSystem.removeEventListener(Y.POINTER_CLICK,this.onTouchOnce,this),B.inputSystem.removeEventListener(Y.POINTER_RIGHT_CLICK,this.onTouchOnce,this),B.inputSystem.removeEventListener(Y.POINTER_MOVE,this.onTouchMove,this)}onTouchStart(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);this._lastDownTarget=t,t&&(Object.assign(this._downEvent,e),this._downEvent.type=Y.PICK_DOWN,this._downEvent.target=t.object3D,this._downEvent.data=this.getPickInfo(),this.dispatchEvent(this._downEvent),t.object3D.containEventListener(Y.PICK_DOWN)&&t.object3D.dispatchEvent(this._downEvent))}onTouchEnd(e){this.isTouching=!1,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._upEvent,e),this._upEvent.type=Y.PICK_UP,this._upEvent.target=t.object3D,this._upEvent.data=this.getPickInfo(),this.dispatchEvent(this._upEvent),t.object3D.containEventListener(Y.PICK_UP)&&t.object3D.dispatchEvent(this._upEvent))}_lastFocus;getPickInfo(){if(B.setting.pick.mode=="pixel")return{worldPos:this._pickCompute.getPickWorldPosition(),worldNormal:this._pickCompute.getPickWorldNormal(),screenUv:this._pickCompute.getPickScreenUV(),meshID:this._pickCompute.getPickMeshID()};{let e=this._interestList[0];return{worldPos:e.intersectPoint,worldNormal:e.normal,meshID:e.collider.transform.worldMatrix.index,distance:e.distance}}}onTouchMove(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._mouseMove,e),this._mouseMove.type=Y.PICK_MOVE,this._mouseMove.target=t.object3D,this._mouseMove.data=this.getPickInfo(),this.dispatchEvent(this._mouseMove),t.object3D.containEventListener(Y.PICK_MOVE)&&t.object3D.dispatchEvent(this._mouseMove)),t!=this._lastFocus&&(this._lastFocus&&this._lastFocus.object3D&&(Object.assign(this._outEvent,e),this._outEvent.type=Y.PICK_OUT,this._outEvent.target=this._lastFocus.object3D,this._outEvent.data=this.getPickInfo(),this.dispatchEvent(this._outEvent),this._lastFocus.object3D.containEventListener(Y.PICK_OUT)&&this._lastFocus.object3D.dispatchEvent(this._outEvent)),t&&(Object.assign(this._overEvent,e),this._overEvent.type=Y.PICK_OVER,this._overEvent.target=t.object3D,this._overEvent.data=this.getPickInfo(),this.dispatchEvent(this._overEvent),t.object3D.containEventListener(Y.PICK_OVER)&&t.object3D.dispatchEvent(this._overEvent))),this._lastFocus=t}onTouchOnce(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);if(t){let a=this.getPickInfo();Object.assign(this._pickEvent,e),this._pickEvent.type=Y.PICK_CLICK,this._pickEvent.target=t.object3D,this._pickEvent.data=a,this.dispatchEvent(this._pickEvent),t===this._lastDownTarget&&t.object3D.containEventListener(Y.PICK_CLICK)&&t.object3D.dispatchEvent(this._pickEvent)}this._lastDownTarget=null}findNearestObj(e,t){return e.sort((a,r)=>a.distance>r.distance?1:-1),e[0]?.collider}_interestList=[];pick(e){if(this._interestList.length=0,B.setting.pick.mode=="pixel"){this._pickCompute.compute(this._view);let t=this._pickCompute.getPickMeshID(),a=this.mouseEnableMap.get(t);if(a){let r=this._pickCompute.getPickWorldPosition(),i=g.distance(r,this.ray.origin);this._interestList.push({distance:i,collider:a,intersectPoint:r})}}else if(B.setting.pick.mode=="bound"){this.ray=e.screenPointToRay(B.inputSystem.mouseX,B.inputSystem.mouseY);let t,a=Ne.componentsEnablePickerList.get(this._view);if(a)for(const r of a){let i=r[0];i.enable&&(t=i.rayPick(this.ray),t&&(t.collider=i,this._interestList.push(t)))}}}}class Cg extends ns{_camera;_scene;_viewPort;_enablePick=!1;_enable=!0;pickFire;guiPick;canvasList;constructor(e=0,t=0,a=0,r=0){super(),this.canvasList=[],this._viewPort=new ue(e,t,a,r)}get enable(){return this._enable}set enable(e){this._enable=e}get enablePick(){return this._enablePick}set enablePick(e){this._enablePick!=e&&(this.pickFire=new rh(this),this.pickFire.start()),this._enablePick=e}get scene(){return this._scene}set scene(e){this._scene=e,e.view=this,Wt.createBuffer(this),e&&this.canvasList.forEach(t=>{t&&e.addChild(t.object3D)})}get camera(){return this._camera}set camera(e){this._camera=e}get viewPort(){return this._viewPort}set viewPort(e){this._viewPort=e}enableUICanvas(e=0){let t=this.canvasList[e];if(!t){let a=new d.Object3D;a.name="Canvas "+e,t=a.addComponent(zi),t.index=e,this.canvasList[e]=t}return this.scene.addChild(t.object3D),this.guiPick||(this.guiPick=new Wd,this.guiPick.init(this)),t}disableUICanvas(e=0){let t=this.canvasList[e];t&&t.object3D&&t.object3D.removeFromParent()}}class Sg{normal;fixNormal;center;rotateShape;distance=0;index;constructor(e){this.index=e,this.rotateShape=[]}}class xg extends Ve{vScale;uNegate;sections;build(e,t,a,r=1,i=!0){if(a.length<2)throw new Error("path length is not enough");return this.vScale=r,this.uNegate=i,e=e.slice(),t&&e.push(e[0]),this.sections=this.buildSections(e,a),this.buildGeometry(e,this.sections),this.bounds=new Ce(g.ZERO.clone(),new g(100,100,100)),this}buildSections(e,t){let a,r,i,s=[],o=t.length;for(let c=0;c<o;c++){let f=new Sg(c);a=t[c],r=t[c+1],f.center=a.clone(),r==null?(f.normal=i.clone(),f.distance=0):(i=r.subtract(a),f.distance=i.length,f.normal=i.normalize()),s.push(f)}s[0].fixNormal=s[0].normal.clone();for(let c=1;c<o;c++){let f=s[c-1],h=s[c];h.fixNormal=h.normal.add(f.normal).normalize()}let l=new T().identity();for(let c=0;c<o;c++){let f=s[c],h,u;if(c==0)h=g.UP,u=e;else{let b=s[c-1];h=b.fixNormal,u=b.rotateShape}T.fromToRotation(h,f.fixNormal,l);for(let b=0,A=e.length;b<A;b++){let m=l.multiplyPoint3(u[b]);f.rotateShape.push(m)}}return s}buildGeometry(e,t){let a=t.length,r=e.length,i=a*r,s=a-1,o=new Float32Array(i*3),l=new Float32Array(i*3),c=new Float32Array(i*2),f=new Uint32Array(s*(r-1)*6),h=r-1,u=0,b=0,A=[0];for(let p=1;p<r;p++)b+=e[p-1].subtract(e[p]).length,A.push(b);for(let p=0;p<a;p++){let D=t[p];for(let _=0;_<r;_++){let v=(p*r+_)*3,U=D.rotateShape[_].add(D.center);o[v]=U.x,o[v+1]=U.y,o[v+2]=U.z,l[v+1]=1;let y=(p*r+_)*2,S=A[_]/b;c[y]=this.uNegate?1-S:S,c[y+1]=u*this.vScale}u+=D.distance}let m=0;for(let p=0;p<s;p++){let D=p*r;for(let _=0;_<h;_++){let v=_,U=_+1,y=v+r,S=U+r;f[m++]=v+D,f[m++]=U+D,f[m++]=y+D,f[m++]=U+D,f[m++]=S+D,f[m++]=y+D}}return this.setIndices(f),this.setAttribute(G.position,o),this.setAttribute(G.normal,l),this.setAttribute(G.uv,c),this.setAttribute(G.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.computeNormals(),this}}class ih extends Ve{_instanceBuffer;_instanceData;_instanceCount=0;constructor(){super(),this.initBaseGeometry()}initBaseGeometry(){const e=new Float32Array([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0]),t=new Float32Array([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2]),a=new Uint16Array([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]);this.setIndices(a),this.setAttribute(G.position,e),this.setAttribute(G.uv,t),this.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:e.length/3,firstStart:0,index:0,topology:0})}setPositions(e){const t=e instanceof Float32Array?e:new Float32Array(e),r=t.length/3-1;if(r<=0)return console.warn("FatLineGeometry: Need at least 2 points"),this;const i=new Float32Array(r*16);for(let s=0;s<r;s++){const o=s*3,l=(s+1)*3;i[s*16+0]=t[o+0],i[s*16+1]=t[o+1],i[s*16+2]=t[o+2],i[s*16+3]=0,i[s*16+4]=t[l+0],i[s*16+5]=t[l+1],i[s*16+6]=t[l+2],i[s*16+7]=0,i[s*16+8]=1,i[s*16+9]=1,i[s*16+10]=1,i[s*16+11]=0,i[s*16+12]=1,i[s*16+13]=1,i[s*16+14]=1,i[s*16+15]=0}return this._instanceData=i,this._instanceCount=r,this.computeBoundingBox(t),this}setColors(e){const t=e instanceof Float32Array?e:new Float32Array(e);if(!this._instanceData)return console.warn("FatLineGeometry: Must call setPositions() before setColors()"),this;const r=t.length/3-1;if(r!==this._instanceCount)return console.warn("FatLineGeometry: Color array length doesn't match segment count"),this;for(let i=0;i<r;i++){const s=i*3,o=(i+1)*3;this._instanceData[i*16+8]=t[s+0],this._instanceData[i*16+9]=t[s+1],this._instanceData[i*16+10]=t[s+2],this._instanceData[i*16+12]=t[o+0],this._instanceData[i*16+13]=t[o+1],this._instanceData[i*16+14]=t[o+2]}return this}computeBoundingBox(e){const t=new g(1/0,1/0,1/0),a=new g(-1/0,-1/0,-1/0);for(let i=0;i<e.length;i+=3){const s=e[i],o=e[i+1],l=e[i+2];t.x=Math.min(t.x,s),t.y=Math.min(t.y,o),t.z=Math.min(t.z,l),a.x=Math.max(a.x,s),a.y=Math.max(a.y,o),a.z=Math.max(a.z,l)}const r=g.sub(a,t);this.bounds=new Ce(g.ZERO.clone(),r),this.bounds.setFromMinMax(t,a)}get instanceData(){return this._instanceData}get instanceCount(){return this._instanceCount}get instanceBuffer(){return!this._instanceBuffer&&this._instanceData&&(this._instanceBuffer=new Pe(this._instanceData.byteLength),this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply()),this._instanceBuffer}updateInstanceBuffer(){this._instanceBuffer&&this._instanceData&&(this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply())}}class Fg{name;offset;size;arrayStride;stepMode;attributes}class kg{name;format;offset;shaderLocation;stride}var sh=(n=>(n[n.position=3]="position",n[n.normal=3]="normal",n[n.TANGENT=4]="TANGENT",n[n.uv=2]="uv",n[n.TEXCOORD_1=2]="TEXCOORD_1",n[n.color=4]="color",n[n.joints0=4]="joints0",n[n.weights0=4]="weights0",n[n.joints1=4]="joints1",n[n.weights1=4]="weights1",n[n.vIndex=1]="vIndex",n[n.weight=1]="weight",n[n.a_morphPositions_0=3]="a_morphPositions_0",n))(sh||{});class Eg{get data(){return null}entity}class nh{min=0;max=0;set(e,t){return this.max=t,this.min=e,this}copy(e){return this.max=e.max,this.min=e.min,this}isInterestRange(e){return!(this.max>e.min||e.max<this.min)}}class oh{_spaceDesc;getRange(e){return this._spaceDesc[e]}initSpace(e){this._spaceDesc={};for(let t of e)(this._spaceDesc[t]=new nh).set(-Number.MAX_VALUE,Number.MAX_VALUE);return this}isContain(e,t){let a=this._spaceDesc[e];return t>=a.min&&t<a.max}isInterestRange(e,t){let a=this._spaceDesc[e];return a?t.isInterestRange(a):!1}splitSpace(e,t,a){let r=this._spaceDesc[e];return t?r.max=a:r.min=a,this}copySpace(e){for(let t in e._spaceDesc){let a=e._spaceDesc[t];this._spaceDesc[t].copy(a)}return this}}class Yi{static MaxEntityCountInLeaf=4;static MaxLayer=10;static ClearLeafLayer=Yi.MaxLayer-4}class Xi{static UUID=0;uuid="0";constructor(){this.uuid=(Xi.UUID++).toString()}}class wg{map={};_count=0;get count(){return this._count}push(e){return this.map[e.uuid]?!1:(this.map[e.uuid]=e,this._count++,!0)}remove(e){return this.map[e]?(delete this.map[e],this._count--,!0):!1}}class _r extends Xi{_dimensionIndex=0;_dimensions;_dimension;_left;_right;_space;_parent;_entities;layer;get dimension(){return this._dimension}constructor(e=0){super(),this.layer=e,_r.nodeCount++}initNode(e,t,a){return this._dimensions=t,this._dimensionIndex=a,this._dimension=t[a],this._space=new oh().initSpace(t),e&&this._space.copySpace(e._space),this._parent=e,this._entities=new wg,this}updateEntity(e){if(e.isInNode(this,this._dimension)&&(e.attachTreeNode(this),this.autoSplit(),this._left&&this._right)){let t=(this._dimensionIndex+1)%this._dimensions.length,a=this._dimensions[t];e.isInNode(this._right,a)?this._right.updateEntity(e):e.isInNode(this._left,a)&&this._left.updateEntity(e)}}buildRoot(e){for(const t of e)t.entity.attachTreeNode(this);this.autoSplit()}_splitEntityList=[];autoSplit(){if(this._entities.count>Yi.MaxEntityCountInLeaf&&!this._right&&!this._left&&this.layer<Yi.MaxLayer){let e=this._splitEntityList,t=(this._dimensionIndex+1)%this._dimensions.length,a=this._dimensions[t],r=0;for(const i in this._entities.map){let s=this._entities.map[i];r+=s.centerValue(a),e.push(s)}r/=this._entities.count,this._left=new _r(this.layer+1),this._right=new _r(this.layer+1),this._left.initNode(this,this._dimensions,t),this._right.initNode(this,this._dimensions,t),this._left.setSpace(!0,r),this._right.setSpace(!1,r);for(let i of e)i.isInNode(this._right,a)?i.attachTreeNode(this._right):i.isInNode(this._left,a)&&i.attachTreeNode(this._left)}this._left&&this._left.autoSplit(),this._right&&this._right.autoSplit()}setSpace(e,t){return this._parent&&this._space.splitSpace(this._dimension,e,t),this}isEmpty(){return this._left==null&&this._right==null&&this._entities.count==0}pushEntity(e){return this._entities.push(e)}removeEntity(e){return this._entities.remove(e.uuid)}static nodeCount=0;autoClear(){let e=this;for(;e&&e.layer>Yi.ClearLeafLayer&&e.clearLeaf();)e=e._parent}clearLeaf(){let e=!this._left&&!this._right,t=!e&&this._left.isEmpty()&&this._right.isEmpty();return t&&(this._left=this._right=null,_r.nodeCount-=2),e||t}isContain(e){return this._space.isContain(this._dimension,e)}static rangeBox=new Ce(new g(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),new g(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE));nodeIntersectsBox(e){let t=this._space.getRange("x"),a=this._space.getRange("y"),r=this._space.getRange("z"),i=_r.rangeBox;return i.min.set(t.min,a.min,r.min),i.max.set(t.max,a.max,r.max),i.intersectsBox(e)}nodeIntersectsRay(e){let t=this._space.getRange("x"),a=this._space.getRange("y"),r=this._space.getRange("z"),i=_r.rangeBox;return i.min.set(t.min,a.min,r.min),i.max.set(t.max,a.max,r.max),!0}pointCast(e,t=0,a){if(a=a||[],this._entities.count>0){let r=this._entities.map;for(let i in r){let s=r[i],o=s.entityContainPoint(e);!o&&t>0&&(o=s.squareDistanceTo(e,this._dimensions)<=t),o&&a.push(s)}}this._left&&this._left.isContain(e[this._left.dimension])&&this._left.pointCast(e,t,a),this._right&&this._right.isContain(e[this._right.dimension])&&this._right.pointCast(e,t,a)}boxCast(e,t){if(t=t||[],this._entities.count>0){let a=this._entities.map;for(let r in a){let i=a[r];i.entityIntersectsBox(e)&&t.push(i)}}this._left&&this._left.nodeIntersectsBox(e)&&this._left.boxCast(e,t),this._right&&this._right.nodeIntersectsBox(e)&&this._right.boxCast(e,t)}pointIntersect=new g;rayCast(e,t,a){t=t||[],a=a||[];let r=this.pointIntersect;if(this._entities.count>0){let i=this._entities.map;for(let s in i){let o=i[s];o.entityIntersectsRay(e,r)&&(a.push(new g().copyFrom(r)),t.push(o))}}this._left&&this._left.nodeIntersectsRay(e)&&this._left.rayCast(e,t,a),this._right&&this._right.nodeIntersectsRay(e)&&this._right.rayCast(e,t,a)}}class Rg extends Xi{userData;node;constructor(e){super(),this.userData=e}centerValue(e){return 0}isInNode(e,t){return!1}entityContainPoint(e){return!1}squareDistanceTo(e,t){return Number.MAX_VALUE}entityIntersectsBox(e){return!1}entityIntersectsRay(e,t){return!1}attachTreeNode(e){return this.node&&this.detachTreeNode(),this.node=e,this.node.pushEntity(this)}detachTreeNode(){let e=this.node.removeEntity(this);return this.node=null,e}updateNode(e){let t=this.node;t&&this.detachTreeNode(),e.updateEntity(this),t&&t.autoClear()}}class Qt{minPosX=0;minPosY=0;maxPosX=0;maxPosY=0;testID=0;points;offsetPosition;static TINY=1e-6;constructor(){this.points=new Array,this.offsetPosition=new g(0,0,0,0),this.clear()}setAABox(e,t,a,r){this.minPosX=e-a/2-Qt.TINY,this.maxPosX=e+a/2+Qt.TINY,this.minPosY=t-r/2-Qt.TINY,this.maxPosY=t+r/2+Qt.TINY,this.offsetPosition.setTo(0,0,0)}setOffset(e){this.maxPosX+=e.x-this.offsetPosition.x,this.minPosX+=e.x-this.offsetPosition.x,this.minPosY+=e.z-this.offsetPosition.z,this.maxPosY+=e.z-this.offsetPosition.z,this.offsetPosition.copyFrom(e)}setContainRect(e,t,a,r){this.minPosX>e&&(this.minPosX=e),this.minPosY>t&&(this.minPosY=t),this.maxPosX<a&&(this.maxPosX=a),this.maxPosY<r&&(this.maxPosY=r)}clear(){var e=1e9;this.minPosX=this.minPosY=e,this.maxPosX=this.maxPosY=-e,this.points.length=0,this.testID=0,this.offsetPosition.setTo(0,0,0)}addPoint(e){this.points.indexOf(e)==-1&&(e.x<this.minPosX&&(this.minPosX=e.x-Qt.TINY),e.x>this.maxPosX&&(this.maxPosX=e.x+Qt.TINY),e.z<this.minPosY&&(this.minPosY=e.z-Qt.TINY),e.z>this.maxPosY&&(this.maxPosY=e.z+Qt.TINY),this.points.push(e))}clone(){var e=new Qt;return e.minPosX=this.minPosX,e.minPosY=this.minPosY,e.maxPosX=this.maxPosX,e.maxPosY=this.maxPosY,e}get radius(){return Math.sqrt((this.maxPosY-this.minPosY)*(this.maxPosY-this.minPosY)+(this.maxPosX-this.minPosX)*(this.maxPosX-this.minPosX))}get sideX(){return this.maxPosX-this.minPosX}get sideY(){return this.maxPosY-this.minPosY}get centreX(){return(this.maxPosX-this.minPosX)*.5+this.minPosX}get centreY(){return(this.maxPosY-this.minPosY)*.5+this.minPosY}overlapTest(e){return!(this.minPosY>=e.maxPosY||this.maxPosY<=e.minPosY||this.minPosX>=e.maxPosX||this.maxPosX<=e.minPosX)}isPointInside(e){return e.x>=this.minPosX&&e.x<=this.maxPosX&&e.z>=this.minPosY&&e.z<=this.maxPosY}isIntersectLineSegment(e,t,a,r){var i=!1,s=t-r,o=a-e,l=e*r-a*t,c=(-l-s*this.minPosX)/o;c<=this.maxPosY&&c>=this.minPosY&&(i=!0),c=(-l-s*this.maxPosX)/o,c<=this.maxPosY&&c>=this.minPosY&&(i=!0);var f=(-l-o*this.minPosY)/s;return f<=this.maxPosX&&f>=this.minPosX&&(i=!0),f=(-l-o*this.maxPosY)/s,f<=this.maxPosX&&f>=this.minPosX&&(i=!0),i}}class Br{static NUM_CHILDREN=4;childCellIndices;nodeIndices;aabb;points;constructor(e){this.childCellIndices=new Array,this.childCellIndices.length=Br.NUM_CHILDREN,this.nodeIndices=new Array,this.clear(),e?this.aabb=e.clone():this.aabb=new Qt}isLeaf(){return this.childCellIndices[0]==-1}clear(){for(var e=0;e<Br.NUM_CHILDREN;e++)this.childCellIndices[e]=-1;this.nodeIndices.splice(0,this.nodeIndices.length)}}class lh{_cells;_rootCell;_quadNodes;_aabb;_cellsToTest;_testID;constructor(){this._testID=0,this._cells=new Array,this._quadNodes=new Array,this._cellsToTest=new Array,this._aabb=new Qt}getQuadNode(e){return this._quadNodes[e]}clear(){this._cells.length=0,this._quadNodes.length=0}initNodes(e){this.clear();for(var t=0,a=e.length;t<a;)e[t].calcGlobalQuadAABB(),this._quadNodes.push(e[t]),t++}buildQuadTree(e,t){this._aabb.clear();for(var a of this._quadNodes)if(a.isTriangle)for(var r of a.aabb.points)this._aabb.addPoint(r);else this._aabb.setContainRect(a.aabb.minPosX,a.aabb.minPosY,a.aabb.maxPosX,a.aabb.maxPosY);this._cells.length=0,this._rootCell=new Br(this._aabb),this._cells.push(this._rootCell);for(var i=this._quadNodes.length,s=0;s<i;s++)this._cells[0].nodeIndices[s]=s;var o=new Array;o.push(0);for(var l,c,f;o.length!=0;)if(c=o.pop(),!(this._cells[c].nodeIndices.length<=e||this._cells[c].aabb.radius<t)){for(s=0;s<Br.NUM_CHILDREN;s++){this._cells[c].childCellIndices[s]=this._cells.length,o.push(this._cells.length),this._cells.push(new Br(this.createAABox(this._cells[c].aabb,s))),f=this._cells[this._cells.length-1],i=this._cells[c].nodeIndices.length;for(var h=0;h<i;h++)l=this._cells[c].nodeIndices[h],this.doesNodeIntersectCell(this._quadNodes[l],f)&&f.nodeIndices.push(l)}this._cells[c].nodeIndices.length=0}}createAABox(e,t){var a=e.centreX,r=e.centreY,i=e.sideX,s=e.sideY,o=new Qt;switch(t){case 0:o.setAABox(a+i/4,r+s/4,i/2,s/2);break;case 1:o.setAABox(a-i/4,r+s/4,i/2,s/2);break;case 2:o.setAABox(a-i/4,r-s/4,i/2,s/2);break;case 3:o.setAABox(a+i/4,r-s/4,i/2,s/2);break;default:o.setAABox(a+i/4,r-s/4,i/2,s/2);break}return o}doesNodeIntersectCell(e,t){var a=e.aabb;if(!a.overlapTest(t.aabb))return!1;if(!e.isTriangle)return!0;var r=a.points,i=r[0],s=r[1],o=r[2];if(t.aabb.isPointInside(i)||t.aabb.isPointInside(s)||t.aabb.isPointInside(o))return!0;var l=this.pointInTriangle(t.aabb.minPosX,t.aabb.minPosY,i,s,o)||this.pointInTriangle(t.aabb.minPosX,t.aabb.maxPosY,i,s,o)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.maxPosY,i,s,o)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.minPosY,i,s,o);return l?!0:(l=t.aabb.isIntersectLineSegment(i.x,i.z,s.x,s.z)||t.aabb.isIntersectLineSegment(i.x,i.z,o.x,o.z)||t.aabb.isIntersectLineSegment(s.x,s.z,o.x,o.z),l)}getNodesIntersectingtAABox(e,t){if(this._cells.length==0)return 0;this._cellsToTest.length=0,this._cellsToTest.push(0),this.incrementTestCounter();for(var a,r,i,s,o=0;this._cellsToTest.length!=0;)if(a=this._cellsToTest.pop(),i=this._cells[a],!!t.overlapTest(i.aabb))if(i.isLeaf())for(r=i.nodeIndices.length,o=0;o<r;o++)s=this.getQuadNode(i.nodeIndices[o]).aabb,s.testID!=this._testID&&(s.testID=this._testID,t.overlapTest(s)&&e.push(i.nodeIndices[o]));else for(o=0;o<Br.NUM_CHILDREN;o++)this._cellsToTest.push(i.childCellIndices[o]);return e.length}pointInTriangle(e,t,a,r,i){var s=a,o=r,l=i,c=s.z-o.z,f=o.x-s.x,h=s.x*o.z-o.x*s.z,u=o.z-l.z,b=l.x-o.x,A=o.x*l.z-l.x*o.z,m=l.z-s.z,p=s.x-l.x,D=l.x*s.z-s.x*l.z,_=!1,v=c*e+f*t+h,U=u*e+b*t+A,y=m*e+p*t+D;const S=.01;return(v>=-S&&U>=-S&&y>=-S||v<=S&&U<=S&&y<=S)&&(_=!0),_}incrementTestCounter(){if(++this._testID,this._testID==0){for(var e=this._quadNodes.length,t=0;t<e;t++)this._quadNodes[t].aabb.testID=0;this._testID=1}}logDeep=0;logTree(e){if(!(e<0)){this.logDeep++;for(var t=this._cells[e],a="",r=0;r<this.logDeep-1;r++)a+="-|";console.log(a+"i="+e+" "+t.aabb.minPosX.toFixed(2)+" "+t.aabb.maxPosX.toFixed(2)+" "+t.aabb.minPosY.toFixed(2)+" "+t.aabb.maxPosY.toFixed(2));var i;for(i=0;i<t.nodeIndices.length;i++)if(t.nodeIndices[i]>=0){var s=this._quadNodes[t.nodeIndices[i]];console.log(a+" t="+t.nodeIndices[i]+" "+s.aabb.minPosX.toFixed(2)+" "+s.aabb.maxPosX.toFixed(2)+" "+s.aabb.minPosY.toFixed(2)+" "+s.aabb.maxPosY.toFixed(2))}for(i=0;i<t.childCellIndices.length;i++)t.childCellIndices[i]>=0&&this.logTree(t.childCellIndices[i]);this.logDeep--}}}class ch{_maxNodesPerCell;_minCellSize;_quadTree;_collisionNodesIdx;_segBox;_collisionNodes;constructor(e=10,t=500){this._maxNodesPerCell=e,this._minCellSize=t,this._segBox=new Qt,this._collisionNodesIdx=new Array,this._collisionNodes=new Array}createQuadTree(e){this._quadTree=new lh,this._quadTree.initNodes(e),this._quadTree.buildQuadTree(this._maxNodesPerCell,this._minCellSize)}getNodesByAABB(e,t,a,r){this._segBox.clear(),this._segBox.maxPosX=a,this._segBox.maxPosY=r,this._segBox.minPosX=e,this._segBox.minPosY=t,this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var i,s=0;s<this._collisionNodesIdx.length;s++)i=this._quadTree.getQuadNode(this._collisionNodesIdx[s]),this._collisionNodes.push(i);return this._collisionNodes}getTriangleAtPoint(e,t=5){this._segBox.clear(),this._segBox.setAABox(e.x,e.z,1,1),this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var a=4294967295,r=0,i,s,o,l,c=0;c<this._collisionNodesIdx.length;c++)s=this._quadTree.getQuadNode(this._collisionNodesIdx[c]),l=s.aabb,g.pointInsideTriangle(e,l.points[0],l.points[1],l.points[2])&&(o=s,r=Math.abs(o.plane.distance(e)),!(r>t)&&(s==null||r<=a)&&(i=o,a=r));return i}}var Ps=(n=>(n[n.MOUSE_LEFT=0]="MOUSE_LEFT",n[n.MOUSE_MID=1]="MOUSE_MID",n[n.MOUSE_RIGHT=2]="MOUSE_RIGHT",n))(Ps||{});class Ig extends bt{static LOADER_PROGRESS="loaderProgress";static LOADER_COMPLETE="loaderComplete"}class Tg extends bt{static ADDED="added";static REMOVED="removed";static CHILD_ADD_EVENT="childAddEvent";static CHILD_REMOVED="childRemoved"}class Qg extends bt{static SHOW="show";static HIDE="hide";static UPDATE="update"}class Mg{static merge(e,t,a,r){let i=0,s=0;i=Math.max(e.width,i),i=Math.max(t.width,i),i=Math.max(a.width,i),i=Math.max(r.width,i),s=Math.max(e.height,s),s=Math.max(t.height,s),s=Math.max(a.height,s),s=Math.max(r.height,s);let o=new Ie(i,s,le.rgba8unorm),l=new Se(qf);l.setSamplerTexture("textureR",e),l.setSamplerTexture("textureG",t),l.setSamplerTexture("textureB",a),l.setSamplerTexture("textureA",r),l.setStorageTexture("outTex",o),l.workerSizeX=Math.ceil(i/8),l.workerSizeY=Math.ceil(s/8);let c=E.beginCommandEncoder();return E.computeCommand(c,[l]),E.endCommandEncoder(c),o}}class fh{computeShader;setInputes(e,t,a){this.computeShader=new Se(bd(e,t,a,8,8,1));for(let r=0;r<t.length;r++)this.computeShader.setSamplerTexture(`source${r}Map`,t[r]);for(let r=0;r<a.length;r++)this.computeShader.setStorageTexture(`dest${r}Map`,a[r]);e&&this.computeShader.setSamplerTexture("colorMap",e),this.computeShader.workerSizeX=a[0].width/8,this.computeShader.workerSizeY=a[0].height/8,this.computeShader.workerSizeZ=1}}class dh{sourceShader;compute;needUpdate=!0;constructor(e,t){this.sourceShader=t,this.compute=new Se(e),this.init()}init(){}onUpdate(){this.onFrame&&this.onFrame(),this.onOnce&&this.needUpdate&&(this.needUpdate=!1,this.onFrame())}}class hh extends dh{constructor(e){super(rd,e)}init(){let e=new Ie(256,256,le.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);return this.compute.setStorageTexture("sssMap",e),this.sourceShader.setTexture("lutMap",e),e}onFrame(){this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let e=E.beginCommandEncoder();E.computeCommand(e,[this.compute]),E.endCommandEncoder(e)}}class Pg{gpuBuffer;probes;memoryDo;_probeInfoList;initDataUniform(e){this.memoryDo=new or,this.probes=e,this._probeInfoList=[],this.memoryDo.destroy(),this.memoryDo.allocation(e.length*17*4);for(let a=0;a<e.length;a++){var t=17;let r=this.memoryDo.allocation_node(t*4);this._probeInfoList.push(r);let i=e[a].transform.worldPosition;r.setArray(0,[i.x,i.y,i.z])}this.gpuBuffer=I.device.createBuffer({size:this.memoryDo.shareDataBuffer.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE,label:"ProbeBuffer",mappedAtCreation:!1})}updateGPUBuffer(){const e=this.memoryDo.shareDataBuffer;let t=this.memoryDo.shareDataBuffer.byteLength,a=0;const r=5e3*64;for(;a<t;)I.device.queue.writeBuffer(this.gpuBuffer,a,e,a,Math.floor(Math.min(r,t-a))),a+=r}}class Ng extends Za{constructor(e,t,a=0){super(),this.bufferType=ga.StructStorageGPUBuffer,this.createBufferByStruct(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|a,e,t)}}class Vg{static codeMax=`
11790
11790
  @group(0) @binding(0) var inputTexture : texture_2d<f32>;
11791
11791
  @group(0) @binding(1) var inputTextureSampler : sampler;
11792
11792
  @group(0) @binding(2) var outputTexture : texture_storage_2d<rgba8unorm, write>;