@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.
package/dist/rings.es.js CHANGED
@@ -7919,7 +7919,7 @@ else if (typeof exports === 'object')
7919
7919
  `;class ed{compute;constructor(){this.compute=new Fe($f)}generateBRDFLUTTexture(){let e=new Te(256,256,oe.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);this.compute.setStorageTexture("brdflutTexture",e),this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let t=k.beginCommandEncoder();return k.computeCommand(t,[this.compute]),k.endCommandEncoder(t),e}}class fi{id;guiTexture;uvRec=new be(0,0,1,1);uvBorder=new be(0,0,0,0);offsetSize=new be(0,0,4,4);borderSize=new be(0,0,0,0);trimSize=new de;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||_.res.defaultGUITexture}}class kr{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=_.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,kr._maxUid++,this._staticId=kr._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class kb{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 di=new kb;class td{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 ad{id=0;file=""}class rd{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class ir extends it{static format=je.TEXT;static parseSprite(e,t){for(const a in t.fontChar)if(Object.prototype.hasOwnProperty.call(t.fontChar,a)){const r=t.fontChar[a];let i=new fi;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),di.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 td;a.trim().split(t).forEach((i,n)=>{if(n<2)ir.readLineProperty(i,r);else if(n<r.pages+2){let o=new ad;ir.readLineProperty(i,o),r.fontPage.push(o)}else if(n<r.pages+3)ir.readLineProperty(i,r);else if(r.count>0){let o=new rd;ir.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 _.res.loadTexture(r,null,!0);let i=_.res.getTexture(r),n=new kr(i);e.push(n)}ir.parseSprite(e,t),t.fontChar[" "]||ir.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new fi,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),di.addFnt(e.face,e.size,a.id,a)}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}}function Eb(s,e){let t=new fi;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new kr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function id(s,e,t){let a=new fi;a.guiTexture=s,a.id=e,a.uvRec.copyFrom(t.textureRect),a.trimSize.x=t.textureRect.z,a.trimSize.y=t.textureRect.w,a.offsetSize.x=t.textureRectOffset.x,a.offsetSize.y=t.textureRectOffset.y,a.offsetSize.z=t.size.x,a.offsetSize.w=t.size.y,a.width=t.size.x,a.height=t.size.y;let r=1/s.width,i=1/s.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let n=.1;return t.border.x<=n&&t.border.y<=n&&t.border.z<=n&&t.border.x<=n?a.isSliced=!1:(a.borderSize.copyFrom(t.border),a.uvBorder.copyFrom(t.border),a.uvBorder.x-=t.textureRectOffset.x,a.uvBorder.y-=t.textureRectOffset.y,a.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),a.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),a.uvBorder.x/=t.textureRect.z,a.uvBorder.z/=t.textureRect.z,a.uvBorder.y/=t.textureRect.w,a.uvBorder.w/=t.textureRect.w,a.isSliced=!0),a}class sd{_spriteMap=new Map;_spriteList=[];textureSize=new de;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=id(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 nd extends it{static format=je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await _.res.loadTexture(t,null,!0),this.data={json:this._json,texture:this._texture},this.parseAtlas()}verification(){if(this.data)return!0;throw new Error("verify failed.")}parseAtlas(){let e=new sd(this._json.size),t=new kr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);_.res.addAtlas(this.baseUrl,e),this.data=e}}var $t=Uint8Array,hi=Uint16Array,wb=Int32Array,od=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]),ld=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]),cd=function(s,e){for(var t=new hi(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new wb(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}},fd=cd(od,2),dd=fd.b,Rb=fd.r;dd[28]=258,Rb[258]=28;for(var Qb=cd(ld,0),Tb=Qb.b,Io=new hi(32768),Ke=0;Ke<32768;++Ke){var gr=(Ke&43690)>>1|(Ke&21845)<<1;gr=(gr&52428)>>2|(gr&13107)<<2,gr=(gr&61680)>>4|(gr&3855)<<4,Io[Ke]=((gr&65280)>>8|(gr&255)<<8)>>1}for(var Vi=(function(s,e,t){for(var a=s.length,r=0,i=new hi(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new hi(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new hi(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],d=n[s[r]-1]++<<f,h=d|(1<<f)-1;d<=h;++d)o[Io[d]>>l]=c}else for(o=new hi(a),r=0;r<a;++r)s[r]&&(o[r]=Io[n[s[r]-1]++]>>15-s[r]);return o}),Oi=new $t(288),Ke=0;Ke<144;++Ke)Oi[Ke]=8;for(var Ke=144;Ke<256;++Ke)Oi[Ke]=9;for(var Ke=256;Ke<280;++Ke)Oi[Ke]=7;for(var Ke=280;Ke<288;++Ke)Oi[Ke]=8;for(var hd=new $t(32),Ke=0;Ke<32;++Ke)hd[Ke]=5;var Mb=Vi(Oi,9,1),Nb=Vi(hd,5,1),Ro=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},xa=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Qo=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Pb=function(s){return(s+7)/8|0},To=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new $t(s.subarray(e,t))},Vb=["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(s,e,t){var a=new Error(e||Vb[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,fa),!t)throw a;return a},Ob=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new $t(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new $t(r*3));var c=function(ie){var le=t.length;if(ie>le){var ge=new $t(Math.max(le*2,ie));ge.set(t),t=ge}},f=e.f||0,d=e.p||0,h=e.b||0,u=e.l,m=e.d,g=e.m,p=e.n,A=r*8;do{if(!u){f=xa(s,d,1);var D=xa(s,d+1,3);if(d+=3,D)if(D==1)u=Mb,m=Nb,g=9,p=5;else if(D==2){var y=xa(s,d,31)+257,S=xa(s,d+10,15)+4,F=y+xa(s,d+5,31)+1;d+=14;for(var C=new $t(F),w=new $t(19),E=0;E<S;++E)w[Ib[E]]=xa(s,d+E*3,7);d+=S*3;for(var Q=Ro(w),T=(1<<Q)-1,j=Vi(w,Q,1),E=0;E<F;){var ue=j[xa(s,d,T)];d+=ue&15;var B=ue>>4;if(B<16)C[E++]=B;else{var ee=0,N=0;for(B==16?(N=3+xa(s,d,3),d+=2,ee=C[E-1]):B==17?(N=3+xa(s,d,7),d+=3):B==18&&(N=11+xa(s,d,127),d+=7);N--;)C[E++]=ee}}var M=C.subarray(0,y),O=C.subarray(y);g=Ro(M),p=Ro(O),u=Vi(M,g,1),m=Vi(O,p,1)}else fa(1);else{var B=Pb(d)+4,v=s[B-4]|s[B-3]<<8,U=B+v;if(U>r){l&&fa(0);break}o&&c(h+v),t.set(s.subarray(B,U),h),e.b=h+=v,e.p=d=U*8,e.f=f;continue}if(d>A){l&&fa(0);break}}o&&c(h+131072);for(var W=(1<<g)-1,ae=(1<<p)-1,z=d;;z=d){var ee=u[Qo(s,d)&W],K=ee>>4;if(d+=ee&15,d>A){l&&fa(0);break}if(ee||fa(2),K<256)t[h++]=K;else if(K==256){z=d,u=null;break}else{var $=K-254;if(K>264){var E=K-257,re=od[E];$=xa(s,d,(1<<re)-1)+dd[E],d+=re}var ce=m[Qo(s,d)&ae],Ae=ce>>4;ce||fa(3),d+=ce&15;var O=Tb[Ae];if(Ae>3){var re=ld[Ae];O+=Qo(s,d)&(1<<re)-1,d+=re}if(d>A){l&&fa(0);break}o&&c(h+131072);var Qe=h+$;if(h<O){var Ve=i-O,H=Math.min(O,Qe);for(Ve+h<0&&fa(3);h<H;++h)t[h]=a[Ve+h]}for(;h<Qe;++h)t[h]=t[h-O]}}e.l=u,e.p=z,e.b=h,e.f=f,u&&(f=1,e.m=g,e.d=m,e.n=p)}while(!f);return h!=t.length&&n?To(t,0,h):t.subarray(0,h)},Lb=new $t(0),La=function(s,e){return s[e]|s[e+1]<<8},Ua=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},Mo=function(s,e){return Ua(s,e)+Ua(s,e+4)*4294967296};function Gb(s,e){return Ob(s,{i:2},e&&e.out,e&&e.dictionary)}var No=typeof TextDecoder<"u"&&new TextDecoder,zb=0;try{No.decode(Lb,{stream:!0}),zb=1}catch{}var Wb=function(s){for(var e="",t=0;;){var a=s[t++],r=(a>127)+(a>223)+(a>239);if(t+r>s.length)return{s:e,r:To(s,t-1)};r?r==3?(a=((a&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|s[t++]&63):e+=String.fromCharCode((a&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(a)}};function ud(s,e){if(e){for(var t="",a=0;a<s.length;a+=16384)t+=String.fromCharCode.apply(null,s.subarray(a,a+16384));return t}else{if(No)return No.decode(s);var r=Wb(s),i=r.s,t=r.r;return t.length&&fa(8),i}}var Jb=function(s,e){return e+30+La(s,e+26)+La(s,e+28)},jb=function(s,e,t){var a=La(s,e+28),r=ud(s.subarray(e+46,e+46+a),!(La(s,e+8)&2048)),i=e+46+a,n=Ua(s,e+20),o=t&&n==4294967295?Zb(s,i):[n,Ua(s,e+24),Ua(s,e+42)],l=o[0],c=o[1],f=o[2];return[La(s,e+10),l,c,r,i+La(s,e+30)+La(s,e+32),f]},Zb=function(s,e){for(;La(s,e)!=1;e+=4+La(s,e+2));return[Mo(s,e+12),Mo(s,e+4),Mo(s,e+20)]};function Yb(s,e){for(var t={},a=s.length-22;Ua(s,a)!=101010256;--a)(!a||s.length-a>65558)&&fa(13);var r=La(s,a+8);if(!r)return{};var i=Ua(s,a+16),n=i==4294967295||r==65535;if(n){var o=Ua(s,a-12);n=Ua(s,o)==101075792,n&&(r=Ua(s,o+32),i=Ua(s,o+48))}for(var l=0;l<r;++l){var c=jb(s,i,n),f=c[0],d=c[1],h=c[2],u=c[3],m=c[4],g=c[5],p=Jb(s,g);i=m,f?f==8?t[u]=Gb(s.subarray(p,p+d),{out:new $t(h)}):fa(14,"unknown compression type "+f):t[u]=To(s,p,p+d)}return t}class vt extends xt{constructor(){super(),this.shader=new qi,this.baseMap=_.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}class Pr extends Le{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),d=new Uint16Array(i*r*2*3),h=0,u=0,m=0;for(t=0;t<=r;++t){var g=Math.PI*t/r,p=n*Math.cos(g),A=n*Math.sin(g);for(e=0;e<=i;++e){var D=2*Math.PI*e/i,B=A*Math.cos(D),v=A*Math.sin(D),U=1/Math.sqrt(B*B+p*p+v*v);if(l[h++]=B,l[h++]=p,l[h++]=v,c[u++]=B*U,c[u++]=p*U,c[u++]=v*U,f[m++]=e/i,f[m++]=t/r,e>0&&t>0){var y=(i+1)*t+e,S=(i+1)*t+e-1,F=(i+1)*(t-1)+e-1,C=(i+1)*(t-1)+e;t==r?(d[a++]=y,d[a++]=F,d[a++]=C):t==1?(d[a++]=y,d[a++]=S,d[a++]=F):(d[a++]=y,d[a++]=S,d[a++]=F,d[a++]=y,d[a++]=F,d[a++]=C)}}}this.setIndices(d),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class _s extends ne{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),_s.register3DRepresentation)this.marker=_s.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new ne;const e=this.marker.addComponent(he);e.geometry=new Pr(.1,32,16),e.material=new vt,e.material.baseColor=this.positionValid?new J(0,1,0,1):new J(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Bs extends ne{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new _s(t);this.addChild(a)}this.entityChildren=this.entityChildren.sort((t,a)=>t.positionIndex-a.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),Bs.register3DRepresentation?(this.line=Bs.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new J(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Le,r=new Float32Array(e.length*3);for(let c=0;c<e.length;c++)r[c*3]=e[c].x,r[c*3+1]=e[c].y,r[c*3+2]=e[c].z;const i=new Uint16Array((e.length-1)*2);for(let c=0;c<e.length-1;c++)i[c*2]=c,i[c*2+1]=c+1;a.setIndices(i),a.setAttribute(G.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new ne,o=n.addComponent(he),l=new vt;return l.topology="line-list",l.baseColor=t,l.blendMode=De.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class bd extends it{static format=je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Yb(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(ud(n),"application/xml"),c={};this.parseNode(l,c);const f=i.replace("wpmz/","").split(".")[0];Object.assign(t,{[f]:c["#document"].kml.Document})}const r=new Bs(t.waylines);this.data=r}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const a=["Placemark","actionGroup","action"],r=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[r]=void 0;else{let i=null,n=!1;for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];if(l.nodeType==Node.TEXT_NODE){const c=l.nodeValue?.trim();c&&c.length>0&&(i=c)}else l.nodeType==Node.ELEMENT_NODE&&(n=!0)}if(i&&!n)t[r]=i;else if(n){a.includes(r)?t[r]?.length?t[r].push({}):t[r]=[{}]:t[r]={};for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[r])?t[r].at(-1):t[r])}}else t[r]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class gd{_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 Rt().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 Rt;r==".gltf"?a=await i.load(e,Ut,t):a=await i.load(e,Bo,t);let n=a.data;return this._prefabPool.set(e,n),this._gltfPool.set(e,a.gltf),n}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new Rt;r==".obj"&&(a=await i.load(e,Ds,t));let n=a.data;return this._prefabPool.set(e,n),n}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new Rt().load(e,Fo,t,a)).data;return this._prefabPool.set(e,n),n}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new Rt().load(e,wo,t,a)).data;return this._prefabPool.set(e,n),n}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $a;r.flipY=a;try{await r.load(e,t)}catch(i){return console.error(`Failed to load texture: ${e}`,i),null}return this._texturePool.set(e,r),r}destroyTexture(e){const t=this._texturePool.get(e);return t?ke.getInstance().hasReference(t)?!1:(t.isDestroyed||t.destroy(),this._texturePool.delete(e),!0):!1}destroyTextureAllUnUsed(){for(const[e,t]of this._texturePool.entries())this.destroyTexture(e)}async loadTextureCount(e,t,a,r){return new Promise(async(i,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(d=>{l.push(d),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Uo;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 Ls;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 zs;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 vo;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 vo;return await a.loadStd(e),a}async loadJSON(e,t){return await new Rt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new Rt().load(e,ir,t,a),n=i.data;return di.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new Rt().load(e,nd,t,e)).data}async loadKMZ(e,t){return(await new Rt().load(e,bd,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let d=new ki;return d.name=o,d.create(16,16,f,!0),o&&this.addTexture(o,d),d}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new ed().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Ls,this.defaultSky.createFromTexture(128,this.blackTexture),ke.getInstance().attached(this.defaultSky,this),ke.getInstance().attached(t,this),ke.getInstance().attached(this.normalTexture,this),ke.getInstance().attached(this.maskTexture,this),ke.getInstance().attached(this.whiteTexture,this),ke.getInstance().attached(this.blackTexture,this),ke.getInstance().attached(this.redTexture,this),ke.getInstance().attached(this.blueTexture,this),ke.getInstance().attached(this.greenTexture,this),ke.getInstance().attached(this.yellowTexture,this),ke.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new kr(this.whiteTexture),this.defaultGUISprite=new fi(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new aa}}class pd extends et{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.removePost(a)})}addPost(e){if(this._postList.has(e))return;let t=new e;return this._postList.set(e,t),this._enable&&this.activePost(),t}removePost(e){if(!this._postList.has(e))return;let t=this._postList.get(e);this._postList.delete(e);let a=this.transform.view3D;_.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Xb="1.0.49";class _{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return I.presentationSize}static get aspect(){return I.aspect}static get width(){return I.windowWidth}static get height(){return I.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new J(96/255,117/255,133/255,1),falloff:.7,rayLength:200,scatteringExponent:2.7,dirHeightLine:10},godRay:{blendColor:!0,rayMarchCount:16,scatteringExponent:5,intensity:.5},ssao:{enable:!1,radius:.15,bias:-.1,aoPower:2,debug:!0},outline:{enable:!1,strength:1,groupCount:4,outlinePixel:2,fadeOutlinePixel:4,textureScale:1,useAddMode:!1,debug:!0},taa:{enable:!1,jitterSeedCount:8,blendFactor:.1,sharpFactor:.6,sharpPreBlurFactor:.5,temporalJitterScale:.13,debug:!0},gtao:{enable:!1,darkFactor:1,maxDistance:5,maxPixel:50,rayMarchSegment:6,multiBounce:!1,usePosFloat32:!0,blendColor:!0,debug:!0},ssr:{enable:!1,pixelRatio:1,fadeEdgeRatio:.2,rayMarchRatio:.5,fadeDistanceMin:600,fadeDistanceMax:2e3,roughnessThreshold:.5,powDotRN:.2,mixThreshold:.1,debug:!0},fxaa:{enable:!1},depthOfView:{enable:!1,iterationCount:3,pixelOffset:1,near:150,far:300}}},shadow:{enable:!0,type:"HARD",pointShadowBias:5e-4,shadowSize:2048,pointShadowSize:1024,shadowSoft:.005,shadowBound:100,shadowBias:.05,needUpdate:!0,autoUpdate:!0,updateFrameRate:2,csmMargin:.1,csmScatteringExp:.7,csmAreaScale:.4,debug:!1},gi:{enable:!1,offsetX:0,offsetY:0,offsetZ:0,probeSpace:64,probeXCount:4,probeYCount:2,probeZCount:4,probeSize:32,probeSourceTextureSize:2048,octRTMaxSize:2048,octRTSideSize:16,maxDistance:64*1.73,normalBias:.25,depthSharpness:1,hysteresis:.98,lerpHysteresis:.01,irradianceChebyshevBias:.01,rayNumber:144,irradianceDistanceBias:32,indirectIntensity:1,ddgiGamma:2.2,bounceIntensity:.025,probeRoughness:1,realTimeGI:!1,debug:!1,autoRenderProbe:!1},sky:{type:"HDRSKY",sky:null,skyExposure:1,defaultFar:65536,defaultNear:1},light:{maxLight:4096},material:{materialChannelDebug:!1,materialDebug:!1},loader:{numConcurrent:20},reflectionSetting:{reflectionProbeMaxCount:8,reflectionProbeSize:256,width:256*6,height:8*256,enable:!0}};static renderJobs;static async init(e={}){console.log("Rings Version",Xb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Re.init(R.allocCount,this.setting.doublePrecision),await I.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,ve.getGBufferFrame(ve.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),Y.init(),Ka.init(),xe.init(),Nt.init(),Zt.init(),this.res=new gd,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Fl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new uf(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(pd).addPost(no),(this.setting.pick.mode=="pixel"||this.setting.pick.mode=="bound")&&(e.enablePick=!0),t}static startRenderView(e){this.renderJobs||=new Map,this.views=[e];let t=this.startRenderJob(e);return this.resume(),t}static startRenderViews(e){this.renderJobs||=new Map,this.views=e;for(let t=0;t<e.length;t++)this.startRenderJob(e[t]);this.resume()}static getRenderJob(e){return this.renderJobs.get(e)}static pause(){this._requestAnimationFrameID!==0&&(cancelAnimationFrame(this._requestAnimationFrameID),this._requestAnimationFrameID=0)}static resume(){this._requestAnimationFrameID===0&&(this._requestAnimationFrameID=requestAnimationFrame(e=>this.render(e)))}static async render(e){if(this._frameRateValue>0){let t=e-this._time;if(t<this._frameRateValue){let a=performance.now();await new Promise(r=>{setTimeout(()=>{e+=performance.now()-a,r(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){We.delta=e-We.time,We.time=e,We.frame+=1,Fr.tick(We.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=I.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of Oe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}let r=I.device.createCommandEncoder();for(const n of Oe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o,r)}}I.device.queue.submit([r.finish()]);for(const n of Oe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}for(const n of Oe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];o&&f.enable&&d(o)}}this._renderLoop&&await this._renderLoop(),Re.updateAllContinueTransform(0,R.useCount,16),xe.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of Oe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}this._lateRender&&await this._lateRender()}}let Ws=`
