@rings-webgpu/core 1.0.49 → 1.0.50

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.
@@ -42326,7 +42326,7 @@ class PostProcessingComponent extends ComponentBase {
42326
42326
  }
42327
42327
  }
42328
42328
 
42329
- const version = "1.0.49";
42329
+ const version = "1.0.50";
42330
42330
 
42331
42331
  class Engine3D {
42332
42332
  /**
@@ -62555,7 +62555,7 @@ class StreamingGaussianSplatParser extends ParserBase {
62555
62555
  _streamParser = null;
62556
62556
  _streamingRenderer = null;
62557
62557
  _rendererObject = null;
62558
- _chunksPerBatch = 1e3;
62558
+ _chunksPerBatch = 1e4;
62559
62559
  // Number of splats to process per batch
62560
62560
  _headerParsed = false;
62561
62561
  _onHeaderParsed = null;
package/dist/rings.umd.js CHANGED
@@ -7919,7 +7919,7 @@ else if (typeof exports === 'object')
7919
7919
  `;class xf{compute;constructor(){this.compute=new Se(Sf)}generateBRDFLUTTexture(){let e=new Re(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 $2{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 $2;class Ff{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 kf{id=0;file=""}class Ef{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 Ff;a.trim().split(t).forEach((i,s)=>{if(s<2)tr.readLineProperty(i,r);else if(s<r.pages+2){let o=new kf;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 Ef;tr.readLineProperty(i,o),r.fontChar[o.id]=o,r.count--}}),a="",this.data=r,await this.loadFontTextures()}getNewLine(e){return e.indexOf(`\r
7920
7920
  `)!=-1?`\r
7921
7921
  `:e.indexOf("\r")!=-1?"\r":`
7922
- `}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 eb(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 wf(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=wf(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 Rf 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 ea=Uint8Array,ii=Uint16Array,tb=Int32Array,Tf=new ea([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]),Qf=new ea([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]),ab=new ea([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mf=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 tb(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}},Pf=Mf(Tf,2),Nf=Pf.b,rb=Pf.r;Nf[28]=258,rb[258]=28;for(var ib=Mf(Qf,0),sb=ib.b,lo=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,lo[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[lo[h]>>l]=c}else for(o=new ii(a),r=0;r<a;++r)n[r]&&(o[r]=lo[s[n[r]-1]++]>>15-n[r]);return o}),Qi=new ea(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 Vf=new ea(32),Xe=0;Xe<32;++Xe)Vf[Xe]=5;var nb=Ti(Qi,9,1),ob=Ti(Vf,5,1),co=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},ya=function(n,e,t){var a=e/8|0;return(n[a]|n[a+1]<<8)>>(e&7)&t},fo=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},lb=function(n){return(n+7)/8|0},ho=function(n,e,t){return(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length),new ea(n.subarray(e,t))},cb=["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"],fa=function(n,e,t){var a=new Error(e||cb[n]);if(a.code=n,Error.captureStackTrace&&Error.captureStackTrace(a,fa),!t)throw a;return a},fb=function(n,e,t,a){var r=n.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new ea(0);var s=!t,o=s||e.i!=2,l=e.i;s&&(t=new ea(r*3));var c=function(ie){var ce=t.length;if(ie>ce){var ge=new ea(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=ya(n,h,1);var _=ya(n,h+1,3);if(h+=3,_)if(_==1)b=nb,A=ob,m=9,p=5;else if(_==2){var S=ya(n,h,31)+257,F=ya(n,h+10,15)+4,k=S+ya(n,h+5,31)+1;h+=14;for(var x=new ea(k),w=new ea(19),I=0;I<F;++I)w[ab[I]]=ya(n,h+I*3,7);h+=F*3;for(var Q=co(w),M=(1<<Q)-1,j=Ti(w,Q,1),I=0;I<k;){var he=j[ya(n,h,M)];h+=he&15;var U=he>>4;if(U<16)x[I++]=U;else{var ae=0,P=0;for(U==16?(P=3+ya(n,h,3),h+=2,ae=x[I-1]):U==17?(P=3+ya(n,h,7),h+=3):U==18&&(P=11+ya(n,h,127),h+=7);P--;)x[I++]=ae}}var z=x.subarray(0,S),W=x.subarray(S);m=co(z),p=co(W),b=Ti(z,m,1),A=Ti(W,p,1)}else fa(1);else{var U=lb(h)+4,v=n[U-4]|n[U-3]<<8,y=U+v;if(y>r){l&&fa(0);break}o&&c(u+v),t.set(n.subarray(U,y),u),e.b=u+=v,e.p=h=y*8,e.f=f;continue}if(h>D){l&&fa(0);break}}o&&c(u+131072);for(var V=(1<<m)-1,te=(1<<p)-1,J=h;;J=h){var ae=b[fo(n,h)&V],K=ae>>4;if(h+=ae&15,h>D){l&&fa(0);break}if(ae||fa(2),K<256)t[u++]=K;else if(K==256){J=h,b=null;break}else{var ee=K-254;if(K>264){var I=K-257,re=Tf[I];ee=ya(n,h,(1<<re)-1)+Nf[I],h+=re}var oe=A[fo(n,h)&te],pe=oe>>4;oe||fa(3),h+=oe&15;var W=sb[pe];if(pe>3){var re=Qf[pe];W+=fo(n,h)&(1<<re)-1,h+=re}if(h>D){l&&fa(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&&fa(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?ho(t,0,u):t.subarray(0,u)},db=new ea(0),Na=function(n,e){return n[e]|n[e+1]<<8},Ca=function(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24)>>>0},uo=function(n,e){return Ca(n,e)+Ca(n,e+4)*4294967296};function hb(n,e){return fb(n,{i:2},e&&e.out,e&&e.dictionary)}var bo=typeof TextDecoder<"u"&&new TextDecoder,ub=0;try{bo.decode(db,{stream:!0}),ub=1}catch{}var bb=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:ho(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 Of(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(bo)return bo.decode(n);var r=bb(n),i=r.s,t=r.r;return t.length&&fa(8),i}}var gb=function(n,e){return e+30+Na(n,e+26)+Na(n,e+28)},mb=function(n,e,t){var a=Na(n,e+28),r=Of(n.subarray(e+46,e+46+a),!(Na(n,e+8)&2048)),i=e+46+a,s=Ca(n,e+20),o=t&&s==4294967295?pb(n,i):[s,Ca(n,e+24),Ca(n,e+42)],l=o[0],c=o[1],f=o[2];return[Na(n,e+10),l,c,r,i+Na(n,e+30)+Na(n,e+32),f]},pb=function(n,e){for(;Na(n,e)!=1;e+=4+Na(n,e+2));return[uo(n,e+12),uo(n,e+4),uo(n,e+20)]};function Ab(n,e){for(var t={},a=n.length-22;Ca(n,a)!=101010256;--a)(!a||n.length-a>65558)&&fa(13);var r=Na(n,a+8);if(!r)return{};var i=Ca(n,a+16),s=i==4294967295||r==65535;if(s){var o=Ca(n,a-12);s=Ca(n,o)==101075792,s&&(r=Ca(n,o+32),i=Ca(n,o+48))}for(var l=0;l<r;++l){var c=mb(n,i,s),f=c[0],h=c[1],u=c[2],b=c[3],A=c[4],m=c[5],p=gb(n,m);i=A,f?f==8?t[b]=hb(n.subarray(p,p+h),{out:new ea(u)}):fa(14,"unknown compression type "+f):t[b]=ho(n,p,p+h)}return t}class vt extends _t{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 Rr 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,U=D*Math.cos(_),v=D*Math.sin(_),y=1/Math.sqrt(U*U+p*p+v*v);if(l[u++]=U,l[u++]=p,l[u++]=v,c[b++]=U*y,c[b++]=p*y,c[b++]=v*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 Rr(.1,32,16),e.material=new vt,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 vt;return l.topology="line-list",l.baseColor=t,l.blendMode=Ae.ADD,l.castReflection=!1,o.geometry=a,o.material=l,s}}class Lf extends rt{static format=Je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Ab(new Uint8Array(e));for(const i in a){const s=a[i],l=new DOMParser().parseFromString(Of(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 Gf{_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 Qt().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 Qt;r==".gltf"?a=await i.load(e,Bt,t):a=await i.load(e,Kn,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 Qt;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 Qt().load(e,io,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 Qt().load(e,oo,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 eo;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 Fs;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 Es;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 qn;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 qn;return await a.loadStd(e),a}async loadJSON(e,t){return await new Qt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new Qt().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 Qt().load(e,Rf,t,e)).data}async loadKMZ(e,t){return(await new Qt().load(e,Lf,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 xf().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Fs,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 $t}}class zf 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 Db="1.0.49";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 R.presentationSize}static get aspect(){return R.aspect}static get width(){return R.windowWidth}static get height(){return R.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",Db),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 R.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(),qa.init(),ve.init(),It.init(),Jt.init(),this.res=new Gf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new al,this.inputSystem.initCanvas(R.canvas)}static startRenderJob(e){let t=new V0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(zf).addPost(Pn),(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]=R.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=R.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)}}R.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 ws=`
7922
+ `}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 eb(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 wf(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=wf(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 Rf 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 ea=Uint8Array,ii=Uint16Array,tb=Int32Array,Tf=new ea([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]),Qf=new ea([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]),ab=new ea([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mf=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 tb(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}},Pf=Mf(Tf,2),Nf=Pf.b,rb=Pf.r;Nf[28]=258,rb[258]=28;for(var ib=Mf(Qf,0),sb=ib.b,lo=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,lo[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[lo[h]>>l]=c}else for(o=new ii(a),r=0;r<a;++r)n[r]&&(o[r]=lo[s[n[r]-1]++]>>15-n[r]);return o}),Qi=new ea(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 Vf=new ea(32),Xe=0;Xe<32;++Xe)Vf[Xe]=5;var nb=Ti(Qi,9,1),ob=Ti(Vf,5,1),co=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},ya=function(n,e,t){var a=e/8|0;return(n[a]|n[a+1]<<8)>>(e&7)&t},fo=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(e&7)},lb=function(n){return(n+7)/8|0},ho=function(n,e,t){return(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length),new ea(n.subarray(e,t))},cb=["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"],fa=function(n,e,t){var a=new Error(e||cb[n]);if(a.code=n,Error.captureStackTrace&&Error.captureStackTrace(a,fa),!t)throw a;return a},fb=function(n,e,t,a){var r=n.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new ea(0);var s=!t,o=s||e.i!=2,l=e.i;s&&(t=new ea(r*3));var c=function(ie){var ce=t.length;if(ie>ce){var ge=new ea(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=ya(n,h,1);var _=ya(n,h+1,3);if(h+=3,_)if(_==1)b=nb,A=ob,m=9,p=5;else if(_==2){var S=ya(n,h,31)+257,F=ya(n,h+10,15)+4,k=S+ya(n,h+5,31)+1;h+=14;for(var x=new ea(k),w=new ea(19),I=0;I<F;++I)w[ab[I]]=ya(n,h+I*3,7);h+=F*3;for(var Q=co(w),M=(1<<Q)-1,j=Ti(w,Q,1),I=0;I<k;){var he=j[ya(n,h,M)];h+=he&15;var U=he>>4;if(U<16)x[I++]=U;else{var ae=0,P=0;for(U==16?(P=3+ya(n,h,3),h+=2,ae=x[I-1]):U==17?(P=3+ya(n,h,7),h+=3):U==18&&(P=11+ya(n,h,127),h+=7);P--;)x[I++]=ae}}var z=x.subarray(0,S),W=x.subarray(S);m=co(z),p=co(W),b=Ti(z,m,1),A=Ti(W,p,1)}else fa(1);else{var U=lb(h)+4,v=n[U-4]|n[U-3]<<8,y=U+v;if(y>r){l&&fa(0);break}o&&c(u+v),t.set(n.subarray(U,y),u),e.b=u+=v,e.p=h=y*8,e.f=f;continue}if(h>D){l&&fa(0);break}}o&&c(u+131072);for(var V=(1<<m)-1,te=(1<<p)-1,J=h;;J=h){var ae=b[fo(n,h)&V],K=ae>>4;if(h+=ae&15,h>D){l&&fa(0);break}if(ae||fa(2),K<256)t[u++]=K;else if(K==256){J=h,b=null;break}else{var ee=K-254;if(K>264){var I=K-257,re=Tf[I];ee=ya(n,h,(1<<re)-1)+Nf[I],h+=re}var oe=A[fo(n,h)&te],pe=oe>>4;oe||fa(3),h+=oe&15;var W=sb[pe];if(pe>3){var re=Qf[pe];W+=fo(n,h)&(1<<re)-1,h+=re}if(h>D){l&&fa(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&&fa(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?ho(t,0,u):t.subarray(0,u)},db=new ea(0),Na=function(n,e){return n[e]|n[e+1]<<8},Ca=function(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16|n[e+3]<<24)>>>0},uo=function(n,e){return Ca(n,e)+Ca(n,e+4)*4294967296};function hb(n,e){return fb(n,{i:2},e&&e.out,e&&e.dictionary)}var bo=typeof TextDecoder<"u"&&new TextDecoder,ub=0;try{bo.decode(db,{stream:!0}),ub=1}catch{}var bb=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:ho(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 Of(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(bo)return bo.decode(n);var r=bb(n),i=r.s,t=r.r;return t.length&&fa(8),i}}var gb=function(n,e){return e+30+Na(n,e+26)+Na(n,e+28)},mb=function(n,e,t){var a=Na(n,e+28),r=Of(n.subarray(e+46,e+46+a),!(Na(n,e+8)&2048)),i=e+46+a,s=Ca(n,e+20),o=t&&s==4294967295?pb(n,i):[s,Ca(n,e+24),Ca(n,e+42)],l=o[0],c=o[1],f=o[2];return[Na(n,e+10),l,c,r,i+Na(n,e+30)+Na(n,e+32),f]},pb=function(n,e){for(;Na(n,e)!=1;e+=4+Na(n,e+2));return[uo(n,e+12),uo(n,e+4),uo(n,e+20)]};function Ab(n,e){for(var t={},a=n.length-22;Ca(n,a)!=101010256;--a)(!a||n.length-a>65558)&&fa(13);var r=Na(n,a+8);if(!r)return{};var i=Ca(n,a+16),s=i==4294967295||r==65535;if(s){var o=Ca(n,a-12);s=Ca(n,o)==101075792,s&&(r=Ca(n,o+32),i=Ca(n,o+48))}for(var l=0;l<r;++l){var c=mb(n,i,s),f=c[0],h=c[1],u=c[2],b=c[3],A=c[4],m=c[5],p=gb(n,m);i=A,f?f==8?t[b]=hb(n.subarray(p,p+h),{out:new ea(u)}):fa(14,"unknown compression type "+f):t[b]=ho(n,p,p+h)}return t}class vt extends _t{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 Rr 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,U=D*Math.cos(_),v=D*Math.sin(_),y=1/Math.sqrt(U*U+p*p+v*v);if(l[u++]=U,l[u++]=p,l[u++]=v,c[b++]=U*y,c[b++]=p*y,c[b++]=v*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 Rr(.1,32,16),e.material=new vt,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 vt;return l.topology="line-list",l.baseColor=t,l.blendMode=Ae.ADD,l.castReflection=!1,o.geometry=a,o.material=l,s}}class Lf extends rt{static format=Je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Ab(new Uint8Array(e));for(const i in a){const s=a[i],l=new DOMParser().parseFromString(Of(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 Gf{_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 Qt().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 Qt;r==".gltf"?a=await i.load(e,Bt,t):a=await i.load(e,Kn,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 Qt;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 Qt().load(e,io,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 Qt().load(e,oo,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 eo;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 Fs;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 Es;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 qn;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 qn;return await a.loadStd(e),a}async loadJSON(e,t){return await new Qt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new Qt().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 Qt().load(e,Rf,t,e)).data}async loadKMZ(e,t){return(await new Qt().load(e,Lf,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 xf().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Fs,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 $t}}class zf 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 Db="1.0.50";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 R.presentationSize}static get aspect(){return R.aspect}static get width(){return R.windowWidth}static get height(){return R.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",Db),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 R.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(),qa.init(),ve.init(),It.init(),Jt.init(),this.res=new Gf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new al,this.inputSystem.initCanvas(R.canvas)}static startRenderJob(e){let t=new V0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(zf).addPost(Pn),(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]=R.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=R.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)}}R.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 ws=`
7923
7923
  struct BloomCfg{
7924
7924
  downSampleStep: f32,
7925
7925
  downSampleBlurSize: f32,
@@ -11849,7 +11849,7 @@ fn frag(){
11849
11849
  `||l[f]==="\r");)f++;const u=l.substring(f).split(/\s+/).filter(q=>q.length>0);let b=0;const A=q=>r.find(ie=>ie.name===q)!=null,m=q=>{if(b>=u.length)throw new Error("PLY: Unexpected end of file");const ie=u[b++];switch(q){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(ie);case"float":case"double":case"float32":case"float64":return parseFloat(ie);default:return parseFloat(ie)}},p=new Float32Array(t*3),D=A("nx")&&A("ny")&&A("nz"),_=D?new Float32Array(t*3):new Float32Array(t*3),U=(A("red")||A("r"))&&(A("green")||A("g"))&&(A("blue")||A("b"))?new Float32Array(t*3):void 0,v=(A("u")||A("s"))&&(A("v")||A("t")),y=i?.some(q=>q.name==="texcoord")||!1,S=v||y?new Float32Array(t*2):void 0,F=new Map,k=i?.some(q=>q.name==="texnumber")||!1,x=k?new Array(a):[],w=[],I=[],Q=[],M=q=>r.findIndex(ie=>ie.name===q),j=M("x"),he=M("y"),ae=M("z"),P=D?M("nx"):-1,z=D?M("ny"):-1,W=D?M("nz"):-1,V=U?M("red")>=0?M("red"):M("r"):-1,te=U?M("green")>=0?M("green"):M("g"):-1,J=U?M("blue")>=0?M("blue"):M("b"):-1,K=S&&v?M("u")>=0?M("u"):M("s"):-1,ee=S&&v?M("v")>=0?M("v"):M("t"):-1;for(let q=0;q<t;q++)for(let ie=0;ie<r.length;ie++){const ce=r[ie],ge=m(ce.type);ie===j?p[q*3+0]=ge:ie===he?p[q*3+1]=ge:ie===ae?p[q*3+2]=ge:ie===P?_[q*3+0]=ge:ie===z?_[q*3+1]=ge:ie===W?_[q*3+2]=ge:ie===V&&U?U[q*3+0]=ce.type==="uchar"||ce.type==="uint8"?ge/255:ge:ie===te&&U?U[q*3+1]=ce.type==="uchar"||ce.type==="uint8"?ge/255:ge:ie===J&&U?U[q*3+2]=ce.type==="uchar"||ce.type==="uint8"?ge/255:ge:ie===K&&S?S[q*2+0]=ge:ie===ee&&S&&(S[q*2+1]=ge)}for(let q=0;q<a;q++){let ie=[],ce,ge=0;for(const ye of i||[])if(ye.name==="vertex_indices"){const Qe=ye.type.split(" "),Ie=Qe[1],Le=Qe[2],yt=m(Ie);ie=[];for(let je=0;je<yt;je++)ie.push(m(Le))}else if(ye.name==="texcoord"){const Qe=ye.type.split(" "),Ie=Qe[1],Le=Qe[2],yt=m(Ie);ce=new Float32Array(yt);for(let je=0;je<yt;je++)ce[je]=m(Le);F.set(q,ce)}else ye.name==="texnumber"&&(ge=m(ye.type),x[q]=ge);const we=ie.length,me=k?x[q]??0:0;if(we===3)w.push(ie[0],ie[1],ie[2]),k&&I.push(me),y&&ce&&ce.length>=6&&Q.push(ce[0],1-ce[1],ce[2],1-ce[3],ce[4],1-ce[5]);else for(let ye=1;ye<we-1;ye++)w.push(ie[0],ie[ye],ie[ye+1]),k&&I.push(me),y&&ce&&ce.length>=we*2&&Q.push(ce[0],1-ce[1],ce[ye*2+0],1-ce[ye*2+1],ce[(ye+1)*2+0],1-ce[(ye+1)*2+1])}if(!D){for(let q=0;q<t*3;q++)_[q]=0;for(let q=0;q<w.length;q+=3){const ie=w[q],ce=w[q+1],ge=w[q+2],we=p[ie*3+0],me=p[ie*3+1],ye=p[ie*3+2],Qe=p[ce*3+0],Ie=p[ce*3+1],Le=p[ce*3+2],yt=p[ge*3+0],je=p[ge*3+1],sr=p[ge*3+2],wa=Qe-we,Wa=Ie-me,Ja=Le-ye,ra=yt-we,ja=je-me,ba=sr-ye,Nt=Wa*ba-Ja*ja,Ia=Ja*ra-wa*ba,ga=wa*ja-Wa*ra;_[ie*3+0]+=Nt,_[ie*3+1]+=Ia,_[ie*3+2]+=ga,_[ce*3+0]+=Nt,_[ce*3+1]+=Ia,_[ce*3+2]+=ga,_[ge*3+0]+=Nt,_[ge*3+1]+=Ia,_[ge*3+2]+=ga}for(let q=0;q<t;q++){const ie=_[q*3+0],ce=_[q*3+1],ge=_[q*3+2],we=Math.sqrt(ie*ie+ce*ce+ge*ge);we>1e-5?(_[q*3+0]=ie/we,_[q*3+1]=ce/we,_[q*3+2]=ge/we):(_[q*3+0]=0,_[q*3+1]=1,_[q*3+2]=0)}}let re=p,oe=_,pe=U,Te,Oe;if(y&&Q.length>0){const q=w.length/3,ie=new Float32Array(q*3*3),ce=new Float32Array(q*3*3),ge=U?new Float32Array(q*3*3):void 0;Te=new Float32Array(Q);for(let me=0;me<q;me++){const ye=me*3,Qe=w[ye+0],Ie=w[ye+1],Le=w[ye+2];ie[me*9+0]=p[Qe*3+0],ie[me*9+1]=p[Qe*3+1],ie[me*9+2]=p[Qe*3+2],ie[me*9+3]=p[Ie*3+0],ie[me*9+4]=p[Ie*3+1],ie[me*9+5]=p[Ie*3+2],ie[me*9+6]=p[Le*3+0],ie[me*9+7]=p[Le*3+1],ie[me*9+8]=p[Le*3+2],ce[me*9+0]=_[Qe*3+0],ce[me*9+1]=_[Qe*3+1],ce[me*9+2]=_[Qe*3+2],ce[me*9+3]=_[Ie*3+0],ce[me*9+4]=_[Ie*3+1],ce[me*9+5]=_[Ie*3+2],ce[me*9+6]=_[Le*3+0],ce[me*9+7]=_[Le*3+1],ce[me*9+8]=_[Le*3+2],ge&&U&&(ge[me*9+0]=U[Qe*3+0],ge[me*9+1]=U[Qe*3+1],ge[me*9+2]=U[Qe*3+2],ge[me*9+3]=U[Ie*3+0],ge[me*9+4]=U[Ie*3+1],ge[me*9+5]=U[Ie*3+2],ge[me*9+6]=U[Le*3+0],ge[me*9+7]=U[Le*3+1],ge[me*9+8]=U[Le*3+2])}re=ie,oe=ce,pe=ge;const we=new Uint32Array(q*3);for(let me=0;me<q*3;me++)we[me]=me;Oe=we}else Oe=new Uint32Array(w),Te=S;return{vertexCount:y&&Q.length>0?re.length/3:t,faceCount:a,position:re,normal:oe,color:pe,uv:Te,indices:Oe,textureFiles:s.length>0?s:void 0,triangleTexnumbers:I.length>0?I:void 0}}function Bh(n){const e=qi(n),{format:t}=e;return t==="ascii"?lm(n,e):om(n,e)}function om(n,e){const{vertexCount:t,properties:a,headerByteLength:r}=e,i=new DataView(n,r),s=m=>a.find(p=>p.name===m)!=null,o=m=>a.findIndex(p=>p.name===m),l=new Float32Array(t*3),c=(s("red")||s("r"))&&(s("green")||s("g"))&&(s("blue")||s("b")),f=s("alpha")||s("a"),h=c?new Uint8Array(t*4):void 0,u=[];let b=0;for(const m of a)u.push(b),b+=ta(m.type);let A=0;for(let m=0;m<t;m++){const p=A,D=o("x"),_=o("y"),U=o("z");if(D<0||_<0||U<0)throw new Error("PLY: Missing x/y/z for vertex");if(l[m*3+0]=be(i,p+u[D],a[D].type),l[m*3+1]=be(i,p+u[_],a[_].type),l[m*3+2]=be(i,p+u[U],a[U].type),h){const v=o("red")>=0?o("red"):o("r"),y=o("green")>=0?o("green"):o("g"),S=o("blue")>=0?o("blue"):o("b"),F=f?o("alpha")>=0?o("alpha"):o("a"):-1;if(v>=0&&y>=0&&S>=0){let k=be(i,p+u[v],a[v].type),x=be(i,p+u[y],a[y].type),w=be(i,p+u[S],a[S].type),I=255;(a[v].type==="float"||a[v].type==="float32"||a[v].type==="double"||a[v].type==="float64")&&(k=Math.round(k*255),x=Math.round(x*255),w=Math.round(w*255)),F>=0&&(I=be(i,p+u[F],a[F].type),(a[F].type==="float"||a[F].type==="float32"||a[F].type==="double"||a[F].type==="float64")&&(I=Math.round(I*255))),h[m*4+0]=Math.max(0,Math.min(255,k)),h[m*4+1]=Math.max(0,Math.min(255,x)),h[m*4+2]=Math.max(0,Math.min(255,w)),h[m*4+3]=Math.max(0,Math.min(255,I))}}A+=b}return{vertexCount:t,position:l,color:h}}function lm(n,e){const{vertexCount:t,properties:a}=e,r=new TextDecoder("utf-8").decode(n),i=r.indexOf("end_header");if(i<0)throw new Error("PLY: Invalid PLY header");let s=i+10;for(;s<r.length&&(r[s]===" "||r[s]===`
11850
11850
  `||r[s]==="\r");)s++;const l=r.substring(s).split(/\s+/).filter(k=>k.length>0);let c=0;const f=k=>a.find(x=>x.name===k)!=null,h=k=>{if(c>=l.length)throw new Error("PLY: Unexpected end of file");const x=l[c++];switch(k){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":return parseInt(x);case"float":case"double":case"float32":case"float64":return parseFloat(x);default:return parseFloat(x)}},u=new Float32Array(t*3),b=(f("red")||f("r"))&&(f("green")||f("g"))&&(f("blue")||f("b")),A=f("alpha")||f("a"),m=b?new Uint8Array(t*4):void 0,p=k=>a.findIndex(x=>x.name===k),D=p("x"),_=p("y"),U=p("z"),v=b?p("red")>=0?p("red"):p("r"):-1,y=b?p("green")>=0?p("green"):p("g"):-1,S=b?p("blue")>=0?p("blue"):p("b"):-1,F=A?p("alpha")>=0?p("alpha"):p("a"):-1;for(let k=0;k<t;k++){for(let x=0;x<a.length;x++){const w=a[x],I=h(w.type);if(x===D)u[k*3+0]=I;else if(x===_)u[k*3+1]=I;else if(x===U)u[k*3+2]=I;else if(x===v&&m){const Q=w.type==="uchar"||w.type==="uint8"?I:Math.round(I*255);m[k*4+0]=Math.max(0,Math.min(255,Q))}else if(x===y&&m){const Q=w.type==="uchar"||w.type==="uint8"?I:Math.round(I*255);m[k*4+1]=Math.max(0,Math.min(255,Q))}else if(x===S&&m){const Q=w.type==="uchar"||w.type==="uint8"?I:Math.round(I*255);m[k*4+2]=Math.max(0,Math.min(255,Q))}else if(x===F&&m){const Q=w.type==="uchar"||w.type==="uint8"?I:Math.round(I*255);m[k*4+3]=Math.max(0,Math.min(255,Q))}}m&&F<0&&(m[k*4+3]=255)}return{vertexCount:t,position:u,color:m}}class $i{_header=null;_headerBuffer=new Uint8Array(4096);_headerLength=0;_headerParsed=!1;_dataBuffer=null;_dataOffset=0;_processedVertices=0;_vertexStride=0;_propOffsets=[];_properties=[];_onHeaderParsed=null;_onSplatParsed=null;_batchSize=1e3;_cancelled=!1;_parseTimeoutId=null;static sVerticesPerChunk=1e7;static sMaxProcessingTime=5;_useIdleCallback=typeof requestIdleCallback<"u";constructor(e,t,a=1e3){this._onHeaderParsed=e,this._onSplatParsed=t,this._batchSize=a}processChunk(e){this._cancelled||(this._headerParsed?this._processDataChunk(e):this._processHeaderChunk(e))}cancel(){this._cancelled=!0,this._parseTimeoutId!==null&&(this._useIdleCallback?cancelIdleCallback(this._parseTimeoutId):clearTimeout(this._parseTimeoutId),this._parseTimeoutId=null)}isCancelled(){return this._cancelled}_processHeaderChunk(e){const t=this._headerLength+e.length;if(t>this._headerBuffer.length){const i=new Uint8Array(Math.max(t,this._headerBuffer.length*2));i.set(this._headerBuffer.subarray(0,this._headerLength)),this._headerBuffer=i}this._headerBuffer.set(e,this._headerLength),this._headerLength+=e.length;const r=new TextDecoder("utf-8").decode(this._headerBuffer.subarray(0,this._headerLength)).indexOf(`end_header
11851
11851
  `);if(r>=0){const i=r+11,s=this._headerBuffer.subarray(0,i),o=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),l=this._parseHeader(o);this._header=l,this._headerParsed=!0,this._initializeDataParsing(l),this._onHeaderParsed&&this._onHeaderParsed(l);const c=this._headerLength-e.length,f=i-c;if(f>0&&f<e.length){const h=e.subarray(f);this._processDataChunk(h)}else f===0&&this._processDataChunk(e)}}_parseHeader(e){const t=new TextDecoder("utf-8").decode(new Uint8Array(e)),a=t.indexOf(`end_header
11852
- `);if(a<0)throw new Error("PLY: Invalid PLY header");const r=t.substring(0,a+11),i=r.split(/\r?\n/);let s="",o=0,l=0;const c=[],f=[],h=[];let u=!1,b=!1;for(const D of i)if(D.startsWith("format "))s=D.split(/\s+/)[1];else if(D.startsWith("comment TextureFile ")){const _=D.substring(20).trim();_&&h.push(_)}else if(D.startsWith("element ")){const _=D.split(/\s+/);u=_[1]==="vertex",b=_[1]==="face",u&&(o=parseInt(_[2]),b=!1),b&&(l=parseInt(_[2]),u=!1)}else if(u&&D.startsWith("property ")){const _=D.split(/\s+/),U=_[1],v=_[2];c.push({name:v,type:U})}else if(b&&D.startsWith("property ")){const _=D.split(/\s+/);if(_[1]==="list"){const U=_[2],v=_[3],y=_[4];f.push({name:y,type:`list ${U} ${v}`})}else{const U=_[1],v=_[2];f.push({name:v,type:U})}}if(s!=="binary_little_endian"&&s!=="ascii")throw new Error(`PLY: Unsupported format: ${s}`);let A=0,m=0;for(const D of c)Ki.includes(D.name)&&A++,wo.includes(D.name)&&m++;let p;return l>0?p=xa.Mesh:A===Ki.length&&m===3?p=xa.Splat:p=xa.PointCloud,{format:s,vertexCount:o,faceCount:l,properties:c,faceProperties:f.length>0?f:void 0,textureFiles:h,headerByteLength:r.length,mode:p}}_initializeDataParsing(e){this._properties=e.properties,this._propOffsets=[],this._vertexStride=0;for(const a of this._properties)this._propOffsets.push(this._vertexStride),this._vertexStride+=ta(a.type);const t=e.vertexCount*this._vertexStride;this._dataBuffer=new Uint8Array(Math.min(t,1024*1024*10)),this._dataOffset=0,this._processedVertices=0}_processDataChunk(e){if(!this._header||!this._dataBuffer)return;const t=this._dataOffset+e.length;if(t>this._dataBuffer.length){const a=Math.max(t,this._dataBuffer.length*2),r=new Uint8Array(a);r.set(this._dataBuffer),this._dataBuffer=r}this._dataBuffer.set(e,this._dataOffset),this._dataOffset+=e.length,this._parseVertices()}_parseVertices(){!this._header||!this._dataBuffer||this._parseTimeoutId===null&&this._parseVerticesChunk()}_parseVerticesChunk(){if(!this._header||!this._dataBuffer||this._cancelled){this._parseTimeoutId=null;return}const e=new DataView(this._dataBuffer.buffer,this._dataBuffer.byteOffset,this._dataBuffer.byteLength),t=this._header.vertexCount,a=o=>this._properties.find(l=>l.name===o)!=null,r=o=>this._properties.findIndex(l=>l.name===o),i=performance.now();let s=0;for(;this._processedVertices<t&&!this._cancelled;){const o=this._processedVertices,l=o*this._vertexStride;if(l+this._vertexStride>this._dataOffset){this._parseTimeoutId=null;return}const c=r("x"),f=r("y"),h=r("z");if(c<0||f<0||h<0)throw new Error("PLY: Missing required x/y/z properties for vertex");const u={position:[be(e,l+this._propOffsets[c],this._properties[c].type),be(e,l+this._propOffsets[f],this._properties[f].type),be(e,l+this._propOffsets[h],this._properties[h].type)]};if(a("scale_0")&&(u.scale=[be(e,l+this._propOffsets[r("scale_0")],this._properties[r("scale_0")].type),be(e,l+this._propOffsets[r("scale_1")],this._properties[r("scale_1")].type),be(e,l+this._propOffsets[r("scale_2")],this._properties[r("scale_2")].type)]),a("rot_0")){const A=be(e,l+this._propOffsets[r("rot_0")],this._properties[r("rot_0")].type),m=be(e,l+this._propOffsets[r("rot_1")],this._properties[r("rot_1")].type),p=be(e,l+this._propOffsets[r("rot_2")],this._properties[r("rot_2")].type),D=be(e,l+this._propOffsets[r("rot_3")],this._properties[r("rot_3")].type);u.rotation=[m,p,D,A]}a("opacity")&&(u.opacity=be(e,l+this._propOffsets[r("opacity")],this._properties[r("opacity")].type));const b=[r("f_dc_0"),r("f_dc_1"),r("f_dc_2")];if(b[0]>=0&&b[1]>=0&&b[2]>=0){const A=[];for(let v=0;v<this._properties.length;v++)this._properties[v].name.startsWith("f_rest_")&&A.push(v);const m=1+A.length/3,p=new Float32Array(m*3);p[0]=be(e,l+this._propOffsets[b[0]],this._properties[b[0]].type),p[m+0]=be(e,l+this._propOffsets[b[1]],this._properties[b[1]].type),p[2*m+0]=be(e,l+this._propOffsets[b[2]],this._properties[b[2]].type);let D=1,_=1,U=1;for(let v=0;v<A.length;v+=3){const y=A[v+0],S=A[v+1],F=A[v+2];p[D]=be(e,l+this._propOffsets[y],this._properties[y].type),p[m+_]=be(e,l+this._propOffsets[S],this._properties[S].type),p[2*m+U]=be(e,l+this._propOffsets[F],this._properties[F].type),D++,_++,U++}u.sh={order:Math.floor(Math.sqrt(m)),coeffs:p}}if(this._onSplatParsed&&this._onSplatParsed(u,o),this._processedVertices++,s++,this._processedVertices%this._batchSize===0){this._scheduleNextChunk();return}if(s>=$i.sVerticesPerChunk){if(performance.now()-i>$i.sMaxProcessingTime){this._scheduleNextChunk();return}s=0}}this._parseTimeoutId=null}_scheduleNextChunk(){if(this._cancelled){this._parseTimeoutId=null;return}this._useIdleCallback?this._parseTimeoutId=requestIdleCallback(e=>{this._parseTimeoutId=null,!this._cancelled&&e.timeRemaining()>0?this._parseVerticesChunk():this._cancelled||(this._parseTimeoutId=setTimeout(()=>{this._parseTimeoutId=null,this._parseVerticesChunk()},0))},{timeout:100}):this._parseTimeoutId=setTimeout(()=>{this._parseTimeoutId=null,this._parseVerticesChunk()},0)}getProgress(){const e=this._header?.vertexCount||0;return{processed:this._processedVertices,total:e,percentage:e>0?this._processedVertices/e*100:0}}}class cm extends rt{static format=Je.BIN;async parseBuffer(e){const t=Dh(e);let a;switch(t){case di.PLY:{const r=Ro(e);a={count:r.vertexCount,position:r.position,rotation:r.rotation,scale:r.scale,opacity:r.opacity,sh:r.sh},a.bbox=Eo(r.position);break}case di.SPLAT:throw new Error("SPLAT format is not yet supported");case di.KSPLAT:throw new Error("KSPLAT format is not yet supported");case di.UNKNOWN:default:throw new Error("Unknown or unsupported Gaussian Splatting file format")}return this.data=a,a}verification(){return!!this.data&&this.data.count>0}}class fm extends rt{static format=Je.BIN;_streamParser=null;_streamingRenderer=null;_rendererObject=null;_chunksPerBatch=1e3;_headerParsed=!1;_onHeaderParsed=null;_cancelled=!1;async initStream(e,t){this._onHeaderParsed=t||null,this._rendererObject=new d.Object3D,this._rendererObject.name="StreamingGaussianSplat",this._streamingRenderer=this._rendererObject.addComponent(d.GSplatStreamRenderer),this._streamParser=new $i(a=>{this._streamingRenderer&&this._streamingRenderer.initCount(a.vertexCount),this._rendererObject&&(this.data=this._rendererObject),this._headerParsed=!0,this._onHeaderParsed&&this._onHeaderParsed()},(a,r)=>{this._streamingRenderer&&this._streamingRenderer.setSplatData(r,a)},this._chunksPerBatch)}async processChunk(e,t,a){this._cancelled||!this._streamParser||this._streamParser.processChunk(e)}cancel(){this._cancelled=!0,this._streamParser&&this._streamParser.cancel()}isCancelled(){return this._cancelled}async finalizeStream(){this._rendererObject&&(this.data=this._rendererObject)}getProgress(){return this._streamParser?this._streamParser.getProgress():{processed:0,total:0,percentage:0}}verification(){return this._headerParsed&&!!this.data&&!!this._streamingRenderer}}var Os=(n=>(n.Point="Point",n.LineString="LineString",n.MultiPolygon="MultiPolygon",n))(Os||{});class dm extends rt{static format=Je.JSON;json;async parseString(e){this.json=e,this.data=JSON.parse(e)}}class hm{static getPath(e){let t=[];for(let a=0;a<e.features.length;a++){const r=e.features[a];switch(r.geometry.type){case Os.LineString:break;case Os.MultiPolygon:let i=[];for(let s=0;s<r.geometry.coordinates.length;s++){const o=r.geometry.coordinates[s];for(const l of o)for(const c of l){let f=new g(c[0],0,c[1]);i.push(f)}}t.push(i);break}}return t}}class um{name;defines;doubleSided;baseColorFactor;emissiveFactor;metallicFactor;roughnessFactor;alphaCutoff;enableBlend;baseColorTexture;metallicRoughnessTexture;normalTexture;occlusionTexture;emissiveTexture;extensions;baseMapOffsetSize;normalMapOffsetSize;emissiveMapOffsetSize;roughnessMapOffsetSize;metallicMapOffsetSize;aoMapOffsetSize}class bm{}class gm{}class Yt{static chunk(e,t){const a=[];let r=0;for(;r<e.length;)a.push(e.slice(r,r+t)),r+=t;return a}static removeComment(e){return e.split(`
11852
+ `);if(a<0)throw new Error("PLY: Invalid PLY header");const r=t.substring(0,a+11),i=r.split(/\r?\n/);let s="",o=0,l=0;const c=[],f=[],h=[];let u=!1,b=!1;for(const D of i)if(D.startsWith("format "))s=D.split(/\s+/)[1];else if(D.startsWith("comment TextureFile ")){const _=D.substring(20).trim();_&&h.push(_)}else if(D.startsWith("element ")){const _=D.split(/\s+/);u=_[1]==="vertex",b=_[1]==="face",u&&(o=parseInt(_[2]),b=!1),b&&(l=parseInt(_[2]),u=!1)}else if(u&&D.startsWith("property ")){const _=D.split(/\s+/),U=_[1],v=_[2];c.push({name:v,type:U})}else if(b&&D.startsWith("property ")){const _=D.split(/\s+/);if(_[1]==="list"){const U=_[2],v=_[3],y=_[4];f.push({name:y,type:`list ${U} ${v}`})}else{const U=_[1],v=_[2];f.push({name:v,type:U})}}if(s!=="binary_little_endian"&&s!=="ascii")throw new Error(`PLY: Unsupported format: ${s}`);let A=0,m=0;for(const D of c)Ki.includes(D.name)&&A++,wo.includes(D.name)&&m++;let p;return l>0?p=xa.Mesh:A===Ki.length&&m===3?p=xa.Splat:p=xa.PointCloud,{format:s,vertexCount:o,faceCount:l,properties:c,faceProperties:f.length>0?f:void 0,textureFiles:h,headerByteLength:r.length,mode:p}}_initializeDataParsing(e){this._properties=e.properties,this._propOffsets=[],this._vertexStride=0;for(const a of this._properties)this._propOffsets.push(this._vertexStride),this._vertexStride+=ta(a.type);const t=e.vertexCount*this._vertexStride;this._dataBuffer=new Uint8Array(Math.min(t,1024*1024*10)),this._dataOffset=0,this._processedVertices=0}_processDataChunk(e){if(!this._header||!this._dataBuffer)return;const t=this._dataOffset+e.length;if(t>this._dataBuffer.length){const a=Math.max(t,this._dataBuffer.length*2),r=new Uint8Array(a);r.set(this._dataBuffer),this._dataBuffer=r}this._dataBuffer.set(e,this._dataOffset),this._dataOffset+=e.length,this._parseVertices()}_parseVertices(){!this._header||!this._dataBuffer||this._parseTimeoutId===null&&this._parseVerticesChunk()}_parseVerticesChunk(){if(!this._header||!this._dataBuffer||this._cancelled){this._parseTimeoutId=null;return}const e=new DataView(this._dataBuffer.buffer,this._dataBuffer.byteOffset,this._dataBuffer.byteLength),t=this._header.vertexCount,a=o=>this._properties.find(l=>l.name===o)!=null,r=o=>this._properties.findIndex(l=>l.name===o),i=performance.now();let s=0;for(;this._processedVertices<t&&!this._cancelled;){const o=this._processedVertices,l=o*this._vertexStride;if(l+this._vertexStride>this._dataOffset){this._parseTimeoutId=null;return}const c=r("x"),f=r("y"),h=r("z");if(c<0||f<0||h<0)throw new Error("PLY: Missing required x/y/z properties for vertex");const u={position:[be(e,l+this._propOffsets[c],this._properties[c].type),be(e,l+this._propOffsets[f],this._properties[f].type),be(e,l+this._propOffsets[h],this._properties[h].type)]};if(a("scale_0")&&(u.scale=[be(e,l+this._propOffsets[r("scale_0")],this._properties[r("scale_0")].type),be(e,l+this._propOffsets[r("scale_1")],this._properties[r("scale_1")].type),be(e,l+this._propOffsets[r("scale_2")],this._properties[r("scale_2")].type)]),a("rot_0")){const A=be(e,l+this._propOffsets[r("rot_0")],this._properties[r("rot_0")].type),m=be(e,l+this._propOffsets[r("rot_1")],this._properties[r("rot_1")].type),p=be(e,l+this._propOffsets[r("rot_2")],this._properties[r("rot_2")].type),D=be(e,l+this._propOffsets[r("rot_3")],this._properties[r("rot_3")].type);u.rotation=[m,p,D,A]}a("opacity")&&(u.opacity=be(e,l+this._propOffsets[r("opacity")],this._properties[r("opacity")].type));const b=[r("f_dc_0"),r("f_dc_1"),r("f_dc_2")];if(b[0]>=0&&b[1]>=0&&b[2]>=0){const A=[];for(let v=0;v<this._properties.length;v++)this._properties[v].name.startsWith("f_rest_")&&A.push(v);const m=1+A.length/3,p=new Float32Array(m*3);p[0]=be(e,l+this._propOffsets[b[0]],this._properties[b[0]].type),p[m+0]=be(e,l+this._propOffsets[b[1]],this._properties[b[1]].type),p[2*m+0]=be(e,l+this._propOffsets[b[2]],this._properties[b[2]].type);let D=1,_=1,U=1;for(let v=0;v<A.length;v+=3){const y=A[v+0],S=A[v+1],F=A[v+2];p[D]=be(e,l+this._propOffsets[y],this._properties[y].type),p[m+_]=be(e,l+this._propOffsets[S],this._properties[S].type),p[2*m+U]=be(e,l+this._propOffsets[F],this._properties[F].type),D++,_++,U++}u.sh={order:Math.floor(Math.sqrt(m)),coeffs:p}}if(this._onSplatParsed&&this._onSplatParsed(u,o),this._processedVertices++,s++,this._processedVertices%this._batchSize===0){this._scheduleNextChunk();return}if(s>=$i.sVerticesPerChunk){if(performance.now()-i>$i.sMaxProcessingTime){this._scheduleNextChunk();return}s=0}}this._parseTimeoutId=null}_scheduleNextChunk(){if(this._cancelled){this._parseTimeoutId=null;return}this._useIdleCallback?this._parseTimeoutId=requestIdleCallback(e=>{this._parseTimeoutId=null,!this._cancelled&&e.timeRemaining()>0?this._parseVerticesChunk():this._cancelled||(this._parseTimeoutId=setTimeout(()=>{this._parseTimeoutId=null,this._parseVerticesChunk()},0))},{timeout:100}):this._parseTimeoutId=setTimeout(()=>{this._parseTimeoutId=null,this._parseVerticesChunk()},0)}getProgress(){const e=this._header?.vertexCount||0;return{processed:this._processedVertices,total:e,percentage:e>0?this._processedVertices/e*100:0}}}class cm extends rt{static format=Je.BIN;async parseBuffer(e){const t=Dh(e);let a;switch(t){case di.PLY:{const r=Ro(e);a={count:r.vertexCount,position:r.position,rotation:r.rotation,scale:r.scale,opacity:r.opacity,sh:r.sh},a.bbox=Eo(r.position);break}case di.SPLAT:throw new Error("SPLAT format is not yet supported");case di.KSPLAT:throw new Error("KSPLAT format is not yet supported");case di.UNKNOWN:default:throw new Error("Unknown or unsupported Gaussian Splatting file format")}return this.data=a,a}verification(){return!!this.data&&this.data.count>0}}class fm extends rt{static format=Je.BIN;_streamParser=null;_streamingRenderer=null;_rendererObject=null;_chunksPerBatch=1e4;_headerParsed=!1;_onHeaderParsed=null;_cancelled=!1;async initStream(e,t){this._onHeaderParsed=t||null,this._rendererObject=new d.Object3D,this._rendererObject.name="StreamingGaussianSplat",this._streamingRenderer=this._rendererObject.addComponent(d.GSplatStreamRenderer),this._streamParser=new $i(a=>{this._streamingRenderer&&this._streamingRenderer.initCount(a.vertexCount),this._rendererObject&&(this.data=this._rendererObject),this._headerParsed=!0,this._onHeaderParsed&&this._onHeaderParsed()},(a,r)=>{this._streamingRenderer&&this._streamingRenderer.setSplatData(r,a)},this._chunksPerBatch)}async processChunk(e,t,a){this._cancelled||!this._streamParser||this._streamParser.processChunk(e)}cancel(){this._cancelled=!0,this._streamParser&&this._streamParser.cancel()}isCancelled(){return this._cancelled}async finalizeStream(){this._rendererObject&&(this.data=this._rendererObject)}getProgress(){return this._streamParser?this._streamParser.getProgress():{processed:0,total:0,percentage:0}}verification(){return this._headerParsed&&!!this.data&&!!this._streamingRenderer}}var Os=(n=>(n.Point="Point",n.LineString="LineString",n.MultiPolygon="MultiPolygon",n))(Os||{});class dm extends rt{static format=Je.JSON;json;async parseString(e){this.json=e,this.data=JSON.parse(e)}}class hm{static getPath(e){let t=[];for(let a=0;a<e.features.length;a++){const r=e.features[a];switch(r.geometry.type){case Os.LineString:break;case Os.MultiPolygon:let i=[];for(let s=0;s<r.geometry.coordinates.length;s++){const o=r.geometry.coordinates[s];for(const l of o)for(const c of l){let f=new g(c[0],0,c[1]);i.push(f)}}t.push(i);break}}return t}}class um{name;defines;doubleSided;baseColorFactor;emissiveFactor;metallicFactor;roughnessFactor;alphaCutoff;enableBlend;baseColorTexture;metallicRoughnessTexture;normalTexture;occlusionTexture;emissiveTexture;extensions;baseMapOffsetSize;normalMapOffsetSize;emissiveMapOffsetSize;roughnessMapOffsetSize;metallicMapOffsetSize;aoMapOffsetSize}class bm{}class gm{}class Yt{static chunk(e,t){const a=[];let r=0;for(;r<e.length;)a.push(e.slice(r,r+t)),r+=t;return a}static removeComment(e){return e.split(`
11853
11853
  `).filter(t=>t.trim().charAt(0)!=="#").join(`
11854
11854
  `)}static convertToValue(e){return+e||/^0|0$/.test(e)?+e:e}static parseSection(e,t){const a=new RegExp(`~${t}(?:\\w*\\s*)*\\n\\s*`,"i"),r=e.split(a);return r.length>1?r[1].split(/~/)[0]:""}static parseParameterLine(e){const t=e.trim();if(!t)return{mnemonic:"",unit:"",value:"",description:""};const a=t.indexOf(":"),r=a>=0?t.substring(0,a).trim():t,i=a>=0?t.substring(a+1).trim():"none",s=r.split(/\s{2,}|\s+/),o=s[0]||"",l=o.indexOf(".");let c="",f="none";l>=0?(c=o.substring(0,l).trim(),f=o.substring(l+1).trim()||"none"):c=o.trim();const h=s.length>1?s[s.length-1].trim():"";return{mnemonic:c.toUpperCase(),unit:f,value:h,description:i||"none"}}}class vh{async parse(e){if(e instanceof ArrayBuffer){const t=new DataView(e);if(ti(t)==="LASF")return await this.parseBinary(e);{const i=new TextDecoder("utf-8",{fatal:!1}).decode(e);return await this.parseText(i)}}else return await this.parseText(e)}async parseText(e){const t=this.parseMetadata(e),a=this.parseWellParams(e),r=this.parseCurveParams(e),i=this.parseHeaders(e),s=a.NULL?.value,o=typeof s=="string"?+s:s,l=this.parseData(e,i,o||-999.25);return{headers:i,data:l,wellParams:a,curveParams:r,metadata:t,nullValue:o||-999.25}}async parseBinary(e){const t=new DataView(e),a=ti(t);if(a!=="LASF")throw new Error(`LASLoader: Invalid binary LAS file, expected 'LASF' magic bytes, got '${a}'`);const r=t.getUint8(24),s=t.getUint8(25)+r/10,o=t.getUint8(104),l=t.getUint32(107,!0),c=t.getFloat64(131,!0),f=t.getFloat64(139,!0),h=t.getFloat64(147,!0),u=t.getFloat64(155,!0),b=t.getFloat64(163,!0),A=t.getFloat64(171,!0),m=t.getFloat64(187,!0),p=t.getFloat64(195,!0),D=t.getFloat64(203,!0),_=t.getFloat64(211,!0),U=t.getFloat64(219,!0),v=t.getFloat64(227,!0),y=t.getUint32(96,!0),S=t.getUint32(100,!0);let F=y;for(let M=0;M<S;M++){const j=t.getUint16(F+54,!0);F+=54+j}const x=[20,28,26,34,57,63,30,36,38,59,67][o]||20;if(o>10)throw new Error(`LASLoader: Unsupported point data format ${o}`);const w=new Float32Array(l*3),I=new Uint8Array(l*4);let Q=F;for(let M=0;M<l;M++){const j=Q+M*x;let he,ae,P;o>=6?(he=Number(t.getBigInt64(j,!0)),ae=Number(t.getBigInt64(j+8,!0)),P=Number(t.getBigInt64(j+16,!0))):(he=t.getInt32(j,!0),ae=t.getInt32(j+4,!0),P=t.getInt32(j+8,!0));const z=he*c+u,W=ae*f+b,V=P*h+A;w[M*3+0]=z,w[M*3+1]=W,w[M*3+2]=V;let te;o>=6?te=j+24:te=j+12;const J=t.getUint16(te,!0);if([2,3,5,7,8,9,10].includes(o)){let K;const ee=j+x;if(o===5?K=j+28:o===10?K=j+59:K=ee-6,K>=j&&K+6<=ee&&K+6<=e.byteLength)try{const re=t.getUint16(K,!0),oe=t.getUint16(K+2,!0),pe=t.getUint16(K+4,!0);I[M*4+0]=re<256?re:re>>8,I[M*4+1]=oe<256?oe:oe>>8,I[M*4+2]=pe<256?pe:pe>>8,I[M*4+3]=255}catch(re){console.warn(`LASLoader: Failed to read RGB at offset ${K} (format ${o}, record length ${x}), using intensity instead. Error: ${re}`);const oe=Math.min(J/65535,1);I[M*4+0]=Math.floor(oe*255),I[M*4+1]=Math.floor(oe*255),I[M*4+2]=Math.floor(oe*255),I[M*4+3]=255}else{console.warn(`LASLoader: RGB offset ${K} out of bounds (offset: ${j}, record end: ${ee}, buffer size: ${e.byteLength}, format: ${o}), using intensity instead`);const re=Math.min(J/65535,1);I[M*4+0]=Math.floor(re*255),I[M*4+1]=Math.floor(re*255),I[M*4+2]=Math.floor(re*255),I[M*4+3]=255}}else{const K=Math.min(J/65535,1);I[M*4+0]=Math.floor(K*255),I[M*4+1]=Math.floor(K*255),I[M*4+2]=Math.floor(K*255),I[M*4+3]=255}}return{format:"binary",version:s,pointDataFormat:o,numPoints:l,positions:w,colors:I,bbox:{xMin:m,xMax:p,yMin:D,yMax:_,zMin:U,zMax:v},scale:{x:c,y:f,z:h},offset:{x:u,y:b,z:A}}}parseMetadata(e){const t=Yt.parseSection(e,"V");if(!t)throw new Error("LASLoader: ~VERSION section not found");const r=Yt.removeComment(t).split(`
11855
11855
  `).filter(Boolean);let i=2,s=!1;for(const o of r){const l=o.split(/\s{2,}|\s*:/).filter(Boolean);if(l.length>=2){const c=l[0].trim().toUpperCase(),f=l[1].trim().toUpperCase();if(c==="VERS"||c==="VERSION"){const h=f.match(/(\d+\.?\d*)/);h&&(i=+h[1])}else(c==="WRAP"||c==="WRAP.")&&(s=f==="YES"||f==="Y")}}return{version:i,wrap:s}}parseWellParams(e){const t=Yt.parseSection(e,"W");if(!t)return{};const r=Yt.removeComment(t).split(`