7922
+ `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await _.res.loadTexture(r,null,!0);let i=_.res.getTexture(r),n=new kr(i);e.push(n)}ir.parseSprite(e,t),t.fontChar[" "]||ir.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new fi,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),di.addFnt(e.face,e.size,a.id,a)}static readLineProperty(e,t){e.trim().split(" ").forEach((a,r)=>{let i=a.split("=");if(i.length>1){let n=i[0],o=i[1];Object.prototype.hasOwnProperty.call(t,n)&&(o.indexOf('"')==-1?t[n]=parseFloat(i[1]):t[n]=o.replace('"',"").replace('"',""))}})}}function Eb(s,e){let t=new fi;return t.id=s,t.offsetSize.set(0,0,e.width,e.height),t.trimSize.set(e.width,e.height),t.width=e.width,t.height=e.height,t.xadvance=0,t.xoffset=0,t.yoffset=0,t.guiTexture=new kr(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function id(s,e,t){let a=new fi;a.guiTexture=s,a.id=e,a.uvRec.copyFrom(t.textureRect),a.trimSize.x=t.textureRect.z,a.trimSize.y=t.textureRect.w,a.offsetSize.x=t.textureRectOffset.x,a.offsetSize.y=t.textureRectOffset.y,a.offsetSize.z=t.size.x,a.offsetSize.w=t.size.y,a.width=t.size.x,a.height=t.size.y;let r=1/s.width,i=1/s.height;a.uvRec.set(a.uvRec.x*r,a.uvRec.y*i,a.uvRec.z*r,a.uvRec.w*i);let n=.1;return t.border.x<=n&&t.border.y<=n&&t.border.z<=n&&t.border.x<=n?a.isSliced=!1:(a.borderSize.copyFrom(t.border),a.uvBorder.copyFrom(t.border),a.uvBorder.x-=t.textureRectOffset.x,a.uvBorder.y-=t.textureRectOffset.y,a.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),a.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),a.uvBorder.x/=t.textureRect.z,a.uvBorder.z/=t.textureRect.z,a.uvBorder.y/=t.textureRect.w,a.uvBorder.w/=t.textureRect.w,a.isSliced=!0),a}class sd{_spriteMap=new Map;_spriteList=[];textureSize=new de;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=id(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 nd extends it{static format=je.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await _.res.loadTexture(t,null,!0),this.data={json:this._json,texture:this._texture},this.parseAtlas()}verification(){if(this.data)return!0;throw new Error("verify failed.")}parseAtlas(){let e=new sd(this._json.size),t=new kr(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);_.res.addAtlas(this.baseUrl,e),this.data=e}}var $t=Uint8Array,hi=Uint16Array,wb=Int32Array,od=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]),ld=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]),cd=function(s,e){for(var t=new hi(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new wb(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}},fd=cd(od,2),dd=fd.b,Rb=fd.r;dd[28]=258,Rb[258]=28;for(var Qb=cd(ld,0),Tb=Qb.b,Io=new hi(32768),Ke=0;Ke<32768;++Ke){var gr=(Ke&43690)>>1|(Ke&21845)<<1;gr=(gr&52428)>>2|(gr&13107)<<2,gr=(gr&61680)>>4|(gr&3855)<<4,Io[Ke]=((gr&65280)>>8|(gr&255)<<8)>>1}for(var Vi=(function(s,e,t){for(var a=s.length,r=0,i=new hi(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new hi(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new hi(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],d=n[s[r]-1]++<<f,h=d|(1<<f)-1;d<=h;++d)o[Io[d]>>l]=c}else for(o=new hi(a),r=0;r<a;++r)s[r]&&(o[r]=Io[n[s[r]-1]++]>>15-s[r]);return o}),Oi=new $t(288),Ke=0;Ke<144;++Ke)Oi[Ke]=8;for(var Ke=144;Ke<256;++Ke)Oi[Ke]=9;for(var Ke=256;Ke<280;++Ke)Oi[Ke]=7;for(var Ke=280;Ke<288;++Ke)Oi[Ke]=8;for(var hd=new $t(32),Ke=0;Ke<32;++Ke)hd[Ke]=5;var Mb=Vi(Oi,9,1),Nb=Vi(hd,5,1),Ro=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},xa=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Qo=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Pb=function(s){return(s+7)/8|0},To=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new $t(s.subarray(e,t))},Vb=["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(s,e,t){var a=new Error(e||Vb[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,fa),!t)throw a;return a},Ob=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new $t(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new $t(r*3));var c=function(ie){var le=t.length;if(ie>le){var ge=new $t(Math.max(le*2,ie));ge.set(t),t=ge}},f=e.f||0,d=e.p||0,h=e.b||0,u=e.l,m=e.d,g=e.m,p=e.n,A=r*8;do{if(!u){f=xa(s,d,1);var D=xa(s,d+1,3);if(d+=3,D)if(D==1)u=Mb,m=Nb,g=9,p=5;else if(D==2){var y=xa(s,d,31)+257,S=xa(s,d+10,15)+4,F=y+xa(s,d+5,31)+1;d+=14;for(var C=new $t(F),w=new $t(19),E=0;E<S;++E)w[Ib[E]]=xa(s,d+E*3,7);d+=S*3;for(var Q=Ro(w),T=(1<<Q)-1,j=Vi(w,Q,1),E=0;E<F;){var ue=j[xa(s,d,T)];d+=ue&15;var B=ue>>4;if(B<16)C[E++]=B;else{var ee=0,N=0;for(B==16?(N=3+xa(s,d,3),d+=2,ee=C[E-1]):B==17?(N=3+xa(s,d,7),d+=3):B==18&&(N=11+xa(s,d,127),d+=7);N--;)C[E++]=ee}}var M=C.subarray(0,y),O=C.subarray(y);g=Ro(M),p=Ro(O),u=Vi(M,g,1),m=Vi(O,p,1)}else fa(1);else{var B=Pb(d)+4,v=s[B-4]|s[B-3]<<8,U=B+v;if(U>r){l&&fa(0);break}o&&c(h+v),t.set(s.subarray(B,U),h),e.b=h+=v,e.p=d=U*8,e.f=f;continue}if(d>A){l&&fa(0);break}}o&&c(h+131072);for(var W=(1<<g)-1,ae=(1<<p)-1,z=d;;z=d){var ee=u[Qo(s,d)&W],K=ee>>4;if(d+=ee&15,d>A){l&&fa(0);break}if(ee||fa(2),K<256)t[h++]=K;else if(K==256){z=d,u=null;break}else{var $=K-254;if(K>264){var E=K-257,re=od[E];$=xa(s,d,(1<<re)-1)+dd[E],d+=re}var ce=m[Qo(s,d)&ae],Ae=ce>>4;ce||fa(3),d+=ce&15;var O=Tb[Ae];if(Ae>3){var re=ld[Ae];O+=Qo(s,d)&(1<<re)-1,d+=re}if(d>A){l&&fa(0);break}o&&c(h+131072);var Qe=h+$;if(h<O){var Ve=i-O,H=Math.min(O,Qe);for(Ve+h<0&&fa(3);h<H;++h)t[h]=a[Ve+h]}for(;h<Qe;++h)t[h]=t[h-O]}}e.l=u,e.p=z,e.b=h,e.f=f,u&&(f=1,e.m=g,e.d=m,e.n=p)}while(!f);return h!=t.length&&n?To(t,0,h):t.subarray(0,h)},Lb=new $t(0),La=function(s,e){return s[e]|s[e+1]<<8},Ua=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},Mo=function(s,e){return Ua(s,e)+Ua(s,e+4)*4294967296};function Gb(s,e){return Ob(s,{i:2},e&&e.out,e&&e.dictionary)}var No=typeof TextDecoder<"u"&&new TextDecoder,zb=0;try{No.decode(Lb,{stream:!0}),zb=1}catch{}var Wb=function(s){for(var e="",t=0;;){var a=s[t++],r=(a>127)+(a>223)+(a>239);if(t+r>s.length)return{s:e,r:To(s,t-1)};r?r==3?(a=((a&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|a>>10,56320|a&1023)):r&1?e+=String.fromCharCode((a&31)<<6|s[t++]&63):e+=String.fromCharCode((a&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(a)}};function ud(s,e){if(e){for(var t="",a=0;a<s.length;a+=16384)t+=String.fromCharCode.apply(null,s.subarray(a,a+16384));return t}else{if(No)return No.decode(s);var r=Wb(s),i=r.s,t=r.r;return t.length&&fa(8),i}}var Jb=function(s,e){return e+30+La(s,e+26)+La(s,e+28)},jb=function(s,e,t){var a=La(s,e+28),r=ud(s.subarray(e+46,e+46+a),!(La(s,e+8)&2048)),i=e+46+a,n=Ua(s,e+20),o=t&&n==4294967295?Zb(s,i):[n,Ua(s,e+24),Ua(s,e+42)],l=o[0],c=o[1],f=o[2];return[La(s,e+10),l,c,r,i+La(s,e+30)+La(s,e+32),f]},Zb=function(s,e){for(;La(s,e)!=1;e+=4+La(s,e+2));return[Mo(s,e+12),Mo(s,e+4),Mo(s,e+20)]};function Yb(s,e){for(var t={},a=s.length-22;Ua(s,a)!=101010256;--a)(!a||s.length-a>65558)&&fa(13);var r=La(s,a+8);if(!r)return{};var i=Ua(s,a+16),n=i==4294967295||r==65535;if(n){var o=Ua(s,a-12);n=Ua(s,o)==101075792,n&&(r=Ua(s,o+32),i=Ua(s,o+48))}for(var l=0;l<r;++l){var c=jb(s,i,n),f=c[0],d=c[1],h=c[2],u=c[3],m=c[4],g=c[5],p=Jb(s,g);i=m,f?f==8?t[u]=Gb(s.subarray(p,p+d),{out:new $t(h)}):fa(14,"unknown compression type "+f):t[u]=To(s,p,p+d)}return t}class vt extends xt{constructor(){super(),this.shader=new qi,this.baseMap=_.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}class Pr extends Le{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),d=new Uint16Array(i*r*2*3),h=0,u=0,m=0;for(t=0;t<=r;++t){var g=Math.PI*t/r,p=n*Math.cos(g),A=n*Math.sin(g);for(e=0;e<=i;++e){var D=2*Math.PI*e/i,B=A*Math.cos(D),v=A*Math.sin(D),U=1/Math.sqrt(B*B+p*p+v*v);if(l[h++]=B,l[h++]=p,l[h++]=v,c[u++]=B*U,c[u++]=p*U,c[u++]=v*U,f[m++]=e/i,f[m++]=t/r,e>0&&t>0){var y=(i+1)*t+e,S=(i+1)*t+e-1,F=(i+1)*(t-1)+e-1,C=(i+1)*(t-1)+e;t==r?(d[a++]=y,d[a++]=F,d[a++]=C):t==1?(d[a++]=y,d[a++]=S,d[a++]=F):(d[a++]=y,d[a++]=S,d[a++]=F,d[a++]=y,d[a++]=F,d[a++]=C)}}}this.setIndices(d),this.setAttribute(G.position,l),this.setAttribute(G.normal,c),this.setAttribute(G.uv,f),this.setAttribute(G.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:d.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Ce(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class _s extends ne{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),_s.register3DRepresentation)this.marker=_s.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new ne;const e=this.marker.addComponent(he);e.geometry=new Pr(.1,32,16),e.material=new vt,e.material.baseColor=this.positionValid?new J(0,1,0,1):new J(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class Bs extends ne{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const a=new _s(t);this.addChild(a)}this.entityChildren=this.entityChildren.sort((t,a)=>t.positionIndex-a.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),Bs.register3DRepresentation?(this.line=Bs.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new J(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Le,r=new Float32Array(e.length*3);for(let c=0;c<e.length;c++)r[c*3]=e[c].x,r[c*3+1]=e[c].y,r[c*3+2]=e[c].z;const i=new Uint16Array((e.length-1)*2);for(let c=0;c<e.length-1;c++)i[c*2]=c,i[c*2+1]=c+1;a.setIndices(i),a.setAttribute(G.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new ne,o=n.addComponent(he),l=new vt;return l.topology="line-list",l.baseColor=t,l.blendMode=De.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class bd extends it{static format=je.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Yb(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(ud(n),"application/xml"),c={};this.parseNode(l,c);const f=i.replace("wpmz/","").split(".")[0];Object.assign(t,{[f]:c["#document"].kml.Document})}const r=new Bs(t.waylines);this.data=r}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const a=["Placemark","actionGroup","action"],r=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[r]=void 0;else{let i=null,n=!1;for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];if(l.nodeType==Node.TEXT_NODE){const c=l.nodeValue?.trim();c&&c.length>0&&(i=c)}else l.nodeType==Node.ELEMENT_NODE&&(n=!0)}if(i&&!n)t[r]=i;else if(n){a.includes(r)?t[r]?.length?t[r].push({}):t[r]=[{}]:t[r]={};for(let o=0;o<e.childNodes.length;++o){const l=e.childNodes[o];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[r])?t[r].at(-1):t[r])}}else t[r]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class gd{_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 Rt().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 Rt;r==".gltf"?a=await i.load(e,Ut,t):a=await i.load(e,Bo,t);let n=a.data;return this._prefabPool.set(e,n),this._gltfPool.set(e,a.gltf),n}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let a,r=e.substring(e.lastIndexOf(".")).toLowerCase(),i=new Rt;r==".obj"&&(a=await i.load(e,Ds,t));let n=a.data;return this._prefabPool.set(e,n),n}async loadB3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new Rt().load(e,Fo,t,a)).data;return this._prefabPool.set(e,n),n}async loadI3DM(e,t,a){if(this._prefabPool.has(e))return this._prefabPool.get(e);let n=(await new Rt().load(e,wo,t,a)).data;return this._prefabPool.set(e,n),n}async loadTexture(e,t,a){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new $a;r.flipY=a;try{await r.load(e,t)}catch(i){return console.error(`Failed to load texture: ${e}`,i),null}return this._texturePool.set(e,r),r}destroyTexture(e){const t=this._texturePool.get(e);return t?ke.getInstance().hasReference(t)?!1:(t.isDestroyed||t.destroy(),this._texturePool.delete(e),!0):!1}destroyTextureAllUnUsed(){for(const[e,t]of this._texturePool.entries())this.destroyTexture(e)}async loadTextureCount(e,t,a,r){return new Promise(async(i,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(d=>{l.push(d),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Uo;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 Ls;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 zs;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 vo;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 vo;return await a.loadStd(e),a}async loadJSON(e,t){return await new Rt().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new Rt().load(e,ir,t,a),n=i.data;return di.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new Rt().load(e,nd,t,e)).data}async loadKMZ(e,t){return(await new Rt().load(e,bd,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let d=new ki;return d.name=o,d.create(16,16,f,!0),o&&this.addTexture(o,d),d}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new ed().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new Ls,this.defaultSky.createFromTexture(128,this.blackTexture),ke.getInstance().attached(this.defaultSky,this),ke.getInstance().attached(t,this),ke.getInstance().attached(this.normalTexture,this),ke.getInstance().attached(this.maskTexture,this),ke.getInstance().attached(this.whiteTexture,this),ke.getInstance().attached(this.blackTexture,this),ke.getInstance().attached(this.redTexture,this),ke.getInstance().attached(this.blueTexture,this),ke.getInstance().attached(this.greenTexture,this),ke.getInstance().attached(this.yellowTexture,this),ke.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new kr(this.whiteTexture),this.defaultGUISprite=new fi(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new aa}}class pd extends et{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=_.getRenderJob(e);this._postList.forEach(a=>{t.removePost(a)})}addPost(e){if(this._postList.has(e))return;let t=new e;return this._postList.set(e,t),this._enable&&this.activePost(),t}removePost(e){if(!this._postList.has(e))return;let t=this._postList.get(e);this._postList.delete(e);let a=this.transform.view3D;_.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Xb="1.0.50";class _{static res;static inputSystem;static views;static _frameRateValue=0;static _frameRate=360;static _time=0;static _beforeRender;static _renderLoop;static _lateRender;static _requestAnimationFrameID=0;static get frameRate(){return this._frameRate}static set frameRate(e){this._frameRate=e,this._frameRateValue=1e3/e,e>=360&&(this._frameRateValue=0)}static get size(){return I.presentationSize}static get aspect(){return I.aspect}static get width(){return I.windowWidth}static get height(){return I.windowHeight}static setting={doublePrecision:!1,occlusionQuery:{enable:!0,debug:!1},pick:{enable:!0,mode:"bound",detail:"mesh"},render:{debug:!1,renderPassState:4,renderState_left:5,renderState_right:5,renderState_split:.5,quadScale:1,hdrExposure:1.5,debugQuad:-1,maxPointLight:1e3,maxDirectLight:4,maxSportLight:1e3,drawOpMin:0,drawOpMax:Number.MAX_SAFE_INTEGER,drawTrMin:0,drawTrMax:Number.MAX_SAFE_INTEGER,zPrePass:!1,useLogDepth:!1,useCompressGBuffer:!1,gi:!1,postProcessing:{bloom:{downSampleStep:3,downSampleBlurSize:9,downSampleBlurSigma:1,upSampleBlurSize:9,upSampleBlurSigma:1,luminanceThreshole:1,bloomIntensity:1,hdr:1},globalFog:{debug:!1,enable:!1,fogType:0,fogHeightScale:.1,start:400,end:10,density:.02,ins:.5,skyFactor:.5,skyRoughness:.4,overrideSkyFactor:.8,fogColor:new J(96/255,117/255,133/255,1),falloff:.7,rayLength:200,scatteringExponent:2.7,dirHeightLine:10},godRay:{blendColor:!0,rayMarchCount:16,scatteringExponent:5,intensity:.5},ssao:{enable:!1,radius:.15,bias:-.1,aoPower:2,debug:!0},outline:{enable:!1,strength:1,groupCount:4,outlinePixel:2,fadeOutlinePixel:4,textureScale:1,useAddMode:!1,debug:!0},taa:{enable:!1,jitterSeedCount:8,blendFactor:.1,sharpFactor:.6,sharpPreBlurFactor:.5,temporalJitterScale:.13,debug:!0},gtao:{enable:!1,darkFactor:1,maxDistance:5,maxPixel:50,rayMarchSegment:6,multiBounce:!1,usePosFloat32:!0,blendColor:!0,debug:!0},ssr:{enable:!1,pixelRatio:1,fadeEdgeRatio:.2,rayMarchRatio:.5,fadeDistanceMin:600,fadeDistanceMax:2e3,roughnessThreshold:.5,powDotRN:.2,mixThreshold:.1,debug:!0},fxaa:{enable:!1},depthOfView:{enable:!1,iterationCount:3,pixelOffset:1,near:150,far:300}}},shadow:{enable:!0,type:"HARD",pointShadowBias:5e-4,shadowSize:2048,pointShadowSize:1024,shadowSoft:.005,shadowBound:100,shadowBias:.05,needUpdate:!0,autoUpdate:!0,updateFrameRate:2,csmMargin:.1,csmScatteringExp:.7,csmAreaScale:.4,debug:!1},gi:{enable:!1,offsetX:0,offsetY:0,offsetZ:0,probeSpace:64,probeXCount:4,probeYCount:2,probeZCount:4,probeSize:32,probeSourceTextureSize:2048,octRTMaxSize:2048,octRTSideSize:16,maxDistance:64*1.73,normalBias:.25,depthSharpness:1,hysteresis:.98,lerpHysteresis:.01,irradianceChebyshevBias:.01,rayNumber:144,irradianceDistanceBias:32,indirectIntensity:1,ddgiGamma:2.2,bounceIntensity:.025,probeRoughness:1,realTimeGI:!1,debug:!1,autoRenderProbe:!1},sky:{type:"HDRSKY",sky:null,skyExposure:1,defaultFar:65536,defaultNear:1},light:{maxLight:4096},material:{materialChannelDebug:!1,materialDebug:!1},loader:{numConcurrent:20},reflectionSetting:{reflectionProbeMaxCount:8,reflectionProbeSize:256,width:256*6,height:8*256,enable:!0}};static renderJobs;static async init(e={}){console.log("Rings Version",Xb),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await Re.init(R.allocCount,this.setting.doublePrecision),await I.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,ve.getGBufferFrame(ve.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),Y.init(),Ka.init(),xe.init(),Nt.init(),Zt.init(),this.res=new gd,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new Fl,this.inputSystem.initCanvas(I.canvas)}static startRenderJob(e){let t=new uf(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(pd).addPost(no),(this.setting.pick.mode=="pixel"||this.setting.pick.mode=="bound")&&(e.enablePick=!0),t}static startRenderView(e){this.renderJobs||=new Map,this.views=[e];let t=this.startRenderJob(e);return this.resume(),t}static startRenderViews(e){this.renderJobs||=new Map,this.views=e;for(let t=0;t<e.length;t++)this.startRenderJob(e[t]);this.resume()}static getRenderJob(e){return this.renderJobs.get(e)}static pause(){this._requestAnimationFrameID!==0&&(cancelAnimationFrame(this._requestAnimationFrameID),this._requestAnimationFrameID=0)}static resume(){this._requestAnimationFrameID===0&&(this._requestAnimationFrameID=requestAnimationFrame(e=>this.render(e)))}static async render(e){if(this._frameRateValue>0){let t=e-this._time;if(t<this._frameRateValue){let a=performance.now();await new Promise(r=>{setTimeout(()=>{e+=performance.now()-a,r(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){We.delta=e-We.time,We.time=e,We.frame+=1,Fr.tick(We.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=I.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of Oe.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}let r=I.device.createCommandEncoder();for(const n of Oe.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o,r)}}I.device.queue.submit([r.finish()]);for(const n of Oe.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}for(const n of Oe.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];o&&f.enable&&d(o)}}this._renderLoop&&await this._renderLoop(),Re.updateAllContinueTransform(0,R.useCount,16),xe.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of Oe.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],d=c[1];f.enable&&d(o)}}this._lateRender&&await this._lateRender()}}let 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 h=l.substring(f).split(/\s+/).filter(H=>H.length>0);let u=0;const m=H=>r.find(ie=>ie.name===H)!=null,g=H=>{if(u>=h.length)throw new Error("PLY: Unexpected end of file");const ie=h[u++];switch(H){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),A=m("nx")&&m("ny")&&m("nz"),D=A?new Float32Array(t*3):new Float32Array(t*3),B=(m("red")||m("r"))&&(m("green")||m("g"))&&(m("blue")||m("b"))?new Float32Array(t*3):void 0,v=(m("u")||m("s"))&&(m("v")||m("t")),U=i?.some(H=>H.name==="texcoord")||!1,y=v||U?new Float32Array(t*2):void 0,S=new Map,F=i?.some(H=>H.name==="texnumber")||!1,C=F?new Array(a):[],w=[],E=[],Q=[],T=H=>r.findIndex(ie=>ie.name===H),j=T("x"),ue=T("y"),ee=T("z"),N=A?T("nx"):-1,M=A?T("ny"):-1,O=A?T("nz"):-1,W=B?T("red")>=0?T("red"):T("r"):-1,ae=B?T("green")>=0?T("green"):T("g"):-1,z=B?T("blue")>=0?T("blue"):T("b"):-1,K=y&&v?T("u")>=0?T("u"):T("s"):-1,$=y&&v?T("v")>=0?T("v"):T("t"):-1;for(let H=0;H<t;H++)for(let ie=0;ie<r.length;ie++){const le=r[ie],ge=g(le.type);ie===j?p[H*3+0]=ge:ie===ue?p[H*3+1]=ge:ie===ee?p[H*3+2]=ge:ie===N?D[H*3+0]=ge:ie===M?D[H*3+1]=ge:ie===O?D[H*3+2]=ge:ie===W&&B?B[H*3+0]=le.type==="uchar"||le.type==="uint8"?ge/255:ge:ie===ae&&B?B[H*3+1]=le.type==="uchar"||le.type==="uint8"?ge/255:ge:ie===z&&B?B[H*3+2]=le.type==="uchar"||le.type==="uint8"?ge/255:ge:ie===K&&y?y[H*2+0]=ge:ie===$&&y&&(y[H*2+1]=ge)}for(let H=0;H<a;H++){let ie=[],le,ge=0;for(const ye of i||[])if(ye.name==="vertex_indices"){const Se=ye.type.split(" "),Me=Se[1],Ze=Se[2],$e=g(Me);ie=[];for(let ft=0;ft<$e;ft++)ie.push(g(Ze))}else if(ye.name==="texcoord"){const Se=ye.type.split(" "),Me=Se[1],Ze=Se[2],$e=g(Me);le=new Float32Array($e);for(let ft=0;ft<$e;ft++)le[ft]=g(Ze);S.set(H,le)}else ye.name==="texnumber"&&(ge=g(ye.type),C[H]=ge);const Ie=ie.length,me=F?C[H]??0:0;if(Ie===3)w.push(ie[0],ie[1],ie[2]),F&&E.push(me),U&&le&&le.length>=6&&Q.push(le[0],1-le[1],le[2],1-le[3],le[4],1-le[5]);else for(let ye=1;ye<Ie-1;ye++)w.push(ie[0],ie[ye],ie[ye+1]),F&&E.push(me),U&&le&&le.length>=Ie*2&&Q.push(le[0],1-le[1],le[ye*2+0],1-le[ye*2+1],le[(ye+1)*2+0],1-le[(ye+1)*2+1])}if(!A){for(let H=0;H<t*3;H++)D[H]=0;for(let H=0;H<w.length;H+=3){const ie=w[H],le=w[H+1],ge=w[H+2],Ie=p[ie*3+0],me=p[ie*3+1],ye=p[ie*3+2],Se=p[le*3+0],Me=p[le*3+1],Ze=p[le*3+2],$e=p[ge*3+0],ft=p[ge*3+1],Za=p[ge*3+2],ga=Se-Ie,Qa=Me-me,Ht=Ze-ye,Ta=$e-Ie,Ma=ft-me,Vt=Za-ye,pa=Qa*Vt-Ht*Ma,ma=Ht*Ta-ga*Vt,ia=ga*Ma-Qa*Ta;D[ie*3+0]+=pa,D[ie*3+1]+=ma,D[ie*3+2]+=ia,D[le*3+0]+=pa,D[le*3+1]+=ma,D[le*3+2]+=ia,D[ge*3+0]+=pa,D[ge*3+1]+=ma,D[ge*3+2]+=ia}for(let H=0;H<t;H++){const ie=D[H*3+0],le=D[H*3+1],ge=D[H*3+2],Ie=Math.sqrt(ie*ie+le*le+ge*ge);Ie>1e-5?(D[H*3+0]=ie/Ie,D[H*3+1]=le/Ie,D[H*3+2]=ge/Ie):(D[H*3+0]=0,D[H*3+1]=1,D[H*3+2]=0)}}let re=p,ce=D,Ae=B,Qe,Ve;if(U&&Q.length>0){const H=w.length/3,ie=new Float32Array(H*3*3),le=new Float32Array(H*3*3),ge=B?new Float32Array(H*3*3):void 0;Qe=new Float32Array(Q);for(let me=0;me<H;me++){const ye=me*3,Se=w[ye+0],Me=w[ye+1],Ze=w[ye+2];ie[me*9+0]=p[Se*3+0],ie[me*9+1]=p[Se*3+1],ie[me*9+2]=p[Se*3+2],ie[me*9+3]=p[Me*3+0],ie[me*9+4]=p[Me*3+1],ie[me*9+5]=p[Me*3+2],ie[me*9+6]=p[Ze*3+0],ie[me*9+7]=p[Ze*3+1],ie[me*9+8]=p[Ze*3+2],le[me*9+0]=D[Se*3+0],le[me*9+1]=D[Se*3+1],le[me*9+2]=D[Se*3+2],le[me*9+3]=D[Me*3+0],le[me*9+4]=D[Me*3+1],le[me*9+5]=D[Me*3+2],le[me*9+6]=D[Ze*3+0],le[me*9+7]=D[Ze*3+1],le[me*9+8]=D[Ze*3+2],ge&&B&&(ge[me*9+0]=B[Se*3+0],ge[me*9+1]=B[Se*3+1],ge[me*9+2]=B[Se*3+2],ge[me*9+3]=B[Me*3+0],ge[me*9+4]=B[Me*3+1],ge[me*9+5]=B[Me*3+2],ge[me*9+6]=B[Ze*3+0],ge[me*9+7]=B[Ze*3+1],ge[me*9+8]=B[Ze*3+2])}re=ie,ce=le,Ae=ge;const Ie=new Uint32Array(H*3);for(let me=0;me<H*3;me++)Ie[me]=me;Ve=Ie}else Ve=new Uint32Array(w),Qe=y;return{vertexCount:U&&Q.length>0?re.length/3:t,faceCount:a,position:re,normal:ce,color:Ae,uv:Qe,indices:Ve,textureFiles:n.length>0?n:void 0,triangleTexnumbers:E.length>0?E:void 0}}function Yh(s){const e=Hi(s),{format:t}=e;return t==="ascii"?Vp(s,e):Pp(s,e)}function Pp(s,e){const{vertexCount:t,properties:a,headerByteLength:r}=e,i=new DataView(s,r),n=g=>a.find(p=>p.name===g)!=null,o=g=>a.findIndex(p=>p.name===g),l=new Float32Array(t*3),c=(n("red")||n("r"))&&(n("green")||n("g"))&&(n("blue")||n("b")),f=n("alpha")||n("a"),d=c?new Uint8Array(t*4):void 0,h=[];let u=0;for(const g of a)h.push(u),u+=ea(g.type);let m=0;for(let g=0;g<t;g++){const p=m,A=o("x"),D=o("y"),B=o("z");if(A<0||D<0||B<0)throw new Error("PLY: Missing x/y/z for vertex");if(l[g*3+0]=pe(i,p+h[A],a[A].type),l[g*3+1]=pe(i,p+h[D],a[D].type),l[g*3+2]=pe(i,p+h[B],a[B].type),d){const v=o("red")>=0?o("red"):o("r"),U=o("green")>=0?o("green"):o("g"),y=o("blue")>=0?o("blue"):o("b"),S=f?o("alpha")>=0?o("alpha"):o("a"):-1;if(v>=0&&U>=0&&y>=0){let F=pe(i,p+h[v],a[v].type),C=pe(i,p+h[U],a[U].type),w=pe(i,p+h[y],a[y].type),E=255;(a[v].type==="float"||a[v].type==="float32"||a[v].type==="double"||a[v].type==="float64")&&(F=Math.round(F*255),C=Math.round(C*255),w=Math.round(w*255)),S>=0&&(E=pe(i,p+h[S],a[S].type),(a[S].type==="float"||a[S].type==="float32"||a[S].type==="double"||a[S].type==="float64")&&(E=Math.round(E*255))),d[g*4+0]=Math.max(0,Math.min(255,F)),d[g*4+1]=Math.max(0,Math.min(255,C)),d[g*4+2]=Math.max(0,Math.min(255,w)),d[g*4+3]=Math.max(0,Math.min(255,E))}}m+=u}return{vertexCount:t,position:l,color:d}}function Vp(s,e){const{vertexCount:t,properties:a}=e,r=new TextDecoder("utf-8").decode(s),i=r.indexOf("end_header");if(i<0)throw new Error("PLY: Invalid PLY header");let n=i+10;for(;n<r.length&&(r[n]===" "||r[n]===`
11850
11850
  `||r[n]==="\r");)n++;const l=r.substring(n).split(/\s+/).filter(F=>F.length>0);let c=0;const f=F=>a.find(C=>C.name===F)!=null,d=F=>{if(c>=l.length)throw new Error("PLY: Unexpected end of file");const C=l[c++];switch(F){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(C);case"float":case"double":case"float32":case"float64":return parseFloat(C);default:return parseFloat(C)}},h=new Float32Array(t*3),u=(f("red")||f("r"))&&(f("green")||f("g"))&&(f("blue")||f("b")),m=f("alpha")||f("a"),g=u?new Uint8Array(t*4):void 0,p=F=>a.findIndex(C=>C.name===F),A=p("x"),D=p("y"),B=p("z"),v=u?p("red")>=0?p("red"):p("r"):-1,U=u?p("green")>=0?p("green"):p("g"):-1,y=u?p("blue")>=0?p("blue"):p("b"):-1,S=m?p("alpha")>=0?p("alpha"):p("a"):-1;for(let F=0;F<t;F++){for(let C=0;C<a.length;C++){const w=a[C],E=d(w.type);if(C===A)h[F*3+0]=E;else if(C===D)h[F*3+1]=E;else if(C===B)h[F*3+2]=E;else if(C===v&&g){const Q=w.type==="uchar"||w.type==="uint8"?E:Math.round(E*255);g[F*4+0]=Math.max(0,Math.min(255,Q))}else if(C===U&&g){const Q=w.type==="uchar"||w.type==="uint8"?E:Math.round(E*255);g[F*4+1]=Math.max(0,Math.min(255,Q))}else if(C===y&&g){const Q=w.type==="uchar"||w.type==="uint8"?E:Math.round(E*255);g[F*4+2]=Math.max(0,Math.min(255,Q))}else if(C===S&&g){const Q=w.type==="uchar"||w.type==="uint8"?E:Math.round(E*255);g[F*4+3]=Math.max(0,Math.min(255,Q))}}g&&S<0&&(g[F*4+3]=255)}return{vertexCount:t,position:h,color:g}}class xs{_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,n=this._headerBuffer.subarray(0,i),o=n.buffer.slice(n.byteOffset,n.byteOffset+n.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 d=e.subarray(f);this._processDataChunk(d)}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 n="",o=0,l=0;const c=[],f=[],d=[];let h=!1,u=!1;for(const A of i)if(A.startsWith("format "))n=A.split(/\s+/)[1];else if(A.startsWith("comment TextureFile ")){const D=A.substring(20).trim();D&&d.push(D)}else if(A.startsWith("element ")){const D=A.split(/\s+/);h=D[1]==="vertex",u=D[1]==="face",h&&(o=parseInt(D[2]),u=!1),u&&(l=parseInt(D[2]),h=!1)}else if(h&&A.startsWith("property ")){const D=A.split(/\s+/),B=D[1],v=D[2];c.push({name:v,type:B})}else if(u&&A.startsWith("property ")){const D=A.split(/\s+/);if(D[1]==="list"){const B=D[2],v=D[3],U=D[4];f.push({name:U,type:`list ${B} ${v}`})}else{const B=D[1],v=D[2];f.push({name:v,type:B})}}if(n!=="binary_little_endian"&&n!=="ascii")throw new Error(`PLY: Unsupported format: ${n}`);let m=0,g=0;for(const A of c)Xi.includes(A.name)&&m++,Xo.includes(A.name)&&g++;let p;return l>0?p=Ca.Mesh:m===Xi.length&&g===3?p=Ca.Splat:p=Ca.PointCloud,{format:n,vertexCount:o,faceCount:l,properties:c,faceProperties:f.length>0?f:void 0,textureFiles:d,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+=ea(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 n=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"),d=r("z");if(c<0||f<0||d<0)throw new Error("PLY: Missing required x/y/z properties for vertex");const h={position:[pe(e,l+this._propOffsets[c],this._properties[c].type),pe(e,l+this._propOffsets[f],this._properties[f].type),pe(e,l+this._propOffsets[d],this._properties[d].type)]};if(a("scale_0")&&(h.scale=[pe(e,l+this._propOffsets[r("scale_0")],this._properties[r("scale_0")].type),pe(e,l+this._propOffsets[r("scale_1")],this._properties[r("scale_1")].type),pe(e,l+this._propOffsets[r("scale_2")],this._properties[r("scale_2")].type)]),a("rot_0")){const m=pe(e,l+this._propOffsets[r("rot_0")],this._properties[r("rot_0")].type),g=pe(e,l+this._propOffsets[r("rot_1")],this._properties[r("rot_1")].type),p=pe(e,l+this._propOffsets[r("rot_2")],this._properties[r("rot_2")].type),A=pe(e,l+this._propOffsets[r("rot_3")],this._properties[r("rot_3")].type);h.rotation=[g,p,A,m]}a("opacity")&&(h.opacity=pe(e,l+this._propOffsets[r("opacity")],this._properties[r("opacity")].type));const u=[r("f_dc_0"),r("f_dc_1"),r("f_dc_2")];if(u[0]>=0&&u[1]>=0&&u[2]>=0){const m=[];for(let v=0;v<this._properties.length;v++)this._properties[v].name.startsWith("f_rest_")&&m.push(v);const g=1+m.length/3,p=new Float32Array(g*3);p[0]=pe(e,l+this._propOffsets[u[0]],this._properties[u[0]].type),p[g+0]=pe(e,l+this._propOffsets[u[1]],this._properties[u[1]].type),p[2*g+0]=pe(e,l+this._propOffsets[u[2]],this._properties[u[2]].type);let A=1,D=1,B=1;for(let v=0;v<m.length;v+=3){const U=m[v+0],y=m[v+1],S=m[v+2];p[A]=pe(e,l+this._propOffsets[U],this._properties[U].type),p[g+D]=pe(e,l+this._propOffsets[y],this._properties[y].type),p[2*g+B]=pe(e,l+this._propOffsets[S],this._properties[S].type),A++,D++,B++}h.sh={order:Math.floor(Math.sqrt(g)),coeffs:p}}if(this._onSplatParsed&&this._onSplatParsed(h,o),this._processedVertices++,n++,this._processedVertices%this._batchSize===0){this._scheduleNextChunk();return}if(n>=xs.sVerticesPerChunk){if(performance.now()-i>xs.sMaxProcessingTime){this._scheduleNextChunk();return}n=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 Op extends it{static format=je.BIN;async parseBuffer(e){const t=jh(e);let a;switch(t){case Di.PLY:{const r=Ko(e);a={count:r.vertexCount,position:r.position,rotation:r.rotation,scale:r.scale,opacity:r.opacity,sh:r.sh},a.bbox=Yo(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 Lp extends it{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 ne,this._rendererObject.name="StreamingGaussianSplat",this._streamingRenderer=this._rendererObject.addComponent(_r),this._streamParser=new xs(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 Hs=(s=>(s.Point="Point",s.LineString="LineString",s.MultiPolygon="MultiPolygon",s))(Hs||{});class Gp extends it{static format=je.JSON;json;async parseString(e){this.json=e,this.data=JSON.parse(e)}}class zp{static getPath(e){let t=[];for(let a=0;a<e.features.length;a++){const r=e.features[a];switch(r.geometry.type){case Hs.LineString:break;case Hs.MultiPolygon:let i=[];for(let n=0;n<r.geometry.coordinates.length;n++){const o=r.geometry.coordinates[n];for(const l of o)for(const c of l){let f=new b(c[0],0,c[1]);i.push(f)}}t.push(i);break}}return t}}class Wp{name;defines;doubleSided;baseColorFactor;emissiveFactor;metallicFactor;roughnessFactor;alphaCutoff;enableBlend;baseColorTexture;metallicRoughnessTexture;normalTexture;occlusionTexture;emissiveTexture;extensions;baseMapOffsetSize;normalMapOffsetSize;emissiveMapOffsetSize;roughnessMapOffsetSize;metallicMapOffsetSize;aoMapOffsetSize}class Jp{}class jp{}class jt{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 n="",o=0,l=0;const c=[],f=[],d=[];let h=!1,u=!1;for(const A of i)if(A.startsWith("format "))n=A.split(/\s+/)[1];else if(A.startsWith("comment TextureFile ")){const D=A.substring(20).trim();D&&d.push(D)}else if(A.startsWith("element ")){const D=A.split(/\s+/);h=D[1]==="vertex",u=D[1]==="face",h&&(o=parseInt(D[2]),u=!1),u&&(l=parseInt(D[2]),h=!1)}else if(h&&A.startsWith("property ")){const D=A.split(/\s+/),B=D[1],v=D[2];c.push({name:v,type:B})}else if(u&&A.startsWith("property ")){const D=A.split(/\s+/);if(D[1]==="list"){const B=D[2],v=D[3],U=D[4];f.push({name:U,type:`list ${B} ${v}`})}else{const B=D[1],v=D[2];f.push({name:v,type:B})}}if(n!=="binary_little_endian"&&n!=="ascii")throw new Error(`PLY: Unsupported format: ${n}`);let m=0,g=0;for(const A of c)Xi.includes(A.name)&&m++,Xo.includes(A.name)&&g++;let p;return l>0?p=Ca.Mesh:m===Xi.length&&g===3?p=Ca.Splat:p=Ca.PointCloud,{format:n,vertexCount:o,faceCount:l,properties:c,faceProperties:f.length>0?f:void 0,textureFiles:d,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+=ea(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 n=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"),d=r("z");if(c<0||f<0||d<0)throw new Error("PLY: Missing required x/y/z properties for vertex");const h={position:[pe(e,l+this._propOffsets[c],this._properties[c].type),pe(e,l+this._propOffsets[f],this._properties[f].type),pe(e,l+this._propOffsets[d],this._properties[d].type)]};if(a("scale_0")&&(h.scale=[pe(e,l+this._propOffsets[r("scale_0")],this._properties[r("scale_0")].type),pe(e,l+this._propOffsets[r("scale_1")],this._properties[r("scale_1")].type),pe(e,l+this._propOffsets[r("scale_2")],this._properties[r("scale_2")].type)]),a("rot_0")){const m=pe(e,l+this._propOffsets[r("rot_0")],this._properties[r("rot_0")].type),g=pe(e,l+this._propOffsets[r("rot_1")],this._properties[r("rot_1")].type),p=pe(e,l+this._propOffsets[r("rot_2")],this._properties[r("rot_2")].type),A=pe(e,l+this._propOffsets[r("rot_3")],this._properties[r("rot_3")].type);h.rotation=[g,p,A,m]}a("opacity")&&(h.opacity=pe(e,l+this._propOffsets[r("opacity")],this._properties[r("opacity")].type));const u=[r("f_dc_0"),r("f_dc_1"),r("f_dc_2")];if(u[0]>=0&&u[1]>=0&&u[2]>=0){const m=[];for(let v=0;v<this._properties.length;v++)this._properties[v].name.startsWith("f_rest_")&&m.push(v);const g=1+m.length/3,p=new Float32Array(g*3);p[0]=pe(e,l+this._propOffsets[u[0]],this._properties[u[0]].type),p[g+0]=pe(e,l+this._propOffsets[u[1]],this._properties[u[1]].type),p[2*g+0]=pe(e,l+this._propOffsets[u[2]],this._properties[u[2]].type);let A=1,D=1,B=1;for(let v=0;v<m.length;v+=3){const U=m[v+0],y=m[v+1],S=m[v+2];p[A]=pe(e,l+this._propOffsets[U],this._properties[U].type),p[g+D]=pe(e,l+this._propOffsets[y],this._properties[y].type),p[2*g+B]=pe(e,l+this._propOffsets[S],this._properties[S].type),A++,D++,B++}h.sh={order:Math.floor(Math.sqrt(g)),coeffs:p}}if(this._onSplatParsed&&this._onSplatParsed(h,o),this._processedVertices++,n++,this._processedVertices%this._batchSize===0){this._scheduleNextChunk();return}if(n>=xs.sVerticesPerChunk){if(performance.now()-i>xs.sMaxProcessingTime){this._scheduleNextChunk();return}n=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 Op extends it{static format=je.BIN;async parseBuffer(e){const t=jh(e);let a;switch(t){case Di.PLY:{const r=Ko(e);a={count:r.vertexCount,position:r.position,rotation:r.rotation,scale:r.scale,opacity:r.opacity,sh:r.sh},a.bbox=Yo(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 Lp extends it{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 ne,this._rendererObject.name="StreamingGaussianSplat",this._streamingRenderer=this._rendererObject.addComponent(_r),this._streamParser=new xs(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 Hs=(s=>(s.Point="Point",s.LineString="LineString",s.MultiPolygon="MultiPolygon",s))(Hs||{});class Gp extends it{static format=je.JSON;json;async parseString(e){this.json=e,this.data=JSON.parse(e)}}class zp{static getPath(e){let t=[];for(let a=0;a<e.features.length;a++){const r=e.features[a];switch(r.geometry.type){case Hs.LineString:break;case Hs.MultiPolygon:let i=[];for(let n=0;n<r.geometry.coordinates.length;n++){const o=r.geometry.coordinates[n];for(const l of o)for(const c of l){let f=new b(c[0],0,c[1]);i.push(f)}}t.push(i);break}}return t}}class Wp{name;defines;doubleSided;baseColorFactor;emissiveFactor;metallicFactor;roughnessFactor;alphaCutoff;enableBlend;baseColorTexture;metallicRoughnessTexture;normalTexture;occlusionTexture;emissiveTexture;extensions;baseMapOffsetSize;normalMapOffsetSize;emissiveMapOffsetSize;roughnessMapOffsetSize;metallicMapOffsetSize;aoMapOffsetSize}class Jp{}class jp{}class jt{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",n=r.split(/\s{2,}|\s+/),o=n[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 d=n.length>1?n[n.length-1].trim():"";return{mnemonic:c.toUpperCase(),unit:f,value:d,description:i||"none"}}}class Xh{async parse(e){if(e instanceof ArrayBuffer){const t=new DataView(e);if(ci(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),n=a.NULL?.value,o=typeof n=="string"?+n:n,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=ci(t);if(a!=="LASF")throw new Error(`LASLoader: Invalid binary LAS file, expected 'LASF' magic bytes, got '${a}'`);const r=t.getUint8(24),n=t.getUint8(25)+r/10,o=t.getUint8(104),l=t.getUint32(107,!0),c=t.getFloat64(131,!0),f=t.getFloat64(139,!0),d=t.getFloat64(147,!0),h=t.getFloat64(155,!0),u=t.getFloat64(163,!0),m=t.getFloat64(171,!0),g=t.getFloat64(187,!0),p=t.getFloat64(195,!0),A=t.getFloat64(203,!0),D=t.getFloat64(211,!0),B=t.getFloat64(219,!0),v=t.getFloat64(227,!0),U=t.getUint32(96,!0),y=t.getUint32(100,!0);let S=U;for(let T=0;T<y;T++){const j=t.getUint16(S+54,!0);S+=54+j}const C=[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),E=new Uint8Array(l*4);let Q=S;for(let T=0;T<l;T++){const j=Q+T*C;let ue,ee,N;o>=6?(ue=Number(t.getBigInt64(j,!0)),ee=Number(t.getBigInt64(j+8,!0)),N=Number(t.getBigInt64(j+16,!0))):(ue=t.getInt32(j,!0),ee=t.getInt32(j+4,!0),N=t.getInt32(j+8,!0));const M=ue*c+h,O=ee*f+u,W=N*d+m;w[T*3+0]=M,w[T*3+1]=O,w[T*3+2]=W;let ae;o>=6?ae=j+24:ae=j+12;const z=t.getUint16(ae,!0);if([2,3,5,7,8,9,10].includes(o)){let K;const $=j+C;if(o===5?K=j+28:o===10?K=j+59:K=$-6,K>=j&&K+6<=$&&K+6<=e.byteLength)try{const re=t.getUint16(K,!0),ce=t.getUint16(K+2,!0),Ae=t.getUint16(K+4,!0);E[T*4+0]=re<256?re:re>>8,E[T*4+1]=ce<256?ce:ce>>8,E[T*4+2]=Ae<256?Ae:Ae>>8,E[T*4+3]=255}catch(re){console.warn(`LASLoader: Failed to read RGB at offset ${K} (format ${o}, record length ${C}), using intensity instead. Error: ${re}`);const ce=Math.min(z/65535,1);E[T*4+0]=Math.floor(ce*255),E[T*4+1]=Math.floor(ce*255),E[T*4+2]=Math.floor(ce*255),E[T*4+3]=255}else{console.warn(`LASLoader: RGB offset ${K} out of bounds (offset: ${j}, record end: ${$}, buffer size: ${e.byteLength}, format: ${o}), using intensity instead`);const re=Math.min(z/65535,1);E[T*4+0]=Math.floor(re*255),E[T*4+1]=Math.floor(re*255),E[T*4+2]=Math.floor(re*255),E[T*4+3]=255}}else{const K=Math.min(z/65535,1);E[T*4+0]=Math.floor(K*255),E[T*4+1]=Math.floor(K*255),E[T*4+2]=Math.floor(K*255),E[T*4+3]=255}}return{format:"binary",version:n,pointDataFormat:o,numPoints:l,positions:w,colors:E,bbox:{xMin:g,xMax:p,yMin:A,yMax:D,zMin:B,zMax:v},scale:{x:c,y:f,z:d},offset:{x:h,y:u,z:m}}}parseMetadata(e){const t=jt.parseSection(e,"V");if(!t)throw new Error("LASLoader: ~VERSION section not found");const r=jt.removeComment(t).split(`
11855
11855
  `).filter(Boolean);let i=2,n=!1;for(const o of r){const l=o.split(/\s{2,}|\s*:/).filter(Boolean);if(l.length>=2){const c=l[0].trim().toUpperCase(),f=l[1].trim().toUpperCase();if(c==="VERS"||c==="VERSION"){const d=f.match(/(\d+\.?\d*)/);d&&(i=+d[1])}else(c==="WRAP"||c==="WRAP.")&&(n=f==="YES"||f==="Y")}}return{version:i,wrap:n}}parseWellParams(e){const t=jt.parseSection(e,"W");if(!t)return{};const r=jt.removeComment(t).split(`