@rings-webgpu/core 1.0.25 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rings.umd.js CHANGED
@@ -5692,7 +5692,7 @@ struct InstanceData {
5692
5692
  var outColor: vec4<f32> = textureSampleLevel(img, imgSampler, texCoord, 0.0);
5693
5693
  return outColor;
5694
5694
  }
5695
- `;static pipelineCache={};static pipeline;static getMipmapPipeline(e){let t=E.device,a=aa.pipelineCache[e.format];if(!a){const r=t.createShaderModule({code:aa.mipmapShader});let i=t.createBindGroupLayout({entries:[{binding:0,visibility:e.visibility,sampler:e.samplerBindingLayout},{binding:1,visibility:e.visibility,texture:e.textureBindingLayout}]}),n=E.device.createPipelineLayout({bindGroupLayouts:[i]});a=t.createRenderPipeline({layout:n,vertex:{module:r,entryPoint:"vertexMain"},fragment:{module:r,entryPoint:"fragmentMain",targets:[{format:e.format}]},primitive:{topology:"triangle-strip",stripIndexFormat:"uint32"}}),aa.pipelineCache[e.format]=a}return a}static webGPUGenerateMipmap(e){let t=E.device,a=e.textureDescriptor,r=aa.getMipmapPipeline(e),i=e.getGPUTexture().createView({baseMipLevel:0,mipLevelCount:1});const n=S.beginCommandEncoder();for(let o=1;o<a.mipLevelCount;++o){const l=e.getGPUTexture().createView({baseMipLevel:o,mipLevelCount:1}),c=n.beginRenderPass({colorAttachments:[{view:l,clearValue:[0,0,0,0],loadOp:"clear",storeOp:"store"}]});let f=t.createBindGroupLayout({entries:[{binding:0,visibility:e.visibility,sampler:e.samplerBindingLayout},{binding:1,visibility:e.visibility,texture:e.textureBindingLayout}]});const h=t.createBindGroup({layout:f,entries:[{binding:0,resource:e.gpuSampler},{binding:1,resource:i}]});c.setPipeline(r),c.setBindGroup(0,h),c.draw(4),c.end(),i=l}S.endCommandEncoder(n)}static getMipmapCount(e,t){let i=Math.max(e,t);return 1+Math.log2(i)|0}}class Xe{name;url;gpuTexture;pid;view;gpuSampler;gpuSampler_comparison;format;usage;width=4;height=4;depthOrArrayLayers=1;numberLayer=1;viewDescriptor;textureDescriptor;visibility=GPUShaderStage.COMPUTE|GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT;textureBindingLayout={viewDimension:"2d",multisampled:!1};samplerBindingLayout={type:"filtering"};sampler_comparisonBindingLayout={type:"comparison"};flipY;isVideoTexture;isHDRTexture;_useMipmap=!1;_sourceImageData;_addressModeU;_addressModeV;_addressModeW;_magFilter;_minFilter;_mipmapFilter;_lodMinClamp;_lodMaxClamp;_compare;_maxAnisotropy;mipmapCount=1;_textureChange=!1;constructor(e=32,t=32,a=1){this.width=e,this.height=t,this.numberLayer=a,this.minFilter=qa.linear,this.magFilter=qa.linear,this.mipmapFilter=qa.linear,this.addressModeU=Pt.repeat,this.addressModeV=Pt.repeat}init(){let e=this;return e.internalCreateBindingLayoutDesc&&e.internalCreateBindingLayoutDesc(),e.internalCreateTexture&&e.internalCreateTexture(),e.internalCreateView&&e.internalCreateView(),e.internalCreateSampler&&e.internalCreateSampler(),this}createTextureDescriptor(e,t,a,r,i=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.STORAGE_BINDING,n=1,o=0){this.width=e,this.height=t,this.format=r,this.usage=i,this.textureDescriptor={size:[e,t,n],mipLevelCount:a,format:r,usage:i,label:`${this.name+this.width+this.height+this.format}`},o>0&&(this.textureDescriptor.sampleCount=o),n>1?this.viewDescriptor={format:r,dimension:"2d-array"}:this.viewDescriptor={format:r,dimension:this.textureBindingLayout.viewDimension,mipLevelCount:a,baseMipLevel:0}}generate(e){let t=32,a=32;"width"in e&&(t=e.width,a=e.height),(t<32||a<32)&&console.log(e.name+"Size must be greater than 32!"),this.width=t,this.height=a,this.createTexture(e)}createTexture(e){this._sourceImageData=e,this.updateTextureDescription(),this.updateGPUTexture();let t=E.device;this.gpuTexture instanceof GPUTexture&&t.queue.copyExternalImageToTexture({source:this._sourceImageData},{texture:this.gpuTexture},[this.width,this.height]),this.useMipmap&&aa.webGPUGenerateMipmap(this)}get useMipmap(){return this._useMipmap}set useMipmap(e){if(e){if(this.samplerBindingLayout.type="filtering",this._useMipmap==!1&&this._sourceImageData){this._useMipmap=!0,this.updateTextureDescription(),this.updateGPUTexture();let t=E.device;this.gpuTexture instanceof GPUTexture&&t.queue.copyExternalImageToTexture({source:this._sourceImageData},{texture:this.gpuTexture},[this.width,this.height]),aa.webGPUGenerateMipmap(this)}}else if(this.samplerBindingLayout.type="non-filtering",this._useMipmap==!0&&this._sourceImageData){this._useMipmap=!1,this.updateTextureDescription(),this.updateGPUTexture();let t=E.device;this.gpuTexture instanceof GPUTexture&&t.queue.copyExternalImageToTexture({source:this._sourceImageData},{texture:this.gpuTexture},[this.width,this.height])}this._textureChange=!0,this._useMipmap=e,this.noticeChange()}get sourceImageData(){return this._sourceImageData}getMipmapCount(){let e=this.width,t=this.height,a=Math.max(e,t);return 1+Math.log2(a)|0}updateTextureDescription(){this.mipmapCount=Math.floor(this.useMipmap?this.getMipmapCount():1),this.createTextureDescriptor(this.width,this.height,this.mipmapCount,this.format)}updateGPUTexture(){this.gpuTexture&&this.gpuTexture instanceof GPUTexture&&this.gpuTexture.destroy(),this.gpuTexture=null,this.view=null,this.gpuTexture=this.getGPUTexture()}getGPUTexture(){return this.gpuTexture||(this.gpuTexture=E.device.createTexture(this.textureDescriptor)),this.gpuTexture}getGPUView(e=0){return this.view||(this.gpuTexture=this.getGPUTexture(),this.gpuTexture instanceof GPUTexture&&(this.view=this.gpuTexture.createView(this.viewDescriptor),this.view.label=this.name)),this.view}_stateChangeRef=new Map;bindStateChange(e,t){this._stateChangeRef.set(t,e)}unBindStateChange(e){this._stateChangeRef.delete(e)}noticeChange(){this.gpuSampler=E.device.createSampler(this),this._stateChangeRef.forEach((e,t)=>{e()})}destroy(e){e&&this.gpuTexture instanceof GPUTexture&&(this.gpuSampler=null,this.gpuSampler_comparison=null,this.textureBindingLayout=null,this.textureDescriptor=null,this.gpuTexture.destroy(),this.gpuTexture=null),this._stateChangeRef.clear()}get addressModeU(){return this._addressModeU}set addressModeU(e){this._addressModeU!=e&&(this._addressModeU=e,this.noticeChange())}get addressModeV(){return this._addressModeV}set addressModeV(e){this._addressModeV!=e&&(this._addressModeV=e,this.noticeChange())}get addressModeW(){return this._addressModeW}set addressModeW(e){this._addressModeW!=e&&(this._addressModeW=e,this.noticeChange())}get magFilter(){return this._magFilter}set magFilter(e){this._magFilter!=e&&(this._magFilter=e,this.noticeChange())}get minFilter(){return this._minFilter}set minFilter(e){this._minFilter!=e&&(this._minFilter=e,this.noticeChange())}get mipmapFilter(){return this._mipmapFilter}set mipmapFilter(e){this._mipmapFilter!=e&&(this._mipmapFilter=e,this.noticeChange())}get lodMinClamp(){return this._lodMinClamp}set lodMinClamp(e){this._lodMinClamp!=e&&(this._lodMinClamp=e,this.noticeChange())}get lodMaxClamp(){return this._lodMaxClamp}set lodMaxClamp(e){this._lodMaxClamp!=e&&(this._lodMaxClamp=e,this.noticeChange())}get compare(){return this._compare}set compare(e){this._compare!=e&&(this._compare=e,this.noticeChange())}get maxAnisotropy(){return this._maxAnisotropy}set maxAnisotropy(e){this._maxAnisotropy!=e&&(this._maxAnisotropy=e,this.noticeChange())}static _texs=[];static delayDestroyTexture(e){this._texs.includes(e)||this._texs.push(e)}static destroyTexture(){if(this._texs.length>0)for(;this._texs.length>0;)this._texs.shift().destroy()}}class sc extends Xe{_bitmapTextures;constructor(e,t,a){super(e,t,a),this.format=Y.rgba8unorm,this.mipmapCount=1,this._bitmapTextures=[],this.init()}setTextures(e){this._bitmapTextures.length=0;for(let t=0;t<e.length;t++){const a=e[t];this.addTexture(a)}}addTexture(e){(e.width!=this.width||e.height!=this.height)&&console.error("bitmap texture must match bitmapTextureArray size!"),e.pid=this._bitmapTextures.length,this._bitmapTextures.push(e),this.updateTexture()}removeTexture(e){let t=this._bitmapTextures.indexOf(e);if(t!=-1){this._bitmapTextures.splice(t,1);for(let a=0;a<this._bitmapTextures.length;a++){const r=this._bitmapTextures[a];r.pid=a}}}updateTexture(){let e=S.beginCommandEncoder();for(let t=0;t<this._bitmapTextures.length;t++){let a=this._bitmapTextures[t];e.copyTextureToTexture({texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:this.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:t}},{width:this.width,height:this.height,depthOrArrayLayers:1})}S.endCommandEncoder(e)}internalCreateBindingLayoutDesc(){this.textureBindingLayout.viewDimension="2d-array",this.samplerBindingLayout.type="filtering",this.minFilter=qa.linear,this.magFilter=qa.linear}internalCreateTexture(){this.textureDescriptor={format:this.format,size:{width:this.width,height:this.height,depthOrArrayLayers:this.numberLayer},dimension:"2d",usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.TEXTURE_BINDING},this.gpuTexture=this.getGPUTexture()}internalCreateView(){this.viewDescriptor={dimension:"2d-array"},this.view=this.getGPUView()}internalCreateSampler(){this.gpuSampler=E.device.createSampler(this)}}class ra{static use=!1;static iesTexture;static ies_list=[];_iesTexture;index=0;constructor(){}generateIES(e){}set IESTexture(e){this._iesTexture=e,e.addressModeU=Pt.repeat,e.addressModeV=Pt.repeat,e.addressModeW=Pt.repeat,ra.ies_list.indexOf(this)==-1&&(this.index=ra.ies_list.length,ra.ies_list.push(this),ra.iesTexture||ra.create(e.width,e.height),ra.iesTexture.addTexture(e))}get IESTexture(){return this._iesTexture}static create(e,t){let a=48;this.iesTexture=new sc(e,t,a)}}class is{static _globalDataBindGroupLayout;static getGlobalDataBindGroupLayout(){if(this._globalDataBindGroupLayout)return this._globalDataBindGroupLayout;let e=[];return e.push({binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,buffer:{type:"uniform"}}),e.push({binding:1,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,buffer:{type:"read-only-storage"}}),this._globalDataBindGroupLayout=E.device.createBindGroupLayout({entries:e}),this._globalDataBindGroupLayout}}class bi{Type=0;Line=0;Colume=0;Literal="";constructor(e=0,t="\0"){this.Type=e,this.Literal=t}isTypeEqual(e){return this.Type==e}isLiteralEqual(e){return this.Literal==e}isBuiltinType(){return this.Type>33&&this.Type<101}isDataType(){return this.Type==1||this.isBuiltinType()}isOperation(){return this.Type>102&&this.Type<127}isAssignOperation(){return this.Type>128&&this.Type<133}get nOperationPriorityLevel(){switch(this.Type){case 26:return 1;case 27:return 1;case 125:return 2;case 110:return 3;case 114:return 3;case 105:return 4;case 106:return 4;case 103:return 5;case 104:return 5;case 115:return 6;case 116:return 6;case 119:return 7;case 120:return 7;case 122:return 7;case 123:return 7;case 121:return 8;case 124:return 8;case 111:return 9;case 113:return 10;case 112:return 11;case 107:return 12;case 109:return 13;case 108:return 14;case 24:return 15;case 126:return 16;case 129:return 16;case 130:return 16;case 131:return 16;case 132:return 16}return 99}}var U=(s=>(s[s.EOF=0]="EOF",s[s.IDENT=1]="IDENT",s[s.VOID=2]="VOID",s[s.CONST=3]="CONST",s[s.LAYOUT=4]="LAYOUT",s[s.PRECISION=5]="PRECISION",s[s.ATTRIBUTE=6]="ATTRIBUTE",s[s.UNIFORM=7]="UNIFORM",s[s.VARYING=8]="VARYING",s[s.INVARIANT=9]="INVARIANT",s[s.IN=10]="IN",s[s.OUT=11]="OUT",s[s.INOUT=12]="INOUT",s[s.IF=13]="IF",s[s.ELSE=14]="ELSE",s[s.FOR=15]="FOR",s[s.WHILE=16]="WHILE",s[s.DO=17]="DO",s[s.BREAK=18]="BREAK",s[s.RETURN=19]="RETURN",s[s.CONTINUE=20]="CONTINUE",s[s.STRUCT=21]="STRUCT",s[s.COMMA=22]="COMMA",s[s.COLON=23]="COLON",s[s.QUEMARK=24]="QUEMARK",s[s.SEMICOLON=25]="SEMICOLON",s[s.LEFTSAMLL=26]="LEFTSAMLL",s[s.RIGHTSAMLL=27]="RIGHTSAMLL",s[s.LEFTMEDI=28]="LEFTMEDI",s[s.RIGHTMEDI=29]="RIGHTMEDI",s[s.LEFTBIG=30]="LEFTBIG",s[s.RIGHTBIG=31]="RIGHTBIG",s[s.LITERAL=32]="LITERAL",s[s.BeginBuiltinType=33]="BeginBuiltinType",s[s.INT=34]="INT",s[s.INT_ARRAY=35]="INT_ARRAY",s[s.UINT=36]="UINT",s[s.UINT_ARRAY=37]="UINT_ARRAY",s[s.BOOL=38]="BOOL",s[s.BOOL_ARRAY=39]="BOOL_ARRAY",s[s.FLOAT=40]="FLOAT",s[s.FLOAT_ARRAY=41]="FLOAT_ARRAY",s[s.DOUBLE=42]="DOUBLE",s[s.DOUBLE_ARRAY=43]="DOUBLE_ARRAY",s[s.VEC2=44]="VEC2",s[s.VEC2_ARRAY=45]="VEC2_ARRAY",s[s.VEC3=46]="VEC3",s[s.VEC3_ARRAY=47]="VEC3_ARRAY",s[s.VEC4=48]="VEC4",s[s.VEC4_ARRAY=49]="VEC4_ARRAY",s[s.BVEC2=50]="BVEC2",s[s.BVEC2_ARRAY=51]="BVEC2_ARRAY",s[s.BVEC3=52]="BVEC3",s[s.BVEC3_ARRAY=53]="BVEC3_ARRAY",s[s.BVEC4=54]="BVEC4",s[s.BVEC4_ARRAY=55]="BVEC4_ARRAY",s[s.IVEC2=56]="IVEC2",s[s.IVEC2_ARRAY=57]="IVEC2_ARRAY",s[s.IVEC3=58]="IVEC3",s[s.IVEC3_ARRAY=59]="IVEC3_ARRAY",s[s.IVEC4=60]="IVEC4",s[s.IVEC4_ARRAY=61]="IVEC4_ARRAY",s[s.UVEC2=62]="UVEC2",s[s.UVEC2_ARRAY=63]="UVEC2_ARRAY",s[s.UVEC3=64]="UVEC3",s[s.UVEC3_ARRAY=65]="UVEC3_ARRAY",s[s.UVEC4=66]="UVEC4",s[s.UVEC4_ARRAY=67]="UVEC4_ARRAY",s[s.MAT2x2=68]="MAT2x2",s[s.MAT2x2_ARRAY=69]="MAT2x2_ARRAY",s[s.MAT2x3=70]="MAT2x3",s[s.MAT2x3_ARRAY=71]="MAT2x3_ARRAY",s[s.MAT2x4=72]="MAT2x4",s[s.MAT2x4_ARRAY=73]="MAT2x4_ARRAY",s[s.MAT3x2=74]="MAT3x2",s[s.MAT3x2_ARRAY=75]="MAT3x2_ARRAY",s[s.MAT3x3=76]="MAT3x3",s[s.MAT3x3_ARRAY=77]="MAT3x3_ARRAY",s[s.MAT3x4=78]="MAT3x4",s[s.MAT3x4_ARRAY=79]="MAT3x4_ARRAY",s[s.MAT4x2=80]="MAT4x2",s[s.MAT4x2_ARRAY=81]="MAT4x2_ARRAY",s[s.MAT4x3=82]="MAT4x3",s[s.MAT4x3_ARRAY=83]="MAT4x3_ARRAY",s[s.MAT4x4=84]="MAT4x4",s[s.MAT4x4_ARRAY=85]="MAT4x4_ARRAY",s[s.SAMPLER=86]="SAMPLER",s[s.SAMPLER_1D=87]="SAMPLER_1D",s[s.SAMPLER_2D=88]="SAMPLER_2D",s[s.SAMPLER_3D=89]="SAMPLER_3D",s[s.SAMPLER_CUBE=90]="SAMPLER_CUBE",s[s.SAMPLER_SHADOW=91]="SAMPLER_SHADOW",s[s.SAMPLER_1D_SHADOW=92]="SAMPLER_1D_SHADOW",s[s.SAMPLER_2D_SHADOW=93]="SAMPLER_2D_SHADOW",s[s.TEXTURE_1D=94]="TEXTURE_1D",s[s.TEXTURE_1D_ARRAY=95]="TEXTURE_1D_ARRAY",s[s.TEXTURE_2D=96]="TEXTURE_2D",s[s.TEXTURE_2D_ARRAY=97]="TEXTURE_2D_ARRAY",s[s.TEXTURE_3D=98]="TEXTURE_3D",s[s.TEXTURE_CUBE=99]="TEXTURE_CUBE",s[s.TEXTURE_CUBE_ARRAY=100]="TEXTURE_CUBE_ARRAY",s[s.EndBuiltinType=101]="EndBuiltinType",s[s.BeginOperation=102]="BeginOperation",s[s.ADD=103]="ADD",s[s.SUB=104]="SUB",s[s.MUL=105]="MUL",s[s.DIV=106]="DIV",s[s.AND=107]="AND",s[s.OR=108]="OR",s[s.XOR=109]="XOR",s[s.NOT=110]="NOT",s[s.BITAND=111]="BITAND",s[s.BITOR=112]="BITOR",s[s.BITXOR=113]="BITXOR",s[s.BITNOT=114]="BITNOT",s[s.BITSHIFT_L=115]="BITSHIFT_L",s[s.BITSHIFT_R=116]="BITSHIFT_R",s[s.INC=117]="INC",s[s.DEC=118]="DEC",s[s.GREATER=119]="GREATER",s[s.GREATEREQUAL=120]="GREATEREQUAL",s[s.EQUAL=121]="EQUAL",s[s.LESS=122]="LESS",s[s.LESSEQUAL=123]="LESSEQUAL",s[s.NOTEQUAL=124]="NOTEQUAL",s[s.DOT=125]="DOT",s[s.ASSIGN=126]="ASSIGN",s[s.EndOperation=127]="EndOperation",s[s.BeginAssignOperation=128]="BeginAssignOperation",s[s.ADDASSIGN=129]="ADDASSIGN",s[s.SUBASSIGN=130]="SUBASSIGN",s[s.MULASSIGN=131]="MULASSIGN",s[s.DIVASSIGN=132]="DIVASSIGN",s[s.EndAssignOperation=133]="EndAssignOperation",s))(U||{});class Yr{_char;_line;_column;_source;_currPosition;_nextPosition;constructor(e){this.reset(e)}reset(e){this._char="",this._line=0,this._column=0,this._source=e,this._currPosition=0,this._nextPosition=0}get source(){return this._source}getChar(){return this._char}get currPosition(){return this._currPosition}peekChar(){return this._nextPosition>=this._source.length?"\0":this._source[this._nextPosition]}readChar(){this._char=this._nextPosition>=this._source.length?"\0":this._source[this._nextPosition],this._char!==`
5695
+ `;static pipelineCache={};static pipeline;static getMipmapPipeline(e){let t=E.device,a=aa.pipelineCache[e.format];if(!a){const r=t.createShaderModule({code:aa.mipmapShader});let i=t.createBindGroupLayout({entries:[{binding:0,visibility:e.visibility,sampler:e.samplerBindingLayout},{binding:1,visibility:e.visibility,texture:e.textureBindingLayout}]}),n=E.device.createPipelineLayout({bindGroupLayouts:[i]});a=t.createRenderPipeline({layout:n,vertex:{module:r,entryPoint:"vertexMain"},fragment:{module:r,entryPoint:"fragmentMain",targets:[{format:e.format}]},primitive:{topology:"triangle-strip",stripIndexFormat:"uint32"}}),aa.pipelineCache[e.format]=a}return a}static webGPUGenerateMipmap(e){let t=E.device,a=e.textureDescriptor,r=aa.getMipmapPipeline(e),i=e.getGPUTexture().createView({baseMipLevel:0,mipLevelCount:1});const n=S.beginCommandEncoder();for(let o=1;o<a.mipLevelCount;++o){const l=e.getGPUTexture().createView({baseMipLevel:o,mipLevelCount:1}),c=n.beginRenderPass({colorAttachments:[{view:l,clearValue:[0,0,0,0],loadOp:"clear",storeOp:"store"}]});let f=t.createBindGroupLayout({entries:[{binding:0,visibility:e.visibility,sampler:e.samplerBindingLayout},{binding:1,visibility:e.visibility,texture:e.textureBindingLayout}]});const h=t.createBindGroup({layout:f,entries:[{binding:0,resource:e.gpuSampler},{binding:1,resource:i}]});c.setPipeline(r),c.setBindGroup(0,h),c.draw(4),c.end(),i=l}S.endCommandEncoder(n)}static getMipmapCount(e,t){let i=Math.max(e,t);return 1+Math.log2(i)|0}}class Xe{name;url;gpuTexture;_isDestroyed=!1;get isDestroyed(){return this._isDestroyed}pid;view;gpuSampler;gpuSampler_comparison;format;usage;width=4;height=4;depthOrArrayLayers=1;numberLayer=1;viewDescriptor;textureDescriptor;visibility=GPUShaderStage.COMPUTE|GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT;textureBindingLayout={viewDimension:"2d",multisampled:!1};samplerBindingLayout={type:"filtering"};sampler_comparisonBindingLayout={type:"comparison"};flipY;isVideoTexture;isHDRTexture;_useMipmap=!1;_sourceImageData;_addressModeU;_addressModeV;_addressModeW;_magFilter;_minFilter;_mipmapFilter;_lodMinClamp;_lodMaxClamp;_compare;_maxAnisotropy;mipmapCount=1;_textureChange=!1;constructor(e=32,t=32,a=1){this.width=e,this.height=t,this.numberLayer=a,this.minFilter=qa.linear,this.magFilter=qa.linear,this.mipmapFilter=qa.linear,this.addressModeU=Pt.repeat,this.addressModeV=Pt.repeat}init(){let e=this;return e.internalCreateBindingLayoutDesc&&e.internalCreateBindingLayoutDesc(),e.internalCreateTexture&&e.internalCreateTexture(),e.internalCreateView&&e.internalCreateView(),e.internalCreateSampler&&e.internalCreateSampler(),this}createTextureDescriptor(e,t,a,r,i=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.STORAGE_BINDING,n=1,o=0){this.width=e,this.height=t,this.format=r,this.usage=i,this.textureDescriptor={size:[e,t,n],mipLevelCount:a,format:r,usage:i,label:`${this.name+this.width+this.height+this.format}`},o>0&&(this.textureDescriptor.sampleCount=o),n>1?this.viewDescriptor={format:r,dimension:"2d-array"}:this.viewDescriptor={format:r,dimension:this.textureBindingLayout.viewDimension,mipLevelCount:a,baseMipLevel:0}}generate(e){let t=32,a=32;"width"in e&&(t=e.width,a=e.height),(t<32||a<32)&&console.log(e.name+"Size must be greater than 32!"),this.width=t,this.height=a,this.createTexture(e)}createTexture(e){this._sourceImageData=e,this.updateTextureDescription(),this.updateGPUTexture();let t=E.device;this.gpuTexture instanceof GPUTexture&&t.queue.copyExternalImageToTexture({source:this._sourceImageData},{texture:this.gpuTexture},[this.width,this.height]),this.useMipmap&&aa.webGPUGenerateMipmap(this)}get useMipmap(){return this._useMipmap}set useMipmap(e){if(e){if(this.samplerBindingLayout.type="filtering",this._useMipmap==!1&&this._sourceImageData){this._useMipmap=!0,this.updateTextureDescription(),this.updateGPUTexture();let t=E.device;this.gpuTexture instanceof GPUTexture&&t.queue.copyExternalImageToTexture({source:this._sourceImageData},{texture:this.gpuTexture},[this.width,this.height]),aa.webGPUGenerateMipmap(this)}}else if(this.samplerBindingLayout.type="non-filtering",this._useMipmap==!0&&this._sourceImageData){this._useMipmap=!1,this.updateTextureDescription(),this.updateGPUTexture();let t=E.device;this.gpuTexture instanceof GPUTexture&&t.queue.copyExternalImageToTexture({source:this._sourceImageData},{texture:this.gpuTexture},[this.width,this.height])}this._textureChange=!0,this._useMipmap=e,this.noticeChange()}get sourceImageData(){return this._sourceImageData}getMipmapCount(){let e=this.width,t=this.height,a=Math.max(e,t);return 1+Math.log2(a)|0}updateTextureDescription(){this.mipmapCount=Math.floor(this.useMipmap?this.getMipmapCount():1),this.createTextureDescriptor(this.width,this.height,this.mipmapCount,this.format)}updateGPUTexture(){this.gpuTexture&&this.gpuTexture instanceof GPUTexture&&this.gpuTexture.destroy(),this.gpuTexture=null,this.view=null,this.gpuTexture=this.getGPUTexture()}getGPUTexture(){return this.gpuTexture||(this.gpuTexture=E.device.createTexture(this.textureDescriptor)),this.gpuTexture}getGPUView(e=0){return this.view||(this.gpuTexture=this.getGPUTexture(),this.gpuTexture instanceof GPUTexture&&(this.view=this.gpuTexture.createView(this.viewDescriptor),this.view.label=this.name)),this.view}_stateChangeRef=new Map;bindStateChange(e,t){this._stateChangeRef.set(t,e)}unBindStateChange(e){this._stateChangeRef.delete(e)}noticeChange(){this.gpuSampler=E.device.createSampler(this),this._stateChangeRef.forEach((e,t)=>{e()})}destroy(e){if(e&&this.gpuTexture instanceof GPUTexture&&(this.gpuSampler=null,this.gpuSampler_comparison=null,this.textureBindingLayout=null,this.textureDescriptor=null,this.gpuTexture.destroy(),this.gpuTexture=null,this._isDestroyed=!0),this._sourceImageData&&this._sourceImageData instanceof ImageBitmap){try{this._sourceImageData.close()}catch{}this._sourceImageData=null}this._stateChangeRef.clear()}get addressModeU(){return this._addressModeU}set addressModeU(e){this._addressModeU!=e&&(this._addressModeU=e,this.noticeChange())}get addressModeV(){return this._addressModeV}set addressModeV(e){this._addressModeV!=e&&(this._addressModeV=e,this.noticeChange())}get addressModeW(){return this._addressModeW}set addressModeW(e){this._addressModeW!=e&&(this._addressModeW=e,this.noticeChange())}get magFilter(){return this._magFilter}set magFilter(e){this._magFilter!=e&&(this._magFilter=e,this.noticeChange())}get minFilter(){return this._minFilter}set minFilter(e){this._minFilter!=e&&(this._minFilter=e,this.noticeChange())}get mipmapFilter(){return this._mipmapFilter}set mipmapFilter(e){this._mipmapFilter!=e&&(this._mipmapFilter=e,this.noticeChange())}get lodMinClamp(){return this._lodMinClamp}set lodMinClamp(e){this._lodMinClamp!=e&&(this._lodMinClamp=e,this.noticeChange())}get lodMaxClamp(){return this._lodMaxClamp}set lodMaxClamp(e){this._lodMaxClamp!=e&&(this._lodMaxClamp=e,this.noticeChange())}get compare(){return this._compare}set compare(e){this._compare!=e&&(this._compare=e,this.noticeChange())}get maxAnisotropy(){return this._maxAnisotropy}set maxAnisotropy(e){this._maxAnisotropy!=e&&(this._maxAnisotropy=e,this.noticeChange())}static _texs=[];static delayDestroyTexture(e){this._texs.includes(e)||this._texs.push(e)}static destroyTexture(){if(this._texs.length>0)for(;this._texs.length>0;)this._texs.shift().destroy()}}class sc extends Xe{_bitmapTextures;constructor(e,t,a){super(e,t,a),this.format=Y.rgba8unorm,this.mipmapCount=1,this._bitmapTextures=[],this.init()}setTextures(e){this._bitmapTextures.length=0;for(let t=0;t<e.length;t++){const a=e[t];this.addTexture(a)}}addTexture(e){(e.width!=this.width||e.height!=this.height)&&console.error("bitmap texture must match bitmapTextureArray size!"),e.pid=this._bitmapTextures.length,this._bitmapTextures.push(e),this.updateTexture()}removeTexture(e){let t=this._bitmapTextures.indexOf(e);if(t!=-1){this._bitmapTextures.splice(t,1);for(let a=0;a<this._bitmapTextures.length;a++){const r=this._bitmapTextures[a];r.pid=a}}}updateTexture(){let e=S.beginCommandEncoder();for(let t=0;t<this._bitmapTextures.length;t++){let a=this._bitmapTextures[t];e.copyTextureToTexture({texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:this.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:t}},{width:this.width,height:this.height,depthOrArrayLayers:1})}S.endCommandEncoder(e)}internalCreateBindingLayoutDesc(){this.textureBindingLayout.viewDimension="2d-array",this.samplerBindingLayout.type="filtering",this.minFilter=qa.linear,this.magFilter=qa.linear}internalCreateTexture(){this.textureDescriptor={format:this.format,size:{width:this.width,height:this.height,depthOrArrayLayers:this.numberLayer},dimension:"2d",usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.TEXTURE_BINDING},this.gpuTexture=this.getGPUTexture()}internalCreateView(){this.viewDescriptor={dimension:"2d-array"},this.view=this.getGPUView()}internalCreateSampler(){this.gpuSampler=E.device.createSampler(this)}}class ra{static use=!1;static iesTexture;static ies_list=[];_iesTexture;index=0;constructor(){}generateIES(e){}set IESTexture(e){this._iesTexture=e,e.addressModeU=Pt.repeat,e.addressModeV=Pt.repeat,e.addressModeW=Pt.repeat,ra.ies_list.indexOf(this)==-1&&(this.index=ra.ies_list.length,ra.ies_list.push(this),ra.iesTexture||ra.create(e.width,e.height),ra.iesTexture.addTexture(e))}get IESTexture(){return this._iesTexture}static create(e,t){let a=48;this.iesTexture=new sc(e,t,a)}}class is{static _globalDataBindGroupLayout;static getGlobalDataBindGroupLayout(){if(this._globalDataBindGroupLayout)return this._globalDataBindGroupLayout;let e=[];return e.push({binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,buffer:{type:"uniform"}}),e.push({binding:1,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,buffer:{type:"read-only-storage"}}),this._globalDataBindGroupLayout=E.device.createBindGroupLayout({entries:e}),this._globalDataBindGroupLayout}}class bi{Type=0;Line=0;Colume=0;Literal="";constructor(e=0,t="\0"){this.Type=e,this.Literal=t}isTypeEqual(e){return this.Type==e}isLiteralEqual(e){return this.Literal==e}isBuiltinType(){return this.Type>33&&this.Type<101}isDataType(){return this.Type==1||this.isBuiltinType()}isOperation(){return this.Type>102&&this.Type<127}isAssignOperation(){return this.Type>128&&this.Type<133}get nOperationPriorityLevel(){switch(this.Type){case 26:return 1;case 27:return 1;case 125:return 2;case 110:return 3;case 114:return 3;case 105:return 4;case 106:return 4;case 103:return 5;case 104:return 5;case 115:return 6;case 116:return 6;case 119:return 7;case 120:return 7;case 122:return 7;case 123:return 7;case 121:return 8;case 124:return 8;case 111:return 9;case 113:return 10;case 112:return 11;case 107:return 12;case 109:return 13;case 108:return 14;case 24:return 15;case 126:return 16;case 129:return 16;case 130:return 16;case 131:return 16;case 132:return 16}return 99}}var U=(s=>(s[s.EOF=0]="EOF",s[s.IDENT=1]="IDENT",s[s.VOID=2]="VOID",s[s.CONST=3]="CONST",s[s.LAYOUT=4]="LAYOUT",s[s.PRECISION=5]="PRECISION",s[s.ATTRIBUTE=6]="ATTRIBUTE",s[s.UNIFORM=7]="UNIFORM",s[s.VARYING=8]="VARYING",s[s.INVARIANT=9]="INVARIANT",s[s.IN=10]="IN",s[s.OUT=11]="OUT",s[s.INOUT=12]="INOUT",s[s.IF=13]="IF",s[s.ELSE=14]="ELSE",s[s.FOR=15]="FOR",s[s.WHILE=16]="WHILE",s[s.DO=17]="DO",s[s.BREAK=18]="BREAK",s[s.RETURN=19]="RETURN",s[s.CONTINUE=20]="CONTINUE",s[s.STRUCT=21]="STRUCT",s[s.COMMA=22]="COMMA",s[s.COLON=23]="COLON",s[s.QUEMARK=24]="QUEMARK",s[s.SEMICOLON=25]="SEMICOLON",s[s.LEFTSAMLL=26]="LEFTSAMLL",s[s.RIGHTSAMLL=27]="RIGHTSAMLL",s[s.LEFTMEDI=28]="LEFTMEDI",s[s.RIGHTMEDI=29]="RIGHTMEDI",s[s.LEFTBIG=30]="LEFTBIG",s[s.RIGHTBIG=31]="RIGHTBIG",s[s.LITERAL=32]="LITERAL",s[s.BeginBuiltinType=33]="BeginBuiltinType",s[s.INT=34]="INT",s[s.INT_ARRAY=35]="INT_ARRAY",s[s.UINT=36]="UINT",s[s.UINT_ARRAY=37]="UINT_ARRAY",s[s.BOOL=38]="BOOL",s[s.BOOL_ARRAY=39]="BOOL_ARRAY",s[s.FLOAT=40]="FLOAT",s[s.FLOAT_ARRAY=41]="FLOAT_ARRAY",s[s.DOUBLE=42]="DOUBLE",s[s.DOUBLE_ARRAY=43]="DOUBLE_ARRAY",s[s.VEC2=44]="VEC2",s[s.VEC2_ARRAY=45]="VEC2_ARRAY",s[s.VEC3=46]="VEC3",s[s.VEC3_ARRAY=47]="VEC3_ARRAY",s[s.VEC4=48]="VEC4",s[s.VEC4_ARRAY=49]="VEC4_ARRAY",s[s.BVEC2=50]="BVEC2",s[s.BVEC2_ARRAY=51]="BVEC2_ARRAY",s[s.BVEC3=52]="BVEC3",s[s.BVEC3_ARRAY=53]="BVEC3_ARRAY",s[s.BVEC4=54]="BVEC4",s[s.BVEC4_ARRAY=55]="BVEC4_ARRAY",s[s.IVEC2=56]="IVEC2",s[s.IVEC2_ARRAY=57]="IVEC2_ARRAY",s[s.IVEC3=58]="IVEC3",s[s.IVEC3_ARRAY=59]="IVEC3_ARRAY",s[s.IVEC4=60]="IVEC4",s[s.IVEC4_ARRAY=61]="IVEC4_ARRAY",s[s.UVEC2=62]="UVEC2",s[s.UVEC2_ARRAY=63]="UVEC2_ARRAY",s[s.UVEC3=64]="UVEC3",s[s.UVEC3_ARRAY=65]="UVEC3_ARRAY",s[s.UVEC4=66]="UVEC4",s[s.UVEC4_ARRAY=67]="UVEC4_ARRAY",s[s.MAT2x2=68]="MAT2x2",s[s.MAT2x2_ARRAY=69]="MAT2x2_ARRAY",s[s.MAT2x3=70]="MAT2x3",s[s.MAT2x3_ARRAY=71]="MAT2x3_ARRAY",s[s.MAT2x4=72]="MAT2x4",s[s.MAT2x4_ARRAY=73]="MAT2x4_ARRAY",s[s.MAT3x2=74]="MAT3x2",s[s.MAT3x2_ARRAY=75]="MAT3x2_ARRAY",s[s.MAT3x3=76]="MAT3x3",s[s.MAT3x3_ARRAY=77]="MAT3x3_ARRAY",s[s.MAT3x4=78]="MAT3x4",s[s.MAT3x4_ARRAY=79]="MAT3x4_ARRAY",s[s.MAT4x2=80]="MAT4x2",s[s.MAT4x2_ARRAY=81]="MAT4x2_ARRAY",s[s.MAT4x3=82]="MAT4x3",s[s.MAT4x3_ARRAY=83]="MAT4x3_ARRAY",s[s.MAT4x4=84]="MAT4x4",s[s.MAT4x4_ARRAY=85]="MAT4x4_ARRAY",s[s.SAMPLER=86]="SAMPLER",s[s.SAMPLER_1D=87]="SAMPLER_1D",s[s.SAMPLER_2D=88]="SAMPLER_2D",s[s.SAMPLER_3D=89]="SAMPLER_3D",s[s.SAMPLER_CUBE=90]="SAMPLER_CUBE",s[s.SAMPLER_SHADOW=91]="SAMPLER_SHADOW",s[s.SAMPLER_1D_SHADOW=92]="SAMPLER_1D_SHADOW",s[s.SAMPLER_2D_SHADOW=93]="SAMPLER_2D_SHADOW",s[s.TEXTURE_1D=94]="TEXTURE_1D",s[s.TEXTURE_1D_ARRAY=95]="TEXTURE_1D_ARRAY",s[s.TEXTURE_2D=96]="TEXTURE_2D",s[s.TEXTURE_2D_ARRAY=97]="TEXTURE_2D_ARRAY",s[s.TEXTURE_3D=98]="TEXTURE_3D",s[s.TEXTURE_CUBE=99]="TEXTURE_CUBE",s[s.TEXTURE_CUBE_ARRAY=100]="TEXTURE_CUBE_ARRAY",s[s.EndBuiltinType=101]="EndBuiltinType",s[s.BeginOperation=102]="BeginOperation",s[s.ADD=103]="ADD",s[s.SUB=104]="SUB",s[s.MUL=105]="MUL",s[s.DIV=106]="DIV",s[s.AND=107]="AND",s[s.OR=108]="OR",s[s.XOR=109]="XOR",s[s.NOT=110]="NOT",s[s.BITAND=111]="BITAND",s[s.BITOR=112]="BITOR",s[s.BITXOR=113]="BITXOR",s[s.BITNOT=114]="BITNOT",s[s.BITSHIFT_L=115]="BITSHIFT_L",s[s.BITSHIFT_R=116]="BITSHIFT_R",s[s.INC=117]="INC",s[s.DEC=118]="DEC",s[s.GREATER=119]="GREATER",s[s.GREATEREQUAL=120]="GREATEREQUAL",s[s.EQUAL=121]="EQUAL",s[s.LESS=122]="LESS",s[s.LESSEQUAL=123]="LESSEQUAL",s[s.NOTEQUAL=124]="NOTEQUAL",s[s.DOT=125]="DOT",s[s.ASSIGN=126]="ASSIGN",s[s.EndOperation=127]="EndOperation",s[s.BeginAssignOperation=128]="BeginAssignOperation",s[s.ADDASSIGN=129]="ADDASSIGN",s[s.SUBASSIGN=130]="SUBASSIGN",s[s.MULASSIGN=131]="MULASSIGN",s[s.DIVASSIGN=132]="DIVASSIGN",s[s.EndAssignOperation=133]="EndAssignOperation",s))(U||{});class Yr{_char;_line;_column;_source;_currPosition;_nextPosition;constructor(e){this.reset(e)}reset(e){this._char="",this._line=0,this._column=0,this._source=e,this._currPosition=0,this._nextPosition=0}get source(){return this._source}getChar(){return this._char}get currPosition(){return this._currPosition}peekChar(){return this._nextPosition>=this._source.length?"\0":this._source[this._nextPosition]}readChar(){this._char=this._nextPosition>=this._source.length?"\0":this._source[this._nextPosition],this._char!==`
5696
5696
  `?this._column++:(this._line++,this._column=0),this._currPosition=this._nextPosition,this._nextPosition++}readCharAndSkipWhitespace(){this.readChar(),this.skipWhitespace()}readIdentifier(){for(var e=this._currPosition;this.isIdentifier(this._char);)this.readChar();return this._source.substring(e,this._currPosition)}isIdentifier(e){var t=e.charCodeAt(0);return 97<=t&&t<=122||65<=t&&t<=90||48<=t&&t<=57||t==95}skipWhitespace(){for(;this.IsWhitespace(this._char);)this.readChar()}IsWhitespace(e){return e===" "||e===" "||e==="\r"||e===`
5697
5697
  `}skipComment(){for(;this._char!==`
5698
5698
  `&&this._char!=="\0";)this.readChar();this.skipWhitespace()}skipMultilineComment(){if(!(this._char!=="/"&&this.peekChar()!=="*")){this.readChar(),this.readChar();for(let e=1;e>0&&this._char!=="\0";)if(this.readChar(),this._char==="/"&&this.peekChar()==="*"){e++,this.readChar();continue}else if(this._char==="*"&&this.peekChar()==="/"){e--,this.readChar();continue}this.readChar(),this.readChar(),this.skipWhitespace()}}isDigit(e){var t=e.charCodeAt(0);return 48<=t&&t<=57}readNumber(){for(var e=this._currPosition;this.isDigit(this._char);)this.readChar();if(this._char===".")for(this.readChar();this.isDigit(this._char);)this.readChar();return this._source.substring(e,this._currPosition)}readValue(){return this.isDigit(this._char)?this.readNumber():this.readIdentifier()}readLine(){var e=this._currPosition,t=this._source.indexOf(`
@@ -5742,7 +5742,7 @@ struct InstanceData {
5742
5742
  `,a}}class de extends Ce{constructor(){super()}static parse(e){let t=new Array,a=new Array,r=0;for(;e.peekToken(0).Type!=U.EOF;){let i=e.peekToken(0);if(i.Type==U.SEMICOLON||i.Type==U.RIGHTMEDI||i.Type==U.COMMA||i.Type==U.COLON||i.Type==U.RIGHTBIG)break;if(i.isOperation()){if(i.isOperation()){if(i.Type==U.INC||i.Type==U.DEC){let n=i;e.skipToken(1);let o=de.parse(e);a.push(new Xr(n,void 0,o));continue}else if(t.length>0){if(t[t.length-1].nOperationPriorityLevel<=i.nOperationPriorityLevel)de.unionOperation(t,a);else if(t.length>0&&t[t.length-1].Literal=="-"){let o=t.pop(),l=a.pop();a.push(new Xr(o,void 0,l))}}t.push(i),e.skipToken(1)}}else if(i.Type==U.LITERAL){a.push(new Pa(i.Literal)),e.skipToken(1);continue}else if(i.Type==U.LEFTSAMLL){r++,t.push(i),e.skipToken(1);continue}else if(i.Type==U.RIGHTSAMLL){if(r<=0)break;for(r--;de.unionOperation(t,a););if(t[t.length-1].Type==U.LEFTSAMLL){t.pop();let n=new fc;n.addNode(a.pop()),a.push(n)}e.skipToken(1);continue}else if(i.Type==U.IDENT){if(e.peekToken(1).Type==U.INC||e.peekToken(1).Type==U.DEC){let n=e.peekToken(1),o=new Na(i.Literal);a.push(new Xr(n,o,void 0)),e.skipToken(2);continue}else if(e.peekToken(1).Type==U.LEFTSAMLL){a.push(Dr.parse(e));continue}else if(e.peekToken(1).Type==U.DOT){a.push(pi.parse(e));continue}else if(e.peekToken(1).Type==U.LEFTMEDI){a.push(vr.parse(e));continue}a.push(new Na(i.Literal)),e.skipToken(1);continue}else{if(i.isBuiltinType()&&e.peekToken(1).Type==U.LEFTSAMLL){a.push(Dr.parse(e));continue}if(i.isAssignOperation()){let n=i;e.skipToken(1);let o=a.pop(),l=de.parse(e);a.push(new er(n,o,l));continue}if(i.Type==U.LEFTBIG&&(e.peekToken(1).Type==U.LITERAL||e.peekToken(1).Type==U.SUB&&e.peekToken(2).Type==U.LITERAL)){a.push(gi.parse(e));continue}if(i.Type==U.QUEMARK){t.length>0&&t[t.length-1].nOperationPriorityLevel<=i.nOperationPriorityLevel&&de.unionOperation(t,a),e.skipToken(1);let n=a.pop(),o=de.parse(e);e.peekToken(0).Type==U.COLON&&e.skipToken(1);let l=de.parse(e);if(a.push(new dc(n,o,l)),e.peekToken(-1).Type==U.SEMICOLON)break;continue}if(i.Type==U.LEFTMEDI){e.skipToken(1);let n=de.parse(e);e.peekToken(0).Type==U.RIGHTMEDI&&e.skipToken(1);let o=a.pop();a.push(new vr(o,n));continue}throw"An unexpected character"}}for(;t.length>0&&de.unionOperation(t,a););if(t.length<=0&&a.length==1){let i=new de;return i.addNode(a.pop()),i}throw"Error parsing expression: Unexpected character("+e.peekToken(0).Literal+")"}formatToWGSL(e,t){return this.nodes[0].formatToWGSL(e,t)}static unionOperation(e,t){if(e.length<0||t.length<2){if(e.length>0&&e[e.length-1].Literal=="-"){let a=e.pop(),r=t.pop();return t.push(new Xr(a,void 0,r)),!0}return!1}if(e[e.length-1].isOperation()){let a=t.pop(),r=e.pop(),i=t.pop();return r.Type==U.DOT?t.push(new pi(i,a)):t.push(new er(r,i,a)),!0}return!1}}class fc extends Ce{constructor(){super()}formatToWGSL(e,t){return(t<=0?"":" ".repeat(t))+"("+this.nodes[0].formatToWGSL(e,0)+")"}}class Na extends Ce{name;constructor(e){super(),this.name=e}formatToWGSL(e,t){return(t<=0?"":" ".repeat(t))+e.findIdentifier(this.name)}}class Pa extends Ce{value;constructor(e){super(),this.value=e}static parse(e){let t=e.peekToken(0);if(t.Type==U.SUB&&e.peekToken(1).Type==U.LITERAL){let a=new Pa("-"+e.peekToken(1).Literal);return e.skipToken(2),a}else if(t.Type==U.LITERAL){let a=new Pa(t.Literal);return e.skipToken(1),a}throw"Error parsing literal constants: Unexpected characters("+t.Literal+")"}formatToWGSL(e,t){return(t<=0?"":" ".repeat(t))+this.value}}class gi extends Pa{arrayValue;constructor(e){super(""),this.arrayValue=e}static parse(e){if(e.peekToken(0).Type==U.LEFTBIG&&e.peekToken(1).Type==U.LITERAL||e.peekToken(0).Type==U.LEFTBIG&&e.peekToken(1).Type==U.SUB&&e.peekToken(2).Type==U.LITERAL){e.skipToken(1);let t=[];for(;e.peekToken(0).Type!=U.RIGHTBIG;){if(e.peekToken(0).Type==U.LEFTSAMLL){t.push(gi.parse(e));continue}if(t.push(Pa.parse(e)),e.peekToken(0).Type==U.COMMA){e.skipToken(1);continue}else if(e.peekToken(0).Type==U.RIGHTBIG){e.skipToken(1);break}else throw"Error parsing array constants: Unexpected characters"}return new gi(t)}throw"Error parsing array constants: Unexpected characters"}formatToWGSL(e,t){let a="",r=t<=0?"":" ".repeat(t);this.arrayValue[0].value.includes(".")?a+=r+"array<f32, "+this.arrayValue.length.toString()+">(":a+=r+"array<i32, "+this.arrayValue.length.toString()+">(";for(let i=0;i<this.arrayValue.length;i++)i>0&&(a+=", "),a+=this.arrayValue[i].formatToWGSL(e,0);return a+=")",a}}class Vu extends Ce{constructor(){super()}}class Ou extends Ce{constructor(){super()}}class sn extends Ce{constructor(){super()}static parse(e){if(e.peekToken(0).Type==U.CONTINUE&&e.peekToken(1).Type==U.SEMICOLON)return e.skipToken(2),new sn;throw"Error parsing continue: Unexpected character"}formatToWGSL(e,t){let a="",r=t<=0?"":" ".repeat(t);return a+=r+"continue",a}}class mi extends Ce{value;constructor(e){super(),this.value=e}static parse(e){if(e.peekToken(0).Type==U.RETURN){e.skipToken(1);let t=de.parse(e);return e.peekToken(0).Type==U.SEMICOLON&&e.skipToken(1),new mi(t)}throw"Error parsing return expression: Unexpected character"}formatToWGSL(e,t){let a="",r=t<=0?"":" ".repeat(t);return a+=r+"return "+this.value.formatToWGSL(e,0),a}}class Xr extends Ce{op;leftValue;rightValue;constructor(e,t,a){super(),this.op=e,this.leftValue=t,this.rightValue=a}formatToWGSL(e,t){let a="",r=t<=0?"":" ".repeat(t);if(this.op.Literal=="++"||this.op.Literal=="--")if(this.leftValue!=null){let i=this.leftValue.formatToWGSL(e,0);a+=r+i+" = "+i+" "+this.op.Literal[0]+" 1"}else{let i=this.rightValue.formatToWGSL(e,0);a+=r+i+" = "+i+" "+this.op.Literal[0]+" 1"}else this.leftValue!=null?a+=r+this.leftValue.formatToWGSL(e,0)+this.op.Literal:a+=r+this.op.Literal+this.rightValue.formatToWGSL(e,0);return a}}class er extends Ce{op;leftValue;rightValue;constructor(e,t,a){super(),this.op=e,this.leftValue=t,this.rightValue=a}formatToWGSL(e,t){let a="",r=t<=0?"":" ".repeat(t);return a+=r+this.leftValue.formatToWGSL(e,0)+" "+this.op.Literal+" "+this.rightValue.formatToWGSL(e,0),a}}class dc extends Ce{condition;expression1;expression2;constructor(e,t,a){super(),this.condition=e,this.expression1=t,this.expression2=a}static parse(e){throw"Error parsing ternary operation expression: Unexpected character"}formatToWGSL(e,t){return""}}class pi extends Ce{leftValue;rightValue;constructor(e,t){super(),this.leftValue=e,this.rightValue=t}static parse(e){if(e.peekToken(0).Type==U.IDENT&&e.peekToken(1).Type==U.DOT&&e.peekToken(2).Type==U.IDENT){let t=new Na(e.peekToken(0).Literal),a=new Na(e.peekToken(2).Literal);return e.skipToken(3),new pi(t,a)}throw"Error parsing selection expression: Unexpected character"}formatToWGSL(e,t){return(t<=0?"":" ".repeat(t))+this.leftValue.formatToWGSL(e,0)+"."+this.rightValue.formatToWGSL(e,0)}}class vr extends Ce{leftValue;indexValue;constructor(e,t){super(),this.leftValue=e,this.indexValue=t}static parse(e){if(e.peekToken(0).Type==U.IDENT&&e.peekToken(1).Type==U.LEFTMEDI){let t=new Na(e.peekToken(0).Literal);e.skipToken(2);let a=de.parse(e);e.peekToken(0).Type==U.RIGHTMEDI&&e.skipToken(1);let r=new vr(t,a);for(;e.peekToken(0).Type==U.LEFTMEDI;)e.skipToken(1),a=de.parse(e),e.peekToken(0).Type==U.RIGHTMEDI&&e.skipToken(1),r=new vr(r,a);return r}throw"Error parsing index expression: Unexpected character"}formatToWGSL(e,t){return(t<=0?"":" ".repeat(t))+this.leftValue.formatToWGSL(e,0)+"["+this.indexValue.formatToWGSL(e,0)+"]"}}class ia extends Ce{constructor(){super()}static parse(e){if(e.peekToken(0).Type==U.LEFTBIG){e.skipToken(1);let t=new ia;for(let a=1;a>0&&e.peekToken(0).Type!=U.EOF;){let r=e.peekToken(0);if(r.Type==U.LEFTBIG){a++,e.skipToken(1);continue}if(r.Type==U.RIGHTBIG){a--,e.skipToken(1);continue}if(r.Type==U.SEMICOLON){e.skipToken(1);continue}if(r.isDataType()&&e.peekToken(1).Type==U.IDENT){t.addNode(Ve.parse(e));continue}if(r.Type==U.CONST&&e.peekToken(1).isDataType()&&e.peekToken(2).Type==U.IDENT){t.addNode(Ve.parse(e));continue}else if(r.Type==U.IDENT&&e.peekToken(1).Type==U.ASSIGN){t.addNode(de.parse(e)),e.peekToken(0).Type==U.SEMICOLON&&e.skipToken(1);continue}else if(r.Type==U.IDENT&&e.peekToken(1).Type==U.LEFTMEDI){let i=vr.parse(e);if(e.peekToken(0).Type==U.ASSIGN){let n=e.peekToken(0);e.skipToken(1);let o=de.parse(e);e.peekToken(0).Type==U.RIGHTMEDI&&e.skipToken(1),t.addNode(new er(n,i,o));continue}t.addNode(i);continue}else if(r.Type==U.IDENT&&e.peekToken(1).Type==U.DOT){let i=de.parse(e);t.addNode(i);continue}else if(r.Type==U.IDENT&&e.peekToken(1).isAssignOperation()){let i=e.peekToken(1),n=new Na(r.Literal);e.skipToken(2);let o=de.parse(e);e.peekToken(0).Type==U.SEMICOLON&&e.skipToken(1),t.addNode(new er(i,n,o));continue}else if(r.Type==U.IDENT&&(e.peekToken(1).Type==U.INC||e.peekToken(1).Type==U.DEC)&&e.peekToken(2).Type==U.SEMICOLON){let i=e.peekToken(1);t.addNode(new Xr(i,new Na(r.Literal),void 0)),e.skipToken(3);continue}else if(r.Type==U.RETURN){t.addNode(mi.parse(e));continue}else if(r.Type==U.CONTINUE){t.addNode(sn.parse(e));continue}else if(r.Type==U.WHILE){t.addNode(Br.parse(e));continue}else if(r.Type==U.FOR){t.addNode(_r.parse(e));continue}else if(r.Type==U.IF){t.addNode(Ur.parse(e));continue}else if(r.Type==U.IDENT&&e.peekToken(1).Type==U.LEFTSAMLL){t.addNode(Dr.parse(e)),e.peekToken(0).Type==U.SEMICOLON&&e.skipToken(0);continue}throw"Error parsing block: Unexpected symbol("+r.Literal+")"}return t}throw"Error parsing block: Unexpected symbol"}}class on extends Ce{type;qualifier;constructor(e,t){super(),this.type=t,this.qualifier=e}static parse(e){if(e.peekToken(0).Type==U.PRECISION&&e.peekToken(1).Type==U.IDENT&&e.peekToken(2).isBuiltinType()){let t=new on(e.peekToken(1).Literal,e.peekToken(2).Literal);return e.skipToken(3),e.peekToken(0).Type==U.SEMICOLON&&e.skipToken(1),t}throw"Error parsing precision qualifier: Unexpected character"}formatToWGSL(e,t){return""}}class Ai extends Ce{scope="";qualifier=new Map;constructor(){super()}addQualifier(e,t=""){this.qualifier.set(e,t)}static parse(e){if(e.peekToken(0).Type==U.LAYOUT&&e.peekToken(1).Type==U.LEFTSAMLL){let t=new Ai;e.skipToken(2);do if(e.peekToken(0).Type==U.IDENT){if(e.peekToken(1).Type==U.ASSIGN&&e.peekToken(2).Type==U.LITERAL){let r=e.peekToken(0).Literal,i=e.peekToken(2).Literal;if(t.addQualifier(r,i),e.skipToken(3),e.peekToken(0).Type==U.COMMA){e.skipToken(1);continue}let n=e.peekToken(0);n.Line=0}else if(e.peekToken(1).Type==U.RIGHTSAMLL){let r=e.peekToken(0).Literal;t.addQualifier(r,""),e.skipToken(1);break}else if(e.peekToken(1).Type==U.COMMA){let r=e.peekToken(0).Literal;t.addQualifier(r,""),e.skipToken(2);continue}}while(e.peekToken(0).Type!=U.RIGHTSAMLL);if(e.peekToken(0).Type==U.RIGHTSAMLL&&e.skipToken(1),t.scope=e.peekToken(0).Literal,e.skipToken(1),e.peekToken(0).Type==U.SEMICOLON)return e.skipToken(1),t;if(e.peekToken(0).isBuiltinType()&&e.peekToken(1).Type==U.IDENT&&e.peekToken(2).Type==U.SEMICOLON){let a=new Ve(e.peekToken(0).Literal,e.peekToken(1).Literal);return t.addNode(a),e.skipToken(3),t}else if(e.peekToken(0).Type==U.IDENT&&e.peekToken(1).Type==U.LEFTBIG){let a=Ma.parse(e);return t.addNode(a),e.peekToken(0).Type==U.IDENT&&e.peekToken(1).Type==U.SEMICOLON&&(a.addNode(new Ve(a.name,e.peekToken(0).Literal)),e.skipToken(2)),t}else throw"Error parsing layout qualifier type: Unexpected symbol("+e.peekToken(0).Literal+")"}throw"Error parsing layout qualifier: Unexpected symbol"}formatToWGSL(e,t){let a="";if(this.qualifier.size==1&&this.qualifier.has("location"))a+="@location("+this.qualifier.get("location")+") ";else if(this.qualifier.size==2&&this.qualifier.has("set")&&this.qualifier.has("binding"))a+="@group("+this.qualifier.get("set")+") @binding("+this.qualifier.get("binding")+") ";else if(this.qualifier.size>=1&&this.qualifier.has("binding"))a+="@group(0) @binding("+this.qualifier.get("binding")+") ";else if(this.qualifier.size==1&&this.qualifier.has("push_constant"))a+="@push_constant ";else if(this.qualifier.size>=1&&this.qualifier.has("local_size_x"))a+="@workgroup_size(",a+=this.qualifier.get("local_size_x")+", ",a+=this.qualifier.has("local_size_y")?this.qualifier.get("local_size_y")+", ":"1, ",a+=this.qualifier.has("local_size_z")?this.qualifier.get("local_size_z")+"":"1",a+=")";else if(this.nodes.length<=0)return"";let r=this.nodes[0];if(r instanceof Ve){switch(r.type){case"sampler":case"texture2D":a+="var ";break;default:this.scope=="buffer"?e.stage=="compute"?a+="var<storage, read_write> ":a+="var<storage, read> ":a+="var<"+this.scope+"> ";break}e.addIdentifier(r.name,r.name),a+=r.name+": "+Yt(r.type)+`;\r
5743
5743
  `}else if(r instanceof Ma){if(this.scope=="buffer"?e.stage=="compute"?a+="var<storage, read_write> ":a+="var<storage, read> ":a+="var<"+this.scope+"> ",r.nodes.length<=0){let i="unif"+e.layoutUniformCount.toString();for(;e.hasIdentifier(i);)e.layoutUniformCount++,i="unif"+e.layoutUniformCount.toString();for(let n of r.fields)e.addIdentifier(n.name,i+"."+n.name);a+=i+": "+r.name+`;\r
5744
5744
  `,e.layoutUniformCount++}else{let i=r.nodes[0];a+=i.name+": "+i.type+`;\r
5745
- `}return a}return a}}function Yt(s){switch(s){case"int":return"i32";case"int[]":return"array<i32>";case"uint":return"u32";case"uint[]":return"array<u32>";case"float":return"f32";case"float[]":return"array<f32>";case"vec2":return"vec2<f32>";case"vec3":return"vec3<f32>";case"vec4":return"vec4<f32>";case"vec2[]":return"array<vec2<f32>>";case"vec3[]":return"array<vec3<f32>>";case"vec4[]":return"array<vec4<f32>>";case"ivec2":return"vec2<i32>";case"ivec3":return"vec3<i32>";case"ivec4":return"vec4<i32>";case"ivec2[]":return"array<vec2<i32>>";case"ivec3[]":return"array<vec3<i32>>";case"ivec4[]":return"array<vec4<i32>>";case"mat2":return"mat2x2<f32>";case"mat2x2":return"mat2x2<f32>";case"mat2x3":return"mat2x3<f32>";case"mat2x4":return"mat2x4<f32>";case"mat2[]":return"array<mat2x2<f32>>";case"mat2x2[]":return"array<mat2x2<f32>>";case"mat2x3[]":return"array<mat2x3<f32>>";case"mat2x4[]":return"array<mat2x4<f32>>";case"mat3":return"mat3x3<f32>";case"mat3x2":return"mat3x2<f32>";case"mat3x3":return"mat3x3<f32>";case"mat3x4":return"mat3x4<f32>";case"mat3[]":return"array<mat3x3<f32>>";case"mat3x2[]":return"array<mat3x2<f32>>";case"mat3x3[]":return"array<mat3x3<f32>>";case"mat3x4[]":return"array<mat3x4<f32>>";case"mat4":return"mat4x4<f32>";case"mat4x2":return"mat4x2<f32>";case"mat4x3":return"mat4x3<f32>";case"mat4x4":return"mat4x4<f32>";case"mat4[]":return"array<mat4x4<f32>>";case"mat4x2[]":return"array<mat4x2<f32>>";case"mat4x3[]":return"array<mat4x3<f32>>";case"mat4x4[]":return"array<mat4x4<f32>>";case"texture2D":return"texture_2d<f32>"}return s}class hc{_lexer;_rootNode;constructor(e){this._lexer=e,this._rootNode=new Ce,this.parse()}get lexer(){return this._lexer}parse(){for(;this.peekToken(0).Type!==U.EOF;){if(this.peekToken(0).Type==U.SEMICOLON){this.skipToken(1);continue}let e=this.parseStatement();e!==null&&this._rootNode.addNode(e)}}parseStatement(){let e=this.peekToken();if(e.Type==U.LAYOUT&&this.peekToken(1).Type==U.LEFTSAMLL)return Ai.parse(this._lexer);if(e.Type==U.STRUCT)return this.skipToken(1),Ma.parse(this._lexer);if((e.isBuiltinType()||e.Type==U.VOID)&&this.peekToken(1).Type==U.IDENT&&this.peekToken(2).Type==U.LEFTSAMLL)return rn.parse(this._lexer);if(e.Type==U.CONST&&this.peekToken(1).isDataType())return Ve.parse(this._lexer);if(e.isDataType()&&this.peekToken(1).Type==U.IDENT)return Ve.parse(this._lexer);if(e.Type==U.OUT&&this.peekToken(1).isDataType()&&this.peekToken(2).Type==U.IDENT)return Ve.parse(this._lexer);if(e.Type==U.PRECISION)return on.parse(this._lexer);throw"Error parsing statement: Unexpected character"}skipToken(e){this._lexer.skipToken(e)}peekToken(e=0){return this._lexer.peekToken(e)}getNextToken(){return this._lexer.GetNextToken()}get ASTRoot(){return this._rootNode}}class uc{static VertexShader="VertexShader";static FragmentShader="FragmentShader";static convertGLSL(e){var t=new lc(e),a=new oc(t),r=new hc(a),i=new cc(r);return i.generateWGSL()}}class ss{setID=0;bindingID=0;name="";type=""}class os{name="";type="";locationID=0;builtinName="";isBuiltinAttribute(){return this.builtinName!=""}}class bc{uniformInfo=[];inputAttribute=[];outputAttribute=[];sourceCode=""}var na=(s=>(s[s.vertex=0]="vertex",s[s.fragment=1]="fragment",s[s.computer=2]="computer",s))(na||{});class gc{blendMode=te.NONE;depthCompare=$e.less_equal;depthWriteEnabled=!0;frontFace="ccw";cullMode=Ft.back;topology=zn.triangle_list;depthBias=10;useLight=!1;useProbe=!1;acceptGI=!1;acceptShadow=!1;castShadow=!1;castReflection=!0;receiveEnv=!1;renderLayer=1e3;renderOrder=2e3;unclippedDepth=!1;transparent=!1;multisample=0;label;useZ=!0;splitTexture=!1;alphaCutoff;useFragDepth=!1;writeMasks=[];setFromMapValues(e){e.has("blendMode")&&(this.blendMode=this.convertBlendMode(e.get("blendMode"))),e.has("depthCompare")&&(this.depthCompare=e.get("depthCompare")),e.has("depthWriteEnabled")&&(this.depthWriteEnabled=e.get("depthWriteEnabled")),e.has("frontFace")&&(this.frontFace=e.get("frontFace")),e.has("cullMode")&&(this.cullMode=e.get("cullMode")),e.has("topology")&&(this.topology=e.get("topology")),e.has("depthBias")&&(this.depthBias=e.get("depthBias")),e.has("useLight")&&(this.useLight=e.get("useLight")),e.has("useProbe")&&(this.useProbe=e.get("useProbe")),e.has("acceptGI")&&(this.acceptGI=e.get("acceptGI")),e.has("acceptShadow")&&(this.acceptShadow=e.get("acceptShadow")),e.has("castShadow")&&(this.castShadow=e.get("castShadow")),e.has("receiveEnv")&&(this.receiveEnv=e.get("receiveEnv")),e.has("renderLayer")&&(this.renderLayer=e.get("renderLayer")),e.has("renderOrder")&&(this.renderOrder=e.get("renderOrder")),e.has("unclippedDepth")&&(this.unclippedDepth=e.get("unclippedDepth")),e.has("multisample")&&(this.multisample=e.get("multisample")),e.has("label")&&(this.label=e.get("label")),e.has("useZ")&&(this.useZ=e.get("useZ"))}convertBlendMode(e){switch(e){case"ABOVE":return te.ABOVE;case"ALPHA":return te.ALPHA;case"NORMAL":return te.NORMAL;case"ADD":return te.ADD;case"BELOW":return te.BELOW;case"ERASE":return te.ERASE;case"MUL":return te.MUL;case"SCREEN":return te.SCREEN;case"DIVD":return te.DIVD;case"SOFT_ADD":return te.SOFT_ADD}return te.NONE}}class mc extends Ta{uniformNodes=[];_onChange=!0;constructor(){super(),this.bufferType=ea.MaterialDataUniformGPUBuffer}initDataUniform(e){this.uniformNodes=e;let t=0;for(const a in e){const r=e[a];r||console.error(a,"is empty"),t+=r.size*4}t=Math.floor(t/256+1)*256,this.createBuffer(GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,t/4,null,"MaterialDataUniformGPUBuffer");for(const a in e){const r=e[a];r||console.error(a,"is empty");let i=this.memory.allocation_node(r.size*4);r.memoryInfo=i,r.bindOnChange=()=>this.onChange()}}onChange(){this._onChange=!0}apply(){if(this.uniformNodes.length!=0&&this._onChange){for(const e in this.uniformNodes)this.uniformNodes[e].update();super.apply(),this._onChange=!1}}}class Va{static renderShaderModulePool;static renderShader;static init(){this.renderShaderModulePool=new Map,this.renderShader=new Map}}class me{reference;static _ins;static getInstance(){return this._ins||=new me,this._ins}attached(e,t){this.reference||=new Map;let a=this.reference.get(e);a||=new Map,a.set(t,e),this.reference.set(e,a)}detached(e,t){let a=this.reference.get(e);a&&a.delete(t)}hasReference(e){let t=this.reference.get(e);return t?t.size>0:!1}getReferenceCount(e){let t=this.reference.get(e);return t?t.size:0}getReference(e){let t=this.reference.get(e);return t||null}}class ls{static pipelineMap=new Map;static getSharePipeline(e){let t=this.pipelineMap.get(e);return t||null}static setSharePipeline(e,t){this.pipelineMap.set(e,t)}}class Ne extends Gn{passType=H.COLOR;useRz=!1;vsName;fsName;shaderState;textures;pipeline;bindGroupLayouts;envMap;prefilterMap;reflectionMap;_sourceVS;_sourceFS;_destVS;_destFS;_vsShaderModule;_fsShaderModule;_textureGroup=-1;_textureChange=!1;_groupsShaderReflectionVarInfos;outBufferMask;constructor(e,t){super(),this.vsName=e.toLowerCase(),this.fsName=t.toLowerCase(),this.vsName in J||console.error("Shader Not Register, Please Register Shader!",this.vsName),this.fsName in J||console.error("Shader Not Register, Please Register Shader!",this.fsName),J[this.vsName]&&(this._sourceVS=J[this.vsName]),J[this.fsName]&&(this._sourceFS=J[this.fsName]),this.textures={},this.bindGroups=[],this.shaderState=new gc,this.materialDataUniformBuffer=new mc,this.materialDataUniformBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,this._bufferDic.set("global",this.materialDataUniformBuffer),this._bufferDic.set("materialUniform",this.materialDataUniformBuffer)}get renderOrder(){return this.shaderState.renderOrder}set renderOrder(e){this.shaderState.renderOrder!=e&&(this._valueChange=!0),this.shaderState.renderOrder=e}get doubleSide(){return this.shaderState.cullMode==Ft.none}set doubleSide(e){let t=e?Ft.none:this.cullMode;this.shaderState.cullMode!=t&&(this._valueChange=!0),this.shaderState.cullMode=t}get depthWriteEnabled(){return this.shaderState.depthWriteEnabled}set depthWriteEnabled(e){this.shaderState.depthWriteEnabled!=e&&(this._valueChange=!0),this.shaderState.depthWriteEnabled=e}get cullMode(){return this.shaderState.cullMode}set cullMode(e){this.shaderState.cullMode!=e&&(this._valueChange=!0),this.shaderState.cullMode=e}get frontFace(){return this.shaderState.frontFace}set frontFace(e){this.shaderState.frontFace!=e&&(this._valueChange=!0),this.shaderState.frontFace=e}get depthBias(){return this.shaderState.depthBias}set depthBias(e){this.shaderState.depthBias!=e&&(this._valueChange=!0),this.shaderState.depthBias=e}get topology(){return this.shaderState.topology}set topology(e){this.shaderState.topology!=e&&(this._valueChange=!0),this.shaderState.topology=e}get blendMode(){return this.shaderState.blendMode}set blendMode(e){this.shaderState.blendMode!=e&&(this._valueChange=!0,e!=te.NORMAL&&e!=te.NONE&&(this.renderOrder=3e3)),this.shaderState.blendMode=e}get depthCompare(){return this.shaderState.depthCompare}set depthCompare(e){this.shaderState.depthCompare!=e&&(this._valueChange=!0),this.shaderState.depthCompare=e}setShaderEntry(e="",t=""){this.vsEntryPoint=e,this.fsEntryPoint=t}setUniform(e,t){super.setUniform(e,t),this.materialDataUniformBuffer.onChange()}setTexture(e,t){t&&this.textures[e]!=t&&(this.textures[e]&&this.textures[e].unBindStateChange(this),this._textureChange=!0,this.textures[e]=t,e=="envMap"?this.envMap=t:e=="prefilterMap"?this.prefilterMap=t:e=="reflectionMap"&&(this.reflectionMap=t),t.bindStateChange(()=>{this._textureChange=!0},this))}get baseColor(){return this.getUniform("baseColor")}set baseColor(e){this.setUniform("baseColor",e)}getTexture(e){return this.textures[e]}genRenderPipeline(e,t){let a=this.createGroupLayouts();this.createPipeline(e,t,a)}reBuild(e,t){this.compileShader(na.vertex,this._destVS,t),this.compileShader(na.fragment,this._destFS,t),this.genRenderPipeline(e,t)}apply(e,t,a){this.materialDataUniformBuffer.apply(),this._textureChange&&this._textureGroup!=-1&&(this._textureChange=!1,this.genGroups(this._textureGroup,this.shaderReflection.groups,!0)),this._valueChange&&(this._shaderChange&&(this.preCompile(e),this._shaderChange=!1),this.shaderVariant=dt.genRenderShaderVariant(this),this.reBuild(e,t),this._valueChange=!1,a&&a())}preCompile(e){this.preDefine(e),this.preCompileShader(na.vertex,this._sourceVS.concat()),this.preCompileShader(na.fragment,this._sourceFS.concat()),this.genReflection()}applyPostDefine(e,t){return t.renderTargetTextures.length>1?(this.defineValue.USE_WORLDPOS=!0,this.defineValue.USEGBUFFER=!0):(this.defineValue.USE_WORLDPOS=!1,this.defineValue.USEGBUFFER=!1),A.setting.render.useCompressGBuffer?this.defineValue.USE_COMPRESSGBUFFER=!0:this.defineValue.USE_COMPRESSGBUFFER=!1,ta.parse(e,this.defineValue)}setBindGroup(e,t){this.bindGroups[e]=t}checkBuffer(e,t){}preCompileShader(e,t,a){let r=t;if(r.indexOf("version ")!=-1){var i=uc.convertGLSL(r);r=i.sourceCode}for(const n in this.constValues)if(Object.prototype.hasOwnProperty.call(this.constValues,n)){const o=this.constValues[n];r=r.replaceAll(`&${n}`,o.toString())}switch(e){case na.vertex:this._destVS=r;break;case na.fragment:this._destFS=r;break}}compileShader(e,t,a){let r=t;r=this.applyPostDefine(r,a);let i=t;for(let o in this.defineValue)i+=`${o}=${this.defineValue[o]},`;let n=Va.renderShaderModulePool.get(i);switch(n||(r=this.applyPostDefine(r,a),n=E.device.createShaderModule({label:e==na.vertex?this.vsName:this.fsName,code:r}),n.getCompilationInfo().then(o=>{o.messages.length>0&&(console.log(r),console.log(o))}),Va.renderShaderModulePool.set(i,n)),e){case na.vertex:this._vsShaderModule=n,this._destVS=r;break;case na.fragment:this._fsShaderModule=n,this._destFS=r;break}}getGroupLayout(e,t){let a=[];for(let r=0;r<t.length;r++){const i=t[r];if(i)if(i.varType=="uniform"){this._bufferDic.has(i.varName)||console.error(`not set ${i.varName} buffer`);let n=this._bufferDic.get(i.varName).visibility,o={binding:i.binding,visibility:n,buffer:{type:"uniform"}};a.push(o)}else if(i.varType=="storage-read"){this._bufferDic.has(i.varName)||console.error(`not set ${i.varName} buffer`);let n=this._bufferDic.get(i.varName).visibility,o={binding:i.binding,visibility:n,buffer:{type:"read-only-storage"}};a.push(o)}else if(i.varType=="var")switch(i.dataType){case"sampler":{let n=i.varName.replace("Sampler",""),o=this.textures[n]?this.textures[n]:A.res.redTexture,l={binding:i.binding,visibility:o.visibility,sampler:o.samplerBindingLayout};a.push(l),this._textureGroup=e}break;case"sampler_comparison":{let n=i.varName.replace("Sampler",""),o=this.textures[n]?this.textures[n]:A.res.redTexture,l={binding:i.binding,visibility:o.visibility,sampler:o.sampler_comparisonBindingLayout};a.push(l),this._textureGroup=e}break;case"texture_2d<f32>":case"texture_2d_array<f32>":case"texture_cube<f32>":case"texture_depth_2d":case"texture_depth_2d_array":case"texture_depth_cube":case"texture_depth_cube_array":{let n=this.textures[i.varName]?this.textures[i.varName]:A.res.redTexture,o={binding:i.binding,visibility:n.visibility,texture:n.textureBindingLayout};a.push(o),this._textureGroup=e,me.getInstance().attached(n,this)}break;case"texture_external":{let n=this.textures[i.varName]?this.textures[i.varName]:A.res.redTexture,o={binding:i.binding,visibility:n.visibility,externalTexture:{}};a.push(o),this._textureGroup=e,me.getInstance().attached(n,this)}break;default:{let n=this.textures[i.varName]?this.textures[i.varName]:A.res.redTexture,o={binding:i.binding,visibility:n.visibility,texture:n.textureBindingLayout};a.push(o),this._textureGroup=e,me.getInstance().attached(n,this)}break}else{debugger;console.error("bind group can't empty")}}return a}_cacheEntries;genGroups(e,t,a=!1){if(!this.bindGroups[e]||a){const r=t[e];let i=[];for(let o=0;o<r.length;o++){const l=r[o];if(l){if(l.varType=="uniform"){let c=this._bufferDic.get(l.varName);if(c){if(c.bufferType==ea.MaterialDataUniformGPUBuffer){let h=[];for(let u=0;u<l.dataFields.length;u++){const g=l.dataFields[u];this.uniforms[g.name]||console.error(`shader-${this.vsName}:${this.fsName} ${g.name}is empty`),h.push(this.uniforms[g.name])}this.materialDataUniformBuffer.initDataUniform(h)}let f={binding:l.binding,resource:{buffer:c.buffer,offset:0,size:c.memory.shareDataBuffer.byteLength}};i.push(f),this.checkBuffer(l.varName,c)}else console.error(`shader${this.vsName}-${this.fsName}`,`buffer ${l.varName} is missing!`)}else if(l.varType=="storage-read"){let c=this._bufferDic.get(l.varName);if(c){let f={binding:l.binding,resource:{buffer:c.buffer,offset:0,size:c.memory.shareDataBuffer.byteLength}};i.push(f),this.checkBuffer(l.varName,c)}else console.error(`buffer ${l.varName} is missing!`)}else if(l.varType=="var")if(l.dataType=="sampler"){let c=l.varName.replace("Sampler",""),f=this.textures[c];if(f||(f=A.res.blackTexture,this.setTexture(c,f)),f){let h={binding:l.binding,resource:f.gpuSampler};i.push(h)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}else if(l.dataType=="sampler_comparison"){let c=l.varName.replace("Sampler",""),f=this.textures[c];if(f){let h={binding:l.binding,resource:f.gpuSampler_comparison};i.push(h)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}else{let c=this.textures[l.varName];if(c||(c=A.res.whiteTexture,this.setTexture(l.varName,c)),c){let f={binding:l.binding,resource:c.getGPUView()};i.push(f)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}}}let n=E.device.createBindGroup({layout:this.bindGroupLayouts[e],entries:i});this.bindGroups[e]=n}}createPipeline(e,t,a){let r=e,i=this.shaderState,n=[];for(const c of t.renderTargetTextures)n.push({format:c.format});for(let c=0;c<n.length;c++){const f=n[c];i.writeMasks&&i.writeMasks.length>0&&(f.writeMask=i.writeMasks[c])}if(t.outColor!=-1){let c=n[t.outColor];i.blendMode!=te.NONE?c.blend=nc.getBlend(i.blendMode):delete c.blend}let o={label:this.vsName+"|"+this.fsName,layout:a,primitive:{topology:i.topology,cullMode:i.cullMode,frontFace:i.frontFace},vertex:void 0};this.vsEntryPoint!=""&&(o.vertex={module:this._vsShaderModule,entryPoint:this.vsEntryPoint,buffers:r.vertexBuffer.vertexBufferLayouts}),this.fsEntryPoint!=""&&(o.fragment={module:this._fsShaderModule,entryPoint:this.fsEntryPoint,targets:n}),i.multisample>0&&(o.multisample={count:i.multisample}),(t.zPreTexture||t.depthTexture)&&(i.blendMode!=te.NONE,A.setting.render.zPrePass&&t.zPreTexture&&i.useZ?o.depthStencil={depthWriteEnabled:!1,depthCompare:$e.less,format:t.zPreTexture.format}:o.depthStencil={depthWriteEnabled:i.depthWriteEnabled,depthCompare:i.depthCompare,format:t.depthTexture.format});let l=ls.getSharePipeline(this.shaderVariant);l?this.pipeline=l:(this.pipeline=S.createPipeline(o),ls.setSharePipeline(this.shaderVariant,this.pipeline))}createGroupLayouts(){this._groupsShaderReflectionVarInfos=[];let e=this.shaderReflection;this.bindGroupLayouts=[is.getGlobalDataBindGroupLayout()];for(let a=1;a<e.groups.length;a++){let r=e.groups[a];if(r){let i=this.getGroupLayout(a,r);this._groupsShaderReflectionVarInfos[a]=r;let n=E.device.createBindGroupLayout({entries:i,label:`vs${this.vsName} fs${this.fsName} ${r.length}`});this.bindGroupLayouts[a]=n}else console.error("can't set empty group!",a)}let t=E.device.createPipelineLayout({bindGroupLayouts:this.bindGroupLayouts});return this._groupsShaderReflectionVarInfos[1]&&this.genGroups(1,this._groupsShaderReflectionVarInfos),this._groupsShaderReflectionVarInfos[2]&&this.genGroups(2,this._groupsShaderReflectionVarInfos),this._groupsShaderReflectionVarInfos[3]&&this.genGroups(3,this._groupsShaderReflectionVarInfos),t}preDefine(e){let t=e.hasAttribute(V.TEXCOORD_1),a=e.hasAttribute(V.joints0),r=e.hasAttribute(V.a_morphPositions_0),i=e.hasAttribute(V.TANGENT),n=e.hasAttribute(V.color),o=this.shaderState.acceptGI,l=this.shaderState.useLight;t&&(this.defineValue.USE_SECONDUV=!0),a&&r?this.defineValue.USE_METAHUMAN=!0:(this.defineValue.USE_SKELETON=a,this.defineValue.USE_MORPHTARGETS=r),"USE_TANGENT"in this.defineValue||(this.defineValue.USE_TANGENT=i),this.defineValue.USE_GI=o,this.defineValue.USE_SHADOWMAPING=this.shaderState.acceptShadow,this.defineValue.USE_LIGHT=l,this.defineValue.USE_VERTXCOLOR=n,A.setting.pick.mode=="pixel"&&(this.defineValue.USE_WORLDPOS=!0),A.setting.gi.enable?this.defineValue.USEGI=!0:this.defineValue.USEGI=!1,A.setting.render.debug&&(this.defineValue.USE_DEBUG=!0,this.defineValue.DEBUG_CLUSTER=!0),this.shaderState.useLight?this.defineValue.USE_LIGHT=!0:this.defineValue.USE_LIGHT=!1,A.setting.render.useLogDepth?(this.defineValue.USE_LOGDEPTH=!0,this.shaderState.useFragDepth=!0):this.defineValue.USE_LOGDEPTH=!1,this.shaderState.useFragDepth?this.defineValue.USE_OUTDEPTH=!0:this.defineValue.USE_OUTDEPTH=!1,this.defineValue.USE_PCF_SHADOW=A.setting.shadow.type=="PCF",this.defineValue.USE_HARD_SHADOW=A.setting.shadow.type=="HARD",this.defineValue.USE_SOFT_SHADOW=A.setting.shadow.type=="SOFT",this.defineValue.USE_CSM=Jt.Cascades>1,this.defineValue.USE_IES_PROFILE=ra.use}genReflection(){this.shaderVariant=dt.genRenderShaderVariant(this);let e=dt.poolGetReflection(this.shaderVariant);if(e)this.shaderReflection=e;else{let t=ta.parse(this._destVS,this.defineValue);t=ta.parse(t,this.defineValue),dt.getShaderReflection2(t,this);let a=ta.parse(this._destFS,this.defineValue);a=ta.parse(a,this.defineValue),dt.getShaderReflection2(a,this),dt.final(this)}this.shaderState.splitTexture=this.shaderReflection.useSplit}destroy(e){for(const t in this.textures)if(Object.prototype.hasOwnProperty.call(this.textures,t)){const a=this.textures[t];if(me.getInstance().detached(a,this),e&&!me.getInstance().hasReference(a))a.destroy(e);else{a.destroy(!1);let r=me.getInstance().getReference(a);if(r){let i=[];r.forEach((n,o)=>{"name"in n?i.push(n.name):i.push("NaN")})}}}this.bindGroups.length=0,this.shaderState=null,this.textures=null,this.pipeline=null,this.bindGroupLayouts=null,this._sourceVS=null,this._sourceFS=null,this._destVS=null,this._destFS=null,this._vsShaderModule=null,this._fsShaderModule=null,this.materialDataUniformBuffer.destroy(e),this.materialDataUniformBuffer=null}static destroyShader(e){Va.renderShader.has(e)&&(Va.renderShader.get(e).destroy(),Va.renderShader.delete(e))}static getShader(e){return Va.renderShader.get(e)}static createShader(e,t){let a=new Ne(e,t);return Va.renderShader.set(a.instanceID,a),a.instanceID}}class pc extends Ne{constructor(){super("sky_vs_frag_wgsl","SkyGBuffer_fs"),this.passType=H.GI,this.setUniformVector3("eyesPos",new b),this.setUniformFloat("exposure",1),this.setUniformFloat("roughness",0);let e=this.shaderState;e.frontFace="ccw",e.cullMode=Ft.front,e.depthWriteEnabled=!1,e.depthCompare=$e.less}}class Ac extends Ne{transparency;constructor(){super("gbuffer_vs","gbuffer_fs"),this.setShaderEntry("VertMain","FragMain"),this.passType=H.GI,this.setUniformColor("baseColor",new O),this.setUniformColor("emissiveColor",new O),this.setUniformFloat("emissiveIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("alphaCutoff",1),this.blendMode=te.NONE,this.setTexture("normalMap",A.res.normalTexture)}}class Dc extends Ne{constructor(){super("shadowCastMap_vert","directionShadowCastMap_frag"),this.passType=H.SHADOW,this.setShaderEntry("main"),this.setUniformFloat("cameraFar",5e3),this.setUniformVector3("lightWorldPos",b.ZERO),this.shaderState.receiveEnv=!1,this.shaderState.castShadow=!1,this.shaderState.acceptShadow=!1,this.setDefine("USE_ALPHACUT",!0)}}class _c extends Ne{constructor(){super("castPointShadowMap_vert","shadowCastMap_frag"),this.passType=H.POINT_SHADOW,this.setShaderEntry("main","main"),this.setUniformFloat("cameraFar",5e3),this.setUniformVector3("lightWorldPos",b.ZERO),this.shaderState.receiveEnv=!1,this.shaderState.castShadow=!1,this.shaderState.acceptShadow=!1,this.setDefine("USE_ALPHACUT",!0)}}class Bc extends Ne{constructor(){super("ZPass_shader_vs","ZPass_shader_vs"),this.passType=H.DEPTH,this.setShaderEntry("main"),this.useRz=!1;let e=this.shaderState;e.receiveEnv=!1}}class Di{static createGIPass(e,t){if(zt.hasMask(e.rendererMask,De.Sky)){if(!t.passShader.get(H.GI)){let r=t.getSubShaders(H.COLOR)[0],i=new pc;i.setTexture("baseMap",r.getTexture("baseMap")),i.cullMode=r.cullMode,i.frontFace=r.frontFace,t.addRenderPass(i,0),i.preCompile(e.geometry)}}else this.castGBufferPass(e,t)}static castGBufferPass(e,t){let a=t.getDefaultShaders();for(let r=0;r<a.length;r++){const i=a[r];let n=t.getSubShaders(H.GI);if(!n||n.length==0||n.length<r){let o=new Ac;o.setTexture("baseMap",i.getTexture("baseMap")),o.setTexture("normalMap",i.getTexture("normalMap")),o.setTexture("emissiveMap",i.getTexture("emissiveMap")),i.uniforms.baseColor&&o.setUniform("baseColor",i.getUniform("baseColor")),i.uniforms.envIntensity&&o.setUniform("envIntensity",i.getUniform("envIntensity")),i.uniforms.emissiveColor&&o.setUniform("emissiveColor",i.getUniform("emissiveColor")),i.uniforms.emissiveIntensity&&o.setUniform("emissiveIntensity",i.getUniform("emissiveIntensity")),i.uniforms.alphaCutoff&&o.setUniform("alphaCutoff",i.getUniform("alphaCutoff")),o.cullMode=i.cullMode,o.frontFace=i.frontFace,o.preCompile(e.geometry),t.addRenderPass(o)}}}static createShadowPass(e,t){let a=zt.hasMask(e.rendererMask,De.SkinnedMesh),r=e.geometry.hasAttribute(V.TANGENT),i=e.geometry.hasAttribute(Zt.MORPH_POSITION_PREFIX+"0"),n=e.geometry.hasAttribute(Zt.MORPH_NORMAL_PREFIX+"0"),o=t.getSubShaders(H.COLOR);for(let l=0;l<o.length;l++){const c=o[l];let f=t.getSubShaders(H.SHADOW);if(!f||f.length<l+1){let u=new Dc;u.setTexture("baseMap",c.getTexture("baseMap")),u.setUniform("alphaCutoff",c.getUniform("alphaCutoff")),r&&u.setDefine("USE_TANGENT",r),a&&u.setDefine("USE_SKELETON",a),i&&u.setDefine("USE_MORPHTARGETS",i),n&&u.setDefine("USE_MORPHNORMALS",n),c.cullMode=="none"?u.shaderState.cullMode="none":c.cullMode=="back"?u.shaderState.cullMode="front":c.cullMode=="front"&&(u.shaderState.cullMode="back"),u.preCompile(e.geometry),t.addRenderPass(u)}let h=t.getSubShaders(H.POINT_SHADOW);if(!h||h.length<l+1){let u=new _c;u.setTexture("baseMap",c.getTexture("baseMap")),u.setUniform("alphaCutoff",c.getUniform("alphaCutoff")),u.setDefine("USE_ALPHACUT",1);for(let g=0;g<1;g++)r&&u.setDefine("USE_TANGENT",r),a&&u.setDefine("USE_SKELETON",a),i&&u.setDefine("USE_MORPHTARGETS",i),n&&u.setDefine("USE_MORPHNORMALS",n),u.shaderState.cullMode="front",u.preCompile(e.geometry);t.addRenderPass(u)}}}static createDepthPass(e,t){let a=t.getSubShaders(H.COLOR),r=e.geometry.hasAttribute("TANGENT"),i=e.geometry.hasAttribute(Zt.MORPH_POSITION_PREFIX+"0"),n=e.geometry.hasAttribute(Zt.MORPH_NORMAL_PREFIX+"0"),o=zt.hasMask(e.rendererMask,De.SkinnedMesh);for(let l=0;l<a.length;l++){const c=a[l];let f=t.getSubShaders(H.DEPTH);if(!f&&c.shaderState.useZ&&(!f||f.length<l)){let h=new Bc;h.setTexture("baseMap",c.getTexture("baseMap")),r||h.setDefine("USE_TANGENT",r),o&&h.setDefine("USE_SKELETON",o),i&&h.setDefine("USE_MORPHTARGETS",i),n&&h.setDefine("USE_MORPHNORMALS",n),h.cullMode=c.cullMode,h.frontFace=c.frontFace,h.preCompile(e.geometry),t.addRenderPass(h)}}}static createReflectionPass(e,t){let a=t.getDefaultShaders();for(let o=0;o<a.length;o++){const l=a[o];let c=t.getSubShaders(H.REFLECTION);if(!c||c.length==0||c.length<o){let f=new Ne(l.vsName,l.fsName);f.vsEntryPoint=l.vsEntryPoint,f.fsEntryPoint=l.fsEntryPoint,f.passType=H.REFLECTION;for(const h in l.shaderState){var r=l.shaderState[h];f.shaderState[h]=r}for(const h in l.textures){var i=l.getTexture(h);f.setTexture(h,i)}for(const h in l.uniforms){var n=l.getUniform(h);f.setUniform(h,n)}for(const h in l.defineValue){var n=l.defineValue[h];f.setDefine(h,n)}f.setDefine("USE_CASTREFLECTION",!0),f.preCompile(e.geometry),t.addRenderPass(f)}}}}class tr{static _v1=new b;static _v2=new b;entities;box;subTrees=[];parent;level;static maxSplitLevel=6;static autoSplitLevel=3;index;uuid;constructor(e,t=0,a=null,r=0){this.parent=a,this.box=e.clone(),this.level=r,this.index=t,this.uuid=r+"_"+t,this.entities=new Map}tryInsertEntity(e){let t=e.renderer.object3D.bound;if(this.level==0||this.box.containsBox(t)){this.subTrees.length==0&&this.level<tr.maxSplitLevel&&this.splitTree();let a;if(this.subTrees.length>0){for(let r of this.subTrees)if(r.tryInsertEntity(e)){a=!0;break}}return a||e.enterNode(this),!0}return!1}splitTree(){if(this.subTrees.length==0){const e=tr._v1,t=this.box.extents.clone();let a=this.level+1,r=0;for(let i=0;i<2;i++)for(let n=0;n<2;n++)for(let o=0;o<2;o++){const l=new ge;this.box.min.add(e.set(i,n,o).multiply(t),l.min),l.min.add(t,l.max),l.setFromMinMax(l.min,l.max);let c=new tr(l,r++,this,a);this.subTrees.push(c)}}}__rayCastTempVector=new b;rayCasts(e,t){if(this.level==0||e.intersectBox(this.box,this.__rayCastTempVector)){this.entities.size>0&&t.push(...this.entities.values());for(let a of this.subTrees)a.rayCasts(e,t);return!0}return!1}frustumCasts(e,t){if(this.level==0||e.containsBox2(this.box)>0){if(this.entities.size>0)for(const a of this.entities.values())(this.level>tr.autoSplitLevel||e.containsBox2(a.renderer.object3D.bound)>0)&&t.push(a);for(let a of this.subTrees)a.frustumCasts(e,t);return!0}return!1}getRenderNode(e,t){if(this.level==0||e.containsBox2(this.box)>0){if(this.entities.size>0)for(const a of this.entities.values())(this.level>tr.autoSplitLevel||e.containsBox2(a.renderer.object3D.bound)>0)&&(a.renderer.renderOrder<3e3?t.opaqueList.push(a.renderer):a.renderer.renderOrder>=3e3&&t.transparentList.push(a.renderer));for(let a of this.subTrees)a.getRenderNode(e,t);return!0}return!1}boxCasts(e,t){if(e.intersectsBox(this.box)){this.entities.size>0&&t.push(...this.entities.values());for(let a of this.subTrees)a.boxCasts(e,t);return!0}return!1}clean(){for(let e of this.entities.values())e.leaveNode();return this.entities.clear(),this}}class Uc{_pool=[];_worldPosition=new b;_viewPosition=new b;_zSortList=[];pop(){return this._pool.pop()||{}}recycle(){for(let e of this._zSortList)e.z=0,e.userData=null,e.obj3d=null,this._pool.push(e);this._zSortList.length=0}sort(e,t,a,r){this._zSortList=[];for(let i of t){let n=this.pop();n.userData=i,n.obj3d=a(i),n.z=this.worldToCameraDepth(n.obj3d,e),this._zSortList.push(n)}this._zSortList.sort((i,n)=>i.z-n.z>0?1:-1),r||=[];for(let i of this._zSortList)r.push(i.userData);return this.recycle(),r}worldToCameraDepth(e,t){t||=e.transform.view3D.camera;let a=0;return t&&(this._worldPosition.copyFrom(e.transform.worldPosition),t.worldToScreenPoint(this._worldPosition,this._viewPosition),a=this._viewPosition.z),a}}let vc=new Uc;var _i=(s=>(s[s.None=2]="None",s[s.StaticBatch=4]="StaticBatch",s[s.DynamicBatch=8]="DynamicBatch",s[s.Hiden=16]="Hiden",s))(_i||{});class cs{static addMask(e,t){return e|t}static removeMask(e,t){return e&~t}static hasMask(e,t){return(e&t)!=0}}class yc{opaqueList=[];transparentList=[];sky;clean(){this.opaqueList.length=0,this.transparentList.length=0}}class Cc{renderGroup;constructor(){this.renderGroup=new Map}collect_add(e){let t="",a="";t+=e.geometry.instanceID;for(let i=0;i<e.materials.length;i++){const n=e.materials[i];a+=n.shader.getDefaultColorShader().shaderVariant}let r=t+a;this.renderGroup.has(r)||this.renderGroup.set(r,{bundleMap:new Map,key:r,renderNodes:[]}),this.renderGroup.get(r).renderNodes.indexOf(e)==-1&&this.renderGroup.get(r).renderNodes.push(e)}}class Sc{renderShaderUpdateList=new Map;renderNodeList=new Map;collect_add(e){let t=e.transform.view3D;t&&e.materials&&e.materials.forEach(a=>{let r=this.renderShaderUpdateList.get(t);r||(r=new Map,this.renderShaderUpdateList.set(t,r));let i=this.renderNodeList.get(t);i||(i=new Map,this.renderNodeList.set(t,i)),i.set(e.instanceID,e);let n=a.getAllPass();for(let o=0;o<n.length;o++){const l=n[o];let c=`${e.geometry.instanceID+l.instanceID}`,f=r.get(c);f||(f=new Map,r.set(c,f)),f.set(e.instanceID,e)}})}collect_remove(e){let t=e.transform.view3D;if(t&&e.materials){let a=this.renderShaderUpdateList.get(t);a&&e.materials.forEach(r=>{let i=r.getAllPass();for(let n=0;n<i.length;n++){const o=i[n];let l=`${e.geometry.instanceID+o.instanceID}`;a.delete(l)}})}}}class W{static _instance;_sceneLights;_sceneGIProbes;_op_RenderNodes;_tr_RenderNodes;_octreeRenderNodes;_reflections;_graphics;_op_renderGroup;_tr_renderGroup;_renderShaderCollect;state={giLightingChange:!0};sky;_collectInfo;rendererOctree;static get instance(){return this._instance||(this._instance=new W),this._instance}constructor(){this._sceneLights=new Map,this._sceneGIProbes=new Map,this._op_RenderNodes=new Map,this._tr_RenderNodes=new Map,this._reflections=new Map,this._graphics=[],this._op_renderGroup=new Map,this._tr_renderGroup=new Map,this._collectInfo=new yc,this._renderShaderCollect=new Sc,this._octreeRenderNodes=new Map}getPashList(e,t){if(t.renderOrder<3e3)return this._op_RenderNodes.get(e);if(t.renderOrder>=3e3)return this._tr_RenderNodes.get(e)}sortRenderNode(e,t){for(let a=e.length-1;a>0;a--)if(e[a].renderOrder<t.renderOrder){e.push(t);return}e.push(t)}addRenderNode(e,t){if(!e)return;let a=t.renderOrder>=3e3;if(t.hasMask(De.Sky))this.sky=t;else if(t.hasMask(De.Reflection)){this.removeRenderNode(e,t);let r=this._reflections.get(e);r||(r=[],this._reflections.set(e,r),r.push(t)),r.includes(t)||r.push(t)}else if(t.hasMask(De.Graphic3D))this._graphics.indexOf(t)==-1&&this._graphics.push(t);else if(cs.hasMask(t.renderLayer,_i.None)){this.removeRenderNode(e,t);let r=a?this._tr_RenderNodes:this._op_RenderNodes;r.has(e)||r.set(e,[]),r.get(e).push(t),A.setting.occlusionQuery.octree&&t.attachSceneOctree(this.getOctree(e));let i=this.getPashList(e,t);i.indexOf(t)==-1&&this.sortRenderNode(i,t)}else{this.removeRenderNode(e,t);let r=a?this._tr_renderGroup:this._op_renderGroup;r.has(e)||r.set(e,new Cc),r.get(e).collect_add(t)}t.object3D.renderNode=t,this._renderShaderCollect.collect_add(t)}getOctree(e){let t,a=A.setting.occlusionQuery.octree;if(a&&(t=this._octreeRenderNodes.get(e),!t)){let r=new b(a.x,a.y,a.z),i=new b(a.width,a.height,a.depth),n=new ge(r,i);t=new tr(n),this._octreeRenderNodes.set(e,t)}return t}removeRenderNode(e,t){if(t.detachSceneOctree(),t.hasMask(De.Sky))this.sky=null;else if(t.hasMask(De.Reflection)){let a=this._reflections.get(e);if(a){let r=a.indexOf(t);r!=-1&&a.splice(r,1)}}else if(cs.hasMask(t.renderLayer,_i.None)){let a=this.getPashList(e,t);if(a){let r=a.indexOf(t);r!=-1&&a.splice(r,1)}}this._renderShaderCollect.collect_remove(t)}addLight(e,t){if(!this._sceneLights.has(e))this._sceneLights.set(e,[t]);else{let a=this._sceneLights.get(e);if(a.length>=A.setting.light.maxLight){console.warn("Alreay meet maxmium light number:",A.setting.light.maxLight);return}a.indexOf(t)!=-1||a.push(t)}}removeLight(e,t){if(this._sceneLights.has(e)){let a=this._sceneLights.get(e),r=a.indexOf(t);r!=-1&&a.splice(r,1)}}getLights(e){let t=this._sceneLights.get(e);return t||[]}addGIProbe(e,t){this._sceneGIProbes.has(e)?this._sceneGIProbes.get(e).push(t):this._sceneGIProbes.set(e,[t])}removeGIProbe(e,t){if(this._sceneGIProbes.has(e)){let a=this._sceneGIProbes.get(e),r=a.indexOf(t);r!=-1&&a.splice(r,1)}}getProbes(e){let t=this._sceneGIProbes.get(e);return t||[]}getReflections(e){let t=this._reflections.get(e);return t||[]}autoSortRenderNodes(e){let t=this._tr_RenderNodes.get(e);if(!t)return;let a=!1;for(const r of t)if(r.isRenderOrderChange||r.needSortOnCameraZ){a=!0;break}if(a){for(const r of t){let i=r.renderOrder;if(r.needSortOnCameraZ){let n=vc.worldToCameraDepth(r.object3D);n=1-Math.max(0,Math.min(1,n)),i+=n}r.__renderOrder=i,r.isRenderOrderChange=!1}t.sort((r,i)=>r.__renderOrder>i.__renderOrder?1:-1)}return this}getRenderNodes(e,t){if(this.autoSortRenderNodes(e),this._collectInfo.clean(),this._collectInfo.sky=this.sky,A.setting.occlusionQuery.octree)this.rendererOctree=this.getOctree(e),this.rendererOctree.getRenderNode(t.frustum,this._collectInfo);else{let a=this._op_RenderNodes.get(e);a&&(this._collectInfo.opaqueList=a.concat());let r=this._tr_RenderNodes.get(e);r&&(this._collectInfo.transparentList=r.concat())}return this._collectInfo}getOpRenderGroup(e){return this._op_renderGroup.get(e)}getTrRenderGroup(e){return this._tr_renderGroup.get(e)}getGraphicList(){return this._graphics}getRenderShaderCollect(e){return this._renderShaderCollect.renderShaderUpdateList.get(e)}}class xc{renderer;owner;uuid;constructor(e){this.renderer=e,this.uuid=e.object3D.instanceID}leaveNode(){this.owner&&(this.owner.entities.delete(this.uuid),this.owner=null)}enterNode(e){this.owner&&this.leaveNode(),this.owner=e,e.entities.set(this.uuid,this)}update(e){return this.owner?.tryInsertEntity(this)||(this.leaveNode(),e.tryInsertEntity(this)),this.owner}}var Lu=Object.defineProperty,Gu=Object.getOwnPropertyDescriptor,fs=(s,e,t,a)=>{for(var r=Gu(e,t),i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(e,t,r)||r);return r&&Lu(e,t,r),r};class Oa extends Pe{instanceCount=0;lodLevel=0;alwaysRender=!1;instanceID;drawType=0;_geometry;_materials=[];_castShadow=!0;_castReflection=!0;_castGI=!1;_rendererMask=De.Default;_inRenderer=!1;_readyPipeline=!1;_combineShaderRefection;_ignoreEnvMap;_ignorePrefilterMap;__renderOrder=0;_renderOrder=0;_passInit=new Map;isRenderOrderChange;needSortOnCameraZ;isRecievePostEffectUI;_octreeBinder;_renderLayer=_i.None;_computes;init(e){this.renderOrder=0,this.rendererMask=De.Default,this.instanceID=Ln().toString(),this._computes=[]}attachSceneOctree(e){this._octreeBinder={octree:e,entity:new xc(this)},this.transform.eventDispatcher.addEventListener(kt.LOCAL_ONCHANGE,this.updateOctreeEntity,this)}detachSceneOctree(){this._octreeBinder&&(this._octreeBinder.entity?.leaveNode(),this.transform.eventDispatcher.removeEventListener(kt.LOCAL_ONCHANGE,this.updateOctreeEntity,this),this._octreeBinder=null)}updateOctreeEntity(e){this._octreeBinder?.entity?.update(this._octreeBinder.octree)}copyComponent(e){return super.copyComponent(e),this.geometry=e._geometry,this.materials=e._materials.slice(),this.drawType=e.drawType,this.alwaysRender=e.alwaysRender,this.needSortOnCameraZ=e.needSortOnCameraZ,this.isRenderOrderChange=e.isRenderOrderChange,this.castShadow=e.castShadow,this.castGI=e.castGI,this.rendererMask=e.rendererMask,this.isRecievePostEffectUI=e.isRecievePostEffectUI,this}get renderLayer(){return this._renderLayer}set renderLayer(e){this._renderLayer=e}get geometry(){return this._geometry}set geometry(e){this._geometry!=e&&(this._readyPipeline=!1,this._geometry&&me.getInstance().detached(this._geometry,this),e&&me.getInstance().attached(e,this)),this._geometry=e}addMask(e){this._rendererMask=zt.addMask(this.rendererMask,e)}removeMask(e){this._rendererMask=zt.removeMask(this.rendererMask,e)}hasMask(e){return zt.hasMask(this.rendererMask,e)}get rendererMask(){return this._rendererMask}set rendererMask(e){this._rendererMask=e}get renderOrder(){return this._renderOrder}set renderOrder(e){e!=this._renderOrder&&(this.isRenderOrderChange=!0,this.__renderOrder=e),this._renderOrder=e}get materials(){return this._materials}set materials(e){this._readyPipeline=!1;for(let a=0;a<this._materials.length;a++){let r=this._materials[a];me.getInstance().detached(r,this),r.shader&&r.shader.computes&&this.removeComputes(r.shader.computes)}for(let a=0;a<e.length;a++){let r=e[a];me.getInstance().attached(r,this),r.shader&&r.shader.computes&&this.addComputes(r.shader.computes)}this._materials=e;let t=0;for(let a=0;a<e.length;a++){const n=e[a].getPass(H.COLOR)[0];n.shaderState.transparent&&(t=t>n.renderOrder?t:n.renderOrder)}this.renderOrder=t,this._readyPipeline||this.initPipeline()}addComputes(e){this._computes.push(...e)}removeComputes(e){for(const t of e){let a=this._computes.indexOf(t);a!=-1&&this._computes.splice(a,1)}}addRendererMask(e){this._rendererMask=zt.addMask(this._rendererMask,e)}removeRendererMask(e){this._rendererMask=zt.removeMask(this._rendererMask,e)}onEnable(){this._readyPipeline||this.initPipeline(),W.instance.addRenderNode(this.transform.scene3D,this),this.updateOctreeEntity()}onDisable(){this._enable=!1,W.instance.removeRenderNode(this.transform.scene3D,this),super.onDisable?.()}selfCloneMaterials(e){let t=[];for(let a=0,r=this.materials.length;a<r;a++){const i=this.materials[a].clone();t.push(i)}return this.materials=t,this._readyPipeline=!1,this.initPipeline(),this}initPipeline(){if(this._geometry&&this._materials.length>0){for(let t=0;t<this._materials.length;t++){let r=this._materials[t].getPass(H.COLOR);for(let i=0;i<r.length;i++){const n=r[i];n.shaderReflection||n.preCompile(this._geometry),this._geometry.generate(n.shaderReflection)}this.object3D.bound=this._geometry.bounds.clone()}this._readyPipeline=!0;let e=0;for(let t=0;t<this.materials.length;t++){const i=this.materials[t].getPass(H.COLOR)[0];i.renderOrder>=3e3?e=e>i.renderOrder?e:i.renderOrder:e=Math.max(e-3e3,0),this.castNeedPass()}this.renderOrder=e,this.enable&&this.transform&&this.transform.scene3D&&W.instance.addRenderNode(this.transform.scene3D,this)}}castNeedPass(){if(this.castGI)for(let t=0;t<this.materials.length;t++){const a=this.materials[t];Di.createGIPass(this,a.shader)}for(let t=0;t<this.materials.length;t++){const a=this.materials[t];a.castShadow&&Di.createShadowPass(this,a.shader)}if(this.castReflection)for(let t=0;t<this.materials.length;t++){const a=this.materials[t];a.castReflection&&Di.createReflectionPass(this,a.shader)}if(!zt.hasMask(this.rendererMask,De.IgnoreDepthPass)&&A.setting.render.zPrePass)for(let t=0;t<this.materials.length;t++){const a=this.materials[t];Di.createDepthPass(this,a.shader)}else for(let t=0;t<this.materials.length;t++)this.materials[t].shader.removeShaderByIndex(H.DEPTH,0)}get castShadow(){return this._castShadow}set castShadow(e){this._castShadow=e}get castGI(){return this._castGI}set castGI(e){this._castGI=e}get castReflection(){return this._castReflection}set castReflection(e){this._castReflection=e}renderPass(e,t,a){if(!this._geometry)return;let r=this,i=r.transform._worldMatrix;const n=Math.max(r.materials.length,r._geometry.subGeometries.length);for(let o=0;o<n;o++){const l=o>=r.materials.length?r.materials[0]:r.materials[o];if(!l||!l.enable)continue;let c=l.getPass(t);if(!(!c||c.length==0)){S.bindGeometryBuffer(a.encoder,r._geometry),Ze.viewCount_vertex(e,H[t],r._geometry.vertexCount);for(let f=0;f<c.length;f++){if(!c||c.length==0)continue;const u=c[f];if(u.pipeline){u.shaderState.splitTexture&&(a.endRenderPass(),mt.WriteSplitColorTexture(r.instanceID),a.beginOpaqueRenderPass(),S.bindCamera(a.encoder,e.camera),S.bindGeometryBuffer(a.encoder,r._geometry)),S.bindPipeline(a.encoder,u)&&Ze.viewCount_pipeline(e,H[t]);let D=(o>=r._geometry.subGeometries.length?r._geometry.subGeometries[0]:r._geometry.subGeometries[o]).lodLevels[r.lodLevel];r.instanceCount>0?(Ze.viewCount_instance(e,H[t],r.instanceCount),Ze.viewCount_indices(e,H[t],D.indexCount),Ze.viewCount_tri(e,H[t],D.indexCount/3*r.instanceCount),S.drawIndexed(a.encoder,D.indexCount,r.instanceCount,D.indexStart,0,0)):(Ze.viewCount_indices(e,H[t],D.indexCount),Ze.viewCount_tri(e,H[t],D.indexCount/3),S.drawIndexed(a.encoder,D.indexCount,1,D.indexStart,0,i.index)),Ze.viewCount_draw(e,H[t])}}}}}renderPass2(e,t,a,r,i,n=!1){if(!this.enable||!this._geometry)return;let o=this,l=o.object3D.transform._worldMatrix;for(let c=0;c<this.materials.length;c++){const f=this.materials[c];if(!f.castShadow&&t==H.SHADOW)continue;let h=f.getPass(t);if(!h||h.length==0)return;if(this.drawType==2)for(let u of h)u.pipeline&&(S.bindPipeline(i,u),S.draw(i,6,1,0,l.index));else{S.bindGeometryBuffer(i,o._geometry);for(let u of h)if(u.pipeline){S.bindPipeline(i,u);let D=o._geometry.subGeometries[c].lodLevels[o.lodLevel];S.drawIndexed(i,D.indexCount,1,D.indexStart,0,l.index)}}}}recordRenderPass2(e,t,a,r,i,n=!1){if(!this.enable)return;let o=this;for(let l=0;l<this.materials.length;l++){let f=this.materials[l].getPass(t);if(!f||f.length==0)return;let h=o.object3D.transform._worldMatrix;for(let u=0;u<f.length;u++){const g=f[u];S.bindPipeline(i,g);let _=o._geometry.subGeometries[l].lodLevels[o.lodLevel];S.drawIndexed(i,_.indexCount,1,_.indexStart,0,h.index)}}}noticeShaderChange(){this.enable&&(this.onEnable(),this._passInit.forEach((e,t)=>{this._passInit.set(t,!1)}))}preInit(e){return this._passInit.get(e)}nodeUpdate(e,t,a,r){let i=this,n=e.scene.envMap;for(let o=0;o<i.materials.length;o++){let c=i.materials[o].getPass(t);if(c)for(let f=0;f<c.length;f++){const u=c[f];if(u.shaderState.splitTexture){let v=mt.CreateSplitTexture(i.instanceID);u.setTexture("splitTexture_Map",v)}!i._ignoreEnvMap&&u.envMap!=n&&u.setTexture("envMap",n),u.prefilterMap||u.setTexture("prefilterMap",n);let g=le.getReflectionEntries(e.scene);if(!u.reflectionMap&&g&&g.reflectionMap&&(u.setTexture("reflectionMap",g.reflectionMap),u.setStorageBuffer("reflectionBuffer",g.storageGPUBuffer)),u.pipeline){u.apply(i._geometry,a,()=>i.noticeShaderChange());continue}let p=A.res.getTexture("BRDFLUT");u.setTexture("brdflutMap",p);let m=A.getRenderJob(e).shadowMapPassRenderer;m&&m.depth2DArrayTexture&&u.setTexture("shadowMap",A.getRenderJob(e).shadowMapPassRenderer.depth2DArrayTexture);let D=A.getRenderJob(e).pointLightShadowRenderer;D&&D.cubeArrayTexture&&u.setTexture("pointShadowMap",D.cubeArrayTexture);let _=ra.iesTexture;_&&u.setTexture("iesTextureArrayMap",_),a.irradianceBuffer&&a.irradianceBuffer.length>0&&(u.setTexture("irradianceMap",a.irradianceBuffer[0]),u.setTexture("irradianceDepthMap",a.irradianceBuffer[1]));let B=le.getLightEntries(e.scene);B&&(u.setStorageBuffer("lightBuffer",B.storageGPUBuffer),B.irradianceVolume&&u.setUniformBuffer("irradianceData",B.irradianceVolume.irradianceVolumeBuffer)),r&&(u.setStorageBuffer("clustersUniform",r.clustersUniformBuffer),u.setStorageBuffer("lightAssignBuffer",r.lightAssignBuffer),u.setStorageBuffer("assignTable",r.assignTableBuffer),u.setStorageBuffer("clusterBuffer",r.clusterBuffer)),u.apply(i._geometry,a),this._passInit.set(t,!0)}}}beforeDestroy(e){me.getInstance().detached(this._geometry,this),me.getInstance().hasReference(this._geometry)||this._geometry.destroy(e);for(let t=0;t<this._materials.length;t++){const a=this._materials[t];me.getInstance().detached(a,this),me.getInstance().hasReference(a)||a.destroy(e)}super.beforeDestroy(e)}destroy(e){super.destroy(e),this._geometry=void 0,this._materials.length=0,this._combineShaderRefection=void 0}}fs([zr],Oa.prototype,"materials"),fs([zr],Oa.prototype,"castShadow"),fs([zr],Oa.prototype,"castGI");class ut{instanceID;name;enable=!0;_defaultSubShader;_shader;constructor(){this.instanceID=xt()}set shader(e){this._shader=e,this._defaultSubShader=e.getDefaultShaders()[0]}get shader(){return this._shader}get doubleSide(){return this._defaultSubShader.doubleSide}set doubleSide(e){this._defaultSubShader.doubleSide=e}get castShadow(){return this._defaultSubShader.shaderState.castShadow}set castShadow(e){let t=this._defaultSubShader.shaderState;e!=t.castShadow&&(t.castShadow=e)}get acceptShadow(){return this._defaultSubShader.shaderState.acceptShadow}set acceptShadow(e){let t=this._defaultSubShader.shaderState;t.acceptShadow!=e&&(t.acceptShadow=e,this._defaultSubShader.noticeShaderChange(),this._defaultSubShader.noticeValueChange())}get castReflection(){return this._defaultSubShader.shaderState.castReflection}set castReflection(e){this._defaultSubShader.shaderState.castReflection=e}get blendMode(){return this._defaultSubShader.blendMode}set blendMode(e){this._defaultSubShader.blendMode=e}get depthCompare(){return this._defaultSubShader.depthCompare}set depthCompare(e){this._defaultSubShader.depthCompare=e;for(let t of this._shader.passShader.values())for(let a of t)a.depthCompare=e}get transparent(){return this._defaultSubShader.shaderState.transparent}set transparent(e){this._defaultSubShader.shaderState.transparent=e,e&&(this._defaultSubShader.renderOrder=3e3)}get cullMode(){return this._defaultSubShader.cullMode}set cullMode(e){if(this._defaultSubShader.cullMode!=e){for(let t of this._shader.passShader.values())for(let a of t)a.cullMode=e;this._defaultSubShader.cullMode=e}}get depthWriteEnabled(){return this._defaultSubShader.depthWriteEnabled}set depthWriteEnabled(e){this._defaultSubShader.depthWriteEnabled=e}set useBillboard(e){this._defaultSubShader.setDefine("USE_BILLBOARD",e)}get topology(){return this._defaultSubShader.topology}set topology(e){this._defaultSubShader.topology=e}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}getPass(e){return this._shader.getSubShaders(e)}getAllPass(){return this._shader.getSubShaders(H.COLOR)}clone(){let e=new ut;return e.shader=this.shader.clone(),e}destroy(e){this.name=null,this.instanceID=null,this._shader.destroy(),this._shader=null}setDefine(e,t){this.shader.setDefine(e,t)}setTexture(e,t){this._shader.setTexture(e,t)}setStorageBuffer(e,t){this._shader.setStorageBuffer(e,t)}setUniformBuffer(e,t){this._shader.setStorageBuffer(e,t)}setUniformFloat(e,t){this._shader.setUniformFloat(e,t)}setUniformVector2(e,t){this._shader.setUniformVector2(e,t)}setUniformVector3(e,t){this._shader.setUniformVector3(e,t)}setUniformVector4(e,t){this._shader.setUniformVector4(e,t)}setUniformColor(e,t){this._shader.setUniformColor(e,t)}getUniformFloat(e){return this._shader.getUniform(e).data}getUniformV2(e){return this._shader.getUniformVector2(e)}getUniformV3(e){return this._shader.getUniformVector3(e)}getUniformV4(e){return this._shader.getUniformVector4(e)}getUniformColor(e){return this._shader.getUniformColor(e)}getTexture(e){return this._shader.getTexture(e)}getStorageBuffer(e){return this._shader.getStorageBuffer(e)}getStructStorageBuffer(e){return this._shader.getStructStorageBuffer(e)}getUniformBuffer(e){return this._shader.getUniformBuffer(e)}applyUniform(){this._shader.applyUniform()}}const Fc=`
5745
+ `}return a}return a}}function Yt(s){switch(s){case"int":return"i32";case"int[]":return"array<i32>";case"uint":return"u32";case"uint[]":return"array<u32>";case"float":return"f32";case"float[]":return"array<f32>";case"vec2":return"vec2<f32>";case"vec3":return"vec3<f32>";case"vec4":return"vec4<f32>";case"vec2[]":return"array<vec2<f32>>";case"vec3[]":return"array<vec3<f32>>";case"vec4[]":return"array<vec4<f32>>";case"ivec2":return"vec2<i32>";case"ivec3":return"vec3<i32>";case"ivec4":return"vec4<i32>";case"ivec2[]":return"array<vec2<i32>>";case"ivec3[]":return"array<vec3<i32>>";case"ivec4[]":return"array<vec4<i32>>";case"mat2":return"mat2x2<f32>";case"mat2x2":return"mat2x2<f32>";case"mat2x3":return"mat2x3<f32>";case"mat2x4":return"mat2x4<f32>";case"mat2[]":return"array<mat2x2<f32>>";case"mat2x2[]":return"array<mat2x2<f32>>";case"mat2x3[]":return"array<mat2x3<f32>>";case"mat2x4[]":return"array<mat2x4<f32>>";case"mat3":return"mat3x3<f32>";case"mat3x2":return"mat3x2<f32>";case"mat3x3":return"mat3x3<f32>";case"mat3x4":return"mat3x4<f32>";case"mat3[]":return"array<mat3x3<f32>>";case"mat3x2[]":return"array<mat3x2<f32>>";case"mat3x3[]":return"array<mat3x3<f32>>";case"mat3x4[]":return"array<mat3x4<f32>>";case"mat4":return"mat4x4<f32>";case"mat4x2":return"mat4x2<f32>";case"mat4x3":return"mat4x3<f32>";case"mat4x4":return"mat4x4<f32>";case"mat4[]":return"array<mat4x4<f32>>";case"mat4x2[]":return"array<mat4x2<f32>>";case"mat4x3[]":return"array<mat4x3<f32>>";case"mat4x4[]":return"array<mat4x4<f32>>";case"texture2D":return"texture_2d<f32>"}return s}class hc{_lexer;_rootNode;constructor(e){this._lexer=e,this._rootNode=new Ce,this.parse()}get lexer(){return this._lexer}parse(){for(;this.peekToken(0).Type!==U.EOF;){if(this.peekToken(0).Type==U.SEMICOLON){this.skipToken(1);continue}let e=this.parseStatement();e!==null&&this._rootNode.addNode(e)}}parseStatement(){let e=this.peekToken();if(e.Type==U.LAYOUT&&this.peekToken(1).Type==U.LEFTSAMLL)return Ai.parse(this._lexer);if(e.Type==U.STRUCT)return this.skipToken(1),Ma.parse(this._lexer);if((e.isBuiltinType()||e.Type==U.VOID)&&this.peekToken(1).Type==U.IDENT&&this.peekToken(2).Type==U.LEFTSAMLL)return rn.parse(this._lexer);if(e.Type==U.CONST&&this.peekToken(1).isDataType())return Ve.parse(this._lexer);if(e.isDataType()&&this.peekToken(1).Type==U.IDENT)return Ve.parse(this._lexer);if(e.Type==U.OUT&&this.peekToken(1).isDataType()&&this.peekToken(2).Type==U.IDENT)return Ve.parse(this._lexer);if(e.Type==U.PRECISION)return on.parse(this._lexer);throw"Error parsing statement: Unexpected character"}skipToken(e){this._lexer.skipToken(e)}peekToken(e=0){return this._lexer.peekToken(e)}getNextToken(){return this._lexer.GetNextToken()}get ASTRoot(){return this._rootNode}}class uc{static VertexShader="VertexShader";static FragmentShader="FragmentShader";static convertGLSL(e){var t=new lc(e),a=new oc(t),r=new hc(a),i=new cc(r);return i.generateWGSL()}}class ss{setID=0;bindingID=0;name="";type=""}class os{name="";type="";locationID=0;builtinName="";isBuiltinAttribute(){return this.builtinName!=""}}class bc{uniformInfo=[];inputAttribute=[];outputAttribute=[];sourceCode=""}var na=(s=>(s[s.vertex=0]="vertex",s[s.fragment=1]="fragment",s[s.computer=2]="computer",s))(na||{});class gc{blendMode=te.NONE;depthCompare=$e.less_equal;depthWriteEnabled=!0;frontFace="ccw";cullMode=Ft.back;topology=zn.triangle_list;depthBias=10;useLight=!1;useProbe=!1;acceptGI=!1;acceptShadow=!1;castShadow=!1;castReflection=!0;receiveEnv=!1;renderLayer=1e3;renderOrder=2e3;unclippedDepth=!1;transparent=!1;multisample=0;label;useZ=!0;splitTexture=!1;alphaCutoff;useFragDepth=!1;writeMasks=[];setFromMapValues(e){e.has("blendMode")&&(this.blendMode=this.convertBlendMode(e.get("blendMode"))),e.has("depthCompare")&&(this.depthCompare=e.get("depthCompare")),e.has("depthWriteEnabled")&&(this.depthWriteEnabled=e.get("depthWriteEnabled")),e.has("frontFace")&&(this.frontFace=e.get("frontFace")),e.has("cullMode")&&(this.cullMode=e.get("cullMode")),e.has("topology")&&(this.topology=e.get("topology")),e.has("depthBias")&&(this.depthBias=e.get("depthBias")),e.has("useLight")&&(this.useLight=e.get("useLight")),e.has("useProbe")&&(this.useProbe=e.get("useProbe")),e.has("acceptGI")&&(this.acceptGI=e.get("acceptGI")),e.has("acceptShadow")&&(this.acceptShadow=e.get("acceptShadow")),e.has("castShadow")&&(this.castShadow=e.get("castShadow")),e.has("receiveEnv")&&(this.receiveEnv=e.get("receiveEnv")),e.has("renderLayer")&&(this.renderLayer=e.get("renderLayer")),e.has("renderOrder")&&(this.renderOrder=e.get("renderOrder")),e.has("unclippedDepth")&&(this.unclippedDepth=e.get("unclippedDepth")),e.has("multisample")&&(this.multisample=e.get("multisample")),e.has("label")&&(this.label=e.get("label")),e.has("useZ")&&(this.useZ=e.get("useZ"))}convertBlendMode(e){switch(e){case"ABOVE":return te.ABOVE;case"ALPHA":return te.ALPHA;case"NORMAL":return te.NORMAL;case"ADD":return te.ADD;case"BELOW":return te.BELOW;case"ERASE":return te.ERASE;case"MUL":return te.MUL;case"SCREEN":return te.SCREEN;case"DIVD":return te.DIVD;case"SOFT_ADD":return te.SOFT_ADD}return te.NONE}}class mc extends Ta{uniformNodes=[];_onChange=!0;constructor(){super(),this.bufferType=ea.MaterialDataUniformGPUBuffer}initDataUniform(e){this.uniformNodes=e;let t=0;for(const a in e){const r=e[a];r||console.error(a,"is empty"),t+=r.size*4}t=Math.floor(t/256+1)*256,this.createBuffer(GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,t/4,null,"MaterialDataUniformGPUBuffer");for(const a in e){const r=e[a];r||console.error(a,"is empty");let i=this.memory.allocation_node(r.size*4);r.memoryInfo=i,r.bindOnChange=()=>this.onChange()}}onChange(){this._onChange=!0}apply(){if(this.uniformNodes.length!=0&&this._onChange){for(const e in this.uniformNodes)this.uniformNodes[e].update();super.apply(),this._onChange=!1}}}class Va{static renderShaderModulePool;static renderShader;static init(){this.renderShaderModulePool=new Map,this.renderShader=new Map}}class me{reference;static _ins;static getInstance(){return this._ins||=new me,this._ins}attached(e,t){this.reference||=new Map;let a=this.reference.get(e);a||=new Map,a.set(t,e),this.reference.set(e,a)}detached(e,t){if(!this.reference)return;let a=this.reference.get(e);a&&(a.delete(t),a.size===0&&this.reference.delete(e))}hasReference(e){let t=this.reference.get(e);return t?t.size>0:!1}getReferenceCount(e){let t=this.reference.get(e);return t?t.size:0}getReference(e){let t=this.reference.get(e);return t||null}}class ls{static pipelineMap=new Map;static getSharePipeline(e){let t=this.pipelineMap.get(e);return t||null}static setSharePipeline(e,t){this.pipelineMap.set(e,t)}}class Ne extends Gn{passType=H.COLOR;useRz=!1;vsName;fsName;shaderState;textures;pipeline;bindGroupLayouts;envMap;prefilterMap;reflectionMap;_sourceVS;_sourceFS;_destVS;_destFS;_vsShaderModule;_fsShaderModule;_textureGroup=-1;_textureChange=!1;_groupsShaderReflectionVarInfos;outBufferMask;constructor(e,t){super(),this.vsName=e.toLowerCase(),this.fsName=t.toLowerCase(),this.vsName in J||console.error("Shader Not Register, Please Register Shader!",this.vsName),this.fsName in J||console.error("Shader Not Register, Please Register Shader!",this.fsName),J[this.vsName]&&(this._sourceVS=J[this.vsName]),J[this.fsName]&&(this._sourceFS=J[this.fsName]),this.textures={},this.bindGroups=[],this.shaderState=new gc,this.materialDataUniformBuffer=new mc,this.materialDataUniformBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,this._bufferDic.set("global",this.materialDataUniformBuffer),this._bufferDic.set("materialUniform",this.materialDataUniformBuffer)}get renderOrder(){return this.shaderState.renderOrder}set renderOrder(e){this.shaderState.renderOrder!=e&&(this._valueChange=!0),this.shaderState.renderOrder=e}get doubleSide(){return this.shaderState.cullMode==Ft.none}set doubleSide(e){let t=e?Ft.none:this.cullMode;this.shaderState.cullMode!=t&&(this._valueChange=!0),this.shaderState.cullMode=t}get depthWriteEnabled(){return this.shaderState.depthWriteEnabled}set depthWriteEnabled(e){this.shaderState.depthWriteEnabled!=e&&(this._valueChange=!0),this.shaderState.depthWriteEnabled=e}get cullMode(){return this.shaderState.cullMode}set cullMode(e){this.shaderState.cullMode!=e&&(this._valueChange=!0),this.shaderState.cullMode=e}get frontFace(){return this.shaderState.frontFace}set frontFace(e){this.shaderState.frontFace!=e&&(this._valueChange=!0),this.shaderState.frontFace=e}get depthBias(){return this.shaderState.depthBias}set depthBias(e){this.shaderState.depthBias!=e&&(this._valueChange=!0),this.shaderState.depthBias=e}get topology(){return this.shaderState.topology}set topology(e){this.shaderState.topology!=e&&(this._valueChange=!0),this.shaderState.topology=e}get blendMode(){return this.shaderState.blendMode}set blendMode(e){this.shaderState.blendMode!=e&&(this._valueChange=!0,e!=te.NORMAL&&e!=te.NONE&&(this.renderOrder=3e3)),this.shaderState.blendMode=e}get depthCompare(){return this.shaderState.depthCompare}set depthCompare(e){this.shaderState.depthCompare!=e&&(this._valueChange=!0),this.shaderState.depthCompare=e}setShaderEntry(e="",t=""){this.vsEntryPoint=e,this.fsEntryPoint=t}setUniform(e,t){super.setUniform(e,t),this.materialDataUniformBuffer.onChange()}setTexture(e,t){t&&this.textures[e]!=t&&(this.textures[e]&&this.textures[e].unBindStateChange(this),this._textureChange=!0,this.textures[e]=t,e=="envMap"?this.envMap=t:e=="prefilterMap"?this.prefilterMap=t:e=="reflectionMap"&&(this.reflectionMap=t),t.bindStateChange(()=>{this._textureChange=!0},this))}get baseColor(){return this.getUniform("baseColor")}set baseColor(e){this.setUniform("baseColor",e)}getTexture(e){return this.textures[e]}genRenderPipeline(e,t){let a=this.createGroupLayouts();this.createPipeline(e,t,a)}reBuild(e,t){this.compileShader(na.vertex,this._destVS,t),this.compileShader(na.fragment,this._destFS,t),this.genRenderPipeline(e,t)}apply(e,t,a){this.materialDataUniformBuffer.apply(),this._textureChange&&this._textureGroup!=-1&&(this._textureChange=!1,this.genGroups(this._textureGroup,this.shaderReflection.groups,!0)),this._valueChange&&(this._shaderChange&&(this.preCompile(e),this._shaderChange=!1),this.shaderVariant=dt.genRenderShaderVariant(this),this.reBuild(e,t),this._valueChange=!1,a&&a())}preCompile(e){this.preDefine(e),this.preCompileShader(na.vertex,this._sourceVS.concat()),this.preCompileShader(na.fragment,this._sourceFS.concat()),this.genReflection()}applyPostDefine(e,t){return t.renderTargetTextures.length>1?(this.defineValue.USE_WORLDPOS=!0,this.defineValue.USEGBUFFER=!0):(this.defineValue.USE_WORLDPOS=!1,this.defineValue.USEGBUFFER=!1),A.setting.render.useCompressGBuffer?this.defineValue.USE_COMPRESSGBUFFER=!0:this.defineValue.USE_COMPRESSGBUFFER=!1,ta.parse(e,this.defineValue)}setBindGroup(e,t){this.bindGroups[e]=t}checkBuffer(e,t){}preCompileShader(e,t,a){let r=t;if(r.indexOf("version ")!=-1){var i=uc.convertGLSL(r);r=i.sourceCode}for(const n in this.constValues)if(Object.prototype.hasOwnProperty.call(this.constValues,n)){const o=this.constValues[n];r=r.replaceAll(`&${n}`,o.toString())}switch(e){case na.vertex:this._destVS=r;break;case na.fragment:this._destFS=r;break}}compileShader(e,t,a){let r=t;r=this.applyPostDefine(r,a);let i=t;for(let o in this.defineValue)i+=`${o}=${this.defineValue[o]},`;let n=Va.renderShaderModulePool.get(i);switch(n||(r=this.applyPostDefine(r,a),n=E.device.createShaderModule({label:e==na.vertex?this.vsName:this.fsName,code:r}),n.getCompilationInfo().then(o=>{o.messages.length>0&&(console.log(r),console.log(o))}),Va.renderShaderModulePool.set(i,n)),e){case na.vertex:this._vsShaderModule=n,this._destVS=r;break;case na.fragment:this._fsShaderModule=n,this._destFS=r;break}}getGroupLayout(e,t){let a=[];for(let r=0;r<t.length;r++){const i=t[r];if(i)if(i.varType=="uniform"){this._bufferDic.has(i.varName)||console.error(`not set ${i.varName} buffer`);let n=this._bufferDic.get(i.varName).visibility,o={binding:i.binding,visibility:n,buffer:{type:"uniform"}};a.push(o)}else if(i.varType=="storage-read"){this._bufferDic.has(i.varName)||console.error(`not set ${i.varName} buffer`);let n=this._bufferDic.get(i.varName).visibility,o={binding:i.binding,visibility:n,buffer:{type:"read-only-storage"}};a.push(o)}else if(i.varType=="var")switch(i.dataType){case"sampler":{let n=i.varName.replace("Sampler",""),o=this.textures[n]?this.textures[n]:A.res.redTexture,l={binding:i.binding,visibility:o.visibility,sampler:o.samplerBindingLayout};a.push(l),this._textureGroup=e}break;case"sampler_comparison":{let n=i.varName.replace("Sampler",""),o=this.textures[n]?this.textures[n]:A.res.redTexture,l={binding:i.binding,visibility:o.visibility,sampler:o.sampler_comparisonBindingLayout};a.push(l),this._textureGroup=e}break;case"texture_2d<f32>":case"texture_2d_array<f32>":case"texture_cube<f32>":case"texture_depth_2d":case"texture_depth_2d_array":case"texture_depth_cube":case"texture_depth_cube_array":{let n=this.textures[i.varName]?this.textures[i.varName]:A.res.redTexture,o={binding:i.binding,visibility:n.visibility,texture:n.textureBindingLayout};a.push(o),this._textureGroup=e,me.getInstance().attached(n,this)}break;case"texture_external":{let n=this.textures[i.varName]?this.textures[i.varName]:A.res.redTexture,o={binding:i.binding,visibility:n.visibility,externalTexture:{}};a.push(o),this._textureGroup=e,me.getInstance().attached(n,this)}break;default:{let n=this.textures[i.varName]?this.textures[i.varName]:A.res.redTexture,o={binding:i.binding,visibility:n.visibility,texture:n.textureBindingLayout};a.push(o),this._textureGroup=e,me.getInstance().attached(n,this)}break}else{debugger;console.error("bind group can't empty")}}return a}_cacheEntries;genGroups(e,t,a=!1){if(!this.bindGroups[e]||a){const r=t[e];let i=[];for(let o=0;o<r.length;o++){const l=r[o];if(l){if(l.varType=="uniform"){let c=this._bufferDic.get(l.varName);if(c){if(c.bufferType==ea.MaterialDataUniformGPUBuffer){let h=[];for(let u=0;u<l.dataFields.length;u++){const g=l.dataFields[u];this.uniforms[g.name]||console.error(`shader-${this.vsName}:${this.fsName} ${g.name}is empty`),h.push(this.uniforms[g.name])}this.materialDataUniformBuffer.initDataUniform(h)}let f={binding:l.binding,resource:{buffer:c.buffer,offset:0,size:c.memory.shareDataBuffer.byteLength}};i.push(f),this.checkBuffer(l.varName,c)}else console.error(`shader${this.vsName}-${this.fsName}`,`buffer ${l.varName} is missing!`)}else if(l.varType=="storage-read"){let c=this._bufferDic.get(l.varName);if(c){let f={binding:l.binding,resource:{buffer:c.buffer,offset:0,size:c.memory.shareDataBuffer.byteLength}};i.push(f),this.checkBuffer(l.varName,c)}else console.error(`buffer ${l.varName} is missing!`)}else if(l.varType=="var")if(l.dataType=="sampler"){let c=l.varName.replace("Sampler",""),f=this.textures[c];if(f||(f=A.res.blackTexture,this.setTexture(c,f)),f){let h={binding:l.binding,resource:f.gpuSampler};i.push(h)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}else if(l.dataType=="sampler_comparison"){let c=l.varName.replace("Sampler",""),f=this.textures[c];if(f){let h={binding:l.binding,resource:f.gpuSampler_comparison};i.push(h)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}else{let c=this.textures[l.varName];if(c||(c=A.res.whiteTexture,this.setTexture(l.varName,c)),c){let f={binding:l.binding,resource:c.getGPUView()};i.push(f)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}}}let n=E.device.createBindGroup({layout:this.bindGroupLayouts[e],entries:i});this.bindGroups[e]=n}}createPipeline(e,t,a){let r=e,i=this.shaderState,n=[];for(const c of t.renderTargetTextures)n.push({format:c.format});for(let c=0;c<n.length;c++){const f=n[c];i.writeMasks&&i.writeMasks.length>0&&(f.writeMask=i.writeMasks[c])}if(t.outColor!=-1){let c=n[t.outColor];i.blendMode!=te.NONE?c.blend=nc.getBlend(i.blendMode):delete c.blend}let o={label:this.vsName+"|"+this.fsName,layout:a,primitive:{topology:i.topology,cullMode:i.cullMode,frontFace:i.frontFace},vertex:void 0};this.vsEntryPoint!=""&&(o.vertex={module:this._vsShaderModule,entryPoint:this.vsEntryPoint,buffers:r.vertexBuffer.vertexBufferLayouts}),this.fsEntryPoint!=""&&(o.fragment={module:this._fsShaderModule,entryPoint:this.fsEntryPoint,targets:n}),i.multisample>0&&(o.multisample={count:i.multisample}),(t.zPreTexture||t.depthTexture)&&(i.blendMode!=te.NONE,A.setting.render.zPrePass&&t.zPreTexture&&i.useZ?o.depthStencil={depthWriteEnabled:!1,depthCompare:$e.less,format:t.zPreTexture.format}:o.depthStencil={depthWriteEnabled:i.depthWriteEnabled,depthCompare:i.depthCompare,format:t.depthTexture.format});let l=ls.getSharePipeline(this.shaderVariant);l?this.pipeline=l:(this.pipeline=S.createPipeline(o),ls.setSharePipeline(this.shaderVariant,this.pipeline))}createGroupLayouts(){this._groupsShaderReflectionVarInfos=[];let e=this.shaderReflection;this.bindGroupLayouts=[is.getGlobalDataBindGroupLayout()];for(let a=1;a<e.groups.length;a++){let r=e.groups[a];if(r){let i=this.getGroupLayout(a,r);this._groupsShaderReflectionVarInfos[a]=r;let n=E.device.createBindGroupLayout({entries:i,label:`vs${this.vsName} fs${this.fsName} ${r.length}`});this.bindGroupLayouts[a]=n}else console.error("can't set empty group!",a)}let t=E.device.createPipelineLayout({bindGroupLayouts:this.bindGroupLayouts});return this._groupsShaderReflectionVarInfos[1]&&this.genGroups(1,this._groupsShaderReflectionVarInfos),this._groupsShaderReflectionVarInfos[2]&&this.genGroups(2,this._groupsShaderReflectionVarInfos),this._groupsShaderReflectionVarInfos[3]&&this.genGroups(3,this._groupsShaderReflectionVarInfos),t}preDefine(e){let t=e.hasAttribute(V.TEXCOORD_1),a=e.hasAttribute(V.joints0),r=e.hasAttribute(V.a_morphPositions_0),i=e.hasAttribute(V.TANGENT),n=e.hasAttribute(V.color),o=this.shaderState.acceptGI,l=this.shaderState.useLight;t&&(this.defineValue.USE_SECONDUV=!0),a&&r?this.defineValue.USE_METAHUMAN=!0:(this.defineValue.USE_SKELETON=a,this.defineValue.USE_MORPHTARGETS=r),"USE_TANGENT"in this.defineValue||(this.defineValue.USE_TANGENT=i),this.defineValue.USE_GI=o,this.defineValue.USE_SHADOWMAPING=this.shaderState.acceptShadow,this.defineValue.USE_LIGHT=l,this.defineValue.USE_VERTXCOLOR=n,A.setting.pick.mode=="pixel"&&(this.defineValue.USE_WORLDPOS=!0),A.setting.gi.enable?this.defineValue.USEGI=!0:this.defineValue.USEGI=!1,A.setting.render.debug&&(this.defineValue.USE_DEBUG=!0,this.defineValue.DEBUG_CLUSTER=!0),this.shaderState.useLight?this.defineValue.USE_LIGHT=!0:this.defineValue.USE_LIGHT=!1,A.setting.render.useLogDepth?(this.defineValue.USE_LOGDEPTH=!0,this.shaderState.useFragDepth=!0):this.defineValue.USE_LOGDEPTH=!1,this.shaderState.useFragDepth?this.defineValue.USE_OUTDEPTH=!0:this.defineValue.USE_OUTDEPTH=!1,this.defineValue.USE_PCF_SHADOW=A.setting.shadow.type=="PCF",this.defineValue.USE_HARD_SHADOW=A.setting.shadow.type=="HARD",this.defineValue.USE_SOFT_SHADOW=A.setting.shadow.type=="SOFT",this.defineValue.USE_CSM=Jt.Cascades>1,this.defineValue.USE_IES_PROFILE=ra.use}genReflection(){this.shaderVariant=dt.genRenderShaderVariant(this);let e=dt.poolGetReflection(this.shaderVariant);if(e)this.shaderReflection=e;else{let t=ta.parse(this._destVS,this.defineValue);t=ta.parse(t,this.defineValue),dt.getShaderReflection2(t,this);let a=ta.parse(this._destFS,this.defineValue);a=ta.parse(a,this.defineValue),dt.getShaderReflection2(a,this),dt.final(this)}this.shaderState.splitTexture=this.shaderReflection.useSplit}destroy(e){for(const t in this.textures)if(Object.prototype.hasOwnProperty.call(this.textures,t)){const a=this.textures[t];if(me.getInstance().detached(a,this),e&&!me.getInstance().hasReference(a))a.destroy(e);else{a.destroy(!1);let r=me.getInstance().getReference(a);if(r){let i=[];r.forEach((n,o)=>{"name"in n?i.push(n.name):i.push("NaN")})}}}this.bindGroups.length=0,this.shaderState=null,this.textures=null,this.pipeline=null,this.bindGroupLayouts=null,this._sourceVS=null,this._sourceFS=null,this._destVS=null,this._destFS=null,this._vsShaderModule=null,this._fsShaderModule=null,this.materialDataUniformBuffer.destroy(e),this.materialDataUniformBuffer=null}static destroyShader(e){Va.renderShader.has(e)&&(Va.renderShader.get(e).destroy(),Va.renderShader.delete(e))}static getShader(e){return Va.renderShader.get(e)}static createShader(e,t){let a=new Ne(e,t);return Va.renderShader.set(a.instanceID,a),a.instanceID}}class pc extends Ne{constructor(){super("sky_vs_frag_wgsl","SkyGBuffer_fs"),this.passType=H.GI,this.setUniformVector3("eyesPos",new b),this.setUniformFloat("exposure",1),this.setUniformFloat("roughness",0);let e=this.shaderState;e.frontFace="ccw",e.cullMode=Ft.front,e.depthWriteEnabled=!1,e.depthCompare=$e.less}}class Ac extends Ne{transparency;constructor(){super("gbuffer_vs","gbuffer_fs"),this.setShaderEntry("VertMain","FragMain"),this.passType=H.GI,this.setUniformColor("baseColor",new O),this.setUniformColor("emissiveColor",new O),this.setUniformFloat("emissiveIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("alphaCutoff",1),this.blendMode=te.NONE,this.setTexture("normalMap",A.res.normalTexture)}}class Dc extends Ne{constructor(){super("shadowCastMap_vert","directionShadowCastMap_frag"),this.passType=H.SHADOW,this.setShaderEntry("main"),this.setUniformFloat("cameraFar",5e3),this.setUniformVector3("lightWorldPos",b.ZERO),this.shaderState.receiveEnv=!1,this.shaderState.castShadow=!1,this.shaderState.acceptShadow=!1,this.setDefine("USE_ALPHACUT",!0)}}class _c extends Ne{constructor(){super("castPointShadowMap_vert","shadowCastMap_frag"),this.passType=H.POINT_SHADOW,this.setShaderEntry("main","main"),this.setUniformFloat("cameraFar",5e3),this.setUniformVector3("lightWorldPos",b.ZERO),this.shaderState.receiveEnv=!1,this.shaderState.castShadow=!1,this.shaderState.acceptShadow=!1,this.setDefine("USE_ALPHACUT",!0)}}class Bc extends Ne{constructor(){super("ZPass_shader_vs","ZPass_shader_vs"),this.passType=H.DEPTH,this.setShaderEntry("main"),this.useRz=!1;let e=this.shaderState;e.receiveEnv=!1}}class Di{static createGIPass(e,t){if(zt.hasMask(e.rendererMask,De.Sky)){if(!t.passShader.get(H.GI)){let r=t.getSubShaders(H.COLOR)[0],i=new pc;i.setTexture("baseMap",r.getTexture("baseMap")),i.cullMode=r.cullMode,i.frontFace=r.frontFace,t.addRenderPass(i,0),i.preCompile(e.geometry)}}else this.castGBufferPass(e,t)}static castGBufferPass(e,t){let a=t.getDefaultShaders();for(let r=0;r<a.length;r++){const i=a[r];let n=t.getSubShaders(H.GI);if(!n||n.length==0||n.length<r){let o=new Ac;o.setTexture("baseMap",i.getTexture("baseMap")),o.setTexture("normalMap",i.getTexture("normalMap")),o.setTexture("emissiveMap",i.getTexture("emissiveMap")),i.uniforms.baseColor&&o.setUniform("baseColor",i.getUniform("baseColor")),i.uniforms.envIntensity&&o.setUniform("envIntensity",i.getUniform("envIntensity")),i.uniforms.emissiveColor&&o.setUniform("emissiveColor",i.getUniform("emissiveColor")),i.uniforms.emissiveIntensity&&o.setUniform("emissiveIntensity",i.getUniform("emissiveIntensity")),i.uniforms.alphaCutoff&&o.setUniform("alphaCutoff",i.getUniform("alphaCutoff")),o.cullMode=i.cullMode,o.frontFace=i.frontFace,o.preCompile(e.geometry),t.addRenderPass(o)}}}static createShadowPass(e,t){let a=zt.hasMask(e.rendererMask,De.SkinnedMesh),r=e.geometry.hasAttribute(V.TANGENT),i=e.geometry.hasAttribute(Zt.MORPH_POSITION_PREFIX+"0"),n=e.geometry.hasAttribute(Zt.MORPH_NORMAL_PREFIX+"0"),o=t.getSubShaders(H.COLOR);for(let l=0;l<o.length;l++){const c=o[l];let f=t.getSubShaders(H.SHADOW);if(!f||f.length<l+1){let u=new Dc;u.setTexture("baseMap",c.getTexture("baseMap")),u.setUniform("alphaCutoff",c.getUniform("alphaCutoff")),r&&u.setDefine("USE_TANGENT",r),a&&u.setDefine("USE_SKELETON",a),i&&u.setDefine("USE_MORPHTARGETS",i),n&&u.setDefine("USE_MORPHNORMALS",n),c.cullMode=="none"?u.shaderState.cullMode="none":c.cullMode=="back"?u.shaderState.cullMode="front":c.cullMode=="front"&&(u.shaderState.cullMode="back"),u.preCompile(e.geometry),t.addRenderPass(u)}let h=t.getSubShaders(H.POINT_SHADOW);if(!h||h.length<l+1){let u=new _c;u.setTexture("baseMap",c.getTexture("baseMap")),u.setUniform("alphaCutoff",c.getUniform("alphaCutoff")),u.setDefine("USE_ALPHACUT",1);for(let g=0;g<1;g++)r&&u.setDefine("USE_TANGENT",r),a&&u.setDefine("USE_SKELETON",a),i&&u.setDefine("USE_MORPHTARGETS",i),n&&u.setDefine("USE_MORPHNORMALS",n),u.shaderState.cullMode="front",u.preCompile(e.geometry);t.addRenderPass(u)}}}static createDepthPass(e,t){let a=t.getSubShaders(H.COLOR),r=e.geometry.hasAttribute("TANGENT"),i=e.geometry.hasAttribute(Zt.MORPH_POSITION_PREFIX+"0"),n=e.geometry.hasAttribute(Zt.MORPH_NORMAL_PREFIX+"0"),o=zt.hasMask(e.rendererMask,De.SkinnedMesh);for(let l=0;l<a.length;l++){const c=a[l];let f=t.getSubShaders(H.DEPTH);if(!f&&c.shaderState.useZ&&(!f||f.length<l)){let h=new Bc;h.setTexture("baseMap",c.getTexture("baseMap")),r||h.setDefine("USE_TANGENT",r),o&&h.setDefine("USE_SKELETON",o),i&&h.setDefine("USE_MORPHTARGETS",i),n&&h.setDefine("USE_MORPHNORMALS",n),h.cullMode=c.cullMode,h.frontFace=c.frontFace,h.preCompile(e.geometry),t.addRenderPass(h)}}}static createReflectionPass(e,t){let a=t.getDefaultShaders();for(let o=0;o<a.length;o++){const l=a[o];let c=t.getSubShaders(H.REFLECTION);if(!c||c.length==0||c.length<o){let f=new Ne(l.vsName,l.fsName);f.vsEntryPoint=l.vsEntryPoint,f.fsEntryPoint=l.fsEntryPoint,f.passType=H.REFLECTION;for(const h in l.shaderState){var r=l.shaderState[h];f.shaderState[h]=r}for(const h in l.textures){var i=l.getTexture(h);f.setTexture(h,i)}for(const h in l.uniforms){var n=l.getUniform(h);f.setUniform(h,n)}for(const h in l.defineValue){var n=l.defineValue[h];f.setDefine(h,n)}f.setDefine("USE_CASTREFLECTION",!0),f.preCompile(e.geometry),t.addRenderPass(f)}}}}class tr{static _v1=new b;static _v2=new b;entities;box;subTrees=[];parent;level;static maxSplitLevel=6;static autoSplitLevel=3;index;uuid;constructor(e,t=0,a=null,r=0){this.parent=a,this.box=e.clone(),this.level=r,this.index=t,this.uuid=r+"_"+t,this.entities=new Map}tryInsertEntity(e){let t=e.renderer.object3D.bound;if(this.level==0||this.box.containsBox(t)){this.subTrees.length==0&&this.level<tr.maxSplitLevel&&this.splitTree();let a;if(this.subTrees.length>0){for(let r of this.subTrees)if(r.tryInsertEntity(e)){a=!0;break}}return a||e.enterNode(this),!0}return!1}splitTree(){if(this.subTrees.length==0){const e=tr._v1,t=this.box.extents.clone();let a=this.level+1,r=0;for(let i=0;i<2;i++)for(let n=0;n<2;n++)for(let o=0;o<2;o++){const l=new ge;this.box.min.add(e.set(i,n,o).multiply(t),l.min),l.min.add(t,l.max),l.setFromMinMax(l.min,l.max);let c=new tr(l,r++,this,a);this.subTrees.push(c)}}}__rayCastTempVector=new b;rayCasts(e,t){if(this.level==0||e.intersectBox(this.box,this.__rayCastTempVector)){this.entities.size>0&&t.push(...this.entities.values());for(let a of this.subTrees)a.rayCasts(e,t);return!0}return!1}frustumCasts(e,t){if(this.level==0||e.containsBox2(this.box)>0){if(this.entities.size>0)for(const a of this.entities.values())(this.level>tr.autoSplitLevel||e.containsBox2(a.renderer.object3D.bound)>0)&&t.push(a);for(let a of this.subTrees)a.frustumCasts(e,t);return!0}return!1}getRenderNode(e,t){if(this.level==0||e.containsBox2(this.box)>0){if(this.entities.size>0)for(const a of this.entities.values())(this.level>tr.autoSplitLevel||e.containsBox2(a.renderer.object3D.bound)>0)&&(a.renderer.renderOrder<3e3?t.opaqueList.push(a.renderer):a.renderer.renderOrder>=3e3&&t.transparentList.push(a.renderer));for(let a of this.subTrees)a.getRenderNode(e,t);return!0}return!1}boxCasts(e,t){if(e.intersectsBox(this.box)){this.entities.size>0&&t.push(...this.entities.values());for(let a of this.subTrees)a.boxCasts(e,t);return!0}return!1}clean(){for(let e of this.entities.values())e.leaveNode();return this.entities.clear(),this}}class Uc{_pool=[];_worldPosition=new b;_viewPosition=new b;_zSortList=[];pop(){return this._pool.pop()||{}}recycle(){for(let e of this._zSortList)e.z=0,e.userData=null,e.obj3d=null,this._pool.push(e);this._zSortList.length=0}sort(e,t,a,r){this._zSortList=[];for(let i of t){let n=this.pop();n.userData=i,n.obj3d=a(i),n.z=this.worldToCameraDepth(n.obj3d,e),this._zSortList.push(n)}this._zSortList.sort((i,n)=>i.z-n.z>0?1:-1),r||=[];for(let i of this._zSortList)r.push(i.userData);return this.recycle(),r}worldToCameraDepth(e,t){t||=e.transform.view3D.camera;let a=0;return t&&(this._worldPosition.copyFrom(e.transform.worldPosition),t.worldToScreenPoint(this._worldPosition,this._viewPosition),a=this._viewPosition.z),a}}let vc=new Uc;var _i=(s=>(s[s.None=2]="None",s[s.StaticBatch=4]="StaticBatch",s[s.DynamicBatch=8]="DynamicBatch",s[s.Hiden=16]="Hiden",s))(_i||{});class cs{static addMask(e,t){return e|t}static removeMask(e,t){return e&~t}static hasMask(e,t){return(e&t)!=0}}class yc{opaqueList=[];transparentList=[];sky;clean(){this.opaqueList.length=0,this.transparentList.length=0}}class Cc{renderGroup;constructor(){this.renderGroup=new Map}collect_add(e){let t="",a="";t+=e.geometry.instanceID;for(let i=0;i<e.materials.length;i++){const n=e.materials[i];a+=n.shader.getDefaultColorShader().shaderVariant}let r=t+a;this.renderGroup.has(r)||this.renderGroup.set(r,{bundleMap:new Map,key:r,renderNodes:[]}),this.renderGroup.get(r).renderNodes.indexOf(e)==-1&&this.renderGroup.get(r).renderNodes.push(e)}}class Sc{renderShaderUpdateList=new Map;renderNodeList=new Map;collect_add(e){let t=e.transform.view3D;t&&e.materials&&e.materials.forEach(a=>{let r=this.renderShaderUpdateList.get(t);r||(r=new Map,this.renderShaderUpdateList.set(t,r));let i=this.renderNodeList.get(t);i||(i=new Map,this.renderNodeList.set(t,i)),i.set(e.instanceID,e);let n=a.getAllPass();for(let o=0;o<n.length;o++){const l=n[o];let c=`${e.geometry.instanceID+l.instanceID}`,f=r.get(c);f||(f=new Map,r.set(c,f)),f.set(e.instanceID,e)}})}collect_remove(e){let t=e.transform.view3D;if(t&&e.materials){let a=this.renderShaderUpdateList.get(t);a&&e.materials.forEach(r=>{let i=r.getAllPass();for(let n=0;n<i.length;n++){const o=i[n];let l=`${e.geometry.instanceID+o.instanceID}`;a.delete(l)}})}}}class W{static _instance;_sceneLights;_sceneGIProbes;_op_RenderNodes;_tr_RenderNodes;_octreeRenderNodes;_reflections;_graphics;_op_renderGroup;_tr_renderGroup;_renderShaderCollect;state={giLightingChange:!0};sky;_collectInfo;rendererOctree;static get instance(){return this._instance||(this._instance=new W),this._instance}constructor(){this._sceneLights=new Map,this._sceneGIProbes=new Map,this._op_RenderNodes=new Map,this._tr_RenderNodes=new Map,this._reflections=new Map,this._graphics=[],this._op_renderGroup=new Map,this._tr_renderGroup=new Map,this._collectInfo=new yc,this._renderShaderCollect=new Sc,this._octreeRenderNodes=new Map}getPashList(e,t){if(t.renderOrder<3e3)return this._op_RenderNodes.get(e);if(t.renderOrder>=3e3)return this._tr_RenderNodes.get(e)}sortRenderNode(e,t){for(let a=e.length-1;a>0;a--)if(e[a].renderOrder<t.renderOrder){e.push(t);return}e.push(t)}addRenderNode(e,t){if(!e)return;let a=t.renderOrder>=3e3;if(t.hasMask(De.Sky))this.sky=t;else if(t.hasMask(De.Reflection)){this.removeRenderNode(e,t);let r=this._reflections.get(e);r||(r=[],this._reflections.set(e,r),r.push(t)),r.includes(t)||r.push(t)}else if(t.hasMask(De.Graphic3D))this._graphics.indexOf(t)==-1&&this._graphics.push(t);else if(cs.hasMask(t.renderLayer,_i.None)){this.removeRenderNode(e,t);let r=a?this._tr_RenderNodes:this._op_RenderNodes;r.has(e)||r.set(e,[]),r.get(e).push(t),A.setting.occlusionQuery.octree&&t.attachSceneOctree(this.getOctree(e));let i=this.getPashList(e,t);i.indexOf(t)==-1&&this.sortRenderNode(i,t)}else{this.removeRenderNode(e,t);let r=a?this._tr_renderGroup:this._op_renderGroup;r.has(e)||r.set(e,new Cc),r.get(e).collect_add(t)}t.object3D.renderNode=t,this._renderShaderCollect.collect_add(t)}getOctree(e){let t,a=A.setting.occlusionQuery.octree;if(a&&(t=this._octreeRenderNodes.get(e),!t)){let r=new b(a.x,a.y,a.z),i=new b(a.width,a.height,a.depth),n=new ge(r,i);t=new tr(n),this._octreeRenderNodes.set(e,t)}return t}removeRenderNode(e,t){if(t.detachSceneOctree(),t.hasMask(De.Sky))this.sky=null;else if(t.hasMask(De.Reflection)){let a=this._reflections.get(e);if(a){let r=a.indexOf(t);r!=-1&&a.splice(r,1)}}else if(cs.hasMask(t.renderLayer,_i.None)){let a=this.getPashList(e,t);if(a){let r=a.indexOf(t);r!=-1&&a.splice(r,1)}}this._renderShaderCollect.collect_remove(t)}addLight(e,t){if(!this._sceneLights.has(e))this._sceneLights.set(e,[t]);else{let a=this._sceneLights.get(e);if(a.length>=A.setting.light.maxLight){console.warn("Alreay meet maxmium light number:",A.setting.light.maxLight);return}a.indexOf(t)!=-1||a.push(t)}}removeLight(e,t){if(this._sceneLights.has(e)){let a=this._sceneLights.get(e),r=a.indexOf(t);r!=-1&&a.splice(r,1)}}getLights(e){let t=this._sceneLights.get(e);return t||[]}addGIProbe(e,t){this._sceneGIProbes.has(e)?this._sceneGIProbes.get(e).push(t):this._sceneGIProbes.set(e,[t])}removeGIProbe(e,t){if(this._sceneGIProbes.has(e)){let a=this._sceneGIProbes.get(e),r=a.indexOf(t);r!=-1&&a.splice(r,1)}}getProbes(e){let t=this._sceneGIProbes.get(e);return t||[]}getReflections(e){let t=this._reflections.get(e);return t||[]}autoSortRenderNodes(e){let t=this._tr_RenderNodes.get(e);if(!t)return;let a=!1;for(const r of t)if(r.isRenderOrderChange||r.needSortOnCameraZ){a=!0;break}if(a){for(const r of t){let i=r.renderOrder;if(r.needSortOnCameraZ){let n=vc.worldToCameraDepth(r.object3D);n=1-Math.max(0,Math.min(1,n)),i+=n}r.__renderOrder=i,r.isRenderOrderChange=!1}t.sort((r,i)=>r.__renderOrder>i.__renderOrder?1:-1)}return this}getRenderNodes(e,t){if(this.autoSortRenderNodes(e),this._collectInfo.clean(),this._collectInfo.sky=this.sky,A.setting.occlusionQuery.octree)this.rendererOctree=this.getOctree(e),this.rendererOctree.getRenderNode(t.frustum,this._collectInfo);else{let a=this._op_RenderNodes.get(e);a&&(this._collectInfo.opaqueList=a.concat());let r=this._tr_RenderNodes.get(e);r&&(this._collectInfo.transparentList=r.concat())}return this._collectInfo}getOpRenderGroup(e){return this._op_renderGroup.get(e)}getTrRenderGroup(e){return this._tr_renderGroup.get(e)}getGraphicList(){return this._graphics}getRenderShaderCollect(e){return this._renderShaderCollect.renderShaderUpdateList.get(e)}}class xc{renderer;owner;uuid;constructor(e){this.renderer=e,this.uuid=e.object3D.instanceID}leaveNode(){this.owner&&(this.owner.entities.delete(this.uuid),this.owner=null)}enterNode(e){this.owner&&this.leaveNode(),this.owner=e,e.entities.set(this.uuid,this)}update(e){return this.owner?.tryInsertEntity(this)||(this.leaveNode(),e.tryInsertEntity(this)),this.owner}}var Lu=Object.defineProperty,Gu=Object.getOwnPropertyDescriptor,fs=(s,e,t,a)=>{for(var r=Gu(e,t),i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(e,t,r)||r);return r&&Lu(e,t,r),r};class Oa extends Pe{instanceCount=0;lodLevel=0;alwaysRender=!1;instanceID;drawType=0;_geometry;_materials=[];_castShadow=!0;_castReflection=!0;_castGI=!1;_rendererMask=De.Default;_inRenderer=!1;_readyPipeline=!1;_combineShaderRefection;_ignoreEnvMap;_ignorePrefilterMap;__renderOrder=0;_renderOrder=0;_passInit=new Map;isRenderOrderChange;needSortOnCameraZ;isRecievePostEffectUI;_octreeBinder;_renderLayer=_i.None;_computes;init(e){this.renderOrder=0,this.rendererMask=De.Default,this.instanceID=Ln().toString(),this._computes=[]}attachSceneOctree(e){this._octreeBinder={octree:e,entity:new xc(this)},this.transform.eventDispatcher.addEventListener(kt.LOCAL_ONCHANGE,this.updateOctreeEntity,this)}detachSceneOctree(){this._octreeBinder&&(this._octreeBinder.entity?.leaveNode(),this.transform.eventDispatcher.removeEventListener(kt.LOCAL_ONCHANGE,this.updateOctreeEntity,this),this._octreeBinder=null)}updateOctreeEntity(e){this._octreeBinder?.entity?.update(this._octreeBinder.octree)}copyComponent(e){return super.copyComponent(e),this.geometry=e._geometry,this.materials=e._materials.slice(),this.drawType=e.drawType,this.alwaysRender=e.alwaysRender,this.needSortOnCameraZ=e.needSortOnCameraZ,this.isRenderOrderChange=e.isRenderOrderChange,this.castShadow=e.castShadow,this.castGI=e.castGI,this.rendererMask=e.rendererMask,this.isRecievePostEffectUI=e.isRecievePostEffectUI,this}get renderLayer(){return this._renderLayer}set renderLayer(e){this._renderLayer=e}get geometry(){return this._geometry}set geometry(e){this._geometry!=e&&(this._readyPipeline=!1,this._geometry&&me.getInstance().detached(this._geometry,this),e&&me.getInstance().attached(e,this)),this._geometry=e}addMask(e){this._rendererMask=zt.addMask(this.rendererMask,e)}removeMask(e){this._rendererMask=zt.removeMask(this.rendererMask,e)}hasMask(e){return zt.hasMask(this.rendererMask,e)}get rendererMask(){return this._rendererMask}set rendererMask(e){this._rendererMask=e}get renderOrder(){return this._renderOrder}set renderOrder(e){e!=this._renderOrder&&(this.isRenderOrderChange=!0,this.__renderOrder=e),this._renderOrder=e}get materials(){return this._materials}set materials(e){this._readyPipeline=!1;for(let a=0;a<this._materials.length;a++){let r=this._materials[a];me.getInstance().detached(r,this),r.shader&&r.shader.computes&&this.removeComputes(r.shader.computes)}for(let a=0;a<e.length;a++){let r=e[a];me.getInstance().attached(r,this),r.shader&&r.shader.computes&&this.addComputes(r.shader.computes)}this._materials=e;let t=0;for(let a=0;a<e.length;a++){const n=e[a].getPass(H.COLOR)[0];n.shaderState.transparent&&(t=t>n.renderOrder?t:n.renderOrder)}this.renderOrder=t,this._readyPipeline||this.initPipeline()}addComputes(e){this._computes.push(...e)}removeComputes(e){for(const t of e){let a=this._computes.indexOf(t);a!=-1&&this._computes.splice(a,1)}}addRendererMask(e){this._rendererMask=zt.addMask(this._rendererMask,e)}removeRendererMask(e){this._rendererMask=zt.removeMask(this._rendererMask,e)}onEnable(){this._readyPipeline||this.initPipeline(),W.instance.addRenderNode(this.transform.scene3D,this),this.updateOctreeEntity()}onDisable(){this._enable=!1,W.instance.removeRenderNode(this.transform.scene3D,this),super.onDisable?.()}selfCloneMaterials(e){let t=[];for(let a=0,r=this.materials.length;a<r;a++){const i=this.materials[a].clone();t.push(i)}return this.materials=t,this._readyPipeline=!1,this.initPipeline(),this}initPipeline(){if(this._geometry&&this._materials.length>0){for(let t=0;t<this._materials.length;t++){let r=this._materials[t].getPass(H.COLOR);for(let i=0;i<r.length;i++){const n=r[i];n.shaderReflection||n.preCompile(this._geometry),this._geometry.generate(n.shaderReflection)}this.object3D.bound=this._geometry.bounds.clone()}this._readyPipeline=!0;let e=0;for(let t=0;t<this.materials.length;t++){const i=this.materials[t].getPass(H.COLOR)[0];i.renderOrder>=3e3?e=e>i.renderOrder?e:i.renderOrder:e=Math.max(e-3e3,0),this.castNeedPass()}this.renderOrder=e,this.enable&&this.transform&&this.transform.scene3D&&W.instance.addRenderNode(this.transform.scene3D,this)}}castNeedPass(){if(this.castGI)for(let t=0;t<this.materials.length;t++){const a=this.materials[t];Di.createGIPass(this,a.shader)}for(let t=0;t<this.materials.length;t++){const a=this.materials[t];a.castShadow&&Di.createShadowPass(this,a.shader)}if(this.castReflection)for(let t=0;t<this.materials.length;t++){const a=this.materials[t];a.castReflection&&Di.createReflectionPass(this,a.shader)}if(!zt.hasMask(this.rendererMask,De.IgnoreDepthPass)&&A.setting.render.zPrePass)for(let t=0;t<this.materials.length;t++){const a=this.materials[t];Di.createDepthPass(this,a.shader)}else for(let t=0;t<this.materials.length;t++)this.materials[t].shader.removeShaderByIndex(H.DEPTH,0)}get castShadow(){return this._castShadow}set castShadow(e){this._castShadow=e}get castGI(){return this._castGI}set castGI(e){this._castGI=e}get castReflection(){return this._castReflection}set castReflection(e){this._castReflection=e}renderPass(e,t,a){if(!this._geometry)return;let r=this,i=r.transform._worldMatrix;const n=Math.max(r.materials.length,r._geometry.subGeometries.length);for(let o=0;o<n;o++){const l=o>=r.materials.length?r.materials[0]:r.materials[o];if(!l||!l.enable)continue;let c=l.getPass(t);if(!(!c||c.length==0)){S.bindGeometryBuffer(a.encoder,r._geometry),Ze.viewCount_vertex(e,H[t],r._geometry.vertexCount);for(let f=0;f<c.length;f++){if(!c||c.length==0)continue;const u=c[f];if(u.pipeline){u.shaderState.splitTexture&&(a.endRenderPass(),mt.WriteSplitColorTexture(r.instanceID),a.beginOpaqueRenderPass(),S.bindCamera(a.encoder,e.camera),S.bindGeometryBuffer(a.encoder,r._geometry)),S.bindPipeline(a.encoder,u)&&Ze.viewCount_pipeline(e,H[t]);let D=(o>=r._geometry.subGeometries.length?r._geometry.subGeometries[0]:r._geometry.subGeometries[o]).lodLevels[r.lodLevel];r.instanceCount>0?(Ze.viewCount_instance(e,H[t],r.instanceCount),Ze.viewCount_indices(e,H[t],D.indexCount),Ze.viewCount_tri(e,H[t],D.indexCount/3*r.instanceCount),S.drawIndexed(a.encoder,D.indexCount,r.instanceCount,D.indexStart,0,0)):(Ze.viewCount_indices(e,H[t],D.indexCount),Ze.viewCount_tri(e,H[t],D.indexCount/3),S.drawIndexed(a.encoder,D.indexCount,1,D.indexStart,0,i.index)),Ze.viewCount_draw(e,H[t])}}}}}renderPass2(e,t,a,r,i,n=!1){if(!this.enable||!this._geometry)return;let o=this,l=o.object3D.transform._worldMatrix;for(let c=0;c<this.materials.length;c++){const f=this.materials[c];if(!f.castShadow&&t==H.SHADOW)continue;let h=f.getPass(t);if(!h||h.length==0)return;if(this.drawType==2)for(let u of h)u.pipeline&&(S.bindPipeline(i,u),S.draw(i,6,1,0,l.index));else{S.bindGeometryBuffer(i,o._geometry);for(let u of h)if(u.pipeline){S.bindPipeline(i,u);let D=o._geometry.subGeometries[c].lodLevels[o.lodLevel];S.drawIndexed(i,D.indexCount,1,D.indexStart,0,l.index)}}}}recordRenderPass2(e,t,a,r,i,n=!1){if(!this.enable)return;let o=this;for(let l=0;l<this.materials.length;l++){let f=this.materials[l].getPass(t);if(!f||f.length==0)return;let h=o.object3D.transform._worldMatrix;for(let u=0;u<f.length;u++){const g=f[u];S.bindPipeline(i,g);let _=o._geometry.subGeometries[l].lodLevels[o.lodLevel];S.drawIndexed(i,_.indexCount,1,_.indexStart,0,h.index)}}}noticeShaderChange(){this.enable&&(this.onEnable(),this._passInit.forEach((e,t)=>{this._passInit.set(t,!1)}))}preInit(e){return this._passInit.get(e)}nodeUpdate(e,t,a,r){let i=this,n=e.scene.envMap;for(let o=0;o<i.materials.length;o++){let c=i.materials[o].getPass(t);if(c)for(let f=0;f<c.length;f++){const u=c[f];if(u.shaderState.splitTexture){let v=mt.CreateSplitTexture(i.instanceID);u.setTexture("splitTexture_Map",v)}!i._ignoreEnvMap&&u.envMap!=n&&u.setTexture("envMap",n),u.prefilterMap||u.setTexture("prefilterMap",n);let g=le.getReflectionEntries(e.scene);if(!u.reflectionMap&&g&&g.reflectionMap&&(u.setTexture("reflectionMap",g.reflectionMap),u.setStorageBuffer("reflectionBuffer",g.storageGPUBuffer)),u.pipeline){u.apply(i._geometry,a,()=>i.noticeShaderChange());continue}let p=A.res.getTexture("BRDFLUT");u.setTexture("brdflutMap",p);let m=A.getRenderJob(e).shadowMapPassRenderer;m&&m.depth2DArrayTexture&&u.setTexture("shadowMap",A.getRenderJob(e).shadowMapPassRenderer.depth2DArrayTexture);let D=A.getRenderJob(e).pointLightShadowRenderer;D&&D.cubeArrayTexture&&u.setTexture("pointShadowMap",D.cubeArrayTexture);let _=ra.iesTexture;_&&u.setTexture("iesTextureArrayMap",_),a.irradianceBuffer&&a.irradianceBuffer.length>0&&(u.setTexture("irradianceMap",a.irradianceBuffer[0]),u.setTexture("irradianceDepthMap",a.irradianceBuffer[1]));let B=le.getLightEntries(e.scene);B&&(u.setStorageBuffer("lightBuffer",B.storageGPUBuffer),B.irradianceVolume&&u.setUniformBuffer("irradianceData",B.irradianceVolume.irradianceVolumeBuffer)),r&&(u.setStorageBuffer("clustersUniform",r.clustersUniformBuffer),u.setStorageBuffer("lightAssignBuffer",r.lightAssignBuffer),u.setStorageBuffer("assignTable",r.assignTableBuffer),u.setStorageBuffer("clusterBuffer",r.clusterBuffer)),u.apply(i._geometry,a),this._passInit.set(t,!0)}}}beforeDestroy(e){this._geometry&&(me.getInstance().detached(this._geometry,this),me.getInstance().hasReference(this._geometry)||this._geometry.destroy(e));for(let t=0;t<this._materials.length;t++){const a=this._materials[t];a&&(me.getInstance().detached(a,this),me.getInstance().hasReference(a)||a.destroy(e))}this._computes&&(this._computes.length=0),this.detachSceneOctree(),super.beforeDestroy(e)}destroy(e){super.destroy(e),this._geometry=void 0,this._materials.length=0,this._computes=null,this._passInit&&(this._passInit.clear(),this._passInit=null),this._combineShaderRefection=void 0}}fs([zr],Oa.prototype,"materials"),fs([zr],Oa.prototype,"castShadow"),fs([zr],Oa.prototype,"castGI");class ut{instanceID;name;enable=!0;_defaultSubShader;_shader;_isDestroyed=!1;constructor(){this.instanceID=xt()}set shader(e){this._shader=e,this._defaultSubShader=e.getDefaultShaders()[0]}get shader(){return this._shader}get doubleSide(){return this._defaultSubShader.doubleSide}set doubleSide(e){this._defaultSubShader.doubleSide=e}get castShadow(){return this._defaultSubShader.shaderState.castShadow}set castShadow(e){let t=this._defaultSubShader.shaderState;e!=t.castShadow&&(t.castShadow=e)}get acceptShadow(){return this._defaultSubShader.shaderState.acceptShadow}set acceptShadow(e){let t=this._defaultSubShader.shaderState;t.acceptShadow!=e&&(t.acceptShadow=e,this._defaultSubShader.noticeShaderChange(),this._defaultSubShader.noticeValueChange())}get castReflection(){return this._defaultSubShader.shaderState.castReflection}set castReflection(e){this._defaultSubShader.shaderState.castReflection=e}get blendMode(){return this._defaultSubShader.blendMode}set blendMode(e){this._defaultSubShader.blendMode=e}get depthCompare(){return this._defaultSubShader.depthCompare}set depthCompare(e){this._defaultSubShader.depthCompare=e;for(let t of this._shader.passShader.values())for(let a of t)a.depthCompare=e}get transparent(){return this._defaultSubShader.shaderState.transparent}set transparent(e){this._defaultSubShader.shaderState.transparent=e,e&&(this._defaultSubShader.renderOrder=3e3)}get cullMode(){return this._defaultSubShader.cullMode}set cullMode(e){if(this._defaultSubShader.cullMode!=e){for(let t of this._shader.passShader.values())for(let a of t)a.cullMode=e;this._defaultSubShader.cullMode=e}}get depthWriteEnabled(){return this._defaultSubShader.depthWriteEnabled}set depthWriteEnabled(e){this._defaultSubShader.depthWriteEnabled=e}set useBillboard(e){this._defaultSubShader.setDefine("USE_BILLBOARD",e)}get topology(){return this._defaultSubShader.topology}set topology(e){this._defaultSubShader.topology=e}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}getPass(e){return this._shader.getSubShaders(e)}getAllPass(){return this._shader.getSubShaders(H.COLOR)}clone(){let e=new ut;return e.shader=this.shader.clone(),e}destroy(e){this._isDestroyed||(this.name=null,this.instanceID=null,this._shader&&(this._shader.destroy(e),this._shader=null),this._defaultSubShader=null,this._isDestroyed=!0)}setDefine(e,t){this.shader.setDefine(e,t)}setTexture(e,t){this._shader.setTexture(e,t)}setStorageBuffer(e,t){this._shader.setStorageBuffer(e,t)}setUniformBuffer(e,t){this._shader.setStorageBuffer(e,t)}setUniformFloat(e,t){this._shader.setUniformFloat(e,t)}setUniformVector2(e,t){this._shader.setUniformVector2(e,t)}setUniformVector3(e,t){this._shader.setUniformVector3(e,t)}setUniformVector4(e,t){this._shader.setUniformVector4(e,t)}setUniformColor(e,t){this._shader.setUniformColor(e,t)}getUniformFloat(e){return this._shader.getUniform(e).data}getUniformV2(e){return this._shader.getUniformVector2(e)}getUniformV3(e){return this._shader.getUniformVector3(e)}getUniformV4(e){return this._shader.getUniformVector4(e)}getUniformColor(e){return this._shader.getUniformColor(e)}getTexture(e){return this._shader.getTexture(e)}getStorageBuffer(e){return this._shader.getStorageBuffer(e)}getStructStorageBuffer(e){return this._shader.getStructStorageBuffer(e)}getUniformBuffer(e){return this._shader.getUniformBuffer(e)}applyUniform(){this._shader.applyUniform()}}const Fc=`
5746
5746
  #include "GlobalUniform"
5747
5747
 
5748
5748
  // Constants
@@ -5992,7 +5992,7 @@ struct InstanceData {
5992
5992
  o.color = evalSplat(vTexCoord, vColor);
5993
5993
  return o;
5994
5994
  }
5995
- `;class it{computes;passShader;constructor(){this.computes=[],this.passShader=new Map}addRenderPass(e,t=-1){let a=this.passShader.get(e.passType)||[];t==-1?a.push(e):a.splice(t,-1,e),this.passShader.set(e.passType,a)}removeShader(e,t=-1){let a=this.passShader.get(e.passType);if(a)if(t==-1){let r=a.indexOf(e);r!=-1&&a.splice(r)}else a.splice(t,1)}removeShaderByIndex(e,t=-1){let a=this.passShader.get(e);a&&(t==-1?this.passShader.delete(e):a.splice(t,1))}getSubShaders(e){return this.passShader.get(e)||[]}hasSubShaders(e){return this.passShader.get(e).length>0}getDefaultShaders(){return this.passShader.get(H.COLOR)}getDefaultColorShader(){return this.passShader.get(H.COLOR)[0]}setDefine(e,t){for(const a of this.passShader)for(const r of a[1])r.setDefine(e,t)}hasDefine(e){for(const t of this.passShader)for(const a of t[1]){let r=a.hasDefine(e);if(r)return r}return!1}deleteDefine(e){for(const t of this.passShader)for(const a of t[1])a.deleteDefine(e)}setUniform(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniform(e,t)}setUniformFloat(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformFloat(e,t)}setUniformVector2(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformVector2(e,t)}setUniformVector3(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformVector3(e,t)}setUniformVector4(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformVector4(e,t)}setUniformColor(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformColor(e,t)}getUniform(e){return this.getDefaultColorShader().getUniform(e)}getUniformFloat(e){return this.getDefaultColorShader().getUniformFloat(e)}getUniformVector2(e){return this.getDefaultColorShader().getUniformVector2(e)}getUniformVector3(e){return this.getDefaultColorShader().getUniformVector3(e)}getUniformVector4(e){return this.getDefaultColorShader().getUniformVector4(e)}getUniformColor(e){return this.getDefaultColorShader().getUniformColor(e)}setTexture(e,t){for(const a of this.passShader)for(const r of a[1])r.setTexture(e,t);this.setDefine(`USE_${e.toLocaleUpperCase()}`,!0)}getTexture(e){return this.getDefaultColorShader().textures[e]}setUniformBuffer(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformBuffer(e,t)}getUniformBuffer(e){return this.getDefaultColorShader().getBuffer(e)}setStorageBuffer(e,t){for(const a of this.passShader)for(const r of a[1])r.setStorageBuffer(e,t)}getStorageBuffer(e){return this.getDefaultColorShader().getBuffer(e)}setStructStorageBuffer(e,t){for(const a of this.passShader)for(const r of a[1])r.setStructStorageBuffer(e,t)}getStructStorageBuffer(e){return this.getDefaultColorShader().getBuffer(e)}noticeValueChange(){for(const e of this.passShader)for(const t of e[1])t.noticeValueChange()}destroy(){this.getDefaultColorShader().destroy()}clone(){let e=new it,t=this.getDefaultShaders();for(const a of t)e.addRenderPass(a);return e}applyUniform(){for(const e of this.passShader)for(const t of e[1])t.applyUniform()}}var zu=Object.getOwnPropertyDescriptor,Ju=(s,e,t,a)=>{for(var r=a>1?void 0:a?zu(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.GSplatShader=class extends it{constructor(){super();const e=new Ne("gsplat_vs_dc","gsplat_fs_dc");e.passType=H.COLOR,e.setShaderEntry("VertMain","FragMain"),e.topology=zn.triangle_list,e.depthWriteEnabled=!1,e.cullMode=Ft.none,e.shaderState.transparent=!0,e.shaderState.blendMode=te.NORMAL,e.shaderState.writeMasks=[15,15],e.shaderState.castReflection=!1,this.addRenderPass(e),this.setDefault()}setDefault(){const e=this.getDefaultColorShader(),t=new R;e.setUniform("modelMatrix",t.rawData),e.setUniform("pixelCull",new Float32Array([2,0,0,0]))}},d.GSplatShader=Ju([Qa(d.GSplatShader,"GSplatShader")],d.GSplatShader);class Ec extends ut{_pixelCullArray=new Float32Array(4);constructor(){super(),J.register("gsplat_vs_dc",Fc),J.register("gsplat_fs_dc",kc),this.shader=new d.GSplatShader}setSplatTextures(e,t,a,r,i){const n=this.shader.getDefaultColorShader();n.setTexture("splatColor",e),n.setTexture("transformA",t),n.setTexture("transformB",a),n.setUniformArray("tex_params",r),i&&n.setTexture("splatOrder",i),n.shaderState.depthCompare=$e.less}setTransformMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}setPixelCulling(e,t,a=0,r=128){this._pixelCullArray[0]=e,this._pixelCullArray[1]=t,this._pixelCullArray[2]=a,this._pixelCullArray[3]=r,this.shader.getDefaultColorShader().setUniform("pixelCull",this._pixelCullArray)}}class ln extends Ta{node;constructor(e){super(),this.bufferType=ea.VertexGPUBuffer,this.createVertexBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,e)}createVertexBuffer(e,t){let a=E.device;this.byteSize=t*Float32Array.BYTES_PER_ELEMENT,this.usage=e,this.buffer&&this.destroy(),this.buffer=a.createBuffer({label:"VertexGPUBuffer",size:this.byteSize,usage:e,mappedAtCreation:!1}),this.memory=new Xa,this.memoryNodes=new Map,this.memory.allocation(this.byteSize),this.node=this.memory.allocation_node(this.byteSize)}}var bt=(s=>(s[s.split=0]="split",s[s.compose=1]="compose",s[s.compose_bin=2]="compose_bin",s))(bt||{});class Rc{vertexCount=0;vertexGPUBuffer;geometryType=bt.compose;_vertexBufferLayouts;_attributeSlotLayouts;_attributeLocation;constructor(){this._vertexBufferLayouts=[],this._attributeLocation={},this._attributeSlotLayouts=[]}get vertexBufferLayouts(){return this._vertexBufferLayouts}createVertexBuffer(e,t){switch(this.geometryType){case bt.split:this.createSplitVertexBuffer(e,t);break;case bt.compose:this.createComposeVertexBuffer(e,t);break;case bt.compose_bin:this.createComposBinVertexBuffer(e,t);break}}createSplitVertexBuffer(e,t){let a=0;for(let r=0;r<t.attributes.length;r++){const i=t.attributes[r];if(i.name=="index")continue;this._attributeLocation[i.name]=i.location;let n={name:i.name,format:i.format,offset:0,shaderLocation:i.location,stride:Ka[i.format]};this._attributeSlotLayouts[i.location]=[n];let o=e.get(i.name);o||(o={attribute:i.name,data:new Float32Array(i.size*this.vertexCount)},e.set(i.name,o));let l=o.data.length/n.stride;this.vertexCount!=0&&this.vertexCount!=l&&console.error(" vertex count not match attribute count"),this.vertexCount=l,this._vertexBufferLayouts[i.location]={name:i.name,arrayStride:i.size*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[i.location],offset:a*4,size:this.vertexCount*i.size*4},a+=this.vertexCount*i.size}this.vertexGPUBuffer=new ln(a)}createComposeVertexBuffer(e,t){this._attributeSlotLayouts[0]=[];let a=0;for(let r=0;r<t.attributes.length;r++){const i=t.attributes[r];if(i.name=="index"||i.type=="builtin")continue;this._attributeLocation[i.name]=i.location;let n={name:i.name,format:i.format,offset:a*4,shaderLocation:i.location,stride:Ka[i.format]};this._attributeSlotLayouts[0][i.location]=n;let o=e.get(i.name);if(o||(o={attribute:i.name,data:new Float32Array(i.size*this.vertexCount)},e.set(i.name,o)),o.data){let l=o.data.length/n.stride;this.vertexCount!=0&&this.vertexCount!=l&&console.error(" vertex count not match attribute count"),this.vertexCount=l}a+=i.size}this._vertexBufferLayouts[0]={name:"composeStruct",arrayStride:a*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[0],offset:0,size:this.vertexCount*a*4},this.vertexGPUBuffer=new ln(this.vertexCount*a)}createComposBinVertexBuffer(e,t){this._attributeSlotLayouts[0]=[];let a=0;for(let n=0;n<t.attributes.length;n++){const o=t.attributes[n];if(o.name=="index"||o.type=="builtin")continue;this._attributeLocation[o.name]=o.location;let l={name:o.name,format:o.format,offset:a*4,shaderLocation:o.location,stride:Ka[o.format]};this._attributeSlotLayouts[0][o.location]=l;let c=e.get(o.name);if(c||(c={attribute:o.name,data:new Float32Array(o.size*this.vertexCount)},e.set(o.name,c)),c.data){let f=c.data.length/l.stride;this.vertexCount!=0&&this.vertexCount!=f&&console.error(" vertex count not match attribute count"),this.vertexCount=f}a+=o.size}let i=e.get(V.all).data.length/a;this.vertexCount=i,this._vertexBufferLayouts[0]={name:"composeStruct",arrayStride:a*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[0],offset:0,size:this.vertexCount*a*4},this.vertexGPUBuffer=new ln(this.vertexCount*a)}upload(e,t){if(this.vertexGPUBuffer){switch(this.geometryType){case bt.split:{let a=this._attributeLocation[e],r=this._vertexBufferLayouts[a];this.vertexGPUBuffer.node.setFloat32Array(r.offset/4,t.data)}break;case bt.compose:for(let a=0;a<this.vertexCount;a++){const r=this._attributeSlotLayouts[0][this._attributeLocation[e]];for(let i=0;i<r.stride;i++){let n=t.data[a*r.stride+i],o=a*(this._vertexBufferLayouts[0].arrayStride/4)+r.offset/4+i;this.vertexGPUBuffer.node.setFloat(n,o)}}break;case bt.compose_bin:this.vertexGPUBuffer.node.setFloat32Array(0,t.data);break}this.vertexGPUBuffer?.apply()}}updateAttributes(e){switch(this.geometryType){case bt.split:for(let t=0;t<this._vertexBufferLayouts.length;t++){const a=this._vertexBufferLayouts[t];let r=e.get(a.name);this.vertexGPUBuffer.node.setFloat32Array(a.offset/4,r.data)}break;case bt.compose:for(let t=0;t<this.vertexCount;t++)this._attributeSlotLayouts.forEach(a=>{for(let r=0;r<a.length;r++){const i=a[r];let n=e.get(i.name);for(let o=0;o<i.stride;o++){let l=n.data[t*i.stride+o],c=t*(this._vertexBufferLayouts[0].arrayStride/4)+i.offset/4+o;this.vertexGPUBuffer.node.setFloat(l,c)}}});break;case bt.compose_bin:{let t=e.get(V.all);this.vertexGPUBuffer.node.setFloat32Array(0,t.data)}break}this.vertexGPUBuffer.apply()}compute(){}destroy(e){this.vertexCount=null,this.geometryType=null,this._vertexBufferLayouts=null,this._attributeSlotLayouts=null,this._attributeLocation=null,this.vertexGPUBuffer&&this.vertexGPUBuffer.destroy(e),this.vertexGPUBuffer=null}}class wc extends Ta{indicesNode;constructor(e){super(),this.bufferType=ea.IndicesGPUBuffer,this.createIndicesBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.INDEX|GPUBufferUsage.INDIRECT,e)}createIndicesBuffer(e,t){let a=E.device;if(this.byteSize=t.length*4,this.usage=e,this.buffer&&this.destroy(),this.buffer=a.createBuffer({label:"IndicesGPUBuffer",size:this.byteSize,usage:e,mappedAtCreation:!1}),this.memory=new Xa,this.memoryNodes=new Map,this.memory.allocation(this.byteSize),t){this.indicesNode=this.memory.allocation_node(t.length*4);const r=t.buffer instanceof ArrayBuffer?t.buffer:new Uint8Array(t.buffer).buffer;this.indicesNode.setArrayBuffer(0,r),this.apply()}}}class Ic{uuid="";name;indicesGPUBuffer;indicesFormat="uint16";indicesCount=0;constructor(){}createIndicesBuffer(e){e.data instanceof Uint16Array?this.indicesFormat="uint16":e.data instanceof Uint32Array&&(this.indicesFormat="uint32"),this.indicesCount=e.data.length,this.indicesGPUBuffer=new wc(e.data)}upload(e){this.indicesGPUBuffer.indicesNode.setArrayBuffer(0,e),this.indicesGPUBuffer.apply()}compute(){}destroy(){this.uuid=null,this.name=null,this.indicesFormat=null,this.indicesCount=null,this.indicesGPUBuffer.destroy(),this.indicesGPUBuffer=null}}class Qc{lodLevels}class Fe{instanceID;name;subGeometries=[];morphTargetsRelative;morphTargetDictionary;skinNames;bindPose;blendShapeData;vertexDim;vertexCount=0;_bounds;_attributeMap;_attributes;_indicesBuffer;_vertexBuffer;_onChange=!0;_wireframeLines;constructor(){this.instanceID=xt(),this._attributeMap=new Map,this._attributes=[],this._vertexBuffer=new Rc}get indicesBuffer(){return this._indicesBuffer}get vertexBuffer(){return this._vertexBuffer}get vertexAttributes(){return this._attributes}get vertexAttributeMap(){return this._attributeMap}get geometryType(){return this._vertexBuffer.geometryType}set geometryType(e){this._vertexBuffer.geometryType=e}get bounds(){if(!this._bounds){this._bounds=new ge(new b,new b(1,1,1)),this._bounds.min.x=Number.MAX_VALUE,this._bounds.min.y=Number.MAX_VALUE,this._bounds.min.z=Number.MAX_VALUE,this._bounds.max.x=-Number.MAX_VALUE,this._bounds.max.y=-Number.MAX_VALUE,this._bounds.max.z=-Number.MAX_VALUE;let e=this.getAttribute(V.position);if(e&&e.data)for(let t=0;t<e.data.length/3;t++){const a=e.data[t*3+0],r=e.data[t*3+1],i=e.data[t*3+2];this._bounds.min.x>a&&(this._bounds.min.x=a),this._bounds.min.y>r&&(this._bounds.min.y=r),this._bounds.min.z>i&&(this._bounds.min.z=i),this._bounds.max.x<a&&(this._bounds.max.x=a),this._bounds.max.y<r&&(this._bounds.max.y=r),this._bounds.max.z<i&&(this._bounds.max.z=i)}this._bounds.setFromMinMax(this._bounds.min,this._bounds.max)}return this._bounds}set bounds(e){this._bounds=e}addSubGeometry(...e){let t=new Qc;return t.lodLevels=e,this.subGeometries.push(t),t}generate(e){this._onChange&&(this._onChange=!1,this._indicesBuffer.upload(this.getAttribute(V.indices).data),this._vertexBuffer.createVertexBuffer(this._attributeMap,e),this._vertexBuffer.updateAttributes(this._attributeMap),this.vertexCount=this._vertexBuffer.vertexCount)}setIndices(e){if(!this._attributeMap.has(V.indices)){let t={attribute:V.indices,data:e};this._attributeMap.set(V.indices,t),this._indicesBuffer=new Ic,this._indicesBuffer.createIndicesBuffer(t)}}setAttribute(e,t){if(e==V.indices)this.setIndices(t);else{let a={attribute:e,data:t};this._attributeMap.set(e,a),this._attributes.push(e)}}getAttribute(e){return this._attributeMap.get(e)}hasAttribute(e){return this._attributeMap.has(e)}genWireframe(){if(this._wireframeLines)return this._wireframeLines;if(this.geometryType==bt.split||this.geometryType==bt.compose){let e=this.getAttribute(V.position),t=this.getAttribute(V.indices);if(t&&e&&t.data.length>0){let a=e.data,r=[];for(let i=0;i<t.data.length/3;i++){const n=t.data[i*3+0],o=t.data[i*3+1],l=t.data[i*3+2];let c=new b(a[n*3+0],a[n*3+1],a[n*3+2]),f=new b(a[o*3+0],a[o*3+1],a[o*3+2]),h=new b(a[l*3+0],a[l*3+1],a[l*3+2]);r.push(c,f),r.push(f,h),r.push(h,c)}return this._wireframeLines=r,r}}else if(this.geometryType==bt.compose_bin){let e=this.getAttribute(V.all),t=this.vertexDim,a=this.getAttribute(V.indices);if(a&&e&&a.data.length>0){let r=e.data,i=[];for(let n=0;n<a.data.length/3;n++){const o=a.data[n*3+0],l=a.data[n*3+1],c=a.data[n*3+2];let f=new b(r[o*t+0],r[o*t+1],r[o*t+2]),h=new b(r[l*t+0],r[l*t+1],r[l*t+2]),u=new b(r[c*t+0],r[c*t+1],r[c*t+2]);i.push(f,h),i.push(h,u),i.push(u,f)}return this._wireframeLines=i,i}}return null}compute(){this._indicesBuffer&&this._indicesBuffer.compute(),this._vertexBuffer&&this._vertexBuffer.compute()}static crossA=b.UP.clone();static crossB=b.UP.clone();static crossRet=b.UP.clone();static point1=b.UP.clone();static point2=b.UP.clone();static point3=b.UP.clone();computeNormals(){let e=this.getAttribute(V.position),t=this.getAttribute(V.normal),a=this.getAttribute(V.indices);if(!e||!t||!a)return this;let r=a.data.length/3,i=Fe.point1,n=Fe.point2,o=Fe.point3,l=Fe.crossA,c=Fe.crossB,f=Fe.crossRet;for(let h=0;h<r;h++){let u=a.data[h*3],g=a.data[h*3+1],p=a.data[h*3+2];i.set(e.data[u*3],e.data[u*3+1],e.data[u*3+2]),n.set(e.data[g*3],e.data[g*3+1],e.data[g*3+2]),o.set(e.data[p*3],e.data[p*3+1],e.data[p*3+2]),b.sub(i,n,l).normalize(),b.sub(i,o,c).normalize();let m=l.crossProduct(c,f).normalize();t.data[u*3]=t.data[g*3]=t.data[p*3]=m.x,t.data[u*3+1]=t.data[g*3+1]=t.data[p*3+1]=m.y,t.data[u*3+2]=t.data[g*3+2]=t.data[p*3+2]=m.z}return this._vertexBuffer.upload(V.normal,t),this}isPrimitive(){return!1}destroy(e){this.instanceID=null,this.name=null,this.subGeometries=null,this.morphTargetDictionary=null,this._bounds.destroy(),this._bounds=null,this._attributeMap=null,this._attributes=null,this._indicesBuffer.destroy(),this._vertexBuffer.destroy(),this._indicesBuffer=null,this._vertexBuffer=null}}class Tc extends Fe{batchSize;constructor(e=128){super(),this.batchSize=e;const t=new Float32Array(12*e);for(let r=0;r<e;++r)t.set([-2,-2,r,2,-2,r,2,2,r,-2,2,r],r*12);const a=new Uint32Array(6*e);for(let r=0;r<e;++r){const i=r*4;a.set([0+i,1+i,2+i,0+i,2+i,3+i],r*6)}this.setAttribute(V.position,t),this.setIndices(a),this.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:t.length/3,firstStart:0,index:0,topology:0})}}class ds extends Xe{_dataBuffer;create(e,t,a,r=!1){let i=E.device;const n=Math.ceil(e*4/256)*256;this.format=Y.rgba8unorm,this.mipmapCount=Math.floor(r?Math.log2(e):1),this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const o=this._dataBuffer=i.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(o,0,a);const l=S.beginCommandEncoder();return l.copyBufferToTexture({buffer:o,bytesPerRow:n},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(l),r&&aa.webGPUGenerateMipmap(this),this}updateTexture(e,t,a){let r=E.device;const i=Math.ceil(e*4/256)*256;this.mipmapCount=Math.floor(Math.log2(e)),this._dataBuffer&&this._dataBuffer.destroy(),this._dataBuffer=null;const n=this._dataBuffer=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(n,0,a);const o=S.beginCommandEncoder();o.copyBufferToTexture({buffer:n,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(o),this.gpuSampler=r.createSampler(this),this.mipmapCount>1&&aa.webGPUGenerateMipmap(this)}}class Mc extends Xe{_dataBuffer;create(e,t,a){let r=E.device;const i=e*4*4;this.format=Y.rgba32uint,this.createTextureDescriptor(e,t,1,this.format);const o=this._dataBuffer=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,a.buffer);const l=r.createCommandEncoder();return l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),r.queue.submit([l.finish()]),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="uint",this.gpuSampler=r.createSampler({}),this}updateTexture(e,t,a){let r=E.device;const i=e*4*4;r.queue.writeTexture({texture:this.getGPUTexture()},a.buffer,{bytesPerRow:i},{width:e,height:t,depthOrArrayLayers:1})}}class Nc extends Xe{_dataBuffer;create(e,t,a){let r=E.device;const i=e*4;this.format=Y.r32uint,this.createTextureDescriptor(e,t,1,this.format);const o=this._dataBuffer=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,a.buffer);const l=r.createCommandEncoder();return l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),r.queue.submit([l.finish()]),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="uint",this.gpuSampler=r.createSampler({}),this}updateTexture(e,t,a){let r=E.device;const i=e*4;r.queue.writeTexture({texture:this.getGPUTexture()},a.buffer,{bytesPerRow:i},{width:e,height:t,depthOrArrayLayers:1})}}const Pc=new Float32Array(1),Wu=new Int32Array(Pc.buffer);let ar=function(s){Pc[0]=s;const e=Wu[0];let t=e>>16&32768,a=e>>12&2047;const r=e>>23&255;return r<103?t:r>142?(t|=31744,t|=(r==255?1:0)&&e&8388607,t):r<114?(a|=2048,t|=(a>>114-r)+(a>>113-r&1),t):(t|=r-112<<10|a>>1,t+=a&1,t)};class hs extends Xe{uint16Array;floatArray;_dataBuffer;create(e,t,a=null,r=!0){if(a==null){a=[];for(let i=0,n=e*t*4;i<n;i++)a[i]=0}return this.updateTexture(e,t,a,r),this}updateTexture(e,t,a,r=!0){(e!=this.width||t!=this.height)&&(this._dataBuffer&&this._dataBuffer.destroy(),this._dataBuffer=null,this.gpuTexture&&this.gpuTexture.destroy(),this.gpuTexture=null),this.floatArray=a;let i=E.device;const n=e*4*2;this.format=Y.rgba16float,this.mipmapCount=Math.floor(r?Math.log2(e):1),this.createTextureDescriptor(e,t,this.mipmapCount,this.format),(!this.uint16Array||this.uint16Array.length!=a.length)&&(this.uint16Array=new Uint16Array(a.length));let o=this.uint16Array;for(let f=0,h=o.length;f<h;f++)o[f]=ar(a[f]);const l=this._dataBuffer=i.createBuffer({size:o.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(l,0,o);const c=S.beginCommandEncoder();c.copyBufferToTexture({buffer:l,bytesPerRow:n},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),this.useMipmap||(this.samplerBindingLayout.type="filtering",this.textureBindingLayout.sampleType="float"),S.endCommandEncoder(c),this.gpuSampler=i.createSampler(this),this.gpuTexture=this.getGPUTexture(),this.mipmapCount>1&&aa.webGPUGenerateMipmap(this)}}var ju=Object.getOwnPropertyDescriptor,Zu=(s,e,t,a)=>{for(var r=a>1?void 0:a?ju(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.GSplatRenderer=class extends Oa{count=0;size=new K;splatColor;transformA;transformB;texParams;splatOrder;gsplatMaterial;_positions;get positions(){return this._positions}_worldPositions;_orderData;_sortWorker;_lastSentTime=0;_minIntervalMs=16;_centersSent=!1;_lastViewMatrixHash=0;_lastCameraSpeed=0;_adaptiveSorting=!0;_lastPixelCullParams="";_texturesInitialized=!1;_lodEnabled=!1;_lodDistances=[5,10,20,40];_lodRatios=[1,.75,.5,.25,.1];_currentLodLevel=0;_minPixelCoverage=4;_maxPixelCoverage=0;_maxPixelCullDistance=0;_mapping=null;_fullCount=0;get fullCount(){return this._fullCount}_batchSize=128;instanceCount=0;constructor(){super()}initAsset(e){this.count=e.count,this._fullCount=e.count,this.size=this.evalTextureSize(e.count),this.buildColor(e),this.buildTransform(e),this.texParams=new Float32Array([this.count,this.size.x,this.count,1]),this._positions=e.position;const t=this.size.x*this.size.y;this._orderData=new Uint32Array(t);for(let a=0;a<t;a++)this._orderData[a]=a<this.count?a:this.count>0?this.count-1:0;this.splatOrder=new Nc().create(this.size.x,this.size.y,this._orderData),this.splatOrder.name="splatOrder",this.splatOrder.minFilter="nearest",this.splatOrder.magFilter="nearest",this.splatOrder.addressModeU="clamp-to-edge",this.splatOrder.addressModeV="clamp-to-edge",this.gsplatMaterial=new Ec,this.geometry=new Tc(this._batchSize),this.materials=[this.gsplatMaterial],this.instanceCount=0}onBeforeUpdate(e){this.count>0&&e?.camera&&(this._lodEnabled&&this.updateLOD(e),e.camera.viewMatrix&&this.scheduleOrder(e.camera.viewMatrix))}updateLOD(e){if(!this._worldPositions||this._fullCount===0)return;const a=e.camera.viewMatrix.rawData,r=-(a[0]*a[12]+a[1]*a[13]+a[2]*a[14]),i=-(a[4]*a[12]+a[5]*a[13]+a[6]*a[14]),n=-(a[8]*a[12]+a[9]*a[13]+a[10]*a[14]);let o=0,l=0,c=0;const f=Math.min(100,this._fullCount);for(let D=0;D<f;D++){const _=Math.floor(D/f*this._fullCount)*3;o+=this._worldPositions[_+0],l+=this._worldPositions[_+1],c+=this._worldPositions[_+2]}o/=f,l/=f,c/=f;const h=r-o,u=i-l,g=n-c,p=Math.sqrt(h*h+u*u+g*g);let m=this._lodDistances.length;for(let D=0;D<this._lodDistances.length;D++)if(p<this._lodDistances[D]){m=D;break}if(m!==this._currentLodLevel){this._currentLodLevel=m;const D=this._lodRatios[m],_=Math.floor(this._fullCount*D);if(this._mapping){const B=this._mapping;this._mapping=new Uint32Array(Math.min(_,B.length));for(let v=0;v<this._mapping.length;v++)this._mapping[v]=B[v];this.setMapping(this._mapping)}else this.count=_,this.texParams[0]=this.count,this.texParams[2]=this.count}}setMapping(e){this._mapping=e&&e.length>0?e:null,this.count=this._mapping?this._mapping.length:this._fullCount,this.texParams[0]=this.count,this.texParams[2]=Math.min(this.texParams[0],this.count);const t=this.size.x*this.size.y;for(let a=0;a<t;a++)this._orderData[a]=a<this.count?a:this.count>0?this.count-1:0;if(this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData),this._sortWorker){const a=this._worldPositions||this._positions,r=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(a);if(this._mapping)for(let i=0;i<this._mapping.length;++i){const n=this._mapping[i]*3,o=i*3;r[o+0]=a[n+0],r[o+1]=a[n+1],r[o+2]=a[n+2]}this._sortWorker.postMessage({type:"centers",centers:r.buffer,mapping:this._mapping?this._mapping:null},[r.buffer]),this._centersSent=!0}else this._centersSent=!1;this.instanceCount=0}setVisBoost(e){this.texParams[3]=Math.max(0,e)}setSortThrottle(e){this._minIntervalMs=Math.max(0,e|0)}setAdaptiveSorting(e){this._adaptiveSorting=e}setLOD(e,t,a){this._lodEnabled=e,t&&(this._lodDistances=t),a&&(this._lodRatios=a)}getLODStats(){return{enabled:this._lodEnabled,currentLevel:this._currentLodLevel,distances:this._lodDistances,ratios:this._lodRatios,currentRatio:this._lodRatios[this._currentLodLevel],visibleCount:this._lodEnabled?Math.floor(this._fullCount*this._lodRatios[this._currentLodLevel]):this._fullCount}}setPixelCulling(e,t=0,a=0){this._minPixelCoverage=Math.max(0,e),this._maxPixelCoverage=Math.max(0,t),this._maxPixelCullDistance=Math.max(0,a)}getPixelCullingStats(){return{minPixels:this._minPixelCoverage,maxPixels:this._maxPixelCoverage,maxPixelCullDistance:this._maxPixelCullDistance,maxEnabled:this._maxPixelCoverage>0,distanceEnabled:this._maxPixelCullDistance>0}}getBatchingStats(){return{enabled:!0,batchSize:this._batchSize,instanceCount:this.instanceCount,splatCount:this.count,reduction:this.count>0?(1-this.instanceCount/this.count)*100:0}}evalTextureSize(e){let t=Math.ceil(Math.sqrt(e));const a=64;t=Math.ceil(t/a)*a;const r=Math.ceil(e/t);return new K(t,r)}buildColor(e){const t=this.size.x|0,a=this.size.y|0,r=new Uint8Array(t*a*4),i=.28209479177387814,n=e.count,o=e.sh?.coeffs,l=o?o.length/(3*n):1;for(let c=0;c<n;c++){let f=.5,h=.5,u=.5;if(o&&l>=1){const m=c*l*3;f=.5+o[m+0]*i,h=.5+o[m+l+0]*i,u=.5+o[m+2*l+0]*i}const g=e.opacity?1/(1+Math.exp(-e.opacity[c])):1,p=c*4;r[p+0]=Math.max(0,Math.min(255,Math.floor(f*255))),r[p+1]=Math.max(0,Math.min(255,Math.floor(h*255))),r[p+2]=Math.max(0,Math.min(255,Math.floor(u*255))),r[p+3]=Math.max(0,Math.min(255,Math.floor(g*255)))}this.splatColor=new ds().create(t,a,r,!1),this.splatColor.name="splatColor",this.splatColor.minFilter="nearest",this.splatColor.magFilter="nearest",this.splatColor.mipmapFilter="nearest",this.splatColor.addressModeU="clamp-to-edge",this.splatColor.addressModeV="clamp-to-edge"}buildTransform(e){const t=this.size.x|0,a=this.size.y|0,r=e.count,i=new Uint32Array(t*a*4),n=new Array(t*a*4).fill(0),o=new ArrayBuffer(4),l=new Float32Array(o),c=new Uint32Array(o),f=p=>(l[0]=p,c[0]),h=e.position,u=e.rotation,g=e.scale;for(let p=0;p<r;p++){const m=p*4,D=h[p*3+0],_=h[p*3+1],B=h[p*3+2];i[m+0]=f(D),i[m+1]=f(_),i[m+2]=f(B);let v=0,C=0,y=0,F=1;if(u){v=u[p*4+0],C=u[p*4+1],y=u[p*4+2],F=u[p*4+3];const $t=1/Math.hypot(v,C,y,F);v*=$t,C*=$t,y*=$t,F*=$t}let k=1,w=1,x=1;g&&(k=Math.exp(g[p*3+0]),w=Math.exp(g[p*3+1]),x=Math.exp(g[p*3+2]));const M=v+v,N=C+C,Q=y+y,G=v*M,X=v*N,ne=v*Q,q=C*N,he=C*Q,Be=y*Q,ae=F*M,ee=F*N,se=F*Q,Ae=1-(q+Be),Ue=X+se,Se=ne-ee,Te=X-se,ve=1-(G+Be),Me=he+ae,Ut=ne+ee,ya=he-ae,Ca=1-(G+q),It=Ae*k,Qt=Ue*k,Gt=Se*k,Ct=Te*w,Sa=ve*w,xa=Me*w,Fa=Ut*x,ka=ya*x,Ea=Ca*x,gr=It*It+Ct*Ct+Fa*Fa,Ra=It*Qt+Ct*Sa+Fa*ka,Ir=It*Gt+Ct*xa+Fa*Ea,mr=Qt*Qt+Sa*Sa+ka*ka,Qr=Qt*Gt+Sa*xa+ka*Ea,Tr=Gt*Gt+xa*xa+Ea*Ea,wa=m;n[wa+0]=gr,n[wa+1]=Ra,n[wa+2]=Ir,n[wa+3]=Tr;const Mr=ar(mr)&65535,Za=ar(Qr)&65535;i[m+3]=Mr|Za<<16}this.transformA=new Mc().create(t,a,i),this.transformA.name="transformA",this.transformA.minFilter="nearest",this.transformA.magFilter="nearest",this.transformA.addressModeU="clamp-to-edge",this.transformA.addressModeV="clamp-to-edge",this.transformB=new hs().create(t,a,n,!1),this.transformB.name="transformB",this.transformB.minFilter="nearest",this.transformB.magFilter="nearest",this.transformB.mipmapFilter="nearest",this.transformB.addressModeU="clamp-to-edge",this.transformB.addressModeV="clamp-to-edge"}updateWorldPositions(){if(!this._positions)return;const e=this.object3D.transform.worldMatrix,t=this._positions,a=this._fullCount;this._worldPositions||(this._worldPositions=new Float32Array(t.length));const r=e.rawData;for(let i=0;i<a;i++){const n=i*3,o=t[n+0],l=t[n+1],c=t[n+2];this._worldPositions[n+0]=r[0]*o+r[4]*l+r[8]*c+r[12],this._worldPositions[n+1]=r[1]*o+r[5]*l+r[9]*c+r[13],this._worldPositions[n+2]=r[2]*o+r[6]*l+r[10]*c+r[14]}this._centersSent=!1}scheduleOrder(e){if(this.count===0)return;const t=this.object3D.transform.localChange;(t||!this._worldPositions)&&this.updateWorldPositions();const a=e.rawData,r=a[2],i=a[6],n=a[10],o=-(a[0]*a[12]+a[1]*a[13]+a[2]*a[14]),l=-(a[4]*a[12]+a[5]*a[13]+a[6]*a[14]),c=-(a[8]*a[12]+a[9]*a[13]+a[10]*a[14]),f=performance.now(),h=(f-this._lastSentTime)/1e3,u=Math.floor(o*1e3)^Math.floor(l*1e3)^Math.floor(c*1e3),g=Math.floor(r*1e3)^Math.floor(i*1e3)^Math.floor(n*1e3),p=u^g;if(p===this._lastViewMatrixHash&&!t)return;let m=this._minIntervalMs;if(this._adaptiveSorting&&this._minIntervalMs>0){const _=Math.abs(p-this._lastViewMatrixHash)/Math.max(h,.001);_<1e3?m=this._minIntervalMs:_<1e4?m=this._minIntervalMs*.5:m=this._minIntervalMs*.2,this._lastCameraSpeed=_}if(!(f-this._lastSentTime<m)){if(this._lastViewMatrixHash=p,this._lastSentTime=f,!this._sortWorker){this._sortWorker=this.createSortWorker(),this._sortWorker.onmessage=v=>{const C=v.data.order,y=this._orderData.buffer;this._sortWorker.postMessage({order:y},[y]);const F=new Uint32Array(C),k=this.size.x*this.size.y,w=this.count;(!this._orderData||this._orderData.length!==k)&&(this._orderData=new Uint32Array(k));const x=Math.min(w,F.length);if(this._orderData.set(F.subarray(0,x),0),x<k){const Q=w>0?w-1:0;this._orderData.fill(Q,x,k)}this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData);const M=Math.max(0,Math.min(this.count,v.data.count|0));this.texParams[2]=M;const N=Math.ceil(M/this._batchSize);this.instanceCount=N};const D=this._worldPositions||this._positions,_=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(D);if(this._mapping)for(let v=0;v<this._mapping.length;++v){const C=this._mapping[v]*3,y=v*3;_[y+0]=D[C+0],_[y+1]=D[C+1],_[y+2]=D[C+2]}const B=new Uint32Array(this.count);for(let v=0;v<this.count;v++)B[v]=v;this._sortWorker.postMessage({order:B.buffer,centers:_.buffer,mapping:this._mapping},[B.buffer,_.buffer]),this._centersSent=!0}if(!this._centersSent&&this._sortWorker){const D=this._worldPositions||this._positions,_=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(D);if(this._mapping)for(let B=0;B<this._mapping.length;++B){const v=this._mapping[B]*3,C=B*3;_[C+0]=D[v+0],_[C+1]=D[v+1],_[C+2]=D[v+2]}this._sortWorker.postMessage({type:"centers",centers:_.buffer,mapping:this._mapping?this._mapping:null},[_.buffer]),this._centersSent=!0}this._sortWorker.postMessage({cameraPosition:{x:o,y:l,z:c},cameraDirection:{x:-r,y:-i,z:-n}})}}createSortWorker(){function e(){let o,l,c,f,h,u=!1;const g={x:0,y:0,z:0},p={x:0,y:0,z:0},m={x:0,y:0,z:0},D={x:0,y:0,z:0};let _,B;const v=(y,F,k)=>{for(;y<=F;){const w=F+y>>1,x=k(w);if(x>0)y=w+1;else if(x<0)F=w-1;else return w}return~y},C=()=>{if(!o||!l||!f||!h)return;const y=f.x,F=f.y,k=f.z,w=h.x,x=h.y,M=h.z,N=.001;if(!u&&Math.abs(y-g.x)<N&&Math.abs(F-g.y)<N&&Math.abs(k-g.z)<N&&Math.abs(w-p.x)<N&&Math.abs(x-p.y)<N&&Math.abs(M-p.z)<N)return;u=!1,g.x=y,g.y=F,g.z=k,p.x=w,p.y=x,p.z=M;const Q=l.length/3;_?.length!==Q&&(_=new Uint32Array(Q));let G,X;for(let ee=0;ee<8;++ee){const se=(ee&1?m.x:D.x)-y,Ae=(ee&2?m.y:D.y)-F,Ue=(ee&4?m.z:D.z)-k,Se=se*w+Ae*x+Ue*M;ee===0?G=X=Se:(G=Math.min(G,Se),X=Math.max(X,Se))}B?B.fill(0):B=new Uint32Array(65537);const ne=X-G,q=ne<1e-6?0:1/ne*2**16;for(let ee=0;ee<Q;++ee){const se=ee*3,Ae=l[se+0]-y,Ue=l[se+1]-F,Se=l[se+2]-k,Te=Ae*w+Ue*x+Se*M,ve=Math.floor((Te-G)*q);_[ee]=ve,B[ve]++}for(let ee=1;ee<65537;ee++)B[ee]+=B[ee-1];for(let ee=0;ee<Q;ee++){const se=_[ee],Ae=--B[se];o[Ae]=ee}const he=ee=>_[o[ee]]/q+G,Be=()=>{const ee=v(0,Q-1,se=>-he(se));return Math.min(Q,Math.abs(ee))},ae=he(Q-1)>=0?Be():Q;if(c)for(let ee=0;ee<Q;++ee)o[ee]=c[o[ee]];self.postMessage({order:o.buffer,count:ae},[o.buffer]),o=null};self.onmessage=y=>{if(y.data.order&&(o=new Uint32Array(y.data.order)),y.data.centers){l=new Float32Array(y.data.centers),m.x=D.x=l[0],m.y=D.y=l[1],m.z=D.z=l[2];const F=l.length/3;for(let k=1;k<F;++k){const w=l[k*3+0],x=l[k*3+1],M=l[k*3+2];m.x=Math.min(m.x,w),m.y=Math.min(m.y,x),m.z=Math.min(m.z,M),D.x=Math.max(D.x,w),D.y=Math.max(D.y,x),D.z=Math.max(D.z,M)}u=!0}y.data.hasOwnProperty("mapping")&&(c=y.data.mapping?new Uint32Array(y.data.mapping):null,u=!0),y.data.cameraPosition&&(f=y.data.cameraPosition),y.data.cameraDirection&&(h=y.data.cameraDirection),C()}}const t=`(${e.toString()})()`,a=new Blob([t],{type:"application/javascript"}),r=URL.createObjectURL(a);return new Worker(r)}nodeUpdate(e,t,a,r){const i=this.object3D.transform.worldMatrix;this.gsplatMaterial.setTransformMatrix(i);const n=`${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;n!==this._lastPixelCullParams&&(this.gsplatMaterial.setPixelCulling(this._minPixelCoverage,this._maxPixelCoverage,this._maxPixelCullDistance,this._batchSize),this._lastPixelCullParams=n),this._texturesInitialized||(this.gsplatMaterial.setSplatTextures(this.splatColor,this.transformA,this.transformB,this.texParams,this.splatOrder),this._texturesInitialized=!0),super.nodeUpdate(e,t,a,r)}renderPass(e,t,a){const r=a.encoder;for(let i of this.materials){const n=i.getPass(t);if(!(!n||n.length===0))for(const o of n){if(!o.pipeline)continue;o.apply(this.geometry,a.rendererPassState||a),S.bindPipeline(r,o),S.bindGeometryBuffer(r,this.geometry);const c=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?S.drawIndexed(r,c.indexCount,this.instanceCount,c.indexStart,0,0):S.drawIndexed(r,c.indexCount,1,c.indexStart,0,0)}}}destroy(e){this._sortWorker&&(this._sortWorker.terminate(),this._sortWorker=null),this.splatColor&&(this.splatColor.destroy(e),this.splatColor=null),this.transformA&&(this.transformA.destroy(e),this.transformA=null),this.transformB&&(this.transformB.destroy(e),this.transformB=null),this.splatOrder&&(this.splatOrder.destroy(e),this.splatOrder=null),this._positions=null,this._worldPositions=null,this._orderData=null,this.texParams=null,this._mapping=null,super.destroy(e)}},d.GSplatRenderer=Zu([Mt(d.GSplatRenderer,"GSplatRenderer")],d.GSplatRenderer);class us{static maxVector=new b(Number.MAX_VALUE*.1,Number.MAX_VALUE*.1,Number.MAX_VALUE*.1);static minVector=this.maxVector.clone().multiplyScalar(-1);static genMeshMaxVector=b.ZERO.clone();static genMeshMinVector=b.ZERO.clone();static genMeshVectorList8=[new b,new b,new b,new b,new b,new b,new b,new b];static genGSplatBounds(e,t){t||=new ge(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(d.GSplatRenderer);if(!a)return console.warn("genGSplatBounds: No GSplatRenderer found on object"),t;for(const r of a){const i=r.positions,n=r.fullCount;if(!i||n===0)return console.warn("genGSplatBounds: No position data available"),t;const o=r.object3D.transform.worldMatrix,l=new b;for(let c=0;c<n;c++){const f=c*3;l.set(i[f+0],i[f+1],i[f+2]),o.transformPoint(l,l),t.expandByPoint(l)}t.setFromMinMax(t.min,t.max)}return t}static genMeshBounds(e,t){let a=this.genMeshMinVector,r=this.genMeshMaxVector,i=this.genMeshVectorList8;t||=new ge(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let n=e.getComponents(d.MeshRenderer);for(const o of n)if(o&&o.geometry){let l=o.object3D.transform.worldMatrix;a.copy(o.geometry.bounds.min),r.copy(o.geometry.bounds.max),i[0].set(a.x,a.y,a.z),i[1].set(a.x,a.y,r.z),i[2].set(a.x,r.y,a.z),i[3].set(a.x,r.y,r.z),i[4].set(r.x,a.y,a.z),i[5].set(r.x,a.y,r.z),i[6].set(r.x,r.y,a.z),i[7].set(r.x,r.y,r.z);for(const c of i)l.transformPoint(c,c),t.expandByPoint(c)}return r.copyFrom(t.max),a.copyFrom(t.min),t.setFromMinMax(a,r),t}static transformBound(e,t,a){let r=this.genMeshMinVector.copyFrom(t.min),i=this.genMeshMaxVector.copyFrom(t.max),n=this.genMeshVectorList8;a||=new ge(b.ZERO,b.ZERO),a.setFromMinMax(this.maxVector,this.minVector),n[0].set(r.x,r.y,r.z),n[1].set(r.x,r.y,i.z),n[2].set(r.x,i.y,r.z),n[3].set(r.x,i.y,i.z),n[4].set(i.x,r.y,r.z),n[5].set(i.x,r.y,i.z),n[6].set(i.x,i.y,r.z),n[7].set(i.x,i.y,i.z);for(const o of n)e.transformPoint(o,o),a.expandByPoint(o);return i.copyFrom(a.max),r.copyFrom(a.min),a.setFromMinMax(r,i),a}}class Vc extends Ia{name="";_instanceID="";_numChildren;get instanceID(){return this._instanceID}transform;renderNode;entityChildren;components;waitDisposeComponents;_bound;_boundWorld;_isBoundChange=!0;_dispose=!1;get dispose(){return this._dispose}getObjectByName(e){if(e.indexOf("/")>=0){let a=e.split("/"),r=this;for(;a.length>0&&r;){let i=a.shift();if(r=r.getChildByName(i,!1),!r)return null}return r}else return this.getChildByName(e,!1)}constructor(){super(),this.entityChildren=[],this.components=new Map,this._instanceID=Ln().toString(),this.waitDisposeComponents=[]}get numChildren(){return this._numChildren}addChild(e){if(e==null)throw new Error("child is null!");if(e===this)throw new Error("child is self!");return this.entityChildren.indexOf(e)==-1?(e.removeFromParent(),e.transform.parent=this.transform,this.entityChildren.push(e),this._numChildren=this.entityChildren.length,this.noticeComponents("onAddChild",e),e):null}removeChild(e){if(e===null)return;if(e===this)throw new Error("add child is self!");let t=this.entityChildren.indexOf(e);t!=-1&&(this.entityChildren.splice(t,1),e.transform.parent=null,this._numChildren=this.entityChildren.length,this.noticeComponents("onRemoveChild",e))}removeAllChild(){for(;this.numChildren>0;)this.removeChild(this.entityChildren[0])}removeSelf(){return this.removeFromParent()}removeChildByIndex(e){e>=0&&e<this.entityChildren.length?this.removeChild(this.entityChildren[e]):console.error("remove child by index , index out of range")}hasChild(e){return this.entityChildren.indexOf(e)!=-1}removeFromParent(){let e=this.transform.parent;return e&&e.object3D&&e.object3D.removeChild(this),this}getChildByIndex(e){let t=null;return e<this.entityChildren.length&&(t=this.entityChildren[e]),t}getChildByName(e,t=!0){let a=null;for(const r of this.entityChildren){if(r.name==e)return a=r,a;if(t&&(a=r.getChildByName(e,t),a))return a}return a}update(){}instantiate(){return null}onTransformLocalChange(e){this._isBoundChange=!0}get bound(){return(this._isBoundChange||!this._bound)&&this.updateBound(),this._boundWorld}set bound(e){this._bound=e,this._boundWorld=this._bound.clone(),this._isBoundChange=!0}updateBound(){return this._bound||(this._bound=new ge,this._boundWorld=this._bound.clone(),this._isBoundChange=!0),this._isBoundChange&&(us.transformBound(this.transform.worldMatrix,this._bound,this._boundWorld),this._isBoundChange=!1),this._boundWorld}waitUpdate(){this._dispose?(this.transform.parent&&this.transform.parent.object3D.removeChild(this),this.components.forEach((e,t)=>{e.enable=!1,e.beforeDestroy(),e.destroy()}),this.components.clear()):ye.waitStartComponent.forEach((e,t)=>{for(;e.length>0;){const a=e.shift();a.__start(),ye.waitStartComponent.delete(a.object3D)}})}noticeComponents(e,t){for(let a of this.components.values())a[e]?.(t)}destroy(e){this._dispose||(this.components.forEach(t=>{t.beforeDestroy(e)}),this.components.forEach(t=>{t.destroy(e)}),this.components.clear(),this.entityChildren.forEach(t=>{t.destroy(e)}),this.removeAllChild(),this.transform.parent=null,this._dispose=!0,super.destroy())}}var Yu=Object.getOwnPropertyDescriptor,Xu=(s,e,t,a)=>{for(var r=a>1?void 0:a?Yu(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.Object3D=class extends Vc{_isScene3D;prefabRef;serializeTag;constructor(){super(),this.transform=this.addComponent(kt),this.transform.eventDispatcher.addEventListener(kt.LOCAL_ONCHANGE,this.onTransformLocalChange,this)}get isScene3D(){return this._isScene3D}forChild(e){this.entityChildren.forEach(t=>{e(t),t.forChild(e)})}addComponent(e,t){if(!this.components.has(e)){let a=new e;return a.object3D=this,this.components.set(e,a),a.__init(t),ye.appendWaitStart(a),a}return this.components.get(e)}getOrAddComponent(e){let t=this.components.get(e);return t||(t=this.addComponent(e)),t}removeComponent(e){if(this.components.has(e)){let t=this.components.get(e);ye.removeWaitStart(this,t),this.components.delete(e),t.__stop(),t.beforeDestroy(),t.destroy()}}hasComponent(e){return this.components.has(e)}getComponent(e){return this.components.get(e)}getComponentFromParent(e){if(!this.parent)return null;let t=this.parent.object3D.getComponent(e);return t||this.parent.object3D.getComponentFromParent(e)}getComponentsInChild(e){let t=[],a=this.components.get(e);a&&t.push(a);for(let r=0;r<this.entityChildren.length;r++){let n=this.entityChildren[r].getComponentsInChild(e);t.push(...n)}return t}getComponents(e,t,a){t||=[];let r=this.getComponent(e);r&&(r.enable||a)&&t.push(r);for(let i=0,n=this.entityChildren.length;i<n;i++){let o=this.entityChildren[i];o&&o instanceof d.Object3D&&o.getComponents(e,t,a)}return t}getComponentsExt(e,t,a){t||=[];let r=this.components.get(e);if(r&&(r.enable||a))t.push(r);else for(const i of this.entityChildren)i instanceof d.Object3D&&i.getComponentsExt(e,t,a);return t}getComponentsByProperty(e,t,a=!0,r,i){r||=[];let n;for(const o of this.components.values())o&&(o.enable||i)&&o[e]===t&&(r.push(o),n=!0);if(!(n&&a))for(const o of this.entityChildren)o instanceof d.Object3D&&o.getComponentsByProperty(e,t,a,r,i);return r}clone(){return this.instantiate()}instantiate(){let e=new d.Object3D;return e.name=this.name,e.serializeTag=this.serializeTag,e.prefabRef=this.prefabRef,this.entityChildren.forEach((t,a)=>{let r=t.instantiate();e.addChild(r)}),this.components.forEach((t,a)=>{t.cloneTo(e)}),e}get localPosition(){return this.transform.localPosition}set localPosition(e){this.transform.localPosition=e}get localRotation(){return this.transform.localRotation}set localRotation(e){this.transform.localRotation=e}get localScale(){return this.transform.localScale}set localScale(e){this.transform.localScale=e}get localQuaternion(){return this.transform.localRotQuat}set localQuaternion(e){this.transform.localRotQuat=e}notifyChange(){this.transform.notifyChange()}get parent(){return this.transform.parent}get parentObject(){return this.transform.parent.object3D}set x(e){this.transform.x=e}get x(){return this.transform.x}set y(e){this.transform.y=e}get y(){return this.transform.y}set z(e){this.transform.z=e}get z(){return this.transform.z}set scaleX(e){this.transform.scaleX=e}get scaleX(){return this.transform.scaleX}set scaleY(e){this.transform.scaleY=e}get scaleY(){return this.transform.scaleY}set scaleZ(e){this.transform.scaleZ=e}get scaleZ(){return this.transform.scaleZ}set rotationX(e){this.transform.rotationX=e}get rotationX(){return this.transform.rotationX}set rotationY(e){this.transform.rotationY=e}get rotationY(){return this.transform.rotationY}set rotationZ(e){this.transform.rotationZ=e}get rotationZ(){return this.transform.rotationZ}fixedUpdate(){}lateUpdate(){}traverse(e){e(this);for(let t=0,a=this.entityChildren.length;t<a;t++){let r=this.entityChildren[t];r instanceof d.Object3D&&r.traverse(e)}}destroy(e){this.transform.eventDispatcher.removeEventListener(kt.LOCAL_ONCHANGE,this.onTransformLocalChange,this),super.destroy(e)}},d.Object3D=Xu([Hu],d.Object3D);function Hu(s,e){return class extends d.Object3D{set active(t){this.transform.enable=t>0}get active(){return this.transform.enable?1:0}get materialColor(){return this.getComponent(d.MeshRenderer)?.material?.shader.getDefaultColorShader().baseColor}set materialColor(t){let a=this.getComponent(d.MeshRenderer)?.material;a&&(a.shader.getDefaultColorShader().baseColor=t)}notifyMaterialColorChange(t,a){this.getComponent(d.MeshRenderer).materials?.[t]?.shader.getDefaultColorShader().uniforms[a].onChange()}}}class He{static createCamera3DObject(e,t){return this.createCamera3D(null,e,t)}static createCamera3D(e,t,a){return e||=new d.Object3D,t&&t.addChild(e),a&&(e.name=a),e.getOrAddComponent(Zr)}static UnProjection(e,t,a=1,r){let i=new b(e,t,0),n=1,o=b.HELP_0,l=E.canvas.offsetLeft,c=E.canvas.offsetTop,f=E.canvas.clientWidth,h=E.canvas.clientHeight;o.x=((i.x-l)*n/f-.5)*2,o.y=-((i.y-c)*n/h-.5)*2,o.z=a;let u=new b(0,0,0),g=R.helpMatrix2;g.copyFrom(r.projectionMatrix),g.invert();let p=R.helpMatrix;return p.identity(),p.multiply(g),p.multiply(r.transform.worldMatrix),p.perspectiveMultiplyPoint3(o,u),u}static Projection(e,t,a){let r=a||new b(0,0,0),i=R.helpMatrix;i.copyFrom(t.viewMatrix),i.multiply(t.projectionMatrix),i.perspectiveMultiplyPoint3(e,r);let n=E.canvas.clientWidth/2,o=E.canvas.clientHeight/2;return r.x=r.x*n+n,r.y=o-r.y*o,r}static UnProjection2(e,t,a,r,i){let n=i||new b(0,0,0),o=R.helpMatrix;o.copyFrom(r.pvMatrixInv);let l=E.canvas.clientWidth/2,c=E.canvas.clientHeight/2;return n.x=(e-l)/l,n.y=(c-t)/c,n.z=a,o.perspectiveMultiplyPoint3(n,n),n}}class Et{static maxNumDirectionShadow=8;static maxNumPointShadow=8;static directionLightList;static pointLightList;static shadowLights;static init(){this.directionLightList=new Map,this.pointLightList=new Map,this.shadowLights=new Map}static createBuffer(e){if(!this.shadowLights.has(e.scene)){let t=new Float32Array(16);this.shadowLights.set(e.scene,t)}}static getShadowLightList(e){if(!e.transform.view3D)return null;if(e.lightData.lightType==Ye.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);return t||(t=[],this.directionLightList.set(e.transform.view3D.scene,t)),t}else if(e.lightData.lightType==Ye.PointLight){let t=this.pointLightList.get(e.transform.view3D.scene);return t||(t=[],this.pointLightList.set(e.transform.view3D.scene,t)),t}else if(e.lightData.lightType==Ye.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);return t||(t=[],this.pointLightList.set(e.transform.view3D.scene,t)),t}}static getShadowLightWhichScene(e,t){if(t==Ye.DirectionLight){let a=this.directionLightList.get(e);return a||(a=[],this.directionLightList.set(e,a)),a}else if(t==Ye.PointLight){let a=this.pointLightList.get(e);return a||(a=[],this.pointLightList.set(e,a)),a}}static getDirectShadowLightWhichScene(e){let t=this.directionLightList.get(e);return t||(t=[],this.directionLightList.set(e,t)),t}static getPointShadowLightWhichScene(e){let t=this.pointLightList.get(e);return t||(t=[],this.pointLightList.set(e,t)),t}static addShadowLight(e){if(!e.transform.view3D)return null;let t=e.transform.view3D.scene;if(e.lightData.lightType==Ye.DirectionLight){let a=this.directionLightList.get(t);if(a||(a=[],this.directionLightList.set(t,a)),!e.shadowCamera){e.shadowCamera=He.createCamera3DObject(null,"shadowCamera"),e.shadowCamera.isShadowCamera=!0;let r=-1e3;e.shadowCamera.orthoOffCenter(r,-r,r,-r,1,1e4)}return a.indexOf(e)==-1&&a.push(e),a}else if(e.lightData.lightType==Ye.PointLight||e.lightData.lightType==Ye.SpotLight){let a=this.pointLightList.get(t);return a&&a.length>=8||(a||(a=[],this.pointLightList.set(t,a)),a.indexOf(e)==-1&&a.push(e)),a}}static removeShadowLight(e){if(e.lightData.castShadowIndex=-1,!e.transform.view3D)return null;if(e.lightData.lightType==Ye.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);if(t){let a=t.indexOf(e);a!=-1&&t.splice(a,1)}return e.lightData.castShadowIndex=-1,t}else if(e.lightData.lightType==Ye.PointLight||e.lightData.lightType==Ye.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);if(t){let a=t.indexOf(e);a!=-1&&t.splice(a,1)}return e.lightData.castShadowIndex=-1,t}}static update(e){let t=this.shadowLights.get(e.scene),a=Et.directionLightList.get(e.scene),r=Et.pointLightList.get(e.scene),i=0,n=0,o=0,l=0;if(t.fill(0),a){let f=0;for(let h=0;h<a.length;h++){const u=a[h];t[h]=u.lightData.index,u.lightData.castShadowIndex=f++}n=a.length}if(r){o=n;let f=0;for(let h=o;h<r.length;h++){const u=r[h];t[h]=u.lightData.index,u.lightData.castShadowIndex=f++}l=o+r.length}le.getAllCameraGroup().forEach(f=>{f.dirShadowStart=i,f.dirShadowEnd=n,f.pointShadowStart=o,f.pointShadowEnd=l,f.shadowLights.set(new Float32Array(t))})}}class bs{uuid;usage;globalBindGroup;uniformGPUBuffer;matrixBindGroup;uniformByteLength;matrixesByteLength;shadowMatrixRaw=new Float32Array(128);csmMatrixRaw=new Float32Array(Jt.Cascades*16);csmShadowBias=new Float32Array(4);shadowLights=new Float32Array(16);dirShadowStart=0;dirShadowEnd=0;pointShadowStart=0;pointShadowEnd=0;constructor(e){this.uuid=xt(),this.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.uniformGPUBuffer=new ct(8336),this.uniformGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBindGroup=e,this.createBindGroup()}createBindGroup(){this.uniformByteLength=this.uniformGPUBuffer.memory.shareDataBuffer.byteLength,this.matrixesByteLength=R.block*4*R.maxCount,this.globalBindGroup=E.device.createBindGroup({label:"global_bindGroupLayout",layout:is.getGlobalDataBindGroupLayout(),entries:[{binding:0,resource:{buffer:this.uniformGPUBuffer.buffer,offset:0,size:this.uniformByteLength}},{binding:1,resource:{buffer:this.matrixBindGroup.matrixBufferDst.buffer,offset:0,size:this.matrixesByteLength}}]})}setCamera(e){this.uniformGPUBuffer.setMatrix("_projectionMatrix",e.projectionMatrix),this.uniformGPUBuffer.setMatrix("_viewMatrix",e.viewMatrix),this.uniformGPUBuffer.setMatrix("_cameraWorldMatrix",e.transform.worldMatrix),this.uniformGPUBuffer.setMatrix("pvMatrixInv",e.projectionMatrixInv),this.uniformGPUBuffer.setMatrix("viewToWorld",e.cameraToWorld);let t=Et.getDirectShadowLightWhichScene(e.transform.scene3D);this.csmShadowBias.fill(1e-4),this.shadowMatrixRaw.fill(0),this.csmMatrixRaw.fill(0);for(let l=0;l<8;l++)if(l<t.length){let c=t[l].shadowCamera;this.shadowMatrixRaw.set(c.pvMatrix.rawData,l*16)}else this.shadowMatrixRaw.set(e.transform.worldMatrix.rawData,l*16);this.uniformGPUBuffer.setFloat32Array("shadowMatrix",this.shadowMatrixRaw);let a=A.setting.shadow.shadowSize;if(Jt.Cascades>1&&e.enableCSM&&t[0])for(let l=0;l<Jt.Cascades;l++){let c=e.csm.children[l].shadowCamera;this.csmMatrixRaw.set(c.pvMatrix.rawData,l*16),this.csmShadowBias[l]=e.getCSMShadowBiasScale(c)}this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights);let r=A.setting.reflectionSetting,i=W.instance.getReflections(e.transform.scene3D).length;this.uniformGPUBuffer.setFloat("reflectionProbeSize",r.reflectionProbeSize),this.uniformGPUBuffer.setFloat("reflectionProbeMaxCount",r.reflectionProbeMaxCount),this.uniformGPUBuffer.setFloat("reflectionMapWidth",r.width),this.uniformGPUBuffer.setFloat("reflectionMapHeight",r.height),this.uniformGPUBuffer.setFloat("reflectionCount",i),this.uniformGPUBuffer.setFloat("test2",Ze.testObj.testValue2),this.uniformGPUBuffer.setFloat("test3",Ze.testObj.testValue3),this.uniformGPUBuffer.setFloat("test4",Ze.testObj.testValue4),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",xe.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",xe.time),this.uniformGPUBuffer.setFloat("delta",xe.delta),this.uniformGPUBuffer.setFloat("shadowBias",e.getShadowBias(a)),this.uniformGPUBuffer.setFloat("skyExposure",A.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",A.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",A.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",A.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",A.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",A.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",A.setting.render.renderState_split);let n=A.inputSystem.mouseX*E.pixelRatio,o=A.inputSystem.mouseY*E.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",n),this.uniformGPUBuffer.setFloat("mouseY",o),this.uniformGPUBuffer.setFloat("windowWidth",E.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",E.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",A.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",a),this.uniformGPUBuffer.setFloat("shadowSoft",A.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",e.enableCSM?1:0),this.uniformGPUBuffer.setFloat("csmMargin",A.setting.shadow.csmMargin),this.uniformGPUBuffer.setInt32("nDirShadowStart",this.dirShadowStart),this.uniformGPUBuffer.setInt32("nDirShadowEnd",this.dirShadowEnd),this.uniformGPUBuffer.setInt32("nPointShadowStart",this.pointShadowStart),this.uniformGPUBuffer.setInt32("nPointShadowEnd",this.pointShadowEnd),this.uniformGPUBuffer.setVector3("cameraForward",e.transform.forward),this.uniformGPUBuffer.setVector4Array("frustumPlanes",e.frustum.planes),this.uniformGPUBuffer.apply()}setShadowCamera(e){this.uniformGPUBuffer.setMatrix("_projectionMatrix",e.projectionMatrix),this.uniformGPUBuffer.setMatrix("_viewMatrix",e.viewMatrix),this.uniformGPUBuffer.setMatrix("_pvMatrix",e.pvMatrix),this.uniformGPUBuffer.setMatrix("pvMatrixInv",e.projectionMatrixInv),this.uniformGPUBuffer.setMatrix("viewToWorld",e.cameraToWorld),this.csmShadowBias.fill(1e-4),this.shadowMatrixRaw.fill(0),this.csmMatrixRaw.fill(0),this.uniformGPUBuffer.setFloat32Array("shadowCamera",this.shadowMatrixRaw),this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",xe.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",xe.time),this.uniformGPUBuffer.setFloat("delta",xe.delta),this.uniformGPUBuffer.setFloat("shadowBias",A.setting.shadow.shadowBias),this.uniformGPUBuffer.setFloat("skyExposure",A.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",A.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",A.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",A.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",A.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",A.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",A.setting.render.renderState_split);let t=A.inputSystem.mouseX*E.pixelRatio,a=A.inputSystem.mouseY*E.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",t),this.uniformGPUBuffer.setFloat("mouseY",a),this.uniformGPUBuffer.setFloat("windowWidth",E.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",E.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",A.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",A.setting.shadow.shadowSize),this.uniformGPUBuffer.setFloat("shadowSoft",A.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",0),this.uniformGPUBuffer.setFloat("csmMargin",A.setting.shadow.csmMargin),this.uniformGPUBuffer.setInt32("nDirShadowStart",this.dirShadowStart),this.uniformGPUBuffer.setInt32("nDirShadowEnd",this.dirShadowEnd),this.uniformGPUBuffer.setInt32("nPointShadowStart",this.pointShadowStart),this.uniformGPUBuffer.setInt32("nPointShadowEnd",this.pointShadowEnd),this.uniformGPUBuffer.apply()}setShadowLight(){}}class Oc{setting;probesBufferData;probesBuffer;isVolumeFrameChange=!0;randomOrientation;startPosition=new b;isVolumeChange=!0;irradianceVolumeBuffer;directionDistance=20;randomSeedCount=3;useRandomIndex=0;centerDirection=new b(0,0,this.directionDistance).normalize(1);arroundPositions=[];updateOrientation(){return this.useRandomIndex++,this.useRandomIndex>=this.arroundPositions.length&&(this.useRandomIndex=0),R.fromToRotation(this.centerDirection,this.arroundPositions[this.useRandomIndex],this.randomOrientation),this.randomOrientation}init(e){this.setting=e,this.randomOrientation=new R(!1),this.randomOrientation.identity(),this.irradianceVolumeBuffer=new ct(80),this.createFramesBuffer(),this.arroundPositions.push(this.centerDirection.clone());for(let t=0;t<this.randomSeedCount;t++){let a=Math.PI*2*t/this.randomSeedCount,r=new b(Math.sin(a),Math.cos(a),this.directionDistance).normalize(1);this.arroundPositions.push(r)}}setVolumeDataChange(){this.isVolumeChange=!0}updateProbes(e){let t=this.probesBufferData;for(let a of e){let r=a.index*4;t[r+3]=a.drawCallFrame}}createFramesBuffer(){if(!this.probesBufferData){let e=this.setting.probeXCount*this.setting.probeYCount*this.setting.probeZCount;this.probesBufferData=new Float32Array(e*4),this.probesBufferData.fill(-1),this.probesBuffer=new _e(e*4,GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST)}}uploadBuffer(){this.isVolumeChange&&(this.fillIrradianceData(),this.isVolumeChange=!1,this.isVolumeFrameChange=!0),this.probesBuffer.setFloat32Array("uniformFramesBuffer",this.probesBufferData)}calcPosition(e,t,a,r){let i=this.setting,n=this.setting.probeSpace;return r=r||new b,r.x=e*n-n*(i.probeXCount-1)*.5+i.offsetX,r.y=t*n-n*(i.probeYCount-1)*.5+i.offsetY,r.z=a*n-n*(i.probeZCount-1)*.5+i.offsetZ,r}debugX=0;debugY=0;debugZ=0;fillIrradianceData(){let e=this.setting,t=this.calcPosition(0,0,0,this.startPosition);this.irradianceVolumeBuffer.setFloat("orientationIndex",this.randomOrientation.index),this.irradianceVolumeBuffer.setFloat("hysteresis",e.hysteresis),this.irradianceVolumeBuffer.setFloat("OctRTSideSize",e.octRTSideSize),this.irradianceVolumeBuffer.setFloat("OctRTMaxSize",e.octRTMaxSize),this.irradianceVolumeBuffer.setFloat("startX",t.x),this.irradianceVolumeBuffer.setFloat("startY",t.y),this.irradianceVolumeBuffer.setFloat("startZ",t.z),this.irradianceVolumeBuffer.setFloat("ProbeSpace",e.probeSpace),this.irradianceVolumeBuffer.setFloat("probeXCount",e.probeXCount),this.irradianceVolumeBuffer.setFloat("probeYCount",e.probeYCount),this.irradianceVolumeBuffer.setFloat("probeZCount",e.probeZCount),this.irradianceVolumeBuffer.setFloat("maxDistance",e.probeSpace*1.732),this.irradianceVolumeBuffer.setFloat("depthSharpness",e.depthSharpness),this.irradianceVolumeBuffer.setFloat("ProbeSourceTextureSize",e.probeSourceTextureSize),this.irradianceVolumeBuffer.setFloat("ProbeSize",e.probeSize),this.irradianceVolumeBuffer.setFloat("bounceIntensity",e.bounceIntensity),this.irradianceVolumeBuffer.setFloat("probeRoughness",e.probeRoughness),this.irradianceVolumeBuffer.setFloat("normalBias",e.normalBias),this.irradianceVolumeBuffer.setFloat("irradianceChebyshevBias",e.irradianceChebyshevBias),this.irradianceVolumeBuffer.setFloat("rayNumber",e.rayNumber),this.irradianceVolumeBuffer.setFloat("irradianceDistanceBias",e.irradianceDistanceBias),this.irradianceVolumeBuffer.setFloat("indirectIntensity",e.indirectIntensity),this.irradianceVolumeBuffer.setFloat("ddgiGamma",e.ddgiGamma),this.irradianceVolumeBuffer.setFloat("lerpHysteresis",e.lerpHysteresis),this.irradianceVolumeBuffer.setFloat("debugX",this.debugX),this.irradianceVolumeBuffer.setFloat("debugY",this.debugY),this.irradianceVolumeBuffer.setFloat("debugZ",this.debugZ),this.irradianceVolumeBuffer.apply()}}class Lc{storageGPUBuffer;irradianceVolume;_lightList=[];constructor(){this.storageGPUBuffer=new _e(tn.lightSize*A.setting.light.maxLight,GPUBufferUsage.COPY_SRC),this.irradianceVolume=new Oc,this.irradianceVolume.init(A.setting.gi);for(let e=0;e<A.setting.light.maxLight;e++){let t=this.storageGPUBuffer.memory.allocation_node(tn.lightSize*4);this._lightList.push(t)}this.storageGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e){this.storageGPUBuffer.clean();let t=W.instance.getLights(e.scene);for(let a=0;a<t.length;a++){const r=t[a].lightData;r.index=a,this.writeLightBytes(r,this._lightList[a])}this.storageGPUBuffer.apply()}writeLightBytes(e,t){t.offset=0,t.writeFloat(e.index),t.writeInt32(e.lightType),t.writeFloat(e.radius),t.writeFloat(e.linear),t.writeVector3(e.lightPosition),t.writeFloat(e.lightMatrixIndex),t.writeVector3(e.direction),t.writeFloat(e.quadratic),t.writeRGBColor(e.lightColor),t.writeFloat(e.intensity),t.writeFloat(e.innerAngle),t.writeFloat(e.outerAngle),t.writeFloat(e.range),t.writeInt32(e.castShadowIndex),t.writeVector3(e.lightTangent),t.writeFloat(e.iesIndex)}}class Gc{storageGPUBuffer;reflectionMap;sourceReflectionMap;count;constructor(){this.storageGPUBuffer=new _e(768)}update(e){this.storageGPUBuffer.clean();let t=W.instance.getReflections(e.scene);for(let a=0;a<t.length;a++){const r=t[a];r.gid=a,this.storageGPUBuffer.setFloat("gid",r.gid),this.storageGPUBuffer.setVector3("worldPosition",r.transform.worldPosition),this.storageGPUBuffer.setFloat("radius",r.radius),this.storageGPUBuffer.setVector3("bound",r.transform.worldPosition)}this.count=t.length,this.storageGPUBuffer.apply()}}class zc extends Ta{size;constructor(e,t=0,a){super(),this.bufferType=ea.StorageGPUBuffer,this.size=e,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|t,e,a,"MatrixGPUBuffer")}writeBufferByHeap(e,t){let a;e instanceof Float64Array?a=new Float32Array(e):a=e;let r=E.device;if(a.length>0){let i=null;for(;this.mapAsyncReady.length&&(i=this.mapAsyncReady.shift(),i.usedSize!=a.byteLength);)i.destroy(),this.mapAsyncBuffersOutstanding--,i=null;i||(i=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,mappedAtCreation:!0}),i.usedSize=a.byteLength,this.mapAsyncBuffersOutstanding++,this.mapAsyncBuffersOutstanding>10&&console.warn(` Warning: mapAsync requests from ${this.mapAsyncBuffersOutstanding} frames ago have not resolved yet. MB of staging buffers allocated.`));let n=new Float32Array(a.buffer,a.byteOffset,t);new Float32Array(i.getMappedRange(0,t*4)).set(n),i.unmap();const l=r.createCommandEncoder();l.copyBufferToBuffer(i,0,this.buffer,0,t*4),r.queue.submit([l.finish()]),i.mapAsync(GPUMapMode.WRITE).then(()=>this.mapAsyncReady.push(i))}}}class Jc{uuid;index;usage;groupBufferSize;matrixBufferDst;constructor(){this.uuid=xt(),this.groupBufferSize=0,this.usage=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.cacheWorldMatrix()}cacheWorldMatrix(){this.groupBufferSize=R.maxCount*R.blockBytes,this.matrixBufferDst=new zc(this.groupBufferSize/4),this.matrixBufferDst.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBufferDst.buffer.label=this.groupBufferSize.toString()}writeBuffer(e){const t=R.dynamicMatrixBytes;this.matrixBufferDst.mapAsyncWrite(t,e)}}class le{static _cameraBindGroups;static _lightEntriesMap;static _reflectionEntriesMap;static modelMatrixBindGroup;static init(){this.modelMatrixBindGroup=new Jc,this._cameraBindGroups=new Map,this._lightEntriesMap=new Map,this._reflectionEntriesMap=new Map}static getAllCameraGroup(){return this._cameraBindGroups}static getCameraGroup(e){let t=this._cameraBindGroups.get(e);return t||(t=new bs(this.modelMatrixBindGroup),this._cameraBindGroups.set(e,t)),e.isShadowCamera?t.setShadowCamera(e):t.setCamera(e),t}static updateCameraGroup(e){let t=this._cameraBindGroups.get(e);t||(t=new bs(this.modelMatrixBindGroup),this._cameraBindGroups.set(e,t)),e.isShadowCamera?t.setShadowCamera(e):t.setCamera(e)}static getLightEntries(e){e||console.log("getLightEntries scene is null");let t=this._lightEntriesMap.get(e);return t||(t=new Lc,this._lightEntriesMap.set(e,t)),this._lightEntriesMap.get(e)}static getReflectionEntries(e){e||console.log("getLightEntries scene is null");let t=this._reflectionEntriesMap.get(e);return t||(t=new Gc,this._reflectionEntriesMap.set(e,t)),this._reflectionEntriesMap.get(e)}}class S{static lastGeometry;static lastPipeline;static lastShader;static drawCount=0;static renderPassCount=0;static geometryCount=0;static pipelineCount=0;static matrixCount=0;static lastRenderPassState;static LastCommand;static bindPipeline(e,t){if(S.lastShader!=t)S.lastShader=t;else return!1;S.lastPipeline!=t.pipeline&&(S.lastPipeline=t.pipeline,e.setPipeline(t.pipeline));for(let a=1;a<t.bindGroups.length;a++){const r=t.bindGroups[a];r&&e.setBindGroup(a,r)}return!0}static bindCamera(e,t){let a=le.getCameraGroup(t);e.setBindGroup(0,a.globalBindGroup)}static bindGeometryBuffer(e,t){if(this.lastGeometry!=t&&(this.lastGeometry=t,t.indicesBuffer)){e.setIndexBuffer(t.indicesBuffer.indicesGPUBuffer.buffer,t.indicesBuffer.indicesFormat);let a=t.vertexBuffer.vertexGPUBuffer,r=t.vertexBuffer.vertexBufferLayouts;for(let i=0;i<r.length;i++){const n=r[i];e.setVertexBuffer(i,a.buffer,n.offset,n.size)}}}static cleanCache(){this.lastGeometry=null,this.lastPipeline=null,this.lastShader=null}static createPipeline(e){return Ze.countStart("GPUContext","pipeline"),E.device.createRenderPipeline(e)}static beginCommandEncoder(){return Ze.countStart("GPUContext","beginCommandEncoder"),this.LastCommand&&E.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=E.device.createCommandEncoder(),this.LastCommand}static endCommandEncoder(e){this.LastCommand==e&&(E.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=null,Ze.countStart("GPUContext","endCommandEncoder"))}static recordBundleEncoder(e){return E.device.createRenderBundleEncoder(e)}static beginRenderPass(e,t){if(this.cleanCache(),this.renderPassCount++,this.lastRenderPassState=t,t.depthTexture){let a=t.renderPassDescriptor.depthStencilAttachment;a.view=t.depthTexture.getGPUView()}if(t.renderTargets&&t.renderTargets.length>0){for(let a=0;a<t.renderTargets.length;++a){const r=t.renderTargets[a];let i=t.renderPassDescriptor.colorAttachments[a];t.multisample>0&&t.renderTargets.length==1?(i.view=t.multiTexture.createView(),i.resolveTarget=r.getGPUView()):i.view=r.getGPUTexture().createView()}return e.beginRenderPass(t.renderPassDescriptor)}else{let a=t.renderPassDescriptor.colorAttachments[0];return a&&(t.multisample>0?(a.view=t.multiTexture.createView(),a.resolveTarget=E.context.getCurrentTexture().createView()):a.view=E.context.getCurrentTexture().createView()),e.beginRenderPass(t.renderPassDescriptor)}}static drawIndexed(e,t,a,r,i,n){e.drawIndexed(t,a,r,i,n),this.drawCount++}static draw(e,t,a,r,i){e.draw(t,a,r,i),this.drawCount++}static endPass(e){e.insertDebugMarker("end"),e.end()}static computeCommand(e,t){let a=e.beginComputePass();for(let r=0;r<t.length;r++)t[r].compute(a);a.end()}static copyTexture(e,t,a){e.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:a.width,height:a.height,depthOrArrayLayers:1})}}class Wc{source;input;output;reset(e){this.input&&this.input.destroy(),this.output&&this.output.destroy(),this.input=this.output=null,this.source=e}apply(e){if(this.source){if(!this.input){let t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this.input=new _e(this.source.length,t,this.source),this.input.apply()}if(!this.output){let t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC;this.output=new _e(e*3,t),this.output.apply()}}}}class jc{enable;morphTargetsRelative;MaxMorphTargetCount=64;_computeConfigArray;_computeConfigBuffer;_morphInfluenceArray;_morphInfluenceBuffer;_positionAttrDataGroup;_normalAttrDataGroup;_isInfluenceDirty;_morphTargetCount;_totalVertexCount;_computeShader;_computeShaders;_computeWorkGroupXY=1;_collectMorphTargetData;_blendTarget;constructor(){this._isInfluenceDirty=!0,this.generateGPUBuffer(),this._positionAttrDataGroup=new Wc,this._normalAttrDataGroup=new Wc}initMorphTarget(e){this._collectMorphTargetData=this.collectMorphTargetList(e),this._computeShader&&this._computeShader.destroy();let t=Nt.CsMain;this._computeShader=new fe(t),this._collectMorphTargetData.mergedNormal?this._computeShader.setDefine("USE_MORPHNORMALS",!0):this._computeShader.deleteDefine("USE_MORPHNORMALS"),this._computeShaders=[this._computeShader],this._isInfluenceDirty=!0,this._morphTargetCount=this._collectMorphTargetData.mtCount,this._totalVertexCount=this._collectMorphTargetData.vCount,this._morphInfluenceArray.fill(0),this._computeWorkGroupXY=this.calcWorkGroup(this._totalVertexCount),this._positionAttrDataGroup.reset(this._collectMorphTargetData.mergedPos),this._normalAttrDataGroup.reset(this._collectMorphTargetData.mergedNormal)}applyRenderShader(e){this.uploadMorphTargetBuffer(),this.uploadConfigGBuffer(),e.setUniformBuffer("morphTargetConfig",this._computeConfigBuffer),e.setStorageBuffer("morphTargetOpPositions",this._positionAttrDataGroup.output),this._collectMorphTargetData.mergedNormal&&e.setStorageBuffer("morphTargetOpNormals",this._normalAttrDataGroup.output)}computeMorphTarget(e){this.uploadConfigGBuffer(),this.uploadMorphTargetBuffer(),this._computeShader.setUniformBuffer("morphTargetConfig",this._computeConfigBuffer),this._computeShader.setStorageBuffer("morphTargetInfluence",this._morphInfluenceBuffer),this._computeShader.setStorageBuffer("morphTargetPositions",this._positionAttrDataGroup.input),this._computeShader.setStorageBuffer("morphTargetOpPositions",this._positionAttrDataGroup.output),this._collectMorphTargetData.mergedNormal&&(this._computeShader.setStorageBuffer("morphTargetNormals",this._normalAttrDataGroup.input),this._computeShader.setStorageBuffer("morphTargetOpNormals",this._normalAttrDataGroup.output)),this._computeShader.workerSizeX=this._computeWorkGroupXY,this._computeShader.workerSizeY=this._computeWorkGroupXY,this._computeShader.workerSizeZ=1,S.computeCommand(e,this._computeShaders)}updateInfluence(e,t){this._isInfluenceDirty=!0,this._morphInfluenceArray[e]=t}get blendShape(){return this._blendTarget}collectMorphTargetList(e){let t=this.collectAttribute("a_morphPositions_",e),a=t.length,r=t[0].data.length/3;if(this._blendTarget={},e.blendShapeData)for(let l=0;l<e.blendShapeData.shapeIndexs.length;l++){let c=e.blendShapeData.shapeIndexs[l],f=e.blendShapeData.shapeNames[l].split("."),h=f[f.length-1];this._blendTarget[h]=u=>this.updateInfluence(c,u)}let i=new Float32Array(r*a*3);{let l=0;for(let c=0;c<a;c++){let f=t[c];i.set(f.data,l),l+=f.data.length}}let n=this.collectAttribute("a_morphNormals_",e),o;if(n&&n.length>0){let l=0;o=new Float32Array(r*a*3);for(let c=0;c<a;c++){let f=n[c];o.set(f.data,l),l+=f.data.length}}return{mtCount:a,vCount:r,mergedPos:i,mergedNormal:o}}collectAttribute(e,t){let a=[];for(let r=0;r<this.MaxMorphTargetCount;r++){let i=e+r,n=t.getAttribute(i);if(n)a[r]=n;else break}return a}uploadConfigGBuffer(){if(this._isInfluenceDirty){let e=0;for(let t=0;t<this._morphTargetCount;t++)e+=this._morphInfluenceArray[t];this._morphInfluenceBuffer.setFloat32Array("data",this._morphInfluenceArray),this._morphInfluenceBuffer.apply(),this._computeConfigArray[0]=this.morphTargetsRelative?1:1-e,this._computeConfigArray[1]=this._morphTargetCount,this._computeConfigArray[2]=this._totalVertexCount,this._computeConfigArray[3]=this._computeWorkGroupXY,this._computeConfigBuffer.setFloat32Array("data",this._computeConfigArray),this._computeConfigBuffer.apply(),this._isInfluenceDirty=!1}}calcWorkGroup(e){let t=Math.ceil(Math.sqrt(e)),a=Math.ceil(Math.log2(t));return t=Math.pow(2,a),t}uploadMorphTargetBuffer(){this._positionAttrDataGroup.output||this._positionAttrDataGroup.apply(this._totalVertexCount),this._normalAttrDataGroup.output||this._normalAttrDataGroup.apply(this._totalVertexCount)}generateGPUBuffer(){this._computeConfigArray=new Float32Array(4),this._computeConfigBuffer=new ct(4),this._morphInfluenceArray=new Float32Array(this.MaxMorphTargetCount);let e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this._morphInfluenceBuffer=new _e(this.MaxMorphTargetCount,e)}destroy(e){this._computeConfigBuffer&&(this._computeConfigBuffer.destroy(e),this._computeConfigBuffer=null),this._morphInfluenceBuffer&&(this._morphInfluenceBuffer.destroy(e),this._morphInfluenceBuffer=null),this._computeShader&&(this._computeShader.destroy(e),this._computeShader=null),this._positionAttrDataGroup&&(this._positionAttrDataGroup.input&&this._positionAttrDataGroup.input.destroy(e),this._positionAttrDataGroup.output&&this._positionAttrDataGroup.output.destroy(e),this._positionAttrDataGroup=null),this._normalAttrDataGroup&&(this._normalAttrDataGroup.input&&this._normalAttrDataGroup.input.destroy(e),this._normalAttrDataGroup.output&&this._normalAttrDataGroup.output.destroy(e),this._normalAttrDataGroup=null),this._computeConfigArray=null,this._morphInfluenceArray=null,this._collectMorphTargetData=null,this._blendTarget=null,this._computeShaders=null}}var Ku=Object.defineProperty,qu=Object.getOwnPropertyDescriptor,gs=(s,e,t,a)=>{for(var r=a>1?void 0:a?qu(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=(a?n(e,t,r):n(r))||r);return a&&r&&Ku(e,t,r),r};d.MeshRenderer=class extends Oa{receiveShadow;morphData;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(e){e.addComponent(d.MeshRenderer).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.receiveShadow=e.receiveShadow,this}get geometry(){return this._geometry}set geometry(e){if(super.geometry=e,e){let t=e.morphTargetDictionary!=null;t&&(this.morphData||=new jc,this.morphData.morphTargetsRelative=e.morphTargetsRelative,this.morphData.initMorphTarget(e)),this.morphData&&(this.morphData.enable=t),this.morphData?.enable?this.addRendererMask(De.MorphTarget):this.removeRendererMask(De.MorphTarget),this.object3D.bound=this._geometry.bounds.clone()}else this.morphData&&(this.morphData.enable=!1),this.removeRendererMask(De.MorphTarget);this._readyPipeline||(this.initPipeline(),this._computes&&(this.onCompute=Ki(this.onCompute,()=>{for(let t=0;t<this._computes.length;t++)this._computes[t].onUpdate()})))}get material(){return this._materials[0]}set material(e){this.materials=[e]}setMorphInfluence(e,t){if(this.morphData&&this.morphData.enable){let a=this._geometry.morphTargetDictionary[e];a>=0&&this.morphData.updateInfluence(a,t)}}setMorphInfluenceIndex(e,t){this.morphData&&this.morphData.enable&&e>=0&&this.morphData.updateInfluence(e,t)}onCompute(e,t){this.morphData&&this.morphData.enable&&this.morphData.computeMorphTarget(t)}nodeUpdate(e,t,a,r){if(this.morphData&&this.morphData.enable)for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(t);if(o)for(let l=0;l<o.length;l++)this.morphData.applyRenderShader(o[l])}super.nodeUpdate(e,t,a,r)}destroy(e){this.morphData&&(this.morphData.destroy(e),this.morphData=null),super.destroy(e)}},gs([zr],d.MeshRenderer.prototype,"geometry",1),gs([zr],d.MeshRenderer.prototype,"material",1),d.MeshRenderer=gs([Mt(d.MeshRenderer,"MeshRenderer")],d.MeshRenderer);class ga{static compressGBufferTex_NAME="compressGBufferTex_NAME";static colorBufferTex_NAME="colorBufferTex";static positionBufferTex_NAME="positionBufferTex";static normalBufferTex_NAME="normalBufferTex";static materialBufferTex_NAME="materialBufferTex";static zBufferTexture_NAME="zBufferTexture";static zPreDepthTexture_NAME="zPreDepthTexture";static outTex_NAME="outTex"}class Zc{label="";customSize=!1;zPreTexture=null;depthTexture=null;renderTargetTextures;outColor=-1;renderTargets;rtTextureDescriptors;irradianceBuffer;multisample=0;multiTexture;depthViewIndex=0;depthCleanValue=0;isOutTarget=!0;camera3D;rtFrame;renderPassDescriptor;renderBundleEncoderDescriptor;depthLoadOp;getLastRenderTexture(){return this.renderTargets&&this.renderTargets.length>0?this.renderTargets[0]:A.res.redTexture}}class gt extends Xe{resolveTarget;sampleCount;autoResize;clear;constructor(e,t,a=Y.rgba8unorm,r=!1,i,n=1,o=0,l=!0,c=!0){super(e,t,n),this.name=xt(),this.autoResize=c,this.useMipmap=r,this.sampleCount=o,this.format=a,this.numberLayer=n,this.clear=l,i!=null?this.usage=i:this.usage=i|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST,this.resize(e,t),this.autoResize&&E.addEventListener(Ya.RESIZE,f=>{let{width:h,height:u}=f.data;this.resize(h,u),this._textureChange=!0},this)}resize(e,t){let a=E.device;this.gpuTexture&&(Xe.delayDestroyTexture(this.gpuTexture),this.gpuTexture=null,this.view=null),this.width=e,this.height=t,this.createTextureDescriptor(e,t,1,this.format,this.usage,this.numberLayer,this.sampleCount),this.useMipmap=!1,this.visibility=GPUShaderStage.COMPUTE|GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,this.format==Y.rgba32float?(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=a.createSampler({})):this.format==Y.depth32float?(this.samplerBindingLayout.type="filtering",this.sampler_comparisonBindingLayout.type="comparison",this.textureBindingLayout.sampleType="depth",this.gpuSampler=E.device.createSampler({}),this.gpuSampler_comparison=E.device.createSampler({compare:"less",label:"sampler_comparison"})):this.format==Y.depth24plus?(this.samplerBindingLayout={type:"filtering"},this.sampler_comparisonBindingLayout={type:"comparison"},this.textureBindingLayout.sampleType="depth",this.gpuSampler=E.device.createSampler({}),this.gpuSampler_comparison=E.device.createSampler({compare:"less",label:"sampler_comparison"})):(this.samplerBindingLayout.type="filtering",this.textureBindingLayout.sampleType="float",this.sampleCount>0&&(this.textureBindingLayout.multisampled=!0),this.minFilter="linear",this.magFilter="linear",this.mipmapFilter="linear",this.addressModeU=Pt.clamp_to_edge,this.addressModeV=Pt.clamp_to_edge,this.gpuSampler=a.createSampler(this)),this._textureChange=!0}create(e,t,a=!0){let r=E.device;const i=e*4;let n=new Float32Array(e*t*4);const o=r.createBuffer({size:n.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,n);const l=S.beginCommandEncoder();l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(l)}clone(){let e=new gt(this.width,this.height,this.format,this.useMipmap,this.usage,this.numberLayer,this.sampleCount,this.clear,this.autoResize);return e.name="clone_"+e.name,e}readTextureToImage(){let e=E.device,t=E.windowWidth,a=E.windowHeight,r=new Float32Array(t*a*4);const i=e.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});return S.beginCommandEncoder().copyTextureToBuffer({texture:this.getGPUTexture()},{buffer:i},[t,a]),i.getMappedRange(0,r.byteLength)}}class ke{storeOp="store";loadOp="clear";clearValue=[0,0,0,0]}class Je{label;customSize=!1;renderTargets;rtDescriptors;zPreTexture;depthTexture;depthViewIndex=0;depthCleanValue=1;depthLoadOp="clear";isOutTarget=!0;constructor(e,t,a,r,i=!0){this.renderTargets=e,this.rtDescriptors=t,this.depthTexture=a,this.zPreTexture=r,this.isOutTarget=i}clone2Frame(e){e.renderTargets.push(...this.renderTargets.concat());for(let t=0;t<this.rtDescriptors.length;t++){const a=this.rtDescriptors[t];let r=new ke;r.loadOp=a.loadOp,r.storeOp=a.storeOp,r.clearValue=a.clearValue,e.rtDescriptors.push(r)}e.depthTexture=this.depthTexture,e.zPreTexture=this.zPreTexture,e.customSize=this.customSize}clone(){let e=new Je([],[]);return this.clone2Frame(e),e}}class oe extends Je{static colorPass_GBuffer="ColorPassGBuffer";static reflections_GBuffer="reflections_GBuffer";static gui_GBuffer="gui_GBuffer";static gBufferMap=new Map;_colorBufferTex;_compressGBufferTex;constructor(){super([],[])}createGBuffer(e,t,a,r=!0,i=!0,n){let o=this.renderTargets,l=this.rtDescriptors;if(i){let f=new ke;f.loadOp="clear",this._colorBufferTex=mt.createRTTexture(e+ga.colorBufferTex_NAME,t,a,Y.rgba16float,!0),o.push(this._colorBufferTex),l.push(f)}this._compressGBufferTex=new gt(t,a,Y.rgba32float,!1,void 0,1,0,!0,!0),o.push(this._compressGBufferTex),n?this.depthTexture=n:(this.depthTexture=new gt(t,a,Y.depth24plus,!1,void 0,1,0,!0,!0),this.depthTexture.name=e+"_depthTexture");let c;c=new ke,l.push(c)}getPositionMap(){return this.renderTargets[1]}getNormalMap(){return this.renderTargets[2]}getColorTexture(){return this._colorBufferTex}getCompressGBufferTexture(){return this._compressGBufferTex}static getGBufferFrame(e,t=0,a=0,r=!0,i){let n;if(oe.gBufferMap.has(e))n=oe.gBufferMap.get(e);else{n=new oe;let o=E.presentationSize;n.createGBuffer(e,t==0?o[0]:t,a==0?o[1]:a,t!=0&&a!=0,r,i),oe.gBufferMap.set(e,n)}return n}static getGUIBufferFrame(){let e=this.getGBufferFrame(this.colorPass_GBuffer);return oe.getGBufferFrame(oe.gui_GBuffer,0,0,!0,e.depthTexture)}clone(){let e=new oe;return this.clone2Frame(e),e}}class Re{static rendererPassState=new Map;static createRendererPassState(e,t=null){let a=Re.rendererPassState.get(e);if(a||(a=new Zc,a.label=e.label,a.customSize=e.customSize,a.rtFrame=e,a.zPreTexture=e.zPreTexture,a.depthTexture=e.depthTexture,a.depthViewIndex=e.depthViewIndex,a.isOutTarget=e.isOutTarget,a.depthCleanValue=e.depthCleanValue,a.depthLoadOp=e.depthLoadOp,Re.rendererPassState.set(e,a)),e&&e.renderTargets.length>0){a.renderTargets=e.renderTargets,a.rtTextureDescriptors=e.rtDescriptors,a.renderPassDescriptor=Re.getRenderPassDescriptor(a),a.renderPassDescriptor.depthStencilAttachment&&(a.renderPassDescriptor.depthStencilAttachment.depthLoadOp=e.depthLoadOp),t=="load"&&e?.renderTargets[0]&&e.renderTargets[0].name.startsWith(oe.gui_GBuffer)&&(a.renderPassDescriptor.colorAttachments[0].loadOp="load"),a.depthLoadOp=e.depthLoadOp,a.renderBundleEncoderDescriptor=Re.getRenderBundleDescriptor(a),a.renderTargetTextures=[];for(let r=0;r<e.renderTargets.length;r++){const i=e.renderTargets[r];a.renderTargetTextures[r]={format:i.format},i.name.indexOf(ga.colorBufferTex_NAME)!=-1&&(a.outColor=r)}}else a.renderPassDescriptor=Re.getRenderPassDescriptor(a,t),a.renderBundleEncoderDescriptor=Re.getRenderBundleDescriptor(a),a.renderTargetTextures=[{format:E.presentationFormat}],a.outColor=0;return a}static getRenderPassDescriptor(e,t=null){if(e.renderPassDescriptor)return e.renderPassDescriptor;E.device,E.presentationSize;let a=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let i=0;i<e.renderTargets.length;i++){const n=e.renderTargets[i],o=e.rtTextureDescriptors[i];a.push({view:n.getGPUView(),resolveTarget:void 0,loadOp:o.loadOp,clearValue:o.clearValue,storeOp:o.storeOp})}}else if(!e.customSize){let i=E.canvasConfig&&E.canvasConfig.alpha?[1,1,1,0]:[0,0,0,1];e.isOutTarget==!0&&a.push({view:void 0,resolveTarget:void 0,loadOp:E.canvasConfig&&E.canvasConfig.alpha||t!=null?"load":"clear",clearValue:i,storeOp:"store"})}let r=null;return e.depthTexture||e.zPreTexture?(e.zPreTexture&&(e.depthTexture=e.zPreTexture),r={label:`${e.label} renderPassDescriptor zPreTexture${e.zPreTexture?"load":"clear"}`,colorAttachments:a,depthStencilAttachment:{view:e.depthTexture.getGPUView(),depthLoadOp:e.zPreTexture?"load":e.depthLoadOp,depthClearValue:e.zPreTexture?1:e.depthCleanValue,depthStoreOp:"store"}}):r={colorAttachments:a,label:"renderPassDescriptor not writeDepth"},e.renderPassDescriptor=r,r}static getRenderBundleDescriptor(e){if(e.renderBundleEncoderDescriptor)return e.renderBundleEncoderDescriptor;E.presentationSize;let t=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let r=0;r<e.renderTargets.length;r++){const i=e.renderTargets[r];t.push(i.format)}}let a=null;return e.depthTexture?a={colorFormats:t,depthStencilFormat:e.depthTexture.format}:a={colorFormats:t},e.renderBundleEncoderDescriptor=a,e.renderBundleEncoderDescriptor}}class Hr extends Fe{width;height;segmentW;segmentH;up;constructor(e,t,a=1,r=1,i=b.Y_AXIS){super(),this.width=e,this.height=t,this.segmentW=a,this.segmentH=r,this.up=i,this.buildGeometry(this.up)}buildGeometry(e){var t,a,r,i,n=this.segmentW+1;(this.segmentH+1)*n,this.bounds=new ge(b.ZERO.clone(),new b(this.width,1,this.height)),r=this.segmentH*this.segmentW*6;let o=(this.segmentW+1)*(this.segmentH+1),l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),h;this.segmentW*this.segmentH*2*3>=Uint16Array.length?h=new Uint32Array(this.segmentW*this.segmentH*2*3):h=new Uint16Array(this.segmentW*this.segmentH*2*3),r=0;for(var g=0,p=0,m=0,D=0;D<=this.segmentH;++D)for(var _=0;_<=this.segmentW;++_){switch(t=(_/this.segmentW-.5)*this.width,a=(D/this.segmentH-.5)*this.height,e){case b.Y_AXIS:l[g++]=t,l[g++]=0,l[g++]=a,c[p++]=0,c[p++]=1,c[p++]=0;break;case b.Z_AXIS:l[g++]=t,l[g++]=-a,l[g++]=0,c[p++]=0,c[p++]=0,c[p++]=1;break;case b.X_AXIS:l[g++]=0,l[g++]=t,l[g++]=a,c[p++]=1,c[p++]=0,c[p++]=0;break;default:l[g++]=t,l[g++]=0,l[g++]=a,c[p++]=0,c[p++]=1,c[p++]=0;break}f[m++]=_/this.segmentW,f[m++]=D/this.segmentH,_!=this.segmentW&&D!=this.segmentH&&(i=_+D*n,h[r++]=i+1,h[r++]=i,h[r++]=i+n,h[r++]=i+1,h[r++]=i+n,h[r++]=i+n+1)}this.setIndices(h),this.setAttribute(V.position,l),this.setAttribute(V.normal,c),this.setAttribute(V.uv,f),this.setAttribute(V.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}var $u=Object.getOwnPropertyDescriptor,e2=(s,e,t,a)=>{for(var r=a>1?void 0:a?$u(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.QuadShader=class extends it{constructor(e="QuadGlsl_vs",t="QuadGlsl_fs"){super();let a=new Ne(e,t);this.addRenderPass(a);let r=a.shaderState;a.blendMode=te.NONE,r.frontFace="cw",r.depthWriteEnabled=!1,r.depthCompare=$e.always,r.multisample=0,this.setTexture("baseMap",A.res.blackTexture),this.setUniformFloat("x",0),this.setUniformFloat("y",0),this.setUniformFloat("width",100),this.setUniformFloat("height",100)}},d.QuadShader=e2([Qa(d.QuadShader,"QuadShader")],d.QuadShader);class ms extends d.Object3D{width=128;height=128;quadRenderer;material;rendererPassState;quadShader;constructor(e="QuadGlsl_vs",t="QuadGlsl_fs",a,r=0,i=!1){super();let n=a?a.renderTargets:[];this.material=new ut,this.quadShader=new d.QuadShader(e,t),this.material.shader=this.quadShader,this.quadRenderer=this.addComponent(d.MeshRenderer),this.quadRenderer.material=this.material,this.quadRenderer.castGI=!1,this.quadRenderer.castShadow=!1,this.quadRenderer.drawType=i?2:0,this.quadRenderer.geometry=new Hr(100,100,1,1),this.quadRenderer.material=this.material,this.quadRenderer.__start(),this.quadRenderer._enable=!0,this.quadRenderer.onEnable(),this.rendererPassState=Re.createRendererPassState(a,"load"),r>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=E.device.createTexture({size:{width:E.presentationSize[0],height:E.presentationSize[1]},sampleCount:r,format:n.length>0?n[0].format:E.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT})),E.addEventListener(Ya.RESIZE,o=>{this.rendererPassState=Re.createRendererPassState(a,"load"),r>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=E.device.createTexture({size:{width:E.presentationSize[0],height:E.presentationSize[1]},sampleCount:r,format:n.length>0?n[0].format:E.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT}))},this)}renderTarget(e,t,a){let r=e.camera,i=S.beginRenderPass(a,t.rendererPassState);S.bindCamera(i,r),t.quadRenderer.nodeUpdate(e,H.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,H.COLOR,t.rendererPassState,null,i),S.endPass(i)}renderToViewQuad(e,t,a,r){let i=e.camera;t.quadShader.setTexture("baseMap",r);let n=S.beginRenderPass(a,t.rendererPassState);S.bindCamera(n,i),t.quadRenderer.nodeUpdate(e,H.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,H.COLOR,t.rendererPassState,null,n),S.endPass(n)}}class mt{static rtTextureMap;static rtViewQuad;static init(){this.rtTextureMap=new Map,this.rtViewQuad=new Map}static createRTTexture(e,t,a,r,i=!1,n=0){let o=this.rtTextureMap.get(e);return o||(e==ga.colorBufferTex_NAME?o=new gt(t,a,r,i,void 0,1,n,!1):o=new gt(t,a,r,i,void 0,1,n,!0),o.name=e,mt.rtTextureMap.set(e,o)),o}static createRTTextureArray(e,t,a,r,i=1,n=!1,o=0){let l=this.rtTextureMap.get(e);return l||(l=new gt(t,a,r,n,void 0,i,o),l.name=e,mt.rtTextureMap.set(e,l)),l}static createViewQuad(e,t,a,r,i=0){let n=new Je([r],[new ke]),o=new ms(t,a,n,i);return mt.rtViewQuad.set(e,o),o}static getTexture(e){return this.rtTextureMap.get(e)}static CreateSplitTexture(e){let t=this.getTexture(ga.colorBufferTex_NAME),a=this.getTexture(e+"_split");return a||(a=this.createRTTexture(e+"_split",t.width,t.height,t.format,!1)),a}static WriteSplitColorTexture(e){let t=this.getTexture(ga.colorBufferTex_NAME),a=this.getTexture(e+"_split");const r=S.beginCommandEncoder();r.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:a.width,height:a.height,depthOrArrayLayers:1}),S.endCommandEncoder(r)}}class ps{command;encoder;rendererPassStates;rtFrame;constructor(e){this.rtFrame=e,this.rendererPassStates=[]}clean(){this.rendererPassStates.length=0,S.cleanCache()}beginContinueRendererPassState(e="load",t="load"){if(this.rendererPassStates.length>0){let a=this.rtFrame.clone();for(const i of a.rtDescriptors)i.loadOp="load";a.depthLoadOp=t;let r=Re.createRendererPassState(a,e);return this.rendererPassStates.push(r),r}else{this.rtFrame.depthLoadOp=t;let a=Re.createRendererPassState(this.rtFrame,e);return this.rendererPassStates.push(a),a}}get rendererPassState(){return this.rendererPassStates[this.rendererPassStates.length-1]}beginOpaqueRenderPass(){this.beginContinueRendererPassState("clear","clear"),this.begineNewCommand(),this.beginNewEncoder()}beginTransparentRenderPass(){this.beginContinueRendererPassState("load","load"),this.begineNewCommand(),this.beginNewEncoder()}specialtRenderPass(){this.beginContinueRendererPassState("load","load"),this.begineNewCommand(),this.beginNewEncoder()}endRenderPass(){this.endEncoder(),this.endCommand()}begineNewCommand(){return this.command=S.beginCommandEncoder(),this.command}endCommand(){S.endCommandEncoder(this.command),this.command=null}beginNewEncoder(){return this.encoder=S.beginRenderPass(this.command,this.rendererPassState),this.encoder}endEncoder(){S.endPass(this.encoder),this.encoder=null}}class ma extends Ia{rendererPassState;splitRendererPassState;useRenderBundle=!1;debugViewQuads;debugTextures;renderContext;_rendererType;_rtFrame;get passType(){return this._rendererType}set passType(e){this._rendererType=e}constructor(){super(),this.debugTextures=[],this.debugViewQuads=[]}setRenderStates(e){if(this._rtFrame=e,e){this.rendererPassState=Re.createRendererPassState(e);let t=e.clone();t.depthLoadOp="load";for(const a of t.rtDescriptors)a.loadOp="load";this.splitRendererPassState=Re.createRendererPassState(t)}this.renderContext=new ps(e)}getRenderContext(e){return this._rtFrame=e,new ps(e)}setIrradiance(e,t){this.rendererPassState.irradianceBuffer=[e,t]}compute(e,t){}render(e,t,a,r=!1){S.cleanCache();let i=e.camera,n=e.scene;this.rendererPassState.camera3D=i;let o=W.instance.getRenderNodes(n,i),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{let f=S.beginCommandEncoder(),h=S.beginRenderPass(f,this.rendererPassState);l.length>0&&h.executeBundles(l),!r&&W.instance.sky&&(S.bindCamera(h,i),W.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,h)),this.drawRenderNodes(e,h,f,o.opaqueList,t),S.endPass(h),S.endCommandEncoder(f)}{let f=S.beginCommandEncoder(),h=S.beginRenderPass(f,this.rendererPassState);c.length>0&&h.executeBundles(c),r||(S.bindCamera(h,i),this.drawRenderNodes(e,h,f,o.transparentList,t)),S.endPass(h),S.endCommandEncoder(f)}}nodeUpload(e,t,a){}occlusionRenderNodeTest(e,t,a){return a?a.occlusionRenderNodeTest(e)>0:!0}renderOp(e,t,a,r,i){}renderTr(e,t,a,r,i){}renderBundleOp(e,t,a,r){let i=W.instance.getOpRenderGroup(e.scene);if(i){let n=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))n.push(o.bundleMap.get(this._rendererType));else{let l=S.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),n.push(c)}}),n}return[]}renderBundleTr(e,t,a,r){let i=W.instance.getTrRenderGroup(e.scene);if(i){let n=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))n.push(o.bundleMap.get(this._rendererType));else{let l=S.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),n.push(c)}}),n}return[]}recordRenderBundleNode(e,t,a,r){S.bindCamera(t,e.camera),S.bindGeometryBuffer(t,a[0].geometry);for(let i=0;i<a.length;++i){let n=a[i];n.transform.worldMatrix.index,n.transform.enable&&n.recordRenderPass2(e,this._rendererType,this.rendererPassState,r,t)}}drawRenderNodes(e,t,a,r,i,n){S.bindCamera(t,e.camera);for(let o=A.setting.render.drawOpMin;o<Math.min(r.length,A.setting.render.drawOpMax);++o){let l=r[o];l.transform.enable&&l.enable&&l.renderPass2(e,this._rendererType,this.rendererPassState,n,t)}}}class Yc extends ma{constructor(){super(),this.passType=H.COLOR}render(e,t,a,r=!1){this.renderContext.clean();let i=e.scene,n=e.camera;le.updateCameraGroup(n),this.rendererPassState.camera3D=n;let o=W.instance.getRenderNodes(i,n),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{this.renderContext.beginOpaqueRenderPass();let f=this.renderContext.encoder;l.length>0&&(W.instance.getOpRenderGroup(i),f.executeBundles(l)),!r&&W.instance.sky&&(S.bindCamera(f,n),W.instance.sky.preInit(this._rendererType)||W.instance.sky.nodeUpdate(e,this._rendererType,this.rendererPassState,a),W.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,f)),o.opaqueList&&(S.bindCamera(f,n),this.drawNodes(e,this.renderContext,o.opaqueList,t,a))}{let f=this.renderContext.encoder;c.length>0&&f.executeBundles(c),!r&&o.transparentList&&(S.bindCamera(f,n),this.drawNodes(e,this.renderContext,o.transparentList,t,a));let h=W.instance.getGraphicList();for(let u=0;u<h.length;u++){const g=h[u];g.nodeUpdate(e,this._rendererType,this.splitRendererPassState,a),g.renderPass2(e,this._rendererType,this.splitRendererPassState,a,f)}this.renderContext.endRenderPass(),Ze.end("ColorPass Draw Transparent")}}drawNodes(e,t,a,r,i){let n=W.instance.getRenderShaderCollect(e);if(n){for(const o of n){let l=o[1];for(const c of l){let f=c[1];if(!f.isDestroyed&&f.preInit(this._rendererType)){f.nodeUpdate(e,this._rendererType,this.rendererPassState,i);break}}}for(let o=A.setting.render.drawOpMin;o<Math.min(a.length,A.setting.render.drawOpMax);++o){let l=a[o];l.transform.enable&&l.enable&&(l.hasMask(De.UI)&&!l.isRecievePostEffectUI||l.isDestroyed||(l.preInit(this._rendererType)||l.nodeUpdate(e,this._rendererType,this.rendererPassState,i),l.renderPass(e,this.passType,this.renderContext)))}}}occlusionRenderNodeTest(e,t,a){return a.zDepthRenderNodeTest(t)>0}}class As{frustumCullingList;zVisibleList;_renderList;static enable=!0;constructor(){this._renderList=new Map}occlusionRenderNodeTest(e){return A.setting.occlusionQuery.enable?this.frustumCullingList?this.frustumCullingList[e]:0:1}zDepthRenderNodeTest(e){return this.zVisibleList?this.zVisibleList[e]:0}update(e,t){}collect(e,t){}renderCommitTesting(e,t){return!0}}class Kr extends Ta{constructor(e,t){super(),this.bufferType=ea.ComputeGPUBuffer,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,e,t,"ComputeGPUBuffer")}}class Xc{clusterBuffer;lightAssignBuffer;assignTableBuffer;clustersUniformBuffer;constructor(e,t){this.clusterBuffer=new Kr(e*2*4),this.clustersUniformBuffer=new ct(10),this.clustersUniformBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.lightAssignBuffer=new Kr(e*t),this.lightAssignBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.assignTableBuffer=new Kr(e*4),this.assignTableBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e,t,a,r,i,n,o,l,c,f){this.clustersUniformBuffer.setFloat("clusterTileX",r),this.clustersUniformBuffer.setFloat("clusterTileY",i),this.clustersUniformBuffer.setFloat("clusterTileZ",n),this.clustersUniformBuffer.setFloat("numLights",o),this.clustersUniformBuffer.setFloat("maxNumLightsPerCluster",l),this.clustersUniformBuffer.setFloat("near",c),this.clustersUniformBuffer.setFloat("far",f),this.clustersUniformBuffer.setFloat("screenWidth",e),this.clustersUniformBuffer.setFloat("screenHeight",t),this.clustersUniformBuffer.setFloat("clusterPix",a),this.clustersUniformBuffer.apply()}}class pt{static clusterTileX=16;static clusterTileY=16;static clusterTileZ=32}let Hc=`
5995
+ `;class it{computes;passShader;constructor(){this.computes=[],this.passShader=new Map}addRenderPass(e,t=-1){let a=this.passShader.get(e.passType)||[];t==-1?a.push(e):a.splice(t,-1,e),this.passShader.set(e.passType,a)}removeShader(e,t=-1){let a=this.passShader.get(e.passType);if(a)if(t==-1){let r=a.indexOf(e);r!=-1&&a.splice(r)}else a.splice(t,1)}removeShaderByIndex(e,t=-1){let a=this.passShader.get(e);a&&(t==-1?this.passShader.delete(e):a.splice(t,1))}getSubShaders(e){return this.passShader.get(e)||[]}hasSubShaders(e){return this.passShader.get(e).length>0}getDefaultShaders(){return this.passShader.get(H.COLOR)}getDefaultColorShader(){return this.passShader.get(H.COLOR)[0]}setDefine(e,t){for(const a of this.passShader)for(const r of a[1])r.setDefine(e,t)}hasDefine(e){for(const t of this.passShader)for(const a of t[1]){let r=a.hasDefine(e);if(r)return r}return!1}deleteDefine(e){for(const t of this.passShader)for(const a of t[1])a.deleteDefine(e)}setUniform(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniform(e,t)}setUniformFloat(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformFloat(e,t)}setUniformVector2(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformVector2(e,t)}setUniformVector3(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformVector3(e,t)}setUniformVector4(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformVector4(e,t)}setUniformColor(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformColor(e,t)}getUniform(e){return this.getDefaultColorShader().getUniform(e)}getUniformFloat(e){return this.getDefaultColorShader().getUniformFloat(e)}getUniformVector2(e){return this.getDefaultColorShader().getUniformVector2(e)}getUniformVector3(e){return this.getDefaultColorShader().getUniformVector3(e)}getUniformVector4(e){return this.getDefaultColorShader().getUniformVector4(e)}getUniformColor(e){return this.getDefaultColorShader().getUniformColor(e)}setTexture(e,t){for(const a of this.passShader)for(const r of a[1])r.setTexture(e,t);this.setDefine(`USE_${e.toLocaleUpperCase()}`,!0)}getTexture(e){return this.getDefaultColorShader().textures[e]}setUniformBuffer(e,t){for(const a of this.passShader)for(const r of a[1])r.setUniformBuffer(e,t)}getUniformBuffer(e){return this.getDefaultColorShader().getBuffer(e)}setStorageBuffer(e,t){for(const a of this.passShader)for(const r of a[1])r.setStorageBuffer(e,t)}getStorageBuffer(e){return this.getDefaultColorShader().getBuffer(e)}setStructStorageBuffer(e,t){for(const a of this.passShader)for(const r of a[1])r.setStructStorageBuffer(e,t)}getStructStorageBuffer(e){return this.getDefaultColorShader().getBuffer(e)}noticeValueChange(){for(const e of this.passShader)for(const t of e[1])t.noticeValueChange()}destroy(e){for(const t of this.passShader)for(const a of t[1])a.destroy(e);this.passShader.clear(),this.passShader=null,this.computes=null}clone(){let e=new it,t=this.getDefaultShaders();for(const a of t)e.addRenderPass(a);return e}applyUniform(){for(const e of this.passShader)for(const t of e[1])t.applyUniform()}}var zu=Object.getOwnPropertyDescriptor,Ju=(s,e,t,a)=>{for(var r=a>1?void 0:a?zu(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.GSplatShader=class extends it{constructor(){super();const e=new Ne("gsplat_vs_dc","gsplat_fs_dc");e.passType=H.COLOR,e.setShaderEntry("VertMain","FragMain"),e.topology=zn.triangle_list,e.depthWriteEnabled=!1,e.cullMode=Ft.none,e.shaderState.transparent=!0,e.shaderState.blendMode=te.NORMAL,e.shaderState.writeMasks=[15,15],e.shaderState.castReflection=!1,this.addRenderPass(e),this.setDefault()}setDefault(){const e=this.getDefaultColorShader(),t=new R;e.setUniform("modelMatrix",t.rawData),e.setUniform("pixelCull",new Float32Array([2,0,0,0]))}},d.GSplatShader=Ju([Qa(d.GSplatShader,"GSplatShader")],d.GSplatShader);class Ec extends ut{_pixelCullArray=new Float32Array(4);constructor(){super(),J.register("gsplat_vs_dc",Fc),J.register("gsplat_fs_dc",kc),this.shader=new d.GSplatShader}setSplatTextures(e,t,a,r,i){const n=this.shader.getDefaultColorShader();n.setTexture("splatColor",e),n.setTexture("transformA",t),n.setTexture("transformB",a),n.setUniformArray("tex_params",r),i&&n.setTexture("splatOrder",i),n.shaderState.depthCompare=$e.less}setTransformMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}setPixelCulling(e,t,a=0,r=128){this._pixelCullArray[0]=e,this._pixelCullArray[1]=t,this._pixelCullArray[2]=a,this._pixelCullArray[3]=r,this.shader.getDefaultColorShader().setUniform("pixelCull",this._pixelCullArray)}}class ln extends Ta{node;constructor(e){super(),this.bufferType=ea.VertexGPUBuffer,this.createVertexBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,e)}createVertexBuffer(e,t){let a=E.device;this.byteSize=t*Float32Array.BYTES_PER_ELEMENT,this.usage=e,this.buffer&&this.destroy(),this.buffer=a.createBuffer({label:"VertexGPUBuffer",size:this.byteSize,usage:e,mappedAtCreation:!1}),this.memory=new Xa,this.memoryNodes=new Map,this.memory.allocation(this.byteSize),this.node=this.memory.allocation_node(this.byteSize)}}var bt=(s=>(s[s.split=0]="split",s[s.compose=1]="compose",s[s.compose_bin=2]="compose_bin",s))(bt||{});class Rc{vertexCount=0;vertexGPUBuffer;geometryType=bt.compose;_vertexBufferLayouts;_attributeSlotLayouts;_attributeLocation;constructor(){this._vertexBufferLayouts=[],this._attributeLocation={},this._attributeSlotLayouts=[]}get vertexBufferLayouts(){return this._vertexBufferLayouts}createVertexBuffer(e,t){switch(this.geometryType){case bt.split:this.createSplitVertexBuffer(e,t);break;case bt.compose:this.createComposeVertexBuffer(e,t);break;case bt.compose_bin:this.createComposBinVertexBuffer(e,t);break}}createSplitVertexBuffer(e,t){let a=0;for(let r=0;r<t.attributes.length;r++){const i=t.attributes[r];if(i.name=="index")continue;this._attributeLocation[i.name]=i.location;let n={name:i.name,format:i.format,offset:0,shaderLocation:i.location,stride:Ka[i.format]};this._attributeSlotLayouts[i.location]=[n];let o=e.get(i.name);o||(o={attribute:i.name,data:new Float32Array(i.size*this.vertexCount)},e.set(i.name,o));let l=o.data.length/n.stride;this.vertexCount!=0&&this.vertexCount!=l&&console.error(" vertex count not match attribute count"),this.vertexCount=l,this._vertexBufferLayouts[i.location]={name:i.name,arrayStride:i.size*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[i.location],offset:a*4,size:this.vertexCount*i.size*4},a+=this.vertexCount*i.size}this.vertexGPUBuffer=new ln(a)}createComposeVertexBuffer(e,t){this._attributeSlotLayouts[0]=[];let a=0;for(let r=0;r<t.attributes.length;r++){const i=t.attributes[r];if(i.name=="index"||i.type=="builtin")continue;this._attributeLocation[i.name]=i.location;let n={name:i.name,format:i.format,offset:a*4,shaderLocation:i.location,stride:Ka[i.format]};this._attributeSlotLayouts[0][i.location]=n;let o=e.get(i.name);if(o||(o={attribute:i.name,data:new Float32Array(i.size*this.vertexCount)},e.set(i.name,o)),o.data){let l=o.data.length/n.stride;this.vertexCount!=0&&this.vertexCount!=l&&console.error(" vertex count not match attribute count"),this.vertexCount=l}a+=i.size}this._vertexBufferLayouts[0]={name:"composeStruct",arrayStride:a*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[0],offset:0,size:this.vertexCount*a*4},this.vertexGPUBuffer=new ln(this.vertexCount*a)}createComposBinVertexBuffer(e,t){this._attributeSlotLayouts[0]=[];let a=0;for(let n=0;n<t.attributes.length;n++){const o=t.attributes[n];if(o.name=="index"||o.type=="builtin")continue;this._attributeLocation[o.name]=o.location;let l={name:o.name,format:o.format,offset:a*4,shaderLocation:o.location,stride:Ka[o.format]};this._attributeSlotLayouts[0][o.location]=l;let c=e.get(o.name);if(c||(c={attribute:o.name,data:new Float32Array(o.size*this.vertexCount)},e.set(o.name,c)),c.data){let f=c.data.length/l.stride;this.vertexCount!=0&&this.vertexCount!=f&&console.error(" vertex count not match attribute count"),this.vertexCount=f}a+=o.size}let i=e.get(V.all).data.length/a;this.vertexCount=i,this._vertexBufferLayouts[0]={name:"composeStruct",arrayStride:a*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[0],offset:0,size:this.vertexCount*a*4},this.vertexGPUBuffer=new ln(this.vertexCount*a)}upload(e,t){if(this.vertexGPUBuffer){switch(this.geometryType){case bt.split:{let a=this._attributeLocation[e],r=this._vertexBufferLayouts[a];this.vertexGPUBuffer.node.setFloat32Array(r.offset/4,t.data)}break;case bt.compose:for(let a=0;a<this.vertexCount;a++){const r=this._attributeSlotLayouts[0][this._attributeLocation[e]];for(let i=0;i<r.stride;i++){let n=t.data[a*r.stride+i],o=a*(this._vertexBufferLayouts[0].arrayStride/4)+r.offset/4+i;this.vertexGPUBuffer.node.setFloat(n,o)}}break;case bt.compose_bin:this.vertexGPUBuffer.node.setFloat32Array(0,t.data);break}this.vertexGPUBuffer?.apply()}}updateAttributes(e){switch(this.geometryType){case bt.split:for(let t=0;t<this._vertexBufferLayouts.length;t++){const a=this._vertexBufferLayouts[t];let r=e.get(a.name);this.vertexGPUBuffer.node.setFloat32Array(a.offset/4,r.data)}break;case bt.compose:for(let t=0;t<this.vertexCount;t++)this._attributeSlotLayouts.forEach(a=>{for(let r=0;r<a.length;r++){const i=a[r];let n=e.get(i.name);for(let o=0;o<i.stride;o++){let l=n.data[t*i.stride+o],c=t*(this._vertexBufferLayouts[0].arrayStride/4)+i.offset/4+o;this.vertexGPUBuffer.node.setFloat(l,c)}}});break;case bt.compose_bin:{let t=e.get(V.all);this.vertexGPUBuffer.node.setFloat32Array(0,t.data)}break}this.vertexGPUBuffer.apply()}compute(){}destroy(e){this.vertexCount=null,this.geometryType=null,this._vertexBufferLayouts=null,this._attributeSlotLayouts=null,this._attributeLocation=null,this.vertexGPUBuffer&&this.vertexGPUBuffer.destroy(e),this.vertexGPUBuffer=null}}class wc extends Ta{indicesNode;constructor(e){super(),this.bufferType=ea.IndicesGPUBuffer,this.createIndicesBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.INDEX|GPUBufferUsage.INDIRECT,e)}createIndicesBuffer(e,t){let a=E.device;if(this.byteSize=t.length*4,this.usage=e,this.buffer&&this.destroy(),this.buffer=a.createBuffer({label:"IndicesGPUBuffer",size:this.byteSize,usage:e,mappedAtCreation:!1}),this.memory=new Xa,this.memoryNodes=new Map,this.memory.allocation(this.byteSize),t){this.indicesNode=this.memory.allocation_node(t.length*4);const r=t.buffer instanceof ArrayBuffer?t.buffer:new Uint8Array(t.buffer).buffer;this.indicesNode.setArrayBuffer(0,r),this.apply()}}}class Ic{uuid="";name;indicesGPUBuffer;indicesFormat="uint16";indicesCount=0;constructor(){}createIndicesBuffer(e){e.data instanceof Uint16Array?this.indicesFormat="uint16":e.data instanceof Uint32Array&&(this.indicesFormat="uint32"),this.indicesCount=e.data.length,this.indicesGPUBuffer=new wc(e.data)}upload(e){this.indicesGPUBuffer.indicesNode.setArrayBuffer(0,e),this.indicesGPUBuffer.apply()}compute(){}destroy(){this.uuid=null,this.name=null,this.indicesFormat=null,this.indicesCount=null,this.indicesGPUBuffer.destroy(),this.indicesGPUBuffer=null}}class Qc{lodLevels}class Fe{instanceID;name;subGeometries=[];morphTargetsRelative;morphTargetDictionary;skinNames;bindPose;blendShapeData;vertexDim;vertexCount=0;_bounds;_attributeMap;_attributes;_indicesBuffer;_vertexBuffer;_onChange=!0;_wireframeLines;_isDestroyed=!1;constructor(){this.instanceID=xt(),this._attributeMap=new Map,this._attributes=[],this._vertexBuffer=new Rc}get indicesBuffer(){return this._indicesBuffer}get vertexBuffer(){return this._vertexBuffer}get vertexAttributes(){return this._attributes}get vertexAttributeMap(){return this._attributeMap}get geometryType(){return this._vertexBuffer.geometryType}set geometryType(e){this._vertexBuffer.geometryType=e}get bounds(){if(!this._bounds){this._bounds=new ge(new b,new b(1,1,1)),this._bounds.min.x=Number.MAX_VALUE,this._bounds.min.y=Number.MAX_VALUE,this._bounds.min.z=Number.MAX_VALUE,this._bounds.max.x=-Number.MAX_VALUE,this._bounds.max.y=-Number.MAX_VALUE,this._bounds.max.z=-Number.MAX_VALUE;let e=this.getAttribute(V.position);if(e&&e.data)for(let t=0;t<e.data.length/3;t++){const a=e.data[t*3+0],r=e.data[t*3+1],i=e.data[t*3+2];this._bounds.min.x>a&&(this._bounds.min.x=a),this._bounds.min.y>r&&(this._bounds.min.y=r),this._bounds.min.z>i&&(this._bounds.min.z=i),this._bounds.max.x<a&&(this._bounds.max.x=a),this._bounds.max.y<r&&(this._bounds.max.y=r),this._bounds.max.z<i&&(this._bounds.max.z=i)}this._bounds.setFromMinMax(this._bounds.min,this._bounds.max)}return this._bounds}set bounds(e){this._bounds=e}addSubGeometry(...e){let t=new Qc;return t.lodLevels=e,this.subGeometries.push(t),t}generate(e){this._onChange&&(this._onChange=!1,this._indicesBuffer.upload(this.getAttribute(V.indices).data),this._vertexBuffer.createVertexBuffer(this._attributeMap,e),this._vertexBuffer.updateAttributes(this._attributeMap),this.vertexCount=this._vertexBuffer.vertexCount)}setIndices(e){if(!this._attributeMap.has(V.indices)){let t={attribute:V.indices,data:e};this._attributeMap.set(V.indices,t),this._indicesBuffer=new Ic,this._indicesBuffer.createIndicesBuffer(t)}}setAttribute(e,t){if(e==V.indices)this.setIndices(t);else{let a={attribute:e,data:t};this._attributeMap.set(e,a),this._attributes.push(e)}}getAttribute(e){return this._attributeMap.get(e)}hasAttribute(e){return this._attributeMap.has(e)}genWireframe(){if(this._wireframeLines)return this._wireframeLines;if(this.geometryType==bt.split||this.geometryType==bt.compose){let e=this.getAttribute(V.position),t=this.getAttribute(V.indices);if(t&&e&&t.data.length>0){let a=e.data,r=[];for(let i=0;i<t.data.length/3;i++){const n=t.data[i*3+0],o=t.data[i*3+1],l=t.data[i*3+2];let c=new b(a[n*3+0],a[n*3+1],a[n*3+2]),f=new b(a[o*3+0],a[o*3+1],a[o*3+2]),h=new b(a[l*3+0],a[l*3+1],a[l*3+2]);r.push(c,f),r.push(f,h),r.push(h,c)}return this._wireframeLines=r,r}}else if(this.geometryType==bt.compose_bin){let e=this.getAttribute(V.all),t=this.vertexDim,a=this.getAttribute(V.indices);if(a&&e&&a.data.length>0){let r=e.data,i=[];for(let n=0;n<a.data.length/3;n++){const o=a.data[n*3+0],l=a.data[n*3+1],c=a.data[n*3+2];let f=new b(r[o*t+0],r[o*t+1],r[o*t+2]),h=new b(r[l*t+0],r[l*t+1],r[l*t+2]),u=new b(r[c*t+0],r[c*t+1],r[c*t+2]);i.push(f,h),i.push(h,u),i.push(u,f)}return this._wireframeLines=i,i}}return null}compute(){this._indicesBuffer&&this._indicesBuffer.compute(),this._vertexBuffer&&this._vertexBuffer.compute()}static crossA=b.UP.clone();static crossB=b.UP.clone();static crossRet=b.UP.clone();static point1=b.UP.clone();static point2=b.UP.clone();static point3=b.UP.clone();computeNormals(){let e=this.getAttribute(V.position),t=this.getAttribute(V.normal),a=this.getAttribute(V.indices);if(!e||!t||!a)return this;let r=a.data.length/3,i=Fe.point1,n=Fe.point2,o=Fe.point3,l=Fe.crossA,c=Fe.crossB,f=Fe.crossRet;for(let h=0;h<r;h++){let u=a.data[h*3],g=a.data[h*3+1],p=a.data[h*3+2];i.set(e.data[u*3],e.data[u*3+1],e.data[u*3+2]),n.set(e.data[g*3],e.data[g*3+1],e.data[g*3+2]),o.set(e.data[p*3],e.data[p*3+1],e.data[p*3+2]),b.sub(i,n,l).normalize(),b.sub(i,o,c).normalize();let m=l.crossProduct(c,f).normalize();t.data[u*3]=t.data[g*3]=t.data[p*3]=m.x,t.data[u*3+1]=t.data[g*3+1]=t.data[p*3+1]=m.y,t.data[u*3+2]=t.data[g*3+2]=t.data[p*3+2]=m.z}return this._vertexBuffer.upload(V.normal,t),this}isPrimitive(){return!1}destroy(e){this._isDestroyed||(this.instanceID=null,this.name=null,this.subGeometries=null,this.morphTargetDictionary=null,this.skinNames=null,this.bindPose=null,this.blendShapeData=null,this._wireframeLines=null,this._bounds&&(this._bounds.destroy(),this._bounds=null),this._attributeMap&&(this._attributeMap.forEach(t=>{t&&t.data&&(t.data=null)}),this._attributeMap.clear(),this._attributeMap=null),this._attributes=null,this._indicesBuffer&&(this._indicesBuffer.destroy(),this._indicesBuffer=null),this._vertexBuffer&&(this._vertexBuffer.destroy(),this._vertexBuffer=null),this._isDestroyed=!0)}}class Tc extends Fe{batchSize;constructor(e=128){super(),this.batchSize=e;const t=new Float32Array(12*e);for(let r=0;r<e;++r)t.set([-2,-2,r,2,-2,r,2,2,r,-2,2,r],r*12);const a=new Uint32Array(6*e);for(let r=0;r<e;++r){const i=r*4;a.set([0+i,1+i,2+i,0+i,2+i,3+i],r*6)}this.setAttribute(V.position,t),this.setIndices(a),this.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:t.length/3,firstStart:0,index:0,topology:0})}}class ds extends Xe{_dataBuffer;create(e,t,a,r=!1){let i=E.device;const n=Math.ceil(e*4/256)*256;this.format=Y.rgba8unorm,this.mipmapCount=Math.floor(r?Math.log2(e):1),this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const o=this._dataBuffer=i.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(o,0,a);const l=S.beginCommandEncoder();return l.copyBufferToTexture({buffer:o,bytesPerRow:n},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(l),r&&aa.webGPUGenerateMipmap(this),this}updateTexture(e,t,a){let r=E.device;const i=Math.ceil(e*4/256)*256;this.mipmapCount=Math.floor(Math.log2(e)),this._dataBuffer&&this._dataBuffer.destroy(),this._dataBuffer=null;const n=this._dataBuffer=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(n,0,a);const o=S.beginCommandEncoder();o.copyBufferToTexture({buffer:n,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(o),this.gpuSampler=r.createSampler(this),this.mipmapCount>1&&aa.webGPUGenerateMipmap(this)}}class Mc extends Xe{_dataBuffer;create(e,t,a){let r=E.device;const i=e*4*4;this.format=Y.rgba32uint,this.createTextureDescriptor(e,t,1,this.format);const o=this._dataBuffer=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,a.buffer);const l=r.createCommandEncoder();return l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),r.queue.submit([l.finish()]),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="uint",this.gpuSampler=r.createSampler({}),this}updateTexture(e,t,a){let r=E.device;const i=e*4*4;r.queue.writeTexture({texture:this.getGPUTexture()},a.buffer,{bytesPerRow:i},{width:e,height:t,depthOrArrayLayers:1})}}class Nc extends Xe{_dataBuffer;create(e,t,a){let r=E.device;const i=e*4;this.format=Y.r32uint,this.createTextureDescriptor(e,t,1,this.format);const o=this._dataBuffer=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,a.buffer);const l=r.createCommandEncoder();return l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),r.queue.submit([l.finish()]),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="uint",this.gpuSampler=r.createSampler({}),this}updateTexture(e,t,a){let r=E.device;const i=e*4;r.queue.writeTexture({texture:this.getGPUTexture()},a.buffer,{bytesPerRow:i},{width:e,height:t,depthOrArrayLayers:1})}}const Pc=new Float32Array(1),Wu=new Int32Array(Pc.buffer);let ar=function(s){Pc[0]=s;const e=Wu[0];let t=e>>16&32768,a=e>>12&2047;const r=e>>23&255;return r<103?t:r>142?(t|=31744,t|=(r==255?1:0)&&e&8388607,t):r<114?(a|=2048,t|=(a>>114-r)+(a>>113-r&1),t):(t|=r-112<<10|a>>1,t+=a&1,t)};class hs extends Xe{uint16Array;floatArray;_dataBuffer;create(e,t,a=null,r=!0){if(a==null){a=[];for(let i=0,n=e*t*4;i<n;i++)a[i]=0}return this.updateTexture(e,t,a,r),this}updateTexture(e,t,a,r=!0){(e!=this.width||t!=this.height)&&(this._dataBuffer&&this._dataBuffer.destroy(),this._dataBuffer=null,this.gpuTexture&&this.gpuTexture.destroy(),this.gpuTexture=null),this.floatArray=a;let i=E.device;const n=e*4*2;this.format=Y.rgba16float,this.mipmapCount=Math.floor(r?Math.log2(e):1),this.createTextureDescriptor(e,t,this.mipmapCount,this.format),(!this.uint16Array||this.uint16Array.length!=a.length)&&(this.uint16Array=new Uint16Array(a.length));let o=this.uint16Array;for(let f=0,h=o.length;f<h;f++)o[f]=ar(a[f]);const l=this._dataBuffer=i.createBuffer({size:o.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(l,0,o);const c=S.beginCommandEncoder();c.copyBufferToTexture({buffer:l,bytesPerRow:n},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),this.useMipmap||(this.samplerBindingLayout.type="filtering",this.textureBindingLayout.sampleType="float"),S.endCommandEncoder(c),this.gpuSampler=i.createSampler(this),this.gpuTexture=this.getGPUTexture(),this.mipmapCount>1&&aa.webGPUGenerateMipmap(this)}}var ju=Object.getOwnPropertyDescriptor,Zu=(s,e,t,a)=>{for(var r=a>1?void 0:a?ju(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.GSplatRenderer=class extends Oa{count=0;size=new K;splatColor;transformA;transformB;texParams;splatOrder;gsplatMaterial;_positions;get positions(){return this._positions}_worldPositions;_orderData;_sortWorker;_lastSentTime=0;_minIntervalMs=16;_centersSent=!1;_lastViewMatrixHash=0;_lastCameraSpeed=0;_adaptiveSorting=!0;_lastPixelCullParams="";_texturesInitialized=!1;_lodEnabled=!1;_lodDistances=[5,10,20,40];_lodRatios=[1,.75,.5,.25,.1];_currentLodLevel=0;_minPixelCoverage=4;_maxPixelCoverage=0;_maxPixelCullDistance=0;_mapping=null;_fullCount=0;get fullCount(){return this._fullCount}_batchSize=128;instanceCount=0;constructor(){super()}initAsset(e){this.count=e.count,this._fullCount=e.count,this.size=this.evalTextureSize(e.count),this.buildColor(e),this.buildTransform(e),this.texParams=new Float32Array([this.count,this.size.x,this.count,1]),this._positions=e.position;const t=this.size.x*this.size.y;this._orderData=new Uint32Array(t);for(let a=0;a<t;a++)this._orderData[a]=a<this.count?a:this.count>0?this.count-1:0;this.splatOrder=new Nc().create(this.size.x,this.size.y,this._orderData),this.splatOrder.name="splatOrder",this.splatOrder.minFilter="nearest",this.splatOrder.magFilter="nearest",this.splatOrder.addressModeU="clamp-to-edge",this.splatOrder.addressModeV="clamp-to-edge",this.gsplatMaterial=new Ec,this.geometry=new Tc(this._batchSize),this.materials=[this.gsplatMaterial],this.instanceCount=0}onBeforeUpdate(e){this.count>0&&e?.camera&&(this._lodEnabled&&this.updateLOD(e),e.camera.viewMatrix&&this.scheduleOrder(e.camera.viewMatrix))}updateLOD(e){if(!this._worldPositions||this._fullCount===0)return;const a=e.camera.viewMatrix.rawData,r=-(a[0]*a[12]+a[1]*a[13]+a[2]*a[14]),i=-(a[4]*a[12]+a[5]*a[13]+a[6]*a[14]),n=-(a[8]*a[12]+a[9]*a[13]+a[10]*a[14]);let o=0,l=0,c=0;const f=Math.min(100,this._fullCount);for(let D=0;D<f;D++){const _=Math.floor(D/f*this._fullCount)*3;o+=this._worldPositions[_+0],l+=this._worldPositions[_+1],c+=this._worldPositions[_+2]}o/=f,l/=f,c/=f;const h=r-o,u=i-l,g=n-c,p=Math.sqrt(h*h+u*u+g*g);let m=this._lodDistances.length;for(let D=0;D<this._lodDistances.length;D++)if(p<this._lodDistances[D]){m=D;break}if(m!==this._currentLodLevel){this._currentLodLevel=m;const D=this._lodRatios[m],_=Math.floor(this._fullCount*D);if(this._mapping){const B=this._mapping;this._mapping=new Uint32Array(Math.min(_,B.length));for(let v=0;v<this._mapping.length;v++)this._mapping[v]=B[v];this.setMapping(this._mapping)}else this.count=_,this.texParams[0]=this.count,this.texParams[2]=this.count}}setMapping(e){this._mapping=e&&e.length>0?e:null,this.count=this._mapping?this._mapping.length:this._fullCount,this.texParams[0]=this.count,this.texParams[2]=Math.min(this.texParams[0],this.count);const t=this.size.x*this.size.y;for(let a=0;a<t;a++)this._orderData[a]=a<this.count?a:this.count>0?this.count-1:0;if(this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData),this._sortWorker){const a=this._worldPositions||this._positions,r=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(a);if(this._mapping)for(let i=0;i<this._mapping.length;++i){const n=this._mapping[i]*3,o=i*3;r[o+0]=a[n+0],r[o+1]=a[n+1],r[o+2]=a[n+2]}this._sortWorker.postMessage({type:"centers",centers:r.buffer,mapping:this._mapping?this._mapping:null},[r.buffer]),this._centersSent=!0}else this._centersSent=!1;this.instanceCount=0}setVisBoost(e){this.texParams[3]=Math.max(0,e)}setSortThrottle(e){this._minIntervalMs=Math.max(0,e|0)}setAdaptiveSorting(e){this._adaptiveSorting=e}setLOD(e,t,a){this._lodEnabled=e,t&&(this._lodDistances=t),a&&(this._lodRatios=a)}getLODStats(){return{enabled:this._lodEnabled,currentLevel:this._currentLodLevel,distances:this._lodDistances,ratios:this._lodRatios,currentRatio:this._lodRatios[this._currentLodLevel],visibleCount:this._lodEnabled?Math.floor(this._fullCount*this._lodRatios[this._currentLodLevel]):this._fullCount}}setPixelCulling(e,t=0,a=0){this._minPixelCoverage=Math.max(0,e),this._maxPixelCoverage=Math.max(0,t),this._maxPixelCullDistance=Math.max(0,a)}getPixelCullingStats(){return{minPixels:this._minPixelCoverage,maxPixels:this._maxPixelCoverage,maxPixelCullDistance:this._maxPixelCullDistance,maxEnabled:this._maxPixelCoverage>0,distanceEnabled:this._maxPixelCullDistance>0}}getBatchingStats(){return{enabled:!0,batchSize:this._batchSize,instanceCount:this.instanceCount,splatCount:this.count,reduction:this.count>0?(1-this.instanceCount/this.count)*100:0}}evalTextureSize(e){let t=Math.ceil(Math.sqrt(e));const a=64;t=Math.ceil(t/a)*a;const r=Math.ceil(e/t);return new K(t,r)}buildColor(e){const t=this.size.x|0,a=this.size.y|0,r=new Uint8Array(t*a*4),i=.28209479177387814,n=e.count,o=e.sh?.coeffs,l=o?o.length/(3*n):1;for(let c=0;c<n;c++){let f=.5,h=.5,u=.5;if(o&&l>=1){const m=c*l*3;f=.5+o[m+0]*i,h=.5+o[m+l+0]*i,u=.5+o[m+2*l+0]*i}const g=e.opacity?1/(1+Math.exp(-e.opacity[c])):1,p=c*4;r[p+0]=Math.max(0,Math.min(255,Math.floor(f*255))),r[p+1]=Math.max(0,Math.min(255,Math.floor(h*255))),r[p+2]=Math.max(0,Math.min(255,Math.floor(u*255))),r[p+3]=Math.max(0,Math.min(255,Math.floor(g*255)))}this.splatColor=new ds().create(t,a,r,!1),this.splatColor.name="splatColor",this.splatColor.minFilter="nearest",this.splatColor.magFilter="nearest",this.splatColor.mipmapFilter="nearest",this.splatColor.addressModeU="clamp-to-edge",this.splatColor.addressModeV="clamp-to-edge"}buildTransform(e){const t=this.size.x|0,a=this.size.y|0,r=e.count,i=new Uint32Array(t*a*4),n=new Array(t*a*4).fill(0),o=new ArrayBuffer(4),l=new Float32Array(o),c=new Uint32Array(o),f=p=>(l[0]=p,c[0]),h=e.position,u=e.rotation,g=e.scale;for(let p=0;p<r;p++){const m=p*4,D=h[p*3+0],_=h[p*3+1],B=h[p*3+2];i[m+0]=f(D),i[m+1]=f(_),i[m+2]=f(B);let v=0,C=0,y=0,F=1;if(u){v=u[p*4+0],C=u[p*4+1],y=u[p*4+2],F=u[p*4+3];const $t=1/Math.hypot(v,C,y,F);v*=$t,C*=$t,y*=$t,F*=$t}let k=1,w=1,x=1;g&&(k=Math.exp(g[p*3+0]),w=Math.exp(g[p*3+1]),x=Math.exp(g[p*3+2]));const M=v+v,N=C+C,Q=y+y,G=v*M,X=v*N,ne=v*Q,q=C*N,he=C*Q,Be=y*Q,ae=F*M,ee=F*N,se=F*Q,Ae=1-(q+Be),Ue=X+se,Se=ne-ee,Te=X-se,ve=1-(G+Be),Me=he+ae,Ut=ne+ee,ya=he-ae,Ca=1-(G+q),It=Ae*k,Qt=Ue*k,Gt=Se*k,Ct=Te*w,Sa=ve*w,xa=Me*w,Fa=Ut*x,ka=ya*x,Ea=Ca*x,gr=It*It+Ct*Ct+Fa*Fa,Ra=It*Qt+Ct*Sa+Fa*ka,Ir=It*Gt+Ct*xa+Fa*Ea,mr=Qt*Qt+Sa*Sa+ka*ka,Qr=Qt*Gt+Sa*xa+ka*Ea,Tr=Gt*Gt+xa*xa+Ea*Ea,wa=m;n[wa+0]=gr,n[wa+1]=Ra,n[wa+2]=Ir,n[wa+3]=Tr;const Mr=ar(mr)&65535,Za=ar(Qr)&65535;i[m+3]=Mr|Za<<16}this.transformA=new Mc().create(t,a,i),this.transformA.name="transformA",this.transformA.minFilter="nearest",this.transformA.magFilter="nearest",this.transformA.addressModeU="clamp-to-edge",this.transformA.addressModeV="clamp-to-edge",this.transformB=new hs().create(t,a,n,!1),this.transformB.name="transformB",this.transformB.minFilter="nearest",this.transformB.magFilter="nearest",this.transformB.mipmapFilter="nearest",this.transformB.addressModeU="clamp-to-edge",this.transformB.addressModeV="clamp-to-edge"}updateWorldPositions(){if(!this._positions)return;const e=this.object3D.transform.worldMatrix,t=this._positions,a=this._fullCount;this._worldPositions||(this._worldPositions=new Float32Array(t.length));const r=e.rawData;for(let i=0;i<a;i++){const n=i*3,o=t[n+0],l=t[n+1],c=t[n+2];this._worldPositions[n+0]=r[0]*o+r[4]*l+r[8]*c+r[12],this._worldPositions[n+1]=r[1]*o+r[5]*l+r[9]*c+r[13],this._worldPositions[n+2]=r[2]*o+r[6]*l+r[10]*c+r[14]}this._centersSent=!1}scheduleOrder(e){if(this.count===0)return;const t=this.object3D.transform.localChange;(t||!this._worldPositions)&&this.updateWorldPositions();const a=e.rawData,r=a[2],i=a[6],n=a[10],o=-(a[0]*a[12]+a[1]*a[13]+a[2]*a[14]),l=-(a[4]*a[12]+a[5]*a[13]+a[6]*a[14]),c=-(a[8]*a[12]+a[9]*a[13]+a[10]*a[14]),f=performance.now(),h=(f-this._lastSentTime)/1e3,u=Math.floor(o*1e3)^Math.floor(l*1e3)^Math.floor(c*1e3),g=Math.floor(r*1e3)^Math.floor(i*1e3)^Math.floor(n*1e3),p=u^g;if(p===this._lastViewMatrixHash&&!t)return;let m=this._minIntervalMs;if(this._adaptiveSorting&&this._minIntervalMs>0){const _=Math.abs(p-this._lastViewMatrixHash)/Math.max(h,.001);_<1e3?m=this._minIntervalMs:_<1e4?m=this._minIntervalMs*.5:m=this._minIntervalMs*.2,this._lastCameraSpeed=_}if(!(f-this._lastSentTime<m)){if(this._lastViewMatrixHash=p,this._lastSentTime=f,!this._sortWorker){this._sortWorker=this.createSortWorker(),this._sortWorker.onmessage=v=>{const C=v.data.order,y=this._orderData.buffer;this._sortWorker.postMessage({order:y},[y]);const F=new Uint32Array(C),k=this.size.x*this.size.y,w=this.count;(!this._orderData||this._orderData.length!==k)&&(this._orderData=new Uint32Array(k));const x=Math.min(w,F.length);if(this._orderData.set(F.subarray(0,x),0),x<k){const Q=w>0?w-1:0;this._orderData.fill(Q,x,k)}this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData);const M=Math.max(0,Math.min(this.count,v.data.count|0));this.texParams[2]=M;const N=Math.ceil(M/this._batchSize);this.instanceCount=N};const D=this._worldPositions||this._positions,_=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(D);if(this._mapping)for(let v=0;v<this._mapping.length;++v){const C=this._mapping[v]*3,y=v*3;_[y+0]=D[C+0],_[y+1]=D[C+1],_[y+2]=D[C+2]}const B=new Uint32Array(this.count);for(let v=0;v<this.count;v++)B[v]=v;this._sortWorker.postMessage({order:B.buffer,centers:_.buffer,mapping:this._mapping},[B.buffer,_.buffer]),this._centersSent=!0}if(!this._centersSent&&this._sortWorker){const D=this._worldPositions||this._positions,_=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(D);if(this._mapping)for(let B=0;B<this._mapping.length;++B){const v=this._mapping[B]*3,C=B*3;_[C+0]=D[v+0],_[C+1]=D[v+1],_[C+2]=D[v+2]}this._sortWorker.postMessage({type:"centers",centers:_.buffer,mapping:this._mapping?this._mapping:null},[_.buffer]),this._centersSent=!0}this._sortWorker.postMessage({cameraPosition:{x:o,y:l,z:c},cameraDirection:{x:-r,y:-i,z:-n}})}}createSortWorker(){function e(){let o,l,c,f,h,u=!1;const g={x:0,y:0,z:0},p={x:0,y:0,z:0},m={x:0,y:0,z:0},D={x:0,y:0,z:0};let _,B;const v=(y,F,k)=>{for(;y<=F;){const w=F+y>>1,x=k(w);if(x>0)y=w+1;else if(x<0)F=w-1;else return w}return~y},C=()=>{if(!o||!l||!f||!h)return;const y=f.x,F=f.y,k=f.z,w=h.x,x=h.y,M=h.z,N=.001;if(!u&&Math.abs(y-g.x)<N&&Math.abs(F-g.y)<N&&Math.abs(k-g.z)<N&&Math.abs(w-p.x)<N&&Math.abs(x-p.y)<N&&Math.abs(M-p.z)<N)return;u=!1,g.x=y,g.y=F,g.z=k,p.x=w,p.y=x,p.z=M;const Q=l.length/3;_?.length!==Q&&(_=new Uint32Array(Q));let G,X;for(let ee=0;ee<8;++ee){const se=(ee&1?m.x:D.x)-y,Ae=(ee&2?m.y:D.y)-F,Ue=(ee&4?m.z:D.z)-k,Se=se*w+Ae*x+Ue*M;ee===0?G=X=Se:(G=Math.min(G,Se),X=Math.max(X,Se))}B?B.fill(0):B=new Uint32Array(65537);const ne=X-G,q=ne<1e-6?0:1/ne*2**16;for(let ee=0;ee<Q;++ee){const se=ee*3,Ae=l[se+0]-y,Ue=l[se+1]-F,Se=l[se+2]-k,Te=Ae*w+Ue*x+Se*M,ve=Math.floor((Te-G)*q);_[ee]=ve,B[ve]++}for(let ee=1;ee<65537;ee++)B[ee]+=B[ee-1];for(let ee=0;ee<Q;ee++){const se=_[ee],Ae=--B[se];o[Ae]=ee}const he=ee=>_[o[ee]]/q+G,Be=()=>{const ee=v(0,Q-1,se=>-he(se));return Math.min(Q,Math.abs(ee))},ae=he(Q-1)>=0?Be():Q;if(c)for(let ee=0;ee<Q;++ee)o[ee]=c[o[ee]];self.postMessage({order:o.buffer,count:ae},[o.buffer]),o=null};self.onmessage=y=>{if(y.data.order&&(o=new Uint32Array(y.data.order)),y.data.centers){l=new Float32Array(y.data.centers),m.x=D.x=l[0],m.y=D.y=l[1],m.z=D.z=l[2];const F=l.length/3;for(let k=1;k<F;++k){const w=l[k*3+0],x=l[k*3+1],M=l[k*3+2];m.x=Math.min(m.x,w),m.y=Math.min(m.y,x),m.z=Math.min(m.z,M),D.x=Math.max(D.x,w),D.y=Math.max(D.y,x),D.z=Math.max(D.z,M)}u=!0}y.data.hasOwnProperty("mapping")&&(c=y.data.mapping?new Uint32Array(y.data.mapping):null,u=!0),y.data.cameraPosition&&(f=y.data.cameraPosition),y.data.cameraDirection&&(h=y.data.cameraDirection),C()}}const t=`(${e.toString()})()`,a=new Blob([t],{type:"application/javascript"}),r=URL.createObjectURL(a);return new Worker(r)}nodeUpdate(e,t,a,r){const i=this.object3D.transform.worldMatrix;this.gsplatMaterial.setTransformMatrix(i);const n=`${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;n!==this._lastPixelCullParams&&(this.gsplatMaterial.setPixelCulling(this._minPixelCoverage,this._maxPixelCoverage,this._maxPixelCullDistance,this._batchSize),this._lastPixelCullParams=n),this._texturesInitialized||(this.gsplatMaterial.setSplatTextures(this.splatColor,this.transformA,this.transformB,this.texParams,this.splatOrder),this._texturesInitialized=!0),super.nodeUpdate(e,t,a,r)}renderPass(e,t,a){const r=a.encoder;for(let i of this.materials){const n=i.getPass(t);if(!(!n||n.length===0))for(const o of n){if(!o.pipeline)continue;o.apply(this.geometry,a.rendererPassState||a),S.bindPipeline(r,o),S.bindGeometryBuffer(r,this.geometry);const c=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?S.drawIndexed(r,c.indexCount,this.instanceCount,c.indexStart,0,0):S.drawIndexed(r,c.indexCount,1,c.indexStart,0,0)}}}destroy(e){this._sortWorker&&(this._sortWorker.terminate(),this._sortWorker=null),this.splatColor&&(this.splatColor.destroy(e),this.splatColor=null),this.transformA&&(this.transformA.destroy(e),this.transformA=null),this.transformB&&(this.transformB.destroy(e),this.transformB=null),this.splatOrder&&(this.splatOrder.destroy(e),this.splatOrder=null),this._positions=null,this._worldPositions=null,this._orderData=null,this.texParams=null,this._mapping=null,super.destroy(e)}},d.GSplatRenderer=Zu([Mt(d.GSplatRenderer,"GSplatRenderer")],d.GSplatRenderer);class us{static maxVector=new b(Number.MAX_VALUE*.1,Number.MAX_VALUE*.1,Number.MAX_VALUE*.1);static minVector=this.maxVector.clone().multiplyScalar(-1);static genMeshMaxVector=b.ZERO.clone();static genMeshMinVector=b.ZERO.clone();static genMeshVectorList8=[new b,new b,new b,new b,new b,new b,new b,new b];static genGSplatBounds(e,t){t||=new ge(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let a=e.getComponents(d.GSplatRenderer);if(!a)return console.warn("genGSplatBounds: No GSplatRenderer found on object"),t;for(const r of a){const i=r.positions,n=r.fullCount;if(!i||n===0)return console.warn("genGSplatBounds: No position data available"),t;const o=r.object3D.transform.worldMatrix,l=new b;for(let c=0;c<n;c++){const f=c*3;l.set(i[f+0],i[f+1],i[f+2]),o.transformPoint(l,l),t.expandByPoint(l)}t.setFromMinMax(t.min,t.max)}return t}static genMeshBounds(e,t){let a=this.genMeshMinVector,r=this.genMeshMaxVector,i=this.genMeshVectorList8;t||=new ge(b.ZERO,b.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let n=e.getComponents(d.MeshRenderer);for(const o of n)if(o&&o.geometry){let l=o.object3D.transform.worldMatrix;a.copy(o.geometry.bounds.min),r.copy(o.geometry.bounds.max),i[0].set(a.x,a.y,a.z),i[1].set(a.x,a.y,r.z),i[2].set(a.x,r.y,a.z),i[3].set(a.x,r.y,r.z),i[4].set(r.x,a.y,a.z),i[5].set(r.x,a.y,r.z),i[6].set(r.x,r.y,a.z),i[7].set(r.x,r.y,r.z);for(const c of i)l.transformPoint(c,c),t.expandByPoint(c)}return r.copyFrom(t.max),a.copyFrom(t.min),t.setFromMinMax(a,r),t}static transformBound(e,t,a){let r=this.genMeshMinVector.copyFrom(t.min),i=this.genMeshMaxVector.copyFrom(t.max),n=this.genMeshVectorList8;a||=new ge(b.ZERO,b.ZERO),a.setFromMinMax(this.maxVector,this.minVector),n[0].set(r.x,r.y,r.z),n[1].set(r.x,r.y,i.z),n[2].set(r.x,i.y,r.z),n[3].set(r.x,i.y,i.z),n[4].set(i.x,r.y,r.z),n[5].set(i.x,r.y,i.z),n[6].set(i.x,i.y,r.z),n[7].set(i.x,i.y,i.z);for(const o of n)e.transformPoint(o,o),a.expandByPoint(o);return i.copyFrom(a.max),r.copyFrom(a.min),a.setFromMinMax(r,i),a}}class Vc extends Ia{name="";_instanceID="";_numChildren;get instanceID(){return this._instanceID}transform;renderNode;entityChildren;components;waitDisposeComponents;_bound;_boundWorld;_isBoundChange=!0;_dispose=!1;get dispose(){return this._dispose}getObjectByName(e){if(e.indexOf("/")>=0){let a=e.split("/"),r=this;for(;a.length>0&&r;){let i=a.shift();if(r=r.getChildByName(i,!1),!r)return null}return r}else return this.getChildByName(e,!1)}constructor(){super(),this.entityChildren=[],this.components=new Map,this._instanceID=Ln().toString(),this.waitDisposeComponents=[]}get numChildren(){return this._numChildren}addChild(e){if(e==null)throw new Error("child is null!");if(e===this)throw new Error("child is self!");return this.entityChildren.indexOf(e)==-1?(e.removeFromParent(),e.transform.parent=this.transform,this.entityChildren.push(e),this._numChildren=this.entityChildren.length,this.noticeComponents("onAddChild",e),e):null}removeChild(e){if(e===null)return;if(e===this)throw new Error("add child is self!");let t=this.entityChildren.indexOf(e);t!=-1&&(this.entityChildren.splice(t,1),e.transform.parent=null,this._numChildren=this.entityChildren.length,this.noticeComponents("onRemoveChild",e))}removeAllChild(){for(;this.numChildren>0;)this.removeChild(this.entityChildren[0])}removeSelf(){return this.removeFromParent()}removeChildByIndex(e){e>=0&&e<this.entityChildren.length?this.removeChild(this.entityChildren[e]):console.error("remove child by index , index out of range")}hasChild(e){return this.entityChildren.indexOf(e)!=-1}removeFromParent(){let e=this.transform.parent;return e&&e.object3D&&e.object3D.removeChild(this),this}getChildByIndex(e){let t=null;return e<this.entityChildren.length&&(t=this.entityChildren[e]),t}getChildByName(e,t=!0){let a=null;for(const r of this.entityChildren){if(r.name==e)return a=r,a;if(t&&(a=r.getChildByName(e,t),a))return a}return a}update(){}instantiate(){return null}onTransformLocalChange(e){this._isBoundChange=!0}get bound(){return(this._isBoundChange||!this._bound)&&this.updateBound(),this._boundWorld}set bound(e){this._bound=e,this._boundWorld=this._bound.clone(),this._isBoundChange=!0}updateBound(){return this._bound||(this._bound=new ge,this._boundWorld=this._bound.clone(),this._isBoundChange=!0),this._isBoundChange&&(us.transformBound(this.transform.worldMatrix,this._bound,this._boundWorld),this._isBoundChange=!1),this._boundWorld}waitUpdate(){this._dispose?(this.transform.parent&&this.transform.parent.object3D.removeChild(this),this.components.forEach((e,t)=>{e.enable=!1,e.beforeDestroy(),e.destroy()}),this.components.clear()):ye.waitStartComponent.forEach((e,t)=>{for(;e.length>0;){const a=e.shift();a.__start(),ye.waitStartComponent.delete(a.object3D)}})}noticeComponents(e,t){for(let a of this.components.values())a[e]?.(t)}destroy(e){this._dispose||(this.components.forEach(t=>{t.beforeDestroy(e)}),this.components.forEach(t=>{t.destroy(e)}),this.components.clear(),this.components.clear(),this.entityChildren&&(this.entityChildren.forEach(t=>{t.destroy(e)}),this.removeAllChild(),this.entityChildren=[]),this._bound&&this._bound.destroy&&(this._bound.destroy(),this._bound=null),this._boundWorld&&this._boundWorld.destroy&&(this._boundWorld.destroy(),this._boundWorld=null),this.transform.parent=null,this._dispose=!0,super.destroy())}}var Yu=Object.getOwnPropertyDescriptor,Xu=(s,e,t,a)=>{for(var r=a>1?void 0:a?Yu(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.Object3D=class extends Vc{_isScene3D;prefabRef;serializeTag;constructor(){super(),this.transform=this.addComponent(kt),this.transform.eventDispatcher.addEventListener(kt.LOCAL_ONCHANGE,this.onTransformLocalChange,this)}get isScene3D(){return this._isScene3D}forChild(e){this.entityChildren.forEach(t=>{e(t),t.forChild(e)})}addComponent(e,t){if(!this.components.has(e)){let a=new e;return a.object3D=this,this.components.set(e,a),a.__init(t),ye.appendWaitStart(a),a}return this.components.get(e)}getOrAddComponent(e){let t=this.components.get(e);return t||(t=this.addComponent(e)),t}removeComponent(e){if(this.components.has(e)){let t=this.components.get(e);ye.removeWaitStart(this,t),this.components.delete(e),t.__stop(),t.beforeDestroy(),t.destroy()}}hasComponent(e){return this.components.has(e)}getComponent(e){return this.components.get(e)}getComponentFromParent(e){if(!this.parent)return null;let t=this.parent.object3D.getComponent(e);return t||this.parent.object3D.getComponentFromParent(e)}getComponentsInChild(e){let t=[],a=this.components.get(e);a&&t.push(a);for(let r=0;r<this.entityChildren.length;r++){let n=this.entityChildren[r].getComponentsInChild(e);t.push(...n)}return t}getComponents(e,t,a){t||=[];let r=this.getComponent(e);r&&(r.enable||a)&&t.push(r);for(let i=0,n=this.entityChildren.length;i<n;i++){let o=this.entityChildren[i];o&&o instanceof d.Object3D&&o.getComponents(e,t,a)}return t}getComponentsExt(e,t,a){t||=[];let r=this.components.get(e);if(r&&(r.enable||a))t.push(r);else for(const i of this.entityChildren)i instanceof d.Object3D&&i.getComponentsExt(e,t,a);return t}getComponentsByProperty(e,t,a=!0,r,i){r||=[];let n;for(const o of this.components.values())o&&(o.enable||i)&&o[e]===t&&(r.push(o),n=!0);if(!(n&&a))for(const o of this.entityChildren)o instanceof d.Object3D&&o.getComponentsByProperty(e,t,a,r,i);return r}clone(){return this.instantiate()}instantiate(){let e=new d.Object3D;return e.name=this.name,e.serializeTag=this.serializeTag,e.prefabRef=this.prefabRef,this.entityChildren.forEach((t,a)=>{let r=t.instantiate();e.addChild(r)}),this.components.forEach((t,a)=>{t.cloneTo(e)}),e}get localPosition(){return this.transform.localPosition}set localPosition(e){this.transform.localPosition=e}get localRotation(){return this.transform.localRotation}set localRotation(e){this.transform.localRotation=e}get localScale(){return this.transform.localScale}set localScale(e){this.transform.localScale=e}get localQuaternion(){return this.transform.localRotQuat}set localQuaternion(e){this.transform.localRotQuat=e}notifyChange(){this.transform.notifyChange()}get parent(){return this.transform.parent}get parentObject(){return this.transform.parent.object3D}set x(e){this.transform.x=e}get x(){return this.transform.x}set y(e){this.transform.y=e}get y(){return this.transform.y}set z(e){this.transform.z=e}get z(){return this.transform.z}set scaleX(e){this.transform.scaleX=e}get scaleX(){return this.transform.scaleX}set scaleY(e){this.transform.scaleY=e}get scaleY(){return this.transform.scaleY}set scaleZ(e){this.transform.scaleZ=e}get scaleZ(){return this.transform.scaleZ}set rotationX(e){this.transform.rotationX=e}get rotationX(){return this.transform.rotationX}set rotationY(e){this.transform.rotationY=e}get rotationY(){return this.transform.rotationY}set rotationZ(e){this.transform.rotationZ=e}get rotationZ(){return this.transform.rotationZ}fixedUpdate(){}lateUpdate(){}traverse(e){e(this);for(let t=0,a=this.entityChildren.length;t<a;t++){let r=this.entityChildren[t];r instanceof d.Object3D&&r.traverse(e)}}destroy(e){this.transform.eventDispatcher.removeEventListener(kt.LOCAL_ONCHANGE,this.onTransformLocalChange,this);const t=this.batchTable;t&&typeof t.destroy=="function"&&(t.destroy(),this.batchTable=null);const a=this.featureTable;a&&typeof a.destroy=="function"&&(a.destroy(),this.featureTable=null),super.destroy(e)}},d.Object3D=Xu([Hu],d.Object3D);function Hu(s,e){return class extends d.Object3D{set active(t){this.transform.enable=t>0}get active(){return this.transform.enable?1:0}get materialColor(){return this.getComponent(d.MeshRenderer)?.material?.shader.getDefaultColorShader().baseColor}set materialColor(t){let a=this.getComponent(d.MeshRenderer)?.material;a&&(a.shader.getDefaultColorShader().baseColor=t)}notifyMaterialColorChange(t,a){this.getComponent(d.MeshRenderer).materials?.[t]?.shader.getDefaultColorShader().uniforms[a].onChange()}}}class He{static createCamera3DObject(e,t){return this.createCamera3D(null,e,t)}static createCamera3D(e,t,a){return e||=new d.Object3D,t&&t.addChild(e),a&&(e.name=a),e.getOrAddComponent(Zr)}static UnProjection(e,t,a=1,r){let i=new b(e,t,0),n=1,o=b.HELP_0,l=E.canvas.offsetLeft,c=E.canvas.offsetTop,f=E.canvas.clientWidth,h=E.canvas.clientHeight;o.x=((i.x-l)*n/f-.5)*2,o.y=-((i.y-c)*n/h-.5)*2,o.z=a;let u=new b(0,0,0),g=R.helpMatrix2;g.copyFrom(r.projectionMatrix),g.invert();let p=R.helpMatrix;return p.identity(),p.multiply(g),p.multiply(r.transform.worldMatrix),p.perspectiveMultiplyPoint3(o,u),u}static Projection(e,t,a){let r=a||new b(0,0,0),i=R.helpMatrix;i.copyFrom(t.viewMatrix),i.multiply(t.projectionMatrix),i.perspectiveMultiplyPoint3(e,r);let n=E.canvas.clientWidth/2,o=E.canvas.clientHeight/2;return r.x=r.x*n+n,r.y=o-r.y*o,r}static UnProjection2(e,t,a,r,i){let n=i||new b(0,0,0),o=R.helpMatrix;o.copyFrom(r.pvMatrixInv);let l=E.canvas.clientWidth/2,c=E.canvas.clientHeight/2;return n.x=(e-l)/l,n.y=(c-t)/c,n.z=a,o.perspectiveMultiplyPoint3(n,n),n}}class Et{static maxNumDirectionShadow=8;static maxNumPointShadow=8;static directionLightList;static pointLightList;static shadowLights;static init(){this.directionLightList=new Map,this.pointLightList=new Map,this.shadowLights=new Map}static createBuffer(e){if(!this.shadowLights.has(e.scene)){let t=new Float32Array(16);this.shadowLights.set(e.scene,t)}}static getShadowLightList(e){if(!e.transform.view3D)return null;if(e.lightData.lightType==Ye.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);return t||(t=[],this.directionLightList.set(e.transform.view3D.scene,t)),t}else if(e.lightData.lightType==Ye.PointLight){let t=this.pointLightList.get(e.transform.view3D.scene);return t||(t=[],this.pointLightList.set(e.transform.view3D.scene,t)),t}else if(e.lightData.lightType==Ye.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);return t||(t=[],this.pointLightList.set(e.transform.view3D.scene,t)),t}}static getShadowLightWhichScene(e,t){if(t==Ye.DirectionLight){let a=this.directionLightList.get(e);return a||(a=[],this.directionLightList.set(e,a)),a}else if(t==Ye.PointLight){let a=this.pointLightList.get(e);return a||(a=[],this.pointLightList.set(e,a)),a}}static getDirectShadowLightWhichScene(e){let t=this.directionLightList.get(e);return t||(t=[],this.directionLightList.set(e,t)),t}static getPointShadowLightWhichScene(e){let t=this.pointLightList.get(e);return t||(t=[],this.pointLightList.set(e,t)),t}static addShadowLight(e){if(!e.transform.view3D)return null;let t=e.transform.view3D.scene;if(e.lightData.lightType==Ye.DirectionLight){let a=this.directionLightList.get(t);if(a||(a=[],this.directionLightList.set(t,a)),!e.shadowCamera){e.shadowCamera=He.createCamera3DObject(null,"shadowCamera"),e.shadowCamera.isShadowCamera=!0;let r=-1e3;e.shadowCamera.orthoOffCenter(r,-r,r,-r,1,1e4)}return a.indexOf(e)==-1&&a.push(e),a}else if(e.lightData.lightType==Ye.PointLight||e.lightData.lightType==Ye.SpotLight){let a=this.pointLightList.get(t);return a&&a.length>=8||(a||(a=[],this.pointLightList.set(t,a)),a.indexOf(e)==-1&&a.push(e)),a}}static removeShadowLight(e){if(e.lightData.castShadowIndex=-1,!e.transform.view3D)return null;if(e.lightData.lightType==Ye.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);if(t){let a=t.indexOf(e);a!=-1&&t.splice(a,1)}return e.lightData.castShadowIndex=-1,t}else if(e.lightData.lightType==Ye.PointLight||e.lightData.lightType==Ye.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);if(t){let a=t.indexOf(e);a!=-1&&t.splice(a,1)}return e.lightData.castShadowIndex=-1,t}}static update(e){let t=this.shadowLights.get(e.scene),a=Et.directionLightList.get(e.scene),r=Et.pointLightList.get(e.scene),i=0,n=0,o=0,l=0;if(t.fill(0),a){let f=0;for(let h=0;h<a.length;h++){const u=a[h];t[h]=u.lightData.index,u.lightData.castShadowIndex=f++}n=a.length}if(r){o=n;let f=0;for(let h=o;h<r.length;h++){const u=r[h];t[h]=u.lightData.index,u.lightData.castShadowIndex=f++}l=o+r.length}le.getAllCameraGroup().forEach(f=>{f.dirShadowStart=i,f.dirShadowEnd=n,f.pointShadowStart=o,f.pointShadowEnd=l,f.shadowLights.set(new Float32Array(t))})}}class bs{uuid;usage;globalBindGroup;uniformGPUBuffer;matrixBindGroup;uniformByteLength;matrixesByteLength;shadowMatrixRaw=new Float32Array(128);csmMatrixRaw=new Float32Array(Jt.Cascades*16);csmShadowBias=new Float32Array(4);shadowLights=new Float32Array(16);dirShadowStart=0;dirShadowEnd=0;pointShadowStart=0;pointShadowEnd=0;constructor(e){this.uuid=xt(),this.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.uniformGPUBuffer=new ct(8336),this.uniformGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBindGroup=e,this.createBindGroup()}createBindGroup(){this.uniformByteLength=this.uniformGPUBuffer.memory.shareDataBuffer.byteLength,this.matrixesByteLength=R.block*4*R.maxCount,this.globalBindGroup=E.device.createBindGroup({label:"global_bindGroupLayout",layout:is.getGlobalDataBindGroupLayout(),entries:[{binding:0,resource:{buffer:this.uniformGPUBuffer.buffer,offset:0,size:this.uniformByteLength}},{binding:1,resource:{buffer:this.matrixBindGroup.matrixBufferDst.buffer,offset:0,size:this.matrixesByteLength}}]})}setCamera(e){this.uniformGPUBuffer.setMatrix("_projectionMatrix",e.projectionMatrix),this.uniformGPUBuffer.setMatrix("_viewMatrix",e.viewMatrix),this.uniformGPUBuffer.setMatrix("_cameraWorldMatrix",e.transform.worldMatrix),this.uniformGPUBuffer.setMatrix("pvMatrixInv",e.projectionMatrixInv),this.uniformGPUBuffer.setMatrix("viewToWorld",e.cameraToWorld);let t=Et.getDirectShadowLightWhichScene(e.transform.scene3D);this.csmShadowBias.fill(1e-4),this.shadowMatrixRaw.fill(0),this.csmMatrixRaw.fill(0);for(let l=0;l<8;l++)if(l<t.length){let c=t[l].shadowCamera;this.shadowMatrixRaw.set(c.pvMatrix.rawData,l*16)}else this.shadowMatrixRaw.set(e.transform.worldMatrix.rawData,l*16);this.uniformGPUBuffer.setFloat32Array("shadowMatrix",this.shadowMatrixRaw);let a=A.setting.shadow.shadowSize;if(Jt.Cascades>1&&e.enableCSM&&t[0])for(let l=0;l<Jt.Cascades;l++){let c=e.csm.children[l].shadowCamera;this.csmMatrixRaw.set(c.pvMatrix.rawData,l*16),this.csmShadowBias[l]=e.getCSMShadowBiasScale(c)}this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights);let r=A.setting.reflectionSetting,i=W.instance.getReflections(e.transform.scene3D).length;this.uniformGPUBuffer.setFloat("reflectionProbeSize",r.reflectionProbeSize),this.uniformGPUBuffer.setFloat("reflectionProbeMaxCount",r.reflectionProbeMaxCount),this.uniformGPUBuffer.setFloat("reflectionMapWidth",r.width),this.uniformGPUBuffer.setFloat("reflectionMapHeight",r.height),this.uniformGPUBuffer.setFloat("reflectionCount",i),this.uniformGPUBuffer.setFloat("test2",Ze.testObj.testValue2),this.uniformGPUBuffer.setFloat("test3",Ze.testObj.testValue3),this.uniformGPUBuffer.setFloat("test4",Ze.testObj.testValue4),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",xe.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",xe.time),this.uniformGPUBuffer.setFloat("delta",xe.delta),this.uniformGPUBuffer.setFloat("shadowBias",e.getShadowBias(a)),this.uniformGPUBuffer.setFloat("skyExposure",A.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",A.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",A.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",A.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",A.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",A.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",A.setting.render.renderState_split);let n=A.inputSystem.mouseX*E.pixelRatio,o=A.inputSystem.mouseY*E.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",n),this.uniformGPUBuffer.setFloat("mouseY",o),this.uniformGPUBuffer.setFloat("windowWidth",E.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",E.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",A.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",a),this.uniformGPUBuffer.setFloat("shadowSoft",A.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",e.enableCSM?1:0),this.uniformGPUBuffer.setFloat("csmMargin",A.setting.shadow.csmMargin),this.uniformGPUBuffer.setInt32("nDirShadowStart",this.dirShadowStart),this.uniformGPUBuffer.setInt32("nDirShadowEnd",this.dirShadowEnd),this.uniformGPUBuffer.setInt32("nPointShadowStart",this.pointShadowStart),this.uniformGPUBuffer.setInt32("nPointShadowEnd",this.pointShadowEnd),this.uniformGPUBuffer.setVector3("cameraForward",e.transform.forward),this.uniformGPUBuffer.setVector4Array("frustumPlanes",e.frustum.planes),this.uniformGPUBuffer.apply()}setShadowCamera(e){this.uniformGPUBuffer.setMatrix("_projectionMatrix",e.projectionMatrix),this.uniformGPUBuffer.setMatrix("_viewMatrix",e.viewMatrix),this.uniformGPUBuffer.setMatrix("_pvMatrix",e.pvMatrix),this.uniformGPUBuffer.setMatrix("pvMatrixInv",e.projectionMatrixInv),this.uniformGPUBuffer.setMatrix("viewToWorld",e.cameraToWorld),this.csmShadowBias.fill(1e-4),this.shadowMatrixRaw.fill(0),this.csmMatrixRaw.fill(0),this.uniformGPUBuffer.setFloat32Array("shadowCamera",this.shadowMatrixRaw),this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",xe.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",xe.time),this.uniformGPUBuffer.setFloat("delta",xe.delta),this.uniformGPUBuffer.setFloat("shadowBias",A.setting.shadow.shadowBias),this.uniformGPUBuffer.setFloat("skyExposure",A.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",A.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",A.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",A.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",A.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",A.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",A.setting.render.renderState_split);let t=A.inputSystem.mouseX*E.pixelRatio,a=A.inputSystem.mouseY*E.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",t),this.uniformGPUBuffer.setFloat("mouseY",a),this.uniformGPUBuffer.setFloat("windowWidth",E.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",E.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",A.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",A.setting.shadow.shadowSize),this.uniformGPUBuffer.setFloat("shadowSoft",A.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",0),this.uniformGPUBuffer.setFloat("csmMargin",A.setting.shadow.csmMargin),this.uniformGPUBuffer.setInt32("nDirShadowStart",this.dirShadowStart),this.uniformGPUBuffer.setInt32("nDirShadowEnd",this.dirShadowEnd),this.uniformGPUBuffer.setInt32("nPointShadowStart",this.pointShadowStart),this.uniformGPUBuffer.setInt32("nPointShadowEnd",this.pointShadowEnd),this.uniformGPUBuffer.apply()}setShadowLight(){}}class Oc{setting;probesBufferData;probesBuffer;isVolumeFrameChange=!0;randomOrientation;startPosition=new b;isVolumeChange=!0;irradianceVolumeBuffer;directionDistance=20;randomSeedCount=3;useRandomIndex=0;centerDirection=new b(0,0,this.directionDistance).normalize(1);arroundPositions=[];updateOrientation(){return this.useRandomIndex++,this.useRandomIndex>=this.arroundPositions.length&&(this.useRandomIndex=0),R.fromToRotation(this.centerDirection,this.arroundPositions[this.useRandomIndex],this.randomOrientation),this.randomOrientation}init(e){this.setting=e,this.randomOrientation=new R(!1),this.randomOrientation.identity(),this.irradianceVolumeBuffer=new ct(80),this.createFramesBuffer(),this.arroundPositions.push(this.centerDirection.clone());for(let t=0;t<this.randomSeedCount;t++){let a=Math.PI*2*t/this.randomSeedCount,r=new b(Math.sin(a),Math.cos(a),this.directionDistance).normalize(1);this.arroundPositions.push(r)}}setVolumeDataChange(){this.isVolumeChange=!0}updateProbes(e){let t=this.probesBufferData;for(let a of e){let r=a.index*4;t[r+3]=a.drawCallFrame}}createFramesBuffer(){if(!this.probesBufferData){let e=this.setting.probeXCount*this.setting.probeYCount*this.setting.probeZCount;this.probesBufferData=new Float32Array(e*4),this.probesBufferData.fill(-1),this.probesBuffer=new _e(e*4,GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST)}}uploadBuffer(){this.isVolumeChange&&(this.fillIrradianceData(),this.isVolumeChange=!1,this.isVolumeFrameChange=!0),this.probesBuffer.setFloat32Array("uniformFramesBuffer",this.probesBufferData)}calcPosition(e,t,a,r){let i=this.setting,n=this.setting.probeSpace;return r=r||new b,r.x=e*n-n*(i.probeXCount-1)*.5+i.offsetX,r.y=t*n-n*(i.probeYCount-1)*.5+i.offsetY,r.z=a*n-n*(i.probeZCount-1)*.5+i.offsetZ,r}debugX=0;debugY=0;debugZ=0;fillIrradianceData(){let e=this.setting,t=this.calcPosition(0,0,0,this.startPosition);this.irradianceVolumeBuffer.setFloat("orientationIndex",this.randomOrientation.index),this.irradianceVolumeBuffer.setFloat("hysteresis",e.hysteresis),this.irradianceVolumeBuffer.setFloat("OctRTSideSize",e.octRTSideSize),this.irradianceVolumeBuffer.setFloat("OctRTMaxSize",e.octRTMaxSize),this.irradianceVolumeBuffer.setFloat("startX",t.x),this.irradianceVolumeBuffer.setFloat("startY",t.y),this.irradianceVolumeBuffer.setFloat("startZ",t.z),this.irradianceVolumeBuffer.setFloat("ProbeSpace",e.probeSpace),this.irradianceVolumeBuffer.setFloat("probeXCount",e.probeXCount),this.irradianceVolumeBuffer.setFloat("probeYCount",e.probeYCount),this.irradianceVolumeBuffer.setFloat("probeZCount",e.probeZCount),this.irradianceVolumeBuffer.setFloat("maxDistance",e.probeSpace*1.732),this.irradianceVolumeBuffer.setFloat("depthSharpness",e.depthSharpness),this.irradianceVolumeBuffer.setFloat("ProbeSourceTextureSize",e.probeSourceTextureSize),this.irradianceVolumeBuffer.setFloat("ProbeSize",e.probeSize),this.irradianceVolumeBuffer.setFloat("bounceIntensity",e.bounceIntensity),this.irradianceVolumeBuffer.setFloat("probeRoughness",e.probeRoughness),this.irradianceVolumeBuffer.setFloat("normalBias",e.normalBias),this.irradianceVolumeBuffer.setFloat("irradianceChebyshevBias",e.irradianceChebyshevBias),this.irradianceVolumeBuffer.setFloat("rayNumber",e.rayNumber),this.irradianceVolumeBuffer.setFloat("irradianceDistanceBias",e.irradianceDistanceBias),this.irradianceVolumeBuffer.setFloat("indirectIntensity",e.indirectIntensity),this.irradianceVolumeBuffer.setFloat("ddgiGamma",e.ddgiGamma),this.irradianceVolumeBuffer.setFloat("lerpHysteresis",e.lerpHysteresis),this.irradianceVolumeBuffer.setFloat("debugX",this.debugX),this.irradianceVolumeBuffer.setFloat("debugY",this.debugY),this.irradianceVolumeBuffer.setFloat("debugZ",this.debugZ),this.irradianceVolumeBuffer.apply()}}class Lc{storageGPUBuffer;irradianceVolume;_lightList=[];constructor(){this.storageGPUBuffer=new _e(tn.lightSize*A.setting.light.maxLight,GPUBufferUsage.COPY_SRC),this.irradianceVolume=new Oc,this.irradianceVolume.init(A.setting.gi);for(let e=0;e<A.setting.light.maxLight;e++){let t=this.storageGPUBuffer.memory.allocation_node(tn.lightSize*4);this._lightList.push(t)}this.storageGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e){this.storageGPUBuffer.clean();let t=W.instance.getLights(e.scene);for(let a=0;a<t.length;a++){const r=t[a].lightData;r.index=a,this.writeLightBytes(r,this._lightList[a])}this.storageGPUBuffer.apply()}writeLightBytes(e,t){t.offset=0,t.writeFloat(e.index),t.writeInt32(e.lightType),t.writeFloat(e.radius),t.writeFloat(e.linear),t.writeVector3(e.lightPosition),t.writeFloat(e.lightMatrixIndex),t.writeVector3(e.direction),t.writeFloat(e.quadratic),t.writeRGBColor(e.lightColor),t.writeFloat(e.intensity),t.writeFloat(e.innerAngle),t.writeFloat(e.outerAngle),t.writeFloat(e.range),t.writeInt32(e.castShadowIndex),t.writeVector3(e.lightTangent),t.writeFloat(e.iesIndex)}}class Gc{storageGPUBuffer;reflectionMap;sourceReflectionMap;count;constructor(){this.storageGPUBuffer=new _e(768)}update(e){this.storageGPUBuffer.clean();let t=W.instance.getReflections(e.scene);for(let a=0;a<t.length;a++){const r=t[a];r.gid=a,this.storageGPUBuffer.setFloat("gid",r.gid),this.storageGPUBuffer.setVector3("worldPosition",r.transform.worldPosition),this.storageGPUBuffer.setFloat("radius",r.radius),this.storageGPUBuffer.setVector3("bound",r.transform.worldPosition)}this.count=t.length,this.storageGPUBuffer.apply()}}class zc extends Ta{size;constructor(e,t=0,a){super(),this.bufferType=ea.StorageGPUBuffer,this.size=e,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|t,e,a,"MatrixGPUBuffer")}writeBufferByHeap(e,t){let a;e instanceof Float64Array?a=new Float32Array(e):a=e;let r=E.device;if(a.length>0){let i=null;for(;this.mapAsyncReady.length&&(i=this.mapAsyncReady.shift(),i.usedSize!=a.byteLength);)i.destroy(),this.mapAsyncBuffersOutstanding--,i=null;i||(i=r.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,mappedAtCreation:!0}),i.usedSize=a.byteLength,this.mapAsyncBuffersOutstanding++,this.mapAsyncBuffersOutstanding>10&&console.warn(` Warning: mapAsync requests from ${this.mapAsyncBuffersOutstanding} frames ago have not resolved yet. MB of staging buffers allocated.`));let n=new Float32Array(a.buffer,a.byteOffset,t);new Float32Array(i.getMappedRange(0,t*4)).set(n),i.unmap();const l=r.createCommandEncoder();l.copyBufferToBuffer(i,0,this.buffer,0,t*4),r.queue.submit([l.finish()]),i.mapAsync(GPUMapMode.WRITE).then(()=>this.mapAsyncReady.push(i))}}}class Jc{uuid;index;usage;groupBufferSize;matrixBufferDst;constructor(){this.uuid=xt(),this.groupBufferSize=0,this.usage=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.cacheWorldMatrix()}cacheWorldMatrix(){this.groupBufferSize=R.maxCount*R.blockBytes,this.matrixBufferDst=new zc(this.groupBufferSize/4),this.matrixBufferDst.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBufferDst.buffer.label=this.groupBufferSize.toString()}writeBuffer(e){const t=R.dynamicMatrixBytes;this.matrixBufferDst.mapAsyncWrite(t,e)}}class le{static _cameraBindGroups;static _lightEntriesMap;static _reflectionEntriesMap;static modelMatrixBindGroup;static init(){this.modelMatrixBindGroup=new Jc,this._cameraBindGroups=new Map,this._lightEntriesMap=new Map,this._reflectionEntriesMap=new Map}static getAllCameraGroup(){return this._cameraBindGroups}static getCameraGroup(e){let t=this._cameraBindGroups.get(e);return t||(t=new bs(this.modelMatrixBindGroup),this._cameraBindGroups.set(e,t)),e.isShadowCamera?t.setShadowCamera(e):t.setCamera(e),t}static updateCameraGroup(e){let t=this._cameraBindGroups.get(e);t||(t=new bs(this.modelMatrixBindGroup),this._cameraBindGroups.set(e,t)),e.isShadowCamera?t.setShadowCamera(e):t.setCamera(e)}static getLightEntries(e){e||console.log("getLightEntries scene is null");let t=this._lightEntriesMap.get(e);return t||(t=new Lc,this._lightEntriesMap.set(e,t)),this._lightEntriesMap.get(e)}static getReflectionEntries(e){e||console.log("getLightEntries scene is null");let t=this._reflectionEntriesMap.get(e);return t||(t=new Gc,this._reflectionEntriesMap.set(e,t)),this._reflectionEntriesMap.get(e)}}class S{static lastGeometry;static lastPipeline;static lastShader;static drawCount=0;static renderPassCount=0;static geometryCount=0;static pipelineCount=0;static matrixCount=0;static lastRenderPassState;static LastCommand;static bindPipeline(e,t){if(S.lastShader!=t)S.lastShader=t;else return!1;S.lastPipeline!=t.pipeline&&(S.lastPipeline=t.pipeline,e.setPipeline(t.pipeline));for(let a=1;a<t.bindGroups.length;a++){const r=t.bindGroups[a];r&&e.setBindGroup(a,r)}return!0}static bindCamera(e,t){let a=le.getCameraGroup(t);e.setBindGroup(0,a.globalBindGroup)}static bindGeometryBuffer(e,t){if(this.lastGeometry!=t&&(this.lastGeometry=t,t.indicesBuffer)){e.setIndexBuffer(t.indicesBuffer.indicesGPUBuffer.buffer,t.indicesBuffer.indicesFormat);let a=t.vertexBuffer.vertexGPUBuffer,r=t.vertexBuffer.vertexBufferLayouts;for(let i=0;i<r.length;i++){const n=r[i];e.setVertexBuffer(i,a.buffer,n.offset,n.size)}}}static cleanCache(){this.lastGeometry=null,this.lastPipeline=null,this.lastShader=null}static createPipeline(e){return Ze.countStart("GPUContext","pipeline"),E.device.createRenderPipeline(e)}static beginCommandEncoder(){return Ze.countStart("GPUContext","beginCommandEncoder"),this.LastCommand&&E.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=E.device.createCommandEncoder(),this.LastCommand}static endCommandEncoder(e){this.LastCommand==e&&(E.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=null,Ze.countStart("GPUContext","endCommandEncoder"))}static recordBundleEncoder(e){return E.device.createRenderBundleEncoder(e)}static beginRenderPass(e,t){if(this.cleanCache(),this.renderPassCount++,this.lastRenderPassState=t,t.depthTexture){let a=t.renderPassDescriptor.depthStencilAttachment;a.view=t.depthTexture.getGPUView()}if(t.renderTargets&&t.renderTargets.length>0){for(let a=0;a<t.renderTargets.length;++a){const r=t.renderTargets[a];let i=t.renderPassDescriptor.colorAttachments[a];t.multisample>0&&t.renderTargets.length==1?(i.view=t.multiTexture.createView(),i.resolveTarget=r.getGPUView()):i.view=r.getGPUTexture().createView()}return e.beginRenderPass(t.renderPassDescriptor)}else{let a=t.renderPassDescriptor.colorAttachments[0];return a&&(t.multisample>0?(a.view=t.multiTexture.createView(),a.resolveTarget=E.context.getCurrentTexture().createView()):a.view=E.context.getCurrentTexture().createView()),e.beginRenderPass(t.renderPassDescriptor)}}static drawIndexed(e,t,a,r,i,n){e.drawIndexed(t,a,r,i,n),this.drawCount++}static draw(e,t,a,r,i){e.draw(t,a,r,i),this.drawCount++}static endPass(e){e.insertDebugMarker("end"),e.end()}static computeCommand(e,t){let a=e.beginComputePass();for(let r=0;r<t.length;r++)t[r].compute(a);a.end()}static copyTexture(e,t,a){e.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:a.width,height:a.height,depthOrArrayLayers:1})}}class Wc{source;input;output;reset(e){this.input&&this.input.destroy(),this.output&&this.output.destroy(),this.input=this.output=null,this.source=e}apply(e){if(this.source){if(!this.input){let t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this.input=new _e(this.source.length,t,this.source),this.input.apply()}if(!this.output){let t=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC;this.output=new _e(e*3,t),this.output.apply()}}}}class jc{enable;morphTargetsRelative;MaxMorphTargetCount=64;_computeConfigArray;_computeConfigBuffer;_morphInfluenceArray;_morphInfluenceBuffer;_positionAttrDataGroup;_normalAttrDataGroup;_isInfluenceDirty;_morphTargetCount;_totalVertexCount;_computeShader;_computeShaders;_computeWorkGroupXY=1;_collectMorphTargetData;_blendTarget;constructor(){this._isInfluenceDirty=!0,this.generateGPUBuffer(),this._positionAttrDataGroup=new Wc,this._normalAttrDataGroup=new Wc}initMorphTarget(e){this._collectMorphTargetData=this.collectMorphTargetList(e),this._computeShader&&this._computeShader.destroy();let t=Nt.CsMain;this._computeShader=new fe(t),this._collectMorphTargetData.mergedNormal?this._computeShader.setDefine("USE_MORPHNORMALS",!0):this._computeShader.deleteDefine("USE_MORPHNORMALS"),this._computeShaders=[this._computeShader],this._isInfluenceDirty=!0,this._morphTargetCount=this._collectMorphTargetData.mtCount,this._totalVertexCount=this._collectMorphTargetData.vCount,this._morphInfluenceArray.fill(0),this._computeWorkGroupXY=this.calcWorkGroup(this._totalVertexCount),this._positionAttrDataGroup.reset(this._collectMorphTargetData.mergedPos),this._normalAttrDataGroup.reset(this._collectMorphTargetData.mergedNormal)}applyRenderShader(e){this.uploadMorphTargetBuffer(),this.uploadConfigGBuffer(),e.setUniformBuffer("morphTargetConfig",this._computeConfigBuffer),e.setStorageBuffer("morphTargetOpPositions",this._positionAttrDataGroup.output),this._collectMorphTargetData.mergedNormal&&e.setStorageBuffer("morphTargetOpNormals",this._normalAttrDataGroup.output)}computeMorphTarget(e){this.uploadConfigGBuffer(),this.uploadMorphTargetBuffer(),this._computeShader.setUniformBuffer("morphTargetConfig",this._computeConfigBuffer),this._computeShader.setStorageBuffer("morphTargetInfluence",this._morphInfluenceBuffer),this._computeShader.setStorageBuffer("morphTargetPositions",this._positionAttrDataGroup.input),this._computeShader.setStorageBuffer("morphTargetOpPositions",this._positionAttrDataGroup.output),this._collectMorphTargetData.mergedNormal&&(this._computeShader.setStorageBuffer("morphTargetNormals",this._normalAttrDataGroup.input),this._computeShader.setStorageBuffer("morphTargetOpNormals",this._normalAttrDataGroup.output)),this._computeShader.workerSizeX=this._computeWorkGroupXY,this._computeShader.workerSizeY=this._computeWorkGroupXY,this._computeShader.workerSizeZ=1,S.computeCommand(e,this._computeShaders)}updateInfluence(e,t){this._isInfluenceDirty=!0,this._morphInfluenceArray[e]=t}get blendShape(){return this._blendTarget}collectMorphTargetList(e){let t=this.collectAttribute("a_morphPositions_",e),a=t.length,r=t[0].data.length/3;if(this._blendTarget={},e.blendShapeData)for(let l=0;l<e.blendShapeData.shapeIndexs.length;l++){let c=e.blendShapeData.shapeIndexs[l],f=e.blendShapeData.shapeNames[l].split("."),h=f[f.length-1];this._blendTarget[h]=u=>this.updateInfluence(c,u)}let i=new Float32Array(r*a*3);{let l=0;for(let c=0;c<a;c++){let f=t[c];i.set(f.data,l),l+=f.data.length}}let n=this.collectAttribute("a_morphNormals_",e),o;if(n&&n.length>0){let l=0;o=new Float32Array(r*a*3);for(let c=0;c<a;c++){let f=n[c];o.set(f.data,l),l+=f.data.length}}return{mtCount:a,vCount:r,mergedPos:i,mergedNormal:o}}collectAttribute(e,t){let a=[];for(let r=0;r<this.MaxMorphTargetCount;r++){let i=e+r,n=t.getAttribute(i);if(n)a[r]=n;else break}return a}uploadConfigGBuffer(){if(this._isInfluenceDirty){let e=0;for(let t=0;t<this._morphTargetCount;t++)e+=this._morphInfluenceArray[t];this._morphInfluenceBuffer.setFloat32Array("data",this._morphInfluenceArray),this._morphInfluenceBuffer.apply(),this._computeConfigArray[0]=this.morphTargetsRelative?1:1-e,this._computeConfigArray[1]=this._morphTargetCount,this._computeConfigArray[2]=this._totalVertexCount,this._computeConfigArray[3]=this._computeWorkGroupXY,this._computeConfigBuffer.setFloat32Array("data",this._computeConfigArray),this._computeConfigBuffer.apply(),this._isInfluenceDirty=!1}}calcWorkGroup(e){let t=Math.ceil(Math.sqrt(e)),a=Math.ceil(Math.log2(t));return t=Math.pow(2,a),t}uploadMorphTargetBuffer(){this._positionAttrDataGroup.output||this._positionAttrDataGroup.apply(this._totalVertexCount),this._normalAttrDataGroup.output||this._normalAttrDataGroup.apply(this._totalVertexCount)}generateGPUBuffer(){this._computeConfigArray=new Float32Array(4),this._computeConfigBuffer=new ct(4),this._morphInfluenceArray=new Float32Array(this.MaxMorphTargetCount);let e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this._morphInfluenceBuffer=new _e(this.MaxMorphTargetCount,e)}destroy(e){this._computeConfigBuffer&&(this._computeConfigBuffer.destroy(e),this._computeConfigBuffer=null),this._morphInfluenceBuffer&&(this._morphInfluenceBuffer.destroy(e),this._morphInfluenceBuffer=null),this._computeShader&&(this._computeShader.destroy(e),this._computeShader=null),this._positionAttrDataGroup&&(this._positionAttrDataGroup.input&&this._positionAttrDataGroup.input.destroy(e),this._positionAttrDataGroup.output&&this._positionAttrDataGroup.output.destroy(e),this._positionAttrDataGroup=null),this._normalAttrDataGroup&&(this._normalAttrDataGroup.input&&this._normalAttrDataGroup.input.destroy(e),this._normalAttrDataGroup.output&&this._normalAttrDataGroup.output.destroy(e),this._normalAttrDataGroup=null),this._computeConfigArray=null,this._morphInfluenceArray=null,this._collectMorphTargetData=null,this._blendTarget=null,this._computeShaders=null}}var Ku=Object.defineProperty,qu=Object.getOwnPropertyDescriptor,gs=(s,e,t,a)=>{for(var r=a>1?void 0:a?qu(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=(a?n(e,t,r):n(r))||r);return a&&r&&Ku(e,t,r),r};d.MeshRenderer=class extends Oa{receiveShadow;morphData;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(e){e.addComponent(d.MeshRenderer).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.receiveShadow=e.receiveShadow,this}get geometry(){return this._geometry}set geometry(e){if(super.geometry=e,e){let t=e.morphTargetDictionary!=null;t&&(this.morphData||=new jc,this.morphData.morphTargetsRelative=e.morphTargetsRelative,this.morphData.initMorphTarget(e)),this.morphData&&(this.morphData.enable=t),this.morphData?.enable?this.addRendererMask(De.MorphTarget):this.removeRendererMask(De.MorphTarget),this.object3D.bound=this._geometry.bounds.clone()}else this.morphData&&(this.morphData.enable=!1),this.removeRendererMask(De.MorphTarget);this._readyPipeline||(this.initPipeline(),this._computes&&(this.onCompute=Ki(this.onCompute,()=>{for(let t=0;t<this._computes.length;t++)this._computes[t].onUpdate()})))}get material(){return this._materials[0]}set material(e){this.materials=[e]}setMorphInfluence(e,t){if(this.morphData&&this.morphData.enable){let a=this._geometry.morphTargetDictionary[e];a>=0&&this.morphData.updateInfluence(a,t)}}setMorphInfluenceIndex(e,t){this.morphData&&this.morphData.enable&&e>=0&&this.morphData.updateInfluence(e,t)}onCompute(e,t){this.morphData&&this.morphData.enable&&this.morphData.computeMorphTarget(t)}nodeUpdate(e,t,a,r){if(this.morphData&&this.morphData.enable)for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(t);if(o)for(let l=0;l<o.length;l++)this.morphData.applyRenderShader(o[l])}super.nodeUpdate(e,t,a,r)}destroy(e){this.morphData&&(this.morphData.destroy(e),this.morphData=null),super.destroy(e)}},gs([zr],d.MeshRenderer.prototype,"geometry",1),gs([zr],d.MeshRenderer.prototype,"material",1),d.MeshRenderer=gs([Mt(d.MeshRenderer,"MeshRenderer")],d.MeshRenderer);class ga{static compressGBufferTex_NAME="compressGBufferTex_NAME";static colorBufferTex_NAME="colorBufferTex";static positionBufferTex_NAME="positionBufferTex";static normalBufferTex_NAME="normalBufferTex";static materialBufferTex_NAME="materialBufferTex";static zBufferTexture_NAME="zBufferTexture";static zPreDepthTexture_NAME="zPreDepthTexture";static outTex_NAME="outTex"}class Zc{label="";customSize=!1;zPreTexture=null;depthTexture=null;renderTargetTextures;outColor=-1;renderTargets;rtTextureDescriptors;irradianceBuffer;multisample=0;multiTexture;depthViewIndex=0;depthCleanValue=0;isOutTarget=!0;camera3D;rtFrame;renderPassDescriptor;renderBundleEncoderDescriptor;depthLoadOp;getLastRenderTexture(){return this.renderTargets&&this.renderTargets.length>0?this.renderTargets[0]:A.res.redTexture}}class gt extends Xe{resolveTarget;sampleCount;autoResize;clear;constructor(e,t,a=Y.rgba8unorm,r=!1,i,n=1,o=0,l=!0,c=!0){super(e,t,n),this.name=xt(),this.autoResize=c,this.useMipmap=r,this.sampleCount=o,this.format=a,this.numberLayer=n,this.clear=l,i!=null?this.usage=i:this.usage=i|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST,this.resize(e,t),this.autoResize&&E.addEventListener(Ya.RESIZE,f=>{let{width:h,height:u}=f.data;this.resize(h,u),this._textureChange=!0},this)}resize(e,t){let a=E.device;this.gpuTexture&&(Xe.delayDestroyTexture(this.gpuTexture),this.gpuTexture=null,this.view=null),this.width=e,this.height=t,this.createTextureDescriptor(e,t,1,this.format,this.usage,this.numberLayer,this.sampleCount),this.useMipmap=!1,this.visibility=GPUShaderStage.COMPUTE|GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,this.format==Y.rgba32float?(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=a.createSampler({})):this.format==Y.depth32float?(this.samplerBindingLayout.type="filtering",this.sampler_comparisonBindingLayout.type="comparison",this.textureBindingLayout.sampleType="depth",this.gpuSampler=E.device.createSampler({}),this.gpuSampler_comparison=E.device.createSampler({compare:"less",label:"sampler_comparison"})):this.format==Y.depth24plus?(this.samplerBindingLayout={type:"filtering"},this.sampler_comparisonBindingLayout={type:"comparison"},this.textureBindingLayout.sampleType="depth",this.gpuSampler=E.device.createSampler({}),this.gpuSampler_comparison=E.device.createSampler({compare:"less",label:"sampler_comparison"})):(this.samplerBindingLayout.type="filtering",this.textureBindingLayout.sampleType="float",this.sampleCount>0&&(this.textureBindingLayout.multisampled=!0),this.minFilter="linear",this.magFilter="linear",this.mipmapFilter="linear",this.addressModeU=Pt.clamp_to_edge,this.addressModeV=Pt.clamp_to_edge,this.gpuSampler=a.createSampler(this)),this._textureChange=!0}create(e,t,a=!0){let r=E.device;const i=e*4;let n=new Float32Array(e*t*4);const o=r.createBuffer({size:n.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});r.queue.writeBuffer(o,0,n);const l=S.beginCommandEncoder();l.copyBufferToTexture({buffer:o,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(l)}clone(){let e=new gt(this.width,this.height,this.format,this.useMipmap,this.usage,this.numberLayer,this.sampleCount,this.clear,this.autoResize);return e.name="clone_"+e.name,e}readTextureToImage(){let e=E.device,t=E.windowWidth,a=E.windowHeight,r=new Float32Array(t*a*4);const i=e.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});return S.beginCommandEncoder().copyTextureToBuffer({texture:this.getGPUTexture()},{buffer:i},[t,a]),i.getMappedRange(0,r.byteLength)}}class ke{storeOp="store";loadOp="clear";clearValue=[0,0,0,0]}class Je{label;customSize=!1;renderTargets;rtDescriptors;zPreTexture;depthTexture;depthViewIndex=0;depthCleanValue=1;depthLoadOp="clear";isOutTarget=!0;constructor(e,t,a,r,i=!0){this.renderTargets=e,this.rtDescriptors=t,this.depthTexture=a,this.zPreTexture=r,this.isOutTarget=i}clone2Frame(e){e.renderTargets.push(...this.renderTargets.concat());for(let t=0;t<this.rtDescriptors.length;t++){const a=this.rtDescriptors[t];let r=new ke;r.loadOp=a.loadOp,r.storeOp=a.storeOp,r.clearValue=a.clearValue,e.rtDescriptors.push(r)}e.depthTexture=this.depthTexture,e.zPreTexture=this.zPreTexture,e.customSize=this.customSize}clone(){let e=new Je([],[]);return this.clone2Frame(e),e}}class oe extends Je{static colorPass_GBuffer="ColorPassGBuffer";static reflections_GBuffer="reflections_GBuffer";static gui_GBuffer="gui_GBuffer";static gBufferMap=new Map;_colorBufferTex;_compressGBufferTex;constructor(){super([],[])}createGBuffer(e,t,a,r=!0,i=!0,n){let o=this.renderTargets,l=this.rtDescriptors;if(i){let f=new ke;f.loadOp="clear",this._colorBufferTex=mt.createRTTexture(e+ga.colorBufferTex_NAME,t,a,Y.rgba16float,!0),o.push(this._colorBufferTex),l.push(f)}this._compressGBufferTex=new gt(t,a,Y.rgba32float,!1,void 0,1,0,!0,!0),o.push(this._compressGBufferTex),n?this.depthTexture=n:(this.depthTexture=new gt(t,a,Y.depth24plus,!1,void 0,1,0,!0,!0),this.depthTexture.name=e+"_depthTexture");let c;c=new ke,l.push(c)}getPositionMap(){return this.renderTargets[1]}getNormalMap(){return this.renderTargets[2]}getColorTexture(){return this._colorBufferTex}getCompressGBufferTexture(){return this._compressGBufferTex}static getGBufferFrame(e,t=0,a=0,r=!0,i){let n;if(oe.gBufferMap.has(e))n=oe.gBufferMap.get(e);else{n=new oe;let o=E.presentationSize;n.createGBuffer(e,t==0?o[0]:t,a==0?o[1]:a,t!=0&&a!=0,r,i),oe.gBufferMap.set(e,n)}return n}static getGUIBufferFrame(){let e=this.getGBufferFrame(this.colorPass_GBuffer);return oe.getGBufferFrame(oe.gui_GBuffer,0,0,!0,e.depthTexture)}clone(){let e=new oe;return this.clone2Frame(e),e}}class Re{static rendererPassState=new Map;static createRendererPassState(e,t=null){let a=Re.rendererPassState.get(e);if(a||(a=new Zc,a.label=e.label,a.customSize=e.customSize,a.rtFrame=e,a.zPreTexture=e.zPreTexture,a.depthTexture=e.depthTexture,a.depthViewIndex=e.depthViewIndex,a.isOutTarget=e.isOutTarget,a.depthCleanValue=e.depthCleanValue,a.depthLoadOp=e.depthLoadOp,Re.rendererPassState.set(e,a)),e&&e.renderTargets.length>0){a.renderTargets=e.renderTargets,a.rtTextureDescriptors=e.rtDescriptors,a.renderPassDescriptor=Re.getRenderPassDescriptor(a),a.renderPassDescriptor.depthStencilAttachment&&(a.renderPassDescriptor.depthStencilAttachment.depthLoadOp=e.depthLoadOp),t=="load"&&e?.renderTargets[0]&&e.renderTargets[0].name.startsWith(oe.gui_GBuffer)&&(a.renderPassDescriptor.colorAttachments[0].loadOp="load"),a.depthLoadOp=e.depthLoadOp,a.renderBundleEncoderDescriptor=Re.getRenderBundleDescriptor(a),a.renderTargetTextures=[];for(let r=0;r<e.renderTargets.length;r++){const i=e.renderTargets[r];a.renderTargetTextures[r]={format:i.format},i.name.indexOf(ga.colorBufferTex_NAME)!=-1&&(a.outColor=r)}}else a.renderPassDescriptor=Re.getRenderPassDescriptor(a,t),a.renderBundleEncoderDescriptor=Re.getRenderBundleDescriptor(a),a.renderTargetTextures=[{format:E.presentationFormat}],a.outColor=0;return a}static getRenderPassDescriptor(e,t=null){if(e.renderPassDescriptor)return e.renderPassDescriptor;E.device,E.presentationSize;let a=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let i=0;i<e.renderTargets.length;i++){const n=e.renderTargets[i],o=e.rtTextureDescriptors[i];a.push({view:n.getGPUView(),resolveTarget:void 0,loadOp:o.loadOp,clearValue:o.clearValue,storeOp:o.storeOp})}}else if(!e.customSize){let i=E.canvasConfig&&E.canvasConfig.alpha?[1,1,1,0]:[0,0,0,1];e.isOutTarget==!0&&a.push({view:void 0,resolveTarget:void 0,loadOp:E.canvasConfig&&E.canvasConfig.alpha||t!=null?"load":"clear",clearValue:i,storeOp:"store"})}let r=null;return e.depthTexture||e.zPreTexture?(e.zPreTexture&&(e.depthTexture=e.zPreTexture),r={label:`${e.label} renderPassDescriptor zPreTexture${e.zPreTexture?"load":"clear"}`,colorAttachments:a,depthStencilAttachment:{view:e.depthTexture.getGPUView(),depthLoadOp:e.zPreTexture?"load":e.depthLoadOp,depthClearValue:e.zPreTexture?1:e.depthCleanValue,depthStoreOp:"store"}}):r={colorAttachments:a,label:"renderPassDescriptor not writeDepth"},e.renderPassDescriptor=r,r}static getRenderBundleDescriptor(e){if(e.renderBundleEncoderDescriptor)return e.renderBundleEncoderDescriptor;E.presentationSize;let t=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let r=0;r<e.renderTargets.length;r++){const i=e.renderTargets[r];t.push(i.format)}}let a=null;return e.depthTexture?a={colorFormats:t,depthStencilFormat:e.depthTexture.format}:a={colorFormats:t},e.renderBundleEncoderDescriptor=a,e.renderBundleEncoderDescriptor}}class Hr extends Fe{width;height;segmentW;segmentH;up;constructor(e,t,a=1,r=1,i=b.Y_AXIS){super(),this.width=e,this.height=t,this.segmentW=a,this.segmentH=r,this.up=i,this.buildGeometry(this.up)}buildGeometry(e){var t,a,r,i,n=this.segmentW+1;(this.segmentH+1)*n,this.bounds=new ge(b.ZERO.clone(),new b(this.width,1,this.height)),r=this.segmentH*this.segmentW*6;let o=(this.segmentW+1)*(this.segmentH+1),l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),h;this.segmentW*this.segmentH*2*3>=Uint16Array.length?h=new Uint32Array(this.segmentW*this.segmentH*2*3):h=new Uint16Array(this.segmentW*this.segmentH*2*3),r=0;for(var g=0,p=0,m=0,D=0;D<=this.segmentH;++D)for(var _=0;_<=this.segmentW;++_){switch(t=(_/this.segmentW-.5)*this.width,a=(D/this.segmentH-.5)*this.height,e){case b.Y_AXIS:l[g++]=t,l[g++]=0,l[g++]=a,c[p++]=0,c[p++]=1,c[p++]=0;break;case b.Z_AXIS:l[g++]=t,l[g++]=-a,l[g++]=0,c[p++]=0,c[p++]=0,c[p++]=1;break;case b.X_AXIS:l[g++]=0,l[g++]=t,l[g++]=a,c[p++]=1,c[p++]=0,c[p++]=0;break;default:l[g++]=t,l[g++]=0,l[g++]=a,c[p++]=0,c[p++]=1,c[p++]=0;break}f[m++]=_/this.segmentW,f[m++]=D/this.segmentH,_!=this.segmentW&&D!=this.segmentH&&(i=_+D*n,h[r++]=i+1,h[r++]=i,h[r++]=i+n,h[r++]=i+1,h[r++]=i+n,h[r++]=i+n+1)}this.setIndices(h),this.setAttribute(V.position,l),this.setAttribute(V.normal,c),this.setAttribute(V.uv,f),this.setAttribute(V.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}var $u=Object.getOwnPropertyDescriptor,e2=(s,e,t,a)=>{for(var r=a>1?void 0:a?$u(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.QuadShader=class extends it{constructor(e="QuadGlsl_vs",t="QuadGlsl_fs"){super();let a=new Ne(e,t);this.addRenderPass(a);let r=a.shaderState;a.blendMode=te.NONE,r.frontFace="cw",r.depthWriteEnabled=!1,r.depthCompare=$e.always,r.multisample=0,this.setTexture("baseMap",A.res.blackTexture),this.setUniformFloat("x",0),this.setUniformFloat("y",0),this.setUniformFloat("width",100),this.setUniformFloat("height",100)}},d.QuadShader=e2([Qa(d.QuadShader,"QuadShader")],d.QuadShader);class ms extends d.Object3D{width=128;height=128;quadRenderer;material;rendererPassState;quadShader;constructor(e="QuadGlsl_vs",t="QuadGlsl_fs",a,r=0,i=!1){super();let n=a?a.renderTargets:[];this.material=new ut,this.quadShader=new d.QuadShader(e,t),this.material.shader=this.quadShader,this.quadRenderer=this.addComponent(d.MeshRenderer),this.quadRenderer.material=this.material,this.quadRenderer.castGI=!1,this.quadRenderer.castShadow=!1,this.quadRenderer.drawType=i?2:0,this.quadRenderer.geometry=new Hr(100,100,1,1),this.quadRenderer.material=this.material,this.quadRenderer.__start(),this.quadRenderer._enable=!0,this.quadRenderer.onEnable(),this.rendererPassState=Re.createRendererPassState(a,"load"),r>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=E.device.createTexture({size:{width:E.presentationSize[0],height:E.presentationSize[1]},sampleCount:r,format:n.length>0?n[0].format:E.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT})),E.addEventListener(Ya.RESIZE,o=>{this.rendererPassState=Re.createRendererPassState(a,"load"),r>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=E.device.createTexture({size:{width:E.presentationSize[0],height:E.presentationSize[1]},sampleCount:r,format:n.length>0?n[0].format:E.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT}))},this)}renderTarget(e,t,a){let r=e.camera,i=S.beginRenderPass(a,t.rendererPassState);S.bindCamera(i,r),t.quadRenderer.nodeUpdate(e,H.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,H.COLOR,t.rendererPassState,null,i),S.endPass(i)}renderToViewQuad(e,t,a,r){let i=e.camera;t.quadShader.setTexture("baseMap",r);let n=S.beginRenderPass(a,t.rendererPassState);S.bindCamera(n,i),t.quadRenderer.nodeUpdate(e,H.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,H.COLOR,t.rendererPassState,null,n),S.endPass(n)}}class mt{static rtTextureMap;static rtViewQuad;static init(){this.rtTextureMap=new Map,this.rtViewQuad=new Map}static createRTTexture(e,t,a,r,i=!1,n=0){let o=this.rtTextureMap.get(e);return o||(e==ga.colorBufferTex_NAME?o=new gt(t,a,r,i,void 0,1,n,!1):o=new gt(t,a,r,i,void 0,1,n,!0),o.name=e,mt.rtTextureMap.set(e,o)),o}static createRTTextureArray(e,t,a,r,i=1,n=!1,o=0){let l=this.rtTextureMap.get(e);return l||(l=new gt(t,a,r,n,void 0,i,o),l.name=e,mt.rtTextureMap.set(e,l)),l}static createViewQuad(e,t,a,r,i=0){let n=new Je([r],[new ke]),o=new ms(t,a,n,i);return mt.rtViewQuad.set(e,o),o}static getTexture(e){return this.rtTextureMap.get(e)}static CreateSplitTexture(e){let t=this.getTexture(ga.colorBufferTex_NAME),a=this.getTexture(e+"_split");return a||(a=this.createRTTexture(e+"_split",t.width,t.height,t.format,!1)),a}static WriteSplitColorTexture(e){let t=this.getTexture(ga.colorBufferTex_NAME),a=this.getTexture(e+"_split");const r=S.beginCommandEncoder();r.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:a.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:a.width,height:a.height,depthOrArrayLayers:1}),S.endCommandEncoder(r)}}class ps{command;encoder;rendererPassStates;rtFrame;constructor(e){this.rtFrame=e,this.rendererPassStates=[]}clean(){this.rendererPassStates.length=0,S.cleanCache()}beginContinueRendererPassState(e="load",t="load"){if(this.rendererPassStates.length>0){let a=this.rtFrame.clone();for(const i of a.rtDescriptors)i.loadOp="load";a.depthLoadOp=t;let r=Re.createRendererPassState(a,e);return this.rendererPassStates.push(r),r}else{this.rtFrame.depthLoadOp=t;let a=Re.createRendererPassState(this.rtFrame,e);return this.rendererPassStates.push(a),a}}get rendererPassState(){return this.rendererPassStates[this.rendererPassStates.length-1]}beginOpaqueRenderPass(){this.beginContinueRendererPassState("clear","clear"),this.begineNewCommand(),this.beginNewEncoder()}beginTransparentRenderPass(){this.beginContinueRendererPassState("load","load"),this.begineNewCommand(),this.beginNewEncoder()}specialtRenderPass(){this.beginContinueRendererPassState("load","load"),this.begineNewCommand(),this.beginNewEncoder()}endRenderPass(){this.endEncoder(),this.endCommand()}begineNewCommand(){return this.command=S.beginCommandEncoder(),this.command}endCommand(){S.endCommandEncoder(this.command),this.command=null}beginNewEncoder(){return this.encoder=S.beginRenderPass(this.command,this.rendererPassState),this.encoder}endEncoder(){S.endPass(this.encoder),this.encoder=null}}class ma extends Ia{rendererPassState;splitRendererPassState;useRenderBundle=!1;debugViewQuads;debugTextures;renderContext;_rendererType;_rtFrame;get passType(){return this._rendererType}set passType(e){this._rendererType=e}constructor(){super(),this.debugTextures=[],this.debugViewQuads=[]}setRenderStates(e){if(this._rtFrame=e,e){this.rendererPassState=Re.createRendererPassState(e);let t=e.clone();t.depthLoadOp="load";for(const a of t.rtDescriptors)a.loadOp="load";this.splitRendererPassState=Re.createRendererPassState(t)}this.renderContext=new ps(e)}getRenderContext(e){return this._rtFrame=e,new ps(e)}setIrradiance(e,t){this.rendererPassState.irradianceBuffer=[e,t]}compute(e,t){}render(e,t,a,r=!1){S.cleanCache();let i=e.camera,n=e.scene;this.rendererPassState.camera3D=i;let o=W.instance.getRenderNodes(n,i),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{let f=S.beginCommandEncoder(),h=S.beginRenderPass(f,this.rendererPassState);l.length>0&&h.executeBundles(l),!r&&W.instance.sky&&(S.bindCamera(h,i),W.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,h)),this.drawRenderNodes(e,h,f,o.opaqueList,t),S.endPass(h),S.endCommandEncoder(f)}{let f=S.beginCommandEncoder(),h=S.beginRenderPass(f,this.rendererPassState);c.length>0&&h.executeBundles(c),r||(S.bindCamera(h,i),this.drawRenderNodes(e,h,f,o.transparentList,t)),S.endPass(h),S.endCommandEncoder(f)}}nodeUpload(e,t,a){}occlusionRenderNodeTest(e,t,a){return a?a.occlusionRenderNodeTest(e)>0:!0}renderOp(e,t,a,r,i){}renderTr(e,t,a,r,i){}renderBundleOp(e,t,a,r){let i=W.instance.getOpRenderGroup(e.scene);if(i){let n=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))n.push(o.bundleMap.get(this._rendererType));else{let l=S.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),n.push(c)}}),n}return[]}renderBundleTr(e,t,a,r){let i=W.instance.getTrRenderGroup(e.scene);if(i){let n=[];return i.renderGroup.forEach(o=>{if(o.bundleMap.has(this._rendererType))n.push(o.bundleMap.get(this._rendererType));else{let l=S.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,o.renderNodes,r);let c=l.finish();o.bundleMap.set(this._rendererType,c),n.push(c)}}),n}return[]}recordRenderBundleNode(e,t,a,r){S.bindCamera(t,e.camera),S.bindGeometryBuffer(t,a[0].geometry);for(let i=0;i<a.length;++i){let n=a[i];n.transform.worldMatrix.index,n.transform.enable&&n.recordRenderPass2(e,this._rendererType,this.rendererPassState,r,t)}}drawRenderNodes(e,t,a,r,i,n){S.bindCamera(t,e.camera);for(let o=A.setting.render.drawOpMin;o<Math.min(r.length,A.setting.render.drawOpMax);++o){let l=r[o];l.transform.enable&&l.enable&&l.renderPass2(e,this._rendererType,this.rendererPassState,n,t)}}}class Yc extends ma{constructor(){super(),this.passType=H.COLOR}render(e,t,a,r=!1){this.renderContext.clean();let i=e.scene,n=e.camera;le.updateCameraGroup(n),this.rendererPassState.camera3D=n;let o=W.instance.getRenderNodes(i,n),l=this.renderBundleOp(e,o,t,a),c=r?[]:this.renderBundleTr(e,o,t,a);{this.renderContext.beginOpaqueRenderPass();let f=this.renderContext.encoder;l.length>0&&(W.instance.getOpRenderGroup(i),f.executeBundles(l)),!r&&W.instance.sky&&(S.bindCamera(f,n),W.instance.sky.preInit(this._rendererType)||W.instance.sky.nodeUpdate(e,this._rendererType,this.rendererPassState,a),W.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,a,f)),o.opaqueList&&(S.bindCamera(f,n),this.drawNodes(e,this.renderContext,o.opaqueList,t,a))}{let f=this.renderContext.encoder;c.length>0&&f.executeBundles(c),!r&&o.transparentList&&(S.bindCamera(f,n),this.drawNodes(e,this.renderContext,o.transparentList,t,a));let h=W.instance.getGraphicList();for(let u=0;u<h.length;u++){const g=h[u];g.nodeUpdate(e,this._rendererType,this.splitRendererPassState,a),g.renderPass2(e,this._rendererType,this.splitRendererPassState,a,f)}this.renderContext.endRenderPass(),Ze.end("ColorPass Draw Transparent")}}drawNodes(e,t,a,r,i){let n=W.instance.getRenderShaderCollect(e);if(n){for(const o of n){let l=o[1];for(const c of l){let f=c[1];if(!f.isDestroyed&&f.preInit(this._rendererType)){f.nodeUpdate(e,this._rendererType,this.rendererPassState,i);break}}}for(let o=A.setting.render.drawOpMin;o<Math.min(a.length,A.setting.render.drawOpMax);++o){let l=a[o];l.transform.enable&&l.enable&&(l.hasMask(De.UI)&&!l.isRecievePostEffectUI||l.isDestroyed||(l.preInit(this._rendererType)||l.nodeUpdate(e,this._rendererType,this.rendererPassState,i),l.renderPass(e,this.passType,this.renderContext)))}}}occlusionRenderNodeTest(e,t,a){return a.zDepthRenderNodeTest(t)>0}}class As{frustumCullingList;zVisibleList;_renderList;static enable=!0;constructor(){this._renderList=new Map}occlusionRenderNodeTest(e){return A.setting.occlusionQuery.enable?this.frustumCullingList?this.frustumCullingList[e]:0:1}zDepthRenderNodeTest(e){return this.zVisibleList?this.zVisibleList[e]:0}update(e,t){}collect(e,t){}renderCommitTesting(e,t){return!0}}class Kr extends Ta{constructor(e,t){super(),this.bufferType=ea.ComputeGPUBuffer,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,e,t,"ComputeGPUBuffer")}}class Xc{clusterBuffer;lightAssignBuffer;assignTableBuffer;clustersUniformBuffer;constructor(e,t){this.clusterBuffer=new Kr(e*2*4),this.clustersUniformBuffer=new ct(10),this.clustersUniformBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.lightAssignBuffer=new Kr(e*t),this.lightAssignBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.assignTableBuffer=new Kr(e*4),this.assignTableBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e,t,a,r,i,n,o,l,c,f){this.clustersUniformBuffer.setFloat("clusterTileX",r),this.clustersUniformBuffer.setFloat("clusterTileY",i),this.clustersUniformBuffer.setFloat("clusterTileZ",n),this.clustersUniformBuffer.setFloat("numLights",o),this.clustersUniformBuffer.setFloat("maxNumLightsPerCluster",l),this.clustersUniformBuffer.setFloat("near",c),this.clustersUniformBuffer.setFloat("far",f),this.clustersUniformBuffer.setFloat("screenWidth",e),this.clustersUniformBuffer.setFloat("screenHeight",t),this.clustersUniformBuffer.setFloat("clusterPix",a),this.clustersUniformBuffer.apply()}}class pt{static clusterTileX=16;static clusterTileY=16;static clusterTileZ=32}let Hc=`
5996
5996
  #include "GlobalUniform"
5997
5997
 
5998
5998
  struct ClusterBox{
@@ -7236,7 +7236,7 @@ $1\r
7236
7236
  `),a=/(\r\n\r\n)/g,e=e.replace(a,`\r
7237
7237
  `),a=/\r\n\,/g,e=e.replace(a,","),t.newlineAfterColonIfBeforeBraceOrBracket||(a=/\:\r\n\{/g,e=e.replace(a,":{"),a=/\:\r\n\[/g,e=e.replace(a,":[")),t.spaceAfterColon&&(a=/\:/g,e=e.replace(a,":")),e.split(`\r
7238
7238
  `).forEach(function(o,l){let c=0,f=0,h="";for(o.match(/\{$/)||o.match(/\[$/)?f=1:o.match(/\}/)||o.match(/\]/)?i!==0&&(i-=1):f=0,c=0;c<i;c++)h+=n;r+=h+o+`\r
7239
- `,i+=f}),r}static compareVersion(e,t){e=e.split("."),t=t.split(".");let a=Math.max(e.length,t.length);for(;e.length<a;)e.push("0");for(;t.length<a;)t.push("0");for(let r=0;r<a;r++){let i=parseInt(e[r]),n=parseInt(t[r]);if(i>n)return 1;if(i<n)return-1}return 0}static buildRandomCode(){let e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",t=e.length,a="";for(let i=0;i<26;i++){let n=Math.floor(Math.random()*t);a+=e.charAt(n)}return`${new Date().getTime()}-${a}`}static UUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,a=e=="x"?t:t&3|8;return a.toString(16)})}static stringToHash(e){let t=0;if(e.length==0)return t;for(let a=0;a<e.length;a++){const r=e.charCodeAt(a);t=(t<<5)-t+r,t=t&t}return t}static parseUrl(e,t){return t.match(/^(blob|http|https):/)?t:e+t}}class La extends Xe{_source;premultiplyAlpha="none";constructor(e=!0){super(),this.useMipmap=e,this.lodMinClamp=0,this.lodMaxClamp=4}get source(){return this._source}set source(e){this._source=e,this._source instanceof HTMLImageElement?this._source.decode().then(async()=>{if(this._source instanceof HTMLImageElement){const t=await createImageBitmap(this._source,{imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:"none"});this.generate(t)}}):(this._source instanceof HTMLCanvasElement||this._source instanceof ImageBitmap)&&this.generate(this._source)}async load(e,t){if(this.name=yt.getURLName(e),e.indexOf(";base64")!=-1){const a=document.createElement("img");let r=e.indexOf("data:image"),i=e.substring(r,e.length);a.src=i,await a.decode(),a.width=Math.max(a.width,32),a.height=Math.max(a.height,32);const n=await createImageBitmap(a,{resizeWidth:a.width,resizeHeight:a.height,imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:"none"});this.format=Y.rgba8unorm,this.generate(n)}else return new Promise((a,r)=>{fetch(e,{headers:Object.assign({Accept:"image/avif,image/webp,*/*"},t?.headers)}).then(i=>{yr.read(e,i,t).then(n=>{let o=new Blob([n],{type:"image/jpeg"});n=null,this.loadFromBlob(o).then(()=>{a(!0)})})})});return!0}imageData;async loadFromBlob(e){this.imageData=e;let t=await createImageBitmap(e,{imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:"none"});if(t.width<32||t.height<32){let a=Math.max(t.width,32),r=Math.max(t.height,32);t=await createImageBitmap(t,{resizeWidth:a,resizeHeight:r,imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:"none"})}return this.format=Y.rgba8unorm,this.generate(t),!0}}class yr{baseUrl="";initUrl;_progress=0;constructor(){}async loadBinData(e,t){return this.baseUrl=yt.getPath(e),this.initUrl=e,new Promise(async(a,r)=>{fetch(e,{headers:t?.headers}).then(async i=>{if(i.ok){let n=await yr.read(e,i,t),o=n.buffer;n=null,a(o)}else throw Error("request rejected with status "+i.status)}).catch(i=>{t.onError&&t.onError(i),r(i)})})}async loadAsyncBitmapTexture(e,t){this.baseUrl=yt.getPath(e),this.initUrl=e;let a=new La;return a.url=e,a.name=yt.getURLName(e),await a.load(e,t),A.res.addTexture(e,a),a}async loadJson(e,t){return this.baseUrl=yt.getPath(e),this.initUrl=e,new Promise(async(a,r)=>{fetch(e,{headers:t?.headers}).then(async i=>{if(i.ok){let n=await yr.read(e,i,t);const l=new TextDecoder("utf-8").decode(n);n=null,a(JSON.parse(l))}else throw Error("request rejected with status"+i.status)}).catch(i=>{t.onError&&t.onError(i),r(i)})})}async loadTxt(e,t){return this.baseUrl=yt.getPath(e),new Promise(async(a,r)=>{fetch(e).then(async i=>{if(i.ok){let n=await yr.read(e,i,t);const l=new TextDecoder("utf-8").decode(n);n=null,a({data:l})}else throw Error("request rejected with status"+i.status)}).catch(i=>{t.onError&&t.onError(i),r(i)})})}static async read(e,t,a){const r=t.body.getReader(),i=+t.headers.get("Content-Length");let n=0,o=[],l=[];for(;;){const{done:h,value:u}=await r.read();if(h){i>0&&a&&a.onComplete&&a.onComplete.call(this,e);break}o.push(u),n+=u.length,i>0?a&&a.onProgress&&a.onProgress.call(this,n,i,e):l.push(u.length)}if(l.length>0)for(let h=0;h<o.length;h++)a&&a.onProgress&&a.onProgress.call(this,l[h],n,e),l[h]==n&&a&&a.onComplete&&a.onComplete.call(this,e);let c=new Uint8Array(n),f=0;for(let h of o)c.set(h,f),f+=h.length;return c}}var Ge=(s=>(s[s.TEXT=0]="TEXT",s[s.BIN=1]="BIN",s[s.JSON=2]="JSON",s))(Ge||{});class At extends yr{async load(e,t,a,r){switch(t.format){case Ge.BIN:return new Promise(async(i,n)=>{this.loadBinData(e,a).then(async o=>{let l=new t;if(l.userData=r,l.baseUrl=this.baseUrl,l.initUrl=e,l.loaderFunctions=a,await l.parseBuffer(o),l.verification())i(l);else throw new Error("parser error")}).catch(o=>{n(o)})});case Ge.JSON:return new Promise((i,n)=>{this.loadJson(e,a).then(async o=>{let l=new t;l.userData=r,l.baseUrl=this.baseUrl,l.initUrl=e,l.loaderFunctions=a,await l.parseJson(o),i(l)}).catch(o=>{n(o)})});case Ge.TEXT:return new Promise((i,n)=>{this.loadTxt(e,a).then(async o=>{let l=new t;l.userData=r,l.baseUrl=this.baseUrl,l.initUrl=e,l.loaderFunctions=a,o.data?(await l.parseString(o.data),i(l)):n("text load is empty!")}).catch(o=>{n(o)})})}}}class nt{static format=Ge.BIN;baseUrl;initUrl;loaderFunctions;userData;data;parseString(e){}parseJson(e){}parseBuffer(e){}parseTexture(e){throw this.parserError("Method not implemented.",-1)}parse(e){}verification(e){throw this.parserError("Method not implemented.",-1)}parserError(e,t){console.error(`error id:${t} ${e}`)}}class fn{asset;accessors;buffers;bufferViews;materials;meshes;nodes;scene=0;scenes;textures;cameras;skins;resources;images;samplers;animations;extensions}class a2{nodes}class r2{name;type;color;intensity;range;spot;isParsed}class i2{name;rotation;scale;translation;children;matrix;mesh=-1;isParsed;dnode;camera;skin;nodeId;primitives;extensions;light}class n2{attributes;indices;material;mode;name;targets;extensions;morphTargetsRelative}class s2{name;primitives;isParsed;dprimitives;weights;extras}class o2{bufferView;componentType;count;type;max;min;isParsed;daccessor;normalized;sparse;byteOffset;computeResult}const l2=window.SharedArrayBuffer?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof window.SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer},vs=5120,Ui=5121,ys=5122,Cs=5123,Ss=5124,xs=5125,Fs=5126,c2=32819,f2=32820,d2=33635,h2=5131,u2=33640,b2=35899,g2=35902,m2=36269,p2=34042,k0={};{const s=k0;s[vs]=Int8Array,s[Ui]=Uint8Array,s[ys]=Int16Array,s[Cs]=Uint16Array,s[Ss]=Int32Array,s[xs]=Uint32Array,s[Fs]=Float32Array,s[c2]=Uint16Array,s[f2]=Uint16Array,s[d2]=Uint16Array,s[h2]=Uint16Array,s[u2]=Uint32Array,s[b2]=Uint32Array,s[g2]=Uint32Array,s[m2]=Uint32Array,s[p2]=Uint32Array}function A2(s){switch(s){case Int8Array:return vs;case Uint8Array:return Ui;case Uint8ClampedArray:return Ui;case Int16Array:return ys;case Uint16Array:return Cs;case Int32Array:return Ss;case Uint32Array:return xs;case Float32Array:return Fs;default:throw new Error("unsupported typed array type")}}function D2(s){if(s instanceof Int8Array)return vs;if(s instanceof Uint8Array||s instanceof Uint8ClampedArray)return Ui;if(s instanceof Int16Array)return ys;if(s instanceof Uint16Array)return Cs;if(s instanceof Int32Array)return Ss;if(s instanceof Uint32Array)return xs;if(s instanceof Float32Array)return Fs;throw new Error("unsupported typed array type")}function ks(s){const e=k0[s];if(!e)throw new Error("unkonw gl type");return e}function _2(s,e=Float32Array){return l2(s)?s:new e(s)}const E0=`
7239
+ `,i+=f}),r}static compareVersion(e,t){e=e.split("."),t=t.split(".");let a=Math.max(e.length,t.length);for(;e.length<a;)e.push("0");for(;t.length<a;)t.push("0");for(let r=0;r<a;r++){let i=parseInt(e[r]),n=parseInt(t[r]);if(i>n)return 1;if(i<n)return-1}return 0}static buildRandomCode(){let e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",t=e.length,a="";for(let i=0;i<26;i++){let n=Math.floor(Math.random()*t);a+=e.charAt(n)}return`${new Date().getTime()}-${a}`}static UUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=Math.random()*16|0,a=e=="x"?t:t&3|8;return a.toString(16)})}static stringToHash(e){let t=0;if(e.length==0)return t;for(let a=0;a<e.length;a++){const r=e.charCodeAt(a);t=(t<<5)-t+r,t=t&t}return t}static parseUrl(e,t){return t.match(/^(blob|http|https):/)?t:e+t}}class La extends Xe{_source;premultiplyAlpha="none";constructor(e=!0){super(),this.useMipmap=e,this.lodMinClamp=0,this.lodMaxClamp=4}get source(){return this._source}set source(e){if(this._source&&this._source instanceof ImageBitmap)try{this._source.close()}catch{}this._source=e,this._source instanceof HTMLImageElement?this._source.decode().then(async()=>{if(this._source instanceof HTMLImageElement){const t=await createImageBitmap(this._source,{imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:"none"});this.generate(t)}}):(this._source instanceof HTMLCanvasElement||this._source instanceof ImageBitmap)&&this.generate(this._source)}async load(e,t){if(this.name=yt.getURLName(e),e.indexOf(";base64")!=-1){const a=document.createElement("img");let r=e.indexOf("data:image"),i=e.substring(r,e.length);a.src=i,await a.decode(),a.width=Math.max(a.width,32),a.height=Math.max(a.height,32);const n=await createImageBitmap(a,{resizeWidth:a.width,resizeHeight:a.height,imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:"none"});this.format=Y.rgba8unorm,this.generate(n)}else return new Promise((a,r)=>{fetch(e,{headers:Object.assign({Accept:"image/avif,image/webp,*/*"},t?.headers)}).then(i=>{yr.read(e,i,t).then(n=>{let o=new Blob([n],{type:"image/jpeg"});n=null,this.loadFromBlob(o).then(()=>{a(!0)})})})});return!0}imageData;async loadFromBlob(e){this.imageData=e;let t=await createImageBitmap(e,{imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:"none"});if(t.width<32||t.height<32){let a=Math.max(t.width,32),r=Math.max(t.height,32);const i=t;t=await createImageBitmap(t,{resizeWidth:a,resizeHeight:r,imageOrientation:this.flipY?"flipY":"from-image",premultiplyAlpha:"none"});try{i.close()}catch{}}return this.format=Y.rgba8unorm,this.generate(t),!0}destroy(e){if(this._source&&this._source instanceof ImageBitmap){try{this._source.close()}catch{}this._source=null}super.destroy(e)}}class yr{baseUrl="";initUrl;_progress=0;constructor(){}async loadBinData(e,t){return this.baseUrl=yt.getPath(e),this.initUrl=e,new Promise(async(a,r)=>{fetch(e,{headers:t?.headers}).then(async i=>{if(i.ok){let n=await yr.read(e,i,t),o=n.buffer;n=null,a(o)}else throw Error("request rejected with status "+i.status)}).catch(i=>{t.onError&&t.onError(i),r(i)})})}async loadAsyncBitmapTexture(e,t){this.baseUrl=yt.getPath(e),this.initUrl=e;let a=new La;return a.url=e,a.name=yt.getURLName(e),await a.load(e,t),A.res.addTexture(e,a),a}async loadJson(e,t){return this.baseUrl=yt.getPath(e),this.initUrl=e,new Promise(async(a,r)=>{fetch(e,{headers:t?.headers}).then(async i=>{if(i.ok){let n=await yr.read(e,i,t);const l=new TextDecoder("utf-8").decode(n);n=null,a(JSON.parse(l))}else throw Error("request rejected with status"+i.status)}).catch(i=>{t.onError&&t.onError(i),r(i)})})}async loadTxt(e,t){return this.baseUrl=yt.getPath(e),new Promise(async(a,r)=>{fetch(e).then(async i=>{if(i.ok){let n=await yr.read(e,i,t);const l=new TextDecoder("utf-8").decode(n);n=null,a({data:l})}else throw Error("request rejected with status"+i.status)}).catch(i=>{t.onError&&t.onError(i),r(i)})})}static async read(e,t,a){const r=t.body.getReader(),i=+t.headers.get("Content-Length");let n=0,o=[],l=[];for(;;){const{done:h,value:u}=await r.read();if(h){i>0&&a&&a.onComplete&&a.onComplete.call(this,e);break}o.push(u),n+=u.length,i>0?a&&a.onProgress&&a.onProgress.call(this,n,i,e):l.push(u.length)}if(l.length>0)for(let h=0;h<o.length;h++)a&&a.onProgress&&a.onProgress.call(this,l[h],n,e),l[h]==n&&a&&a.onComplete&&a.onComplete.call(this,e);let c=new Uint8Array(n),f=0;for(let h of o)c.set(h,f),f+=h.length;return c}}var Ge=(s=>(s[s.TEXT=0]="TEXT",s[s.BIN=1]="BIN",s[s.JSON=2]="JSON",s))(Ge||{});class At extends yr{async load(e,t,a,r){switch(t.format){case Ge.BIN:return new Promise(async(i,n)=>{this.loadBinData(e,a).then(async o=>{let l=new t;if(l.userData=r,l.baseUrl=this.baseUrl,l.initUrl=e,l.loaderFunctions=a,await l.parseBuffer(o),l.verification())i(l);else throw new Error("parser error")}).catch(o=>{n(o)})});case Ge.JSON:return new Promise((i,n)=>{this.loadJson(e,a).then(async o=>{let l=new t;l.userData=r,l.baseUrl=this.baseUrl,l.initUrl=e,l.loaderFunctions=a,await l.parseJson(o),i(l)}).catch(o=>{n(o)})});case Ge.TEXT:return new Promise((i,n)=>{this.loadTxt(e,a).then(async o=>{let l=new t;l.userData=r,l.baseUrl=this.baseUrl,l.initUrl=e,l.loaderFunctions=a,o.data?(await l.parseString(o.data),i(l)):n("text load is empty!")}).catch(o=>{n(o)})})}}}class nt{static format=Ge.BIN;baseUrl;initUrl;loaderFunctions;userData;data;parseString(e){}parseJson(e){}parseBuffer(e){}parseTexture(e){throw this.parserError("Method not implemented.",-1)}parse(e){}verification(e){throw this.parserError("Method not implemented.",-1)}parserError(e,t){console.error(`error id:${t} ${e}`)}}class fn{asset;accessors;buffers;bufferViews;materials;meshes;nodes;scene=0;scenes;textures;cameras;skins;resources;images;samplers;animations;extensions}class a2{nodes}class r2{name;type;color;intensity;range;spot;isParsed}class i2{name;rotation;scale;translation;children;matrix;mesh=-1;isParsed;dnode;camera;skin;nodeId;primitives;extensions;light}class n2{attributes;indices;material;mode;name;targets;extensions;morphTargetsRelative}class s2{name;primitives;isParsed;dprimitives;weights;extras}class o2{bufferView;componentType;count;type;max;min;isParsed;daccessor;normalized;sparse;byteOffset;computeResult}const l2=window.SharedArrayBuffer?function(e){return e&&e.buffer&&(e.buffer instanceof ArrayBuffer||e.buffer instanceof window.SharedArrayBuffer)}:function(e){return e&&e.buffer&&e.buffer instanceof ArrayBuffer},vs=5120,Ui=5121,ys=5122,Cs=5123,Ss=5124,xs=5125,Fs=5126,c2=32819,f2=32820,d2=33635,h2=5131,u2=33640,b2=35899,g2=35902,m2=36269,p2=34042,k0={};{const s=k0;s[vs]=Int8Array,s[Ui]=Uint8Array,s[ys]=Int16Array,s[Cs]=Uint16Array,s[Ss]=Int32Array,s[xs]=Uint32Array,s[Fs]=Float32Array,s[c2]=Uint16Array,s[f2]=Uint16Array,s[d2]=Uint16Array,s[h2]=Uint16Array,s[u2]=Uint32Array,s[b2]=Uint32Array,s[g2]=Uint32Array,s[m2]=Uint32Array,s[p2]=Uint32Array}function A2(s){switch(s){case Int8Array:return vs;case Uint8Array:return Ui;case Uint8ClampedArray:return Ui;case Int16Array:return ys;case Uint16Array:return Cs;case Int32Array:return Ss;case Uint32Array:return xs;case Float32Array:return Fs;default:throw new Error("unsupported typed array type")}}function D2(s){if(s instanceof Int8Array)return vs;if(s instanceof Uint8Array||s instanceof Uint8ClampedArray)return Ui;if(s instanceof Int16Array)return ys;if(s instanceof Uint16Array)return Cs;if(s instanceof Int32Array)return Ss;if(s instanceof Uint32Array)return xs;if(s instanceof Float32Array)return Fs;throw new Error("unsupported typed array type")}function ks(s){const e=k0[s];if(!e)throw new Error("unkonw gl type");return e}function _2(s,e=Float32Array){return l2(s)?s:new e(s)}const E0=`
7240
7240
  var DracoDecoderModule = (() => {
7241
7241
  var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
7242
7242
  if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
@@ -7272,7 +7272,7 @@ else if (typeof define === 'function' && define['amd'])
7272
7272
  define([], function() { return DracoDecoderModule; });
7273
7273
  else if (typeof exports === 'object')
7274
7274
  exports["DracoDecoderModule"] = DracoDecoderModule;
7275
- `;class Es{static _workerCode;static _workers=new Map;static async apply(e,t){if(!t.extensions)return;const a=t.extensions.KHR_draco_mesh_compression;if(!a)return;let r=this._workers.get(e.gltf);r||(r=new Worker(await this.initDecoder()),this._workers.set(e.gltf,r)),r.postMessage({type:"init",decoderConfig:{}});let i=e.parseBufferView(a.bufferView);if(!i.result){let n=await new Promise((o,l)=>{r.onmessage=c=>{const f=c.data;f.type=="decode"?o(f.result):f.type=="error"&&l(f.error)},r.postMessage({type:"decoder",buffer:i,attributes:a.attributes},[i])});i.result=n}return i.result}static unload(e){let t=this._workers.get(e);t&&(t.terminate(),this._workers.delete(e))}static async initDecoder(){if(!this._workerCode){const e=new Blob([E0,"",`(${B2})()`],{type:"application/javascript"});this._workerCode=URL.createObjectURL(e)}return this._workerCode}}function B2(){let s,e;onmessage=t=>{const a=t.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise((n,o)=>{s.onModuleLoaded=l=>{n({draco:l})},DracoDecoderModule(s)});break;case"decoder":const r=a.buffer,i=a.attributes;e.then(n=>{const o=n.draco;let l=new o.Decoder,c=new o.DecoderBuffer;c.Init(new Int8Array(r),r.byteLength);let f,h;try{const u=l.GetEncodedGeometryType(c);u==o.TRIANGULAR_MESH?(h=new o.Mesh,f=l.DecodeBufferToMesh(c,h)):self.postMessage(new Error("INVALID_GEOMETRY_TYPE:"+u)),f.ok()||self.postMessage(new Error("DracoDecode:"+f.error_msg()));let g={};for(const p in i){let m=l.GetAttributeByUniqueId(h,i[p]);const D=m.num_components(),B=h.num_points()*D,v=B*Float32Array.BYTES_PER_ELEMENT,C=o.DT_FLOAT32,y=o._malloc(v);l.GetAttributeDataArrayForAllPoints(h,m,C,v,y);const F=new Float32Array(o.HEAPF32.buffer,y,B).slice();o._free(y),g[p]={data:F,numComponents:D,normalize:!1}}{const m=h.num_faces()*3,D=m*4,_=o._malloc(D);l.GetTrianglesUInt32Array(h,D,_);const B=new Uint32Array(o.HEAPF32.buffer,_,m).slice();o._free(_),g.indices={data:B,numComponents:1,normalize:!1}}self.postMessage({type:"decode",result:g})}catch(u){self.postMessage({type:"error",error:u.message})}finally{o.destroy(h),o.destroy(l),o.destroy(c)}});break}}}class R0{gltf;constructor(e){this.gltf=e}parse(e){const t=this.gltf.cameras[e];if(!t)return this.errorMiss("camera",e);if(t.isParsed)return t.dcamera;t.isParsed=!0,t.dcamera=!1;const{name:a,type:r,perspective:i,orthographic:n}=t;if(r==="perspective"&&i){const{aspectRatio:o,yfov:l,zfar:c,znear:f}=i;t.dcamera=Object.assign({},{name:a,type:r,yfov:l,znear:f,aspectRatio:o,zfar:c})}else if(r==="orthographic"&&n){const{xmag:o,ymag:l,zfar:c,znear:f}=n;t.dcamera=Object.assign({},{name:a,type:r,xmag:o,ymag:l,zfar:c,znear:f})}return t.dcamera}errorMiss(e,t){throw new Error(e+t)}}class Dt extends nt{static format=Ge.JSON;_gltf;async parseJson(e){this._gltf=new fn,this._gltf={...this._gltf,...e},this._gltf.resources={},await Promise.all([this.load_gltf_bin(),this.load_gltf_textures()]);let t=new hn,a=await t.parse(this.initUrl,this._gltf,this._gltf.scene);return t.destroy(),t=null,a?(this.data=a.rootNode,a.rootNode):(this._gltf=null,null)}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}static _counter=0;static getMeshNameCounter(){return function(){return`GLTF_NO_NAME_PRIMITIVE_${Dt._counter++}`}}static getModelNameCounter(){let e=0;return function(){return`GLTF_NO_NAME_MESH_${e++}`}}static getTexCoordDefine(e){return`UV_NUM ${e}`}static getVertexColorDefine(e){return`HAS_VERTEXCOLOR ${e}`}static getBaseColorTextureDefine(){return"HAS_BASECOLORMAP"}static getMetalRoughnessDefine(){return"HAS_METALROUGHNESSMAP"}static getNormalMapDefine(){return"HAS_NORMALMAP"}static getEmissiveMapDefine(){return"HAS_EMISSIVEMAP"}static getOcclusionMapDefine(){return"HAS_OCCLUSIONMAP"}static getMorphTargetsDefine(e){return`MORPH_TARGET_NUM ${e}`}static getMorphtargetPositionDefine(){return"HAS_MORPH_POSITION"}static getMorphtargetNormalDefine(){return"HAS_MORPH_NORMAL"}static getMorphtargetTangentDefine(){return"HAS_MORPH_TANGENT"}static getJointsNumDefine(e){return`JOINTS_NUM ${e}`}static getJointVec8Define(){return"JOINT_VEC8"}static getHasNormalDefine(){return"HAS_NORMAL"}static getHasTangentDefine(){return"HAS_TANGENT"}static getHasNormalMapDefine(){return"HAS_NORMAL_MAP"}static getAlphaMaskDefine(){return"ALPHA_MASK"}static getAlphaBlendDefine(){return"ALPHA_BLEND"}static defaultMaterial={name:"GLTF_DEFAULT_MATERIAL",alphaCutoff:.33,alphaMode:"MASK",pbrMetallicRoughness:{name:"GLTF_DEFAULT_MATERIAL",defines:[],doubleSided:!1,baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1,emissiveFactor:[0,0,0]}};async load_gltf_bin(){if(this._gltf.buffers&&this._gltf.buffers.length>0){let e=[];for(let t=0;t<this._gltf.buffers.length;t++){const a=this._gltf.buffers[t];if(a.uri.substring(0,5)!=="data:"){let r=yt.parseUrl(this.baseUrl,a.uri);this.loaderFunctions?.onUrl&&(r=await this.loaderFunctions.onUrl(r));let i=new At().loadBinData(r,this.loaderFunctions).then(n=>{this._gltf.resources[a.uri]=n});e.push(i)}}await Promise.all(e)}}async load_gltf_textures(){if(this._gltf,this._gltf.images){let e=[];for(let t=0;t<this._gltf.images.length;t++){const a=this._gltf.images[t];if(a.uri){let r=yt.parseUrl(this.baseUrl,a.uri);this.loaderFunctions?.onUrl&&(r=await this.loaderFunctions.onUrl(r));let i=new At().loadAsyncBitmapTexture(r,this.loaderFunctions).then(n=>{n.name=yt.getURLName(a.uri),this._gltf.resources[n.name]=n});e.push(i)}}await Promise.all(e)}}}class w0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}async parse(e){const t=this.gltf.meshes[e];if(!t)return this.errorMiss("mesh",e);if(t.isParsed)return t.dprimitives;const a=t.primitives,r=t.extras,i=[];for(let n=0;n<a.length;n++){const o=a[n],{attributes:l,indices:c,material:f,mode:h,name:u,targets:g,morphTargetsRelative:p,extensions:m}=o;let D=t.name;for(let k in l)D+=k;D+=`indices:${c}`,D+=`material:${f}`;const _={attribArrays:{indices:[]},weights:[],defines:[],material:null,drawMode:null,meshName:null,modelName:null,morphTargetsRelative:!1,targetNames:r?r.targetNames:null};let B=!1,v=0,C=!1,y;m&&m.KHR_draco_mesh_compression&&(y=await Es.apply(this.subParser,o));for(const k in l){const w=y?y[k]:this.parseAccessor(l[k]);if(w){let x;switch(k){case"POSITION":x=V.position;break;case"NORMAL":x=V.normal,B=!0;break;case"TEXCOORD_0":x=V.uv,v++;break;case"JOINTS_0":x=V.joints0;break;case"JOINTS_1":x=V.joints1,C=!0;break;case"WEIGHTS_0":x=V.weights0;break;case"WEIGHTS_1":x=V.weights1;break;default:x=k}_.attribArrays[x]=w}}if(B&&_.defines.push(Dt.getHasNormalDefine()),v&&_.defines.push(Dt.getTexCoordDefine(v)),C&&_.defines.push(Dt.getJointVec8Define()),c!==void 0){const k=y?y.indices:this.parseAccessor(c);k&&(_.attribArrays.indices=k)}const F=await this.parseMaterial(f);if(F&&(_.material=F,_.defines=_.defines.concat(F.defines)),_.drawMode=h===void 0?4:h,_.meshName=()=>D,_.modelName=t.name||Dt.getModelNameCounter(),g){_.defines.push(Dt.getMorphTargetsDefine(g.length)),_.morphTargetsRelative=!0;let k=!1,w=!1,x=!1;for(let M=0;M<g.length;M++){const N=g[M];Object.keys(N).forEach(Q=>{const G=this.parseAccessor(N[Q]);if(G){let X;switch(Q){case"POSITION":X=Zt.MORPH_POSITION_PREFIX+M,k=!0;break;case"NORMAL":X=Zt.MORPH_NORMAL_PREFIX+M,w=!0;break;case"TANGENT":X=Zt.MORPH_TANGENT_PREFIX+M,x=!0;break;default:X=!1}X?_.attribArrays[X]=G:console.error(`glTF has unsupported morph target attribute ${Q}`)}})}k&&_.defines.push(Dt.getMorphtargetPositionDefine()),w&&_.defines.push(Dt.getMorphtargetNormalDefine()),x&&_.defines.push(Dt.getMorphtargetTangentDefine()),_.weights=t.weights||new Array(g.length).fill(0)}i.push(_)}return t.dprimitives=i,t.isParsed=!0,t.dprimitives}parseAccessor(e){return this.subParser.parseAccessor(e)}parseMaterial(e){return this.subParser.parseMaterial(e)}errorMiss(e,t){throw new Error(e+t)}}class I0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}async parse(e){let t;if(e==null?t=Dt.defaultMaterial:t=this.gltf.materials[e],!t)return this.errorMiss("material",e);if(t.isParsed)return t.dmaterial;let{name:a,pbrMetallicRoughness:r,normalTexture:i,occlusionTexture:n,emissiveTexture:o,emissiveFactor:l,alphaMode:c,alphaCutoff:f,doubleSided:h,extensions:u}=t;const g={name:a,defines:[],doubleSided:!!h,baseColorFactor:[1,1,1,1],emissiveFactor:null,alphaCutoff:0,enableBlend:!1,baseColorTexture:null,metallicRoughnessTexture:null,normalTexture:null,occlusionTexture:null,emissiveTexture:null,extensions:null,baseMapOffsetSize:null,normalMapOffsetSize:null,emissiveMapOffsetSize:null,roughnessMapOffsetSize:null,metallicMapOffsetSize:null,aoMapOffsetSize:null,metallicFactor:0,roughnessFactor:1};if(r){const{baseColorFactor:p,metallicFactor:m,roughnessFactor:D,baseColorTexture:_,metallicRoughnessTexture:B}=r;if(Object.assign(g,{baseColorFactor:p||[1,1,1,1],metallicFactor:m===void 0?1:m,roughnessFactor:D===void 0?.5:D}),_){let v=_.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.baseMapOffsetSize=F}}const C=await this.parseTexture(_.index);C?g.baseColorTexture=C:g.baseColorTexture=A.res.redTexture}if(i){let v=i.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.normalMapOffsetSize=F}}const C=await this.parseTexture(i.index);C?g.normalTexture=C:g.normalTexture=A.res.normalTexture}if(B){let v=B.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.roughnessMapOffsetSize=F}}const C=await this.parseTexture(B.index);C?g.metallicRoughnessTexture=C:g.metallicRoughnessTexture=A.res.blackTexture}}else Object.assign(g,{baseColorFactor:[1,1,1,1],metallicFactor:0,roughnessFactor:.5});if(g.baseColorFactor&&g.baseColorFactor[3]<1&&(c=c==="MASK"?"MASK":"BLEND"),c&&c!=="OPAQUE"&&(c==="MASK"&&(g.defines.push(Dt.getAlphaMaskDefine()),g.alphaCutoff=f===void 0?.5:f),c==="BLEND"&&(g.defines.push(Dt.getAlphaBlendDefine()),g.enableBlend=!0)),i){const p=await this.parseTexture(i.index);p?g.normalTexture=p:g.normalTexture=A.res.normalTexture}if(n){const p=await this.parseTexture(n.index);p&&(g.occlusionTexture=p)}if(l&&(g.emissiveFactor=l),o){const p=await this.parseTexture(o.index);p?g.emissiveTexture=p:g.emissiveTexture=A.res.blackTexture}return u&&(g.extensions=u),t.isParsed=!0,t.dmaterial=g,g}async parseTexture(e){return this.subParser.parseTexture(e)}errorMiss(e,t){throw new Error(e+t)}}class Q0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}parse(e){const t=this.gltf.skins[e];if(!t)return this.errorMiss("skin",e);if(t.isParsed)return t.dskin;const{name:a,joints:r,inverseBindMatrices:i,skeleton:n}=t;if(!r)return this.errorMiss("skin.joints",e);t.isParsed=!0,t.dskin=!1;let o={name:a,skeleton:null,inverseBindMatrices:null,joints:r,defines:[Dt.getJointsNumDefine(r.length)]};if(n)o.skeleton=n;else{var l=-1;for(let c=0;c<this.gltf.nodes.length;c++)if(this.gltf.nodes[c].name=="root"){l=c;break}if(l==-1){let c=this.gltf.scenes[this.gltf.scene];l=c.nodes[c.nodes.length-1]}o.skeleton=l}if(o.inverseBindMatrices=Zt.IDENTITY_INVERSE_BIND_MATRICES,i!==void 0){const c=this.parseAccessor(i);if(c){const f=c.data,h=[];for(let u=0;u<f.length;u+=16)h.push(f.slice(u,u+16));o.inverseBindMatrices=h}else o=null}return t.dskin=o,t.dskin}parseAccessor(e){return this.subParser.parseAccessor(e)}errorMiss(e,t){throw new Error(e+t)}}class T0{name="";index=0;instanceID="";parent=null;scale=new b;rotation=new Z;translation=new b;constructor(e=""){this.name=e}}class Rs{index;worldMatrix;constructor(e,t=!1){this.index=e,this.worldMatrix=new R(!t)}}class vi{time;_skeleton;_jointsPose;mJointMatrixIndexTable;constructor(e,t=!1){this._skeleton=e,this._jointsPose=new Array(e.numJoint),this.mJointMatrixIndexTable=new Array(e.numJoint);for(let a=0;a<e.numJoint;a++){let r=new Rs(a,t);this._jointsPose[a]=r,this.mJointMatrixIndexTable[a]=r.worldMatrix.index}}buildSkeletonPose(e){let t=new b,a=new Z,r=new b,i=new Array(this._skeleton.numJoint);this.time=e[11]>0?e[11]:e[24];for(let n=0;n<this._skeleton.numJoint;n++){let o=12*n*4,l=new Float32Array(e.buffer,e.byteOffset+o,12),c=new R;t.set(l[0],l[1],l[2]),a.set(l[4],l[5],l[6],l[7]),r.set(l[8],l[9],l[10]),en(a.getEulerAngles(),r,t,c),i[n]=c;let f=new Rs(n);const h=this._skeleton.getJointParentIndex(n);if(h<0)f.worldMatrix.copyFrom(c);else{let u=this._jointsPose[h];tc(u.worldMatrix,c,f.worldMatrix)}this._jointsPose[n]=f}}get numJoint(){return this._skeleton.numJoint}get joints(){return this._jointsPose}get jointMatrixIndexTable(){return this.mJointMatrixIndexTable}lerp(e,t,a){if(e&&t)for(let r=0;r<this._jointsPose.length;r++){let i=e._jointsPose[r],n=t._jointsPose[r];this._jointsPose[r].worldMatrix.lerp(i.worldMatrix,n.worldMatrix,a)}else for(let r=0;r<this._jointsPose.length;r++){let i=e._jointsPose[r];this._jointsPose[r].worldMatrix.copyFrom(i.worldMatrix)}}copyFrom(e){for(let t=0;t<this._jointsPose.length;t++)this._jointsPose[t].worldMatrix.copyFrom(e._jointsPose[t].worldMatrix)}reset(){for(let e=0;e<this._jointsPose.length;e++)this._jointsPose[e].worldMatrix.identity()}}class M0 extends qe{skeletonAnimation;constructor(e,t){super(),this.type=e,this.time=t}}class dn{name="";_skeleton;_skeletonPoses;_animationClipData;_events;constructor(e,t,a,r){if(this.name=e,this._skeleton=t,this._animationClipData=r,a>0&&r){this._skeletonPoses=new Array(a);let i=12*t.numJoint;for(let n=0;n<a;n++){let o=i*n*4;const l=r.buffer instanceof ArrayBuffer?r.buffer:new Uint8Array(r.buffer).buffer;let c=new Float32Array(l,o,i),f=new vi(t);f.buildSkeletonPose(c),this._skeletonPoses[n]=f}}}get totalTime(){return this._skeletonPoses[this._skeletonPoses.length-1].time}get frameRate(){return this.totalTime/this._skeletonPoses.length}get skeleton(){return this._skeleton}get numFrame(){return this._skeletonPoses.length-1}get animationClipData(){return this._animationClipData}getSkeletonPose(e){return this._skeletonPoses[e]}getLerpSkeletonPose(e,t,a,r){let i=this.getSkeletonPose(e),n=this.getSkeletonPose(t);return r.lerp(i,n,a),r}createSubClip(e,t,a){var r=new dn(e,this._skeleton,0,null);const i=Math.max(Math.floor(t/this.frameRate),0),n=Math.min(Math.floor(a/this.frameRate),this._skeletonPoses.length-1);r._skeletonPoses=this._skeletonPoses.slice(i,n);const o=12*this._skeleton.numJoint*4,l=this._animationClipData.buffer instanceof ArrayBuffer?this._animationClipData.buffer:new Uint8Array(this._animationClipData.buffer).buffer;return this._animationClipData=new Float32Array(l,i*o,(n-i)*o),r}addEvent(e,t){this._events||(this._events=new Array),this._events.push(new M0(e,t))}removeEvent(e){this._events&&(this._events=this._events.filter(t=>t.type!=e))}getEvents(){return this._events}}class ws{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}parse(e){let t=new go;return t.name="Id:"+e,t.count=0,t.boneData=[],t.boneMap=new Map,this.buildSkeleton(t,void 0,e),t}parseSkeletonAnimation(e,t){let a=new ko;a.clipName=t.name,a.useSkeletonPos=!1,a.useSkeletonScale=!1;for(let r of t.channels){let i=t.samplers[r.sampler];const n=this.subParser.parseAccessor(i.input),o=this.subParser.parseAccessor(i.output);let l=r.target.node,c=r.target.path,f=this.gltf.nodes[l];if(!f||!e.boneMap.has(f.name))continue;let h=e.boneMap.get(f.name);switch(c){case"scale":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.useSkeletonScale=!0,a.scaleCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new b().set(o.data[m+0],o.data[m+1],o.data[m+2]);D.split(z.vector3,_,"value"),u.addKeyFrame(D)}}break;case"rotation":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.rotationCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new Z().set(o.data[m+0],o.data[m+1],o.data[m+2],o.data[m+3]);D.split(z.quaternion,_,"value"),u.addKeyFrame(D)}}break;case"translation":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.useSkeletonPos=!0,a.positionCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new b().set(o.data[m+0],o.data[m+1],o.data[m+2]);D.split(z.vector3,_,"value"),u.addKeyFrame(D)}}break}}return a}parseSkeletonAnimationOld(e,t){let a=this.subParser.parseAccessor(t.samplers[0].input),r=a.data.length,i=a.data[1]-a.data[0];a.data[a.data.length-1];let n=12*e.numJoint,o=new Float32Array(n*r);for(var l=0;l<e.numJoint;l++)for(var c=0;c<r;c++){var f=n*c+12*l;o[f+0]=1,o[f+1]=1,o[f+2]=1,o[f+3]=1}for(let m of t.channels){let D=t.samplers[m.sampler];const _=this.subParser.parseAccessor(D.input),B=this.subParser.parseAccessor(D.output);let v=m.target.node,C=m.target.path,y=this.gltf.nodes[v];if(!y)continue;let F=e.getJointByName(y.name);if(F)switch(C){case"scale":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=1}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2]);for(var c=0;c<r;c++){let M=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,M);var f=n*c+12*F.index;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=1,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break;case"rotation":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index+4;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=B.data[h+3]}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2],B.data[u+3]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2],B.data[g+3]);for(var c=0;c<r;c++){let Q=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,Q);var f=n*c+12*F.index+4;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=b.HELP_2.w,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break;case"translation":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index+8;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=_.data[c*_.numComponents]}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2]);for(var c=0;c<r;c++){let Q=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,Q);var f=n*c+12*F.index+8;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=k,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break}}return new dn(t.name,e,r,o)}buildSkeleton(e,t,a){let r=this.gltf.nodes[a];r.name||(r.name="Bone"+e.count);let i=new bo;if(i.boneName=r.name,i.bonePath=t?t.bonePath+"/"+r.name:r.name,i.parentBoneName=t?t.boneName:"",i.boneID=e.count++,i.parentBoneID=t?t.boneID:-1,i.instanceID="",i.parentInstanceID="",i.s=new b(1,1,1),r.scale&&i.s.set(r.scale[0],r.scale[1],r.scale[2]),i.q=new Z,r.rotation&&i.q.set(r.rotation[0],r.rotation[1],r.rotation[2],r.rotation[3]),i.t=new b,r.translation&&i.t.set(r.translation[0],r.translation[1],r.translation[2]),e.boneData.push(i),e.boneMap.set(i.boneName,i),r.children)for(let n of r.children)this.buildSkeleton(e,i,n)}buildSkeletonOld(e,t,a,r=0){let i=this.gltf.nodes[a];i.name||(i.name="Node_"+a);let n=new T0(i.name);if(n.parent=t,i.scale&&n.scale.set(i.scale[0],i.scale[1],i.scale[2]),i.rotation&&n.rotation.set(i.rotation[0],i.rotation[1],i.rotation[2],i.rotation[3]),i.translation&&n.translation.set(i.translation[0],i.translation[1],i.translation[2]),e.addJoint(n),i.children)for(let o of i.children)this.buildSkeletonOld(e,n,o,r+1)}}class Is{static list=[];static add(e){this.list.indexOf(e)==-1&&this.list.push(e)}static remove(e){let t=this.list.indexOf(e);t!=-1&&this.list.splice(t,1)}}class yi extends Pe{name;size=1;lightData;dirFix=1;bindOnChange;needUpdateShadow=!0;realTimeShadow=!0;_castGI=!1;_castShadow=!1;_iesProfiles;constructor(){super()}init(){this.transform.object3D.bound=new ge(new b,new b),this.lightData=new tn,this.lightData.lightMatrixIndex=this.transform.worldMatrix.index}onChange(){this.bindOnChange&&this.bindOnChange(),this.transform.object3D.bound.setFromCenterAndSize(this.transform.worldPosition,new b(this.size,this.size,this.size)),this._castGI&&(W.instance.state.giLightingChange=!0),this._castShadow?(this.needUpdateShadow=!0,Et.addShadowLight(this)):Et.removeShadowLight(this),this.transform.view3D&&A.renderJobs&&A.renderJobs.get(this.transform.view3D).reflectionRenderer&&A.renderJobs.get(this.transform.view3D).reflectionRenderer.forceUpdate()}start(){this.transform.onPositionChange=()=>this.onPositionChange(),this.transform.onRotationChange=()=>this.onRotChange(),this.onPositionChange(),this.onRotChange()}onPositionChange(){this.lightData.lightPosition.copyFrom(this.transform.worldPosition),this.onChange()}onRotChange(){this.dirFix==1?this.lightData.direction.copyFrom(this.transform.forward):this.lightData.direction.copyFrom(this.transform.back),this.lightData.lightTangent.copyFrom(this.transform.up),this.onChange()}onScaleChange(){this.onChange()}onEnable(){this.onChange(),W.instance.addLight(this.transform.scene3D,this)}onDisable(){this.onChange(),W.instance.removeLight(this.transform.scene3D,this),Et.removeShadowLight(this)}set iesProfiles(e){this._iesProfiles=e,this.lightData.iesIndex=e.index,ra.use=!0,this.onChange()}get iesProfile(){return this._iesProfiles}get r(){return this.lightData.lightColor.r}set r(e){this.lightData.lightColor.r=e,this.onChange()}get g(){return this.lightData.lightColor.g}set g(e){this.lightData.lightColor.g=e,this.onChange()}get b(){return this.lightData.lightColor.b}set b(e){this.lightData.lightColor.b=e,this.onChange()}get lightColor(){return this.lightData.lightColor}set lightColor(e){this.lightData.lightColor=e,this.onChange()}get color(){return this.lightData.lightColor}set color(e){this.lightData.lightColor=e,this.onChange()}get intensity(){return this.lightData.intensity}set intensity(e){this.lightData.intensity=e,this.onChange()}set castShadow(e){e!=this._castShadow&&(this._castShadow=e,this.onChange())}get castShadow(){return this._castShadow}get shadowIndex(){return this.lightData.castShadowIndex}get castGI(){return this._castGI}set castGI(e){e?Is.add(this):Is.remove(this),this._castGI=e,e&&this.onChange()}get direction(){return this.lightData.direction}destroy(e){this.bindOnChange=null,W.instance.removeLight(this.transform.scene3D,this),Et.removeShadowLight(this),this.transform.eventDispatcher.removeEventListener(kt.ROTATION_ONCHANGE,this.onRotChange,this),this.transform.eventDispatcher.removeEventListener(kt.SCALE_ONCHANGE,this.onScaleChange,this),super.destroy(e)}}var U2=Object.getOwnPropertyDescriptor,v2=(s,e,t,a)=>{for(var r=a>1?void 0:a?U2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.DirectLight=class extends yi{shadowCamera;constructor(){super()}init(){super.init(),this.object3D.name==""&&(this.object3D.name="DirectionLight_"+xt()),this.radius=Number.MAX_SAFE_INTEGER,this.lightData.lightType=Ye.DirectionLight,this.lightData.linear=0,this.lightData.quadratic=.3}start(){super.start(),this.castGI=!0}get radius(){return this.lightData.range}set radius(e){this.lightData.range=e,this.onChange()}get indirect(){return this.lightData.quadratic}set indirect(e){this.lightData.quadratic=e,this.onChange()}debug(){}},d.DirectLight=v2([Mt(d.DirectLight,"DirectLight")],d.DirectLight);var y2=Object.getOwnPropertyDescriptor,C2=(s,e,t,a)=>{for(var r=a>1?void 0:a?y2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.PointLight=class extends yi{constructor(){super()}init(){super.init(),this.lightData.lightType=Ye.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+xt())}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(e){this.lightData.quadratic=e,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(e){}debug(){}debugDraw(e){}},d.PointLight=C2([Mt(d.PointLight,"PointLight")],d.PointLight);var S2=Object.getOwnPropertyDescriptor,x2=(s,e,t,a)=>{for(var r=a>1?void 0:a?S2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.SpotLight=class extends yi{constructor(){super()}init(){super.init(),this.lightData.lightType=Ye.SpotLight,this.object3D.name==""&&(this.object3D.name="SpotLight"+xt())}get innerAngle(){return this.lightData.innerAngle/this.lightData.outerAngle*100}set innerAngle(e){this.lightData.innerAngle=ie(e,0,100)/100*this.lightData.outerAngle,this.onChange()}get outerAngle(){return this.lightData.outerAngle*Wr*2}set outerAngle(e){this.lightData.outerAngle=ie(e,1,179)*at*.5,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}start(){super.start(),this.lightData.lightType=Ye.SpotLight}onUpdate(){}onGraphic(e){}debug(){}debugDraw(e){}},d.SpotLight=x2([Mt(d.SpotLight,"SpotLight")],d.SpotLight);class N0{static apply(e,t,a){let r=t.extensions;if(r&&r.KHR_materials_clearcoat){a.shader.getDefaultColorShader().setDefine("USE_CLEARCOAT",!0);let i=r.KHR_materials_clearcoat;"clearcoatFactor"in i&&(t.clearcoatFactor=i.clearcoatFactor,a.clearcoatFactor=t.clearcoatFactor),"clearcoatRoughnessFactor"in i&&(t.clearcoatRoughnessFactor=i.clearcoatRoughnessFactor,a.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor)}}}class P0{static apply(e,t,a){let r=t.extensions;r&&r.KHR_materials_emissive_strength?(a.emissiveIntensity=r.KHR_materials_emissive_strength.emissiveStrength,a.emissiveMap==A.res.blackTexture&&(a.emissiveMap=A.res.whiteTexture)):a.emissiveIntensity=1}}class V0{static apply(e,t,a){let r=t.extensions;r&&r.KHR_materials_unlit?a.supportLight=!1:a.supportLight=!0}}class O0{gltf;subParser;_testCount=8;_hasCastShadow=!1;constructor(e){this.gltf=e.gltf,this.subParser=e}async convertNodeToObject3D(e,t){const a=new d.Object3D;if(a.name=e.name,a[Zt.GLTF_NODE_INDEX_PROPERTY]=e.nodeId,e.nodeObj=a,e.matrix&&(e.translation=[0,0,0],e.rotation=[0,0,0,1],e.scale=[1,1,1]),e.translation&&(a.transform.x=e.translation[0],a.transform.y=e.translation[1],a.transform.z=e.translation[2]),e.rotation){let r=new Z;r.setFromArray(e.rotation),a.transform.localRotQuat=r}return e.scale&&(a.transform.scaleX=e.scale[0],a.transform.scaleY=e.scale[1],a.transform.scaleZ=e.scale[2]),t.addChild(a),e.light&&this.convertLight(e,a),e.primitives&&this.convertprimitives(e,a),e.skeleton&&this.convertSkeletonAnim(a,e.skeleton),a}convertSkeletonAnim(e,t){let a=this.subParser.parseSkeleton(t.skeleton);A.res.addObj(a.name,a);let r=[];for(let n=0;n<this.gltf.animations.length;n++){let o=this.gltf.animations[n];o.name||(o.name=n.toString());let l=this.subParser.parseSkeletonAnimation(a,o);r.push(l)}let i=e.addComponent(d.AnimatorComponent);i.avatar=a.name,i.clips=r}convertLight(e,t){switch(e.light.type){case"directional":let a=t.addComponent(d.DirectLight);t.name=e.light.name,a.intensity=e.light.intensity*.1,a.radius=Number.MAX_SAFE_INTEGER,a.dirFix=-1,this._hasCastShadow||(this._hasCastShadow=!0,a.castShadow=this._hasCastShadow),a.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1),a.debug();break;case"point":if(this._testCount>0){let i=t.addComponent(d.PointLight);i.name=e.light.name,i.intensity=e.light.intensity?e.light.intensity*8*2:1,i.radius=8,i.at=2,i.range=e.light.range?e.light.range:8,i.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1)}this._testCount--;break;case"spot":let r=t.addComponent(d.SpotLight);r.name=e.light.name,r.intensity=e.light.intensity*5,r.radius=1,r.dirFix=-1,r.at=2,r.range=e.light.range?e.light.range:8,r.outerAngle=e.light.spot.outerConeAngle*Wr,r.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1);break}}convertprimitives(e,t){for(let a=0;a<e.primitives.length;a++){const r=e.primitives[a];r.modelName;let i=r.material;i.name==null&&(i.name=xt());let n,o=`matkey_${i.name}`;if(i&&this.gltf.resources[o])n=this.gltf.resources[o];else{let g=i;const p=g?.extensions?.KHR_materials_unlit!==void 0;let m=p?new st:new pa;if(n=m,this.gltf.resources[o]=m,m.name=i.name,g){const{baseColorTexture:D,baseColorFactor:_,metallicFactor:B,roughnessFactor:v,doubleSided:C,metallicRoughnessTexture:y,normalTexture:F,occlusionTexture:k,emissiveTexture:w,emissiveFactor:x,enableBlend:M,alphaCutoff:N}=g;let Q=m=this.applyMaterialExtensions(g,m);if(p){const G=Q;G.baseColor=new O(_[0],_[1],_[2],_[3]),D&&(G.baseMap=D),Q.doubleSide=C,"enableBlend"in g&&(g.enableBlend?(g.defines?.includes("ALPHA_BLEND")?Q.blendMode=te.ALPHA:Q.blendMode=te.NORMAL,Q.castShadow=!1):Q.blendMode=te.NONE),"alphaCutoff"in g&&N>0&&N<1&&(Q.setUniformFloat("alphaCutoff",N),Q.blendMode=te.NORMAL,Q.transparent=!0)}else if("enableBlend"in g&&(g.enableBlend?(g.defines?.includes("ALPHA_BLEND")?Q.blendMode=te.ALPHA:Q.blendMode=te.NORMAL,Q.castShadow=!1):Q.blendMode=te.NONE),"alphaCutoff"in g&&N>0&&N<1&&(Q.setUniformFloat("alphaCutoff",N),Q.blendMode=te.NORMAL,Q.transparent=!0),g.baseMapOffsetSize&&Q.setUniformVector4("baseMapOffsetSize",g.baseMapOffsetSize),g.normalMapOffsetSize&&Q.setUniformVector4("normalMapOffsetSize",g.normalMapOffsetSize),g.emissiveMapOffsetSize&&Q.setUniformVector4("emissiveMapOffsetSize",g.emissiveMapOffsetSize),g.roughnessMapOffsetSize&&Q.setUniformVector4("roughnessMapOffsetSize",g.roughnessMapOffsetSize),g.metallicMapOffsetSize&&Q.setUniformVector4("metallicMapOffsetSize",g.metallicMapOffsetSize),g.aoMapOffsetSize&&Q.setUniformVector4("aoMapOffsetSize",g.aoMapOffsetSize),Q.setUniformColor("baseColor",new O(_[0],_[1],_[2],_[3])),Q.setUniformFloat("roughness",v??1),Q.setUniformFloat("metallic",B??0),Q.setUniformFloat("ao",1),Q.doubleSide=C,D&&Q.setTexture("baseMap",D),F&&Q.setTexture("normalMap",F),y?(Q.setTexture("maskMap",y),Q.shader.setDefine("USE_ROUGHNESS_G",!0),Q.shader.setDefine("USE_METALLIC_B",!0)):(Q.shader.setDefine("USE_ROUGHNESS_G",!1),Q.shader.setDefine("USE_METALLIC_B",!1)),w&&Q.setTexture("emissiveMap",w),x&&(x[0]>0||x[1]>0||x[2]>0)){Q.shader.getTexture("emissiveMap")||Q.shader.setTexture("emissiveMap",A.res.whiteTexture),Q.shader.setDefine("USE_EMISSIVEMAP",!0),Q.setUniformColor("emissiveColor",new O(x[0],x[1],x[2],x[3])),Q.blendMode!=te.NONE&&(Q.blendMode=te.ADD);let G=n.getUniformFloat("emissiveIntensity");(!G||G<=0)&&n.setUniformFloat("emissiveIntensity",1)}}}const{attribArrays:l,modelName:c,drawMode:f}=r;let h;if(!l.indices.data){let g=[],p=l.position.data.length/3/3;for(let m=0;m<p;m++){let D=m*3;g.push(D+2),g.push(D+0),g.push(D+1)}l.indices={data:new Uint8Array(g),normalize:!1,numComponents:1}}let u=!l.normal;if(u){let g=[],p=l.position.data.length/3;for(let m=0;m<p;m++)g.push(0),g.push(0),g.push(0);l.normal={data:new Float32Array(g),normalize:!1,numComponents:3}}if(l.indices.data&&l.indices.data.length>3){let g=r.meshName();this.gltf.resources[g]&&(h=this.gltf.resources[g]);const p=new d.Object3D;if(p.name=c+a,this.gltf.animations&&l[V.joints0]!=null){h||=this.createGeometryBase(c,l,r,e.skin),this.gltf.resources[g]=h,u&&l.indices?.data&&l.indices.data.length>0&&h.computeNormals();let m=this.gltf.nodes[e.skin.skeleton];m.dnode&&m.dnode.nodeObj?this.convertSkeletonAnim(t,e.skin):m.dnode.skeleton=e.skin;let D=p.addComponent(d.SkinnedMeshRenderer2);D.geometry=h,D.material=n}else{h||=this.createGeometryBase(c,l,r),this.gltf.resources[g]=h,u&&l.indices?.data&&l.indices.data.length>0&&h.computeNormals(),h.hasAttribute(V.joints0)&&h.vertexAttributeMap.delete(V.joints0);let m=p.addComponent(d.MeshRenderer);m.castShadow=!0,m.castGI=!0,m.geometry=h,m.material=n}e.skin&&e.skin.defines,t.addChild(p)}}}createGeometryBase(e,t,a,r){"indices"in t&&(t.indices.data.length>65534?t.indices.data=new Uint32Array(t.indices.data):t.indices.data=new Uint16Array(t.indices.data));let i=new Fe;if(i.name=e,"indices"in t&&(t.indices.data.length>65535?t.indices.data=new Uint32Array(t.indices.data):t.indices.data=new Uint16Array(t.indices.data)),a.morphTargetsRelative){let l=new Ao,c=a.targetNames;if(c&&c.length>0){l.shapeNames=[],l.shapeIndexs=[];for(let f=0;f<c.length;f++)l.shapeNames.push(c[f]),l.shapeIndexs.push(f)}l.vertexCount=t.position.data.length/3,l.blendCount=l.shapeNames.length,l.blendShapePropertyDatas=[],l.blendShapeMap=new Map;for(let f=0;f<l.blendCount;f++){let h=new po;h.shapeName=l.shapeNames[f],h.shapeIndex=l.shapeIndexs[f],h.frameCount=1,h.blendPositionList=t[Zt.MORPH_POSITION_PREFIX+f].data,h.blendNormalList=t[Zt.MORPH_NORMAL_PREFIX+f].data,l.blendShapePropertyDatas.push(h),l.blendShapeMap.set(h.shapeName,h)}i.blendShapeData=l}i.morphTargetsRelative=a.morphTargetsRelative;let n=a.targetNames;if(n&&n.length>0){let l=i.morphTargetDictionary={};for(let c=0;c<n.length;c++)l[n[c]]=c}if(i.morphTargetDictionary){let l=t.position.data.length/3,c=new Float32Array(l);for(let f=0;f<l;f++)c[f]=f;t.vIndex={data:c,normalize:!1,numComponents:1}}for(const l in t){let c=t[l];i.setAttribute(l,c.data)}if(r){i.skinNames=new Array(r.joints.length);for(let l=0;l<r.joints.length;l++){const c=r.joints[l],f=this.gltf.nodes[c];i.skinNames[l]=f.name}i.bindPose=new Array(r.inverseBindMatrices.length);for(let l=0;l<r.inverseBindMatrices.length;l++){const c=r.inverseBindMatrices[l];let f=new R;f.rawData.set(c),i.bindPose[l]=f}}let o=i.getAttribute(V.indices);return i.addSubGeometry({indexStart:0,indexCount:o.data.length,vertexStart:0,index:0,vertexCount:0,firstStart:0,topology:0}),i}applyMaterialExtensions(e,t){return e.extensions&&(N0.apply(this.gltf,e,t),V0.apply(this.gltf,e,t),P0.apply(this.gltf,e,t)),t}parseSkinJoints(e){let t=[];for(let a of e.joints){let r=this.gltf.nodes[a];t.push(r.name)}return t}}class hn{currentSceneName;gltf;initUrl;_generator;_version;_BASE64_MARKER=";base64,";_cameraParser=null;_meshParser=null;_materialParser=null;_skinParser=null;_skeletonParser=null;_converter=null;constructor(){}get version(){return this.version?this.version:this.gltf?this.gltf.asset?(this._version=this.gltf.asset.version,this.gltf.asset.minVersion&&(this._version+=`\r minVersion${this.gltf.asset.minVersion}`),this.version):this.errorMiss("asset"):(console.warn("glTF not loaded."),null)}async parse(e,t,a){this.gltf=t,this.initUrl=e;const{version:r,generator:i}=this.gltf.asset;if(this._generator=i,r!=="2.0")return console.error(`GLTFParser only support glTF 2.0 for now! Received glTF version: ${this.version}`),!1;const n={nodes:await this.parseScene(a),animations:this.parseAnimations(),name:this.currentSceneName};return await this.convertToNode(n)}destroy(){Es.unload(this.gltf),this.gltf=null}async parseScene(e){const t=e||this.gltf.scene||0,a=this.gltf.scenes[t];if(typeof a>"u")return this.errorMiss("scene",t);this.currentSceneName=a.name||"GLTF_NO_NAME_SCENE";const r=[],i=a.nodes;for(let n=0;n<i.length;n++){const o=await this.parseNode(i[n]);o&&r.push(o)}return r}async parseNode(e){const t=this.gltf.nodes[e];if(!t)return this.errorMiss("node",e);if(t.isParsed)return t.dnode;const{name:a,matrix:r,translation:i,rotation:n,scale:o}=t,l={name:a,matrix:r,translation:i,rotation:n,scale:o,nodeId:e,camera:null,primitives:null,skin:null,children:null,light:null};if(t.camera!==void 0&&(l.camera=this.parseCamera(t.camera)),t.mesh!==void 0&&(l.primitives=await this.parseMesh(t.mesh)),t.extensions!==void 0&&this.applyNodeExtensions(t,l),t.skin!==void 0){const c=this.parseSkin(t.skin);c&&(l.skin=c)}if(l.children=[],t.children)for(let c=0;c<t.children.length;c++)l.children.push(await this.parseNode(t.children[c]));return t.dnode=l,t.isParsed=!0,t.dnode}errorMiss(e,t){throw new Error(e+t)}parseCamera(e){return this._cameraParser||(this._cameraParser=new R0(this.gltf)),this._cameraParser.parse(e)}async parseMesh(e){return this._meshParser||(this._meshParser=new w0(this)),this._meshParser.parse(e)}async parseTexture(e){let t=this.gltf.textures[e];if(t&&!t.dtexture){if(t&&t.source!=null){let a=this.gltf.images[t.source];if(a.uri){let r=a.uri;r=yt.getURLName(r),t.dtexture=this.gltf.resources[r]}else if(a.bufferView){let r=this.parseBufferView(a.bufferView),i=new La,n=new Blob([r],{type:a.mimeType});await i.loadFromBlob(n),t.dtexture=i}else t.dtexture=this.gltf.resources[a.name]}else if(t.name){let a=yt.getURLName(t.name);t.dtexture=this.gltf.resources[a]}}return t.dtexture||console.log("miss texture , please check texture!",e,t),t.dtexture}async parseMaterial(e){return this._materialParser||(this._materialParser=new I0(this)),this._materialParser.parse(e)}parseAnimations(){return[]}async parseObject3D(e,t){return this._converter||(this._converter=new O0(this)),this._converter.convertNodeToObject3D(e,t)}parseSkeleton(e){return this._skeletonParser||(this._skeletonParser=new ws(this)),this._skeletonParser.parse(e)}parseSkeletonAnimation(e,t){return this._skeletonParser||(this._skeletonParser=new ws(this)),this._skeletonParser.parseSkeletonAnimation(e,t)}async traverse(e,t){for(let a=0;a<t.length;a++){const r=await this.parseObject3D(t[a],e);await this.traverse(r,t[a].children)}}async convertToNode(e){const t=new d.Object3D;t.name=e.name;const a=e.nodes;e.animations;const r=[],i=[];return await this.traverse(t,a),{rootNode:t,textures:r,animations:void 0,cameras:i}}parseSkin(e){return this._skinParser||(this._skinParser=new Q0(this)),this._skinParser.parse(e)}parseAccessor(e){const t=this.gltf.accessors[e];if(!t)return this.errorMiss("accessor",e);if(t.isParsed)return t.daccessor;t.isParsed=!0,t.daccessor=!1;const a=!!t.normalized,r=this.gltf.bufferViews[t.bufferView],i=r&&r.byteStride,n=ks(t.componentType);let o=1;switch(t.type){case"SCALAR":o=1;break;case"VEC2":o=2;break;case"VEC3":o=3;break;case"VEC4":case"MAT2":o=4;break;case"MAT3":o=9;break;case"MAT4":o=16;break;default:o=0;break}if(o===0)return console.error(`glTF has unknown data type in accessor: ${t.type}`),!1;const l=o*n.BYTES_PER_ELEMENT;let c;if(r!==void 0){if(c=this.parseBufferView(t.bufferView),!c)return t.daccessor}else c=new Uint8Array(l*t.count).buffer;let f=this.getTypedArrayFromArrayBuffer(c,i,t.byteOffset||0,n,o,t.count);if(t.sparse){const{count:h,indices:u,values:g}=t.sparse;f=new n(f);const p=u.byteOffset||0,m=this.gltf.bufferViews[u.bufferView],D=ks(u.componentType),_=this.parseBufferView(u.bufferView),B=this.getTypedArrayFromArrayBuffer(_,m.byteStride,p,D,1,h),v=g.byteOffset||0,C=this.gltf.bufferViews[g.bufferView],y=this.parseBufferView(g.bufferView),F=this.getTypedArrayFromArrayBuffer(y,C.byteStride,v,n,o,h);for(let k=0;k<B.length;k++)f.set(F.slice(k*o,k*o+o),B[k]*o)}return t.computeResult={typedArray:f,arrayType:n,numComponents:o},t.daccessor={data:f,numComponents:o,normalize:a},t.daccessor}getTypedArrayFromArrayBuffer(e,t,a,r,i,n){let o;const l=i*r.BYTES_PER_ELEMENT;if(t&&l!==t){const c=i*n;o=new r(c);for(let f=0;f<n;f++){const h=new r(e,a+f*t,i);for(let u=0;u<i;u++)o[f*i+u]=h[u]}}else o=new r(e,a,n*i);return o}parseBufferView(e){const t=this.gltf.bufferViews[e];if(!t)return this.errorMiss("bufferView",e);if(t.isParsed)return t.dbufferView;t.isParsed=!0,t.dbufferView=!1;const a=this.parseBuffer(t.buffer);if(a){const{byteOffset:r,byteLength:i}=t,n=new Uint8Array(a,r||0,i);t.dbufferView=new Uint8Array(n).buffer}return t.dbufferView}parseBuffer(e){const t=this.gltf.buffers[e];if(!t)return this.errorMiss("buffer",e);if(t.isParsed)return t.dbuffer;if(t.isParsed=!0,t.dbuffer=!1,t.uri.substring(0,5)!=="data:"){const a=t.uri,r=this.gltf.resources[a];r?r.byteLength===t.byteLength?t.dbuffer=this.gltf.resources[a]:console.error(`load gltf resource "${a}" at buffers[${e} failed, ArrayBuffer.byteLength not equals buffer's byteLength]`):console.error(`load gltf resource "${a}" at buffers[${e}] failed`)}else{const a=t.uri.indexOf(this._BASE64_MARKER)+this._BASE64_MARKER.length,r=window.atob(t.uri.substring(a)),i=new Uint8Array(r.length);for(let n=0;n<r.length;n++)i[n]=r.charCodeAt(n);t.dbuffer=i.buffer}return t.dbuffer}getLight(e){return this.gltf.extensions.KHR_lights_punctual.lights[e]}applyNodeExtensions(e,t){let a=e.extensions;a.KHR_lights_punctual&&this.gltf.extensions.KHR_lights_punctual&&(t.light=this.getLight(a.KHR_lights_punctual.light))}}class L0{magic;version;length}class G0{chunkLength;chunkType;chunkData}class Qs extends nt{static format=Ge.BIN;_gltf;async parseBuffer(e){let t=new Uint8Array(e);t.pos=0;const a=this.parseHeader(t);if(a.magic!=1179937895)return console.error("invalid GLB file"),!1;if(a.version!==2)return console.error(`GLBParser only support glTF 2.0 for now! Received glTF version: ${a.version}`),!1;let r=[];for(;t.pos<t.length;){let h=this.parseChunk(t);r.push(h)}if(r[0].chunkType!=1313821514)return console.error("invalid GLBChunk"),!1;let i="",n=65535,o=r[0].chunkData;for(let h=0;h<o.length;h+=n){let u=o.length-h;u=Math.min(u,n);let g=o.subarray(h,h+u);i+=String.fromCharCode(...g)}let l=JSON.parse(i);this._gltf=new fn,this._gltf={...this._gltf,...l},this._gltf.resources={};for(let h=0;h<this._gltf.buffers.length;h++){let u=this._gltf.buffers[h];u.isParsed=!0,u.dbuffer=r[h+1].chunkData.buffer}if(this._gltf.images)for(let h=0;h<this._gltf.images.length;h++){let u=this._gltf.images[h];u.name=u.name||"bufferView_"+u.bufferView.toString();const g=this._gltf.bufferViews[u.bufferView],p=this._gltf.buffers[g.buffer];let m=new Uint8Array(p.dbuffer,g.byteOffset,g.byteLength),D=new Blob([m],{type:u.mimeType}),_=new La;await _.loadFromBlob(D),_.name=u.name,this._gltf.resources[u.name]=_}let f=await new hn().parse(this.initUrl,this._gltf,this._gltf.scene);return f?(this.data=f.rootNode,f.rootNode):null}async parseJsonAndBuffer(e,t){this._gltf=new fn,this._gltf={...this._gltf,...e},this._gltf.resources={};let a=this._gltf.buffers[0];if(a.isParsed=!0,a.dbuffer=t,this._gltf.images)for(let n=0;n<this._gltf.images.length;n++){let o=this._gltf.images[n];o.name=o.name||"bufferView_"+o.bufferView.toString();const l=this._gltf.bufferViews[o.bufferView],c=this._gltf.buffers[l.buffer];let f=new Uint8Array(c.dbuffer,l.byteOffset,l.byteLength),h=new Blob([f],{type:o.mimeType}),u=new La;await u.loadFromBlob(h),u.name=o.name,this._gltf.resources[o.name]=u}let i=await new hn().parse(this.initUrl,this._gltf,this._gltf.scene);return i?(this.data=i.rootNode,i.rootNode):null}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}parseHeader(e){let t=e.pos,a=new L0,r=new Uint32Array(e.buffer,t,3);return e.pos+=r.byteLength,a.magic=r[0],a.version=r[1],a.length=r[2],a}parseChunk(e){let t=e.pos,a=new G0,r=new Uint32Array(e.buffer,t,2);t=e.pos+=r.byteLength,a.chunkLength=r[0],a.chunkType=r[1],a.chunkData=new Uint8Array(e.buffer,t,a.chunkLength);const i=new Uint8Array(a.chunkLength);for(let n=0;n<a.chunkLength;n++)i[n]=a.chunkData[n];return a.chunkData=i,e.pos+=a.chunkLength,a}}class z0 extends it{constructor(){super();let e=new Ne("PBRLItShader","PBRLItShader");e.setShaderEntry("VertMain","FragMain"),e.passType=H.COLOR,this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformColor("baseColor",new O(.75,.75,.75,1)),this.setUniformColor("emissiveColor",new O(0,0,0)),this.setUniformVector4("materialF0",new $(.04,.04,.04,1)),this.setUniformColor("specularColor",new O(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",1),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new O(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this.setUniformFloat("clearcoatIor",1.5),this.setUniformVector4("baseMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("normalMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("emissiveMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("roughnessMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("metallicMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("aoMapOffsetSize",new $(0,0,1,1)),this.baseMap=A.res.whiteTexture,this.normalMap=A.res.normalTexture,this.maskMap=A.res.maskTexture}get baseMap(){return this.getDefaultColorShader().getTexture("baseMap")}set baseMap(e){this.getDefaultColorShader().setTexture("baseMap",e)}get baseColor(){return this.getDefaultColorShader().getUniform("baseColor")}set baseColor(e){this.getDefaultColorShader().setUniformColor("baseColor",e)}get normalMap(){return this.getDefaultColorShader().getTexture("normalMap")}set normalMap(e){this.getDefaultColorShader().setTexture("normalMap",e)}get doubleSide(){return this.getDefaultColorShader().doubleSide}set doubleSide(e){this.getDefaultColorShader().doubleSide=e}get alphaCutoff(){return this.getDefaultColorShader().shaderState.alphaCutoff}set alphaCutoff(e){this.getDefaultColorShader().setDefine("USE_ALPHACUT",!0),this.getDefaultColorShader().shaderState.alphaCutoff=e,this.getDefaultColorShader().setUniform("alphaCutoff",e)}get emissiveColor(){return this.getDefaultColorShader().getUniform("emissiveColor")}set emissiveColor(e){this.getDefaultColorShader().setUniform("emissiveColor",e)}get emissiveIntensity(){return this.getDefaultColorShader().getUniform("emissiveIntensity")}set emissiveIntensity(e){this.getDefaultColorShader().setUniform("emissiveIntensity",e)}get transformUV1(){return this.getDefaultColorShader().uniforms.transformUV1.vector4}set transformUV1(e){this.getDefaultColorShader().setUniform("transformUV1",e)}get uvTransform_2(){return this.getDefaultColorShader().uniforms.transformUV2.vector4}set uvTransform_2(e){this.getDefaultColorShader().setUniform("transformUV2",e)}get depthWriteEnabled(){return this.getDefaultColorShader().shaderState.depthWriteEnabled}set depthWriteEnabled(e){this.getDefaultColorShader().shaderState.depthWriteEnabled=e}get materialF0(){return this.getDefaultColorShader().uniforms.materialF0.vector4}set materialF0(e){this.getDefaultColorShader().setUniform("materialF0",e)}get specularColor(){return this.getDefaultColorShader().uniforms.specularColor.color}set specularColor(e){this.getDefaultColorShader().setUniform("specularColor",e)}get roughness(){return this.getDefaultColorShader().uniforms.roughness.value}set roughness(e){this.getDefaultColorShader().setUniform("roughness",e)}get metallic(){return this.getDefaultColorShader().uniforms.metallic.value}set metallic(e){this.getDefaultColorShader().setUniform("metallic",e)}get ao(){return this.getDefaultColorShader().uniforms.ao.value}set ao(e){this.getDefaultColorShader().setUniform("ao",e)}get metallic_min(){return this.getDefaultColorShader().uniforms.metallic_min.value}set metallic_min(e){this.getDefaultColorShader().setUniform("metallic_min",e)}get metallic_max(){return this.getDefaultColorShader().uniforms.metallic_max.value}set metallic_max(e){this.getDefaultColorShader().setUniform("metallic_max",e)}get roughness_min(){return this.getDefaultColorShader().uniforms.roughness_min.value}set roughness_min(e){this.getDefaultColorShader().setUniform("roughness_min",e)}get roughness_max(){return this.getDefaultColorShader().uniforms.roughness_max.value}set roughness_max(e){this.getDefaultColorShader().setUniform("roughness_max",e)}get normalScale(){return this.getDefaultColorShader().uniforms.normalScale.value}set normalScale(e){this.getDefaultColorShader().setUniform("normalScale",e)}get maskMap(){return this.getDefaultColorShader().textures.maskMap}set maskMap(e){this.getDefaultColorShader().setDefine("USE_MR",!0),this.getDefaultColorShader().setTexture("maskMap",e)}set aoMap(e){e&&(this.getDefaultColorShader().setTexture("aoMap",e),e!=A.res.whiteTexture&&this.getDefaultColorShader().setDefine("USE_AOTEX",!0))}get aoMap(){return this.getDefaultColorShader().textures.aoMap}set clearCoatRoughnessMap(e){e&&(console.log("USE_CLEARCOAT_ROUGHNESS"),this.getDefaultColorShader().setTexture("clearCoatRoughnessMap",e),this.getDefaultColorShader().setDefine("USE_CLEARCOAT_ROUGHNESS",!0))}get clearCoatRoughnessMap(){return this.getDefaultColorShader().textures.clearCoatRoughnessMap}get brdfLUT(){return this.getDefaultColorShader().textures.brdfLUT}set brdfLUT(e){this.getDefaultColorShader().setTexture("brdfLUT",e),this.getDefaultColorShader().setTexture("brdflutMap",e)}get emissiveMap(){return this.getDefaultColorShader().textures.emissiveMap}set emissiveMap(e){this.getDefaultColorShader().setTexture("emissiveMap",e)}set envIntensity(e){this.getDefaultColorShader().setUniformFloat("envIntensity",e)}get envIntensity(){return this.getDefaultColorShader().uniforms.envIntensity.value}set ior(e){this.getDefaultColorShader().setUniformFloat("ior",e)}get ior(){return this.getDefaultColorShader().uniforms.ior.value}useCleanCoat(){this.getDefaultColorShader().setDefine("USE_CLEARCOAT",!0)}set clearcoatFactor(e){this.getDefaultColorShader().setUniformFloat("clearcoatFactor",e),this.useCleanCoat()}get clearcoatFactor(){return this.getDefaultColorShader().uniforms.clearcoatFactor.value}set clearcoatRoughnessFactor(e){this.getDefaultColorShader().setUniformFloat("clearcoatRoughnessFactor",e),this.useCleanCoat()}get clearcoatRoughnessFactor(){return this.getDefaultColorShader().uniforms.clearcoatRoughnessFactor.value}set clearcoatWeight(e){this.getDefaultColorShader().setUniformFloat("clearcoatWeight",e),this.useCleanCoat()}get clearcoatWeight(){return this.getDefaultColorShader().uniforms.clearcoatWeight.value}set clearcoatColor(e){this.getDefaultColorShader().setUniformColor("clearcoatColor",e),this.useCleanCoat()}get clearcoatColor(){return this.getDefaultColorShader().uniforms.clearcoatColor.color}}class pa extends ut{constructor(){super();let e=new z0;this.shader=e}clone(){let e=new pa,t=e.shader.getDefaultColorShader(),a=this.shader.getDefaultColorShader();return t.defineValue={...a.defineValue},t.setUniform("shadowBias",a.getUniform("shadowBias")),t.setUniform("baseColor",a.getUniform("baseColor")),t.setUniform("specularColor",a.getUniform("specularColor")),t.setUniform("emissiveColor",a.getUniform("emissiveColor")),t.setUniform("materialF0",a.getUniform("materialF0")),t.setUniform("envIntensity",a.getUniform("envIntensity")),t.setUniform("normalScale",a.getUniform("normalScale")),t.setUniform("roughness",a.getUniform("roughness")),t.setUniform("metallic",a.getUniform("metallic")),t.setUniform("ao",a.getUniform("ao")),t.setUniform("roughness_min",a.getUniform("roughness_min")),t.setUniform("roughness_max",a.getUniform("roughness_max")),t.setUniform("metallic_min",a.getUniform("metallic_min")),t.setUniform("metallic_max",a.getUniform("metallic_max")),t.setUniform("emissiveIntensity",a.getUniform("emissiveIntensity")),t.setUniform("alphaCutoff",a.getUniform("alphaCutoff")),t.setUniform("ior",a.getUniform("ior")),t.setUniform("clearcoatFactor",a.getUniform("clearcoatFactor")),t.setUniform("clearcoatRoughnessFactor",a.getUniform("clearcoatRoughnessFactor")),t.setUniform("clearcoatColor",a.getUniform("clearcoatColor")),t.setUniform("clearcoatWeight",a.getUniform("clearcoatWeight")),t.setUniform("clearcoatIor",a.getUniform("clearcoatIor")),t.setTexture("baseMap",a.getTexture("baseMap")),t.setTexture("normalMap",a.getTexture("normalMap")),t.setTexture("emissiveMap",a.getTexture("emissiveMap")),t.setTexture("aoMap",a.getTexture("aoMap")),t.setTexture("maskMap",a.getTexture("maskMap")),t.setTexture("empty",a.getTexture("empty")),t.setUniform("baseMapOffsetSize",a.getUniform("baseMapOffsetSize")),t.setUniform("normalMapOffsetSize",a.getUniform("normalMapOffsetSize")),t.setUniform("emissiveMapOffsetSize",a.getUniform("emissiveMapOffsetSize")),t.setUniform("roughnessMapOffsetSize",a.getUniform("roughnessMapOffsetSize")),t.setUniform("metallicMapOffsetSize",a.getUniform("metallicMapOffsetSize")),t.setUniform("aoMapOffsetSize",a.getUniform("aoMapOffsetSize")),e}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set maskMap(e){this.shader.setTexture("maskMap",e)}get maskMap(){return this.shader.getTexture("maskMap")}set normalMap(e){this.shader.setTexture("normalMap",e)}get normalMap(){return this.shader.getTexture("normalMap")}set emissiveMap(e){this.shader.setTexture("emissiveMap",e)}get emissiveMap(){return this.shader.getTexture("emissiveMap")}set aoMap(e){this.shader.setTexture("aoMap",e)}get aoMap(){return this.shader.getTexture("aoMap")}set clearCoatRoughnessMap(e){this.shader.setTexture("clearCoatRoughnessMap",e),this.shader.setDefine("USE_CLEARCOAT",!0),this.shader.setDefine("USE_CLEARCOAT_ROUGHNESS",!0)}get clearCoatRoughnessMap(){return this.shader.getTexture("clearCoatRoughnessMap")}set clearcoatColor(e){this.shader.setUniformColor("clearcoatColor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatColor(){return this.shader.getUniformColor("clearcoatColor")}set clearcoatWeight(e){this.shader.setUniformFloat("clearcoatWeight",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatWeight(){return this.shader.getUniformFloat("clearcoatWeight")}set clearcoatFactor(e){this.shader.setUniformFloat("clearcoatFactor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatFactor(){return this.shader.getUniformFloat("clearcoatFactor")}set clearcoatRoughnessFactor(e){this.shader.setUniformFloat("clearcoatRoughnessFactor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatRoughnessFactor(){return this.shader.getUniformFloat("clearcoatRoughnessFactor")}set ior(e){this.shader.setUniformFloat("clearcoatIor",e)}get ior(){return this.shader.getUniformFloat("clearcoatIor")}set alphaCutoff(e){this.shader.setUniform("alphaCutoff",e)}get alphaCutoff(){return this.shader.getUniform("alphaCutoff")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}get roughness(){return this.shader.getUniformFloat("roughness")}set roughness(e){this.shader.setUniformFloat("roughness",e)}get metallic(){return this.shader.getUniformFloat("metallic")}set metallic(e){this.shader.setUniformFloat("metallic",e)}get emissiveColor(){return this.shader.getUniformColor("emissiveColor")}set emissiveColor(e){this.shader.setUniformColor("emissiveColor",e)}get emissiveIntensity(){return this.shader.getUniformFloat("emissiveIntensity")}set emissiveIntensity(e){this.shader.setUniformFloat("emissiveIntensity",e)}get ao(){return this.shader.getUniform("ao")}set ao(e){this.shader.setUniform("ao",e)}}class J0 extends nt{static format=Ge.TEXT;textData="";source_vertices;source_normals;source_tangents;source_textureCoords;matLibs;geometrys;activeGeo;currentObjectName;currentMaterialName;facesMaterialsIndex;mtl;mtlUrl;async parseString(e){return this.source_vertices=[],this.source_normals=[],this.source_tangents=[],this.source_textureCoords=[],this.currentObjectName="default",this.currentMaterialName="",this.matLibs={},this.geometrys={},this.activeGeo=void 0,this.textData=e,await Promise.all([this.parserOBJ(),this.loadMTL()]),this.parser_mesh(),"null"}applyVector2(e,t,a){e>=0&&t[e]&&t[e].length>0?(a.push(t[e][0]),a.push(-t[e][1])):(a.push(0),a.push(0))}applyVector3(e,t,a){e>=0&&t[e]&&t[e].length>0?(a.push(t[e][0]),a.push(t[e][1]),a.push(t[e][2])):(a.push(0),a.push(0),a.push(0))}applyVector4(e,t,a){a.push(t[e][0]),a.push(t[e][1]),a.push(t[e][2]),a.push(t[e][3])}parseUVIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}parseVertexIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}parseNormalIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}calculateFaceNormal(e,t,a){const r=[t[0]-e[0],t[1]-e[1],t[2]-e[2]],i=[a[0]-e[0],a[1]-e[1],a[2]-e[2]],n=[r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]],o=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);return o>0&&(n[0]/=o,n[1]/=o,n[2]/=o),n}async loadMTL(){let t=await new At().loadTxt(this.baseUrl+this.mtlUrl),a=t.data,r,i=a.split(/\r?\n/);for(let c=0;c<i.length;c++){let f=i[c];var n=f.indexOf("#");n!=-1&&(f=f.substring(0,n)),f=f.trim();var o=f.split(/\s+/);o[0]==="newmtl"?(r={name:o[1]},this.matLibs[o[1]]=r):o[0].indexOf("map_")!=-1?(r[o[0]]=o[1],r.textures||(r.textures=[o[o.length-1]]),r.textures.push(o[o.length-1])):o.length==2?r[o[0]]=Number(o[1]):o.length==3?r[o[0]]=[Number(o[1]),Number(o[2])]:o.length==4&&(r[o[0]]=[Number(o[1]),Number(o[2]),Number(o[3])])}const l=[];for(const c in this.matLibs){const f=this.matLibs[c];if(f.textures&&f.textures.length>0)for(let h=0;h<f.textures.length;h++){const u=yt.normalizePath(this.baseUrl+f.textures[h]);l.push(A.res.loadTexture(u).catch(g=>(console.error(`Failed to load texture: ${u}`,g),null)))}}return await Promise.all(l),t=null,!0}async load_textures(){}getGeometryKey(e,t){const a=(e??this.currentObjectName??"default")||"default",r=t??this.currentMaterialName??"",i=r.length>0?r:"default";return`${a}::${i}`}ensureActiveGeo(e,t){const a=(e??this.currentObjectName??"default")||"default",r=t??this.currentMaterialName??"",i=this.getGeometryKey(a,r);this.geometrys[i]?this.geometrys[i].source_mat!==r&&(this.geometrys[i].source_mat=r):this.geometrys[i]={type:a,name:i,source_mat:r,source_faces:[]},this.activeGeo=this.geometrys[i]}parserLine(e){var t=e.indexOf("#");if(t!=-1){if(e.indexOf("# object")!=-1){const p=e.split(/\s+/),m=p[1]||"default",D=p[2]||"default";this.currentObjectName=D,this.activeGeo=void 0,this.ensureActiveGeo(D,this.currentMaterialName),this.activeGeo&&(this.activeGeo.type=m)}e=e.substring(0,t)}e=e.trim();var a=e.split(/\s+/);if(a[0]==="v"){var r=[Number(a[1]),Number(a[2]),Number(a[3]),a[4]?1:Number(a[4])];this.source_vertices.push(r)}else if(a[0]==="vt"){var i=[Number(a[1]),Number(a[2]),a[3]?1:Number(a[3])];this.source_textureCoords.push(i)}else if(a[0]==="vn"){var n=[Number(a[1]),Number(a[2]),Number(a[3])];this.source_normals.push(n)}else if(a[0]==="f"){for(var o={indices:[],texture:[],normal:[]},l=1;l<a.length;++l){var c=a[l];if(c.length!==0){var f=c.split("/"),h=f[0]||"",u=f.length>=2&&f[1]||"",g=f.length>=3&&f[2]||"";h.length!==0&&(o.indices.push(h),o.texture.push(u),o.normal.push(g))}}this.ensureActiveGeo(),this.activeGeo.source_faces.push(o)}else a[0]==="usemtl"?(this.currentMaterialName=a[1]||"",this.ensureActiveGeo(this.currentObjectName,this.currentMaterialName)):a[0]==="mtllib"&&(this.mtlUrl=a[1])}async parserOBJ(){let e=this.textData.split(/\r?\n/);for(let t=0;t<e.length;t++){const a=e[t];this.parserLine(a)}return this.textData="",!0}async parser_mesh(){let e=new d.Object3D;for(const t in this.geometrys){const a=this.geometrys[t];a.vertex_arr=[],a.normal_arr=[],a.uv_arr=[],a.indeice_arr=[];let r=0;const i=this.source_vertices.length,n=this.source_normals.length,o=this.source_textureCoords.length;for(let p=0;p<a.source_faces.length;p++){const m=a.source_faces[p];let D=this.parseVertexIndex(m.indices[0],i),_=this.parseVertexIndex(m.indices[1],i),B=this.parseVertexIndex(m.indices[2],i);const v=G=>{if(!G||G.length===0)return-1;const X=this.parseNormalIndex(G,n);return Number.isFinite(X)&&X>=0&&X<n?X:-1},C=G=>{if(!G||G.length===0)return-1;const X=this.parseUVIndex(G,o);return Number.isFinite(X)&&X>=0&&X<o?X:-1};let y=v(m.normal[0]),F=v(m.normal[1]),k=v(m.normal[2]);const w=y<0||F<0||k<0;let x=null;w&&D>=0&&_>=0&&B>=0&&this.source_vertices[D]&&this.source_vertices[_]&&this.source_vertices[B]&&(x=this.calculateFaceNormal(this.source_vertices[D],this.source_vertices[_],this.source_vertices[B]));let M=C(m.texture[0]),N=C(m.texture[1]),Q=C(m.texture[2]);if(this.applyVector3(D,this.source_vertices,a.vertex_arr),y>=0?this.applyVector3(y,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),M>=0?this.applyVector2(M,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(_,this.source_vertices,a.vertex_arr),F>=0?this.applyVector3(F,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),N>=0?this.applyVector2(N,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(B,this.source_vertices,a.vertex_arr),k>=0?this.applyVector3(k,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),Q>=0?this.applyVector2(Q,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,m.indices.length>3){let G=this.parseVertexIndex(m.indices[3],i),X=v(m.normal[3]),ne=C(m.texture[3]),q=null;(y<0||k<0||X<0)&&D>=0&&B>=0&&G>=0&&this.source_vertices[D]&&this.source_vertices[B]&&this.source_vertices[G]&&(q=this.calculateFaceNormal(this.source_vertices[D],this.source_vertices[B],this.source_vertices[G])),this.applyVector3(D,this.source_vertices,a.vertex_arr),y>=0?this.applyVector3(y,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),M>=0?this.applyVector2(M,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(B,this.source_vertices,a.vertex_arr),k>=0?this.applyVector3(k,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),Q>=0?this.applyVector2(Q,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(G,this.source_vertices,a.vertex_arr),X>=0?this.applyVector3(X,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),ne>=0?this.applyVector2(ne,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++}}let l=new Fe;l.setIndices(new Uint32Array(a.indeice_arr)),l.setAttribute(V.position,new Float32Array(a.vertex_arr)),l.setAttribute(V.normal,new Float32Array(a.normal_arr)),l.setAttribute(V.uv,new Float32Array(a.uv_arr)),l.setAttribute(V.TEXCOORD_1,new Float32Array(a.uv_arr)),l.addSubGeometry({indexStart:0,indexCount:a.indeice_arr.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let c=new pa;const f=a.source_mat,h=f?this.matLibs[f]:void 0;if(h&&h.map_Kd){const p=yt.normalizePath(this.baseUrl+h.map_Kd),m=A.res.getTexture(p);m&&(c.baseMap=m)}let u=new d.Object3D,g=u.addComponent(d.MeshRenderer);g.geometry=l,g.material=c,e.addChild(u)}this.data=e}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}}let W0=`
7275
+ `;class Es{static _workerCode;static _workers=new Map;static async apply(e,t){if(!t.extensions)return;const a=t.extensions.KHR_draco_mesh_compression;if(!a)return;let r=this._workers.get(e.gltf);r||(r=new Worker(await this.initDecoder()),this._workers.set(e.gltf,r)),r.postMessage({type:"init",decoderConfig:{}});let i=e.parseBufferView(a.bufferView);if(!i.result){let n=await new Promise((o,l)=>{r.onmessage=c=>{const f=c.data;f.type=="decode"?o(f.result):f.type=="error"&&l(f.error)},r.postMessage({type:"decoder",buffer:i,attributes:a.attributes},[i])});i.result=n}return i.result}static unload(e){let t=this._workers.get(e);t&&(t.terminate(),this._workers.delete(e))}static async initDecoder(){if(!this._workerCode){const e=new Blob([E0,"",`(${B2})()`],{type:"application/javascript"});this._workerCode=URL.createObjectURL(e)}return this._workerCode}}function B2(){let s,e;onmessage=t=>{const a=t.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise((n,o)=>{s.onModuleLoaded=l=>{n({draco:l})},DracoDecoderModule(s)});break;case"decoder":const r=a.buffer,i=a.attributes;e.then(n=>{const o=n.draco;let l=new o.Decoder,c=new o.DecoderBuffer;c.Init(new Int8Array(r),r.byteLength);let f,h;try{const u=l.GetEncodedGeometryType(c);u==o.TRIANGULAR_MESH?(h=new o.Mesh,f=l.DecodeBufferToMesh(c,h)):self.postMessage(new Error("INVALID_GEOMETRY_TYPE:"+u)),f.ok()||self.postMessage(new Error("DracoDecode:"+f.error_msg()));let g={};for(const p in i){let m=l.GetAttributeByUniqueId(h,i[p]);const D=m.num_components(),B=h.num_points()*D,v=B*Float32Array.BYTES_PER_ELEMENT,C=o.DT_FLOAT32,y=o._malloc(v);l.GetAttributeDataArrayForAllPoints(h,m,C,v,y);const F=new Float32Array(o.HEAPF32.buffer,y,B).slice();o._free(y),g[p]={data:F,numComponents:D,normalize:!1}}{const m=h.num_faces()*3,D=m*4,_=o._malloc(D);l.GetTrianglesUInt32Array(h,D,_);const B=new Uint32Array(o.HEAPF32.buffer,_,m).slice();o._free(_),g.indices={data:B,numComponents:1,normalize:!1}}self.postMessage({type:"decode",result:g})}catch(u){self.postMessage({type:"error",error:u.message})}finally{o.destroy(h),o.destroy(l),o.destroy(c)}});break}}}class R0{gltf;constructor(e){this.gltf=e}parse(e){const t=this.gltf.cameras[e];if(!t)return this.errorMiss("camera",e);if(t.isParsed)return t.dcamera;t.isParsed=!0,t.dcamera=!1;const{name:a,type:r,perspective:i,orthographic:n}=t;if(r==="perspective"&&i){const{aspectRatio:o,yfov:l,zfar:c,znear:f}=i;t.dcamera=Object.assign({},{name:a,type:r,yfov:l,znear:f,aspectRatio:o,zfar:c})}else if(r==="orthographic"&&n){const{xmag:o,ymag:l,zfar:c,znear:f}=n;t.dcamera=Object.assign({},{name:a,type:r,xmag:o,ymag:l,zfar:c,znear:f})}return t.dcamera}errorMiss(e,t){throw new Error(e+t)}}class Dt extends nt{static format=Ge.JSON;_gltf;async parseJson(e){this._gltf=new fn,this._gltf={...this._gltf,...e},this._gltf.resources={},await Promise.all([this.load_gltf_bin(),this.load_gltf_textures()]);let t=new hn,a=await t.parse(this.initUrl,this._gltf,this._gltf.scene);return t.destroy(),t=null,a?(this.data=a.rootNode,a.rootNode):(this._gltf=null,null)}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}static _counter=0;static getMeshNameCounter(){return function(){return`GLTF_NO_NAME_PRIMITIVE_${Dt._counter++}`}}static getModelNameCounter(){let e=0;return function(){return`GLTF_NO_NAME_MESH_${e++}`}}static getTexCoordDefine(e){return`UV_NUM ${e}`}static getVertexColorDefine(e){return`HAS_VERTEXCOLOR ${e}`}static getBaseColorTextureDefine(){return"HAS_BASECOLORMAP"}static getMetalRoughnessDefine(){return"HAS_METALROUGHNESSMAP"}static getNormalMapDefine(){return"HAS_NORMALMAP"}static getEmissiveMapDefine(){return"HAS_EMISSIVEMAP"}static getOcclusionMapDefine(){return"HAS_OCCLUSIONMAP"}static getMorphTargetsDefine(e){return`MORPH_TARGET_NUM ${e}`}static getMorphtargetPositionDefine(){return"HAS_MORPH_POSITION"}static getMorphtargetNormalDefine(){return"HAS_MORPH_NORMAL"}static getMorphtargetTangentDefine(){return"HAS_MORPH_TANGENT"}static getJointsNumDefine(e){return`JOINTS_NUM ${e}`}static getJointVec8Define(){return"JOINT_VEC8"}static getHasNormalDefine(){return"HAS_NORMAL"}static getHasTangentDefine(){return"HAS_TANGENT"}static getHasNormalMapDefine(){return"HAS_NORMAL_MAP"}static getAlphaMaskDefine(){return"ALPHA_MASK"}static getAlphaBlendDefine(){return"ALPHA_BLEND"}static defaultMaterial={name:"GLTF_DEFAULT_MATERIAL",alphaCutoff:.33,alphaMode:"MASK",pbrMetallicRoughness:{name:"GLTF_DEFAULT_MATERIAL",defines:[],doubleSided:!1,baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1,emissiveFactor:[0,0,0]}};async load_gltf_bin(){if(this._gltf.buffers&&this._gltf.buffers.length>0){let e=[];for(let t=0;t<this._gltf.buffers.length;t++){const a=this._gltf.buffers[t];if(a.uri.substring(0,5)!=="data:"){let r=yt.parseUrl(this.baseUrl,a.uri);this.loaderFunctions?.onUrl&&(r=await this.loaderFunctions.onUrl(r));let i=new At().loadBinData(r,this.loaderFunctions).then(n=>{this._gltf.resources[a.uri]=n});e.push(i)}}await Promise.all(e)}}async load_gltf_textures(){if(this._gltf,this._gltf.images){let e=[];for(let t=0;t<this._gltf.images.length;t++){const a=this._gltf.images[t];if(a.uri){let r=yt.parseUrl(this.baseUrl,a.uri);this.loaderFunctions?.onUrl&&(r=await this.loaderFunctions.onUrl(r));let i=new At().loadAsyncBitmapTexture(r,this.loaderFunctions).then(n=>{n.name=yt.getURLName(a.uri),this._gltf.resources[n.name]=n});e.push(i)}}await Promise.all(e)}}}class w0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}async parse(e){const t=this.gltf.meshes[e];if(!t)return this.errorMiss("mesh",e);if(t.isParsed)return t.dprimitives;const a=t.primitives,r=t.extras,i=[];for(let n=0;n<a.length;n++){const o=a[n],{attributes:l,indices:c,material:f,mode:h,name:u,targets:g,morphTargetsRelative:p,extensions:m}=o;let D=t.name;for(let k in l)D+=k;D+=`indices:${c}`,D+=`material:${f}`;const _={attribArrays:{indices:[]},weights:[],defines:[],material:null,drawMode:null,meshName:null,modelName:null,morphTargetsRelative:!1,targetNames:r?r.targetNames:null};let B=!1,v=0,C=!1,y;m&&m.KHR_draco_mesh_compression&&(y=await Es.apply(this.subParser,o));for(const k in l){const w=y?y[k]:this.parseAccessor(l[k]);if(w){let x;switch(k){case"POSITION":x=V.position;break;case"NORMAL":x=V.normal,B=!0;break;case"TEXCOORD_0":x=V.uv,v++;break;case"JOINTS_0":x=V.joints0;break;case"JOINTS_1":x=V.joints1,C=!0;break;case"WEIGHTS_0":x=V.weights0;break;case"WEIGHTS_1":x=V.weights1;break;default:x=k}_.attribArrays[x]=w}}if(B&&_.defines.push(Dt.getHasNormalDefine()),v&&_.defines.push(Dt.getTexCoordDefine(v)),C&&_.defines.push(Dt.getJointVec8Define()),c!==void 0){const k=y?y.indices:this.parseAccessor(c);k&&(_.attribArrays.indices=k)}const F=await this.parseMaterial(f);if(F&&(_.material=F,_.defines=_.defines.concat(F.defines)),_.drawMode=h===void 0?4:h,_.meshName=()=>D,_.modelName=t.name||Dt.getModelNameCounter(),g){_.defines.push(Dt.getMorphTargetsDefine(g.length)),_.morphTargetsRelative=!0;let k=!1,w=!1,x=!1;for(let M=0;M<g.length;M++){const N=g[M];Object.keys(N).forEach(Q=>{const G=this.parseAccessor(N[Q]);if(G){let X;switch(Q){case"POSITION":X=Zt.MORPH_POSITION_PREFIX+M,k=!0;break;case"NORMAL":X=Zt.MORPH_NORMAL_PREFIX+M,w=!0;break;case"TANGENT":X=Zt.MORPH_TANGENT_PREFIX+M,x=!0;break;default:X=!1}X?_.attribArrays[X]=G:console.error(`glTF has unsupported morph target attribute ${Q}`)}})}k&&_.defines.push(Dt.getMorphtargetPositionDefine()),w&&_.defines.push(Dt.getMorphtargetNormalDefine()),x&&_.defines.push(Dt.getMorphtargetTangentDefine()),_.weights=t.weights||new Array(g.length).fill(0)}i.push(_)}return t.dprimitives=i,t.isParsed=!0,t.dprimitives}parseAccessor(e){return this.subParser.parseAccessor(e)}parseMaterial(e){return this.subParser.parseMaterial(e)}errorMiss(e,t){throw new Error(e+t)}}class I0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}async parse(e){let t;if(e==null?t=Dt.defaultMaterial:t=this.gltf.materials[e],!t)return this.errorMiss("material",e);if(t.isParsed)return t.dmaterial;let{name:a,pbrMetallicRoughness:r,normalTexture:i,occlusionTexture:n,emissiveTexture:o,emissiveFactor:l,alphaMode:c,alphaCutoff:f,doubleSided:h,extensions:u}=t;const g={name:a,defines:[],doubleSided:!!h,baseColorFactor:[1,1,1,1],emissiveFactor:null,alphaCutoff:0,enableBlend:!1,baseColorTexture:null,metallicRoughnessTexture:null,normalTexture:null,occlusionTexture:null,emissiveTexture:null,extensions:null,baseMapOffsetSize:null,normalMapOffsetSize:null,emissiveMapOffsetSize:null,roughnessMapOffsetSize:null,metallicMapOffsetSize:null,aoMapOffsetSize:null,metallicFactor:0,roughnessFactor:1};if(r){const{baseColorFactor:p,metallicFactor:m,roughnessFactor:D,baseColorTexture:_,metallicRoughnessTexture:B}=r;if(Object.assign(g,{baseColorFactor:p||[1,1,1,1],metallicFactor:m===void 0?1:m,roughnessFactor:D===void 0?.5:D}),_){let v=_.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.baseMapOffsetSize=F}}const C=await this.parseTexture(_.index);C?g.baseColorTexture=C:g.baseColorTexture=A.res.redTexture}if(i){let v=i.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.normalMapOffsetSize=F}}const C=await this.parseTexture(i.index);C?g.normalTexture=C:g.normalTexture=A.res.normalTexture}if(B){let v=B.extensions;if(v){let y=v.KHR_texture_transform;if(y){let F=new $(y.offset?y.offset[0]:0,y.offset?y.offset[1]:0,y.scale?y.scale[0]:1,y.scale?y.scale[1]:1);g.roughnessMapOffsetSize=F}}const C=await this.parseTexture(B.index);C?g.metallicRoughnessTexture=C:g.metallicRoughnessTexture=A.res.blackTexture}}else Object.assign(g,{baseColorFactor:[1,1,1,1],metallicFactor:0,roughnessFactor:.5});if(g.baseColorFactor&&g.baseColorFactor[3]<1&&(c=c==="MASK"?"MASK":"BLEND"),c&&c!=="OPAQUE"&&(c==="MASK"&&(g.defines.push(Dt.getAlphaMaskDefine()),g.alphaCutoff=f===void 0?.5:f),c==="BLEND"&&(g.defines.push(Dt.getAlphaBlendDefine()),g.enableBlend=!0)),i){const p=await this.parseTexture(i.index);p?g.normalTexture=p:g.normalTexture=A.res.normalTexture}if(n){const p=await this.parseTexture(n.index);p&&(g.occlusionTexture=p)}if(l&&(g.emissiveFactor=l),o){const p=await this.parseTexture(o.index);p?g.emissiveTexture=p:g.emissiveTexture=A.res.blackTexture}return u&&(g.extensions=u),t.isParsed=!0,t.dmaterial=g,g}async parseTexture(e){return this.subParser.parseTexture(e)}errorMiss(e,t){throw new Error(e+t)}}class Q0{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}parse(e){const t=this.gltf.skins[e];if(!t)return this.errorMiss("skin",e);if(t.isParsed)return t.dskin;const{name:a,joints:r,inverseBindMatrices:i,skeleton:n}=t;if(!r)return this.errorMiss("skin.joints",e);t.isParsed=!0,t.dskin=!1;let o={name:a,skeleton:null,inverseBindMatrices:null,joints:r,defines:[Dt.getJointsNumDefine(r.length)]};if(n)o.skeleton=n;else{var l=-1;for(let c=0;c<this.gltf.nodes.length;c++)if(this.gltf.nodes[c].name=="root"){l=c;break}if(l==-1){let c=this.gltf.scenes[this.gltf.scene];l=c.nodes[c.nodes.length-1]}o.skeleton=l}if(o.inverseBindMatrices=Zt.IDENTITY_INVERSE_BIND_MATRICES,i!==void 0){const c=this.parseAccessor(i);if(c){const f=c.data,h=[];for(let u=0;u<f.length;u+=16)h.push(f.slice(u,u+16));o.inverseBindMatrices=h}else o=null}return t.dskin=o,t.dskin}parseAccessor(e){return this.subParser.parseAccessor(e)}errorMiss(e,t){throw new Error(e+t)}}class T0{name="";index=0;instanceID="";parent=null;scale=new b;rotation=new Z;translation=new b;constructor(e=""){this.name=e}}class Rs{index;worldMatrix;constructor(e,t=!1){this.index=e,this.worldMatrix=new R(!t)}}class vi{time;_skeleton;_jointsPose;mJointMatrixIndexTable;constructor(e,t=!1){this._skeleton=e,this._jointsPose=new Array(e.numJoint),this.mJointMatrixIndexTable=new Array(e.numJoint);for(let a=0;a<e.numJoint;a++){let r=new Rs(a,t);this._jointsPose[a]=r,this.mJointMatrixIndexTable[a]=r.worldMatrix.index}}buildSkeletonPose(e){let t=new b,a=new Z,r=new b,i=new Array(this._skeleton.numJoint);this.time=e[11]>0?e[11]:e[24];for(let n=0;n<this._skeleton.numJoint;n++){let o=12*n*4,l=new Float32Array(e.buffer,e.byteOffset+o,12),c=new R;t.set(l[0],l[1],l[2]),a.set(l[4],l[5],l[6],l[7]),r.set(l[8],l[9],l[10]),en(a.getEulerAngles(),r,t,c),i[n]=c;let f=new Rs(n);const h=this._skeleton.getJointParentIndex(n);if(h<0)f.worldMatrix.copyFrom(c);else{let u=this._jointsPose[h];tc(u.worldMatrix,c,f.worldMatrix)}this._jointsPose[n]=f}}get numJoint(){return this._skeleton.numJoint}get joints(){return this._jointsPose}get jointMatrixIndexTable(){return this.mJointMatrixIndexTable}lerp(e,t,a){if(e&&t)for(let r=0;r<this._jointsPose.length;r++){let i=e._jointsPose[r],n=t._jointsPose[r];this._jointsPose[r].worldMatrix.lerp(i.worldMatrix,n.worldMatrix,a)}else for(let r=0;r<this._jointsPose.length;r++){let i=e._jointsPose[r];this._jointsPose[r].worldMatrix.copyFrom(i.worldMatrix)}}copyFrom(e){for(let t=0;t<this._jointsPose.length;t++)this._jointsPose[t].worldMatrix.copyFrom(e._jointsPose[t].worldMatrix)}reset(){for(let e=0;e<this._jointsPose.length;e++)this._jointsPose[e].worldMatrix.identity()}}class M0 extends qe{skeletonAnimation;constructor(e,t){super(),this.type=e,this.time=t}}class dn{name="";_skeleton;_skeletonPoses;_animationClipData;_events;constructor(e,t,a,r){if(this.name=e,this._skeleton=t,this._animationClipData=r,a>0&&r){this._skeletonPoses=new Array(a);let i=12*t.numJoint;for(let n=0;n<a;n++){let o=i*n*4;const l=r.buffer instanceof ArrayBuffer?r.buffer:new Uint8Array(r.buffer).buffer;let c=new Float32Array(l,o,i),f=new vi(t);f.buildSkeletonPose(c),this._skeletonPoses[n]=f}}}get totalTime(){return this._skeletonPoses[this._skeletonPoses.length-1].time}get frameRate(){return this.totalTime/this._skeletonPoses.length}get skeleton(){return this._skeleton}get numFrame(){return this._skeletonPoses.length-1}get animationClipData(){return this._animationClipData}getSkeletonPose(e){return this._skeletonPoses[e]}getLerpSkeletonPose(e,t,a,r){let i=this.getSkeletonPose(e),n=this.getSkeletonPose(t);return r.lerp(i,n,a),r}createSubClip(e,t,a){var r=new dn(e,this._skeleton,0,null);const i=Math.max(Math.floor(t/this.frameRate),0),n=Math.min(Math.floor(a/this.frameRate),this._skeletonPoses.length-1);r._skeletonPoses=this._skeletonPoses.slice(i,n);const o=12*this._skeleton.numJoint*4,l=this._animationClipData.buffer instanceof ArrayBuffer?this._animationClipData.buffer:new Uint8Array(this._animationClipData.buffer).buffer;return this._animationClipData=new Float32Array(l,i*o,(n-i)*o),r}addEvent(e,t){this._events||(this._events=new Array),this._events.push(new M0(e,t))}removeEvent(e){this._events&&(this._events=this._events.filter(t=>t.type!=e))}getEvents(){return this._events}}class ws{gltf;subParser;constructor(e){this.gltf=e.gltf,this.subParser=e}parse(e){let t=new go;return t.name="Id:"+e,t.count=0,t.boneData=[],t.boneMap=new Map,this.buildSkeleton(t,void 0,e),t}parseSkeletonAnimation(e,t){let a=new ko;a.clipName=t.name,a.useSkeletonPos=!1,a.useSkeletonScale=!1;for(let r of t.channels){let i=t.samplers[r.sampler];const n=this.subParser.parseAccessor(i.input),o=this.subParser.parseAccessor(i.output);let l=r.target.node,c=r.target.path,f=this.gltf.nodes[l];if(!f||!e.boneMap.has(f.name))continue;let h=e.boneMap.get(f.name);switch(c){case"scale":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.useSkeletonScale=!0,a.scaleCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new b().set(o.data[m+0],o.data[m+1],o.data[m+2]);D.split(z.vector3,_,"value"),u.addKeyFrame(D)}}break;case"rotation":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.rotationCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new Z().set(o.data[m+0],o.data[m+1],o.data[m+2],o.data[m+3]);D.split(z.quaternion,_,"value"),u.addKeyFrame(D)}}break;case"translation":{let u=new ur(o.numComponents);u.path="",u.attribute="",u.propertys=u.attribute.split("."),u.preInfinity=0,u.postInfinity=0,u.rotationOrder=0,a.useSkeletonPos=!0,a.positionCurves.set(h.bonePath,u);for(let g=0;g<n.data.length;g++){const p=n.data[g],m=g*o.numComponents;let D=new ji(0);D.time=p;const _=new b().set(o.data[m+0],o.data[m+1],o.data[m+2]);D.split(z.vector3,_,"value"),u.addKeyFrame(D)}}break}}return a}parseSkeletonAnimationOld(e,t){let a=this.subParser.parseAccessor(t.samplers[0].input),r=a.data.length,i=a.data[1]-a.data[0];a.data[a.data.length-1];let n=12*e.numJoint,o=new Float32Array(n*r);for(var l=0;l<e.numJoint;l++)for(var c=0;c<r;c++){var f=n*c+12*l;o[f+0]=1,o[f+1]=1,o[f+2]=1,o[f+3]=1}for(let m of t.channels){let D=t.samplers[m.sampler];const _=this.subParser.parseAccessor(D.input),B=this.subParser.parseAccessor(D.output);let v=m.target.node,C=m.target.path,y=this.gltf.nodes[v];if(!y)continue;let F=e.getJointByName(y.name);if(F)switch(C){case"scale":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=1}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2]);for(var c=0;c<r;c++){let M=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,M);var f=n*c+12*F.index;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=1,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break;case"rotation":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index+4;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=B.data[h+3]}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2],B.data[u+3]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2],B.data[g+3]);for(var c=0;c<r;c++){let Q=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,Q);var f=n*c+12*F.index+4;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=b.HELP_2.w,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break;case"translation":if(r*B.numComponents==B.data.length)for(var c=0;c<r;c++){var h=c*B.numComponents,f=n*c+12*F.index+8;o[f+0]=B.data[h+0],o[f+1]=B.data[h+1],o[f+2]=B.data[h+2],o[f+3]=_.data[c*_.numComponents]}else if(_.data.length==2){let k=0;_.data[0];let w=_.data[1];var u=0*B.numComponents;b.HELP_0.set(B.data[u+0],B.data[u+1],B.data[u+2]);var g=1*B.numComponents;b.HELP_1.set(B.data[g+0],B.data[g+1],B.data[g+2]);for(var c=0;c<r;c++){let Q=k/w;b.HELP_2.lerp(b.HELP_0,b.HELP_1,Q);var f=n*c+12*F.index+8;o[f+0]=b.HELP_2.x,o[f+1]=b.HELP_2.y,o[f+2]=b.HELP_2.z,o[f+3]=k,k+=i}}else throw new Error("Unsupported animation sampler interpolation.");break}}return new dn(t.name,e,r,o)}buildSkeleton(e,t,a){let r=this.gltf.nodes[a];r.name||(r.name="Bone"+e.count);let i=new bo;if(i.boneName=r.name,i.bonePath=t?t.bonePath+"/"+r.name:r.name,i.parentBoneName=t?t.boneName:"",i.boneID=e.count++,i.parentBoneID=t?t.boneID:-1,i.instanceID="",i.parentInstanceID="",i.s=new b(1,1,1),r.scale&&i.s.set(r.scale[0],r.scale[1],r.scale[2]),i.q=new Z,r.rotation&&i.q.set(r.rotation[0],r.rotation[1],r.rotation[2],r.rotation[3]),i.t=new b,r.translation&&i.t.set(r.translation[0],r.translation[1],r.translation[2]),e.boneData.push(i),e.boneMap.set(i.boneName,i),r.children)for(let n of r.children)this.buildSkeleton(e,i,n)}buildSkeletonOld(e,t,a,r=0){let i=this.gltf.nodes[a];i.name||(i.name="Node_"+a);let n=new T0(i.name);if(n.parent=t,i.scale&&n.scale.set(i.scale[0],i.scale[1],i.scale[2]),i.rotation&&n.rotation.set(i.rotation[0],i.rotation[1],i.rotation[2],i.rotation[3]),i.translation&&n.translation.set(i.translation[0],i.translation[1],i.translation[2]),e.addJoint(n),i.children)for(let o of i.children)this.buildSkeletonOld(e,n,o,r+1)}}class Is{static list=[];static add(e){this.list.indexOf(e)==-1&&this.list.push(e)}static remove(e){let t=this.list.indexOf(e);t!=-1&&this.list.splice(t,1)}}class yi extends Pe{name;size=1;lightData;dirFix=1;bindOnChange;needUpdateShadow=!0;realTimeShadow=!0;_castGI=!1;_castShadow=!1;_iesProfiles;constructor(){super()}init(){this.transform.object3D.bound=new ge(new b,new b),this.lightData=new tn,this.lightData.lightMatrixIndex=this.transform.worldMatrix.index}onChange(){this.bindOnChange&&this.bindOnChange(),this.transform.object3D.bound.setFromCenterAndSize(this.transform.worldPosition,new b(this.size,this.size,this.size)),this._castGI&&(W.instance.state.giLightingChange=!0),this._castShadow?(this.needUpdateShadow=!0,Et.addShadowLight(this)):Et.removeShadowLight(this),this.transform.view3D&&A.renderJobs&&A.renderJobs.get(this.transform.view3D).reflectionRenderer&&A.renderJobs.get(this.transform.view3D).reflectionRenderer.forceUpdate()}start(){this.transform.onPositionChange=()=>this.onPositionChange(),this.transform.onRotationChange=()=>this.onRotChange(),this.onPositionChange(),this.onRotChange()}onPositionChange(){this.lightData.lightPosition.copyFrom(this.transform.worldPosition),this.onChange()}onRotChange(){this.dirFix==1?this.lightData.direction.copyFrom(this.transform.forward):this.lightData.direction.copyFrom(this.transform.back),this.lightData.lightTangent.copyFrom(this.transform.up),this.onChange()}onScaleChange(){this.onChange()}onEnable(){this.onChange(),W.instance.addLight(this.transform.scene3D,this)}onDisable(){this.onChange(),W.instance.removeLight(this.transform.scene3D,this),Et.removeShadowLight(this)}set iesProfiles(e){this._iesProfiles=e,this.lightData.iesIndex=e.index,ra.use=!0,this.onChange()}get iesProfile(){return this._iesProfiles}get r(){return this.lightData.lightColor.r}set r(e){this.lightData.lightColor.r=e,this.onChange()}get g(){return this.lightData.lightColor.g}set g(e){this.lightData.lightColor.g=e,this.onChange()}get b(){return this.lightData.lightColor.b}set b(e){this.lightData.lightColor.b=e,this.onChange()}get lightColor(){return this.lightData.lightColor}set lightColor(e){this.lightData.lightColor=e,this.onChange()}get color(){return this.lightData.lightColor}set color(e){this.lightData.lightColor=e,this.onChange()}get intensity(){return this.lightData.intensity}set intensity(e){this.lightData.intensity=e,this.onChange()}set castShadow(e){e!=this._castShadow&&(this._castShadow=e,this.onChange())}get castShadow(){return this._castShadow}get shadowIndex(){return this.lightData.castShadowIndex}get castGI(){return this._castGI}set castGI(e){e?Is.add(this):Is.remove(this),this._castGI=e,e&&this.onChange()}get direction(){return this.lightData.direction}destroy(e){this.bindOnChange=null,W.instance.removeLight(this.transform.scene3D,this),Et.removeShadowLight(this),this.transform.eventDispatcher.removeEventListener(kt.ROTATION_ONCHANGE,this.onRotChange,this),this.transform.eventDispatcher.removeEventListener(kt.SCALE_ONCHANGE,this.onScaleChange,this),super.destroy(e)}}var U2=Object.getOwnPropertyDescriptor,v2=(s,e,t,a)=>{for(var r=a>1?void 0:a?U2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.DirectLight=class extends yi{shadowCamera;constructor(){super()}init(){super.init(),this.object3D.name==""&&(this.object3D.name="DirectionLight_"+xt()),this.radius=Number.MAX_SAFE_INTEGER,this.lightData.lightType=Ye.DirectionLight,this.lightData.linear=0,this.lightData.quadratic=.3}start(){super.start(),this.castGI=!0}get radius(){return this.lightData.range}set radius(e){this.lightData.range=e,this.onChange()}get indirect(){return this.lightData.quadratic}set indirect(e){this.lightData.quadratic=e,this.onChange()}debug(){}},d.DirectLight=v2([Mt(d.DirectLight,"DirectLight")],d.DirectLight);var y2=Object.getOwnPropertyDescriptor,C2=(s,e,t,a)=>{for(var r=a>1?void 0:a?y2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.PointLight=class extends yi{constructor(){super()}init(){super.init(),this.lightData.lightType=Ye.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+xt())}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(e){this.lightData.quadratic=e,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(e){}debug(){}debugDraw(e){}},d.PointLight=C2([Mt(d.PointLight,"PointLight")],d.PointLight);var S2=Object.getOwnPropertyDescriptor,x2=(s,e,t,a)=>{for(var r=a>1?void 0:a?S2(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.SpotLight=class extends yi{constructor(){super()}init(){super.init(),this.lightData.lightType=Ye.SpotLight,this.object3D.name==""&&(this.object3D.name="SpotLight"+xt())}get innerAngle(){return this.lightData.innerAngle/this.lightData.outerAngle*100}set innerAngle(e){this.lightData.innerAngle=ie(e,0,100)/100*this.lightData.outerAngle,this.onChange()}get outerAngle(){return this.lightData.outerAngle*Wr*2}set outerAngle(e){this.lightData.outerAngle=ie(e,1,179)*at*.5,this.onChange()}get radius(){return this.lightData.radius}set radius(e){this.lightData.radius=e,this.onChange()}get range(){return this.lightData.range}set range(e){this.lightData.range=e,this.onChange()}get at(){return this.lightData.linear}set at(e){this.lightData.linear=e,this.onChange()}start(){super.start(),this.lightData.lightType=Ye.SpotLight}onUpdate(){}onGraphic(e){}debug(){}debugDraw(e){}},d.SpotLight=x2([Mt(d.SpotLight,"SpotLight")],d.SpotLight);class N0{static apply(e,t,a){let r=t.extensions;if(r&&r.KHR_materials_clearcoat){a.shader.getDefaultColorShader().setDefine("USE_CLEARCOAT",!0);let i=r.KHR_materials_clearcoat;"clearcoatFactor"in i&&(t.clearcoatFactor=i.clearcoatFactor,a.clearcoatFactor=t.clearcoatFactor),"clearcoatRoughnessFactor"in i&&(t.clearcoatRoughnessFactor=i.clearcoatRoughnessFactor,a.clearcoatRoughnessFactor=t.clearcoatRoughnessFactor)}}}class P0{static apply(e,t,a){let r=t.extensions;r&&r.KHR_materials_emissive_strength?(a.emissiveIntensity=r.KHR_materials_emissive_strength.emissiveStrength,a.emissiveMap==A.res.blackTexture&&(a.emissiveMap=A.res.whiteTexture)):a.emissiveIntensity=1}}class V0{static apply(e,t,a){let r=t.extensions;r&&r.KHR_materials_unlit?a.supportLight=!1:a.supportLight=!0}}class O0{gltf;subParser;_testCount=8;_hasCastShadow=!1;constructor(e){this.gltf=e.gltf,this.subParser=e}async convertNodeToObject3D(e,t){const a=new d.Object3D;if(a.name=e.name,a[Zt.GLTF_NODE_INDEX_PROPERTY]=e.nodeId,e.nodeObj=a,e.matrix&&(e.translation=[0,0,0],e.rotation=[0,0,0,1],e.scale=[1,1,1]),e.translation&&(a.transform.x=e.translation[0],a.transform.y=e.translation[1],a.transform.z=e.translation[2]),e.rotation){let r=new Z;r.setFromArray(e.rotation),a.transform.localRotQuat=r}return e.scale&&(a.transform.scaleX=e.scale[0],a.transform.scaleY=e.scale[1],a.transform.scaleZ=e.scale[2]),t.addChild(a),e.light&&this.convertLight(e,a),e.primitives&&this.convertprimitives(e,a),e.skeleton&&this.convertSkeletonAnim(a,e.skeleton),a}convertSkeletonAnim(e,t){let a=this.subParser.parseSkeleton(t.skeleton);A.res.addObj(a.name,a);let r=[];for(let n=0;n<this.gltf.animations.length;n++){let o=this.gltf.animations[n];o.name||(o.name=n.toString());let l=this.subParser.parseSkeletonAnimation(a,o);r.push(l)}let i=e.addComponent(d.AnimatorComponent);i.avatar=a.name,i.clips=r}convertLight(e,t){switch(e.light.type){case"directional":let a=t.addComponent(d.DirectLight);t.name=e.light.name,a.intensity=e.light.intensity*.1,a.radius=Number.MAX_SAFE_INTEGER,a.dirFix=-1,this._hasCastShadow||(this._hasCastShadow=!0,a.castShadow=this._hasCastShadow),a.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1),a.debug();break;case"point":if(this._testCount>0){let i=t.addComponent(d.PointLight);i.name=e.light.name,i.intensity=e.light.intensity?e.light.intensity*8*2:1,i.radius=8,i.at=2,i.range=e.light.range?e.light.range:8,i.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1)}this._testCount--;break;case"spot":let r=t.addComponent(d.SpotLight);r.name=e.light.name,r.intensity=e.light.intensity*5,r.radius=1,r.dirFix=-1,r.at=2,r.range=e.light.range?e.light.range:8,r.outerAngle=e.light.spot.outerConeAngle*Wr,r.lightColor=e.light.color?new O(e.light.color[0],e.light.color[1],e.light.color[2]):new O(1,1,1,1);break}}convertprimitives(e,t){for(let a=0;a<e.primitives.length;a++){const r=e.primitives[a];r.modelName;let i=r.material;i.name==null&&(i.name=xt());let n,o=`matkey_${i.name}`;if(i&&this.gltf.resources[o])n=this.gltf.resources[o];else{let g=i;const p=g?.extensions?.KHR_materials_unlit!==void 0;let m=p?new st:new pa;if(n=m,this.gltf.resources[o]=m,m.name=i.name,g){const{baseColorTexture:D,baseColorFactor:_,metallicFactor:B,roughnessFactor:v,doubleSided:C,metallicRoughnessTexture:y,normalTexture:F,occlusionTexture:k,emissiveTexture:w,emissiveFactor:x,enableBlend:M,alphaCutoff:N}=g;let Q=m=this.applyMaterialExtensions(g,m);if(p){const G=Q;G.baseColor=new O(_[0],_[1],_[2],_[3]),D&&(G.baseMap=D),Q.doubleSide=C,"enableBlend"in g&&(g.enableBlend?(g.defines?.includes("ALPHA_BLEND")?Q.blendMode=te.ALPHA:Q.blendMode=te.NORMAL,Q.castShadow=!1):Q.blendMode=te.NONE),"alphaCutoff"in g&&N>0&&N<1&&(Q.setUniformFloat("alphaCutoff",N),Q.blendMode=te.NORMAL,Q.transparent=!0)}else if("enableBlend"in g&&(g.enableBlend?(g.defines?.includes("ALPHA_BLEND")?Q.blendMode=te.ALPHA:Q.blendMode=te.NORMAL,Q.castShadow=!1):Q.blendMode=te.NONE),"alphaCutoff"in g&&N>0&&N<1&&(Q.setUniformFloat("alphaCutoff",N),Q.blendMode=te.NORMAL,Q.transparent=!0),g.baseMapOffsetSize&&Q.setUniformVector4("baseMapOffsetSize",g.baseMapOffsetSize),g.normalMapOffsetSize&&Q.setUniformVector4("normalMapOffsetSize",g.normalMapOffsetSize),g.emissiveMapOffsetSize&&Q.setUniformVector4("emissiveMapOffsetSize",g.emissiveMapOffsetSize),g.roughnessMapOffsetSize&&Q.setUniformVector4("roughnessMapOffsetSize",g.roughnessMapOffsetSize),g.metallicMapOffsetSize&&Q.setUniformVector4("metallicMapOffsetSize",g.metallicMapOffsetSize),g.aoMapOffsetSize&&Q.setUniformVector4("aoMapOffsetSize",g.aoMapOffsetSize),Q.setUniformColor("baseColor",new O(_[0],_[1],_[2],_[3])),Q.setUniformFloat("roughness",v??1),Q.setUniformFloat("metallic",B??0),Q.setUniformFloat("ao",1),Q.doubleSide=C,D&&Q.setTexture("baseMap",D),F&&Q.setTexture("normalMap",F),y?(Q.setTexture("maskMap",y),Q.shader.setDefine("USE_ROUGHNESS_G",!0),Q.shader.setDefine("USE_METALLIC_B",!0)):(Q.shader.setDefine("USE_ROUGHNESS_G",!1),Q.shader.setDefine("USE_METALLIC_B",!1)),w&&Q.setTexture("emissiveMap",w),x&&(x[0]>0||x[1]>0||x[2]>0)){Q.shader.getTexture("emissiveMap")||Q.shader.setTexture("emissiveMap",A.res.whiteTexture),Q.shader.setDefine("USE_EMISSIVEMAP",!0),Q.setUniformColor("emissiveColor",new O(x[0],x[1],x[2],x[3])),Q.blendMode!=te.NONE&&(Q.blendMode=te.ADD);let G=n.getUniformFloat("emissiveIntensity");(!G||G<=0)&&n.setUniformFloat("emissiveIntensity",1)}}}const{attribArrays:l,modelName:c,drawMode:f}=r;let h;if(!l.indices.data){let g=[],p=l.position.data.length/3/3;for(let m=0;m<p;m++){let D=m*3;g.push(D+2),g.push(D+0),g.push(D+1)}l.indices={data:new Uint8Array(g),normalize:!1,numComponents:1}}let u=!l.normal;if(u){let g=[],p=l.position.data.length/3;for(let m=0;m<p;m++)g.push(0),g.push(0),g.push(0);l.normal={data:new Float32Array(g),normalize:!1,numComponents:3}}if(l.indices.data&&l.indices.data.length>3){let g=r.meshName();this.gltf.resources[g]&&(h=this.gltf.resources[g]);const p=new d.Object3D;if(p.name=c+a,this.gltf.animations&&l[V.joints0]!=null){h||=this.createGeometryBase(c,l,r,e.skin),this.gltf.resources[g]=h,u&&l.indices?.data&&l.indices.data.length>0&&h.computeNormals();let m=this.gltf.nodes[e.skin.skeleton];m.dnode&&m.dnode.nodeObj?this.convertSkeletonAnim(t,e.skin):m.dnode.skeleton=e.skin;let D=p.addComponent(d.SkinnedMeshRenderer2);D.geometry=h,D.material=n}else{h||=this.createGeometryBase(c,l,r),this.gltf.resources[g]=h,u&&l.indices?.data&&l.indices.data.length>0&&h.computeNormals(),h.hasAttribute(V.joints0)&&h.vertexAttributeMap.delete(V.joints0);let m=p.addComponent(d.MeshRenderer);m.castShadow=!0,m.castGI=!0,m.geometry=h,m.material=n}e.skin&&e.skin.defines,t.addChild(p)}}}createGeometryBase(e,t,a,r){"indices"in t&&(t.indices.data.length>65534?t.indices.data=new Uint32Array(t.indices.data):t.indices.data=new Uint16Array(t.indices.data));let i=new Fe;if(i.name=e,"indices"in t&&(t.indices.data.length>65535?t.indices.data=new Uint32Array(t.indices.data):t.indices.data=new Uint16Array(t.indices.data)),a.morphTargetsRelative){let l=new Ao,c=a.targetNames;if(c&&c.length>0){l.shapeNames=[],l.shapeIndexs=[];for(let f=0;f<c.length;f++)l.shapeNames.push(c[f]),l.shapeIndexs.push(f)}l.vertexCount=t.position.data.length/3,l.blendCount=l.shapeNames.length,l.blendShapePropertyDatas=[],l.blendShapeMap=new Map;for(let f=0;f<l.blendCount;f++){let h=new po;h.shapeName=l.shapeNames[f],h.shapeIndex=l.shapeIndexs[f],h.frameCount=1,h.blendPositionList=t[Zt.MORPH_POSITION_PREFIX+f].data,h.blendNormalList=t[Zt.MORPH_NORMAL_PREFIX+f].data,l.blendShapePropertyDatas.push(h),l.blendShapeMap.set(h.shapeName,h)}i.blendShapeData=l}i.morphTargetsRelative=a.morphTargetsRelative;let n=a.targetNames;if(n&&n.length>0){let l=i.morphTargetDictionary={};for(let c=0;c<n.length;c++)l[n[c]]=c}if(i.morphTargetDictionary){let l=t.position.data.length/3,c=new Float32Array(l);for(let f=0;f<l;f++)c[f]=f;t.vIndex={data:c,normalize:!1,numComponents:1}}for(const l in t){let c=t[l];i.setAttribute(l,c.data)}if(r){i.skinNames=new Array(r.joints.length);for(let l=0;l<r.joints.length;l++){const c=r.joints[l],f=this.gltf.nodes[c];i.skinNames[l]=f.name}i.bindPose=new Array(r.inverseBindMatrices.length);for(let l=0;l<r.inverseBindMatrices.length;l++){const c=r.inverseBindMatrices[l];let f=new R;f.rawData.set(c),i.bindPose[l]=f}}let o=i.getAttribute(V.indices);return i.addSubGeometry({indexStart:0,indexCount:o.data.length,vertexStart:0,index:0,vertexCount:0,firstStart:0,topology:0}),i}applyMaterialExtensions(e,t){return e.extensions&&(N0.apply(this.gltf,e,t),V0.apply(this.gltf,e,t),P0.apply(this.gltf,e,t)),t}parseSkinJoints(e){let t=[];for(let a of e.joints){let r=this.gltf.nodes[a];t.push(r.name)}return t}}class hn{currentSceneName;gltf;initUrl;_generator;_version;_BASE64_MARKER=";base64,";_cameraParser=null;_meshParser=null;_materialParser=null;_skinParser=null;_skeletonParser=null;_converter=null;constructor(){}get version(){return this.version?this.version:this.gltf?this.gltf.asset?(this._version=this.gltf.asset.version,this.gltf.asset.minVersion&&(this._version+=`\r minVersion${this.gltf.asset.minVersion}`),this.version):this.errorMiss("asset"):(console.warn("glTF not loaded."),null)}async parse(e,t,a){this.gltf=t,this.initUrl=e;const{version:r,generator:i}=this.gltf.asset;if(this._generator=i,r!=="2.0")return console.error(`GLTFParser only support glTF 2.0 for now! Received glTF version: ${this.version}`),!1;const n={nodes:await this.parseScene(a),animations:this.parseAnimations(),name:this.currentSceneName};return await this.convertToNode(n)}destroy(){Es.unload(this.gltf),this.gltf=null}async parseScene(e){const t=e||this.gltf.scene||0,a=this.gltf.scenes[t];if(typeof a>"u")return this.errorMiss("scene",t);this.currentSceneName=a.name||"GLTF_NO_NAME_SCENE";const r=[],i=a.nodes;for(let n=0;n<i.length;n++){const o=await this.parseNode(i[n]);o&&r.push(o)}return r}async parseNode(e){const t=this.gltf.nodes[e];if(!t)return this.errorMiss("node",e);if(t.isParsed)return t.dnode;const{name:a,matrix:r,translation:i,rotation:n,scale:o}=t,l={name:a,matrix:r,translation:i,rotation:n,scale:o,nodeId:e,camera:null,primitives:null,skin:null,children:null,light:null};if(t.camera!==void 0&&(l.camera=this.parseCamera(t.camera)),t.mesh!==void 0&&(l.primitives=await this.parseMesh(t.mesh)),t.extensions!==void 0&&this.applyNodeExtensions(t,l),t.skin!==void 0){const c=this.parseSkin(t.skin);c&&(l.skin=c)}if(l.children=[],t.children)for(let c=0;c<t.children.length;c++)l.children.push(await this.parseNode(t.children[c]));return t.dnode=l,t.isParsed=!0,t.dnode}errorMiss(e,t){throw new Error(e+t)}parseCamera(e){return this._cameraParser||(this._cameraParser=new R0(this.gltf)),this._cameraParser.parse(e)}async parseMesh(e){return this._meshParser||(this._meshParser=new w0(this)),this._meshParser.parse(e)}async parseTexture(e){let t=this.gltf.textures[e];if(t&&!t.dtexture){if(t&&t.source!=null){let a=this.gltf.images[t.source];if(a.uri){let r=a.uri;r=yt.getURLName(r),t.dtexture=this.gltf.resources[r]}else if(a.bufferView){let r=this.parseBufferView(a.bufferView),i=new La,n=new Blob([r],{type:a.mimeType});await i.loadFromBlob(n),t.dtexture=i}else t.dtexture=this.gltf.resources[a.name]}else if(t.name){let a=yt.getURLName(t.name);t.dtexture=this.gltf.resources[a]}}return t.dtexture||console.log("miss texture , please check texture!",e,t),t.dtexture}async parseMaterial(e){return this._materialParser||(this._materialParser=new I0(this)),this._materialParser.parse(e)}parseAnimations(){return[]}async parseObject3D(e,t){return this._converter||(this._converter=new O0(this)),this._converter.convertNodeToObject3D(e,t)}parseSkeleton(e){return this._skeletonParser||(this._skeletonParser=new ws(this)),this._skeletonParser.parse(e)}parseSkeletonAnimation(e,t){return this._skeletonParser||(this._skeletonParser=new ws(this)),this._skeletonParser.parseSkeletonAnimation(e,t)}async traverse(e,t){for(let a=0;a<t.length;a++){const r=await this.parseObject3D(t[a],e);await this.traverse(r,t[a].children)}}async convertToNode(e){const t=new d.Object3D;t.name=e.name;const a=e.nodes;e.animations;const r=[],i=[];return await this.traverse(t,a),{rootNode:t,textures:r,animations:void 0,cameras:i}}parseSkin(e){return this._skinParser||(this._skinParser=new Q0(this)),this._skinParser.parse(e)}parseAccessor(e){const t=this.gltf.accessors[e];if(!t)return this.errorMiss("accessor",e);if(t.isParsed)return t.daccessor;t.isParsed=!0,t.daccessor=!1;const a=!!t.normalized,r=this.gltf.bufferViews[t.bufferView],i=r&&r.byteStride,n=ks(t.componentType);let o=1;switch(t.type){case"SCALAR":o=1;break;case"VEC2":o=2;break;case"VEC3":o=3;break;case"VEC4":case"MAT2":o=4;break;case"MAT3":o=9;break;case"MAT4":o=16;break;default:o=0;break}if(o===0)return console.error(`glTF has unknown data type in accessor: ${t.type}`),!1;const l=o*n.BYTES_PER_ELEMENT;let c;if(r!==void 0){if(c=this.parseBufferView(t.bufferView),!c)return t.daccessor}else c=new Uint8Array(l*t.count).buffer;let f=this.getTypedArrayFromArrayBuffer(c,i,t.byteOffset||0,n,o,t.count);if(t.sparse){const{count:h,indices:u,values:g}=t.sparse;f=new n(f);const p=u.byteOffset||0,m=this.gltf.bufferViews[u.bufferView],D=ks(u.componentType),_=this.parseBufferView(u.bufferView),B=this.getTypedArrayFromArrayBuffer(_,m.byteStride,p,D,1,h),v=g.byteOffset||0,C=this.gltf.bufferViews[g.bufferView],y=this.parseBufferView(g.bufferView),F=this.getTypedArrayFromArrayBuffer(y,C.byteStride,v,n,o,h);for(let k=0;k<B.length;k++)f.set(F.slice(k*o,k*o+o),B[k]*o)}return t.computeResult={typedArray:f,arrayType:n,numComponents:o},t.daccessor={data:f,numComponents:o,normalize:a},t.daccessor}getTypedArrayFromArrayBuffer(e,t,a,r,i,n){let o;const l=i*r.BYTES_PER_ELEMENT;if(t&&l!==t){const c=i*n;o=new r(c);for(let f=0;f<n;f++){const h=new r(e,a+f*t,i);for(let u=0;u<i;u++)o[f*i+u]=h[u]}}else o=new r(e,a,n*i);return o}parseBufferView(e){const t=this.gltf.bufferViews[e];if(!t)return this.errorMiss("bufferView",e);if(t.isParsed)return t.dbufferView;t.isParsed=!0,t.dbufferView=!1;const a=this.parseBuffer(t.buffer);if(a){const{byteOffset:r,byteLength:i}=t,n=new Uint8Array(a,r||0,i);t.dbufferView=new Uint8Array(n).buffer}return t.dbufferView}parseBuffer(e){const t=this.gltf.buffers[e];if(!t)return this.errorMiss("buffer",e);if(t.isParsed)return t.dbuffer;if(t.isParsed=!0,t.dbuffer=!1,t.uri.substring(0,5)!=="data:"){const a=t.uri,r=this.gltf.resources[a];r?r.byteLength===t.byteLength?t.dbuffer=this.gltf.resources[a]:console.error(`load gltf resource "${a}" at buffers[${e} failed, ArrayBuffer.byteLength not equals buffer's byteLength]`):console.error(`load gltf resource "${a}" at buffers[${e}] failed`)}else{const a=t.uri.indexOf(this._BASE64_MARKER)+this._BASE64_MARKER.length,r=window.atob(t.uri.substring(a)),i=new Uint8Array(r.length);for(let n=0;n<r.length;n++)i[n]=r.charCodeAt(n);t.dbuffer=i.buffer}return t.dbuffer}getLight(e){return this.gltf.extensions.KHR_lights_punctual.lights[e]}applyNodeExtensions(e,t){let a=e.extensions;a.KHR_lights_punctual&&this.gltf.extensions.KHR_lights_punctual&&(t.light=this.getLight(a.KHR_lights_punctual.light))}}class L0{magic;version;length}class G0{chunkLength;chunkType;chunkData}class Qs extends nt{static format=Ge.BIN;_gltf;async parseBuffer(e){let t=new Uint8Array(e);t.pos=0;const a=this.parseHeader(t);if(a.magic!=1179937895)return console.error("invalid GLB file"),!1;if(a.version!==2)return console.error(`GLBParser only support glTF 2.0 for now! Received glTF version: ${a.version}`),!1;let r=[];for(;t.pos<t.length;){let h=this.parseChunk(t);r.push(h)}if(r[0].chunkType!=1313821514)return console.error("invalid GLBChunk"),!1;let i="",n=65535,o=r[0].chunkData;for(let h=0;h<o.length;h+=n){let u=o.length-h;u=Math.min(u,n);let g=o.subarray(h,h+u);i+=String.fromCharCode(...g)}let l=JSON.parse(i);this._gltf=new fn,this._gltf={...this._gltf,...l},this._gltf.resources={};for(let h=0;h<this._gltf.buffers.length;h++){let u=this._gltf.buffers[h];u.isParsed=!0,u.dbuffer=r[h+1].chunkData.buffer}if(this._gltf.images)for(let h=0;h<this._gltf.images.length;h++){let u=this._gltf.images[h];u.name=u.name||"bufferView_"+u.bufferView.toString();const g=this._gltf.bufferViews[u.bufferView],p=this._gltf.buffers[g.buffer];let m=new Uint8Array(p.dbuffer,g.byteOffset,g.byteLength),D=new Blob([m],{type:u.mimeType}),_=new La;await _.loadFromBlob(D),_.name=u.name,this._gltf.resources[u.name]=_}let c=new hn,f=await c.parse(this.initUrl,this._gltf,this._gltf.scene);return c.destroy(),f?(this.data=f.rootNode,f.rootNode):null}async parseJsonAndBuffer(e,t){this._gltf=new fn,this._gltf={...this._gltf,...e},this._gltf.resources={};let a=this._gltf.buffers[0];if(a.isParsed=!0,a.dbuffer=t,this._gltf.images)for(let n=0;n<this._gltf.images.length;n++){let o=this._gltf.images[n];o.name=o.name||"bufferView_"+o.bufferView.toString();const l=this._gltf.bufferViews[o.bufferView],c=this._gltf.buffers[l.buffer];let f=new Uint8Array(c.dbuffer,l.byteOffset,l.byteLength),h=new Blob([f],{type:o.mimeType}),u=new La;await u.loadFromBlob(h),u.name=o.name,this._gltf.resources[o.name]=u}let r=new hn,i=await r.parse(this.initUrl,this._gltf,this._gltf.scene);return r.destroy(),i?(this.data=i.rootNode,i.rootNode):null}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}parseHeader(e){let t=e.pos,a=new L0,r=new Uint32Array(e.buffer,t,3);return e.pos+=r.byteLength,a.magic=r[0],a.version=r[1],a.length=r[2],a}parseChunk(e){let t=e.pos,a=new G0,r=new Uint32Array(e.buffer,t,2);t=e.pos+=r.byteLength,a.chunkLength=r[0],a.chunkType=r[1],a.chunkData=new Uint8Array(e.buffer,t,a.chunkLength);const i=new Uint8Array(a.chunkLength);for(let n=0;n<a.chunkLength;n++)i[n]=a.chunkData[n];return a.chunkData=i,e.pos+=a.chunkLength,a}}class z0 extends it{constructor(){super();let e=new Ne("PBRLItShader","PBRLItShader");e.setShaderEntry("VertMain","FragMain"),e.passType=H.COLOR,this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformColor("baseColor",new O(.75,.75,.75,1)),this.setUniformColor("emissiveColor",new O(0,0,0)),this.setUniformVector4("materialF0",new $(.04,.04,.04,1)),this.setUniformColor("specularColor",new O(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",1),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new O(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this.setUniformFloat("clearcoatIor",1.5),this.setUniformVector4("baseMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("normalMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("emissiveMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("roughnessMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("metallicMapOffsetSize",new $(0,0,1,1)),this.setUniformVector4("aoMapOffsetSize",new $(0,0,1,1)),this.baseMap=A.res.whiteTexture,this.normalMap=A.res.normalTexture,this.maskMap=A.res.maskTexture}get baseMap(){return this.getDefaultColorShader().getTexture("baseMap")}set baseMap(e){this.getDefaultColorShader().setTexture("baseMap",e)}get baseColor(){return this.getDefaultColorShader().getUniform("baseColor")}set baseColor(e){this.getDefaultColorShader().setUniformColor("baseColor",e)}get normalMap(){return this.getDefaultColorShader().getTexture("normalMap")}set normalMap(e){this.getDefaultColorShader().setTexture("normalMap",e)}get doubleSide(){return this.getDefaultColorShader().doubleSide}set doubleSide(e){this.getDefaultColorShader().doubleSide=e}get alphaCutoff(){return this.getDefaultColorShader().shaderState.alphaCutoff}set alphaCutoff(e){this.getDefaultColorShader().setDefine("USE_ALPHACUT",!0),this.getDefaultColorShader().shaderState.alphaCutoff=e,this.getDefaultColorShader().setUniform("alphaCutoff",e)}get emissiveColor(){return this.getDefaultColorShader().getUniform("emissiveColor")}set emissiveColor(e){this.getDefaultColorShader().setUniform("emissiveColor",e)}get emissiveIntensity(){return this.getDefaultColorShader().getUniform("emissiveIntensity")}set emissiveIntensity(e){this.getDefaultColorShader().setUniform("emissiveIntensity",e)}get transformUV1(){return this.getDefaultColorShader().uniforms.transformUV1.vector4}set transformUV1(e){this.getDefaultColorShader().setUniform("transformUV1",e)}get uvTransform_2(){return this.getDefaultColorShader().uniforms.transformUV2.vector4}set uvTransform_2(e){this.getDefaultColorShader().setUniform("transformUV2",e)}get depthWriteEnabled(){return this.getDefaultColorShader().shaderState.depthWriteEnabled}set depthWriteEnabled(e){this.getDefaultColorShader().shaderState.depthWriteEnabled=e}get materialF0(){return this.getDefaultColorShader().uniforms.materialF0.vector4}set materialF0(e){this.getDefaultColorShader().setUniform("materialF0",e)}get specularColor(){return this.getDefaultColorShader().uniforms.specularColor.color}set specularColor(e){this.getDefaultColorShader().setUniform("specularColor",e)}get roughness(){return this.getDefaultColorShader().uniforms.roughness.value}set roughness(e){this.getDefaultColorShader().setUniform("roughness",e)}get metallic(){return this.getDefaultColorShader().uniforms.metallic.value}set metallic(e){this.getDefaultColorShader().setUniform("metallic",e)}get ao(){return this.getDefaultColorShader().uniforms.ao.value}set ao(e){this.getDefaultColorShader().setUniform("ao",e)}get metallic_min(){return this.getDefaultColorShader().uniforms.metallic_min.value}set metallic_min(e){this.getDefaultColorShader().setUniform("metallic_min",e)}get metallic_max(){return this.getDefaultColorShader().uniforms.metallic_max.value}set metallic_max(e){this.getDefaultColorShader().setUniform("metallic_max",e)}get roughness_min(){return this.getDefaultColorShader().uniforms.roughness_min.value}set roughness_min(e){this.getDefaultColorShader().setUniform("roughness_min",e)}get roughness_max(){return this.getDefaultColorShader().uniforms.roughness_max.value}set roughness_max(e){this.getDefaultColorShader().setUniform("roughness_max",e)}get normalScale(){return this.getDefaultColorShader().uniforms.normalScale.value}set normalScale(e){this.getDefaultColorShader().setUniform("normalScale",e)}get maskMap(){return this.getDefaultColorShader().textures.maskMap}set maskMap(e){this.getDefaultColorShader().setDefine("USE_MR",!0),this.getDefaultColorShader().setTexture("maskMap",e)}set aoMap(e){e&&(this.getDefaultColorShader().setTexture("aoMap",e),e!=A.res.whiteTexture&&this.getDefaultColorShader().setDefine("USE_AOTEX",!0))}get aoMap(){return this.getDefaultColorShader().textures.aoMap}set clearCoatRoughnessMap(e){e&&(console.log("USE_CLEARCOAT_ROUGHNESS"),this.getDefaultColorShader().setTexture("clearCoatRoughnessMap",e),this.getDefaultColorShader().setDefine("USE_CLEARCOAT_ROUGHNESS",!0))}get clearCoatRoughnessMap(){return this.getDefaultColorShader().textures.clearCoatRoughnessMap}get brdfLUT(){return this.getDefaultColorShader().textures.brdfLUT}set brdfLUT(e){this.getDefaultColorShader().setTexture("brdfLUT",e),this.getDefaultColorShader().setTexture("brdflutMap",e)}get emissiveMap(){return this.getDefaultColorShader().textures.emissiveMap}set emissiveMap(e){this.getDefaultColorShader().setTexture("emissiveMap",e)}set envIntensity(e){this.getDefaultColorShader().setUniformFloat("envIntensity",e)}get envIntensity(){return this.getDefaultColorShader().uniforms.envIntensity.value}set ior(e){this.getDefaultColorShader().setUniformFloat("ior",e)}get ior(){return this.getDefaultColorShader().uniforms.ior.value}useCleanCoat(){this.getDefaultColorShader().setDefine("USE_CLEARCOAT",!0)}set clearcoatFactor(e){this.getDefaultColorShader().setUniformFloat("clearcoatFactor",e),this.useCleanCoat()}get clearcoatFactor(){return this.getDefaultColorShader().uniforms.clearcoatFactor.value}set clearcoatRoughnessFactor(e){this.getDefaultColorShader().setUniformFloat("clearcoatRoughnessFactor",e),this.useCleanCoat()}get clearcoatRoughnessFactor(){return this.getDefaultColorShader().uniforms.clearcoatRoughnessFactor.value}set clearcoatWeight(e){this.getDefaultColorShader().setUniformFloat("clearcoatWeight",e),this.useCleanCoat()}get clearcoatWeight(){return this.getDefaultColorShader().uniforms.clearcoatWeight.value}set clearcoatColor(e){this.getDefaultColorShader().setUniformColor("clearcoatColor",e),this.useCleanCoat()}get clearcoatColor(){return this.getDefaultColorShader().uniforms.clearcoatColor.color}}class pa extends ut{constructor(){super();let e=new z0;this.shader=e}clone(){let e=new pa,t=e.shader.getDefaultColorShader(),a=this.shader.getDefaultColorShader();return t.defineValue={...a.defineValue},t.setUniform("shadowBias",a.getUniform("shadowBias")),t.setUniform("baseColor",a.getUniform("baseColor")),t.setUniform("specularColor",a.getUniform("specularColor")),t.setUniform("emissiveColor",a.getUniform("emissiveColor")),t.setUniform("materialF0",a.getUniform("materialF0")),t.setUniform("envIntensity",a.getUniform("envIntensity")),t.setUniform("normalScale",a.getUniform("normalScale")),t.setUniform("roughness",a.getUniform("roughness")),t.setUniform("metallic",a.getUniform("metallic")),t.setUniform("ao",a.getUniform("ao")),t.setUniform("roughness_min",a.getUniform("roughness_min")),t.setUniform("roughness_max",a.getUniform("roughness_max")),t.setUniform("metallic_min",a.getUniform("metallic_min")),t.setUniform("metallic_max",a.getUniform("metallic_max")),t.setUniform("emissiveIntensity",a.getUniform("emissiveIntensity")),t.setUniform("alphaCutoff",a.getUniform("alphaCutoff")),t.setUniform("ior",a.getUniform("ior")),t.setUniform("clearcoatFactor",a.getUniform("clearcoatFactor")),t.setUniform("clearcoatRoughnessFactor",a.getUniform("clearcoatRoughnessFactor")),t.setUniform("clearcoatColor",a.getUniform("clearcoatColor")),t.setUniform("clearcoatWeight",a.getUniform("clearcoatWeight")),t.setUniform("clearcoatIor",a.getUniform("clearcoatIor")),t.setTexture("baseMap",a.getTexture("baseMap")),t.setTexture("normalMap",a.getTexture("normalMap")),t.setTexture("emissiveMap",a.getTexture("emissiveMap")),t.setTexture("aoMap",a.getTexture("aoMap")),t.setTexture("maskMap",a.getTexture("maskMap")),t.setTexture("empty",a.getTexture("empty")),t.setUniform("baseMapOffsetSize",a.getUniform("baseMapOffsetSize")),t.setUniform("normalMapOffsetSize",a.getUniform("normalMapOffsetSize")),t.setUniform("emissiveMapOffsetSize",a.getUniform("emissiveMapOffsetSize")),t.setUniform("roughnessMapOffsetSize",a.getUniform("roughnessMapOffsetSize")),t.setUniform("metallicMapOffsetSize",a.getUniform("metallicMapOffsetSize")),t.setUniform("aoMapOffsetSize",a.getUniform("aoMapOffsetSize")),e}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set maskMap(e){this.shader.setTexture("maskMap",e)}get maskMap(){return this.shader.getTexture("maskMap")}set normalMap(e){this.shader.setTexture("normalMap",e)}get normalMap(){return this.shader.getTexture("normalMap")}set emissiveMap(e){this.shader.setTexture("emissiveMap",e)}get emissiveMap(){return this.shader.getTexture("emissiveMap")}set aoMap(e){this.shader.setTexture("aoMap",e)}get aoMap(){return this.shader.getTexture("aoMap")}set clearCoatRoughnessMap(e){this.shader.setTexture("clearCoatRoughnessMap",e),this.shader.setDefine("USE_CLEARCOAT",!0),this.shader.setDefine("USE_CLEARCOAT_ROUGHNESS",!0)}get clearCoatRoughnessMap(){return this.shader.getTexture("clearCoatRoughnessMap")}set clearcoatColor(e){this.shader.setUniformColor("clearcoatColor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatColor(){return this.shader.getUniformColor("clearcoatColor")}set clearcoatWeight(e){this.shader.setUniformFloat("clearcoatWeight",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatWeight(){return this.shader.getUniformFloat("clearcoatWeight")}set clearcoatFactor(e){this.shader.setUniformFloat("clearcoatFactor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatFactor(){return this.shader.getUniformFloat("clearcoatFactor")}set clearcoatRoughnessFactor(e){this.shader.setUniformFloat("clearcoatRoughnessFactor",e),this.shader.setDefine("USE_CLEARCOAT",!0)}get clearcoatRoughnessFactor(){return this.shader.getUniformFloat("clearcoatRoughnessFactor")}set ior(e){this.shader.setUniformFloat("clearcoatIor",e)}get ior(){return this.shader.getUniformFloat("clearcoatIor")}set alphaCutoff(e){this.shader.setUniform("alphaCutoff",e)}get alphaCutoff(){return this.shader.getUniform("alphaCutoff")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}get roughness(){return this.shader.getUniformFloat("roughness")}set roughness(e){this.shader.setUniformFloat("roughness",e)}get metallic(){return this.shader.getUniformFloat("metallic")}set metallic(e){this.shader.setUniformFloat("metallic",e)}get emissiveColor(){return this.shader.getUniformColor("emissiveColor")}set emissiveColor(e){this.shader.setUniformColor("emissiveColor",e)}get emissiveIntensity(){return this.shader.getUniformFloat("emissiveIntensity")}set emissiveIntensity(e){this.shader.setUniformFloat("emissiveIntensity",e)}get ao(){return this.shader.getUniform("ao")}set ao(e){this.shader.setUniform("ao",e)}}class J0 extends nt{static format=Ge.TEXT;textData="";source_vertices;source_normals;source_tangents;source_textureCoords;matLibs;geometrys;activeGeo;currentObjectName;currentMaterialName;facesMaterialsIndex;mtl;mtlUrl;async parseString(e){return this.source_vertices=[],this.source_normals=[],this.source_tangents=[],this.source_textureCoords=[],this.currentObjectName="default",this.currentMaterialName="",this.matLibs={},this.geometrys={},this.activeGeo=void 0,this.textData=e,await Promise.all([this.parserOBJ(),this.loadMTL()]),this.parser_mesh(),"null"}applyVector2(e,t,a){e>=0&&t[e]&&t[e].length>0?(a.push(t[e][0]),a.push(-t[e][1])):(a.push(0),a.push(0))}applyVector3(e,t,a){e>=0&&t[e]&&t[e].length>0?(a.push(t[e][0]),a.push(t[e][1]),a.push(t[e][2])):(a.push(0),a.push(0),a.push(0))}applyVector4(e,t,a){a.push(t[e][0]),a.push(t[e][1]),a.push(t[e][2]),a.push(t[e][3])}parseUVIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}parseVertexIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}parseNormalIndex(e,t){const a=parseInt(e,10);return a>=0?a-1:t+a}calculateFaceNormal(e,t,a){const r=[t[0]-e[0],t[1]-e[1],t[2]-e[2]],i=[a[0]-e[0],a[1]-e[1],a[2]-e[2]],n=[r[1]*i[2]-r[2]*i[1],r[2]*i[0]-r[0]*i[2],r[0]*i[1]-r[1]*i[0]],o=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);return o>0&&(n[0]/=o,n[1]/=o,n[2]/=o),n}async loadMTL(){let t=await new At().loadTxt(this.baseUrl+this.mtlUrl),a=t.data,r,i=a.split(/\r?\n/);for(let c=0;c<i.length;c++){let f=i[c];var n=f.indexOf("#");n!=-1&&(f=f.substring(0,n)),f=f.trim();var o=f.split(/\s+/);o[0]==="newmtl"?(r={name:o[1]},this.matLibs[o[1]]=r):o[0].indexOf("map_")!=-1?(r[o[0]]=o[1],r.textures||(r.textures=[o[o.length-1]]),r.textures.push(o[o.length-1])):o.length==2?r[o[0]]=Number(o[1]):o.length==3?r[o[0]]=[Number(o[1]),Number(o[2])]:o.length==4&&(r[o[0]]=[Number(o[1]),Number(o[2]),Number(o[3])])}const l=[];for(const c in this.matLibs){const f=this.matLibs[c];if(f.textures&&f.textures.length>0)for(let h=0;h<f.textures.length;h++){const u=yt.normalizePath(this.baseUrl+f.textures[h]);l.push(A.res.loadTexture(u).catch(g=>(console.error(`Failed to load texture: ${u}`,g),null)))}}return await Promise.all(l),t=null,!0}async load_textures(){}getGeometryKey(e,t){const a=(e??this.currentObjectName??"default")||"default",r=t??this.currentMaterialName??"",i=r.length>0?r:"default";return`${a}::${i}`}ensureActiveGeo(e,t){const a=(e??this.currentObjectName??"default")||"default",r=t??this.currentMaterialName??"",i=this.getGeometryKey(a,r);this.geometrys[i]?this.geometrys[i].source_mat!==r&&(this.geometrys[i].source_mat=r):this.geometrys[i]={type:a,name:i,source_mat:r,source_faces:[]},this.activeGeo=this.geometrys[i]}parserLine(e){var t=e.indexOf("#");if(t!=-1){if(e.indexOf("# object")!=-1){const p=e.split(/\s+/),m=p[1]||"default",D=p[2]||"default";this.currentObjectName=D,this.activeGeo=void 0,this.ensureActiveGeo(D,this.currentMaterialName),this.activeGeo&&(this.activeGeo.type=m)}e=e.substring(0,t)}e=e.trim();var a=e.split(/\s+/);if(a[0]==="v"){var r=[Number(a[1]),Number(a[2]),Number(a[3]),a[4]?1:Number(a[4])];this.source_vertices.push(r)}else if(a[0]==="vt"){var i=[Number(a[1]),Number(a[2]),a[3]?1:Number(a[3])];this.source_textureCoords.push(i)}else if(a[0]==="vn"){var n=[Number(a[1]),Number(a[2]),Number(a[3])];this.source_normals.push(n)}else if(a[0]==="f"){for(var o={indices:[],texture:[],normal:[]},l=1;l<a.length;++l){var c=a[l];if(c.length!==0){var f=c.split("/"),h=f[0]||"",u=f.length>=2&&f[1]||"",g=f.length>=3&&f[2]||"";h.length!==0&&(o.indices.push(h),o.texture.push(u),o.normal.push(g))}}this.ensureActiveGeo(),this.activeGeo.source_faces.push(o)}else a[0]==="usemtl"?(this.currentMaterialName=a[1]||"",this.ensureActiveGeo(this.currentObjectName,this.currentMaterialName)):a[0]==="mtllib"&&(this.mtlUrl=a[1])}async parserOBJ(){let e=this.textData.split(/\r?\n/);for(let t=0;t<e.length;t++){const a=e[t];this.parserLine(a)}return this.textData="",!0}async parser_mesh(){let e=new d.Object3D;for(const t in this.geometrys){const a=this.geometrys[t];a.vertex_arr=[],a.normal_arr=[],a.uv_arr=[],a.indeice_arr=[];let r=0;const i=this.source_vertices.length,n=this.source_normals.length,o=this.source_textureCoords.length;for(let p=0;p<a.source_faces.length;p++){const m=a.source_faces[p];let D=this.parseVertexIndex(m.indices[0],i),_=this.parseVertexIndex(m.indices[1],i),B=this.parseVertexIndex(m.indices[2],i);const v=G=>{if(!G||G.length===0)return-1;const X=this.parseNormalIndex(G,n);return Number.isFinite(X)&&X>=0&&X<n?X:-1},C=G=>{if(!G||G.length===0)return-1;const X=this.parseUVIndex(G,o);return Number.isFinite(X)&&X>=0&&X<o?X:-1};let y=v(m.normal[0]),F=v(m.normal[1]),k=v(m.normal[2]);const w=y<0||F<0||k<0;let x=null;w&&D>=0&&_>=0&&B>=0&&this.source_vertices[D]&&this.source_vertices[_]&&this.source_vertices[B]&&(x=this.calculateFaceNormal(this.source_vertices[D],this.source_vertices[_],this.source_vertices[B]));let M=C(m.texture[0]),N=C(m.texture[1]),Q=C(m.texture[2]);if(this.applyVector3(D,this.source_vertices,a.vertex_arr),y>=0?this.applyVector3(y,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),M>=0?this.applyVector2(M,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(_,this.source_vertices,a.vertex_arr),F>=0?this.applyVector3(F,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),N>=0?this.applyVector2(N,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(B,this.source_vertices,a.vertex_arr),k>=0?this.applyVector3(k,this.source_normals,a.normal_arr):x?a.normal_arr.push(x[0],x[1],x[2]):a.normal_arr.push(0,0,0),Q>=0?this.applyVector2(Q,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,m.indices.length>3){let G=this.parseVertexIndex(m.indices[3],i),X=v(m.normal[3]),ne=C(m.texture[3]),q=null;(y<0||k<0||X<0)&&D>=0&&B>=0&&G>=0&&this.source_vertices[D]&&this.source_vertices[B]&&this.source_vertices[G]&&(q=this.calculateFaceNormal(this.source_vertices[D],this.source_vertices[B],this.source_vertices[G])),this.applyVector3(D,this.source_vertices,a.vertex_arr),y>=0?this.applyVector3(y,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),M>=0?this.applyVector2(M,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(B,this.source_vertices,a.vertex_arr),k>=0?this.applyVector3(k,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),Q>=0?this.applyVector2(Q,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++,this.applyVector3(G,this.source_vertices,a.vertex_arr),X>=0?this.applyVector3(X,this.source_normals,a.normal_arr):q?a.normal_arr.push(q[0],q[1],q[2]):a.normal_arr.push(0,0,0),ne>=0?this.applyVector2(ne,this.source_textureCoords,a.uv_arr):a.uv_arr.push(0,0),a.indeice_arr[r]=r++}}let l=new Fe;l.setIndices(new Uint32Array(a.indeice_arr)),l.setAttribute(V.position,new Float32Array(a.vertex_arr)),l.setAttribute(V.normal,new Float32Array(a.normal_arr)),l.setAttribute(V.uv,new Float32Array(a.uv_arr)),l.setAttribute(V.TEXCOORD_1,new Float32Array(a.uv_arr)),l.addSubGeometry({indexStart:0,indexCount:a.indeice_arr.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let c=new pa;const f=a.source_mat,h=f?this.matLibs[f]:void 0;if(h&&h.map_Kd){const p=yt.normalizePath(this.baseUrl+h.map_Kd),m=A.res.getTexture(p);m&&(c.baseMap=m)}let u=new d.Object3D,g=u.addComponent(d.MeshRenderer);g.geometry=l,g.material=c,e.addChild(u)}this.data=e}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}}let W0=`
7276
7276
  struct ImageSize {
7277
7277
  srcWidth: i32,
7278
7278
  srcHeight: i32,
@@ -7670,7 +7670,7 @@ else if (typeof exports === 'object')
7670
7670
  var oc:vec4<f32> = multiSample(worldDirection, blurSetting.x);
7671
7671
  textureStore(outputBuffer0, coord, i32(GlobalInvocationID.z), oc);
7672
7672
  }
7673
- `;class $0{static configBuffer=null;static quaternionBuffer=null;static blurSettingBuffer=null;static pipeline;static importantSample(e,t,a,r){const i=E.device;this.pipeline==null&&(this.pipeline=i.createComputePipeline({layout:"auto",compute:{module:i.createShaderModule({code:q0}),entryPoint:"main"}}));const n=this.pipeline,o=16;this.configBuffer||=i.createBuffer({size:o,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),i.queue.writeBuffer(this.configBuffer,0,new Uint32Array([e.width,e.height,t,t]));const l=24;if(!this.quaternionBuffer){this.quaternionBuffer=i.createBuffer({size:l*4*6,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST});let D=new Float32Array(24);for(let _=0;_<6;_++){let B=Ms.getRotationToFace(_);D[_*4+0]=B.x,D[_*4+1]=B.y,D[_*4+2]=B.z,D[_*4+3]=B.w}i.queue.writeBuffer(this.quaternionBuffer,0,D)}this.blurSettingBuffer||=i.createBuffer({size:o,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),i.queue.writeBuffer(this.blurSettingBuffer,0,new Float32Array([a,0,0,0]));const c=e.erpTexture;let f=[{binding:0,resource:{buffer:this.configBuffer,size:16}},{binding:1,resource:{buffer:this.quaternionBuffer,size:l*4}},{binding:2,resource:c.gpuSampler},{binding:3,resource:c.getGPUView()}],h=[{binding:0,resource:{buffer:this.blurSettingBuffer,size:16}},{binding:1,resource:r}];const u=i.createBindGroup({layout:n.getBindGroupLayout(0),entries:f}),g=i.createBindGroup({layout:n.getBindGroupLayout(1),entries:h}),p=S.beginCommandEncoder(),m=p.beginComputePass();m.setPipeline(n),m.setBindGroup(0,u),m.setBindGroup(1,g),m.dispatchWorkgroups(t/8,t/8,6),m.end(),S.endCommandEncoder(p)}}class Os{faceTextureRef;_texture;constructor(e){this._texture=e,this.faceTextureRef={}}uploadTexture(e,t){let a=this.getGpuSource(e);return wt.makeTextureCube(t,this._texture.width,a.v),this}uploadErpTexture(e){let t=this.getGpuSource(0);return wt.makeTextureCube(e,this._texture.width,t.v),this.generateMipmap(e),this}getGpuSource(e){let t=this.faceTextureRef[e];return t||(t={t:this._texture.getGPUTexture(),v:this._texture.getGPUTexture().createView({format:this._texture.format,dimension:"2d-array",baseMipLevel:e,mipLevelCount:1,arrayLayerCount:6})},this.faceTextureRef[e]=t),t}generateMipmap(e){let t=1;for(;t<this._texture.mipmapCount;)this.generateMipmapAtLevel(t,e),t++}generateMipmapAtLevel(e,t,a=3){let r=this._texture.width/Math.pow(2,e),i={width:r,height:r,erpTexture:t},n=(e+1)/this._texture.mipmapCount;n=Math.pow(n,a);let o=this.getGpuSource(e);$0.importantSample(i,r,n,o.v)}}class gn extends un{_url;_faceData;constructor(){super(),this.useMipmap=!0,this.format=Y.rgba16float,this.isHDRTexture=!0,this._faceData=new Os(this)}createFromHDRData(e,t){let a=new pe(t.width,t.height,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING),r=new Float32Array(t.array);return wt.convertRGBE2RGBA(a,r),this.createFromTexture(e,a),this}createFromTexture(e,t){this.width=this.height=e,this.textureBindingLayout.viewDimension="cube";let a=this.width;for(this.mipmapCount=1;a>16;)a/=2,this.mipmapCount++;return this.createTextureDescriptor(e,e,this.mipmapCount,this.format),this.textureDescriptor.size={width:e,height:e,depthOrArrayLayers:6},this.textureDescriptor.dimension="2d",this.gpuSampler=E.device.createSampler(this),this._faceData.uploadErpTexture(t),this}async load(e,t){return this._url=e,(await new At().load(e,Vs,t)).getCubeTexture()}}function ef(s){return new TextDecoder().decode(s)}class mn{buffer;binOffset;binLength;header;constructor(e,t,a,r){this.buffer=e,this.binOffset=t+a,this.binLength=r;let i=null;if(a!==0){const n=new Uint8Array(e,t,a);i=JSON.parse(ef(n))}else i={};this.header=i}getKeys(){return Object.keys(this.header)}getData(e,t,a=null,r=null){const i=this.header;if(!(e in i))return null;const n=i[e];if(n instanceof Object){if(Array.isArray(n))return n;{const{buffer:o,binOffset:l,binLength:c}=this,f=n.byteOffset||0,h=n.type||r,u=n.componentType||a;if("type"in n&&r&&n.type!==r)throw new Error("FeatureTable: Specified type does not match expected type.");let g;switch(h){case"SCALAR":g=1;break;case"VEC2":g=2;break;case"VEC3":g=3;break;case"VEC4":g=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${e}".`)}let p;const m=l+f,D=t*g;switch(u){case"BYTE":p=new Int8Array(o,m,D);break;case"UNSIGNED_BYTE":p=new Uint8Array(o,m,D);break;case"SHORT":p=new Int16Array(o,m,D);break;case"UNSIGNED_SHORT":p=new Uint16Array(o,m,D);break;case"INT":p=new Int32Array(o,m,D);break;case"UNSIGNED_INT":p=new Uint32Array(o,m,D);break;case"FLOAT":p=new Float32Array(o,m,D);break;case"DOUBLE":p=new Float64Array(o,m,D);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${e}".`)}if(m+D*p.BYTES_PER_ELEMENT>l+c)throw new Error("FeatureTable: Feature data read outside binary body length.");return p}}else return n}}class Ls extends mn{batchSize;constructor(e,t,a,r,i){super(e,a,r,i),this.batchSize=t}getData(e,t=null,a=null){return super.getData(e,this.batchSize,t,a)}}function Gs(s){let e;if(s instanceof DataView?e=s:e=new DataView(s),String.fromCharCode(e.getUint8(0))==="{")return null;let t="";for(let a=0;a<4;a++)t+=String.fromCharCode(e.getUint8(a));return t}class tf{async parse(e){const t=new DataView(e),a=Gs(t);console.assert(a==="b3dm");const r=t.getUint32(4,!0);console.assert(r===1);const i=t.getUint32(8,!0);console.assert(i===e.byteLength);const n=t.getUint32(12,!0),o=t.getUint32(16,!0),l=t.getUint32(20,!0),c=t.getUint32(24,!0),f=28,h=new mn(e,f,n,o),u=f+n+o,g=new Ls(e,h.getData("BATCH_LENGTH"),u,l,c),p=u+l+c,m=new Uint8Array(e,p,i-p);return{version:r,featureTable:h,batchTable:g,glbBytes:m}}}class Ga extends tf{adjustmentTransform;gltfBuffer;static tempMatrix;constructor(){super(),this.adjustmentTransform=new R().identity(),Ga.tempMatrix||=new R().identity()}async parse(e){const t=await super.parse(e);this.gltfBuffer=t.glbBytes.slice().buffer;let r=await new Ws().parseBinary(this.gltfBuffer),{batchTable:i,featureTable:n}=t;const o=n.getData("RTC_CENTER");o&&(r.x+=o[0],r.y+=o[1],r.z+=o[2]);let l=r.getComponent(kt);l.updateWorldMatrix();let c=Ga.tempMatrix;c.compose(l.localPosition,l.localRotQuat,l.localScale),c.multiply(this.adjustmentTransform);let f=c.decompose(Wt.QUATERNION);return l.localRotQuat.copyFrom(f[1]),l.localRotQuat=l.localRotQuat,l.localPosition.copyFrom(f[0]),l.localPosition=l.localPosition,l.localScale.copyFrom(f[2]),l.localScale=l.localScale,l.updateWorldMatrix(),r.batchTable=i,r.featureTable=n,r}static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let a=0,r=e.length;a<r;a++)t+=String.fromCharCode(e[a]);try{return decodeURIComponent(escape(t))}catch{return t}}}class zs extends nt{static format=Ge.BIN;async parseBuffer(e){let t=new Ga;this.userData&&(t.adjustmentTransform=this.userData),this.data=await t.parse(e)}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}}const af="glTF",Ci=12,rf={JSON:1313821514,BIN:5130562},Js={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class nf{name;content;body;header;constructor(e){this.name=Js.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ci);if(this.header={magic:Ga.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==af)throw new Error("GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("GLTFLoader: Legacy binary file detected.");const a=this.header.length-Ci,r=new DataView(e,Ci);let i=0;for(;i<a;){const n=r.getUint32(i,!0);i+=4;const o=r.getUint32(i,!0);if(i+=4,o===rf.JSON){const l=new Uint8Array(e,Ci+i,n);this.content=Ga.decodeText(l)}else if(o===rf.BIN){const l=Ci+i;this.body=e.slice(l,l+n)}i+=n}if(this.content===null)throw new Error("GLTFLoader: JSON content not found.")}}class Ws{_binary;async parseBinary(e){this._binary=e;const t=Ga.decodeText(new Uint8Array(this._binary,0,4)),a={};let r,i;if(t===af){try{i=a[Js.KHR_BINARY_GLTF]=new nf(this._binary)}catch{return}r=a[Js.KHR_BINARY_GLTF].content}else r=Ga.decodeText(new Uint8Array(this._binary));const n=JSON.parse(r);return await this.parseGLB(n,i.body)}async parseGLB(e,t){return await new Qs().parseJsonAndBuffer(e,t)}}class sf{async parse(e){const t=new DataView(e),a=Gs(t);console.assert(a==="i3dm");const r=t.getUint32(4,!0);console.assert(r===1);const i=t.getUint32(8,!0);console.assert(i===e.byteLength);const n=t.getUint32(12,!0),o=t.getUint32(16,!0),l=t.getUint32(20,!0),c=t.getUint32(24,!0);t.getUint32(28,!0);const f=32,h=new mn(e,f,n,o),u=f+n+o,g=new Ls(e,h.getData("INSTANCES_LENGTH"),u,l,c),p=u+l+c,m=new Uint8Array(e,p,i-p);return{version:r,featureTable:h,batchTable:g,glbBytes:m}}}class of extends d.Object3D{_geometry;_material;_instanceList;constructor(e,t,a){super(),this._geometry=e,this._material=t,this._instanceList=[];for(let r=0;r<a;r++){let i,n=new d.Object3D;i=n.addComponent(d.MeshRenderer),i.geometry=this._geometry,i.material=this._material,this.addChild(n),this._instanceList.push(n)}}setMatrixAt(e,t){let a=this._instanceList[e],r=t.decompose(Wt.QUATERNION),i=a.transform;return i.localRotQuat.copyFrom(r[1]),i.localRotQuat=i.localRotQuat,i.localPosition.copyFrom(r[0]),i.localPosition=i.localPosition,i.localScale.copyFrom(r[2]),i.localScale=i.localScale,this}}class sa extends sf{static tempFwd;static tempUp;static tempRight;static tempPos;static tempQuat;static tempSca;static tempMat;adjustmentTransform;_gltfBuffer;constructor(){super(),sa.tempFwd||=new b,sa.tempUp||=new b,sa.tempRight||=new b,sa.tempPos||=new b,sa.tempQuat||=new Z,sa.tempSca||=new b,sa.tempMat||=new R,this.adjustmentTransform=new R().identity()}async parse(e){const t=await super.parse(e);this._gltfBuffer=t.glbBytes.slice().buffer;let r=await new Ws().parseBinary(this._gltfBuffer),{batchTable:i,featureTable:n}=t;const o=this.adjustmentTransform,l=n.getData("INSTANCES_LENGTH"),c=n.getData("POSITION",l,"FLOAT","VEC3"),f=n.getData("NORMAL_UP",l,"FLOAT","VEC3"),h=n.getData("NORMAL_RIGHT",l,"FLOAT","VEC3"),u=n.getData("SCALE_NON_UNIFORM",l,"FLOAT","VEC3"),g=n.getData("SCALE",l,"FLOAT","SCALAR"),p=new Map,m=[];r.traverse(B=>{let v;if(v=B?B.getComponent(d.MeshRenderer):null,v){const{geometry:C,material:y}=v,F=new of(C,y,l);F.localPosition=F.localPosition.copy(B.localPosition),F.localRotation=F.localRotation.copy(B.localRotation),F.localScale=F.localScale.copy(B.localScale),m.push(F),p.set(B,F)}});const D=new b;for(let B=0;B<l;B++)D.x+=c[B*3+0]/l,D.y+=c[B*3+1]/l,D.z+=c[B*3+2]/l;p.forEach((B,v)=>{const C=v.parent?v.parentObject:null;C&&(C.removeChild(v),C.addChild(B),B.transform.updateWorldMatrix(),B.transform.worldMatrix.transformVector4(D,B.localPosition))});const _=sa;for(let B=0;B<l;B++){_.tempMat.identity(),_.tempPos.set(c[B*3+0]-D.x,c[B*3+1]-D.y,c[B*3+2]-D.z),f?(_.tempUp.set(f[B*3+0],f[B*3+1],f[B*3+2]),_.tempRight.set(h[B*3+0],h[B*3+1],h[B*3+2]),_.tempRight.crossProduct(_.tempUp,_.tempFwd).normalize(),_.tempMat.makeBasis(_.tempRight,_.tempUp,_.tempFwd),_.tempQuat.setFromRotationMatrix(_.tempMat)):_.tempQuat.set(0,0,0,1),g?_.tempSca.setScalar(g[B]):u?_.tempSca.set(u[B*3+0],u[B*3+1],u[B*3+2]):_.tempSca.set(1,1,1),_.tempMat.compose(_.tempPos,_.tempQuat,_.tempSca),_.tempMat.multiplyMatrices(_.tempMat,o);for(let v=0,C=m.length;v<C;v++)m[v].setMatrixAt(B,_.tempMat)}return r.batchTable=i,r.featureTable=n,r}}class lf extends nt{static format=Ge.BIN;async parseBuffer(e){let t=new sa;t.adjustmentTransform=this.userData,this.data=await t.parse(e)}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}}class pn extends un{_faceData;_url;get ldrImageUrl(){return this._url}constructor(){super(),this.useMipmap=!0,this.format=Y.rgba16float,this._faceData=new Os(this)}async load(e,t){this._url=e;let a=new La(!1);return await a.load(e,t),this.createFromLDRTexture(a),this}createFromLDRTexture(e){let t=Math.log2(e.width/4);return t=Math.pow(2,Math.round(t)),this.createFromTexture(t,e),this}createFromTexture(e,t){this.width=this.height=e,this.textureBindingLayout.viewDimension="cube";let a=this.width;for(this.mipmapCount=1;a>16;)a/=2,this.mipmapCount++;return this.createTextureDescriptor(e,e,this.mipmapCount,this.format),this.textureDescriptor.size={width:e,height:e,depthOrArrayLayers:6},this.textureDescriptor.dimension="2d",this.gpuSampler=E.device.createSampler(this),this._faceData.uploadErpTexture(t),this}}let cf=`
7673
+ `;class $0{static configBuffer=null;static quaternionBuffer=null;static blurSettingBuffer=null;static pipeline;static importantSample(e,t,a,r){const i=E.device;this.pipeline==null&&(this.pipeline=i.createComputePipeline({layout:"auto",compute:{module:i.createShaderModule({code:q0}),entryPoint:"main"}}));const n=this.pipeline,o=16;this.configBuffer||=i.createBuffer({size:o,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),i.queue.writeBuffer(this.configBuffer,0,new Uint32Array([e.width,e.height,t,t]));const l=24;if(!this.quaternionBuffer){this.quaternionBuffer=i.createBuffer({size:l*4*6,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST});let D=new Float32Array(24);for(let _=0;_<6;_++){let B=Ms.getRotationToFace(_);D[_*4+0]=B.x,D[_*4+1]=B.y,D[_*4+2]=B.z,D[_*4+3]=B.w}i.queue.writeBuffer(this.quaternionBuffer,0,D)}this.blurSettingBuffer||=i.createBuffer({size:o,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),i.queue.writeBuffer(this.blurSettingBuffer,0,new Float32Array([a,0,0,0]));const c=e.erpTexture;let f=[{binding:0,resource:{buffer:this.configBuffer,size:16}},{binding:1,resource:{buffer:this.quaternionBuffer,size:l*4}},{binding:2,resource:c.gpuSampler},{binding:3,resource:c.getGPUView()}],h=[{binding:0,resource:{buffer:this.blurSettingBuffer,size:16}},{binding:1,resource:r}];const u=i.createBindGroup({layout:n.getBindGroupLayout(0),entries:f}),g=i.createBindGroup({layout:n.getBindGroupLayout(1),entries:h}),p=S.beginCommandEncoder(),m=p.beginComputePass();m.setPipeline(n),m.setBindGroup(0,u),m.setBindGroup(1,g),m.dispatchWorkgroups(t/8,t/8,6),m.end(),S.endCommandEncoder(p)}}class Os{faceTextureRef;_texture;constructor(e){this._texture=e,this.faceTextureRef={}}uploadTexture(e,t){let a=this.getGpuSource(e);return wt.makeTextureCube(t,this._texture.width,a.v),this}uploadErpTexture(e){let t=this.getGpuSource(0);return wt.makeTextureCube(e,this._texture.width,t.v),this.generateMipmap(e),this}getGpuSource(e){let t=this.faceTextureRef[e];return t||(t={t:this._texture.getGPUTexture(),v:this._texture.getGPUTexture().createView({format:this._texture.format,dimension:"2d-array",baseMipLevel:e,mipLevelCount:1,arrayLayerCount:6})},this.faceTextureRef[e]=t),t}generateMipmap(e){let t=1;for(;t<this._texture.mipmapCount;)this.generateMipmapAtLevel(t,e),t++}generateMipmapAtLevel(e,t,a=3){let r=this._texture.width/Math.pow(2,e),i={width:r,height:r,erpTexture:t},n=(e+1)/this._texture.mipmapCount;n=Math.pow(n,a);let o=this.getGpuSource(e);$0.importantSample(i,r,n,o.v)}}class gn extends un{_url;_faceData;constructor(){super(),this.useMipmap=!0,this.format=Y.rgba16float,this.isHDRTexture=!0,this._faceData=new Os(this)}createFromHDRData(e,t){let a=new pe(t.width,t.height,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING),r=new Float32Array(t.array);return wt.convertRGBE2RGBA(a,r),this.createFromTexture(e,a),this}createFromTexture(e,t){this.width=this.height=e,this.textureBindingLayout.viewDimension="cube";let a=this.width;for(this.mipmapCount=1;a>16;)a/=2,this.mipmapCount++;return this.createTextureDescriptor(e,e,this.mipmapCount,this.format),this.textureDescriptor.size={width:e,height:e,depthOrArrayLayers:6},this.textureDescriptor.dimension="2d",this.gpuSampler=E.device.createSampler(this),this._faceData.uploadErpTexture(t),this}async load(e,t){return this._url=e,(await new At().load(e,Vs,t)).getCubeTexture()}}function ef(s){return new TextDecoder().decode(s)}class mn{buffer;binOffset;binLength;header;constructor(e,t,a,r){this.buffer=e,this.binOffset=t+a,this.binLength=r;let i=null;if(a!==0){const n=new Uint8Array(e,t,a);i=JSON.parse(ef(n))}else i={};this.header=i}getKeys(){return Object.keys(this.header)}getData(e,t,a=null,r=null){const i=this.header;if(!(e in i))return null;const n=i[e];if(n instanceof Object){if(Array.isArray(n))return n;{const{buffer:o,binOffset:l,binLength:c}=this,f=n.byteOffset||0,h=n.type||r,u=n.componentType||a;if("type"in n&&r&&n.type!==r)throw new Error("FeatureTable: Specified type does not match expected type.");let g;switch(h){case"SCALAR":g=1;break;case"VEC2":g=2;break;case"VEC3":g=3;break;case"VEC4":g=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${e}".`)}let p;const m=l+f,D=t*g;switch(u){case"BYTE":p=new Int8Array(o,m,D);break;case"UNSIGNED_BYTE":p=new Uint8Array(o,m,D);break;case"SHORT":p=new Int16Array(o,m,D);break;case"UNSIGNED_SHORT":p=new Uint16Array(o,m,D);break;case"INT":p=new Int32Array(o,m,D);break;case"UNSIGNED_INT":p=new Uint32Array(o,m,D);break;case"FLOAT":p=new Float32Array(o,m,D);break;case"DOUBLE":p=new Float64Array(o,m,D);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${e}".`)}if(m+D*p.BYTES_PER_ELEMENT>l+c)throw new Error("FeatureTable: Feature data read outside binary body length.");return p}}else return n}destroy(){this.buffer=null,this.header=null,this.binOffset=null,this.binLength=null}}class Ls extends mn{batchSize;constructor(e,t,a,r,i){super(e,a,r,i),this.batchSize=t}getData(e,t=null,a=null){return super.getData(e,this.batchSize,t,a)}}function Gs(s){let e;if(s instanceof DataView?e=s:e=new DataView(s),String.fromCharCode(e.getUint8(0))==="{")return null;let t="";for(let a=0;a<4;a++)t+=String.fromCharCode(e.getUint8(a));return t}class tf{async parse(e){const t=new DataView(e),a=Gs(t);console.assert(a==="b3dm");const r=t.getUint32(4,!0);console.assert(r===1);const i=t.getUint32(8,!0);console.assert(i===e.byteLength);const n=t.getUint32(12,!0),o=t.getUint32(16,!0),l=t.getUint32(20,!0),c=t.getUint32(24,!0),f=28,h=new mn(e,f,n,o),u=f+n+o,g=new Ls(e,h.getData("BATCH_LENGTH"),u,l,c),p=u+l+c,m=new Uint8Array(e,p,i-p);return{version:r,featureTable:h,batchTable:g,glbBytes:m}}}class Ga extends tf{adjustmentTransform;gltfBuffer;static tempMatrix;constructor(){super(),this.adjustmentTransform=new R().identity(),Ga.tempMatrix||=new R().identity()}async parse(e){const t=await super.parse(e);this.gltfBuffer=t.glbBytes.slice().buffer;let r=await new Ws().parseBinary(this.gltfBuffer),{batchTable:i,featureTable:n}=t;const o=n.getData("RTC_CENTER");o&&(r.x+=o[0],r.y+=o[1],r.z+=o[2]);let l=r.getComponent(kt);l.updateWorldMatrix();let c=Ga.tempMatrix;c.compose(l.localPosition,l.localRotQuat,l.localScale),c.multiply(this.adjustmentTransform);let f=c.decompose(Wt.QUATERNION);return l.localRotQuat.copyFrom(f[1]),l.localRotQuat=l.localRotQuat,l.localPosition.copyFrom(f[0]),l.localPosition=l.localPosition,l.localScale.copyFrom(f[2]),l.localScale=l.localScale,l.updateWorldMatrix(),r.batchTable=i,r.featureTable=n,r}static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let a=0,r=e.length;a<r;a++)t+=String.fromCharCode(e[a]);try{return decodeURIComponent(escape(t))}catch{return t}}}class zs extends nt{static format=Ge.BIN;async parseBuffer(e){let t=new Ga;this.userData&&(t.adjustmentTransform=this.userData),this.data=await t.parse(e)}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}}const af="glTF",Ci=12,rf={JSON:1313821514,BIN:5130562},Js={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class nf{name;content;body;header;constructor(e){this.name=Js.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ci);if(this.header={magic:Ga.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==af)throw new Error("GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("GLTFLoader: Legacy binary file detected.");const a=this.header.length-Ci,r=new DataView(e,Ci);let i=0;for(;i<a;){const n=r.getUint32(i,!0);i+=4;const o=r.getUint32(i,!0);if(i+=4,o===rf.JSON){const l=new Uint8Array(e,Ci+i,n);this.content=Ga.decodeText(l)}else if(o===rf.BIN){const l=Ci+i;this.body=e.slice(l,l+n)}i+=n}if(this.content===null)throw new Error("GLTFLoader: JSON content not found.")}}class Ws{_binary;async parseBinary(e){this._binary=e;const t=Ga.decodeText(new Uint8Array(this._binary,0,4)),a={};let r,i;if(t===af){try{i=a[Js.KHR_BINARY_GLTF]=new nf(this._binary)}catch{return}r=a[Js.KHR_BINARY_GLTF].content}else r=Ga.decodeText(new Uint8Array(this._binary));const n=JSON.parse(r);return await this.parseGLB(n,i.body)}async parseGLB(e,t){return await new Qs().parseJsonAndBuffer(e,t)}}class sf{async parse(e){const t=new DataView(e),a=Gs(t);console.assert(a==="i3dm");const r=t.getUint32(4,!0);console.assert(r===1);const i=t.getUint32(8,!0);console.assert(i===e.byteLength);const n=t.getUint32(12,!0),o=t.getUint32(16,!0),l=t.getUint32(20,!0),c=t.getUint32(24,!0);t.getUint32(28,!0);const f=32,h=new mn(e,f,n,o),u=f+n+o,g=new Ls(e,h.getData("INSTANCES_LENGTH"),u,l,c),p=u+l+c,m=new Uint8Array(e,p,i-p);return{version:r,featureTable:h,batchTable:g,glbBytes:m}}}class of extends d.Object3D{_geometry;_material;_instanceList;constructor(e,t,a){super(),this._geometry=e,this._material=t,this._instanceList=[];for(let r=0;r<a;r++){let i,n=new d.Object3D;i=n.addComponent(d.MeshRenderer),i.geometry=this._geometry,i.material=this._material,this.addChild(n),this._instanceList.push(n)}}setMatrixAt(e,t){let a=this._instanceList[e],r=t.decompose(Wt.QUATERNION),i=a.transform;return i.localRotQuat.copyFrom(r[1]),i.localRotQuat=i.localRotQuat,i.localPosition.copyFrom(r[0]),i.localPosition=i.localPosition,i.localScale.copyFrom(r[2]),i.localScale=i.localScale,this}}class sa extends sf{static tempFwd;static tempUp;static tempRight;static tempPos;static tempQuat;static tempSca;static tempMat;adjustmentTransform;_gltfBuffer;constructor(){super(),sa.tempFwd||=new b,sa.tempUp||=new b,sa.tempRight||=new b,sa.tempPos||=new b,sa.tempQuat||=new Z,sa.tempSca||=new b,sa.tempMat||=new R,this.adjustmentTransform=new R().identity()}async parse(e){const t=await super.parse(e);this._gltfBuffer=t.glbBytes.slice().buffer;let r=await new Ws().parseBinary(this._gltfBuffer),{batchTable:i,featureTable:n}=t;const o=this.adjustmentTransform,l=n.getData("INSTANCES_LENGTH"),c=n.getData("POSITION",l,"FLOAT","VEC3"),f=n.getData("NORMAL_UP",l,"FLOAT","VEC3"),h=n.getData("NORMAL_RIGHT",l,"FLOAT","VEC3"),u=n.getData("SCALE_NON_UNIFORM",l,"FLOAT","VEC3"),g=n.getData("SCALE",l,"FLOAT","SCALAR"),p=new Map,m=[];r.traverse(B=>{let v;if(v=B?B.getComponent(d.MeshRenderer):null,v){const{geometry:C,material:y}=v,F=new of(C,y,l);F.localPosition=F.localPosition.copy(B.localPosition),F.localRotation=F.localRotation.copy(B.localRotation),F.localScale=F.localScale.copy(B.localScale),m.push(F),p.set(B,F)}});const D=new b;for(let B=0;B<l;B++)D.x+=c[B*3+0]/l,D.y+=c[B*3+1]/l,D.z+=c[B*3+2]/l;p.forEach((B,v)=>{const C=v.parent?v.parentObject:null;C&&(C.removeChild(v),C.addChild(B),B.transform.updateWorldMatrix(),B.transform.worldMatrix.transformVector4(D,B.localPosition))});const _=sa;for(let B=0;B<l;B++){_.tempMat.identity(),_.tempPos.set(c[B*3+0]-D.x,c[B*3+1]-D.y,c[B*3+2]-D.z),f?(_.tempUp.set(f[B*3+0],f[B*3+1],f[B*3+2]),_.tempRight.set(h[B*3+0],h[B*3+1],h[B*3+2]),_.tempRight.crossProduct(_.tempUp,_.tempFwd).normalize(),_.tempMat.makeBasis(_.tempRight,_.tempUp,_.tempFwd),_.tempQuat.setFromRotationMatrix(_.tempMat)):_.tempQuat.set(0,0,0,1),g?_.tempSca.setScalar(g[B]):u?_.tempSca.set(u[B*3+0],u[B*3+1],u[B*3+2]):_.tempSca.set(1,1,1),_.tempMat.compose(_.tempPos,_.tempQuat,_.tempSca),_.tempMat.multiplyMatrices(_.tempMat,o);for(let v=0,C=m.length;v<C;v++)m[v].setMatrixAt(B,_.tempMat)}return r.batchTable=i,r.featureTable=n,r}}class lf extends nt{static format=Ge.BIN;async parseBuffer(e){let t=new sa;t.adjustmentTransform=this.userData,this.data=await t.parse(e)}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}}class pn extends un{_faceData;_url;get ldrImageUrl(){return this._url}constructor(){super(),this.useMipmap=!0,this.format=Y.rgba16float,this._faceData=new Os(this)}async load(e,t){this._url=e;let a=new La(!1);return await a.load(e,t),this.createFromLDRTexture(a),this}createFromLDRTexture(e){let t=Math.log2(e.width/4);return t=Math.pow(2,Math.round(t)),this.createFromTexture(t,e),this}createFromTexture(e,t){this.width=this.height=e,this.textureBindingLayout.viewDimension="cube";let a=this.width;for(this.mipmapCount=1;a>16;)a/=2,this.mipmapCount++;return this.createTextureDescriptor(e,e,this.mipmapCount,this.format),this.textureDescriptor.size={width:e,height:e,depthOrArrayLayers:6},this.textureDescriptor.dimension="2d",this.gpuSampler=E.device.createSampler(this),this._faceData.uploadErpTexture(t),this}}let cf=`
7674
7674
  var<private>PI: f32 = 3.141592653589793;
7675
7675
 
7676
7676
  fn hammersley(i : u32, N : u32) -> vec2<f32>{
@@ -7762,7 +7762,7 @@ else if (typeof exports === 'object')
7762
7762
  `;class ff{compute;constructor(){this.compute=new fe(cf)}generateBRDFLUTTexture(){let e=new pe(256,256,Y.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=S.beginCommandEncoder();return S.computeCommand(t,[this.compute]),S.endCommandEncoder(t),e}}class qr{id;guiTexture;uvRec=new $(0,0,1,1);uvBorder=new $(0,0,0,0);offsetSize=new $(0,0,4,4);borderSize=new $(0,0,0,0);trimSize=new K;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||A.res.defaultGUITexture}}class ir{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=A.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,ir._maxUid++,this._staticId=ir._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class F2{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 $r=new F2;class df{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 hf{id=0;file=""}class uf{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class za extends nt{static format=Ge.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 qr;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),$r.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 df;a.trim().split(t).forEach((i,n)=>{if(n<2)za.readLineProperty(i,r);else if(n<r.pages+2){let o=new hf;za.readLineProperty(i,o),r.fontPage.push(o)}else if(n<r.pages+3)za.readLineProperty(i,r);else if(r.count>0){let o=new uf;za.readLineProperty(i,o),r.fontChar[o.id]=o,r.count--}}),a="",this.data=r,await this.loadFontTextures()}getNewLine(e){return e.indexOf(`\r
7763
7763
  `)!=-1?`\r
7764
7764
  `:e.indexOf("\r")!=-1?"\r":`
7765
- `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await A.res.loadTexture(r,null,!0);let i=A.res.getTexture(r),n=new ir(i);e.push(n)}za.parseSprite(e,t),t.fontChar[" "]||za.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new qr,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),$r.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 k2(s,e){let t=new qr;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 ir(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function bf(s,e,t){let a=new qr;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 gf{_spriteMap=new Map;_spriteList=[];textureSize=new K;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=bf(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 mf extends nt{static format=Ge.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await A.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 gf(this._json.size),t=new ir(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);A.res.addAtlas(this.baseUrl,e),this.data=e}}var Ot=Uint8Array,ei=Uint16Array,E2=Int32Array,pf=new Ot([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]),Af=new Ot([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]),R2=new Ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Df=function(s,e){for(var t=new ei(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new E2(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}},_f=Df(pf,2),Bf=_f.b,w2=_f.r;Bf[28]=258,w2[258]=28;for(var I2=Df(Af,0),Q2=I2.b,js=new ei(32768),we=0;we<32768;++we){var nr=(we&43690)>>1|(we&21845)<<1;nr=(nr&52428)>>2|(nr&13107)<<2,nr=(nr&61680)>>4|(nr&3855)<<4,js[we]=((nr&65280)>>8|(nr&255)<<8)>>1}for(var Si=(function(s,e,t){for(var a=s.length,r=0,i=new ei(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new ei(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new ei(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],h=n[s[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[js[h]>>l]=c}else for(o=new ei(a),r=0;r<a;++r)s[r]&&(o[r]=js[n[s[r]-1]++]>>15-s[r]);return o}),xi=new Ot(288),we=0;we<144;++we)xi[we]=8;for(var we=144;we<256;++we)xi[we]=9;for(var we=256;we<280;++we)xi[we]=7;for(var we=280;we<288;++we)xi[we]=8;for(var Uf=new Ot(32),we=0;we<32;++we)Uf[we]=5;var T2=Si(xi,9,1),M2=Si(Uf,5,1),Zs=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},oa=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Ys=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},N2=function(s){return(s+7)/8|0},Xs=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new Ot(s.subarray(e,t))},P2=["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"],Xt=function(s,e,t){var a=new Error(e||P2[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,Xt),!t)throw a;return a},V2=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new Ot(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new Ot(r*3));var c=function(It){var Qt=t.length;if(It>Qt){var Gt=new Ot(Math.max(Qt*2,It));Gt.set(t),t=Gt}},f=e.f||0,h=e.p||0,u=e.b||0,g=e.l,p=e.d,m=e.m,D=e.n,_=r*8;do{if(!g){f=oa(s,h,1);var B=oa(s,h+1,3);if(h+=3,B)if(B==1)g=T2,p=M2,m=9,D=5;else if(B==2){var F=oa(s,h,31)+257,k=oa(s,h+10,15)+4,w=F+oa(s,h+5,31)+1;h+=14;for(var x=new Ot(w),M=new Ot(19),N=0;N<k;++N)M[R2[N]]=oa(s,h+N*3,7);h+=k*3;for(var Q=Zs(M),G=(1<<Q)-1,X=Si(M,Q,1),N=0;N<w;){var ne=X[oa(s,h,G)];h+=ne&15;var v=ne>>4;if(v<16)x[N++]=v;else{var q=0,he=0;for(v==16?(he=3+oa(s,h,3),h+=2,q=x[N-1]):v==17?(he=3+oa(s,h,7),h+=3):v==18&&(he=11+oa(s,h,127),h+=7);he--;)x[N++]=q}}var Be=x.subarray(0,F),ae=x.subarray(F);m=Zs(Be),D=Zs(ae),g=Si(Be,m,1),p=Si(ae,D,1)}else Xt(1);else{var v=N2(h)+4,C=s[v-4]|s[v-3]<<8,y=v+C;if(y>r){l&&Xt(0);break}o&&c(u+C),t.set(s.subarray(v,y),u),e.b=u+=C,e.p=h=y*8,e.f=f;continue}if(h>_){l&&Xt(0);break}}o&&c(u+131072);for(var ee=(1<<m)-1,se=(1<<D)-1,Ae=h;;Ae=h){var q=g[Ys(s,h)&ee],Ue=q>>4;if(h+=q&15,h>_){l&&Xt(0);break}if(q||Xt(2),Ue<256)t[u++]=Ue;else if(Ue==256){Ae=h,g=null;break}else{var Se=Ue-254;if(Ue>264){var N=Ue-257,Te=pf[N];Se=oa(s,h,(1<<Te)-1)+Bf[N],h+=Te}var ve=p[Ys(s,h)&se],Me=ve>>4;ve||Xt(3),h+=ve&15;var ae=Q2[Me];if(Me>3){var Te=Af[Me];ae+=Ys(s,h)&(1<<Te)-1,h+=Te}if(h>_){l&&Xt(0);break}o&&c(u+131072);var Ut=u+Se;if(u<ae){var ya=i-ae,Ca=Math.min(ae,Ut);for(ya+u<0&&Xt(3);u<Ca;++u)t[u]=a[ya+u]}for(;u<Ut;++u)t[u]=t[u-ae]}}e.l=g,e.p=Ae,e.b=u,e.f=f,g&&(f=1,e.m=m,e.d=p,e.n=D)}while(!f);return u!=t.length&&n?Xs(t,0,u):t.subarray(0,u)},O2=new Ot(0),Aa=function(s,e){return s[e]|s[e+1]<<8},la=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},Hs=function(s,e){return la(s,e)+la(s,e+4)*4294967296};function L2(s,e){return V2(s,{i:2},e&&e.out,e&&e.dictionary)}var Ks=typeof TextDecoder<"u"&&new TextDecoder,G2=0;try{Ks.decode(O2,{stream:!0}),G2=1}catch{}var z2=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:Xs(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 vf(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(Ks)return Ks.decode(s);var r=z2(s),i=r.s,t=r.r;return t.length&&Xt(8),i}}var J2=function(s,e){return e+30+Aa(s,e+26)+Aa(s,e+28)},W2=function(s,e,t){var a=Aa(s,e+28),r=vf(s.subarray(e+46,e+46+a),!(Aa(s,e+8)&2048)),i=e+46+a,n=la(s,e+20),o=t&&n==4294967295?j2(s,i):[n,la(s,e+24),la(s,e+42)],l=o[0],c=o[1],f=o[2];return[Aa(s,e+10),l,c,r,i+Aa(s,e+30)+Aa(s,e+32),f]},j2=function(s,e){for(;Aa(s,e)!=1;e+=4+Aa(s,e+2));return[Hs(s,e+12),Hs(s,e+4),Hs(s,e+20)]};function Z2(s,e){for(var t={},a=s.length-22;la(s,a)!=101010256;--a)(!a||s.length-a>65558)&&Xt(13);var r=Aa(s,a+8);if(!r)return{};var i=la(s,a+16),n=i==4294967295||r==65535;if(n){var o=la(s,a-12);n=la(s,o)==101075792,n&&(r=la(s,o+32),i=la(s,o+48))}for(var l=0;l<r;++l){var c=W2(s,i,n),f=c[0],h=c[1],u=c[2],g=c[3],p=c[4],m=c[5],D=J2(s,m);i=p,f?f==8?t[g]=L2(s.subarray(D,D+h),{out:new Ot(u)}):Xt(14,"unknown compression type "+f):t[g]=Xs(s,D,D+h)}return t}class st extends ut{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=A.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 Cr extends Fe{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),h=new Uint16Array(i*r*2*3),u=0,g=0,p=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,D=n*Math.cos(m),_=n*Math.sin(m);for(e=0;e<=i;++e){var B=2*Math.PI*e/i,v=_*Math.cos(B),C=_*Math.sin(B),y=1/Math.sqrt(v*v+D*D+C*C);if(l[u++]=v,l[u++]=D,l[u++]=C,c[g++]=v*y,c[g++]=D*y,c[g++]=C*y,f[p++]=e/i,f[p++]=t/r,e>0&&t>0){var F=(i+1)*t+e,k=(i+1)*t+e-1,w=(i+1)*(t-1)+e-1,x=(i+1)*(t-1)+e;t==r?(h[a++]=F,h[a++]=w,h[a++]=x):t==1?(h[a++]=F,h[a++]=k,h[a++]=w):(h[a++]=F,h[a++]=k,h[a++]=w,h[a++]=F,h[a++]=w,h[a++]=x)}}}this.setIndices(h),this.setAttribute(V.position,l),this.setAttribute(V.normal,c),this.setAttribute(V.uv,f),this.setAttribute(V.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new ge(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class Fi extends d.Object3D{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),Fi.register3DRepresentation)this.marker=Fi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Cr(.1,32,16),e.material=new st,e.material.baseColor=this.positionValid?new O(0,1,0,1):new O(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class ki 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 Fi(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),ki.register3DRepresentation?(this.line=ki.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new O(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Fe,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(V.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new d.Object3D,o=n.addComponent(d.MeshRenderer),l=new st;return l.topology="line-list",l.baseColor=t,l.blendMode=te.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class yf extends nt{static format=Ge.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Z2(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(vf(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 ki(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 Cf{_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 At().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 At;r==".gltf"?a=await i.load(e,Dt,t):a=await i.load(e,Qs,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 At;r==".obj"&&(a=await i.load(e,J0,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 At().load(e,zs,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 At().load(e,lf,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 La;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}async loadTextureCount(e,t,a,r){return new Promise(async(i,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(h=>{l.push(h),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Ns;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 gn;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 pn;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 Ts;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 Ts;return await a.loadStd(e),a}async loadJSON(e,t){return await new At().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new At().load(e,za,t,a),n=i.data;return $r.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new At().load(e,mf,t,e)).data}async loadKMZ(e,t){return(await new At().load(e,yf,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let h=new ds;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new ff().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new gn,this.defaultSky.createFromTexture(128,this.blackTexture),me.getInstance().attached(this.defaultSky,this),me.getInstance().attached(t,this),me.getInstance().attached(this.normalTexture,this),me.getInstance().attached(this.maskTexture,this),me.getInstance().attached(this.whiteTexture,this),me.getInstance().attached(this.blackTexture,this),me.getInstance().attached(this.redTexture,this),me.getInstance().attached(this.blueTexture,this),me.getInstance().attached(this.greenTexture,this),me.getInstance().attached(this.yellowTexture,this),me.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new ir(this.whiteTexture),this.defaultGUISprite=new qr(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new pa}}class Sf extends Pe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=A.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=A.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;A.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Y2="1.0.24";class A{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 E.presentationSize}static get aspect(){return E.aspect}static get width(){return E.windowWidth}static get height(){return E.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 O(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",Y2),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await be.init(R.allocCount,this.setting.doublePrecision),await E.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,oe.getGBufferFrame(oe.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),J.init(),Va.init(),le.init(),mt.init(),Et.init(),this.res=new Cf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new No,this.inputSystem.initCanvas(E.canvas)}static startRenderJob(e){let t=new _0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Sf).addPost(_s),(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){xe.delta=e-xe.time,xe.time=e,xe.frame+=1,rr.tick(xe.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=E.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of ye.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=E.device.createCommandEncoder();for(const n of ye.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}E.device.queue.submit([r.finish()]);for(const n of ye.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const n of ye.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];o&&f.enable&&h(o)}}this._renderLoop&&await this._renderLoop(),be.updateAllContinueTransform(0,R.useCount,16),le.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of ye.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let An=`
7765
+ `}async loadFontTextures(){let e=[],t=this.data;for(const a of t.fontPage){let r=this.baseUrl+a.file;await A.res.loadTexture(r,null,!0);let i=A.res.getTexture(r),n=new ir(i);e.push(n)}za.parseSprite(e,t),t.fontChar[" "]||za.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let a=new qr,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),$r.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 k2(s,e){let t=new qr;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 ir(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function bf(s,e,t){let a=new qr;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 gf{_spriteMap=new Map;_spriteList=[];textureSize=new K;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,a){let r=bf(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 mf extends nt{static format=Ge.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await A.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 gf(this._json.size),t=new ir(this._texture),a=this._json.atlas;for(const r in a)e.setTexture(t,r,a[r]);A.res.addAtlas(this.baseUrl,e),this.data=e}}var Ot=Uint8Array,ei=Uint16Array,E2=Int32Array,pf=new Ot([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]),Af=new Ot([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]),R2=new Ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Df=function(s,e){for(var t=new ei(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var r=new E2(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}},_f=Df(pf,2),Bf=_f.b,w2=_f.r;Bf[28]=258,w2[258]=28;for(var I2=Df(Af,0),Q2=I2.b,js=new ei(32768),we=0;we<32768;++we){var nr=(we&43690)>>1|(we&21845)<<1;nr=(nr&52428)>>2|(nr&13107)<<2,nr=(nr&61680)>>4|(nr&3855)<<4,js[we]=((nr&65280)>>8|(nr&255)<<8)>>1}for(var Si=(function(s,e,t){for(var a=s.length,r=0,i=new ei(e);r<a;++r)s[r]&&++i[s[r]-1];var n=new ei(e);for(r=1;r<e;++r)n[r]=n[r-1]+i[r-1]<<1;var o;if(t){o=new ei(1<<e);var l=15-e;for(r=0;r<a;++r)if(s[r])for(var c=r<<4|s[r],f=e-s[r],h=n[s[r]-1]++<<f,u=h|(1<<f)-1;h<=u;++h)o[js[h]>>l]=c}else for(o=new ei(a),r=0;r<a;++r)s[r]&&(o[r]=js[n[s[r]-1]++]>>15-s[r]);return o}),xi=new Ot(288),we=0;we<144;++we)xi[we]=8;for(var we=144;we<256;++we)xi[we]=9;for(var we=256;we<280;++we)xi[we]=7;for(var we=280;we<288;++we)xi[we]=8;for(var Uf=new Ot(32),we=0;we<32;++we)Uf[we]=5;var T2=Si(xi,9,1),M2=Si(Uf,5,1),Zs=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},oa=function(s,e,t){var a=e/8|0;return(s[a]|s[a+1]<<8)>>(e&7)&t},Ys=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},N2=function(s){return(s+7)/8|0},Xs=function(s,e,t){return(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length),new Ot(s.subarray(e,t))},P2=["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"],Xt=function(s,e,t){var a=new Error(e||P2[s]);if(a.code=s,Error.captureStackTrace&&Error.captureStackTrace(a,Xt),!t)throw a;return a},V2=function(s,e,t,a){var r=s.length,i=a?a.length:0;if(!r||e.f&&!e.l)return t||new Ot(0);var n=!t,o=n||e.i!=2,l=e.i;n&&(t=new Ot(r*3));var c=function(It){var Qt=t.length;if(It>Qt){var Gt=new Ot(Math.max(Qt*2,It));Gt.set(t),t=Gt}},f=e.f||0,h=e.p||0,u=e.b||0,g=e.l,p=e.d,m=e.m,D=e.n,_=r*8;do{if(!g){f=oa(s,h,1);var B=oa(s,h+1,3);if(h+=3,B)if(B==1)g=T2,p=M2,m=9,D=5;else if(B==2){var F=oa(s,h,31)+257,k=oa(s,h+10,15)+4,w=F+oa(s,h+5,31)+1;h+=14;for(var x=new Ot(w),M=new Ot(19),N=0;N<k;++N)M[R2[N]]=oa(s,h+N*3,7);h+=k*3;for(var Q=Zs(M),G=(1<<Q)-1,X=Si(M,Q,1),N=0;N<w;){var ne=X[oa(s,h,G)];h+=ne&15;var v=ne>>4;if(v<16)x[N++]=v;else{var q=0,he=0;for(v==16?(he=3+oa(s,h,3),h+=2,q=x[N-1]):v==17?(he=3+oa(s,h,7),h+=3):v==18&&(he=11+oa(s,h,127),h+=7);he--;)x[N++]=q}}var Be=x.subarray(0,F),ae=x.subarray(F);m=Zs(Be),D=Zs(ae),g=Si(Be,m,1),p=Si(ae,D,1)}else Xt(1);else{var v=N2(h)+4,C=s[v-4]|s[v-3]<<8,y=v+C;if(y>r){l&&Xt(0);break}o&&c(u+C),t.set(s.subarray(v,y),u),e.b=u+=C,e.p=h=y*8,e.f=f;continue}if(h>_){l&&Xt(0);break}}o&&c(u+131072);for(var ee=(1<<m)-1,se=(1<<D)-1,Ae=h;;Ae=h){var q=g[Ys(s,h)&ee],Ue=q>>4;if(h+=q&15,h>_){l&&Xt(0);break}if(q||Xt(2),Ue<256)t[u++]=Ue;else if(Ue==256){Ae=h,g=null;break}else{var Se=Ue-254;if(Ue>264){var N=Ue-257,Te=pf[N];Se=oa(s,h,(1<<Te)-1)+Bf[N],h+=Te}var ve=p[Ys(s,h)&se],Me=ve>>4;ve||Xt(3),h+=ve&15;var ae=Q2[Me];if(Me>3){var Te=Af[Me];ae+=Ys(s,h)&(1<<Te)-1,h+=Te}if(h>_){l&&Xt(0);break}o&&c(u+131072);var Ut=u+Se;if(u<ae){var ya=i-ae,Ca=Math.min(ae,Ut);for(ya+u<0&&Xt(3);u<Ca;++u)t[u]=a[ya+u]}for(;u<Ut;++u)t[u]=t[u-ae]}}e.l=g,e.p=Ae,e.b=u,e.f=f,g&&(f=1,e.m=m,e.d=p,e.n=D)}while(!f);return u!=t.length&&n?Xs(t,0,u):t.subarray(0,u)},O2=new Ot(0),Aa=function(s,e){return s[e]|s[e+1]<<8},la=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},Hs=function(s,e){return la(s,e)+la(s,e+4)*4294967296};function L2(s,e){return V2(s,{i:2},e&&e.out,e&&e.dictionary)}var Ks=typeof TextDecoder<"u"&&new TextDecoder,G2=0;try{Ks.decode(O2,{stream:!0}),G2=1}catch{}var z2=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:Xs(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 vf(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(Ks)return Ks.decode(s);var r=z2(s),i=r.s,t=r.r;return t.length&&Xt(8),i}}var J2=function(s,e){return e+30+Aa(s,e+26)+Aa(s,e+28)},W2=function(s,e,t){var a=Aa(s,e+28),r=vf(s.subarray(e+46,e+46+a),!(Aa(s,e+8)&2048)),i=e+46+a,n=la(s,e+20),o=t&&n==4294967295?j2(s,i):[n,la(s,e+24),la(s,e+42)],l=o[0],c=o[1],f=o[2];return[Aa(s,e+10),l,c,r,i+Aa(s,e+30)+Aa(s,e+32),f]},j2=function(s,e){for(;Aa(s,e)!=1;e+=4+Aa(s,e+2));return[Hs(s,e+12),Hs(s,e+4),Hs(s,e+20)]};function Z2(s,e){for(var t={},a=s.length-22;la(s,a)!=101010256;--a)(!a||s.length-a>65558)&&Xt(13);var r=Aa(s,a+8);if(!r)return{};var i=la(s,a+16),n=i==4294967295||r==65535;if(n){var o=la(s,a-12);n=la(s,o)==101075792,n&&(r=la(s,o+32),i=la(s,o+48))}for(var l=0;l<r;++l){var c=W2(s,i,n),f=c[0],h=c[1],u=c[2],g=c[3],p=c[4],m=c[5],D=J2(s,m);i=p,f?f==8?t[g]=L2(s.subarray(D,D+h),{out:new Ot(u)}):Xt(14,"unknown compression type "+f):t[g]=Xs(s,D,D+h)}return t}class st extends ut{constructor(){super(),this.shader=new d.UnLitShader,this.baseMap=A.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 Cr extends Fe{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,a,r,i,n,o){super(),this.radius=e,this.widthSegments=t,this.heightSegments=a,this.phiStart=r,this.phiLength=i,this.thetaStart=n,this.thetaLength=o,this.buildGeometry()}buildGeometry(){var e,t,a=0;let r=this.heightSegments,i=this.widthSegments,n=this.radius;var o=(r+1)*(i+1);let l=new Float32Array(o*3),c=new Float32Array(o*3),f=new Float32Array(o*2),h=new Uint16Array(i*r*2*3),u=0,g=0,p=0;for(t=0;t<=r;++t){var m=Math.PI*t/r,D=n*Math.cos(m),_=n*Math.sin(m);for(e=0;e<=i;++e){var B=2*Math.PI*e/i,v=_*Math.cos(B),C=_*Math.sin(B),y=1/Math.sqrt(v*v+D*D+C*C);if(l[u++]=v,l[u++]=D,l[u++]=C,c[g++]=v*y,c[g++]=D*y,c[g++]=C*y,f[p++]=e/i,f[p++]=t/r,e>0&&t>0){var F=(i+1)*t+e,k=(i+1)*t+e-1,w=(i+1)*(t-1)+e-1,x=(i+1)*(t-1)+e;t==r?(h[a++]=F,h[a++]=w,h[a++]=x):t==1?(h[a++]=F,h[a++]=k,h[a++]=w):(h[a++]=F,h[a++]=k,h[a++]=w,h[a++]=F,h[a++]=w,h[a++]=x)}}}this.setIndices(h),this.setAttribute(V.position,l),this.setAttribute(V.normal,c),this.setAttribute(V.uv,f),this.setAttribute(V.TEXCOORD_1,f),this.addSubGeometry({indexStart:0,indexCount:h.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new ge(b.ZERO,new b(this.radius*2,this.radius*2,this.radius*2))}}class Fi extends d.Object3D{static register3DRepresentation=null;positionIndex=-1;positionValid=!1;marker;constructor(e){super(),this.parsePlacemark(e),this.setup3DRepresentation()}parsePlacemark(e){if(!e.slamPositionInfo){console.warn("WayPoint3D: slamPositionInfo is not found");return}const t=e.slamPositionInfo.slamPosition.split(",").map(Number);this.localPosition=new b(t[0],t[1],t[2]),this.positionIndex=Number(e.slamPositionInfo.slamPositionIndex),this.positionValid=e.slamPositionInfo.slamPositionValid==="1"}setup3DRepresentation(){if(this.marker&&(this.removeChild(this.marker),this.marker=null),Fi.register3DRepresentation)this.marker=Fi.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new d.Object3D;const e=this.marker.addComponent(d.MeshRenderer);e.geometry=new Cr(.1,32,16),e.material=new st,e.material.baseColor=this.positionValid?new O(0,1,0,1):new O(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class ki 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 Fi(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),ki.register3DRepresentation?(this.line=ki.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new O(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const a=new Fe,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(V.position,r),a.addSubGeometry({indexStart:0,indexCount:i.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const n=new d.Object3D,o=n.addComponent(d.MeshRenderer),l=new st;return l.topology="line-list",l.baseColor=t,l.blendMode=te.ADD,l.castReflection=!1,o.geometry=a,o.material=l,n}}class yf extends nt{static format=Ge.BIN;parseBuffer(e){try{const t={template:null,waylines:null},a=Z2(new Uint8Array(e));for(const i in a){const n=a[i],l=new DOMParser().parseFromString(vf(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 ki(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 Cf{_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 At().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 At;r==".gltf"?a=await i.load(e,Dt,t):a=await i.load(e,Qs,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 At;r==".obj"&&(a=await i.load(e,J0,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 At().load(e,zs,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 At().load(e,lf,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 La;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?me.getInstance().hasReference(t)?!1:(t.isDestroyed||t.destroy(),this._texturePool.delete(e),!0):!1}destroyTextureAllUnUsed(){for(const[e,t]of this._texturePool.entries())this.destroyTexture(e)}async loadTextureCount(e,t,a,r){return new Promise(async(i,n)=>{let o=0,l=[];t==0&&i(l);for(let c=0;c<t;c++){const f=e.shift();this.loadTexture(f,a,r).then(h=>{l.push(h),o++,o==t&&i(l)})}})}async loadBitmapTextures(e,t=5,a,r){let i=[],n=Math.floor(e.length/t)+1,o=Math.floor(e.length%t);for(let l=0;l<n;l++){let c=await this.loadTextureCount(e,l==n-1?o:t,a,r);i.push(...c)}return i}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let a=new Ns;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 gn;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 pn;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 Ts;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 Ts;return await a.loadStd(e),a}async loadJSON(e,t){return await new At().loadJson(e,t).then(async a=>a).catch(a=>{console.log(a)})}async loadFont(e,t,a){let i=await new At().load(e,za,t,a),n=i.data;return $r.addFontData(n.face,n.size,n),i.data}async loadAtlas(e,t){return(await new At().load(e,mf,t,e)).data}async loadKMZ(e,t){return(await new At().load(e,yf,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,a,r,i,n,o){let l=32,c=32,f=new Uint8Array(l*c*4);this.fillColor(f,e,t,a,r,i,n);let h=new ds;return h.name=o,h.create(16,16,f,!0),o&&this.addTexture(o,h),h}fillColor(e,t,a,r,i,n,o){for(let l=0;l<t;l++)for(let c=0;c<a;c++){let f=c*t+l;e[f*4+0]=r,e[f*4+1]=i,e[f*4+2]=n,e[f*4+3]=o}}initDefault(){this.normalTexture=this.createTexture(32,32,255*.5,255*.5,255,255,"default-normalTexture"),this.maskTexture=this.createTexture(32,32,255,255*.5,255,255,"default-maskTexture"),this.whiteTexture=this.createTexture(32,32,255,255,255,255,"default-whiteTexture"),this.blackTexture=this.createTexture(32,32,0,0,0,255,"default-blackTexture"),this.redTexture=this.createTexture(32,32,255,0,0,255,"default-redTexture"),this.blueTexture=this.createTexture(32,32,0,0,255,255,"default-blueTexture"),this.greenTexture=this.createTexture(32,32,0,255,0,255,"default-greenTexture"),this.yellowTexture=this.createTexture(32,32,0,255,255,255,"default-yellowTexture"),this.grayTexture=this.createTexture(32,32,128,128,128,255,"default-grayTexture");let t=new ff().generateBRDFLUTTexture(),a=t.name="BRDFLUT";this.addTexture(a,t),this.defaultSky=new gn,this.defaultSky.createFromTexture(128,this.blackTexture),me.getInstance().attached(this.defaultSky,this),me.getInstance().attached(t,this),me.getInstance().attached(this.normalTexture,this),me.getInstance().attached(this.maskTexture,this),me.getInstance().attached(this.whiteTexture,this),me.getInstance().attached(this.blackTexture,this),me.getInstance().attached(this.redTexture,this),me.getInstance().attached(this.blueTexture,this),me.getInstance().attached(this.greenTexture,this),me.getInstance().attached(this.yellowTexture,this),me.getInstance().attached(this.grayTexture,this),this.defaultGUITexture=new ir(this.whiteTexture),this.defaultGUISprite=new qr(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new pa}}class Sf extends Pe{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=A.getRenderJob(e);this._postList.forEach(a=>{t.addPost(a)})}unActivePost(){let e=this.transform.view3D,t=A.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;A.getRenderJob(a).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Y2="1.0.25";class A{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 E.presentationSize}static get aspect(){return E.aspect}static get width(){return E.windowWidth}static get height(){return E.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 O(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",Y2),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await be.init(R.allocCount,this.setting.doublePrecision),await E.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,oe.getGBufferFrame(oe.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),J.init(),Va.init(),le.init(),mt.init(),Et.init(),this.res=new Cf,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new No,this.inputSystem.initCanvas(E.canvas)}static startRenderJob(e){let t=new _0(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(Sf).addPost(_s),(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){xe.delta=e-xe.time,xe.time=e,xe.frame+=1,rr.tick(xe.delta);let t=this.views,a=0;for(a=0;a<t.length;a++){const n=t[a];n.scene.waitUpdate();let[o,l]=E.presentationSize;n.camera.viewPort.setTo(0,0,o,l)}this._beforeRender&&await this._beforeRender();for(const n of ye.componentsBeforeUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}let r=E.device.createCommandEncoder();for(const n of ye.componentsComputeList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o,r)}}E.device.queue.submit([r.finish()]);for(const n of ye.componentsUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}for(const n of ye.graphicComponent){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];o&&f.enable&&h(o)}}this._renderLoop&&await this._renderLoop(),be.updateAllContinueTransform(0,R.useCount,16),le.modelMatrixBindGroup.writeBuffer(R.useCount*16),this.renderJobs.forEach((n,o)=>{n.renderState||n.start(),n.renderFrame()});for(const n of ye.componentsLateUpdateList){let o=n[0],l=n[1];for(const c of l){let f=c[0],h=c[1];f.enable&&h(o)}}this._lateRender&&await this._lateRender()}}let An=`
7766
7766
  struct BloomCfg{
7767
7767
  downSampleStep: f32,
7768
7768
  downSampleBlurSize: f32,
@@ -11687,5 +11687,5 @@ fn frag(){
11687
11687
  textureStore(outputTexture, dstCoord, fromColor);
11688
11688
  }
11689
11689
  `;static _pipelineMax;static _pipelineMin;static createMipmap(e,t){const a=E.device;this._pipelineMax||=a.createComputePipeline({layout:"auto",compute:{module:a.createShaderModule({code:this.codeMax}),entryPoint:"main"}}),this._pipelineMin||=a.createComputePipeline({layout:"auto",compute:{module:a.createShaderModule({code:this.codeMin}),entryPoint:"main"}});let r=Math.ceil(e.width*.5),i=Math.ceil(e.height*.5),n={mipmapCount:t,texture:e,srcView:null,mipLevel:1,dstHeight:i,dstWidth:r};n.srcView=e.getGPUTexture().createView({format:e.format,dimension:"2d",baseMipLevel:0,mipLevelCount:1}),e.width>1024&&e.height>1024?this.mipmap(this._pipelineMax,n):this.mipmap(this._pipelineMin,n)}static mipmap(e,t){const a=E.device,r=S.beginCommandEncoder();let i=e==this._pipelineMax,n,o;for(let l=t.mipLevel;l<t.mipmapCount;l++){let c=[],f=0;c.push({binding:f++,resource:t.srcView}),c.push({binding:f++,resource:t.texture.gpuSampler}),n=t.texture.getGPUTexture().createView({format:t.texture.format,dimension:"2d",baseMipLevel:l,mipLevelCount:1}),c.push({binding:f++,resource:n});const h=a.createBindGroup({layout:e.getBindGroupLayout(0),entries:c}),u=r.beginComputePass();u.setPipeline(e),u.setBindGroup(0,h);let g=t.dstWidth,p=t.dstHeight;if(i&&(g=Math.max(1,Math.floor(t.dstWidth/8)),p=Math.max(1,Math.floor(t.dstHeight/8))),u.dispatchWorkgroups(g,p),t.dstHeight*=.5,t.dstWidth*=.5,t.srcView=n,t.mipLevel=l+1,o=i&&(t.dstWidth<8||t.dstHeight<8),u.end(),o)break}S.endCommandEncoder(r),o&&this.mipmap(this._pipelineMin,t)}}class Yd{name="";passMap=new Map}class Xd{passType="";shaderState=new Map;vertexShader="";fragmentShader=""}class hg{static passKeyword="pass";static shaderKeyword="Shader";static vertexKeyword="vertex";static fragmentKeyword="fragment";static passTypeKeyword="PassType";static parser(e,t){e=ta.filterComment(e);let a=new Yd,r=e.indexOf(this.shaderKeyword),i=e.indexOf("{",r),n=e.substring(r+this.shaderKeyword.length,i).trim();a.name=n.substring(1,n.length-1),n=e.substring(e.indexOf("{")+1,e.lastIndexOf("}"));let o=this.splitPassBlock(n);for(let l of o){let c=this.parserPassBlock(l),f;a.passMap.has(c.passType)?f=a.passMap.get(c.passType):(f=[],a.passMap.set(c.passType,f)),f.push(c),c.vertexShader.length>0&&(c.vertexShader=ta.parse(c.vertexShader,t)),c.fragmentShader.length>0&&(c.fragmentShader=ta.parse(c.fragmentShader,t))}return a}static splitPassBlock(e){let t=0,a=[];for(;t<e.length;){let r=e.indexOf(this.passKeyword,t);if(r==-1){a.push(e.substring(t));break}t!=0&&a.push(e.substring(t,r)),t=r+this.passKeyword.length}return a}static parserPassBlock(e){let t=new Xd,a=e.indexOf(this.passTypeKeyword),r=e.indexOf('"',a);return a=e.indexOf('"',r+1),t.passType=e.substring(a+1,r).trim(),this.parserShaderState(t,e),a=e.indexOf(this.vertexKeyword),a!=-1&&(t.vertexShader=this.extractBlock(e.substring(a+this.vertexKeyword.length),"{","}")),a=e.indexOf(this.fragmentKeyword),a!=-1&&(t.fragmentShader=this.extractBlock(e.substring(a+this.fragmentKeyword.length),"{","}")),t}static parserShaderState(e,t){let a=t.indexOf("ShaderState");if(a==-1)return!1;a=t.indexOf("{",a);let r=t.indexOf("}",a),n=t.substring(a+1,r).split(",");for(let o of n){let l=o.split(":"),c=l[0].trim(),f=this.convertValue(l[1].trim());e.shaderState.set(c,f)}return!0}static convertValue(e){return e.length==4&&e.toLowerCase()=="true"?!0:e.length==5&&e.toLowerCase()=="false"?!1:e[0]=='"'?e.substring(1,e.length-1):Number.parseInt(e)}static extractBlock(e,t,a){let r=e.indexOf(t);if(r==-1)return"";let i=0,n=0;e=e.substring(r);for(let l of e){if(l==t?i++:l==a&&i--,i<=0)break;n++}return e.substring(1,n).trim()}}let Hd=new qe("IrradianceDataReaderCompleteEvent");class Gi extends Ia{readFlag=!1;probeRenderer;opColorBuffer;opDepthBuffer;srcColorMap;srcDepthMap;opDepthArray;opColorArray;initReader(e,t,a){this.probeRenderer=e,this.srcColorMap=t,this.srcDepthMap=a;let r=A.setting.gi,i=r.octRTMaxSize*r.octRTMaxSize;this.opColorBuffer=E.device.createBuffer({size:i*4*4,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,mappedAtCreation:!1}),this.opColorArray=new Float32Array(i*4),this.opDepthBuffer=E.device.createBuffer({size:i*4*4,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,mappedAtCreation:!1}),this.opDepthArray=new Float32Array(i*4),this.probeRenderer.addEventListener(Bs.type,()=>{this.onProbeRenderComplete()},this),this.probeRenderer.addEventListener(cn.type,()=>{console.log("GIRenderStartEvent")},this)}async onProbeRenderComplete(){if(console.log("GIRenderCompleteEvent"),this.readFlag)console.log("irradianceDataReader is reading yet!!!");else{this.readFlag=!0;let e=Date.now();console.log("irradianceDataReader start reading "),await Gi.read(this.srcColorMap.getGPUTexture(),this.opColorBuffer,this.opColorArray),await Gi.read(this.srcDepthMap.getGPUTexture(),this.opDepthBuffer,this.opDepthArray),this.readFlag=!1,console.log("process time :",Date.now()-e),console.log("irradianceDataReader read complete"),this.dispatchEvent(Hd)}}static async read(e,t,a){let r=S.beginCommandEncoder();r.copyTextureToBuffer({texture:e},{buffer:t,bytesPerRow:e.width*16},[e.width,e.height]),S.endCommandEncoder(r),await t.mapAsync(GPUMapMode.READ);const i=t.getMappedRange();a.set(new Float32Array(i),0),t.unmap()}}let ug=new Gi;class bg{computeShader;visibleBuffer;texture;constructor(){this.computeShader=new fe(qf),this.visibleBuffer=new Kr(8192*2),this.computeShader.setStorageBuffer("visibleBuffer",this.visibleBuffer),this.texture=mt.getTexture(ga.zBufferTexture_NAME),this.computeShader.setSamplerTexture("zBufferTexture",this.texture),this.computeShader.workerSizeX=Math.ceil(this.texture.width/8),this.computeShader.workerSizeY=Math.ceil(this.texture.height/8),this.computeShader.workerSizeZ=1}compute(e,t){this.visibleBuffer.reset(!0,0),this.visibleBuffer.apply();let a=S.beginCommandEncoder();S.computeCommand(a,[this.computeShader]),this.visibleBuffer.readBuffer(),t.zVisibleList=this.visibleBuffer.outFloat32Array}}class gg extends Rt{RT_BloomUp;RT_BloomDown;RT_threshold;rendererPassState;thresholdCompute;downSampleComputes;upSampleComputes;postCompute;bloomSetting;rtFrame;constructor(){super()}onAttach(e){A.setting.render.postProcessing.bloom.enable=!0,this.createGUI()}onDetach(e){A.setting.render.postProcessing.bloom.enable=!1,this.removeGUI()}createGUI(){}removeGUI(){}get downSampleBlurSize(){return A.setting.render.postProcessing.bloom.downSampleBlurSize}set downSampleBlurSize(e){A.setting.render.postProcessing.bloom.downSampleBlurSize=e}get downSampleBlurSigma(){return A.setting.render.postProcessing.bloom.downSampleBlurSigma}set downSampleBlurSigma(e){A.setting.render.postProcessing.bloom.downSampleBlurSigma=e}get upSampleBlurSize(){return A.setting.render.postProcessing.bloom.upSampleBlurSize}set upSampleBlurSize(e){A.setting.render.postProcessing.bloom.upSampleBlurSize=e}get upSampleBlurSigma(){return A.setting.render.postProcessing.bloom.upSampleBlurSigma}set upSampleBlurSigma(e){A.setting.render.postProcessing.bloom.upSampleBlurSigma=e}get luminanceThreshole(){return A.setting.render.postProcessing.bloom.luminanceThreshole}set luminanceThreshole(e){A.setting.render.postProcessing.bloom.luminanceThreshole=e}get bloomIntensity(){return A.setting.render.postProcessing.bloom.bloomIntensity}set bloomIntensity(e){A.setting.render.postProcessing.bloom.bloomIntensity=e}get hdr(){return A.setting.render.postProcessing.bloom.hdr}set hdr(e){A.setting.render.postProcessing.bloom.hdr=e}createThreshouldCompute(){this.thresholdCompute=new fe(Ff),this.autoSetColorTexture("inTex",this.thresholdCompute),this.thresholdCompute.setStorageTexture("outTex",this.RT_threshold),this.thresholdCompute.setUniformBuffer("bloomCfg",this.bloomSetting),this.thresholdCompute.workerSizeX=Math.ceil(this.RT_threshold.width/8),this.thresholdCompute.workerSizeY=Math.ceil(this.RT_threshold.height/8),this.thresholdCompute.workerSizeZ=1}createDownSampleComputes(){const t=A.setting.render.postProcessing.bloom.downSampleStep;this.downSampleComputes=[];for(let a=0;a<t;a++){let r=new fe(kf),i=this.RT_BloomDown[a],n=a==0?this.RT_threshold:this.RT_BloomDown[a-1];r.setSamplerTexture("inTex",n),r.setStorageTexture("outTex",i),r.setUniformBuffer("bloomCfg",this.bloomSetting),r.workerSizeX=Math.ceil(i.width/8),r.workerSizeY=Math.ceil(i.height/8),r.workerSizeZ=1,this.downSampleComputes.push(r)}}createUpSampleComputes(){const t=A.setting.render.postProcessing.bloom.downSampleStep;this.upSampleComputes=[];{let a=new fe(eo),r=this.RT_BloomUp[0],i=this.RT_BloomDown[t-2];a.setSamplerTexture("_MainTex",i),a.setSamplerTexture("_PrevMip",this.RT_BloomDown[t-1]),a.setStorageTexture("outTex",r),a.setUniformBuffer("bloomCfg",this.bloomSetting),a.workerSizeX=Math.ceil(r.width/8),a.workerSizeY=Math.ceil(r.height/8),a.workerSizeZ=1,this.upSampleComputes.push(a)}for(let a=1;a<t-1;a++){let r=new fe(eo),i=this.RT_BloomUp[a],n=this.RT_BloomDown[t-2-a];r.setSamplerTexture("_MainTex",n),r.setSamplerTexture("_PrevMip",this.RT_BloomUp[a-1]),r.setStorageTexture("outTex",i),r.setUniformBuffer("bloomCfg",this.bloomSetting),r.workerSizeX=Math.ceil(i.width/8),r.workerSizeY=Math.ceil(i.height/8),r.workerSizeZ=1,this.upSampleComputes.push(r)}}createPostCompute(){const t=A.setting.render.postProcessing.bloom.downSampleStep;this.postCompute=new fe(Ef),this.autoSetColorTexture("_MainTex",this.postCompute),this.postCompute.setSamplerTexture("_BloomTex",this.RT_BloomUp[t-2]),this.postCompute.setStorageTexture("outTex",this.RT_threshold),this.postCompute.setUniformBuffer("bloomCfg",this.bloomSetting),this.postCompute.workerSizeX=Math.ceil(this.RT_threshold.width/8),this.postCompute.workerSizeY=Math.ceil(this.RT_threshold.height/8),this.postCompute.workerSizeZ=1}createResource(){let e=A.setting.render.postProcessing.bloom;this.bloomSetting=new ct(8);let[t,a]=E.presentationSize,r=GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING;this.RT_threshold=new pe(t,a,Y.rgba16float,!1,r);const i=e.downSampleStep;{this.RT_BloomDown=[];let o=Math.ceil(t/4),l=Math.ceil(a/4);for(let c=0;c<i;c++)this.RT_BloomDown[c]=new pe(o,l,Y.rgba16float,!1,r),o=Math.ceil(o/2),l=Math.ceil(l/2)}{this.RT_BloomUp=[];for(let o=0;o<i-1;o++){let l=this.RT_BloomDown[i-2-o].width,c=this.RT_BloomDown[i-2-o].height;this.RT_BloomUp[o]=new pe(l,c,Y.rgba16float,!1,r)}}let n=new ke;n.loadOp="load",this.rtFrame=new Je([this.RT_threshold],[n])}render(e,t){this.thresholdCompute||(this.createResource(),this.createThreshouldCompute(),this.createDownSampleComputes(),this.createUpSampleComputes(),this.createPostCompute(),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null),this.rendererPassState.label="Bloom");let a=A.setting.render.postProcessing.bloom;this.bloomSetting.setFloat("downSampleStep",a.downSampleStep),this.bloomSetting.setFloat("downSampleBlurSize",a.downSampleBlurSize),this.bloomSetting.setFloat("downSampleBlurSigma",a.downSampleBlurSigma),this.bloomSetting.setFloat("upSampleBlurSize",a.upSampleBlurSize),this.bloomSetting.setFloat("upSampleBlurSigma",a.upSampleBlurSigma),this.bloomSetting.setFloat("luminanceThreshole",a.luminanceThreshole),this.bloomSetting.setFloat("bloomIntensity",a.bloomIntensity),this.bloomSetting.setFloat("hdr",a.hdr),this.bloomSetting.apply(),S.computeCommand(t,[this.thresholdCompute,...this.downSampleComputes,...this.upSampleComputes,this.postCompute]),S.lastRenderPassState=this.rendererPassState}onResize(){let e=A.setting.render.postProcessing.bloom,[t,a]=E.presentationSize;this.RT_threshold.resize(t,a);const r=e.downSampleStep;let i=Math.ceil(t/4),n=Math.ceil(a/4);for(let o=0;o<r;o++)this.RT_BloomDown[o].resize(i,n),i=Math.ceil(i/2),n=Math.ceil(n/2);for(let o=0;o<r-1;o++){let l=this.RT_BloomDown[r-2-o].width,c=this.RT_BloomDown[r-2-o].height;this.RT_BloomUp[o].resize(l,c)}this.thresholdCompute.workerSizeX=Math.ceil(this.RT_threshold.width/8),this.thresholdCompute.workerSizeY=Math.ceil(this.RT_threshold.height/8),this.thresholdCompute.workerSizeZ=1;for(let o=0;o<r;o++){let l=this.downSampleComputes[o],c=this.RT_BloomDown[o];l.workerSizeX=Math.ceil(c.width/8),l.workerSizeY=Math.ceil(c.height/8),l.workerSizeZ=1}{let o=this.RT_BloomUp[0],l=this.upSampleComputes[0];l.workerSizeX=Math.ceil(o.width/8),l.workerSizeY=Math.ceil(o.height/8),l.workerSizeZ=1}for(let o=1;o<r-1;o++){let l=this.RT_BloomUp[o],c=this.upSampleComputes[o];c.workerSizeX=Math.ceil(l.width/8),c.workerSizeY=Math.ceil(l.height/8),c.workerSizeZ=1}this.postCompute.workerSizeX=Math.ceil(this.RT_threshold.width/8),this.postCompute.workerSizeY=Math.ceil(this.RT_threshold.height/8),this.postCompute.workerSizeZ=1}}class mg extends Rt{blurTexture1;blurTexture2;rendererPassState;blurComputes;blurSettings;outTexture;rtFrame;constructor(){super()}onAttach(e){A.setting.render.postProcessing.depthOfView.enable=!0}onDetach(e){A.setting.render.postProcessing.depthOfView.enable=!1}get pixelOffset(){return A.setting.render.postProcessing.depthOfView.pixelOffset}set pixelOffset(e){e=Math.max(0,e);let t=A.setting.render.postProcessing.depthOfView;t.pixelOffset=e}get near(){return A.setting.render.postProcessing.depthOfView.near}set near(e){e=Math.max(0,e);let t=A.setting.render.postProcessing.depthOfView;t.near=e}get far(){return A.setting.render.postProcessing.depthOfView.far}set far(e){e=Math.max(0,e);let t=A.setting.render.postProcessing.depthOfView;t.far=e}createBlurCompute(){this.blurSettings=[],this.blurComputes=[];let e=A.setting.render.postProcessing.depthOfView;for(let t=0;t<e.iterationCount;t++){let a=new ct(4),r=new fe(Rf);this.blurComputes.push(r),this.blurSettings.push(a),r.setUniformBuffer("blurSetting",a);let i=oe.getGBufferFrame(oe.colorPass_GBuffer);r.setSamplerTexture("gBufferTexture",i.getCompressGBufferTexture());let n=t%2==0?this.blurTexture1:this.blurTexture2,o=t%2==1?this.blurTexture1:this.blurTexture2;r.setSamplerTexture("inTex",n),r.setStorageTexture("outTex",o),r.workerSizeX=Math.ceil(this.blurTexture1.width/8),r.workerSizeY=Math.ceil(this.blurTexture1.height/8),r.workerSizeZ=1,this.outTexture=o}}createResource(){let e=E.presentationSize,t=e[0],a=e[1];this.blurTexture1=new pe(t,a,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.blurTexture1.name="dof1";let r=new ke;r.clearValue=[0,0,0,1],r.loadOp="clear",this.blurTexture2=new pe(t,a,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.blurTexture2.name="dof2";let i=new ke;i.clearValue=[0,0,0,1],i.loadOp="clear",this.rtFrame=new Je([this.blurTexture1,this.blurTexture2],[r,i])}render(e,t){if(!this.blurComputes){this.createResource(),this.createBlurCompute();let r=le.getCameraGroup(e.camera);for(let i=0;i<this.blurComputes.length;i++)this.blurComputes[i].setUniformBuffer("globalUniform",r.uniformGPUBuffer);this.rendererPassState=Re.createRendererPassState(this.rtFrame,null)}this.autoSetColorTexture("inTex",this.blurComputes[0]);let a=A.setting.render.postProcessing.depthOfView;a.far=Math.max(a.near,a.far)+1e-4;for(let r=0;r<a.iterationCount;r++){let i=this.blurComputes[r],n=this.blurSettings[r];n.setFloat("near",a.near),n.setFloat("far",a.far),n.setFloat("pixelOffset",(r+1)*a.pixelOffset),n.apply(),i.setStorageBuffer("blurSetting",n)}S.computeCommand(t,this.blurComputes),S.lastRenderPassState=this.rendererPassState}onResize(){let e=E.presentationSize,t=e[0],a=e[1],r=A.setting.render.postProcessing.depthOfView;r.far=Math.max(r.near,r.far)+1e-4,this.blurTexture1.resize(t,a),this.blurTexture2.resize(t,a);for(let i=0;i<r.iterationCount;i++){let n=this.blurComputes[i];n.workerSizeX=Math.ceil(this.blurTexture1.width/8),n.workerSizeY=Math.ceil(this.blurTexture1.height/8),n.workerSizeZ=1}}}class pg extends Rt{outTexture;rendererPassState;rtFrame;view;gBufferTexture;testCompute;_state=0;_state1=256;_state2=256;uniformBuffer;currentRenderTexture;constructor(){super()}onAttach(e){this.view=e}onDetach(e){}set state(e){this._state=e,this.uniformBuffer.setInt32("state",e),this.uniformBuffer.apply()}get state(){return this._state}set size1(e){this._state1=e,this.uniformBuffer.setInt32("state1",e),this.uniformBuffer.apply()}get size1(){return this._state1}set size2(e){this._state2=e,this.uniformBuffer.setInt32("state2",e),this.uniformBuffer.apply()}get size2(){return this._state2}createResource(){let e=oe.getGBufferFrame("ColorPassGBuffer");this.currentRenderTexture=e.getColorTexture(),this.gBufferTexture=e.getCompressGBufferTexture();let[t,a]=E.presentationSize;this.outTexture=new pe(t,a,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.outTexture.name="outTexture";let r=new ke;r.loadOp="load",this.rtFrame=new Je([this.outTexture],[r])}createCompute(){this.uniformBuffer=new ct(4),this.uniformBuffer.setInt32("state",this._state);let e=le.getCameraGroup(this.view.camera),a=oe.getGBufferFrame("ColorPassGBuffer").getCompressGBufferTexture(),r=A.setting.reflectionSetting,n=oe.getGBufferFrame(oe.reflections_GBuffer,r.width,r.height).getCompressGBufferTexture(),o=A.renderJobs.get(this.view).reflectionRenderer.outTexture;this.testCompute=new fe(Xf),this.testCompute.setUniformBuffer("globalUniform",e.uniformGPUBuffer),this.testCompute.setUniformBuffer("uniformData",this.uniformBuffer),this.testCompute.setSamplerTexture("gBufferTexture",a),this.testCompute.setSamplerTexture("currentRenderTexture",this.currentRenderTexture),this.testCompute.setSamplerTexture("reflectionsGBufferTexture",n),this.testCompute.setSamplerTexture("envMap",o),this.testCompute.setStorageTexture("outputTexture",this.outTexture),this.testCompute.workerSizeX=Math.ceil(this.outTexture.width/16),this.testCompute.workerSizeY=Math.ceil(this.outTexture.height/16),this.testCompute.workerSizeZ=1}render(e,t){}compute(e){this.testCompute||(this.createResource(),this.createCompute(),this.onResize(),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null),this.rendererPassState.label="test");let t=S.beginCommandEncoder();S.computeCommand(t,[this.testCompute]),S.endCommandEncoder(t),S.lastRenderPassState=this.rendererPassState}onResize(){let[e,t]=E.presentationSize;this.outTexture.resize(e,t),this.testCompute.workerSizeX=Math.ceil(this.outTexture.width/16),this.testCompute.workerSizeY=Math.ceil(this.outTexture.height/16)}}class Ag extends Rt{gtaoTexture;rendererPassState;gtaoCompute;gtaoSetting;aoBuffer;directionsBuffer;directionsArray;rtFrame;constructor(){super()}onAttach(e){A.setting.render.postProcessing.gtao.enable=!0}Render;onDetach(e){A.setting.render.postProcessing.gtao.enable=!1}get maxDistance(){return A.setting.render.postProcessing.gtao.maxDistance}set maxDistance(e){e=ie(e,.1,50);let t=A.setting.render.postProcessing.gtao;t.maxDistance=e}get maxPixel(){return A.setting.render.postProcessing.gtao.maxPixel}set maxPixel(e){e=ie(e,5,100);let t=A.setting.render.postProcessing.gtao;t.maxPixel=e}get darkFactor(){return A.setting.render.postProcessing.gtao.darkFactor}set darkFactor(e){e=ie(e,.01,1);let t=A.setting.render.postProcessing.gtao;t.darkFactor=e}get rayMarchSegment(){return A.setting.render.postProcessing.gtao.rayMarchSegment}set rayMarchSegment(e){e=ie(e,4,10);let t=A.setting.render.postProcessing.gtao;t.rayMarchSegment=e}get multiBounce(){return A.setting.render.postProcessing.gtao.multiBounce}set multiBounce(e){let t=A.setting.render.postProcessing.gtao;t.multiBounce=e}get blendColor(){return A.setting.render.postProcessing.gtao.blendColor}set blendColor(e){let t=A.setting.render.postProcessing.gtao;t.blendColor=e}get usePosFloat32(){return A.setting.render.postProcessing.gtao.usePosFloat32}set usePosFloat32(e){let t=A.setting.render.postProcessing.gtao;t.usePosFloat32=e}createCompute(){this.gtaoCompute=new fe(wf);let e=new ct(8);this.gtaoCompute.setUniformBuffer("gtaoData",e),this.directionsArray=new Float32Array(16),this.directionsBuffer=new _e(16),this.directionsBuffer.setFloat32Array("array",this.randomDirection()),this.directionsBuffer.apply(),this.gtaoCompute.setStorageBuffer("directions",this.directionsBuffer),this.aoBuffer=new _e(this.gtaoTexture.width*this.gtaoTexture.height),this.gtaoCompute.setStorageBuffer("aoBuffer",this.aoBuffer);let t=oe.getGBufferFrame(oe.colorPass_GBuffer);this.gtaoCompute.setSamplerTexture("gBufferTexture",t.getCompressGBufferTexture()),this.autoSetColorTexture("inTex",this.gtaoCompute),this.gtaoCompute.setStorageTexture("outTex",this.gtaoTexture),this.gtaoSetting=e}createResource(){let[e,t]=E.presentationSize;this.gtaoTexture=new pe(e,t,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.gtaoTexture.name="gtaoTex";let a=new ke;a.loadOp="load",this.rtFrame=new Je([this.gtaoTexture],[a])}randomCount=0;randomDirection(){this.randomCount=0;let e=Math.PI*2*this.randomCount/16,t=Math.PI*2/8;for(let a=0;a<8;a++){let r=e+a*t;this.directionsArray[a*2]=Math.sin(r),this.directionsArray[a*2+1]=Math.cos(r)}return this.directionsArray}render(e,t){if(!this.gtaoCompute){this.createResource(),this.createCompute(),this.onResize(),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null),this.rendererPassState.label="GTAO";let l=le.getCameraGroup(e.camera);this.gtaoCompute.setUniformBuffer("globalUniform",l.uniformGPUBuffer)}let a=A.setting.render.postProcessing.gtao;this.directionsBuffer.setFloat32Array("array",this.randomDirection()),this.directionsBuffer.apply();let r=1-.2*(xe.frame%2),i=a.maxDistance*r,n=a.maxPixel*r;this.gtaoSetting.setFloat("maxDistance",i),this.gtaoSetting.setFloat("maxPixel",n),this.gtaoSetting.setFloat("darkFactor",a.darkFactor),this.gtaoSetting.setFloat("rayMarchSegment",a.rayMarchSegment);let o=e.camera;this.gtaoSetting.setFloat("cameraNear",o.near),this.gtaoSetting.setFloat("cameraFar",o.far),this.gtaoSetting.setFloat("multiBounce",a.multiBounce?1:0),this.gtaoSetting.setFloat("blendColor",a.blendColor?1:0),this.gtaoSetting.apply(),S.computeCommand(t,[this.gtaoCompute]),S.lastRenderPassState=this.rendererPassState}onResize(){let[e,t]=E.presentationSize;this.gtaoTexture.resize(e,t),this.gtaoCompute.workerSizeX=Math.ceil(this.gtaoTexture.width/8),this.gtaoCompute.workerSizeY=Math.ceil(this.gtaoTexture.height/8),this.gtaoCompute.workerSizeZ=1}}class Dg extends Rt{fogSetting;fogOpTexture;fogCompute;fogUniform;rendererPassState;constructor(){super(),this.fogSetting=A.setting.render.postProcessing.globalFog}createCompute(e){J.register("GlobalFog_shader",to),this.fogCompute=new fe(to),this.fogUniform=new ct(20),this.fogCompute.setUniformBuffer("fogUniform",this.fogUniform);let t=oe.getGBufferFrame(oe.colorPass_GBuffer);this.fogCompute.setSamplerTexture("gBufferTexture",t.getCompressGBufferTexture()),this.fogCompute.setSamplerTexture("inTex",t.getColorTexture()),this._lastSkyTexture=this.getSkyTexture(),this.fogCompute.setSamplerTexture("prefilterMap",this._lastSkyTexture),this.fogCompute.setStorageTexture("outTex",this.fogOpTexture),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null),this.rendererPassState.label="FOG";let a=le.getLightEntries(e.scene);this.fogCompute.setStorageBuffer("lightBuffer",a.storageGPUBuffer)}uploadSetting(){let e=this.fogUniform,t=this.fogSetting;e.setColor("fogColor",t.fogColor),e.setFloat("fogType",t.fogType),e.setFloat("fogHeightScale",t.fogHeightScale),e.setFloat("start",t.start),e.setFloat("end",t.end),e.setFloat("density",t.density),e.setFloat("ins",t.ins),e.setFloat("falloff",t.falloff),e.setFloat("rayLength",t.rayLength),e.setFloat("scatteringExponent",t.scatteringExponent),e.setFloat("dirHeightLine",t.dirHeightLine),e.setFloat("skyFactor",t.skyFactor),e.setFloat("skyRoughness",t.skyRoughness),e.setFloat("overrideSkyFactor",t.overrideSkyFactor),e.setFloat("isSkyHDR",0),e.apply(),this.fogCompute.setUniformBuffer("fogUniform",this.fogUniform)}rtFrame;createResource(){let[e,t]=E.presentationSize;this.fogOpTexture=new pe(e,t,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.fogOpTexture.name="fogTex";let a=new ke;a.loadOp="load",this.rtFrame=new Je([this.fogOpTexture],[a])}onAttach(e){A.setting.render.postProcessing.globalFog.enable=!0}onDetach(e){A.setting.render.postProcessing.globalFog.enable=!1}set fogType(e){this.fogSetting.fogType=e}get fogType(){return this.fogSetting.fogType}set fogHeightScale(e){this.fogSetting.fogHeightScale=e}get fogHeightScale(){return this.fogSetting.fogHeightScale}set start(e){this.fogSetting.start=e}get start(){return this.fogSetting.start}set end(e){this.fogSetting.end=e}get end(){return this.fogSetting.end}set ins(e){this.fogSetting.ins=e}get ins(){return this.fogSetting.ins}set density(e){this.fogSetting.density=e}get density(){return this.fogSetting.density}set skyRoughness(e){this.fogSetting.skyRoughness=e}get skyRoughness(){return this.fogSetting.skyRoughness}set skyFactor(e){this.fogSetting.skyFactor=e}get skyFactor(){return this.fogSetting.skyFactor}set overrideSkyFactor(e){this.fogSetting.overrideSkyFactor=e}get overrideSkyFactor(){return this.fogSetting.overrideSkyFactor}get fogColor(){return this.fogSetting.fogColor}set fogColor(e){this.fogSetting.fogColor.copyFrom(e)}set falloff(e){this.fogSetting.falloff=e}get falloff(){return this.fogSetting.falloff}set rayLength(e){this.fogSetting.rayLength=e}get rayLength(){return this.fogSetting.rayLength}set scatteringExponent(e){this.fogSetting.scatteringExponent=e}get scatteringExponent(){return this.fogSetting.scatteringExponent}set dirHeightLine(e){this.fogSetting.dirHeightLine=e}get dirHeightLine(){return this.fogSetting.dirHeightLine}_lastSkyTexture;getSkyTexture(){let e=A.res.defaultSky;return W.instance.sky instanceof Dn&&(e=W.instance.sky.map),e}render(e,t){if(!this.fogCompute){this.createResource(),this.createCompute(e),this.onResize();let r=le.getCameraGroup(e.camera);this.fogCompute.setUniformBuffer("globalUniform",r.uniformGPUBuffer)}let a=this.getSkyTexture();a!=this._lastSkyTexture&&(this._lastSkyTexture=a,this.fogCompute.setSamplerTexture("prefilterMap",this._lastSkyTexture)),this.fogCompute.setUniformFloat("isSkyHDR",a.isHDRTexture?1:0),this.uploadSetting(),S.computeCommand(t,[this.fogCompute]),S.lastRenderPassState=this.rendererPassState}onResize(){let[e,t]=E.presentationSize;this.fogOpTexture.resize(e,t),this.fogCompute.workerSizeX=Math.ceil(this.fogOpTexture.width/8),this.fogCompute.workerSizeY=Math.ceil(this.fogOpTexture.height/8),this.fogCompute.workerSizeZ=1}}class _g extends Rt{godRayTexture;rendererPassState;godRayCompute;historyGodRayData;godRaySetting;rtFrame;constructor(){super()}onAttach(e){A.setting.render.postProcessing.godRay.enable=!0,this.createGUI()}Render;onDetach(e){A.setting.render.postProcessing.godRay.enable=!1,this.removeGUI()}get blendColor(){return A.setting.render.postProcessing.godRay.blendColor}set blendColor(e){A.setting.render.postProcessing.godRay.blendColor=e}get rayMarchCount(){return A.setting.render.postProcessing.godRay.rayMarchCount}set rayMarchCount(e){e=ie(e,8,20),A.setting.render.postProcessing.godRay.rayMarchCount=e}get scatteringExponent(){return A.setting.render.postProcessing.godRay.scatteringExponent}set scatteringExponent(e){e=ie(e,1,40),A.setting.render.postProcessing.godRay.scatteringExponent=e}get intensity(){return A.setting.render.postProcessing.godRay.intensity}set intensity(e){e=ie(e,.01,5),A.setting.render.postProcessing.godRay.intensity=e}createGUI(){}removeGUI(){}createCompute(e){this.godRayCompute=new fe(If);let t=new ct(12);this.godRayCompute.setUniformBuffer("godRayUniform",t),this.historyGodRayData=new _e(4*this.godRayTexture.width*this.godRayTexture.height),this.godRayCompute.setStorageBuffer("historyGodRayData",this.historyGodRayData);let a=oe.getGBufferFrame(oe.colorPass_GBuffer);this.godRayCompute.setSamplerTexture("gBufferTexture",a.getCompressGBufferTexture()),this.autoSetColorTexture("inTex",this.godRayCompute),this.godRayCompute.setStorageTexture("outTex",this.godRayTexture);let r=A.getRenderJob(e).shadowMapPassRenderer;this.godRayCompute.setSamplerTexture("shadowMap",r.depth2DArrayTexture),this.godRaySetting=t,this.onResize()}createResource(){let e=E.presentationSize,[t,a]=e;this.godRayTexture=new pe(t,a,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.godRayTexture.name="godRayTexture";let r=new ke;r.loadOp="load",this.rtFrame=new Je([this.godRayTexture],[r])}onResize(){let e=E.presentationSize,[t,a]=e;this.godRayTexture.resize(t,a),this.historyGodRayData.resizeBuffer(4*this.godRayTexture.width*this.godRayTexture.height),this.godRayCompute.setStorageBuffer("historyGodRayData",this.historyGodRayData),this.godRayCompute.workerSizeX=Math.ceil(this.godRayTexture.width/8),this.godRayCompute.workerSizeY=Math.ceil(this.godRayTexture.height/8),this.godRayCompute.workerSizeZ=1}render(e,t){if(!this.godRayCompute){this.createResource(),this.createCompute(e);let o=le.getLightEntries(e.scene);this.godRayCompute.setStorageBuffer("lightBuffer",o.storageGPUBuffer),this.godRayCompute.setStorageBuffer("models",le.modelMatrixBindGroup.matrixBufferDst),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null),this.rendererPassState.label="GodRay";let l=le.getCameraGroup(e.camera);this.godRayCompute.setUniformBuffer("globalUniform",l.uniformGPUBuffer)}let a=A.setting.render.postProcessing.godRay;this.godRaySetting.setFloat("intensity",a.intensity),this.godRaySetting.setFloat("rayMarchCount",a.rayMarchCount);let r=E.presentationSize,[i,n]=r;this.godRaySetting.setFloat("viewPortWidth",i),this.godRaySetting.setFloat("viewPortHeight",n),this.godRaySetting.setFloat("blendColor",a.blendColor?1:0),this.godRaySetting.setFloat("scatteringExponent",a.scatteringExponent),this.godRaySetting.apply(),S.computeCommand(t,[this.godRayCompute]),S.lastRenderPassState=this.rendererPassState}}class Kd{indexList;color;count}class qd{SlotCount=8;MaxEntities=16;defaultColor=new O(.2,1,1,1);slots=[];dataDirty=!0;constructor(){let e=A.setting.render.postProcessing.outline.groupCount;this.SlotCount=Math.max(1,Math.min(e,this.SlotCount));for(let t=0;t<this.SlotCount;t++){let a=this.slots[t]=new Kd;a.indexList=new Float32Array(this.MaxEntities),a.color=this.defaultColor.clone(),a.count=0}}clear(){for(let e=0;e<this.SlotCount;e++)this.clearAt(e)}clearAt(e){this.dataDirty=!0;let t=this.slots[e];return t.color.copyFrom(this.defaultColor),t.indexList.fill(-1),t.count=0,this}fillDataAt(e,t,a){this.dataDirty=!0;let r=this.slots[e];if(r){r.indexList.fill(-1);for(let i=0,n=t.length;i<n;i++)r.indexList[i]=t[i];r.count=t.length,r.color.copyFrom(a)}return this}fetchData(e){return e.dirty=this.dataDirty,e.slots=this.slots,this.dataDirty=!1,this}}let ca=new qd;class Bg extends Rt{outlineTex;lowTex;rendererPassState;calcWeightCompute;outlineCompute;blendCompute;outlineSetting;slotsBuffer;slotsArray;entitiesArray;entitiesBuffer;weightBuffer;lowTexSize;oldOutlineColor;rtFrame;view;constructor(){super()}onAttach(e){this.view=e,A.setting.render.postProcessing.outline.enable=!0}onDetach(e){A.setting.render.postProcessing.outline.enable=!1}set outlinePixel(e){e=ie(e,0,8);let t=A.setting.render.postProcessing.outline;t.outlinePixel!=e&&(t.outlinePixel=e)}get outlinePixel(){return A.setting.render.postProcessing.outline.outlinePixel}set fadeOutlinePixel(e){let t=A.setting.render.postProcessing.outline;e=ie(e,0,8),t.fadeOutlinePixel!=e&&(t.fadeOutlinePixel=e)}get fadeOutlinePixel(){return A.setting.render.postProcessing.outline.fadeOutlinePixel}set strength(e){e=ie(e,0,1);let t=A.setting.render.postProcessing.outline;t.strength!=e&&(t.strength=e)}get strength(){return A.setting.render.postProcessing.outline.strength}set useAddMode(e){A.setting.render.postProcessing.outline.useAddMode=e}get useAddMode(){return A.setting.render.postProcessing.outline.useAddMode}createGUI(){}createCompute(){let e=oe.getGBufferFrame(oe.colorPass_GBuffer);this.calcWeightCompute=new fe(Mf);let t=le.getCameraGroup(this.view.camera);this.calcWeightCompute.setUniformBuffer("globalUniform",t.uniformGPUBuffer),this.calcWeightCompute.setStorageBuffer("outlineSetting",this.outlineSetting),this.calcWeightCompute.setStorageBuffer("slotsBuffer",this.slotsBuffer),this.calcWeightCompute.setStorageBuffer("weightBuffer",this.weightBuffer),this.calcWeightCompute.setStorageBuffer("entitiesBuffer",this.entitiesBuffer),this.calcWeightCompute.setSamplerTexture("gBufferTexture",e.getCompressGBufferTexture()),this.calcWeightCompute.workerSizeX=Math.ceil(this.lowTex.width/8),this.calcWeightCompute.workerSizeY=Math.ceil(this.lowTex.height/8),this.calcWeightCompute.workerSizeZ=1,this.outlineCompute=new fe(Nf),this.outlineCompute.setStorageBuffer("outlineSetting",this.outlineSetting),this.outlineCompute.setStorageBuffer("slotsBuffer",this.slotsBuffer),this.outlineCompute.setStorageBuffer("weightBuffer",this.weightBuffer),this.outlineCompute.setStorageBuffer("oldOutlineColor",this.oldOutlineColor),this.outlineCompute.setStorageTexture("lowTex",this.lowTex),this.outlineCompute.workerSizeX=Math.ceil(this.lowTex.width/8),this.outlineCompute.workerSizeY=Math.ceil(this.lowTex.height/8),this.outlineCompute.workerSizeZ=1,this.blendCompute=new fe(Tf),this.blendCompute.setStorageBuffer("outlineSetting",this.outlineSetting),this.autoSetColorTexture("inTex",this.blendCompute),this.blendCompute.setSamplerTexture("lowTex",this.lowTex),this.blendCompute.setStorageTexture("outlineTex",this.outlineTex),this.blendCompute.workerSizeX=Math.ceil(this.outlineTex.width/8),this.blendCompute.workerSizeY=Math.ceil(this.outlineTex.height/8),this.blendCompute.workerSizeZ=1}createResource(){let e=E.presentationSize,t=e[0],a=e[1],r=A.setting.render.postProcessing.outline.textureScale;this.lowTexSize=new K(Math.ceil(t*r),Math.ceil(a*r)),this.lowTex=new pe(this.lowTexSize.x,this.lowTexSize.y,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.lowTex.name="lowTex";let i=new ke;i.clearValue=[0,0,0,1],i.loadOp="clear",this.outlineTex=new pe(t,a,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.outlineTex.name="outlineTex";let n=new ke;n.clearValue=[0,0,0,1],n.loadOp="clear",this.rtFrame=new Je([this.outlineTex],[n]),this.outlineSetting=new ct(8),this.weightBuffer=new _e(this.lowTexSize.x*this.lowTexSize.y*4,GPUBufferUsage.COPY_SRC),this.oldOutlineColor=new _e(this.lowTexSize.x*this.lowTexSize.y*4,GPUBufferUsage.COPY_SRC),this.slotsArray=new Float32Array(ca.SlotCount*4),this.slotsBuffer=new _e(this.slotsArray.length),this.slotsBuffer.setFloat32Array("slotsArray",this.slotsArray),this.slotsBuffer.apply(),this.entitiesArray=new Float32Array(ca.SlotCount*ca.MaxEntities),this.entitiesBuffer=new _e(this.entitiesArray.length),this.entitiesBuffer.setFloat32Array("entitiesArray",this.entitiesArray),this.slotsBuffer.apply(),this.fetchData||={}}fetchData;fetchOutlineData(){if(ca.fetchData(this.fetchData),this.fetchData.dirty){let e=ca.SlotCount,t=ca.MaxEntities;for(let a=0;a<e;a++){let r=4*a,i=this.fetchData.slots[a];this.slotsArray[r+0]=i.color.r,this.slotsArray[r+1]=i.color.g,this.slotsArray[r+2]=i.color.b,this.slotsArray[r+3]=i.count,r=t*a,this.entitiesArray.set(i.indexList,r)}this.slotsBuffer.setFloat32Array("slotsArray",this.slotsArray),this.slotsBuffer.apply(),this.entitiesBuffer.setFloat32Array("entitiesArray",this.entitiesArray),this.entitiesBuffer.apply()}}computeList;render(e,t){this.calcWeightCompute||(this.createResource(),this.createCompute(),this.createGUI(),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null)),this.computeList||=[this.calcWeightCompute,this.outlineCompute,this.blendCompute];let a=A.setting.render.postProcessing.outline;this.outlineSetting.setFloat("strength",a.strength),this.outlineSetting.setFloat("useAddMode",a.useAddMode?1:0),this.outlineSetting.setFloat("outlinePixel",a.outlinePixel),this.outlineSetting.setFloat("fadeOutlinePixel",a.fadeOutlinePixel),this.outlineSetting.setFloat("lowTexWidth",this.lowTexSize.x),this.outlineSetting.setFloat("lowTexHeight",this.lowTexSize.y),this.outlineSetting.apply(),this.fetchOutlineData(),S.computeCommand(t,this.computeList),S.lastRenderPassState=this.rendererPassState}onResize(){let e=E.presentationSize,t=e[0],a=e[1],r=A.setting.render.postProcessing.outline.textureScale;this.lowTexSize=new K(Math.ceil(t*r),Math.ceil(a*r)),this.lowTex.resize(this.lowTexSize.x,this.lowTexSize.y),this.outlineTex.resize(t,a),this.weightBuffer.resizeBuffer(this.lowTexSize.x*this.lowTexSize.y*4),this.oldOutlineColor.resizeBuffer(this.lowTexSize.x*this.lowTexSize.y*4),this.calcWeightCompute.workerSizeX=Math.ceil(this.lowTex.width/8),this.calcWeightCompute.workerSizeY=Math.ceil(this.lowTex.height/8),this.calcWeightCompute.workerSizeZ=1,this.outlineCompute.workerSizeX=Math.ceil(this.lowTex.width/8),this.outlineCompute.workerSizeY=Math.ceil(this.lowTex.height/8),this.outlineCompute.workerSizeZ=1,this.blendCompute.workerSizeX=Math.ceil(this.outlineTex.width/8),this.blendCompute.workerSizeY=Math.ceil(this.outlineTex.height/8),this.blendCompute.workerSizeZ=1}}class Ug extends Rt{outTexture;newTexture;oldTexture;combineTexture;rendererPassState;ssgiCompute;delayCompute;combineCompute;rtFrame;textureScaleSmallCompute;textureScaleBigCompute;view;colorTexture;posTexture;normalTexture;gBufferTexture;lastPosTexture;downSampleCofe=1;debugChanal="0";updateBuffer;constructor(){super(),this.updateBuffer=new _e(32),this.updateBuffer.setFloat("frameCount",10),this.updateBuffer.setFloat("indirectIns",1.5),this.updateBuffer.setFloat("delay",.02),this.updateBuffer.setFloat("colorIns",1),this.updateBuffer.setFloat("d1",.03),this.updateBuffer.apply()}onAttach(e){this.view=e,e.camera.transform.onPositionChange=e.camera.transform.onPositionChange?Ki(e.camera.transform.onPositionChange,(t,a)=>this.onCameraChange(t,a)):(t,a)=>this.onCameraChange(t,a)}onCameraChange(e,t){console.log("a");let a=b.distance(e,t);a=Math.min(.45,a)+.01,this.updateBuffer.setFloat("delay",a)}Render;onDetach(e){}set ins(e){this.updateBuffer.setFloat("indirectIns",e),this.updateBuffer.apply()}get ins(){return this.updateBuffer.getFloat("indirectIns")}set delay(e){this.updateBuffer.setFloat("delay",e),this.updateBuffer.apply()}get delay(){return this.updateBuffer.getFloat("delay")}set colorIns(e){this.updateBuffer.setFloat("colorIns",e),this.updateBuffer.apply()}get colorIns(){return this.updateBuffer.getFloat("colorIns")}set frameCount(e){this.updateBuffer.setFloat("frameCount",e),this.updateBuffer.apply()}get frameCount(){return this.updateBuffer.getFloat("frameCount")}set d1(e){this.updateBuffer.setFloat("d1",e),this.updateBuffer.apply()}get d1(){return this.updateBuffer.getFloat("d1")}createResource(){let e=oe.getGBufferFrame("ColorPassGBuffer");this.gBufferTexture=e.getCompressGBufferTexture();let t=E.presentationSize,a=t[0],r=t[1];this.lastPosTexture=new pe(a,r,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.lastPosTexture.name="lastPosTexture",this.outTexture=new pe(a,r,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.outTexture.name="outTexture";let i=Math.floor(a*this.downSampleCofe),n=Math.floor(r*this.downSampleCofe);this.newTexture=new pe(i,n,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.newTexture.name="newTexture",this.oldTexture=new pe(i,n,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.oldTexture.name="oldTexture",this.combineTexture=new pe(i,n,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.combineTexture.name="combineTexture";let o=new ke;o.loadOp="load",this.rtFrame=new Je([this.outTexture],[o])}createCompute(){this.ssgiCompute=new fe(Of),this.delayCompute=new fe(Yf),this.combineCompute=new fe(Zf);let e=le.getCameraGroup(this.view.camera);this.ssgiCompute.setSamplerTexture("gBufferTexture",this.gBufferTexture),this.ssgiCompute.setSamplerTexture("combineTexture",this.combineTexture),this.ssgiCompute.setSamplerTexture("oldTexture",this.oldTexture),this.ssgiCompute.setStorageTexture("newTexture",this.newTexture),this.ssgiCompute.setUniformBuffer("globalUniform",e.uniformGPUBuffer),this.ssgiCompute.setStorageBuffer("updateBuffer",this.updateBuffer),this.autoSetColorTexture("inTex",this.ssgiCompute),this.delayCompute.setSamplerTexture("newTexture",this.newTexture),this.delayCompute.setSamplerTexture("oldTexture",this.oldTexture),this.delayCompute.setStorageTexture("combineTexture",this.combineTexture),this.delayCompute.setStorageBuffer("updateBuffer",this.updateBuffer),this.combineCompute.setSamplerTexture("inputBTexture",this.combineTexture),this.combineCompute.setSamplerTexture("gBufferTexture",this.gBufferTexture),this.combineCompute.setUniformBuffer("globalUniform",e.uniformGPUBuffer),this.combineCompute.setStorageTexture("outTexture",this.outTexture),this.combineCompute.setStorageBuffer("updateBuffer",this.updateBuffer),this.textureScaleBigCompute=new Wd,this.textureScaleBigCompute.setInputes(null,[this.combineTexture],[this.outTexture])}render(e,t){}frame=0;compute(e){this.ssgiCompute||(this.createResource(),this.createCompute(),this.onResize(),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null),this.rendererPassState.label="SSGI"),this.frameCount=this.frame,this.frame++;let t=S.beginCommandEncoder();switch(parseInt(this.debugChanal)){case 0:S.copyTexture(t,this.combineTexture,this.oldTexture),S.computeCommand(t,[this.ssgiCompute,this.delayCompute,this.combineCompute]);break;case 1:S.copyTexture(t,this.posTexture,this.lastPosTexture),S.copyTexture(t,this.lastPosTexture,this.outTexture);break;case 2:S.copyTexture(t,this.normalTexture,this.outTexture);break;case 3:S.copyTexture(t,this.posTexture,this.outTexture);break;case 4:S.copyTexture(t,this.colorTexture,this.outTexture);break;case 5:S.copyTexture(t,this.gBufferTexture,this.outTexture);break}S.lastRenderPassState=this.rendererPassState,this.updateBuffer.setFloat("delay",.01)}onResize(){let e=E.presentationSize,t=e[0],a=e[1];this.outTexture.resize(t,a),this.ssgiCompute.workerSizeX=Math.ceil(this.newTexture.width/16),this.ssgiCompute.workerSizeY=Math.ceil(this.newTexture.height/16),this.ssgiCompute.workerSizeZ=1,this.delayCompute.workerSizeX=Math.ceil(this.combineTexture.width/16),this.delayCompute.workerSizeY=Math.ceil(this.combineTexture.height/16),this.delayCompute.workerSizeZ=1,this.combineCompute.workerSizeX=Math.ceil(this.outTexture.width/16),this.combineCompute.workerSizeY=Math.ceil(this.outTexture.height/16),this.combineCompute.workerSizeZ=1}}class vg extends Rt{SSR_RayTraceCompute;SSR_IS_Compute;SSR_Blend_Compute;isRetTexture;finalTexture;rendererPassState;ssrUniformBuffer;rayTraceData;ssrColorData;rtFrame;historyPosition;view;onAttach(e){this.view=e,A.setting.render.postProcessing.ssr.enable=!0}onDetach(e){A.setting.render.postProcessing.ssr.enable=!1}reflectionRatio=.5;get fadeEdgeRatio(){return A.setting.render.postProcessing.ssr.fadeEdgeRatio}set fadeEdgeRatio(e){e=ie(e,0,1);let t=A.setting.render.postProcessing.ssr;t.fadeEdgeRatio=e}get rayMarchRatio(){return A.setting.render.postProcessing.ssr.rayMarchRatio}set rayMarchRatio(e){e=ie(e,0,1);let t=A.setting.render.postProcessing.ssr;t.rayMarchRatio=e}get roughnessThreshold(){return A.setting.render.postProcessing.ssr.roughnessThreshold}set roughnessThreshold(e){e=ie(e,0,1);let t=A.setting.render.postProcessing.ssr;t.roughnessThreshold=e}get fadeDistanceMin(){return A.setting.render.postProcessing.ssr.fadeDistanceMin}set fadeDistanceMin(e){e=ie(e,0,1e4);let t=A.setting.render.postProcessing.ssr;t.fadeDistanceMin=e}get fadeDistanceMax(){return A.setting.render.postProcessing.ssr.fadeDistanceMax}set fadeDistanceMax(e){e=ie(e,0,1e4);let t=A.setting.render.postProcessing.ssr;t.fadeDistanceMax=e}get powDotRN(){return A.setting.render.postProcessing.ssr.powDotRN}set powDotRN(e){e=ie(e,0,1);let t=A.setting.render.postProcessing.ssr;t.powDotRN=e}createRayTraceShader(){let e=le.getCameraGroup(this.view.camera);this.SSR_RayTraceCompute=new fe(zf),this.SSR_RayTraceCompute.setUniformBuffer("globalUniform",e.uniformGPUBuffer),this.SSR_RayTraceCompute.setUniformBuffer("ssrUniform",this.ssrUniformBuffer),this.SSR_RayTraceCompute.setStorageBuffer("rayTraceBuffer",this.rayTraceData),this.SSR_RayTraceCompute.setStorageBuffer("historyPosition",this.historyPosition);let a=oe.getGBufferFrame("ColorPassGBuffer").getCompressGBufferTexture();this.SSR_RayTraceCompute.setSamplerTexture("gBufferTexture",a),W.instance.sky instanceof Dn&&this.SSR_RayTraceCompute.setSamplerTexture("prefilterMap",W.instance.sky.map),this.SSR_RayTraceCompute.workerSizeX=Math.ceil(this.isRetTexture.width/8),this.SSR_RayTraceCompute.workerSizeY=Math.ceil(this.isRetTexture.height/8),this.SSR_RayTraceCompute.workerSizeZ=1}createISShader(){this.SSR_IS_Compute=new fe(Gf),this.SSR_IS_Compute.setStorageBuffer("ssrUniform",this.ssrUniformBuffer),this.SSR_IS_Compute.setStorageBuffer("rayTraceBuffer",this.rayTraceData),this.SSR_IS_Compute.setStorageBuffer("ssrColorData",this.ssrColorData),this.SSR_IS_Compute.setStorageBuffer("historyPosition",this.historyPosition),this.SSR_IS_Compute.setSamplerTexture("colorMap",this.getOutTexture()),this.SSR_IS_Compute.setStorageTexture("outTex",this.isRetTexture),this.SSR_IS_Compute.workerSizeX=Math.ceil(this.isRetTexture.width/8),this.SSR_IS_Compute.workerSizeY=Math.ceil(this.isRetTexture.height/8),this.SSR_IS_Compute.workerSizeZ=1}createBlendShader(e){let t=le.getCameraGroup(this.view.camera);this.SSR_Blend_Compute=new fe(Lf),this.SSR_Blend_Compute.setStorageBuffer("rayTraceBuffer",this.rayTraceData),this.SSR_Blend_Compute.setUniformBuffer("globalUniform",t.uniformGPUBuffer);let r=oe.getGBufferFrame("ColorPassGBuffer").getCompressGBufferTexture();this.SSR_Blend_Compute.setSamplerTexture("gBufferTexture",r),this.SSR_Blend_Compute.setSamplerTexture("colorMap",this.getOutTexture()),this.SSR_Blend_Compute.setSamplerTexture("ssrMap",e),this.SSR_Blend_Compute.setStorageTexture("outTex",this.finalTexture),this.SSR_Blend_Compute.workerSizeX=Math.ceil(this.finalTexture.width/8),this.SSR_Blend_Compute.workerSizeY=Math.ceil(this.finalTexture.height/8),this.SSR_Blend_Compute.workerSizeZ=1}createResource(){let[e,t]=E.presentationSize;this.finalTexture=new pe(e,t,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING),this.finalTexture.name="ssrOutTex";let a=new ke;a.clearValue=[0,0,0,0],a.loadOp="clear";let r=Math.ceil(e*A.setting.render.postProcessing.ssr.pixelRatio),i=Math.ceil(t*A.setting.render.postProcessing.ssr.pixelRatio);this.isRetTexture=new pe(r,i,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING),this.isRetTexture.name="ssrTextureIn";let n=new ke;n.clearValue=[0,0,0,0],n.loadOp="clear",this.rtFrame=new Je([this.finalTexture,this.isRetTexture],[a,n]),this.rayTraceData=new _e(r*i*8,GPUBufferUsage.COPY_SRC),this.ssrColorData=new _e(r*i*4,GPUBufferUsage.COPY_SRC),this.historyPosition=new _e(r*i*4,GPUBufferUsage.COPY_SRC),this.ssrUniformBuffer=new ct(32),this.ssrUniformBuffer.setFloat("ssrBufferSizeX",this.isRetTexture.width),this.ssrUniformBuffer.setFloat("ssrBufferSizeY",this.isRetTexture.height),this.ssrUniformBuffer.setFloat("colorMapSizeX",this.finalTexture.width),this.ssrUniformBuffer.setFloat("colorMapSizeY",this.finalTexture.height),this.ssrUniformBuffer.apply()}render(e,t){if(!this.SSR_RayTraceCompute){this.createResource(),this.createISShader(),this.createRayTraceShader(),this.createBlendShader(this.isRetTexture),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null);let i=le.getCameraGroup(e.camera);this.SSR_RayTraceCompute.setUniformBuffer("standUniform",i.uniformGPUBuffer)}let a=A.setting.render.postProcessing.ssr;this.ssrUniformBuffer.setFloat("fadeEdgeRatio",a.fadeEdgeRatio),this.ssrUniformBuffer.setFloat("rayMarchRatio",a.rayMarchRatio),this.ssrUniformBuffer.setFloat("fadeDistanceMin",a.fadeDistanceMin),this.ssrUniformBuffer.setFloat("fadeDistanceMax",a.fadeDistanceMax),this.ssrUniformBuffer.setFloat("mixThreshold",a.mixThreshold),this.ssrUniformBuffer.setFloat("roughnessThreshold",a.roughnessThreshold),this.ssrUniformBuffer.setFloat("reflectionRatio",this.reflectionRatio),this.ssrUniformBuffer.setFloat("powDotRN",a.powDotRN),this.ssrUniformBuffer.setFloat("randomSeedX",Math.random()),this.ssrUniformBuffer.setFloat("randomSeedY",Math.random()),this.ssrUniformBuffer.apply();let r=[this.SSR_RayTraceCompute,this.SSR_IS_Compute,this.SSR_Blend_Compute];S.computeCommand(t,r),S.lastRenderPassState=this.rendererPassState}onResize(){let[e,t]=E.presentationSize,a=Math.ceil(e*A.setting.render.postProcessing.ssr.pixelRatio),r=Math.ceil(t*A.setting.render.postProcessing.ssr.pixelRatio);this.finalTexture.resize(e,t),this.isRetTexture.resize(a,r),this.rayTraceData.resizeBuffer(a*r*8),this.ssrColorData.resizeBuffer(a*r*4),this.historyPosition.resizeBuffer(a*r*4),this.ssrUniformBuffer.setFloat("ssrBufferSizeX",this.isRetTexture.width),this.ssrUniformBuffer.setFloat("ssrBufferSizeY",this.isRetTexture.height),this.ssrUniformBuffer.setFloat("colorMapSizeX",this.finalTexture.width),this.ssrUniformBuffer.setFloat("colorMapSizeY",this.finalTexture.height),this.SSR_RayTraceCompute.workerSizeX=Math.ceil(this.isRetTexture.width/8),this.SSR_RayTraceCompute.workerSizeY=Math.ceil(this.isRetTexture.height/8),this.SSR_RayTraceCompute.workerSizeZ=1,this.SSR_IS_Compute.workerSizeX=Math.ceil(this.isRetTexture.width/8),this.SSR_IS_Compute.workerSizeY=Math.ceil(this.isRetTexture.height/8),this.SSR_IS_Compute.workerSizeZ=1,this.SSR_Blend_Compute.workerSizeX=Math.ceil(this.finalTexture.width/8),this.SSR_Blend_Compute.workerSizeY=Math.ceil(this.finalTexture.height/8),this.SSR_Blend_Compute.workerSizeZ=1}}class yg{static createSeeds(){let e=20,t=32,a=[new b(0,0,e)],r=0,i=.02;for(let n=1;n<t;n++){let o=new b;a.push(o),r+=1-(1-.618)*n/t,i+=n*.01,o.x=Math.sin(r)*i,o.y=Math.cos(r)*i,o.z=1-n/t,o.multiplyScalar(e)}return a}}class Cg extends Rt{taaTexture;outTexture;rendererPassState;taaCompute;copyTexCompute;sharpCompute;taaSetting;preColorBuffer;preColorTex;preProjMatrix;preViewMatrix;rtFrame;constructor(){super()}onAttach(e){A.setting.render.postProcessing.taa.enable=!0,e.camera.enableJitterProjection(!0),this.createGUI()}onDetach(e){A.setting.render.postProcessing.taa.enable=!1,e.camera.enableJitterProjection(!1)}get jitterSeedCount(){return A.setting.render.postProcessing.taa.jitterSeedCount}set jitterSeedCount(e){e=ie(e,2,32),e=Math.round(e);let t=A.setting.render.postProcessing.taa;t.jitterSeedCount=e}get blendFactor(){return A.setting.render.postProcessing.taa.blendFactor}set blendFactor(e){e=ie(e,0,1);let t=A.setting.render.postProcessing.taa;t.blendFactor=e}get sharpFactor(){return A.setting.render.postProcessing.taa.sharpFactor}set sharpFactor(e){e=ie(e,.1,.99);let t=A.setting.render.postProcessing.taa;t.sharpFactor=e}get sharpPreBlurFactor(){return A.setting.render.postProcessing.taa.sharpPreBlurFactor}set sharpPreBlurFactor(e){e=ie(e,.1,.99);let t=A.setting.render.postProcessing.taa;t.sharpPreBlurFactor=e}get temporalJitterScale(){return A.setting.render.postProcessing.taa.temporalJitterScale}set temporalJitterScale(e){e=ie(e,0,1);let t=A.setting.render.postProcessing.taa;t.temporalJitterScale=e}createGUI(){}createCompute(e){let t=new fe(jf),a=new ct(44),r=le.getCameraGroup(e.camera);t.setUniformBuffer("globalUniform",r.uniformGPUBuffer),t.setUniformBuffer("taaData",a),t.setStorageBuffer("preColorBuffer",this.preColorBuffer);let i=oe.getGBufferFrame(oe.colorPass_GBuffer);t.setSamplerTexture("preColorTex",this.preColorTex),t.setSamplerTexture("gBufferTexture",i.getCompressGBufferTexture()),this.autoSetColorTexture("inTex",t),t.setStorageTexture("outTex",this.taaTexture),t.workerSizeX=Math.ceil(this.taaTexture.width/8),t.workerSizeY=Math.ceil(this.taaTexture.height/8),t.workerSizeZ=1,this.taaCompute=t,this.taaSetting=a,this.copyTexCompute=new fe(Jf),this.copyTexCompute.setStorageBuffer("preColor",this.preColorBuffer),this.copyTexCompute.setStorageTexture("preColorTex",this.preColorTex),this.copyTexCompute.workerSizeX=Math.ceil(this.taaTexture.width/8),this.copyTexCompute.workerSizeY=Math.ceil(this.taaTexture.height/8),this.copyTexCompute.workerSizeZ=1,this.sharpCompute=new fe(Wf),this.sharpCompute.setUniformBuffer("taaData",a),this.sharpCompute.setSamplerTexture("inTex",this.taaTexture),this.sharpCompute.setStorageTexture("outTex",this.outTexture),this.sharpCompute.workerSizeX=Math.ceil(this.outTexture.width/8),this.sharpCompute.workerSizeY=Math.ceil(this.outTexture.height/8),this.sharpCompute.workerSizeZ=1}createResource(){this.preProjMatrix=new R().identity(),this.preViewMatrix=new R().identity();let[e,t]=E.presentationSize;this.preColorBuffer=new _e(e*t*4,GPUBufferUsage.COPY_SRC),this.preColorTex=new pe(e,t,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.preColorTex.name="taaTex";let a=new ke;a.clearValue=[0,0,0,1],a.loadOp="clear",this.taaTexture=new pe(e,t,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.taaTexture.name="taaTex";let r=new ke;r.clearValue=[0,0,0,1],r.loadOp="clear",this.outTexture=new pe(e,t,Y.rgba16float,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.TEXTURE_BINDING),this.outTexture.name="sharpTaaTex";let i=new ke;i.clearValue=[0,0,0,1],i.loadOp="clear",this.rtFrame=new Je([this.preColorTex,this.taaTexture,this.outTexture],[a,r,i])}render(e,t){this.taaCompute||(this.createResource(),this.createCompute(e),this.rendererPassState=Re.createRendererPassState(this.rtFrame,null));let a=A.setting.render.postProcessing.taa;this.taaSetting.setMatrix("preProjMatrix",this.preProjMatrix),this.taaSetting.setMatrix("preViewMatrix",this.preViewMatrix),this.taaSetting.setFloat("jitterFrameIndex",e.camera.jitterFrameIndex),this.taaSetting.setFloat("blendFactor",a.blendFactor),this.taaSetting.setFloat("sharpFactor",a.sharpFactor),this.taaSetting.setFloat("sharpPreBlurFactor",a.sharpPreBlurFactor),this.taaSetting.setFloat("jitterX",e.camera.jitterX),this.taaSetting.setFloat("jitterY",e.camera.jitterY),this.taaSetting.apply(),S.computeCommand(t,[this.copyTexCompute,this.taaCompute,this.sharpCompute]),S.lastRenderPassState=this.rendererPassState,this.preProjMatrix.copyFrom(e.camera.projectionMatrix),this.preViewMatrix.copyFrom(e.camera.viewMatrix)}onResize(){let[e,t]=E.presentationSize;this.preColorBuffer.resizeBuffer(e*t*4),this.taaTexture.resize(e,t),this.outTexture.resize(e,t),this.preColorTex.resize(e,t),this.taaCompute.workerSizeX=Math.ceil(this.taaTexture.width/8),this.taaCompute.workerSizeY=Math.ceil(this.taaTexture.height/8),this.taaCompute.workerSizeZ=1,this.copyTexCompute.workerSizeX=Math.ceil(this.taaTexture.width/8),this.copyTexCompute.workerSizeY=Math.ceil(this.taaTexture.height/8),this.copyTexCompute.workerSizeZ=1,this.sharpCompute.workerSizeX=Math.ceil(this.outTexture.width/8),this.sharpCompute.workerSizeY=Math.ceil(this.outTexture.height/8),this.sharpCompute.workerSizeZ=1}}class $d{_tempIndexArray=[];setOutline(e,t){this.setOutlineList([e],t?[t]:null)}setOutlineList(e,t){e||=[];let a=ca.defaultColor,r=ca.SlotCount;for(let i=0;i<r;i++){this._tempIndexArray.length=0;let n=e[i],o=(t?t[i]:null)||a;if(n)for(const l of n)this.getEntityIdList(l,this._tempIndexArray);ca.fillDataAt(i,this._tempIndexArray,o)}}clearOutline(){return ca.clear(),this}_rendererList=[];getEntityIdList(e,t){this._rendererList.length=0;let a=e.getComponents(d.MeshRenderer,this._rendererList);for(const r of a)t.push(r.object3D.transform._worldMatrix.index)}}let Sg=new $d;class eh{localPosition=new b;worldPosition=new b;uv=new K;faceIndex;isIn=!1;t=0;u=0;v=0;triangle;v0;v1;v2;pickList;color}class si{static EPS=1e-4;static FLT_MAX=3402823466e29;static distPtTri(e,t,a,r){let i=new b,n=new b,o=new b;r.subtract(t,i),a.subtract(t,n),e.subtract(t,o);let l=ht(i,i),c=ht(i,n),f=ht(i,o),h=ht(n,n),u=ht(n,o),g=1/(l*h-c*c),p=(h*f-c*u)*g,m=(l*u-c*f)*g;if(p>=-si.EPS&&m>=-si.EPS&&p+m<=1+si.EPS){let D=t[1]+i[1]*p+n[1]*m;return Math.abs(D-e[1])}return si.FLT_MAX}static _info=new eh;static IntersectTriangle(e,t,a){let r=t.v1,i=t.v2,n=t.v3,o=i.subtract(r,b.HELP_3),l=n.subtract(r,b.HELP_4),c=e.direction.crossProduct(l,b.HELP_5),f=ht(o,c),h;if(f>0){if(a)return null;h=e.origin.subtract(r,b.HELP_2)}else h=r.subtract(e.origin,b.HELP_2),f=-f;if(f<1e-4)return this._info.isIn=!1,this._info.t=0,this._info.u=0,this._info.v=0,this._info;let u=ht(h,c);if(u<0||u>f)return this._info.isIn=!1,this._info.t=0,this._info.u=0,this._info.v=0,this._info;let g=h.crossProduct(o,b.HELP_1),p=ht(e.direction,g);if(p<0||u+p>f)return this._info.isIn=!1,this._info.t=0,this._info.u=0,this._info.v=0,this._info;let m=ht(l,g),D=1/f;m*=D,u*=D,p*=D,this._info.isIn=!0,this._info.t=m,this._info.u=u,this._info.v=p;let _=1-u-p;return this._u0.copyFrom(t.u1),this._u0.scale(_),this._u1.copyFrom(t.u2),this._u1.scale(u),this._u2.copyFrom(t.u3),this._u2.scale(p),this._info.uv.copyFrom(this._u0),this._info.uv.add(this._u1,this._info.uv),this._info.uv.add(this._u2,this._info.uv),this._info.localPosition.copyFrom(e.direction).multiplyScalar(m),this._info.localPosition.add(e.origin,this._info.localPosition),this._info}static _u0=new K;static _u1=new K;static _u2=new K}class Sn extends Ia{static _instance;_maxRetry=3;loadAll(e,t){return new Promise((a,r)=>{let i=e.length,n=[];e.forEach((o,l)=>{let c=new t;this.load(o,t).then(f=>{c.parse(f),n.push(c),i--,i===0&&a(n)})})})}constructor(){if(super(),Sn._instance)throw new Error("LoadManager is singleton class...")}static getInstance(){return this._instance||(this._instance=new Sn)}loadUrls(e,t){return new Promise((a,r)=>{let i=e.length,n=[];e.forEach((o,l)=>{this.load(o,t).then(c=>{n.push(c),i--,i===0&&a(n),i<0&&console.error(`loadUrls ${e} error`)})})})}get maxRetry(){return this._maxRetry}set maxRetry(e){this._maxRetry=e}load(e,t){return new Promise((a,r)=>{t.format})}}function th(s){const e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let a=0;a<s.length;a+=3){const r=s[a+0],i=s[a+1],n=s[a+2];r<e[0]&&(e[0]=r),i<e[1]&&(e[1]=i),n<e[2]&&(e[2]=n),r>t[0]&&(t[0]=r),i>t[1]&&(t[1]=i),n>t[2]&&(t[2]=n)}return{min:e,max:t}}var oi=(s=>(s.PLY="ply",s.SPLAT="splat",s.KSPLAT="ksplat",s.UNKNOWN="unknown",s))(oi||{});function ah(s){if(s.byteLength<16)return"unknown";const e=new Uint8Array(s,0,Math.min(512,s.byteLength));return new TextDecoder("utf-8").decode(e).startsWith("ply")?"ply":"unknown"}function rh(s){switch(s){case"char":case"uchar":case"uint8":case"int8":return 1;case"short":case"ushort":case"int16":case"uint16":return 2;case"int":case"uint":case"int32":case"uint32":case"float":case"float32":return 4;case"double":case"float64":return 8;default:return 4}}function et(s,e,t){switch(t){case"char":case"int8":return s.getInt8(e);case"uchar":case"uint8":return s.getUint8(e);case"short":case"int16":return s.getInt16(e,!0);case"ushort":case"uint16":return s.getUint16(e,!0);case"int":case"int32":return s.getInt32(e,!0);case"uint":case"uint32":return s.getUint32(e,!0);case"double":case"float64":return s.getFloat64(e,!0);case"float":case"float32":default:return s.getFloat32(e,!0)}}function ih(s){const e=Math.round(Math.sqrt(s));return Math.max(0,e-1)}function nh(s){const e=new TextDecoder("utf-8").decode(new Uint8Array(s,0,Math.min(4096,s.byteLength)));if(!e.startsWith("ply"))throw new Error("PLY: Unsupported format. Expecting PLY file.");const t=e.indexOf(`end_header
11690
- `);if(t<0)throw new Error("PLY: Invalid PLY header");const a=e.substring(0,t+11),r=a.split(/\r?\n/);let i="",n=0;const o=[];let l=!1;for(const c of r)if(c.startsWith("format "))i=c.split(/\s+/)[1];else if(c.startsWith("element ")){const f=c.split(/\s+/);l=f[1]==="vertex",l&&(n=parseInt(f[2]))}else if(l&&c.startsWith("property ")){const f=c.split(/\s+/),h=f[1],u=f[2];o.push({name:u,type:h})}if(i!=="binary_little_endian")throw new Error("PLY: Only binary_little_endian PLY is supported");return{format:i,vertexCount:n,properties:o,headerByteLength:a.length}}function sh(s){const e=nh(s),{vertexCount:t,properties:a,headerByteLength:r}=e,i=new DataView(s,r),n=C=>a.find(y=>y.name===C)!=null,o=C=>a.findIndex(y=>y.name===C),l=new Float32Array(t*3),c=n("scale_0")?new Float32Array(t*3):void 0,f=n("rot_0")?new Float32Array(t*4):void 0,h=n("opacity")?new Float32Array(t):void 0,u=[o("f_dc_0"),o("f_dc_1"),o("f_dc_2")],g=[];for(let C=0;C<a.length;C++)a[C].name.startsWith("f_rest_")&&g.push(C);const p=u[0]>=0&&u[1]>=0&&u[2]>=0;let m,D=0;if(p){const C=1+g.length/3;D=ih(C),m=new Float32Array(t*C*3)}const _=[];let B=0;for(const C of a)_.push(B),B+=rh(C.type);let v=0;for(let C=0;C<t;C++){const y=v,F=o("x"),k=o("y"),w=o("z");if(F<0||k<0||w<0)throw new Error("PLY: Missing x/y/z for vertex");if(l[C*3+0]=et(i,y+_[F],a[F].type),l[C*3+1]=et(i,y+_[k],a[k].type),l[C*3+2]=et(i,y+_[w],a[w].type),c){const x=o("scale_0"),M=o("scale_1"),N=o("scale_2");c[C*3+0]=et(i,y+_[x],a[x].type),c[C*3+1]=et(i,y+_[M],a[M].type),c[C*3+2]=et(i,y+_[N],a[N].type)}if(f){const x=o("rot_0"),M=o("rot_1"),N=o("rot_2"),Q=o("rot_3"),G=et(i,y+_[x],a[x].type),X=et(i,y+_[M],a[M].type),ne=et(i,y+_[N],a[N].type),q=et(i,y+_[Q],a[Q].type);f[C*4+0]=X,f[C*4+1]=ne,f[C*4+2]=q,f[C*4+3]=G}if(h){const x=o("opacity");h[C]=et(i,y+_[x],a[x].type)}if(p&&m){const x=1+g.length/3,M=C*x*3;m[M+0]=et(i,y+_[u[0]],a[u[0]].type),m[M+x+0]=et(i,y+_[u[1]],a[u[1]].type),m[M+2*x+0]=et(i,y+_[u[2]],a[u[2]].type);let N=1,Q=1,G=1;for(let X=0;X<g.length;X+=3){const ne=g[X+0],q=g[X+1],he=g[X+2];m[M+N]=et(i,y+_[ne],a[ne].type),m[M+x+Q]=et(i,y+_[q],a[q].type),m[M+2*x+G]=et(i,y+_[he],a[he].type),N++,Q++,G++}}v+=B}return{vertexCount:t,position:l,scale:c,rotation:f,opacity:h,sh:p&&m?{order:D,coeffs:m}:void 0}}class xg extends nt{static format=Ge.BIN;async parseBuffer(e){const t=ah(e);let a;switch(t){case oi.PLY:{const r=sh(e);a={count:r.vertexCount,position:r.position,rotation:r.rotation,scale:r.scale,opacity:r.opacity,sh:r.sh},a.bbox=th(r.position);break}case oi.SPLAT:throw new Error("SPLAT format is not yet supported");case oi.KSPLAT:throw new Error("KSPLAT format is not yet supported");case oi.UNKNOWN:default:throw new Error("Unknown or unsupported Gaussian Splatting file format")}return this.data=a,a}verification(){return!!this.data&&this.data.count>0}}var xn=(s=>(s.Point="Point",s.LineString="LineString",s.MultiPolygon="MultiPolygon",s))(xn||{});class Fg extends nt{static format=Ge.JSON;json;async parseString(e){this.json=e,this.data=JSON.parse(e)}}class kg{static getPath(e){let t=[];for(let a=0;a<e.features.length;a++){const r=e.features[a];switch(r.geometry.type){case xn.LineString:break;case xn.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 Eg{name;defines;doubleSided;baseColorFactor;emissiveFactor;metallicFactor;roughnessFactor;alphaCutoff;enableBlend;baseColorTexture;metallicRoughnessTexture;normalTexture;occlusionTexture;emissiveTexture;extensions;baseMapOffsetSize;normalMapOffsetSize;emissiveMapOffsetSize;roughnessMapOffsetSize;metallicMapOffsetSize;aoMapOffsetSize}class Rg{}class wg{}class bo{boneName;bonePath;parentBoneName;boneID;parentBoneID;instanceID;parentInstanceID;t;q;s;formBytes(e){this.boneName=e.readUTF(),this.bonePath=e.readUTF(),this.parentBoneName=e.readUTF(),this.boneID=e.readInt32(),this.parentBoneID=e.readInt32(),this.instanceID=e.readUTF(),this.parentInstanceID=e.readUTF(),this.t=e.readVector3(),this.q=e.readQuaternion(),this.s=e.readVector3()}}class go{name;count;boneData;boneMap;formBytes(e){this.boneData=[],this.boneMap=new Map,this.name=e.readUTF(),this.count=e.readInt32();for(let t=0;t<this.count;t++){let a=new bo;a.formBytes(e.readBytesArray()),this.boneData[t]=a,this.boneMap.set(a.boneName,a)}}}class oh extends nt{static format=Ge.BIN;static parser(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new go;i.formBytes(e.readBytesArray()),A.res.addObj(i.name,i)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}V.position,V.normal,V.color,V.TANGENT,V.uv,V.TEXCOORD_1,V.TEXCOORD_2,V.TEXCOORD_2,V.TEXCOORD_4,V.TEXCOORD_5,V.TEXCOORD_6,V.TEXCOORD_7,V.joints0,V.weights0;var z=(s=>(s[s.single=0]="single",s[s.boolean=1]="boolean",s[s.int=2]="int",s[s.int16=3]="int16",s[s.int32=4]="int32",s[s.float=5]="float",s[s.long=6]="long",s[s.uint=7]="uint",s[s.uint32=8]="uint32",s[s.uint64=9]="uint64",s[s.double=10]="double",s[s.string=11]="string",s[s.singleArray=12]="singleArray",s[s.stringArray=13]="stringArray",s[s.floatArray=14]="floatArray",s[s.vector2=15]="vector2",s[s.vector3=16]="vector3",s[s.vector4=17]="vector4",s[s.color=18]="color",s[s.color32=19]="color32",s[s.animationCurve=20]="animationCurve",s[s.quaternion=21]="quaternion",s[s.matrix4x4=22]="matrix4x4",s[s.mesh=23]="mesh",s[s.texture=24]="texture",s[s.material=25]="material",s[s.materials=26]="materials",s[s.skeleton=27]="skeleton",s[s.animClip=28]="animClip",s[s.vector2Int=29]="vector2Int",s[s.int32List=30]="int32List",s[s.colorList=31]="colorList",s[s.color32List=32]="color32List",s))(z||{});class Fn{static GetMaterial(e){let t=e,a=t.split("/");t=a[a.length-1],a=t.split("."),t=a[a.length-1];let r=Oo(t);if(r){let i=new ut;return i.shader=new r,i}else throw new Error("not found shader, shader name is "+t)}static applyMaterialTexture(e,t){for(let a=0;a<t.length;a++){const r=t[a];r.property in e?e[r.property]=r.texture:r.property in e.shader?e.shader[r.property]=r.texture:e.setTexture(r.property,r.texture)}}static applyMaterialProperties(e,t){for(let a=0;a<t.length;a++){const r=t[a],i=r.key;switch(r.type){case z.color:case z.color32:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformColor(i,n)}break;case z.single:case z.float:case z.int:case z.int16:case z.int32:case z.uint:case z.uint32:case z.uint64:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformFloat(i,n)}break;case z.singleArray:{let n=r.getValue()[0];i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformFloat(i,n)}break;case z.vector2:case z.vector2Int:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector2(i,n)}break;case z.vector3:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector3(i,n)}break;case z.vector4:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector4(i,n)}break}}}}class _a{static parser(e){switch(e.readInt32()){case z.single:return{t:z.single,v:e.readFloat32()};case z.boolean:return{t:z.boolean,v:e.readBoolean()};case z.int:return{t:z.int,v:e.readInt32()};case z.int16:return{t:z.int16,v:e.readInt16()};case z.int32:return{t:z.int32,v:e.readInt32()};case z.float:return{t:z.float,v:e.readFloat32()};case z.long:return{t:z.long,v:e.readFloat64()};case z.uint:return{t:z.uint,v:e.readUnit32()};case z.uint32:return{t:z.uint32,v:e.readUnit32()};case z.uint64:return{t:z.uint64,v:e.readUnit32()};case z.double:return{t:z.double,v:e.readFloat64()};case z.string:return{t:z.string,v:e.readUTF()};case z.singleArray:return{t:z.singleArray,v:e.readFloatArray()};case z.stringArray:return{t:z.stringArray,v:e.readStringArray()};case z.floatArray:return{t:z.floatArray,v:e.readFloatArray()};case z.vector2:return{t:z.vector2,v:e.readVector2()};case z.vector3:return{t:z.vector3,v:e.readVector3()};case z.vector4:return{t:z.vector4,v:e.readVector4()};case z.color:return{t:z.color,v:e.readColor()};case z.color32:return{t:z.color32,v:e.readColor()};case z.animationCurve:return{t:z.animationCurve,v:null};case z.quaternion:return{t:z.quaternion,v:e.readQuaternion()};case z.matrix4x4:return{t:z.matrix4x4,v:null};case z.mesh:{let o=e.readUTF(),l=A.res.getGeometry(o);return{t:z.mesh,v:l}}case z.texture:{let o=e.readUTF(),l=A.res.getTexture(o);return{t:z.texture,v:l}}case z.material:{let o=e.readUTF(),l=A.res.getMat(o);return{t:z.material,v:l}}case z.materials:{let o=e.readStringArray(),l=[];for(let c=0;c<o.length;c++){const f=o[c];let h=A.res.getMat(f);l.push(h)}return{t:z.materials,v:l}}case z.skeleton:break;case z.animClip:{let o=[],l=e.readInt32();for(let c=0;c<l;c++){let f=new ko;f.formBytes(e),o.push(f)}return{t:z.animClip,v:o}}case z.vector2Int:return{t:z.vector2Int,v:e.readVector2int()};case z.int32List:return{t:z.int32List,v:e.readInt32List()};case z.colorList:let a=e.readInt32(),r=[];for(let o=0;o<a;o++){const l=_a.parser(e).v;r.push(l)}return{t:z.colorList,v:r};case z.color32List:let i=e.readInt32(),n=[];for(let o=0;o<i;o++){const l=_a.parser(e).v;n.push(l)}return{t:z.color32List,v:n}}}}class mo{key;type;_data;getValue(){return this._data}formBytes(e){this.key=e.readUTF();let{t,v:a}=_a.parser(e);this.type=t,this._data=a}}class lh{property;name;texture;texelSize;wrapModeU;wrapModeV;wrapModeW;wrapMode;anisoLevel;dimension;filterMode}class ch extends nt{static format=Ge.TEXT;static parserMaterial(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=e.readBytesArray(),n=i.readUTF(),o=i.readUTF();i.readUTF();let l=i.readStringArray();i.readVector4(),i.readVector4();let c=i.readUTF(),f=[],h=[],u=i.readInt32();for(let m=0;m<u;m++){let D=new mo;D.formBytes(i),f.push(D)}let g=i.readInt32();for(let m=0;m<g;m++){let D=i.readBytesArray(),_=new lh;_.property=D.readUTF(),_.name=D.readUTF(),_.texture=A.res.getTexture(_.name),_.texelSize=D.readVector2(),_.wrapModeU=D.readUnit32(),_.wrapModeV=D.readUnit32(),_.wrapModeW=D.readUnit32(),_.wrapMode=D.readUnit32(),_.anisoLevel=D.readUnit32(),_.dimension=D.readUnit32(),_.filterMode=D.readUnit32(),h.push(_)}let p=Fn.GetMaterial(c);p.name=n;for(let m=0;m<l.length;m++){const D=l[m];p.shader.setDefine(D,!0)}Fn.applyMaterialTexture(p,h),Fn.applyMaterialProperties(p,f),A.res.addMat(o,p)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class po{shapeName;shapeIndex;frameCount;blendPositionList=new Float32Array;blendNormalList=new Float32Array;formBytes(e){let t=e.readBytesArray();this.shapeName=t.readUTF(),this.shapeIndex=t.readInt32(),this.frameCount=t.readInt32();let a=t.readInt32();this.blendPositionList=t.readFloat32Array(a*3);let r=t.readInt32();this.blendNormalList=t.readFloat32Array(r*3)}}class Ao{vertexCount;shapeNames;shapeIndexs;blendCount;blendShapePropertyDatas;blendShapeMap;formBytes(e){this.blendShapeMap=new Map,this.blendShapePropertyDatas=[];let t=e.readBytesArray();this.vertexCount=t.readInt32(),this.shapeNames=t.readStringArray(),this.shapeIndexs=t.readIntArray(),this.blendCount=t.readInt32();for(let a=0;a<this.blendCount;a++){let r=new po;r.formBytes(t),this.blendShapePropertyDatas.push(r),this.blendShapeMap.set(r.shapeName,r)}return e}}class fh{name;meshName;meshID;vertexCount;vertexStrip;vertexBuffer;indices;attributes;bones;bindPose;blendShapeData}class dh extends nt{static format=Ge.BIN;async parseBuffer(e){}static parserMeshs(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new fh,n=e.readBytesArray();i.meshName=n.readUTF(),i.meshID=n.readUTF(),n.readFloat32()>0,n.readFloat32()>0,n.readFloat32()>0;let o=n.readFloat32()>0,l=n.readFloat32()>0;o&&(i.bones=n.readStringArray(),i.bindPose=n.readMatrix44Array()),l&&(i.blendShapeData=new Ao,i.blendShapeData.formBytes(n));let c=n.readBytesArray(),f=n.readBytesArray(),h=c.readInt32(),u=0,g=[];for(let B=0;B<h;B++)g[B]={},g[B].att=Ig[c.readUTF()],g[B].dim=c.readInt32(),u+=g[B].dim,g[B].format=c.readUTF();i.vertexCount=c.readInt32(),i.vertexBuffer=f.getFloat32Array();let p=n.readInt32Array(),m=[],D=n.readInt32();for(let B=0;B<D;B++){let v=n.readInt32(),C=n.readInt32(),y=n.readInt32(),F=n.readInt32(),k=n.readInt32(),w=n.readInt32();n.readVector3(),n.readVector3();let x={indexStart:C,indexCount:y,vertexStart:F,vertexCount:w,firstStart:k,topology:v,index:B};m.push(x)}p.length>65535?i.indices=new Uint32Array(p):i.indices=new Uint16Array(p);let _=new Fe;if(_.vertexDim=u,_.geometryType=bt.compose_bin,_.setIndices(i.indices),_.setAttribute(V.all,i.vertexBuffer),o&&(_.skinNames=i.bones,_.bindPose=i.bindPose),l){_.blendShapeData=i.blendShapeData,_.morphTargetsRelative=!0,_.morphTargetDictionary={};for(let B=0;B<i.blendShapeData.blendCount;B++){_.setAttribute("a_morphPositions_"+B,i.blendShapeData.blendShapePropertyDatas[B].blendPositionList),_.setAttribute("a_morphNormals_"+B,i.blendShapeData.blendShapePropertyDatas[B].blendNormalList);for(let v=0;v<i.blendShapeData.blendCount;v++){let C=i.blendShapeData.shapeNames[v],y=i.blendShapeData.shapeIndexs[v];_.morphTargetDictionary[C]=y}}}for(let B=0;B<g.length;B++){const v=g[B].att;_.setAttribute(v,null)}for(let B=0;B<m.length;B++){const v=m[B];_.addSubGeometry(v)}_.name=i.meshName,A.res.addGeometry(i.meshID,_)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}let Ig={Position:V.position,Normal:V.normal,Color:V.color,Tangent:V.TANGENT,TexCoord0:V.uv,TexCoord1:V.TEXCOORD_1,TexCoord2:V.TEXCOORD_2,TexCoord3:V.TEXCOORD_2,TexCoord4:V.TEXCOORD_4,TexCoord5:V.TEXCOORD_5,TexCoord6:V.TEXCOORD_6,TexCoord7:V.vIndex,BlendIndices:V.joints0,BlendWeight:V.weights0};class kn extends DataView{get buffer(){return super.buffer}get byteOffset(){return super.byteOffset}get byteLength(){return super.byteLength}getInt16(e,t){return super.getInt16(e,t)}getInt32(e,t){return super.getInt32(e,t)}getFloat32(e,t){return super.getFloat32(e,t)}getFloat64(e,t){return super.getFloat64(e,t)}getUint8(e){return super.getUint8(e)}getUint32(e,t){return super.getUint32(e,t)}getInt8(e){return super.getInt8(e)}getUint16(e,t){return super.getUint16(e,t)}position=0;littleEndian=!0;constructor(e,t,a){super(e,t,a),this.position=0,this.position+=this.byteOffset}readUTF(){let e=this.readInt32(),t=e%4;t>0&&t<4&&(t=4-t);let a="",r=new Int8Array(this.buffer,this.position,e);return this.position+=e*Int8Array.BYTES_PER_ELEMENT,a+=String.fromCharCode.apply(null,r),this.position+=t*Int8Array.BYTES_PER_ELEMENT,a}readStringArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readUTF());return e}readByte(){let e=this.buffer[this.position];return this.position+=1,e}readBoolean(){let e=this.readInt32();return this.position+=4,e==1}readBytes(e){let t=new DataView(this.buffer,this.position,e);return this.position+=e,t.buffer}readBytesArray(){let e=this.readInt32(),t=new kn(this.buffer.slice(this.position,this.position+e));return this.position+=e,t}readUnit8(){let e=this.getUint8(this.position);return this.position+=Uint8Array.BYTES_PER_ELEMENT,e}readUnit16(){let e=this.getUint16(this.position);return this.position+=Uint16Array.BYTES_PER_ELEMENT,e}readUnit32(){let e=this.getUint32(this.position);return this.position+=Uint32Array.BYTES_PER_ELEMENT,e}readInt8(){let e=this.getInt8(this.position);return this.position+=Int8Array.BYTES_PER_ELEMENT,e}readInt16(){let e=this.getInt16(this.position,this.littleEndian);return this.position+=Int16Array.BYTES_PER_ELEMENT,e}readInt32(){let e=this.getInt32(this.position,this.littleEndian);return this.position+=Int32Array.BYTES_PER_ELEMENT,e}readFloat32(){let e=this.getFloat32(this.position,this.littleEndian);return this.position+=Float32Array.BYTES_PER_ELEMENT,e}readFloat64(){let e=this.getFloat64(this.position,this.littleEndian);return this.position+=Float64Array.BYTES_PER_ELEMENT,e}readInt32Array(){let e=this.readInt32(),t=new Int32Array(this.buffer,this.position,e);return t=t.slice(0,e),this.position+=t.byteLength,t}readInt32List(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++)t.push(this.readInt32());return t}readFloatArray(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readFloat32();t.push(r)}return t}readIntArray(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readInt32();t.push(r)}return t}readVector2int(){let e=new K;return e.x=this.readInt32(),e.y=this.readInt32(),e}readVector2(){let e=new K;return e.x=this.readFloat32(),e.y=this.readFloat32(),e}readVector3(){let e=new b;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e}readVector3Array(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readVector3());return e}readVector4(){let e=new $;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e.w=this.readFloat32(),e}readVector4Array(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readVector4());return e}readColor(){let e=new O;return e.r=this.readFloat32(),e.g=this.readFloat32(),e.b=this.readFloat32(),e.a=this.readFloat32(),e}readColorArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readColor());return e}readQuaternion(){let e=new Z;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e.w=this.readFloat32(),e}readQuaternionArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readQuaternion());return e}readMatrix44(){let e=new R,t=e.rawData;return t[0]=this.readFloat32(),t[1]=this.readFloat32(),t[2]=this.readFloat32(),t[3]=this.readFloat32(),t[4]=this.readFloat32(),t[5]=this.readFloat32(),t[6]=this.readFloat32(),t[7]=this.readFloat32(),t[8]=this.readFloat32(),t[9]=this.readFloat32(),t[10]=this.readFloat32(),t[11]=this.readFloat32(),t[12]=this.readFloat32(),t[13]=this.readFloat32(),t[14]=this.readFloat32(),t[15]=this.readFloat32(),e}readMatrix44Array(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readMatrix44();t.push(r)}return t}readFloat32Array(e){let t=new DataView(this.buffer),a=new Float32Array(e);for(let r=0;r<e;r++)a[r]=t.getFloat32(this.position+r*Float32Array.BYTES_PER_ELEMENT,this.littleEndian);return this.position+=e*Float32Array.BYTES_PER_ELEMENT,a}getFloat32Array(){let e=new Float32Array(this.buffer,this.byteOffset,this.byteLength/Float32Array.BYTES_PER_ELEMENT);return e=e.slice(0,this.byteLength),e}}class hh extends nt{static format=Ge.TEXT;static async parserTexture(e,t,a){let r=e.readInt32(),i=[];for(let o=0;o<r;o++){let l=e.readUTF();uh.useWebp?(l=l.replace("png","webp"),l=l.replace("jpb","webp"),i.push(t.baseUrl+"webp/"+l)):i.push(t.baseUrl+l)}let n=await A.res.loadBitmapTextures(i,A.setting.loader.numConcurrent,a,!0);for(const o of n)A.res.addTexture(o.name,o)}verification(){if(this.data)return!0;throw new Error("verify failed.")}}var Qg=Object.getOwnPropertyDescriptor,Tg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Qg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.LitSSSShader=class extends it{constructor(){super(),J.register("PBRLitSSSShader",ad);let e=new Ne("PBRLitSSSShader","PBRLitSSSShader");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefine("USE_CUSTOMUNIFORM",!0),this.setDefault(),this.computes=[new Zd(this)]}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new $(0,0,1,1)),this.setUniformVector4("transformUV2",new $(0,0,1,1)),this.setUniformColor("baseColor",new O),this.setUniformColor("emissiveColor",new O(1,1,1)),this.setUniformVector4("materialF0",new $(.04,.04,.04,1)),this.setUniformColor("specularColor",new O(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",0),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new O(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this.setUniformColor("skinColor",new O(1,0,0)),this.setUniformFloat("skinPower",3.4),this.setUniformFloat("skinColorIns",.5),this.setUniformFloat("curveFactor",1)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _SSSMap(e){this.setTexture("sssMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Ft.none:t.shaderState.cullMode}set _SkinColor(e){this.setUniformColor("skinColor",e)}set _SkinPower(e){this.setUniformFloat("skinPower",e)}set _SkinColorIns(e){this.setUniformFloat("skinColorIns",e)}set curveFactor(e){this.setUniformFloat("curveFactor",e)}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=te.NONE:t.blendMode=te.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.LitSSSShader=Tg([Qa(d.LitSSSShader,"LitSSSShader")],d.LitSSSShader);var Mg=Object.getOwnPropertyDescriptor,Ng=(s,e,t,a)=>{for(var r=a>1?void 0:a?Mg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.LitShader=class extends it{constructor(){super();let e=new Ne("PBRLItShader","PBRLItShader");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new $(0,0,1,1)),this.setUniformVector4("transformUV2",new $(0,0,1,1)),this.setUniformColor("baseColor",new O),this.setUniformColor("emissiveColor",new O(0,0,0)),this.setUniformVector4("materialF0",new $(.04,.04,.04,1)),this.setUniformColor("specularColor",new O(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",0),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new O(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this._MainTex=A.res.grayTexture,this._BumpMap=A.res.normalTexture,this._MaskTex=A.res.maskTexture}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Ft.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=te.NONE:t.blendMode=te.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.LitShader=Ng([Qa(d.LitShader,"LitShader")],d.LitShader);class En{comName;data;static parser(e){let t=e.readBytesArray(),a=new En;a.comName=t.readUTF(),a.data=[];let r=t.readInt32();for(let i=0;i<r;i++){let n=new mo;n.formBytes(t),a.data.push(n)}return a}}class zi{name;parentName;position;rotation;scale;comDatas;child;static parser(e){let t=e.readBytesArray(),a=new zi;a.name=t.readUTF(),a.parentName=t.readUTF(),a.position=t.readVector3(),a.rotation=t.readQuaternion(),a.scale=t.readVector3(),a.comDatas=[],a.child=[];let r=t.readInt32();for(let n=0;n<r;n++){const o=En.parser(t);a.comDatas.push(o)}let i=t.readInt32();for(let n=0;n<i;n++){const o=zi.parser(t);a.child.push(o)}return a}}class uh extends nt{static useWebp=!0;static format=Ge.BIN;avatarDic;nodeData;async parseBuffer(e){this.avatarDic={};let t=new kn(e,0);await hh.parserTexture(t,this,this.loaderFunctions),oh.parser(t,this),dh.parserMeshs(t,this),ch.parserMaterial(t,this),this.nodeData=this.parserPrefabNode(t),this.data=this.data=this.parserNodeTree(this.nodeData)}parserPrefabNode(e){return zi.parser(e)}parserNodeTree(e){let t=new d.Object3D;if(t.localPosition=b.serialize(e.position),t.localQuaternion=Z.serialize(e.rotation),t.localScale=b.serialize(e.scale),t.name=e.name,e.comDatas)for(let a=0;a<e.comDatas.length;a++){const r=e.comDatas[a];let i=null,n=Vo(r.comName);if(n){i=t.getOrAddComponent(n);for(let o=0;o<r.data.length;o++){const l=r.data[o];l.key in i&&(i[l.key]=l.getValue())}}}if(e.child&&e.child.length>0)for(let a=0;a<e.child.length;a++){let r=this.parserNodeTree(e.child[a]);t.addChild(r)}return t}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class Pg{static getNumber(e){return parseFloat(e)}static getInt(e){return parseInt(e)}static getBoolean(e){return e=="true"}static getNumberArray(e){let t=e.replaceAll("[","");t=t.replaceAll("]","");let a=t.split(",");for(let r=0;r<a.length;r++)parseFloat(a[r]);return t}static getStringArray(e){let t=e.replaceAll("[","");t=t.replaceAll("]","");let a=t.split(","),r=[];for(let i=0;i<a.length;i++){const n=a[i];r.push(n)}return r}static getVector2(e){}static getVector3(e){}static getVector4(e){}static getQuaternion(e){}static getColor(e){}}var Vg=Object.getOwnPropertyDescriptor,Og=(s,e,t,a)=>{for(var r=a>1?void 0:a?Vg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.FatLineShader=class extends it{constructor(){super();const e=new Ne("FatLine_VS","FatLine_FS");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);const t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1,t.cullMode=Ft.none,t.depthWriteEnabled=!0,this.setDefault()}setDefault(){this.setUniformColor("baseColor",new O(1,1,1,1)),this.setUniformFloat("lineWidth",1),this.setUniformFloat("opacity",1),this.setUniformVector2("resolution",new K(1920,1080));const e=new R;this.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}},d.FatLineShader=Og([Qa(d.FatLineShader,"FatLineShader")],d.FatLineShader);var Lg=Object.getOwnPropertyDescriptor,Gg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Lg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.UnLitShader=class extends it{constructor(){super();let e=new Ne("UnLit","UnLit");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformVector4("transformUV1",new $(0,0,1,1)),this.setUniformVector4("transformUV2",new $(0,0,1,1)),this.setUniformColor("baseColor",new O),this.setUniformFloat("alphaCutoff",0)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Ft.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=te.NONE:t.blendMode=te.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.UnLitShader=Gg([Qa(d.UnLitShader,"UnLitShader")],d.UnLitShader);var zg=Object.getOwnPropertyDescriptor,Jg=(s,e,t,a)=>{for(var r=a>1?void 0:a?zg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.UnLitTexArrayShader=class extends it{constructor(){super(),J.register("VertexAttributeIndexShader",$f),J.register("UnLitTextureArray",rd);let e=new Ne("UnLitTextureArray","UnLitTextureArray");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformVector4("transformUV1",new $(0,0,1,1)),this.setUniformVector4("transformUV2",new $(0,0,1,1)),this.setUniformColor("baseColor",new O),this.setUniformFloat("alphaCutoff",0)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Ft.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=te.NONE:t.blendMode=te.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.UnLitTexArrayShader=Jg([Qa(d.UnLitTexArrayShader,"UnLitTexArrayShader")],d.UnLitTexArrayShader);const fr=-1,dr=0,Do=1,bh=2,Ba=3,Wg=6378137,jg=1/298.257223563,Zg=6356752314245179e-9,Yg=Symbol("PLUGIN_REGISTERED");class _o{boundingVolume;geometricError;refine;content;contents;transform;extensions;extras;parent=null;children=[];loadingState=dr;used=!1;visible=!1;active=!1;inFrustum=!1;error=1/0;distanceFromCamera=1/0;depth=0;depthFromRenderedParent=0;lastFrameVisited=-1;isLeaf=!1;allChildrenReady=!1;hasContent=!1;hasRenderableContent=!1;hasUnrenderableContent=!1;childrenProcessed=0;usedLastFrame=!1;priority;canTraverse=!1;canTraverseFrame=-1;basePath="";cached={};constructor(e,t=null){if(this.boundingVolume=e.boundingVolume,this.geometricError=e.geometricError,this.refine=e.refine,this.content=e.content,this.contents=e.contents,this.transform=e.transform,this.extensions=e.extensions,this.extras=e.extras,this.parent=t,this.depth=t?t.depth+1:0,this.depthFromRenderedParent=t?.hasContent?0:t?t.depthFromRenderedParent+1:0,this.hasContent=!!(this.content||this.contents&&this.contents.length>0),this.content?.uri){const a=this.content.uri.toLowerCase();this.hasUnrenderableContent=a.endsWith("tileset.json"),this.hasRenderableContent=!this.hasUnrenderableContent}else this.contents&&this.contents.length>0&&(this.hasRenderableContent=!0)}addChild(e){e.parent=this,e.depth=this.depth+1,e.depthFromRenderedParent=this.hasContent?0:this.depthFromRenderedParent+1,this.children.push(e)}resetFrameState(e){this.lastFrameVisited!==e&&(this.lastFrameVisited=e,this.used=!1,this.inFrustum=!1,this.isLeaf=!1,this.visible=!1,this.active=!1,this.error=1/0,this.distanceFromCamera=1/0,this.allChildrenReady=!1)}}const gh=2**30;class mh{minSize=6e3;maxSize=8e3;minBytesSize=.3*gh;maxBytesSize=.4*gh;unloadPercent=.05;autoMarkUnused=!0;_itemSet=new Map;_itemList=[];_usedSet=new Set;_callbacks=new Map;_unloadingHandle=-1;_cachedBytes=0;_bytesMap=new Map;_loadedSet=new Set;_unloadPriorityCallback=null;set unloadPriorityCallback(e){this._unloadPriorityCallback=e}get unloadPriorityCallback(){return this._unloadPriorityCallback}isFull(){return this._itemSet.size>=this.maxSize||this._cachedBytes>=this.maxBytesSize}getMemoryUsage(e){return this._bytesMap.get(e)||0}setMemoryUsage(e,t){if(!this._itemSet.has(e))return;const a=this._bytesMap.get(e)||0;this._cachedBytes-=a,this._bytesMap.set(e,t),this._cachedBytes+=t}add(e,t){return this._itemSet.has(e)||this.isFull()?!1:(this._itemList.push(e),this._usedSet.add(e),this._itemSet.set(e,Date.now()),this._callbacks.set(e,t),this._loadedSet.add(e),!0)}has(e){return this._itemSet.has(e)}remove(e){if(!this._itemSet.has(e))return!1;const t=this._bytesMap.get(e)||0;this._cachedBytes-=t,this._bytesMap.delete(e);const a=this._callbacks.get(e);a&&a(e);const r=this._itemList.indexOf(e);return r!==-1&&this._itemList.splice(r,1),this._usedSet.delete(e),this._itemSet.delete(e),this._callbacks.delete(e),this._loadedSet.delete(e),!0}markUsed(e){this._itemSet.has(e)&&(this._usedSet.add(e),this._itemSet.set(e,Date.now()))}markUnused(e){this._usedSet.delete(e)}scheduleUnload(){this._unloadingHandle===-1&&(this._unloadingHandle=requestAnimationFrame(()=>{this._unloadingHandle=-1,this._performUnload()}))}_performUnload(){if(!(this._itemSet.size>this.minSize||this._cachedBytes>this.minBytesSize))return;this.autoMarkUnused&&this._itemSet.forEach((o,l)=>{this._usedSet.has(l)||this.markUnused(l)});const t=[];this._itemList.forEach(o=>{this._usedSet.has(o)||t.push(o)}),this._unloadPriorityCallback&&t.sort(this._unloadPriorityCallback);const a=Math.floor(this._itemSet.size*(1-this.unloadPercent)),r=this._cachedBytes-(this._cachedBytes-this.minBytesSize);let i=0,n=0;for(let o=0;o<t.length;o++){const l=t[o];if(this._itemSet.size-i<=a&&this._cachedBytes-n<=r)break;const c=this._bytesMap.get(l)||0;this.remove(l)&&(i++,n+=c)}}clear(){Array.from(this._itemSet.keys()).forEach(t=>this.remove(t))}getStats(){return{size:this._itemSet.size,bytes:this._cachedBytes,usedCount:this._usedSet.size}}}class Bo{maxJobs=6;autoUpdate=!0;priorityCallback=null;_items=[];_callbacks=new Map;_currJobs=0;_scheduled=!1;_schedulingCallback;constructor(){this._schedulingCallback=e=>{requestAnimationFrame(e)}}set schedulingCallback(e){this._schedulingCallback=e}get running(){return this._items.length!==0||this._currJobs!==0}sort(){this.priorityCallback&&this._items.sort(this.priorityCallback)}has(e){return this._callbacks.has(e)}add(e,t){if(this._callbacks.has(e))return this._callbacks.get(e).promise;let a,r;const i=new Promise((o,l)=>{a=o,r=l}),n={callback:t,promise:i,resolve:a,reject:r};return this._items.unshift(e),this._callbacks.set(e,n),this.autoUpdate&&this._scheduleJobRun(),i}remove(e){const t=this._items.indexOf(e);if(t!==-1){const a=this._callbacks.get(e);a&&(a.promise.catch(()=>{}),a.reject(new Error("PriorityQueue: Item removed."))),this._items.splice(t,1),this._callbacks.delete(e)}}removeByFilter(e){const t=[];this._items.forEach(a=>{e(a)&&t.push(a)}),t.forEach(a=>this.remove(a))}_scheduleJobRun(){this._scheduled||(this._scheduled=!0,this._schedulingCallback(()=>{this._scheduled=!1,this._tryRunJobs()}))}_tryRunJobs(){this.sort();const e=this.maxJobs;let t=0;const a=()=>{this._currJobs--,this.autoUpdate&&this._scheduleJobRun()};for(;e>this._currJobs&&this._items.length>0&&t<e;){this._currJobs++,t++;const r=this._items.shift(),i=this._callbacks.get(r);this._callbacks.delete(r),Promise.resolve(i.callback(r)).then(()=>{i.resolve(),a()}).catch(n=>{i.reject(n),a()})}}clear(){Array.from(this._items).forEach(t=>this.remove(t))}getStats(){return{queued:this._items.length,running:this._currJobs}}}function ph(s,e=null,t=null){const a=[];for(a.push(s),a.push(null),a.push(0);a.length>0;){const r=a.pop(),i=a.pop(),n=a.pop();if(e&&e(n,i,r)===!0){t&&t(n,i,r);return}const o=n.children;if(o&&o.length>0)for(let l=o.length-1;l>=0;l--)a.push(o[l]),a.push(n),a.push(r+1);if(t&&t(n,i,r)===!0)return}}function Xg(s,e){let t=s;for(;t;){const a=t.depth,r=t.parent;e(t,r,a),t=r}}const Rn={inView:!1,error:1/0,distanceFromCamera:1/0},Ah=!0;function Dh(s){return s===Ba||s===fr}function hr(s,e){return s.lastFrameVisited===e&&s.used}function _h(s){return s.childrenProcessed===s.children.length}function Uo(s){return s.hasUnrenderableContent||s.parent!==null&&s.parent.geometricError<s.geometricError}function vo(s,e){s.lastFrameVisited!==e.frameCount&&(s.usedLastFrame=s.used,s.lastFrameVisited=e.frameCount,s.used=!1,s.inFrustum=!1,s.isLeaf=!1,s.visible=!1,s.active=!1,s.error=1/0,s.distanceFromCamera=1/0,s.allChildrenReady=!1,e.calculateTileViewError(s,Rn),s.inFrustum=Rn.inView,s.error=Rn.error,s.distanceFromCamera=Rn.distanceFromCamera)}function yo(s,e,t=!1){s.used||(t||(s.used=!0,e.stats.used++),e.markTileUsed(s),s.inFrustum===!0&&e.stats.inFrustum++)}function Hg(s,e){if(s.canTraverse&&s.canTraverseFrame===e.frameCount)return s.canTraverse;let t=!1;return s.error<=e.errorTarget&&!Uo(s)||s.depth>=e.maxDepth||!s.children||s.children.length===0?t=!1:t=!0,s.canTraverse=t,s.canTraverseFrame=e.frameCount,t}function Co(s,e,t=!1){if(e.ensureChildrenArePreprocessed(s),vo(s,e),yo(s,e,t),Uo(s)&&_h(s)){const a=s.children;for(let r=0,i=a.length;r<i;r++)Co(a[r],e,t)}}function wn(s,e){if(e.ensureChildrenArePreprocessed(s),vo(s,e),!s.inFrustum)return;if(!Hg(s,e)){yo(s,e);const n=s.children;if(!s.hasContent&&n&&n.length>0)for(let o=0,l=n.length;o<l;o++){const c=n[o];wn(c,e)}return}const a=s.children;let r=!1,i=!1;for(let n=0,o=a.length;n<o;n++){const l=a[n];wn(l,e),r=r||hr(l,e.frameCount),i=i||l.inFrustum}if(s.refine==="REPLACE"&&!i&&a.length!==0){s.inFrustum=!1;for(let n=0,o=a.length;n<o;n++)Co(a[n],e,!0);return}if(yo(s,e),s.refine==="REPLACE"&&(r&&s.depth!==0||Ah))for(let n=0,o=a.length;n<o;n++)Co(a[n],e)}function So(s,e){const t=e.frameCount;if(!hr(s,t))return;const a=s.children;let r=!1;for(let i=0,n=a.length;i<n;i++){const o=a[i];r=r||hr(o,t)}if(!r)s.isLeaf=!0;else{let i=!0;for(let n=0,o=a.length;n<o;n++){const l=a[n];if(So(l,e),hr(l,t)){const c=!Uo(l);let f=!l.hasContent||l.hasRenderableContent&&Dh(l.loadingState)||l.hasUnrenderableContent&&l.loadingState===fr;f=c&&f||l.allChildrenReady,i=i&&f}}s.allChildrenReady=i}}function Bh(s,e){if(e.ensureChildrenArePreprocessed(s),hr(s,e.frameCount)&&(s.hasContent&&e.queueTileForDownload(s),_h(s))){const t=s.children;for(let a=0,r=t.length;a<r;a++)Bh(t[a],e)}}function xo(s,e){const t=e.stats;if(!hr(s,e.frameCount))return;if(s.isLeaf){s.loadingState===Ba?(s.inFrustum&&(s.visible=!0,t.visible++),s.active=!0,t.active++):s.hasContent&&e.queueTileForDownload(s);return}const a=s.children,r=s.hasContent,i=Dh(s.loadingState)&&r,n=(e.errorTarget+1)*(e.errorThreshold||1),o=s.error<=n,l=s.refine==="ADD",c=s.allChildrenReady||s.depth===0&&!Ah;if(r&&(o||l)&&e.queueTileForDownload(s),(o&&i&&!c||i&&l)&&(s.inFrustum&&(s.visible=!0,t.visible++),s.active=!0,t.active++),!l&&o&&!c)for(let f=0,h=a.length;f<h;f++){const u=a[f];hr(u,e.frameCount)&&Bh(u,e)}else for(let f=0,h=a.length;f<h;f++)xo(a[f],e)}function Fo(s,e){const t=hr(s,e.frameCount);if(t||s.usedLastFrame){let a=!1,r=!1;if(t?(a=s.active,r=s.visible):vo(s,e),s.hasRenderableContent&&s.loadingState===Ba){const n=s.__wasSetVisible;s.__wasSetActive!==a&&(e.setTileActive(s,a),s.__wasSetActive=a),n!==r&&(e.setTileVisible(s,r),s.__wasSetVisible=r)}s.usedLastFrame=t;const i=s.children;for(let n=0,o=i.length;n<o;n++)Fo(i[n],e)}}class Rr{static s_tmpMatrix=null;_type;_data;_box;get box(){return this._box}_sphere;_matrix;constructor(e){if(Rr.s_tmpMatrix||(Rr.s_tmpMatrix=new R),this._data=e,e.box)this._type="box",this._parseBox(e.box);else if(e.sphere)this._type="sphere",this._parseSphere(e.sphere);else if(e.region)this._type="region",this._parseRegion(e.region);else throw new Error("BoundingVolume: Invalid bounding volume data")}_parseBox(e){if(e.length!==12)throw new Error("BoundingVolume: Box must have 12 elements");const t=new b(e[0],e[1],e[2]),a=new b(e[3],e[4],e[5]),r=new b(e[6],e[7],e[8]),i=new b(e[9],e[10],e[11]),n=a.length,o=r.length,l=i.length,c=a.clone().normalize(),f=r.clone().normalize(),h=i.clone().normalize();this._matrix=new R;const u=this._matrix.rawData;u[0]=c.x,u[1]=c.y,u[2]=c.z,u[3]=0,u[4]=f.x,u[5]=f.y,u[6]=f.z,u[7]=0,u[8]=h.x,u[9]=h.y,u[10]=h.z,u[11]=0,u[12]=t.x,u[13]=t.y,u[14]=t.z,u[15]=1;const g=new b(n*2,o*2,l*2);this._box=new ge(new b(0,0,0),g)}_parseSphere(e){if(e.length!==4)throw new Error("BoundingVolume: Sphere must have 4 elements");const t=new b(e[0],e[1],e[2]),a=e[3];this._sphere=new Sr(t,a)}_parseRegion(e){if(e.length!==6)throw new Error("BoundingVolume: Region must have 6 elements");const[t,a,r,i,n,o]=e,l=new b((t+r)/2,(a+i)/2,(n+o)/2),c=new b(Math.abs(r-t),Math.abs(i-a),Math.abs(o-n));this._box=new ge(l,c),this._matrix=new R,this._matrix.identity()}getAABB(e,t){if(this._type==="sphere"&&this._sphere){const a=this._sphere.center,r=this._sphere.radius,i=new b(a.x-r,a.y-r,a.z-r),n=new b(a.x+r,a.y+r,a.z+r);if(e.setFromMinMax(i,n),t){const o=[new b(i.x,i.y,i.z),new b(n.x,i.y,i.z),new b(i.x,n.y,i.z),new b(n.x,n.y,i.z),new b(i.x,i.y,n.z),new b(n.x,i.y,n.z),new b(i.x,n.y,n.z),new b(n.x,n.y,n.z)];o.forEach(l=>{const c=new b;t.transformPoint(l,c),l.copyFrom(c)}),e.makeEmpty(),o.forEach(l=>{e.expandByPoint(l)})}return e}else if(this._box){const a=Rr.s_tmpMatrix;if(a.identity(),this._matrix?t?a.multiplyMatrices(t,this._matrix):a.copyFrom(this._matrix):t&&a.copyFrom(t),a){const r=this._box,i=[new b(r.min.x,r.min.y,r.min.z),new b(r.max.x,r.min.y,r.min.z),new b(r.min.x,r.max.y,r.min.z),new b(r.max.x,r.max.y,r.min.z),new b(r.min.x,r.min.y,r.max.z),new b(r.max.x,r.min.y,r.max.z),new b(r.min.x,r.max.y,r.max.z),new b(r.max.x,r.max.y,r.max.z)];i.forEach(n=>{const o=new b;a.transformPoint(n,o),n.copyFrom(o)}),e.makeEmpty(),i.forEach(n=>{e.expandByPoint(n)})}else e.setFromMinMax(this._box.min,this._box.max);return e}throw new Error("BoundingVolume: Invalid state")}getOBB(e,t){this._type==="box"&&this._box&&this._matrix?(e.setFromMinMax(this._box.min,this._box.max),t.copyFrom(this._matrix)):(this.getAABB(e),t.identity())}getSphere(e){if(this._type==="sphere"&&this._sphere)return e.center.copyFrom(this._sphere.center),e.radius=this._sphere.radius,e;const t=new ge;this.getAABB(t);const a=t.center,i=t.size.length*.5;return e.center.copyFrom(a),e.radius=i,e}get type(){return this._type}distanceToPoint(e,t){if(this._type==="sphere"&&this._sphere){const a=this._sphere.center;let r=a;if(t){const o=new b;t.transformPoint(a,o),r=o}const i=this._sphere.radius,n=e.clone().subtract(r).length;return Math.max(0,n-i)}else if(this._box){const a=new ge;this.getAABB(a,t);const r=a.center,i=a.size,n=Math.max(0,Math.abs(e.x-r.x)-i.x*.5),o=Math.max(0,Math.abs(e.y-r.y)-i.y*.5),l=Math.max(0,Math.abs(e.z-r.z)-i.z*.5);return Math.sqrt(n*n+o*o+l*l)}return 1/0}intersectsFrustum(e,t){if(this._type==="sphere"&&this._sphere){const a=new ge;return this.getAABB(a,t),e.containsBox2(a)>0}else if(this._box){const a=new ge;return this.getAABB(a,t),e.containsBox2(a)>0}return!1}}const Uh=(s,e)=>{const t=s.priority||0,a=e.priority||0;return t!==a?t>a?1:-1:s.used!==e.used?s.used?1:-1:s.error!==e.error?s.error>e.error?1:-1:s.distanceFromCamera!==e.distanceFromCamera?s.distanceFromCamera>e.distanceFromCamera?-1:1:s.depthFromRenderedParent!==e.depthFromRenderedParent?s.depthFromRenderedParent>e.depthFromRenderedParent?-1:1:0},vh=(s,e)=>{const t=s.priority||0,a=e.priority||0;return t!==a?t>a?1:-1:s.lastFrameVisited!==e.lastFrameVisited?s.lastFrameVisited>e.lastFrameVisited?-1:1:s.depthFromRenderedParent!==e.depthFromRenderedParent?s.depthFromRenderedParent>e.depthFromRenderedParent?1:-1:s.loadingState!==e.loadingState?s.loadingState>e.loadingState?-1:1:s.hasUnrenderableContent!==e.hasUnrenderableContent?s.hasUnrenderableContent?-1:1:s.error!==e.error?s.error>e.error?-1:1:0};class Kg{rootLoadingState=dr;rootTileSet=null;rootURL=null;fetchOptions={};frameCount=0;isLoading=!1;lruCache;loadQueue;processNodeQueue;plugins=[];_queuedTiles=[];_cachedSinceLoadComplete=new Set;_processedTiles=new WeakSet;_visibleTiles=new Set;_usedSet=new Set;_cacheHits=0;_cacheMisses=0;stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0,inCacheSinceLoad:0};errorTarget=16;errorThreshold=1;maxDepth=30;displayActiveTiles=!1;onRootTileLoaded;rtcOffset=null;_root=null;_activeTiles=new Set;group;cameras=[];_cameraMap=new Map;_cameraInfo=[];_upRotationMatrix=new R;_ellipsoid;_bytesUsed=new WeakMap;_eventListeners=new Map;performanceStats={updateTime:0,traverseTime:0,markUsedTime:0,markVisibleTime:0,toggleTime:0,queueProcessTime:0};constructor(e=null){this.rootURL=e,this.lruCache=new mh,this.lruCache.unloadPriorityCallback=vh,this.loadQueue=new Bo,this.loadQueue.maxJobs=10,this.loadQueue.priorityCallback=Uh,this.processNodeQueue=new Bo,this.processNodeQueue.maxJobs=25,this.group=new d.Object3D,this.group.name="TilesRendererGroup"}get root(){return this._root}get loadProgress(){const{stats:e,isLoading:t}=this,a=e.downloading,r=e.inCacheSinceLoad+(t?1:0);return r===0?1:1-a/r}update(){const{lruCache:e,_usedSet:t,stats:a,loadQueue:r,processNodeQueue:i}=this;this.rootLoadingState===dr&&(this.rootLoadingState=Do,this.isLoading=!0,this._loadRootTileSet().then(c=>{if(this.rootLoadingState=Ba,this.rootTileSet=c,c.root){const f=this._getBasePath(this.rootURL||""),h=this.preprocessNode(c.root,f,null);this._root=h;const u=new Rr(h.boundingVolume),g=new Sr;u.getSphere(g);const p=new ge;if(u.getAABB(p),this.rtcOffset=new b(-g.center.x,-g.center.y,-g.center.z),this.onRootTileLoaded)try{this.onRootTileLoaded({center:g.center,radius:g.radius,boundingBox:p,rtcOffset:this.rtcOffset})}catch(m){console.warn("Failed to calculate bounding volume for root tile:",m)}}this.dispatchEvent({type:"load-tile-set",tileSet:c,url:this.rootURL})}).catch(c=>{this.rootLoadingState=fr,console.error("Failed to load root tileset:",c),this.dispatchEvent({type:"load-error",tile:null,error:c,url:this.rootURL})}));const n=this.root;if(!n)return;a.inFrustum=0,a.used=0,a.active=0,a.visible=0,this.frameCount++,t.forEach(c=>e.markUnused(c)),t.clear(),this.updateCameraInfo(),wn(n,this),So(n,this),xo(n,this),Fo(n,this);const o=this._queuedTiles;e.unloadPriorityCallback&&o.sort(e.unloadPriorityCallback);for(let c=0,f=o.length;c<f&&!e.isFull();c++)this.requestTileContents(o[c]);o.length=0,e.scheduleUnload(),(r.running||i.running)===!1&&this.isLoading===!0&&(this._cachedSinceLoadComplete.clear(),a.inCacheSinceLoad=0,this.dispatchEvent({type:"tiles-load-end"}),this.isLoading=!1)}traverse(e,t,a=!0){this.root&&ph(this.root,(r,i,n)=>(a&&this.ensureChildrenArePreprocessed(r,!0),e?e(r,i,n):!1),t)}registerPlugin(e){if(this.plugins.includes(e))return;const t=e.priority||0;let a=this.plugins.length;for(let r=0;r<this.plugins.length;r++)if((this.plugins[r].priority||0)>t){a=r;break}this.plugins.splice(a,0,e),e.init&&e.init(this)}unregisterPlugin(e){const t=this.plugins;let a;if(typeof e=="string"?a=t.find(r=>r.name===e):a=e,a&&t.includes(a)){const r=t.indexOf(a);return t.splice(r,1),a.dispose&&a.dispose(),!0}return!1}getPluginByName(e){return this.plugins.find(t=>t.name===e)||null}calculateTileViewError(e,t){const a=e.cached,r=this.cameras,i=this._cameraInfo,n=a.boundingVolume;if(!n){t.inView=!1,t.error=1/0,t.distanceFromCamera=1/0;return}let o=!1,l=-1/0,c=1/0,f=-1/0,h=1/0;const u=a.worldTransform;for(let g=0,p=r.length;g<p;g++){const m=i[g];let D,_;if(m.isOrthographic){const v=m.pixelSize;D=e.geometricError/v,_=1/0}else{const v=m.sseDenominator;_=n.distanceToPoint(m.position,u),D=_===0?1/0:e.geometricError/(_*v)}const B=i[g].frustum;n.intersectsFrustum(B,u)&&(o=!0,l=Math.max(l,D),c=Math.min(c,_)),f=Math.max(f,D),h=Math.min(h,_)}o?(t.inView=!0,t.error=l,t.distanceFromCamera=c):(t.inView=!1,t.error=f,t.distanceFromCamera=h)}updateCameraInfo(){this._updateCameraInfo()}_updateCameraInfo(){const e=this.cameras,t=this._cameraInfo,a=this._cameraMap;for(;t.length<e.length;)t.push({position:new b,frustum:new rs,isOrthographic:!1});for(let r=0;r<e.length;r++){const i=e[r],n=t[r],o=a.get(i);if(!o)continue;const l=i.transform.worldPosition;if(n.position.copyFrom(l),n.frustum=i.frustum,n.isOrthographic=i.type===ze.ortho,n.isOrthographic){const c=i.frustumSize;n.pixelSize=c/o.height}else{const f=i.fov*Math.PI/180;n.sseDenominator=2*Math.tan(f/2)/o.height}}}preprocessNode(e,t,a=null){if(this._processedTiles.has(e))return e;this._processedTiles.add(e);let r;if(e instanceof _o?r=e:r=new _o(e,a),r.content){const c=r.content;!("uri"in c)&&"url"in c&&(c.uri=c.url,delete c.url)}if(r.basePath=t,r.boundingVolume){const c=new Rr(r.boundingVolume);r.cached.boundingVolume=c}const i=new b(r.boundingVolume.box[0],r.boundingVolume.box[1],r.boundingVolume.box[2]),n=new R;if(r.transform){const c=r.transform;for(let f=0;f<16;f++)n.rawData[f]=c[f]}if(!a){n.copyFrom(this._upRotationMatrix);const c=new b;c.copyFrom(i),c.applyMatrix4(n);const f=r.cached.boundingVolume.box,h=[new b(f.min.x,f.min.y,f.min.z),new b(f.max.x,f.min.y,f.min.z),new b(f.min.x,f.max.y,f.min.z),new b(f.max.x,f.max.y,f.min.z),new b(f.min.x,f.min.y,f.max.z),new b(f.max.x,f.min.y,f.max.z),new b(f.min.x,f.max.y,f.max.z),new b(f.max.x,f.max.y,f.max.z)];for(const p of h)p.applyMatrix4(n);const u=new ge;h.forEach(p=>{u.expandByPoint(p)}),n.rawData[12]=-c.x,n.rawData[13]=-c.y,n.rawData[14]=-c.z;const g=u.min;n.rawData[13]-=g.y}const o=new R;o.copyFrom(n),a&&a.cached.worldTransform&&o.multiplyMatrices(a.cached.worldTransform,n);const l=new R;if(l.copyFrom(o),l.invert(),r.cached.transfrom=n,r.cached.worldTransform=o,r.cached.transformInverse=l,e.children&&e.children.length>0){r.children=[];for(let c=0;c<e.children.length;c++){const f=e.children[c],h=this.preprocessNode(f,t,r);r.children.push(h)}r.childrenProcessed=r.children.length}return r}ensureChildrenArePreprocessed(e,t=!1){const a=e.children;for(let r=0,i=a.length;r<i;r++){const n=a[r];n.basePath!==void 0&&n.basePath!==""||n.cached.boundingVolume||(t?(this.processNodeQueue.remove(n),this.preprocessNode(n,e.basePath,e)):this.processNodeQueue.has(n)||this.processNodeQueue.add(n,o=>{this.preprocessNode(o,e.basePath,e)}))}}_recordCacheHit(){this._cacheHits++}_recordCacheMiss(){this._cacheMisses++}resetCacheStats(){this._cacheHits=0,this._cacheMisses=0}requestTileContents(e){if(e.loadingState!==dr){this._recordCacheHit();return}if(this.lruCache.isFull()){this._recordCacheMiss();return}this._recordCacheMiss(),e.loadingState=Do,this.stats.downloading++;const t=e.content||e.contents&&e.contents[0];if(!t||!t.uri){e.loadingState=fr,this.stats.downloading--,this.stats.failed++;return}const a=e.basePath||"",r=t.uri,i=this._resolveURL(a,r);this.loadQueue.add(e,async n=>{try{await this.parseTileContent(n,r,i),this.stats.downloading--}catch(o){n.loadingState=fr,this.stats.downloading--,this.stats.failed++,console.error("Failed to load tile:",o)}})}async parseTileContent(e,t,a){e.loadingState=bh;const i=(l=>{const c=l.split(".");return c.length>1?c[c.length-1]:""})(t),n=a;let o=null;switch(i.toLowerCase()){case"b3dm":o=(await new At().load(n,zs,{onProgress:f=>{},onComplete:f=>{}})).data;break;case"i3dm":o=await A.res.loadI3DM(n,{onProgress:f=>{},onComplete:f=>{}});break;case"glb":case"gltf":o=await A.res.loadGltf(n,{onProgress:f=>{},onComplete:f=>{}});break;case"pnts":console.warn("PNTS format not yet supported");break;case"json":try{const f=await A.res.loadJSON(n);e.children.length=0,e.childrenProcessed=0;const h=this._getBasePath(n);if(f.root){const u=this.preprocessNode(f.root,h,e);e.children.push(u),e.childrenProcessed=1,this.dispatchEvent({type:"load-tile-set",tileSet:f,url:n})}e.loadingState=Ba;return}catch(f){console.error("Failed to load external tileset:",f),e.loadingState=fr,this.stats.failed++;return}break;default:console.warn(`Unknown tile format: ${i}`);break}if(o){e.cached.scene=o,e.loadingState=Ba;const l=this._estimateBytesUsed(o);this._bytesUsed.set(o,l),this.lruCache.setMemoryUsage(e,l),this.lruCache.has(e)||this.lruCache.add(e,c=>{if(c.cached.scene){const f=c.cached.scene;f.parent&&f.parent.object3D.removeChild(f),f.destroy(),c.cached.scene=null}c.loadingState=dr}),e.active&&this.setTileActive(e,!0)}else e.loadingState=fr,this.stats.failed++}markTileUsed(e){this._usedSet.add(e),this.lruCache.markUsed(e)}setTileActive(e,t){t?this._activeTiles.add(e):this._activeTiles.delete(e);const a=e.cached.scene;a&&(t?(this.group.entityChildren.includes(a)||(a.parent&&a.parent.object3D.removeChild(a),this.group.addChild(a)),e.cached.worldTransform&&this._applyWorldTransform(a.transform,e.cached.worldTransform),a.transform.enable=!0):a.transform.enable=!1)}setTileVisible(e,t){t?this._visibleTiles.add(e):this._visibleTiles.delete(e);const a=e.cached.scene;a&&(a.transform.enable=t)}queueTileForDownload(e){e.loadingState!==dr||this.lruCache.isFull()||this._queuedTiles.push(e)}dispatchEvent(e){const t=this._eventListeners.get(e.type);t&&t.forEach(a=>{try{a(e)}catch(r){console.error("Error in event listener:",r)}})}async _loadRootTileSet(){if(!this.rootURL)throw new Error("Root URL is not set");const e=await A.res.loadJSON(this.rootURL);return e.asset&&e.asset.gltfUpAxis&&this._setupUpAxisRotation(e.asset.gltfUpAxis),e}_setupUpAxisRotation(e){const t=new R;switch(e.toLowerCase()){case"x":t.makeRotationAxis(b.Y_AXIS,-Math.PI/2);break;case"y":t.identity();break;case"z":t.makeRotationAxis(b.X_AXIS,-Math.PI/2);break;default:console.warn(`Unknown gltfUpAxis: ${e}, using default`),t.identity();break}this._upRotationMatrix=t}_applyLocalTransform(e,t){const a=t.decompose(Wt.EULER_ANGLES);e.localPosition=a[0];const r=new Z;r.fromEulerAngles(a[1].x,a[1].y,a[1].z),e.localRotQuat=r,e.localScale=a[2]}_applyWorldTransform(e,t){const a=t.decompose(Wt.EULER_ANGLES);e.localPosition=a[0];const r=new Z;r.fromEulerAngles(a[1].x,a[1].y,a[1].z),e.localRotQuat=r,e.localScale=a[2]}_getBasePath(e){const t=e.lastIndexOf("/");return t!==-1?e.substring(0,t):""}_resolveURL(e,t){return t.startsWith("http://")||t.startsWith("https://")?t:e+"/"+t}_getUrlExtension(e){const t=e.split(".");return t.length>1?t[t.length-1]:""}getMemoryStats(){const e=this.lruCache.getStats(),t=this.lruCache.maxBytesSize,a=e.bytes,r=t-a,i=this._cacheHits+this._cacheMisses,n=i>0?this._cacheHits/i:0;return{totalTiles:e.size,loadedTiles:e.usedCount,cachedTiles:e.size,totalBytes:t,usedBytes:a,freeBytes:r,cacheHitRate:n}}getLoadedTiles(){const e=[];return this.traverse(t=>(t.loadingState===Ba&&e.push(t),!1),null),e}getVisibleTiles(){return Array.from(this._visibleTiles)}getActiveTiles(){return Array.from(this._activeTiles)}getTileTreeStats(){let e=0,t=0,a=0,r=0,i=0,n=0;return this.traverse(o=>(e++,o.loadingState===Ba&&t++,o.visible&&a++,o.active&&r++,i=Math.max(i,o.depth),n+=o.depth,!1),null),{totalTiles:e,loadedTiles:t,visibleTiles:a,activeTiles:r,maxDepth:i,averageDepth:e>0?n/e:0}}printDebugInfo(){const e=this.stats,t=this.getMemoryStats(),a=this.getTileTreeStats(),r=this.performanceStats,i=this.lruCache.getStats();console.log("=== TilesRenderer Debug Info ==="),console.log("Stats:",e),console.log("Memory:",t),console.log("Tree:",a),console.log("Performance:",r),console.log("Cache:",i),console.log("Queues:",{load:this.loadQueue.getStats(),process:this.processNodeQueue.getStats()})}setPerformanceOptions(e){e.lruCacheMinSize!==void 0&&(this.lruCache.minSize=e.lruCacheMinSize),e.lruCacheMaxSize!==void 0&&(this.lruCache.maxSize=e.lruCacheMaxSize),e.lruCacheMinBytes!==void 0&&(this.lruCache.minBytesSize=e.lruCacheMinBytes),e.lruCacheMaxBytes!==void 0&&(this.lruCache.maxBytesSize=e.lruCacheMaxBytes),e.lruCacheUnloadPercent!==void 0&&(this.lruCache.unloadPercent=e.lruCacheUnloadPercent),e.downloadQueueMaxJobs!==void 0&&(this.loadQueue.maxJobs=e.downloadQueueMaxJobs),e.parseQueueMaxJobs!==void 0&&(this.loadQueue.maxJobs=e.parseQueueMaxJobs),e.processQueueMaxJobs!==void 0&&(this.processNodeQueue.maxJobs=e.processQueueMaxJobs),e.enablePerformanceStats!==void 0&&(this._enablePerformanceStats=e.enablePerformanceStats),e.enableCacheStats!==void 0&&(this._enableCacheStats=e.enableCacheStats)}dispose(){[...this.plugins].forEach(t=>this.unregisterPlugin(t)),this.lruCache.clear(),this.loadQueue.clear(),this.processNodeQueue.clear(),this._root=null,this.rootTileSet=null,this.rootLoadingState=dr,this.frameCount=0,this.isLoading=!1,this.resetCacheStats(),this.group.destroy()}setCamera(e,t,a){this.cameras.includes(e)||this.cameras.push(e),this._cameraMap.set(e,{width:t,height:a}),this._updateCameraInfo()}deleteCamera(e){const t=this.cameras.indexOf(e);t!==-1&&this.cameras.splice(t,1),this._cameraMap.delete(e),this._updateCameraInfo()}setResolution(e,t,a){const r=this._cameraMap.get(e);r?(r.width=t,r.height=a):this._cameraMap.set(e,{width:t,height:a}),this._updateCameraInfo()}forEachLoadedModel(e){this.traverse(t=>(t.loadingState===Ba&&t.cached.scene&&e(t.cached.scene,t),!1),null)}_estimateBytesUsed(e){let t=0;return e.forChild(a=>{const r=a.getComponent(d.MeshRenderer);r&&r.geometry&&(t+=1024),r&&r.material&&(t+=512)}),t}addEventListener(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]),this._eventListeners.get(e).push(t)}removeEventListener(e,t){const a=this._eventListeners.get(e);if(a){const r=a.indexOf(t);r!==-1&&a.splice(r,1)}}async loadTileSet(e,t){const r=(e.endsWith("/")?e.slice(0,-1):e)+"/"+t;this.rootURL=r}get modelList(){const e=[];return this.forEachLoadedModel(t=>{e.push(t)}),e}}class qg{asset;extras;geometricError;properties;refine;root;extensionsUsed;extensionsRequired;extensions}class $g{boundingVolume;children;geometricError;transform;content;contents;refine;extensions;extras}class em{boundingVolume;geometricError;refine;content;contents;children;transform;extensions;extras}class tm{uri;group;metadata}class am{class;properties}function rm(s,e){let t=0,a=null;return function(...r){const i=Date.now(),n=i-t;n>=e?(t=i,s.apply(this,r)):(a!==null&&clearTimeout(a),a=window.setTimeout(()=>{t=Date.now(),s.apply(this,r),a=null},e-n))}}class im extends ut{static count=0;constructor(){super(),J.register("ColorLitShader",ed),this.shader=new it;let e=new Ne("ColorLitShader","ColorLitShader");e.passType=H.COLOR,this.shader.addRenderPass(e),e.setDefine("USE_BRDF",!0),e.setShaderEntry("VertMain","FragMain"),e.setUniformColor("baseColor",new O),e.setUniformColor("emissiveColor",new O),e.setUniformFloat("envIntensity",1),e.setUniformFloat("normalScale",1),e.setUniformFloat("roughness",0),e.setUniformFloat("metallic",0),e.setUniformFloat("ao",1),e.setUniformFloat("alphaCutoff",0);let t=e.shaderState;t.acceptShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,e.setTexture("normalMap",A.res.normalTexture),e.setTexture("emissiveMap",A.res.blackTexture)}clone(){return null}debug(){}}class nm extends ut{constructor(){super(),this.shader=new d.FatLineShader,this.transparent=!0}setInstanceBuffer(e){this.shader.setStorageBuffer("instances",e)}setModelMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set lineWidth(e){this.shader.setUniformFloat("lineWidth",e)}get lineWidth(){return this.shader.getUniformFloat("lineWidth")}set opacity(e){this.shader.setUniformFloat("opacity",e)}get opacity(){return this.shader.getUniformFloat("opacity")}set resolution(e){this.shader.setUniformVector2("resolution",e)}get resolution(){return this.shader.getUniformVector2("resolution")}}class sm extends ut{constructor(){super();let e=new Ne("LambertShader","LambertShader");e.setShaderEntry("VertMain","FragMain"),e.passType=H.COLOR,e.setUniformVector4("transformUV1",new $(0,0,1,1)),e.setUniformVector4("transformUV2",new $(0,0,1,1)),e.setUniformColor("baseColor",new O(1,1,1,1)),e.setUniformFloat("alphaCutoff",.5);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1;let a=new it;a.addRenderPass(e),this.shader=a,this.baseMap=A.res.grayTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}function om(s,e){}class lm extends ut{constructor(){super(),this.shader=new d.UnLitTexArrayShader,this.baseMap=A.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set shadowMap(e){}}class ko{clipName;loopTime;startTime;stopTime;sampleRate;useSkeletonPos;useSkeletonScale;positionCurves=new Map;rotationCurves=new Map;scaleCurves=new Map;floatCurves=new Map;formBytes(e){if(this.clipName=e.readUTF(),this.loopTime=!e.readInt32(),this.startTime=e.readFloat32(),this.stopTime=e.readFloat32(),this.sampleRate=e.readInt32(),this.useSkeletonPos=e.readInt32()>0,this.useSkeletonScale=e.readInt32()>0,this.useSkeletonPos){let r=e.readInt32();for(let i=0;i<r;i++){let n=new ur;n.formBytes(e),this.positionCurves.set(n.path,n)}}let t=e.readInt32();for(let r=0;r<t;r++){let i=new ur;i.formBytes(e),this.rotationCurves.set(i.path,i)}if(this.useSkeletonScale){let r=e.readInt32();for(let i=0;i<r;i++){let n=new ur;n.formBytes(e),this.scaleCurves.set(n.path,n)}}let a=e.readInt32();for(let r=0;r<a;r++){let i=new ur;i.formBytes(e),this.floatCurves.set(i.attribute,i)}}}class ur{path;attribute;propertys;preInfinity;postInfinity;rotationOrder;m_curves;k=0;_cacheValue;_kValue;constructor(e=1){this.k=e,this.m_curves=[],this.check()}check(){for(let e=0;e<this.k;e++)this.m_curves[e]||=new Ri;switch(this.k){case 1:this._cacheValue=0;break;case 2:this._cacheValue=new K;break;case 3:this._cacheValue=new b;break;case 4:this._cacheValue=new $;break}}get totalTime(){return this.m_curves[0].totalTime}addKeyFrame(e){for(let t=0;t<this.k;t++)this.m_curves[t].addKeyFrame(e.getK(t))}removeKeyFrame(e){for(let t=0;t<this.k;t++)this.m_curves[t].removeKeyFrame(e.getK(t))}getValue(e){switch(this.k){case 1:this._cacheValue=this.m_curves[0].getValue(e);break;case 2:this._cacheValue.x=this.m_curves[0].getValue(e),this._cacheValue.y=this.m_curves[1].getValue(e);break;case 3:this._cacheValue.x=this.m_curves[0].getValue(e),this._cacheValue.y=this.m_curves[1].getValue(e),this._cacheValue.z=this.m_curves[2].getValue(e);break;case 4:const t=this.m_curves[0].getCurveFramesExtent(e),a=t.lhsIndex,r=t.rhsIndex;e=t.time;let i=this.m_curves[0].getKey(a),n=this.m_curves[0].getKey(r);e%=this.m_curves[0].totalTime;let o=(e-i.time)/(n.time-i.time);Z.HELP_0.set(this.m_curves[0].getKey(a).value,this.m_curves[1].getKey(a).value,this.m_curves[2].getKey(a).value,this.m_curves[3].getKey(a).value),Z.HELP_1.set(this.m_curves[0].getKey(r).value,this.m_curves[1].getKey(r).value,this.m_curves[2].getKey(r).value,this.m_curves[3].getKey(r).value),Z.HELP_2.slerp(Z.HELP_0,Z.HELP_1,o),this._cacheValue.x=Z.HELP_2.x,this._cacheValue.y=Z.HELP_2.y,this._cacheValue.z=Z.HELP_2.z,this._cacheValue.w=Z.HELP_2.w;break}return this._cacheValue}getKeyCount(){return this.m_curves[0].getKeyCount()}getKey(e){let t=[];for(let a=0;a<this.k;a++)t.push(this.m_curves[a].getKey(e));return t}formBytes(e){this.path=e.readUTF(),this.k=e.readInt32(),this.check(),this.attribute=e.readUTF(),this.propertys=this.attribute.split("."),this.preInfinity=e.readInt32(),this.postInfinity=e.readInt32(),this.rotationOrder=e.readInt32();let t=e.readInt32();for(let a=0;a<t;a++){let r=new ji(0);r.formBytes(e),this.addKeyFrame(r)}}}class cm extends Map{negtive;constructor(e){if(super(e),this.negtive=new Map,e)for(let t of e)this.negtive.set(t[1],t[0])}delete(e){if(this.has(e)){let t=this.get(e);return this.negtive.delete(t),super.delete(e)}return!1}getKey(e){return this.negtive.get(e)}deleteValue(e){let t=this.negtive.get(e);return t&&this.delete(t),this.negtive.delete(e)}set(e,t){return super.set(e,t),this.negtive.set(t,e),this}clear(){this.negtive.clear(),super.clear()}}class fm{colorArray;constructor(e){this.colorArray=e}getColor(e){let t=e*this.colorArray.length,a=Math.floor(t),r=Math.min(a+1,this.colorArray.length-1),i=this.colorArray[a],n=this.colorArray[r];return O.lerp(t-a,i,n)}}class In{controlVertices;constructor(e){this.setControlVertices(e)}setControlVertices(e){e.length==4&&(this.controlVertices=e.concat())}getPoint(e){if(!(e>=0&&e<=1))return b.ZERO;let t=1-e,a=t*t*t,r=3*e*t*t,i=3*e*e*t,n=e*e*e;return this.controlVertices[0].mul(a).add(this.controlVertices[1].mul(r)).add(this.controlVertices[2].mul(i)).add(this.controlVertices[3].mul(n))}getTangent(e){if(!(e>=0&&e<=1))return b.ZERO;let t=this.controlVertices,a=t[0].add(t[1].add(t[0]).mul(e)),r=t[1].add(t[2].add(t[1]).mul(e)),i=t[2].add(t[3].add(t[2]).mul(e)),n=a.add(r.subtract(a).mul(e));return r.add(i.subtract(r).mul(e)).subtract(n)}getClosestParam(e,t=1e-6){return this.getClosestParamRec(e,0,1,t)}getClosestParamRec(e,t,a,r){let i=(t+a)/2;if(a-t<r)return i;let n=(t+i)/2,o=(i+a)/2,l=this.getPoint(n),c=this.getPoint(o),f=l.subtract(e).lengthSquared,h=c.subtract(e).lengthSquared;return f<h?a=i:t=i,this.getClosestParamRec(e,t,a,r)}}var yh=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(yh||{});class dm{type=0;numCurveSegments=0;numControlVertices=0;controlVertices=[];constructor(e,t=0){this.setControlVertices(e,t)}getPathType(){return this.type}isClosed(){return this.type==1}isValid(){return this.numCurveSegments>0}clear(){this.controlVertices.length=0,this.type=0,this.numCurveSegments=0,this.numControlVertices=0}computeApproxLength(){if(!this.isValid())return 0;let e=this.numCurveSegments+1;if(e<2)return 0;let t=0,a=this.controlVertices;for(let r=1;r<e;r++){let i=a[(r-1)*3],n=a[r*3];t+=i.subtract(n).lengthSquared}return t==0?0:t}computeApproxParamPerUnitLength(){let e=this.computeApproxLength();return this.numCurveSegments/e}computeApproxNormParamPerUnitLength(){return 1/this.computeApproxLength()}interpolatePoints(e,t){let a=e.length;a<2&&console.error("point count must great 1"),this.clear(),this.type=t;let r=this.controlVertices;switch(t){case 0:{this.numCurveSegments=a-1,this.numControlVertices=3*a-2,r.length=this.numControlVertices;for(let o=0;o<a;o++)r[o*3]=e[o];let i=e[1].subtract(e[0]).mul(.25);r[1]=e[0].add(i);let n=e[a-2].subtract(e[a-1]).mul(.25);r[this.numControlVertices-2]=e[a-1].add(n);for(let o=1;o<this.numCurveSegments;o++){let l=e[o-1].subtract(e[o]),c=e[o+1].subtract(e[o]),f=l.lengthSquared,h=c.lengthSquared;if(f>0&&h>0){let u=(f+h)/8,g=c.div(h).subtract(l.div(f));g.normalize(),g=g.mul(u),r[o*3-1]=e[o].subtract(g),r[o*3+1]=e[o].add(g)}else r[o*3-1]=e[o],r[o*3+1]=e[o]}break}case 1:{this.numCurveSegments=a,this.numControlVertices=3*a+1,r.length=this.numControlVertices;for(let i=0;i<a;i++)r[i*3]=e[i];r[this.numControlVertices-1]=e[0];for(let i=1;i<=this.numCurveSegments;i++){let n=i-1,o=(i+1)%this.numCurveSegments,l=i%this.numCurveSegments,c=e[n].subtract(e[l]),f=e[o].subtract(e[l]),h=c.lengthSquared,u=f.lengthSquared,g=3*i-1,p=(3*i+1)%(this.numControlVertices-1);if(h>0&&u>0){let m=(h+u)/8,D=f.div(u).subtract(c.div(h));D.normalize(),D=D.mul(m),r[g]=e[l].subtract(D),r[p]=e[l].add(D)}else r[g]=e[l],r[p]=e[l]}break}}}setControlVertices(e,t){let a=e.length;a<=0||t==0&&a<4||t==1&&a<7||(a-1)%3==0&&(this.clear(),this.type=t,this.numControlVertices=a,this.numCurveSegments=(a-1)/3,this.controlVertices=e)}getPoint(e){if(this.type==1){for(;e<0;)e+=this.numCurveSegments;for(;e>this.numCurveSegments;)e-=this.numCurveSegments}else e=vt.clampf(e,0,this.numCurveSegments);if(!(e>=0)&&e<=this.numCurveSegments)return;let t=Math.floor(e);t>=this.numCurveSegments&&(t=this.numCurveSegments-1);let a=[],r=this.controlVertices;return a[0]=r[3*t+0],a[1]=r[3*t+1],a[2]=r[3*t+2],a[3]=r[3*t+3],new In(a).getPoint(e-t)}getPointNorm(e){return this.getPoint(e*this.numCurveSegments)}getTangent(e){if(this.type==1){for(;e<0;)e+=this.numCurveSegments;for(;e>this.numCurveSegments;)e-=this.numCurveSegments}else e=vt.clampf(e,0,this.numCurveSegments);if(!(e>=0)&&e<=this.numCurveSegments)return;let t=Math.floor(e);t>=this.numCurveSegments&&(t=this.numCurveSegments-1);let a=this.controlVertices,r=[];return r[0]=a[3*t+0],r[1]=a[3*t+1],r[2]=a[3*t+2],r[3]=a[3*t+3],new In(r).getTangent(e-t)}getTangentNorm(e){return this.getTangent(e*this.numCurveSegments)}computeClosestParam(e,t){let a=Number.MAX_SAFE_INTEGER,r=0,i=[],n=new In(i);for(let o=0;o<this.controlVertices.length-1;o+=3){for(let h=0;h<4;h++)i[h]=this.controlVertices[o+h];n.setControlVertices(i);let l=n.getClosestParam(e,t),f=n.getPoint(l).subtract(e).lengthSquared;f<a&&(a=f,r=o/3+l)}return r}computeClosestNormParam(e,t){return this.computeClosestParam(e,t*this.numCurveSegments)}}class hm extends Map{valueList;keyList;isChange=!0;constructor(e,t,a){if(super(e),t&&(this.keyList=[]),a&&(this.valueList=[]),e)for(let r of e)this.valueList?.push(r[1]),this.keyList?.push(r[0])}delete(e){if(this.has(e)){let t=this.get(e);return this.valueList&&this.deleteValue(t),this.keyList&&this.deleteKey(e),this.isChange=!0,super.delete(e)}return!1}deleteValue(e){let t=this.valueList.indexOf(e);return t>=0&&this.valueList.splice(t,1),this}deleteKey(e){let t=this.keyList.indexOf(e);return t>=0&&this.keyList.splice(t,1),this}set(e,t){return this.delete(e),this.keyList?.push(e),this.valueList?.push(t),super.set(e,t),this.isChange=!0,this}clear(){this.valueList&&(this.valueList.length=0),this.keyList&&(this.keyList.length=0),this.isChange=!0,super.clear()}}var Ch=(s=>(s[s.kParticleSystemClampVelocityCurveId=322376503]="kParticleSystemClampVelocityCurveId",s[s.kParticleSystemForceCurveId=306581307]="kParticleSystemForceCurveId",s[s.kParticleSystemRotationCurveId=1793934638]="kParticleSystemRotationCurveId",s[s.kParticleSystemRotationBySpeedCurveId=3737431713]="kParticleSystemRotationBySpeedCurveId",s[s.kParticleSystemStartSpeedCurveId=2527743459]="kParticleSystemStartSpeedCurveId",s[s.kParticleSystemSizeCurveId=2368504881]="kParticleSystemSizeCurveId",s[s.kParticleSystemSizeBySpeedCurveId=4085612399]="kParticleSystemSizeBySpeedCurveId",s[s.kParticleSystemVelocityCurveId=3774601268]="kParticleSystemVelocityCurveId",s[s.kParticleSystemUVCurveId=326370691]="kParticleSystemUVCurveId",s[s.kParticleSystemColorGradientId=1494990940]="kParticleSystemColorGradientId",s[s.kParticleSystemColorByVelocityGradientId=1089181156]="kParticleSystemColorByVelocityGradientId",s[s.kParticleSystemMeshSelectionId=3159510623]="kParticleSystemMeshSelectionId",s[s.kParticleSystemUVRowSelectionId=2941263940]="kParticleSystemUVRowSelectionId",s))(Ch||{});const um=3.141592653589793;class bm{}function Sh(s,e,t){let a=.3333333333333333,r=.5,i=s*a,n=i*i,l=n*i-i*e*r+t*r,c=-n+e*a,f=c*c*c,h=f+l*l;if(h>=0){let p=Math.sqrt(h)-l;return p=p>0?Math.pow(p,a):-Math.pow(-p,a),-i-c/p+p}let u=Math.sqrt(-f),g=Math.acos(-l/u);return u=Math.pow(u,a),u=u-c/u,g=-i+u*Math.cos(g*a),g}function Qn(s,e,t,a){let r=1e-5;if(Math.abs(s)<r)return Math.abs(e)>r?(a.r0=-t/e,1):0;let i=e*e-4*s*t;if(i<0)return 0;let n=.5/s,o=Math.sqrt(i);return a.r0=(o-e)*n,a.r1=(-o-e)*n,2}function xh(s,e,t,a,r){let i=0;if(Math.abs(e)>=1e-4){let n=t/e,o=a/e,l=r/e;s[0]=Sh(n,o,l),i++;let c=e,f=t+e*s[0],h=a+t*s[0]+e*s[0]*s[0];i+=Qn(c,f,h,{r0:s[1],r1:s[2]})}else i+=Qn(t,a,r,{r0:s[1],r1:s[2]});return i}class Ua{coeff=[];static EvalSegment(e,t){return e*(e*(e*t[0]+t[1])+t[2])+t[3]}}class Wa{static kMaxNumSegments=8;segments=[];integrationCache=[];doubleIntegrationCache=[];times=[];segmentCount;constructor(){this.segments[Wa.kMaxNumSegments]=new Ua,this.integrationCache[Wa.kMaxNumSegments]=0,this.doubleIntegrationCache[Wa.kMaxNumSegments]=0,this.times[Wa.kMaxNumSegments]=0}calculateMinMax(e,t){e.x=Math.min(e.x,t),e.y=Math.max(e.y,t)}findMinMaxDoubleIntegrated(){let e=K.ZERO.clone(),t=20,a=1/t,r=a;for(let i=0;i<t;i++)this.calculateMinMax(e,this.evaluateDoubleIntegrated(r)),r+=a;return e}findMinMaxIntegrated(){let e=K.ZERO.clone(),t=[],a=[];for(let r=0;r<this.segmentCount;r++){let i=4*this.segments[r].coeff[0],n=3*this.segments[r].coeff[1],o=2*this.segments[r].coeff[2],l=1*this.segments[r].coeff[3],c=[],f=xh(c,i,n,o,l);for(let h=0;h<f;h++){let u=c[h]+t[r];u>=t[r]&&u<a[r]&&this.calculateMinMax(e,this.evaluateIntegrated(u))}this.calculateMinMax(e,this.evaluateIntegrated(a[r])),this.times[r]}return e}generateIntegrationCache(e){e.integrationCache[0]=0;let t=e.times[0],a=0;for(let r=1;r<e.segmentCount;r++){let i=e.segments[r-1].coeff;Eo(i);let n=t-a;e.integrationCache[r]=e.integrationCache[r-1]+Ua.EvalSegment(n,i)*n,a=t,t=e.times[r]}}generateDoubleIntegrationCache(e){let t=0,a=0;for(let r=0;r<e.segmentCount;r++){e.doubleIntegrationCache[r]=t;let i=e.times[r]-a;i=Math.max(i,0),t+=Ua.EvalSegment(i,e.segments[r].coeff)*i*i+e.integrationCache[r]*i,a=e.times[r]}}integrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)Eo(this.segments[e].coeff)}doubleIntegrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)Fh(this.segments[e].coeff);this.generateDoubleIntegrationCache(this)}static isValidCurve(e){let t=e.getKeyCount(),a=t-1;return e.getKey(0).time!=0&&a++,e.getKey(t-1).time!=1&&a++,a<=Wa.kMaxNumSegments}evaluateDoubleIntegrated(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a]){let r=e-t;return this.doubleIntegrationCache[a]+this.integrationCache[a]*r+Ua.EvalSegment(r,this.segments[a].coeff)*r*r}t=this.times[a]}return 1}evaluateIntegrated(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a]){let r=e-t;return this.integrationCache[a]+Ua.EvalSegment(r,this.segments[a].coeff)*r}t=this.times[a]}return 1}evaluate(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a])return Ua.EvalSegment(e-t,this.segments[a].coeff);t=this.times[a]}return 1}buildCurve(e,t){let a=e.getKeyCount();this.segmentCount=1;let r=1.01;if(this.segments.length=0,this.integrationCache.length=0,this.doubleIntegrationCache.length=0,this.times.length=0,this.times[0]=r,a!=0)if(a==1)this.segments[0]=new Ua,this.segments[0].coeff[3]=e.getKey(0).value*t;else{this.segmentCount=a-1;let i=0;e.getKey(0).time!=0&&(this.segments[0].coeff[3]=e.getKey(0).value,this.times[0]=e.getKey(0).time,i=1);for(let n=0;n<this.segmentCount;n++){let o;e.calculateCacheData(o,n,n+1,0),this.segments[n+i].coeff=o.coeff.concat(),this.times[n+i]=e.getKey(n+1).time}this.segmentCount+=i,e.getKey(a-1).time!=1&&(this.segments[this.segmentCount].coeff[3]=e.getKey(a-1).value,this.segmentCount++),this.times[this.segmentCount-1]=r;for(let n=0;n<this.segmentCount;n++)this.segments[n].coeff[0]*=t,this.segments[n].coeff[1]*=t,this.segments[n].coeff[2]*=t,this.segments[n].coeff[3]*=t}return!0}}function Fh(s){s[0]/=20,s[1]/=12,s[2]/=6,s[3]/=2}function Eo(s){s[0]/=4,s[1]/=3,s[2]/=2,s[3]/=1}var kh=(s=>(s[s.kEMScalar=0]="kEMScalar",s[s.kEMOptimized=1]="kEMOptimized",s[s.kEMOptimizedMinMax=2]="kEMOptimizedMinMax",s[s.kEMSlow=3]="kEMSlow",s))(kh||{}),Eh=(s=>(s[s.kMMCScalar=0]="kMMCScalar",s[s.kMMCCurve=1]="kMMCCurve",s[s.kMMCTwoCurves=2]="kMMCTwoCurves",s[s.kMMCTwoConstants=3]="kMMCTwoConstants",s))(Eh||{});class gm{max;min}class mm{max;min;integrate(){this.max.integrate(),this.min.integrate()}doubleIntegrate(){this.max.doubleIntegrate(),this.min.doubleIntegrate()}findMinMaxIntegrated(){return null}findMinMaxDoubleIntegrated(){return null}}class Rh{minMaxState;minCurve;maxCurve;_scalar=1;_minScalar;constructor(e=1){this._scalar=e,this.minMaxState=0,this.minCurve=new Ri,this.maxCurve=new Ri}setScalar(e){this._scalar=e}getScalar(){return this._scalar}static evaluateSlow(e,t,a){let r=e.maxCurve.getValue(t)*e.getScalar();return e.minMaxState==2?Ar(e.minCurve.getValue(t)*e.getScalar(),r,a):r}static evaluate(e,t,a=1){if(e.minMaxState==0)return e.getScalar();let r=e.maxCurve.getValue(t)*e.getScalar();return e.minMaxState==1?Ar(e.minCurve.getValue(t)*e.getScalar(),r,a):e.minMaxState==3?Ar(e._minScalar,e._scalar,a):e.minMaxState==2?Ar(e.minCurve.getValue(t)*e.getScalar(),r,1*Math.random()):this.evaluateSlow(e,t,1)}unSerialized(e){this.minMaxState=e.minMaxState,this._scalar=e.scalar,this._minScalar=e.minScalar,this.maxCurve.unSerialized(e.maxCurve),this.minCurve.unSerialized(e.minCurve)}}class pm{value=0;mode=0;spread=0;speed=new Rh;unSerialized(e){this.value=e.value,this.mode=e.mode,this.spread=e.spread,this.speed.unSerialized(e.speed)}}function Am(s,e){let t=Wa.isValidCurve(s.max);return e!=2&&e!=3?t:t&&Wa.isValidCurve(s.min)}function Dm(s,e,t,a){s.max.buildCurve(e.max,t),a!=2&&a!=3?s.min.buildCurve(e.max,t):s.min.buildCurve(e.min,t)}function _m(s,e){let t=e.getKeyCount();if(t!=0)if(t==1)Ji(s,e.getKey(0).value);else{let a=t-1;Ji(s,e.getKey(0).value);for(let r=0;r<a;r++){let i=new ao;e.calculateCacheData(i,r,r+1,0);let n=3*i.coeff[0],o=2*i.coeff[1],l=1*i.coeff[2],c=e.getKey(r).time,f=e.getKey(r+1).time,h=[],u=Qn(n,o,l,{r0:h[0],r1:h[1]});for(let g=0;g<u;g++)h[g]>=0&&h[g]+c<f&&Ji(s,Ua.EvalSegment(h[g],i.coeff));Ji(s,Ua.EvalSegment(f-c,i.coeff))}}}function Ji(s,e){s.x=Math.min(s.x,e),s.y=Math.max(s.y,e)}class wr{static BACK=0;static FRONT=1;static IN=0;static OUT=1;static INTERSECT=2}class wh{a;b;c;d;static ALIGN_ANY=0;static ALIGN_XY_AXIS=1;static ALIGN_YZ_AXIS=2;static ALIGN_XZ_AXIS=3;constructor(e=0,t=0,a=0,r=0){this.a=e,this.b=t,this.c=a,this.d=r}setTo(e=0,t=0,a=0,r=0){this.a=e,this.b=t,this.c=a,this.d=r}fromPoints(e,t,a){var r=t.x-e.x,i=t.y-e.y,n=t.z-e.z,o=a.x-e.x,l=a.y-e.y,c=a.z-e.z;this.a=i*c-n*l,this.b=n*o-r*c,this.c=r*l-i*o,this.d=-(this.a*e.x+this.b*e.y+this.c*e.z)}fromNormalAndPoint(e,t){this.a=e.x,this.b=e.y,this.c=e.z,this.d=-(this.a*t.x+this.b*t.y+this.c*t.z)}normalize(){var e=Math.sqrt(this.a*this.a+this.b*this.b+this.c*this.c);if(e>0){var t=1/e;this.a*=t,this.b*=t,this.c*=t,this.d*=t}return e}distance(e){return this.a*e.x+this.b*e.y+this.c*e.z+this.d}classifyPoint(e,t=.01){var a=this.distance(e);return a<-t?wr.BACK:a>t?wr.FRONT:wr.INTERSECT}toString(){return"Plane3D [a:"+this.a+", b:"+this.b+", c:"+this.c+", d:"+this.d+"]"}}function Bm(s,e){return Math.random()*e+Math.random()*s+(e-s)*Math.random()}function Um(s,e,t){let a=t*Math.random();return Math.random()*e*a+Math.random()*s*a+(e-s)*Math.random()*a}function Ih(s,e,t){let a=0,r=0;for(;a===0;)a=Math.random();for(;r===0;)r=Math.random();let i=Math.sqrt(-2*Math.log(a))*Math.cos(2*Math.PI*r);return i=i/10+.5,(i>1||i<0)&&(i=Ih(s,e,t)),i=Math.pow(i,t),i*=e-s,i+=s,i}function fa(s){return s>0?Math.floor(s):Math.floor(s)-1}let ce=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];function Ro(s,e){let t=s&15,a=1+(t&7);return t&8&&(a=-a),a*e}function Tn(s,e,t){let a=s&7,r=a<4?e:t,i=a<4?t:e;return(a&1?-r:r)+(a&2?-2*i:2*i)}function Wi(s,e,t,a){let r=s&15,i=r<8?e:t,n=r<4?t:r==12||r==14?e:a;return(r&1?-i:i)+(r&2?-n:n)}function li(s,e,t,a,r){let i=s&31,n=i<24?e:t,o=i<16?t:a,l=i<8?a:r;return(i&1?-n:n)+(i&2?-o:o)+(i&4?-l:l)}let Lt=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]];function vm(s){let e=fa(s),t=e+1,a=s-e,r=a-1,i,n,o=1-a*a;o*=o,i=o*o*Ro(ce[e&255],a);let l=1-r*r;return l*=l,n=l*l*Ro(ce[t&255],r),.25*(i+n)}function ym(s,e){const t=.366025403,a=.211324865;let r,i,n,o=(s+e)*t,l=s+o,c=e+o,f=fa(l),h=fa(c),u=(f+h)*a,g=f-u,p=h-u,m=s-g,D=e-p,_,B;m>D?(_=1,B=0):(_=0,B=1);let v=m-_+a,C=D-B+a,y=m-1+2*a,F=D-1+2*a,k=f&255,w=h&255,x=.5-m*m-D*D;x<0?r=0:(x*=x,r=x*x*Tn(ce[k+ce[w]],m,D));let M=.5-v*v-C*C;M<0?i=0:(M*=M,i=M*M*Tn(ce[k+_+ce[w+B]],v,C));let N=.5-y*y-F*F;return N<0?n=0:(N*=N,n=N*N*Tn(ce[k+1+ce[w+1]],y,F)),40*(r+i+n)}function Cm(s,e,t){const a=.333333333,r=.166666667;let i,n,o,l,c=(s+e+t)*a,f=s+c,h=e+c,u=t+c,g=fa(f),p=fa(h),m=fa(u),D=(g+p+m)*r,_=g-D,B=p-D,v=m-D,C=s-_,y=e-B,F=t-v,k,w,x,M,N,Q;C>=y?y>=F?(k=1,w=0,x=0,M=1,N=1,Q=0):C>=F?(k=1,w=0,x=0,M=1,N=0,Q=1):(k=0,w=0,x=1,M=1,N=0,Q=1):y<F?(k=0,w=0,x=1,M=0,N=1,Q=1):C<F?(k=0,w=1,x=0,M=0,N=1,Q=1):(k=0,w=1,x=0,M=1,N=1,Q=0);let G=C-k+r,X=y-w+r,ne=F-x+r,q=C-M+2*r,he=y-N+2*r,Be=F-Q+2*r,ae=C-1+3*r,ee=y-1+3*r,se=F-1+3*r,Ae=g&255,Ue=p&255,Se=m&255,Te=.6-C*C-y*y-F*F;Te<0?i=0:(Te*=Te,i=Te*Te*Wi(ce[Ae+ce[Ue+ce[Se]]],C,y,F));let ve=.6-G*G-X*X-ne*ne;ve<0?n=0:(ve*=ve,n=ve*ve*Wi(ce[Ae+k+ce[Ue+w+ce[Se+x]]],G,X,ne));let Me=.6-q*q-he*he-Be*Be;Me<0?o=0:(Me*=Me,o=Me*Me*Wi(ce[Ae+M+ce[Ue+N+ce[Se+Q]]],q,he,Be));let Ut=.6-ae*ae-ee*ee-se*se;return Ut<0?l=0:(Ut*=Ut,l=Ut*Ut*Wi(ce[Ae+1+ce[Ue+1+ce[Se+1]]],ae,ee,se)),32*(i+n+o+l)}function Sm(s,e,t,a){const r=.309016994,i=.138196601;let n,o,l,c,f,h=(s+e+t+a)*r,u=s+h,g=e+h,p=t+h,m=a+h,D=fa(u),_=fa(g),B=fa(p),v=fa(m),C=(D+_+B+v)*i,y=D-C,F=_-C,k=B-C,w=v-C,x=s-y,M=e-F,N=t-k,Q=a-w,G=x>M?32:0,X=x>N?16:0,ne=M>N?8:0,q=x>Q?4:0,he=M>Q?2:0,Be=N>Q?1:0,ae=G+X+ne+q+he+Be,ee,se,Ae,Ue,Se,Te,ve,Me,Ut,ya,Ca,It;ee=Lt[ae][0]>=3?1:0,se=Lt[ae][1]>=3?1:0,Ae=Lt[ae][2]>=3?1:0,Ue=Lt[ae][3]>=3?1:0,Se=Lt[ae][0]>=2?1:0,Te=Lt[ae][1]>=2?1:0,ve=Lt[ae][2]>=2?1:0,Me=Lt[ae][3]>=2?1:0,Ut=Lt[ae][0]>=1?1:0,ya=Lt[ae][1]>=1?1:0,Ca=Lt[ae][2]>=1?1:0,It=Lt[ae][3]>=1?1:0;let Qt=x-ee+i,Gt=M-se+i,Ct=N-Ae+i,Sa=Q-Ue+i,xa=x-Se+2*i,Fa=M-Te+2*i,ka=N-ve+2*i,Ea=Q-Me+2*i,gr=x-Ut+3*i,Ra=M-ya+3*i,Ir=N-Ca+3*i,mr=Q-It+3*i,Qr=x-1+4*i,Tr=M-1+4*i,wa=N-1+4*i,Mr=Q-1+4*i,Za=D&255,$t=_&255,Nr=B&255,pr=v&255,Pr=.6-x*x-M*M-N*N-Q*Q;Pr<0?n=0:(Pr*=Pr,n=Pr*Pr*li(ce[Za+ce[$t+ce[Nr+ce[pr]]]],x,M,N,Q));let Vr=.6-Qt*Qt-Gt*Gt-Ct*Ct-Sa*Sa;Vr<0?o=0:(Vr*=Vr,o=Vr*Vr*li(ce[Za+ee+ce[$t+se+ce[Nr+Ae+ce[pr+Ue]]]],Qt,Gt,Ct,Sa));let Or=.6-xa*xa-Fa*Fa-ka*ka-Ea*Ea;Or<0?l=0:(Or*=Or,l=Or*Or*li(ce[Za+Se+ce[$t+Te+ce[Nr+ve+ce[pr+Me]]]],xa,Fa,ka,Ea));let Lr=.6-gr*gr-Ra*Ra-Ir*Ir-mr*mr;Lr<0?c=0:(Lr*=Lr,c=Lr*Lr*li(ce[Za+Ut+ce[$t+ya+ce[Nr+Ca+ce[pr+It]]]],gr,Ra,Ir,mr));let Gr=.6-Qr*Qr-Tr*Tr-wa*wa-Mr*Mr;return Gr<0?f=0:(Gr*=Gr,f=Gr*Gr*li(ce[Za+1+ce[$t+1+ce[Nr+1+ce[pr+1]]]],Qr,Tr,wa,Mr)),27*(n+o+l+c+f)}class wo extends K{static uv_0=new wo;u=0;v=0;constructor(e=0,t=0){super(e,t),this.u=e,this.v=t}length(){return 0}static getUVSheet(e,t,a){let r=Math.floor(e%(t*a)),i=Math.floor(r/t),n=r%t;return new $(i/t,n/a,1/t,1/a)}}class ji{serializedVersion="2";time;tangentMode=0;weightedMode=0;propertyKeyFrame;constructor(e=0){this.time=e,this.propertyKeyFrame={}}getK(e){return this.propertyKeyFrame[e]}split(e,t,a){switch(e){case z.single:{let r=this.getKeyFrame(0);r[a]=t}break;case z.float:{let r=this.getKeyFrame(0);r[a]=t}break;case z.vector2:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y}break;case z.vector3:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z}break;case z.vector4:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z;let l=this.getKeyFrame(3);l[a]=r.w}break;case z.quaternion:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z;let l=this.getKeyFrame(3);l[a]=r.w}break}}getKeyFrame(e){let t=this.propertyKeyFrame[e];return t||(t=new _n,t.time=this.time,t.tangentMode=this.tangentMode,t.weightedMode=this.weightedMode,this.propertyKeyFrame[e]=t),t}formBytes(e){this.time=e.readFloat32();{let{t,v:a}=_a.parser(e);this.split(t,a,"value")}{let{t,v:a}=_a.parser(e);this.split(t,a,"inSlope")}{let{t,v:a}=_a.parser(e);this.split(t,a,"outSlope")}this.tangentMode=e.readInt32(),this.weightedMode=e.readInt32();{let{t,v:a}=_a.parser(e);this.split(t,a,"inWeight")}{let{t,v:a}=_a.parser(e);this.split(t,a,"outWeight")}}}class xm{static sub(e,t){switch(e.constructor.name){case"number":return e-t;case"Vector2":{let r=e,i=t;return new K(r.x-i.x,r.y-i.y)}case"Vector3":{let r=e,i=t;return new b(r.x-i.x,r.y-i.y,r.z-i.z)}case"Vector4":{let r=e,i=t;return new $(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}case"Quaternion":{let r=e,i=t;return new Z(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}}}}class Zi{_keys=new Array;_values=new Array;getIndexByKey(e){return this._keys.indexOf(e)}getValueByKey(e){var t=this.getIndexByKey(e);return t>-1?this._values[t]:null}put(e,t){if(e==null)return null;var a=this.remove(e);return this._keys.push(e),this._values.push(t),a}remove(e){var t=this._keys.indexOf(e),a;return t>-1&&(a=this._values[t],this._keys.splice(t,1),this._values.splice(t,1)),a}getValues(){return this._values}getKeys(){return this._keys}clear(){this._values.length=0,this._keys.length=0}}class br{static WalkAble=1}class Yi{static SetConst(e){this.EPSILON=e,this.POWER_EPSILON=e*e}static EPSILON=.1;static POWER_EPSILON=this.EPSILON*this.EPSILON}class Bt extends b{static CALC_VECTOR3D1=new b;static CALC_VECTOR3D2=new b;static CALC_VECTOR3D3=new b;static CALC_VECTOR3D4=new b;static CALC_VECTOR3D5=new b;_pointId=0;constructor(e,t,a,r){super(t,a,r,0),this._pointId=e}get id(){return this._pointId}static equalPoint(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)+(e.z-t.z)*(e.z-t.z)<Yi.POWER_EPSILON}static calcDistance(e,t){return Bt.CALC_VECTOR3D3.setTo(e.x-t.x,e.y-t.y,e.z-t.z),Bt.CALC_VECTOR3D3.length}}class Qh{_openedList;_closedList;_endNode;_startNode;_triangleChannel;_navMesh;_findIndex=0;constructor(){this._openedList=new Array,this._closedList=new Array}findPath(e,t,a){return this._findIndex++,this._navMesh=e,this._startNode=t,this._endNode=a,this._openedList.length=0,this._closedList.length=0,this._startNode&&this._endNode?(this._startNode.gg=0,this._startNode.h=0,this._startNode.f=0,this._startNode.parent=null,this.search()):!1}search(){for(var e=this._startNode,t=[],a;e!=this._endNode;){t=e.getNeibourTriangles(t,br.WalkAble,br.WalkAble);for(a of t)if(a.closeId!=this._findIndex&&!(a==e||!a.walkAble)){var r=e.gg+Bt.calcDistance(a,e)*a.costMultiplier,i=Bt.calcDistance(a,this._endNode),n=r+i;a.openId==this._findIndex?a.f>n&&(a.f=n,a.gg=r,a.h=i,a.parent=e):(a.f=n,a.gg=r,a.h=i,a.parent=e,a.openId=this._findIndex,this._openedList.push(a))}if(e.closeId=this._findIndex,this._closedList.push(e),this._openedList.length==0)return!1;this._openedList.sort(function(o,l){return o.f-l.f}),e=this._openedList.shift()}return this.buildPath(),!0}buildPath(){this._triangleChannel=[];var e=this._endNode;for(this._triangleChannel.push(e);e!=this._startNode;)e=e.parent,this._triangleChannel.unshift(e)}get channel(){return this._triangleChannel}}class da extends Bt{_ownerPoint;_ownerEdge;radius=0;constructor(e,t){super(e.id,0,0,0),this._ownerEdge=t,this._ownerPoint=e}get ownerPoint(){return this._ownerPoint}get ownerEdge(){return this._ownerEdge}scalePoint(e=.7){var t=new da(this._ownerPoint,this._ownerEdge);return t.copyFrom(this),t.decrementBy(this._ownerPoint),t.scaleBy(e),t.radius=t.length,t.incrementBy(this._ownerPoint),t}}class ha{_edgeMask=0;_edgeSize=0;_pointA;_pointB;_triangleOwners;_centerPoint;_edgeDirA2B;crossPoint;fatPointA;fatPointB;static CALC_FAT_VECTOR=new b;constructor(e,t){if(this._pointA=e,this._pointB=t,e.id>=t.id)throw new Error("edge point order error!!!");this._triangleOwners=new Array,this._centerPoint=new b,this._edgeMask=br.WalkAble,Bt.CALC_VECTOR3D1.setTo(e.x-t.x,e.y-t.y,e.z-t.z),this._edgeSize=Bt.CALC_VECTOR3D1.length,this._centerPoint.setTo((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2)}get size(){return this._edgeSize}get triangleOwners(){return this._triangleOwners}get centerPoint(){return this._centerPoint}initFatPoints(e){this._edgeDirA2B=this._pointB.subtract(this._pointA),this._edgeDirA2B.normalize(),this.fatPointA=this.fatPointA||new da(this._pointA,this),this.fatPointB=this.fatPointB||new da(this._pointB,this),this.fatPointA.radius!=e&&(ha.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),ha.CALC_FAT_VECTOR.scaleBy(e),ha.CALC_FAT_VECTOR.incrementBy(this._pointA),this.fatPointA.copyFrom(ha.CALC_FAT_VECTOR),this.fatPointA.radius=e),this.fatPointB.radius!=e&&(ha.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),ha.CALC_FAT_VECTOR.scaleBy(-e),ha.CALC_FAT_VECTOR.incrementBy(this._pointB),this.fatPointB.copyFrom(ha.CALC_FAT_VECTOR),this.fatPointB.radius=e)}getFatPoint(e){return e==this._pointA?this.fatPointA:this.fatPointB}getAnotherFatPoint(e){return e==this._pointA?this.fatPointB:this.fatPointA}getAnotherPoint(e){return e==this._pointA?this._pointB:this._pointA}containsPoint(e){return Bt.equalPoint(e,this._pointA)?this._pointA:Bt.equalPoint(e,this._pointB)?this._pointB:null}addTriangleOwners(e){if(e.edges.indexOf(this)==-1)throw new Error("the edge is not belong triangle!!!");this._triangleOwners.indexOf(e)==-1&&this._triangleOwners.push(e)}getPublicPoint(e){return this._pointA==e._pointA||this._pointA==e._pointB?this._pointA:this._pointB==e._pointA||this._pointB==e._pointB?this._pointB:null}getEqualPoint(e){return Bt.equalPoint(e,this._pointA)?this._pointA:Bt.equalPoint(e,this._pointB)?this._pointB:null}get pointA(){return this._pointA}get pointB(){return this._pointB}get walkAble(){return(this._edgeMask&br.WalkAble)==br.WalkAble}testMask(e){return(this._edgeMask&e)==e}}class re{endPoint;curPoint;rayA;rayB;rayAPoint;rayBPoint;static RAY_1=new b;static RAY_2=new b;static TEST_RAY=new b;static TEST_RAY_1=new b;static TEST_RAY_2=new b;static CALC_CROSS_POINT=new b;static CALC_CROSS_TEST=new b;cornerPoint;cornerEdge;continuePass(e,t,a){this.resetData(),this.curPoint=e,this.endPoint=t,this.cornerEdge=a}passEdge(e,t,a,r){if((this.rayA==null||this.rayB==null)&&(this.rayA=re.RAY_1,this.rayB=re.RAY_2,this.rayAPoint=e.pointA,this.rayBPoint=e.pointB,this.rayA.setTo(this.rayAPoint.x-this.curPoint.x,0,this.rayAPoint.z-this.curPoint.z),this.rayB.setTo(this.rayBPoint.x-this.curPoint.x,0,this.rayBPoint.z-this.curPoint.z)),r)return this.checkEndPoint(a);if(re.TEST_RAY.setTo(a.x-this.curPoint.x,0,a.z-this.curPoint.z),this.isPointAtCenter(re.TEST_RAY,this.rayA,this.rayB)){this.hasCrossPoint(t.pointA,t.pointB,this.rayAPoint,this.rayA)?(this.rayB.copyFrom(re.TEST_RAY),a instanceof Bt?this.rayBPoint=a:this.rayBPoint=null):(this.rayA.copyFrom(re.TEST_RAY),a instanceof Bt?this.rayAPoint=a:this.rayAPoint=null);var i=t.getAnotherPoint(a);re.TEST_RAY.setTo(i.x-this.curPoint.x,0,i.z-this.curPoint.z),(i==this.rayAPoint||i==this.rayBPoint||this.isPointAtCenter(re.TEST_RAY,this.rayA,this.rayB))&&(this.cornerEdge=t)}else{var n;if(re.TEST_RAY_1.copyFrom(t.pointA),re.TEST_RAY_1.decrementBy(this.curPoint),re.TEST_RAY_2.copyFrom(t.pointB),re.TEST_RAY_2.decrementBy(this.curPoint),re.TEST_RAY_1.y=0,re.TEST_RAY_2.y=0,this.isPointAtCenter(this.rayA,re.TEST_RAY_1,re.TEST_RAY_2)||this.isPointAtCenter(this.rayB,re.TEST_RAY_1,re.TEST_RAY_2)?n=!1:n=!0,n)return this.isPointAtCenter(this.rayA,re.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1}return!0}checkEndPoint(e){return re.TEST_RAY.setTo(e.x-this.curPoint.x,0,e.z-this.curPoint.z),this.isPointAtCenter(re.TEST_RAY,this.rayA,this.rayB)?!0:(this.isPointAtCenter(this.rayA,re.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1)}calcCrossEdge(e,t,a){return this.calcCrossPoint(e.fatPointA,e.fatPointB,t,a)}calcCrossPoint(e,t,a,r){re.CALC_CROSS_POINT.copyFrom(t),re.CALC_CROSS_POINT.decrementBy(e);let i=re.CALC_CROSS_POINT.x*r.z-r.x*re.CALC_CROSS_POINT.z;var n=0;return i!=0&&(n=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/i),n>1?n=1:n<0&&(n=0),re.CALC_CROSS_POINT.scaleBy(n),re.CALC_CROSS_POINT.incrementBy(e),re.CALC_CROSS_POINT.clone()}calcCrossPointOut(e,t,a,r){re.CALC_CROSS_POINT.copyFrom(t),re.CALC_CROSS_POINT.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(re.CALC_CROSS_POINT.x*r.z-r.x*re.CALC_CROSS_POINT.z);return i<=1&&i>=0?null:(re.CALC_CROSS_POINT.scaleBy(i),re.CALC_CROSS_POINT.incrementBy(e),re.CALC_CROSS_POINT.clone())}hasCrossPoint(e,t,a,r){re.CALC_CROSS_TEST.copyFrom(t),re.CALC_CROSS_TEST.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(re.CALC_CROSS_TEST.x*r.z-r.x*re.CALC_CROSS_TEST.z);return i<=1&&i>=0}isPointAtCenter(e,t,a){var r=t.crossProduct(e);if(r.length==0&&e.length<t.length)return!0;var i=a.crossProduct(e);return i.length==0&&e.length<a.length?!0:(r.normalize(),i.normalize(),r.incrementBy(i),r.length<.01)}resetData(){this.cornerEdge=null,this.cornerPoint=null,this.curPoint=null,this.rayA=this.rayB=null,this.rayAPoint=this.rayBPoint=null,re.RAY_1.setTo(0,0,0),re.RAY_2.setTo(0,0,0)}}class ja{_aiRadius=0;_router;_result;_tempPublicEdgeList=new Array;_tempSamePlaneList=new Array;static CROSS_TEST_DIRECTION=new b;constructor(){this._router=new re}searchPath(e,t,a,r=0){return r<=0&&(r=1),this._aiRadius=r*1.5,this.searchEnable(e,t,a)?(this.search(e,t,a),!0):!1}get path(){return this._result}searchEnable(e,t,a){return!(e==null||t==null||a==null||a[0].plane.classifyPoint(e,Yi.EPSILON)!=wr.INTERSECT||a[a.length-1].plane.classifyPoint(t,Yi.EPSILON)!=wr.INTERSECT)}search(e,t,a){this._tempPublicEdgeList.length=0,this._tempSamePlaneList.length=0;var r=0,i=a.length-1,n,o,l,c;for(r=0;r<i;r++)o=a[r].getPublicEdge(a[r+1]),o.crossPoint=null,o.initFatPoints(this._aiRadius),this._tempPublicEdgeList.push(o),n=a[r],c=n.plane,n=a[r+1],l=n.getEdgeAgainstPoint(o),this._tempSamePlaneList.push(c.classifyPoint(l,Yi.EPSILON)==wr.INTERSECT);this._router.continuePass(e,t,this._tempPublicEdgeList[0]),i=this._tempPublicEdgeList.length;var f,h,u,g;for(r=0;r<i;r++)o=this._tempPublicEdgeList[r],n=a[r+1],g=r==i-1,g?l=t:l=n.getEdgeAgainstPoint(o),u=this._router.passEdge(o,this._tempPublicEdgeList[r+1],l,g),u||(f=this._router.cornerPoint,h=this._router.cornerEdge,r=this._tempPublicEdgeList.indexOf(h),this._router.continuePass(f,t,this._tempPublicEdgeList[r+1]));this.pushAllPathPoint2(e,t),this._result.length>=3&&(this.optimusTerminusFat(),this.optimusByRadius());let p=[];for(let m of this._result)p.push(new b().copyFrom(m));this._result=p}optimusTerminusFat(){var e,t,a;a=this._result[1],a instanceof da&&(e=a),a=this._result[this._result.length-2],a instanceof da&&(t=a),e&&(this._result[1]=e.scalePoint()),t&&e!=t&&(this._result[this._result.length-2]=t.scalePoint())}pushAllPathPoint2(e,t){var a=this._tempPublicEdgeList.length,r,i;this._result=new Array,this._result.push(e);for(var n=e,o,l,c,f=0;f<a;f++)if(r=this._tempPublicEdgeList[f],l=null,r.crossPoint)l=this.getFatPoint(r,r.crossPoint),l?this._result.push(l):this._result.push(r.crossPoint),n=r.crossPoint;else{i=null,o=null;for(var h=f+1;h<a&&(i=this._tempPublicEdgeList[h],o=i.crossPoint,!o);h++);o==null&&(o=t),l=this.getFatPoint(r,o),l?this._result.push(l):(o==n?c=o.clone():(ja.CROSS_TEST_DIRECTION.setTo(o.x-n.x,0,o.z-n.z),c=this._router.calcCrossEdge(r,n,ja.CROSS_TEST_DIRECTION)),this._result.push(c))}this._result.push(t)}optimusByRadius(){var e=new Array;e.length=this._result.length;var t=this._result.length-2,a,r,i,n,o,l,c,f,h,u,g,p,m;for(m=0;m<t;m++)c=f=h=null,n=o=l=null,g=!1,p=null,a=this._result[m],r=this._result[m+1],i=this._result[m+2],a instanceof da&&(n=a),r instanceof da&&(o=r),i instanceof da&&(l=i),n&&(c=n.ownerPoint),o&&(f=o.ownerPoint),l&&(h=l.ownerPoint),c&&f&&c==f&&f!=h&&(g=!0),h&&f&&h==f&&c!=f&&(g=!0),g&&(ja.CROSS_TEST_DIRECTION.copyFrom(a),ja.CROSS_TEST_DIRECTION.decrementBy(i),u=o.ownerEdge,g=this._router.hasCrossPoint(u.pointA,u.pointB,i,ja.CROSS_TEST_DIRECTION),g&&(p=this._router.calcCrossPointOut(f,r,i,ja.CROSS_TEST_DIRECTION)),p&&(e[m+1]=p))}getFatPoint(e,t){if(e==null)return null;var a;t instanceof da&&(a=t);var r;return a?r=a.ownerPoint:r=e.getEqualPoint(t),r==null?null:(a=e.getFatPoint(r),a)}}class Th extends b{_id=0;_plane;_points=new Array;_edges=new Array;_neibourTriangles=new Zi;_pointAgainstEdge=new Zi;_edgeAgainstPoint=new Zi;_mask=0;_aabbBox;f=0;gg=0;h=0;parent;costMultiplier=1;openId=0;closeId=0;get aabb(){return this._aabbBox}initAABB(){this._aabbBox=new _t,this._aabbBox.addPoint(this._points[0]),this._aabbBox.addPoint(this._points[1]),this._aabbBox.addPoint(this._points[2])}calcGlobalQuadAABB(){}get isTriangle(){return!0}constructor(e,t,a,r){super(0,0,0,0),this._id=e,this._mask=br.WalkAble,this._edges.push(t,a,r);var i;for(i of this._edges)this._points.indexOf(i.pointA)==-1&&this._points.push(i.pointA),this._points.indexOf(i.pointB)==-1&&this._points.push(i.pointB);this.x=(this._points[0].x+this._points[1].x+this._points[2].x)/3,this.y=(this._points[0].y+this._points[1].y+this._points[2].y)/3,this.z=(this._points[0].z+this._points[1].z+this._points[2].z)/3,this._plane=new wh,this._plane.fromPoints(this._points[0],this._points[1],this._points[2]),this._plane.normalize(),this.genarateAgainstData(),this.initAABB()}genarateAgainstData(){var e,t;for(e of this._edges)for(t of this._points)e.pointA!=t&&e.pointB!=t&&(this._edgeAgainstPoint.put(e,t),this._pointAgainstEdge.put(t,e))}get id(){return this._id}get plane(){return this._plane}get points(){return this._points}addNeibour(e,t){if(this._edges.indexOf(e)>=0)this._neibourTriangles.put(e,t);else throw new Error("the edge is not in triangle!!!")}getNeibourTriangles(e=null,t=1,a=1){e=e||new Array,e.length=0;var r,i,n=this._neibourTriangles.getKeys(),o;for(o of n)i=o,i.testMask(t)&&(r=this._neibourTriangles.getValueByKey(i),r.testMask(a)&&e.push(r));return e}getEdges(e=null,t=1){e=e||new Array,e.length=0;var a;for(a of this._edges)a.testMask(t)&&e.push(a);return e}get walkAble(){return this.testMask(br.WalkAble)}get edges(){return this._edges}testMask(e){return(this._mask&e)==e}getEdgeAgainstPoint(e){return this._edgeAgainstPoint.getValueByKey(e)}getPointAgainstEdge(e){return this._pointAgainstEdge.getValueByKey(e)}getPublicEdge(e){if(e&&e!=this){var t=this._neibourTriangles.getKeys(),a;for(a of t)if(this._neibourTriangles.getValueByKey(a)==e)return a}return null}loopPublicEdge(e){var t,a;if(e&&e!=this){for(t of this._edges)for(a of e._edges)if(t==a)return t}return null}randomPoint(){var e=this._points[2].subtract(this._points[0]);e.scaleBy(Math.random()),e.incrementBy(this._points[0]);var t=this._points[1].subtract(e);return t.scaleBy(Math.random()),t.incrementBy(e),t}}class Fm{_nav3dPoints;_nav3dEdges;_nav3dTriangles;_path;_edgesDict;_nav3dAstar;_nav3dFunnel;_terrainQuad;_triangleList;get edges(){return this._nav3dEdges}get points(){return this._nav3dPoints}get path(){return this._path}get triangles(){return this._nav3dTriangles}constructor(e,t){this._nav3dPoints=new Array,this._nav3dEdges=new Array,this._nav3dTriangles=new Array,this._edgesDict=new Zi,this.initPoints(e),this.initEdgesAndTriangles(t),this.createConnections(),this._nav3dAstar=new Qh,this._nav3dFunnel=new ja,this._terrainQuad=new Jd(8,128),this._terrainQuad.createQuadTree(this._nav3dTriangles)}getTriangleAtPoint(e,t=5){return this._terrainQuad.getTriangleAtPoint(e,t)}findPath(e,t,a=5){this._path=null,this._triangleList=null;var r=this.getTriangleAtPoint(e,10),i=this.getTriangleAtPoint(t,10),n=this._nav3dAstar.findPath(this,r,i);return n?(this._triangleList=this._nav3dAstar.channel,n=this._nav3dFunnel.searchPath(e,t,this._triangleList,a),this._path=this._nav3dFunnel.path,n):!1}initPoints(e){for(var t,a,r=e.length,i=0;i<r;i++)t=e[i],a=new Bt(i,t.x,t.y,t.z),this._nav3dPoints.push(a)}initEdgesAndTriangles(e){for(var t,a,r,i,n,o=e.length,l=0;l<o;l++)t=e[l],a=this.tryCreateEdge(t[0],t[1]),r=this.tryCreateEdge(t[1],t[2]),i=this.tryCreateEdge(t[2],t[0]),!(a==null||r==null||i==null)&&(n=new Th(l,a,r,i),this._nav3dTriangles.push(n))}tryCreateEdge(e,t){if(e==t)throw new Error("edge point index error!!!");if(e>t){var a=e;e=t,t=a}var r=this._edgesDict.getValueByKey(e+"_"+t);return r==null&&(r=new ha(this._nav3dPoints[e],this._nav3dPoints[t]),this._nav3dEdges.push(r),this._edgesDict.put(e+"_"+t,r)),r}createConnections(){for(var e=this._nav3dTriangles.length,t=this._nav3dTriangles.length,a,r,i,n,o=0;o<e;o++){a=this._nav3dTriangles[o];for(i of a.edges)i.addTriangleOwners(a);for(var l=0;l<t;l++)r=this._nav3dTriangles[l],a!=r&&(n=a.loopPublicEdge(r),n&&(a.addNeibour(n,r),r.addNeibour(n,a)))}}}class Io{x;y;setTo(e,t){this.x=e,this.y=t}equals(e,t){return e==this.x&&t==this.y}equalPoint(e){return this.equals(e.x,e.y)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y)}clone(){var e=new Io;return e.setTo(this.x,this.y),e}normalize(){var e=length;e!=0&&this.setTo(this.x/e,this.y/e)}}class va extends Fe{width;height;depth;constructor(e=1,t=1,a=1){super(),this.width=e,this.height=t,this.depth=a,this.initVertex()}initVertex(){let e=this.width/2,t=this.height/2,a=this.depth/2;this.bounds=new ge(b.ZERO.clone(),new b(this.width,this.height,this.depth));let r=new Float32Array([-e,t,a,e,t,a,e,t,-a,-e,t,-a,-e,t,a,e,t,-a,e,-t,a,-e,-t,a,-e,-t,-a,e,-t,-a,e,-t,a,-e,-t,-a,-e,-t,a,-e,t,a,-e,t,-a,-e,-t,-a,-e,-t,a,-e,t,-a,e,t,a,e,-t,a,e,-t,-a,e,t,-a,e,t,a,e,-t,-a,e,t,a,-e,t,a,-e,-t,a,-e,-t,a,e,-t,a,e,t,a,e,-t,-a,-e,-t,-a,-e,t,-a,e,t,-a,e,-t,-a,-e,t,-a]),i=new Float32Array([0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1]),n=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),o=[0,2,1,3,5,4,6,8,7,9,11,10,12,14,13,15,17,16,18,20,19,21,23,22,24,26,25,27,29,28,30,32,31,33,35,34],l=new Uint16Array(o.reverse());this.setIndices(l),this.setAttribute(V.position,r),this.setAttribute(V.normal,i),this.setAttribute(V.uv,n),this.setAttribute(V.TEXCOORD_1,n),this.addSubGeometry({indexStart:0,indexCount:o.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Mh extends Fe{radiusTop;radiusBottom;height;radialSegments;heightSegments;openEnded;thetaStart;thetaLength;constructor(e=1,t=1,a=1,r=8,i=8,n=!1,o=0,l=Math.PI*2){super(),this.radiusTop=e,this.radiusBottom=t,this.height=a,this.radialSegments=r,this.heightSegments=i,this.openEnded=n,this.thetaStart=o,this.thetaLength=l,this.instanceID=xt(),this.buildGeometry()}addGroup(e,t,a){this.addSubGeometry({indexStart:e,indexCount:t,vertexStart:e,vertexCount:0,firstStart:0,index:a,topology:0})}buildGeometry(){const e=this;this.radialSegments=Math.floor(this.radialSegments),this.heightSegments=Math.floor(this.heightSegments);const t=[],a=[],r=[],i=[];let n=0;const o=[],l=this.height/2;let c=0;p(),this.openEnded===!1&&(this.radiusTop>0&&m(!0),this.radiusBottom>0&&m(!1));let f=new Float32Array(t),h=new Float32Array(a),u=new Float32Array(r),g=new Uint16Array(i);this.setAttribute(V.position,f),this.setAttribute(V.normal,h),this.setAttribute(V.uv,u),this.setAttribute(V.TEXCOORD_1,u),this.setIndices(g);function p(){const D=new b,_=new b;let B=0;const v=(e.radiusBottom-e.radiusTop)/e.height;for(let C=0;C<=e.heightSegments;C++){const y=[],F=C/e.heightSegments,k=F*(e.radiusBottom-e.radiusTop)+e.radiusTop;for(let w=0;w<=e.radialSegments;w++){const x=w/e.radialSegments;let M=x*e.thetaLength+e.thetaStart;w==e.radialSegments&&Math.abs(e.thetaLength-e.thetaStart)==Math.PI*2&&(M=0);const N=Math.sin(M),Q=Math.cos(M);_.x=k*N,_.y=-F*e.height+l,_.z=k*Q,t.push(_.x,_.y,_.z),D.set(N,v,Q).normalize(),a.push(D.x,D.y,D.z),r.push(x,1-F),y.push(n++)}o.push(y)}for(let C=0;C<e.radialSegments;C++)for(let y=0;y<e.heightSegments;y++){const F=o[y][C],k=o[y+1][C],w=o[y+1][C+1],x=o[y][C+1];i.push(F,k,x),i.push(k,w,x),B+=6}e.addGroup(c,B,0),c+=B}function m(D){const _=n,B=new K,v=new b;let C=0;const y=D===!0?e.radiusTop:e.radiusBottom,F=D===!0?1:-1;for(let w=1;w<=e.radialSegments;w++)t.push(0,l*F,0),a.push(0,F,0),r.push(.5,.5),n++;const k=n;for(let w=0;w<=e.radialSegments;w++){const M=w/e.radialSegments*e.thetaLength+e.thetaStart,N=Math.cos(M),Q=Math.sin(M);v.x=y*Q,v.y=l*F,v.z=y*N,t.push(v.x,v.y,v.z),a.push(0,F,0),B.x=N*.5+.5,B.y=Q*.5*F+.5,r.push(B.x,B.y),n++}for(let w=0;w<e.radialSegments;w++){const x=_+w,M=k+w;D===!0?i.push(M,M+1,x):i.push(M+1,M,x),C+=3}e.addGroup(c,C,D===!0?1:2),c+=C}}}class Nh extends Fe{radius;tube;radialSegments;tubularSegments;constructor(e=.4,t=.1,a=32,r=32){super(),this.radius=e,this.tube=t,this.radialSegments=a,this.tubularSegments=r,this.initVertex()}initVertex(){const e=2*Math.PI,t=this.radius,a=this.tube,r=this.radialSegments,i=this.tubularSegments;this.bounds=new ge(b.ZERO.clone(),new b(t*2,a*2,t*2));var n=(r+1)*(i+1);let o=new Float32Array(n*3),l=new Float32Array(n*3),c=new Float32Array(n*2),f=new Uint16Array(r*i*2*3),h=0,u=0,g=0,p=0;for(let m=0;m<=r;m++)for(let D=0;D<=i;D++){const _=D/i,B=m/r,v=_*e,C=B*Math.PI*2;if(o[h++]=(t+a*Math.cos(C))*Math.sin(v),o[h++]=a*Math.sin(C),o[h++]=(t+a*Math.cos(C))*Math.cos(v),l[u++]=Math.sin(v)*Math.cos(C),l[u++]=Math.sin(C),l[u++]=Math.cos(v)*Math.cos(C),c[g++]=_,c[g++]=B,D<i&&m<r){const y=i+1,F=y*m+D,k=y*(m+1)+D,w=y*(m+1)+D+1,x=y*m+D+1;f[p++]=F,f[p++]=x,f[p++]=k,f[p++]=x,f[p++]=w,f[p++]=k}}this.setIndices(f),this.setAttribute(V.position,o),this.setAttribute(V.normal,l),this.setAttribute(V.uv,c),this.setAttribute(V.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class km extends Fe{segment;row=0;constructor(e){super(),this.segment=e,this.buildGeometry()}buildGeometry(){this.row=this.segment+1;let e=new Uint32Array(this.segment*6),t=new Float32Array(this.row*3*2),a=new Float32Array(this.row*3*2),r=new Float32Array(this.row*2*2);for(let i=0;i<this.row;i++){t[i*3*2+0]=0,t[i*3*2+1]=0,t[i*3*2+2]=0,t[i*3*2+3]=0,t[i*3*2+4]=0,t[i*3*2+5]=0,a[i*3*2+0]=0,a[i*3*2+1]=0,a[i*3*2+2]=1,a[i*3*2+3]=0,a[i*3*2+4]=0,a[i*3*2+5]=1,r[i*2*2+0]=0,r[i*2*2+1]=i/this.segment,r[i*2*2+2]=1,r[i*2*2+3]=i/this.segment;let n=i*2,o=n,l=n+1,c=n+2,f=n+3;e[i*6+0]=o,e[i*6+1]=l,e[i*6+2]=c,e[i*6+3]=l,e[i*6+4]=f,e[i*6+5]=c}this.setIndices(e),this.setAttribute(V.position,t),this.setAttribute(V.normal,a),this.setAttribute(V.uv,r),this.setAttribute(V.TEXCOORD_1,r),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Em extends Fe{faceCount=0;constructor(e){super(),this.faceCount=e,this.buildGeometry()}buildGeometry(){let e=new Uint32Array(this.faceCount*3),t=new Float32Array(this.faceCount*3*3),a=new Float32Array(this.faceCount*3*3),r=new Float32Array(this.faceCount*3*2),i=new Float32Array(this.faceCount*3*1);for(let n=0;n<this.faceCount;n++){let o=n*3+0,l=n*3+1,c=n*3+2;e[o]=o,e[l]=l,e[c]=c}this.setIndices(e),this.setAttribute(V.position,t),this.setAttribute(V.normal,a),this.setAttribute(V.uv,r),this.setAttribute(V.TEXCOORD_1,r),this.setAttribute(V.vIndex,i),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Rm extends Xe{create(e,t,a,r=!0){let i=E.device;const n=e*4*4;this.format=Y.rgba32float,this.createTextureDescriptor(e,t,1,this.format);const l=i.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(l,0,a);const c=S.beginCommandEncoder();c.copyBufferToTexture({buffer:l,bytesPerRow:n},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(c),r&&(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float"),this.gpuSampler=i.createSampler({})}fromBuffer(e,t,a){let r=E.device;const i=e*4*4;this.format=Y.rgba32float,this.mipmapCount=1,this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const n=S.beginCommandEncoder();return n.copyBufferToTexture({buffer:a,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(n),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=r.createSampler({}),this}}class wm extends pn{_internalTexture;_minSize=32;_skyColor;constructor(e){super(),this._skyColor=e,this._internalTexture=new hs;let t=[];return A.res.fillColor(t,this._minSize,this._minSize,this.color.r,this.color.g,this.color.b,this.color.a),this._internalTexture.create(this._minSize,this._minSize,t,!1),this.createFromTexture(this._minSize,this._internalTexture),this}changeColor(e){return this._skyColor=e,A.res.fillColor(this._internalTexture.floatArray,this._minSize,this._minSize,this.color.r,this.color.g,this.color.b,this.color.a),this._internalTexture.updateTexture(this._minSize,this._minSize,this._internalTexture.floatArray,!1),this._faceData.uploadTexture(0,this._internalTexture),this}get color(){return this._skyColor}set color(e){this.changeColor(e)}}class Im extends d.Object3D{length=100;thickness=.1;constructor(e,t=.1){super(),this.length=e,this.thickness=t,this.init()}init(){let e=new d.Object3D,t=new d.Object3D,a=new d.Object3D,r=new va(2,2,2),i=new va(2,2,2),n=new va(2,2,2),o=new st;o.baseColor=new O(1,0,0);let l=new st;l.baseColor=new O(0,1,0);let c=new st;c.baseColor=new O(0,0,1);let f=e.addComponent(d.MeshRenderer),h=t.addComponent(d.MeshRenderer),u=a.addComponent(d.MeshRenderer);f.geometry=r,f.material=o,f.castShadow=!1,h.geometry=i,h.material=l,h.castShadow=!1,u.geometry=n,u.material=c,u.castShadow=!1,e.localScale=new b(this.length,this.thickness,this.thickness),e.x=this.length,t.localScale=new b(this.thickness,this.length,this.thickness),t.y=this.length,a.localScale=new b(this.thickness,this.thickness,this.length),a.z=this.length,this.addChild(e),this.addChild(t),this.addChild(a)}}class Qm{static merge(e,t,a){}static mergeNumber(e,t,a){let r=a||new Fe,i=e.getAttribute(V.position).data.length/3,n=new Float32Array(i*t);for(const f of e.vertexAttributeMap){let h=f[1].attribute;if(h==V.indices)continue;let u=e.getAttribute(h).data,g=u.length,p=new Float32Array(g*t);for(let m=0;m<t;m++){p.set(u,g*m);for(let D=0;D<i;D++)n[i*m+D]=m}r.setAttribute(h,p)}r.setAttribute(V.vIndex,n);let o=e.getAttribute(V.indices).data,l=o.length,c=new Uint32Array(o.length*t);for(let f=0;f<t;f++)for(let h=0;h<l;h++){let u=f*i,g=f*l;const p=o[h]+u;c[g+h]=p}return r.setIndices(c),r.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,index:0,vertexCount:0,firstStart:0,topology:0}),r}static generateNormal(){}static generateTangent(){}static packUV(){}}class Tm extends d.Object3D{size=100;divisions=10;constructor(e=100,t=10){super(),this.size=e,this.divisions=t,this.buildGeometry(),this.addAxis()}buildGeometry(){const e=[],t=[],a=this.size/this.divisions,r=this.size/2,i=this.divisions/2;for(let c=0,f=-r;c<=this.divisions;c++,f+=a)c!==i&&(e.push(-r,0,f,r,0,f),e.push(f,0,-r,f,0,r));for(let c=0;c<e.length/3;c+=2)t.push(c,c+1);let n=new Fe;n.setIndices(t.length>Uint16Array.length?new Uint32Array(t):new Uint16Array(t)),n.setAttribute(V.position,new Float32Array(e)),n.addSubGeometry({indexStart:0,indexCount:t.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let o=new st;o.topology="line-list",o.baseColor=new O(1,1,1,.15),o.blendMode=te.ADD,o.castReflection=!1;let l=this.addComponent(d.MeshRenderer);l.geometry=n,l.material=o}addAxis(){const e=this.size/2;let t=new Float32Array([-e,0,0,e,0,0]),a=new Uint16Array([0,1,2,3]),r=new Fe;r.setIndices(a),r.setAttribute(V.position,t),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});{let i=new d.Object3D,n=i.addComponent(d.MeshRenderer);n.geometry=r;let o=n.material=new st;o.baseColor=new O(1,0,0,.5),o.blendMode=te.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}{let i=new d.Object3D;i.rotationY=90;let n=i.addComponent(d.MeshRenderer);n.geometry=r;let o=n.material=new st;o.baseColor=new O(0,1,0,.5),o.blendMode=te.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}}}class Mm{static color_temperature_to_rgb(e){e<1e3?e=1e3:e>4e4&&(e=4e4);let t=e/100,a=this.get_red(t),r=this.get_green(t),i=this.get_blue(t);return new O(a/255,r/255,i/255,1)}static get_red(e){if(e<=66)return 255;let t=329.698727446*Math.pow(e-60,-.1332047592);return this.bound(t)}static get_green(e){let t=0;return e<=66?t=99.4708025861*Math.log(e)-161.1195681661:t=288.1221695283*Math.pow(e-60,-.0755148492),this.bound(t)}static get_blue(e){let t=0;return e>=66?255:e<=19?0:(t=138.5177312231*Math.log(e-10)-305.0447927307,this.bound(t))}static bound(e,t=0,a=255){let r=Math.max(e,t);return Math.min(r,a)}}class Nm{static boxGeo;static planeGeo;static sphere;static material;static materialMap;static initHeap(){this.boxGeo||(this.boxGeo=new va),this.planeGeo||(this.planeGeo=new Hr(1,1,1,1,b.UP)),this.sphere||(this.sphere=new Cr(1,35,35)),this.material||(this.material=new pa),this.materialMap||(this.materialMap=new Map)}static get CubeMesh(){return this.initHeap(),this.boxGeo}static get SphereMesh(){return this.initHeap(),this.sphere}static GetCube(){this.initHeap();let e=new d.Object3D,t=e.addComponent(d.MeshRenderer);return t.geometry=this.boxGeo,t.material=this.material.clone(),t.castShadow=!0,e}static GetMaterial(e){let t=this.materialMap.get(e);return t||(t=new pa,t.baseMap=e,this.materialMap.set(e,t)),t.clone()}static GetPlane(e){this.initHeap();let t=new d.Object3D,a=t.addComponent(d.MeshRenderer);a.geometry=this.planeGeo;let r=this.GetMaterial(e);return r.blendMode=te.ADD,r.castShadow=!1,a.material=r,a.castGI=!1,a.castReflection=!1,t}static GetSingleCube(e,t,a,r,i,n){this.initHeap();let o=new pa;o.roughness=.5,o.metallic=.1,o.baseColor=new O(r,i,n,1);let l=new d.Object3D,c=l.addComponent(d.MeshRenderer);return c.castGI=!0,c.geometry=new va(e,t,a),c.material=o,l}static GetSingleSphere(e,t,a,r){this.initHeap();let i=new pa;i.baseColor=new O(t,a,r,1);let n=new d.Object3D,o=n.addComponent(d.MeshRenderer);return o.castGI=!0,o.geometry=new Cr(e,20,20),o.material=i,n}static get Sphere(){this.initHeap();let e=new d.Object3D,t=e.addComponent(d.MeshRenderer);return t.geometry=this.sphere,t.material=this.material,e}static GetSingleCube2(e,t=10){this.initHeap();let a=new d.Object3D,r=a.addComponent(d.MeshRenderer);return r.castShadow=!1,r.geometry=new va(t,t,t),r.material=e,a}static GetPointLight(e,t,a,r,i,n,o=1,l=!0){let c=new d.Object3D,f=c.addComponent(d.PointLight);f.lightColor=new O(r,i,n,1),f.intensity=o,f.range=a,f.at=8,f.radius=0,f.castShadow=l,c.localPosition=e,c.localRotation=t;let h=this.GetSingleSphere(.1,1,1,1);return c.addChild(h),f}}var I=(s=>(s[s.X=0]="X",s[s.Y=1]="Y",s[s.Z=2]="Z",s[s.XY=3]="XY",s[s.XZ=4]="XZ",s[s.YZ=5]="YZ",s[s.XYZ=6]="XYZ",s[s.MAX=7]="MAX",s[s.NONE=8]="NONE",s))(I||{}),qt=(s=>(s[s.Local=0]="Local",s[s.Global=1]="Global",s))(qt||{});class Mn extends Pe{mAxis;mAxisColor;mContainer;mAxisMaterial;mAxisCollider;constructor(){super(),this._enable=!1,this.mAxis=new Array(I.MAX),this.mAxisColor=new Array(I.MAX),this.mAxisMaterial=new Array(I.MAX),this.mAxisCollider=new Array(I.MAX)}get target(){return this.object3D.target}get mX(){return this.object3D.mXObj}get mY(){return this.object3D.mYObj}get mZ(){return this.object3D.mZObj}get transformSpaceMode(){return this.object3D.transformSpaceMode}init(e){this.mContainer=new d.Object3D;let t=new st;t.baseColor=new O(1,0,0),t.depthCompare=$e.always,this.mAxisColor[I.X]=t.baseColor,this.mAxisMaterial[I.X]=t;let a=new st;a.baseColor=new O(0,1,0),a.depthCompare=$e.always,this.mAxisColor[I.Y]=a.baseColor,this.mAxisMaterial[I.Y]=a;let r=new st;r.baseColor=new O(0,0,1),r.depthCompare=$e.always,this.mAxisColor[I.Z]=r.baseColor,this.mAxisMaterial[I.Z]=r;let i=this.createCustomAxis(I.X),n=this.createCustomAxis(I.Y),o=this.createCustomAxis(I.Z);this.mContainer.addChild(this.mAxis[I.X]=i),this.mContainer.addChild(this.mAxis[I.Y]=n),this.mContainer.addChild(this.mAxis[I.Z]=o),this.mAxisCollider[I.X]=i.getComponent(Kt),this.mAxisCollider[I.Y]=n.getComponent(Kt),this.mAxisCollider[I.Z]=o.getComponent(Kt)}start(){}onEnable(e){this.object3D.addChild(this.mContainer),this.reset()}onDisable(e){this.object3D.removeChild(this.mContainer)}reset(){switch(this.transformSpaceMode){case qt.Local:{let t=R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix).decompose();this.object3D.scaleX=1,this.object3D.scaleY=1,this.object3D.scaleZ=1,this.object3D.rotationX=t[1].x,this.object3D.rotationY=t[1].y,this.object3D.rotationZ=t[1].z,this.object3D.x=t[0].x,this.object3D.y=t[0].y,this.object3D.z=t[0].z}break;case qt.Global:{this.object3D.scaleX=1,this.object3D.scaleY=1,this.object3D.scaleZ=1,this.object3D.rotationX=0,this.object3D.rotationY=0,this.object3D.rotationZ=0;const e=this.mX.transform.worldPosition;this.object3D.x=e.x,this.object3D.y=e.y,this.object3D.z=e.z}break}}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(A.inputSystem.mouseX,A.inputSystem.mouseY),r,i;for(let n=0;n<=I.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r&&(!i||i.distance>r.distance||n==I.XYZ)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint},n==I.XYZ)))break}return i}currentAxis=I.NONE;beginPoint=new b;beginMousePos=new b;currentPoint=new b;onMouseDown(e){if(e.mouseCode!=Cn.MOUSE_LEFT)return;let t=this.pickAxis();if(!t)return;this.currentAxis=t.axis,e.stopImmediatePropagation();const r=this.object3D.transform.scene3D.view.camera;let i=r.worldToScreenPoint(this.mX.transform.worldPosition),n=r.screenPointToWorld(A.inputSystem.mouseX,A.inputSystem.mouseY,i.z);this.beginPoint.copyFrom(n),this.beginMousePos.x=A.inputSystem.mouseX,this.beginMousePos.y=A.inputSystem.mouseY}lastMoveObj;lastMoveAxis;onMouseMove(e){if(this.currentAxis==I.NONE){let t=this.lastMoveObj.getComponent(d.MeshRenderer).material;this.lastMoveObj&&"baseColor"in t&&(t.baseColor=this.mAxisColor[this.lastMoveAxis],this.lastMoveObj=null,this.lastMoveAxis==I.XYZ&&(this.mAxis[I.X].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[I.X]),this.mAxis[I.Y].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[I.Y]),this.mAxis[I.Z].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[I.Z])),this.lastMoveAxis=I.NONE);let a=this.pickAxis();if(!a)return;t.setUniformColor("baseColor",new O(1,1,1)),this.lastMoveObj=a.obj,this.lastMoveAxis=a.axis,this.lastMoveAxis==I.XYZ&&(this.mAxis[I.X].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new O(1,1,1)),this.mAxis[I.Y].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new O(1,1,1)),this.mAxis[I.Z].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new O(1,1,1)))}else{const a=this.object3D.transform.scene3D.view.camera;let r=a.worldToScreenPoint(this.mX.transform.worldPosition),i=a.screenPointToWorld(A.inputSystem.mouseX,A.inputSystem.mouseY,r.z);this.currentPoint.copyFrom(i);let n=i.subtract(this.beginPoint);b.HELP_0.set(A.inputSystem.mouseX,A.inputSystem.mouseY,0);let o=b.distance(b.HELP_0,this.beginMousePos);switch(this.beginMousePos.copyFrom(b.HELP_0),this.transformSpaceMode){case qt.Local:this.applyLocalTransform(this.currentAxis,n,o);break;case qt.Global:this.applyGlobalTransform(this.currentAxis,n,o);break}this.beginPoint.copyFrom(i),this.reset()}}onMouseUp(e){e.mouseCode==Cn.MOUSE_LEFT&&(this.currentAxis=I.NONE,this.reset())}onUpdate(e){let a=b.distance(e.camera.transform.worldPosition,this.object3D.transform.worldPosition)/100;if(this.mContainer.scaleX=this.mContainer.scaleY=this.mContainer.scaleZ=a,this.mX){const r=this.mX.transform.worldPosition;this.object3D.x=r.x,this.object3D.y=r.y,this.object3D.z=r.z}}applyLocalTransform(e,t,a){console.warn("not imp")}applyGlobalTransform(e,t,a){console.warn("not imp")}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=0,a=0,r=0;switch(e){case I.X:t=1;break;case I.Y:a=1;break;case I.Z:r=1;break}let i=.4+t*20,n=.4+a*20,o=.4+r*20,l=new d.Object3D;l.x=i*.5,l.y=n*.5,l.z=o*.5;let c=l.addComponent(d.MeshRenderer);c.geometry=new va(i,n,o),c.material=this.mAxisMaterial[e];let f=l.addComponent(Kt),h=new ri;return h.setFromCenterAndSize(new b(0,0,0),new b(i+1,n+1,o+1)),f.shape=h,l}}class Ph extends Mn{init(e){super.init(e);let t=new st;t.doubleSide=!0,t.baseColor=new O(.9,.9,.9),t.depthCompare=$e.always,this.mAxisColor[I.XYZ]=t.baseColor,this.mAxisMaterial[I.XYZ]=t;let a=new d.Object3D,r=a.addComponent(d.MeshRenderer);r.geometry=new va(2,2,2),r.material=this.mAxisMaterial[I.XYZ];let i=a.addComponent(Kt),n=new ri;n.setFromCenterAndSize(new b(0,0,0),new b(2,2,2)),i.shape=n,this.mContainer.addChild(this.mAxis[I.XYZ]=a),this.mAxisCollider[I.XYZ]=a.getComponent(Kt)}applyLocalTransform(e,t,a){switch(this.currentAxis){case I.XYZ:{let r=0;Math.abs(t.x)>Math.abs(t.y)?Math.abs(t.x)>Math.abs(t.z)?r=t.x:r=t.z:r=t.y,this.mX.scaleX+=r,this.mX.scaleY+=r,this.mX.scaleZ+=r}break;default:this.mX.transform.worldMatrix.transformVector(t,t),(this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ)&&(this.mX.scaleX=Math.abs(this.mX.scaleX+t.x)),(this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ)&&(this.mX.scaleY=Math.abs(this.mX.scaleY+t.y)),(this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ)&&(this.mX.scaleZ=Math.abs(this.mX.scaleZ+t.z));break}}applyGlobalTransform(e,t,a){let r=b.HELP_0;r.set(0,0,0),(this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ)&&(r.x=t.x),(this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ)&&(r.y=t.y),(this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ)&&(r.z=t.z),this.mX.transform.worldMatrix.transformVector(r,b.HELP_1),this.mX.scaleX+=b.HELP_1.x,this.mX.scaleY+=b.HELP_1.y,this.mX.scaleZ+=b.HELP_1.z}createCustomAxis(e){let t=super.createAxis(e),a=this.createBox(e);return t.addChild(a),t}createBox(e){let t=0,a=0,r=0,i=new d.Object3D;switch(e){case I.X:t=1,i.rotationZ=-90;break;case I.Y:a=1;break;case I.Z:r=1,i.rotationX=90;break}let n=.2+t*20,o=.2+a*20,l=.2+r*20;i.x=n*.5,i.y=o*.5,i.z=l*.5;let c=i.addComponent(d.MeshRenderer);return c.geometry=new va(2,2,2),c.material=this.mAxisMaterial[e],i}}var tt=(s=>(s[s.Scale=0]="Scale",s[s.Rotation=1]="Rotation",s[s.Translation=2]="Translation",s[s.NONE=3]="NONE",s))(tt||{});class Vh extends Mn{applyLocalTransform(e,t,a){if(this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ,this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ){R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.identity(),R.help_matrix_1.createByRotation(1,b.Y_AXIS),R.help_matrix_2.multiplyMatrices(R.help_matrix_1,R.help_matrix_0),R.help_matrix_2.invert(),R.help_matrix_1.multiplyMatrices(R.help_matrix_2,R.help_matrix_0);let r=R.help_matrix_1.decompose();this.mX.rotationX+=r[1].x,this.mY.rotationY+=r[1].y,this.mZ.rotationZ+=r[1].z}this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ}getAngle(){const t=this.object3D.transform.scene3D.view.camera,a=this.mZ.transform.worldPosition;if(t.screenPointToRay(A.inputSystem.mouseX,A.inputSystem.mouseY),this.currentAxis==I.X){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(A.inputSystem.mouseX,A.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.x-a.x>0&&(n=360-n),n}if(this.currentAxis==I.Y){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(A.inputSystem.mouseX,A.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.y-a.y>0&&(n=360-n),n}if(this.currentAxis==I.Z){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(A.inputSystem.mouseX,A.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.z-a.z>0&&(n=360-n),n}return 0}mLastAngle=0;applyGlobalTransform(e,t,a){if(this.currentAxis==I.X||this.currentAxis==I.Y||this.currentAxis==I.Z){let r=this.getAngle();switch(R.help_matrix_0.identity(),this.currentAxis){case I.X:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.X_AXIS);break;case I.Y:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Y_AXIS);break;case I.Z:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Z_AXIS);break}R.help_matrix_1.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.append(R.help_matrix_0),this.mX.parent&&(R.help_matrix_2.copyFrom(this.mX.parent.worldMatrix),R.help_matrix_2.invert(),R.help_matrix_1.multiply(R.help_matrix_2));let n=R.help_matrix_1.decompose(Wt.QUATERNION)[1];Z.HELP_0.set(n.x,n.y,n.z,n.w),this.mLastAngle=r,this.mX.transform.localRotQuat=Z.HELP_0}}onMouseDown(e){super.onMouseDown(e),this.currentAxis!=I.NONE&&(this.mAxis[I.X].getComponent(d.MeshRenderer).enable=!1,this.mAxis[I.Y].getComponent(d.MeshRenderer).enable=!1,this.mAxis[I.Z].getComponent(d.MeshRenderer).enable=!1,this.mAxis[this.currentAxis].getComponent(d.MeshRenderer).enable=!0,this.mLastAngle=this.getAngle())}onMouseUp(e){super.onMouseUp(e),this.currentAxis==I.NONE&&(this.mAxis[I.X].getComponent(d.MeshRenderer).enable=!0,this.mAxis[I.Y].getComponent(d.MeshRenderer).enable=!0,this.mAxis[I.Z].getComponent(d.MeshRenderer).enable=!0)}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=new d.Object3D;switch(e){case I.X:t.rotationZ=90;break;case I.Y:break;case I.Z:t.rotationX=90;break}let a=t.addComponent(d.MeshRenderer);a.geometry=new Nh(20,.4),a.material=this.mAxisMaterial[e];let r=t.addComponent(Kt),i=new ri;return i.setFromCenterAndSize(new b,new b(40,.4,40)),r.shape=i,t}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(A.inputSystem.mouseX,A.inputSystem.mouseY),r,i;for(let n=0;n<=I.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r)){let l=b.distance(r.intersectPoint,o.shape.center);if(l>20+.8||l<20-.8)continue;(!i||i.distance>r.distance)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint})}}return i}}class Oh extends Mn{init(e){super.init(e);let t=new st;t.doubleSide=!0,t.baseColor=new O(0,0,1),t.depthCompare=$e.always,this.mAxisColor[I.XY]=t.baseColor,this.mAxisMaterial[I.XY]=t;let a=new st;a.doubleSide=!0,a.baseColor=new O(0,1,0),a.depthCompare=$e.always,this.mAxisColor[I.XZ]=a.baseColor,this.mAxisMaterial[I.XZ]=a;let r=new st;r.doubleSide=!0,r.baseColor=new O(1,0,0),r.depthCompare=$e.always,this.mAxisColor[I.YZ]=r.baseColor,this.mAxisMaterial[I.YZ]=r;let i=this.createPlane(I.XY),n=this.createPlane(I.XZ),o=this.createPlane(I.YZ);this.mContainer.addChild(this.mAxis[I.XY]=i),this.mContainer.addChild(this.mAxis[I.XZ]=n),this.mContainer.addChild(this.mAxis[I.YZ]=o),this.mAxisCollider[I.XY]=i.getComponent(Kt),this.mAxisCollider[I.XZ]=n.getComponent(Kt),this.mAxisCollider[I.YZ]=o.getComponent(Kt)}applyLocalTransform(e,t,a){R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix).invert(),R.help_matrix_0.transformVector(t,b.HELP_0),this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ||(b.HELP_0.x=0),this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ||(b.HELP_0.y=0),this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ||(b.HELP_0.z=0),this.mX.transform.worldMatrix.transformVector(b.HELP_0,b.HELP_1),this.mX.x+=b.HELP_1.x,this.mX.y+=b.HELP_1.y,this.mX.z+=b.HELP_1.z}applyGlobalTransform(e,t,a){R.help_matrix_0.identity(),(this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ)&&R.help_matrix_0.appendTranslation(t.x,0,0),(this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ)&&R.help_matrix_0.appendTranslation(0,t.y,0),(this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ)&&R.help_matrix_0.appendTranslation(0,0,t.z),R.help_matrix_1.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.append(R.help_matrix_0),this.mX.parent&&(R.help_matrix_2.copyFrom(this.mX.parent.worldMatrix),R.help_matrix_2.invert(),R.help_matrix_1.multiply(R.help_matrix_2));let r=R.help_matrix_1.decompose(Wt.QUATERNION);this.mX.transform.localPosition=r[0],console.log(this.target.localPosition)}createCustomAxis(e){let t=super.createAxis(e),a=this.createArrows(e);return t.addChild(a),t}createArrows(e){let t=0,a=0,r=0,i=new d.Object3D;switch(e){case I.X:t=1,i.rotationZ=-90;break;case I.Y:a=1,i.rotationY=-90;break;case I.Z:r=1,i.rotationX=90;break}let n=.2+t*20,o=.2+a*20,l=.2+r*20;i.x=n*.5,i.y=o*.5,i.z=l*.5;let c=i.addComponent(d.MeshRenderer);return c.geometry=new Mh(0,1,4),c.material=this.mAxisMaterial[e],i}createPlane(e){let t=new d.Object3D,a=t.addComponent(d.MeshRenderer);a.material=this.mAxisMaterial[e];let r=t.addComponent(Kt),i=new ri;switch(r.shape=i,e){case I.XY:a.geometry=new Hr(4,4,1,1,b.Z_AXIS),t.x=8,t.y=8,i.setFromCenterAndSize(new b(0,0,0),new b(4,4,.1));break;case I.XZ:a.geometry=new Hr(4,4,1,1,b.Y_AXIS),t.x=8,t.z=8,i.setFromCenterAndSize(new b(0,0,0),new b(4,.1,4));break;case I.YZ:a.geometry=new Hr(4,4,1,1,b.X_AXIS),t.y=8,t.z=8,i.setFromCenterAndSize(new b(0,0,0),new b(.1,4,4));break}return t}}class Qo extends d.Object3D{static _instance;static get instance(){return this._instance||(this._instance=new Qo),this._instance}mTarget;mTransformMode=tt.NONE;mTransformSpaceType=qt.Global;mControllers;mXObj;mYObj;mZObj;constructor(){super(),this.mControllers=[null,null,null],this.mControllers[tt.Scale]=this.addComponent(Ph),this.mControllers[tt.Rotation]=this.addComponent(Vh),this.mControllers[tt.Translation]=this.addComponent(Oh),this.mControllers[tt.Scale].enable=!1,this.mControllers[tt.Rotation].enable=!1,this.mControllers[tt.Translation].enable=!1,this.mXObj=new d.Object3D,this.mYObj=new d.Object3D,this.mZObj=new d.Object3D,this.mXObj.addChild(this.mYObj),this.mYObj.addChild(this.mZObj)}get transformMode(){return this.mTransformMode}get transformSpaceMode(){return this.mTransformSpaceType}active(e){e.addChild(this),e.addChild(this.mXObj)}unActive(e){e.removeChild(this)}get target(){return this.mTarget}selectObject(e,t,a){this.mTarget!=e&&(e?this.activate():this.unactivate(),this.mTarget=e,this.mXObj.localPosition=e.transform.worldPosition.clone()),t!=null&&this.selectTransformMode(t),a!=null&&this.selectTransformSpaceMode(a)}selectTransformMode(e){this.mTransformMode!=e&&(this.mTransformMode!=tt.NONE&&(this.mControllers[this.mTransformMode].enable=!1),this.mTransformMode=e,this.mTransformMode!=tt.NONE&&(this.mControllers[this.mTransformMode].enable=!0))}selectTransformSpaceMode(e){this.mTransformSpaceType!=e&&(this.mTransformSpaceType=e,this.mTransformMode!=tt.NONE&&this.mControllers[this.mTransformMode].reset())}activate(){A.inputSystem.addEventListener(ba.KEY_DOWN,this.onKeyDown,this),A.inputSystem.addEventListener(L.POINTER_DOWN,this.onMouseDown,this,null,99999),A.inputSystem.addEventListener(L.POINTER_MOVE,this.onMouseMove,this,null,99999),A.inputSystem.addEventListener(L.POINTER_UP,this.onMouseUp,this,null,99999)}unactivate(){A.inputSystem.removeEventListener(ba.KEY_DOWN,this.onKeyDown,this),A.inputSystem.removeEventListener(L.POINTER_DOWN,this.onMouseDown,this),A.inputSystem.removeEventListener(L.POINTER_MOVE,this.onMouseMove,this),A.inputSystem.removeEventListener(L.POINTER_UP,this.onMouseUp,this)}onKeyDown(e){switch(e.keyCode){case Oe.Key_R:this.selectTransformMode(tt.Scale),this.selectTransformSpaceMode(qt.Local);break;case Oe.Key_E:this.selectTransformMode(tt.Rotation),this.selectTransformSpaceMode(qt.Global);break;case Oe.Key_W:this.selectTransformMode(tt.Translation),this.selectTransformSpaceMode(qt.Global);break;case Oe.Key_A:this.selectTransformSpaceMode(qt.Local);break;case Oe.Key_S:this.selectTransformSpaceMode(qt.Global);break}}onMouseDown(e){this.mTransformMode!=tt.NONE&&this.mControllers[this.mTransformMode].onMouseDown(e)}onMouseMove(e){this.mTransformMode!=tt.NONE&&this.mControllers[this.mTransformMode].onMouseMove(e)}onMouseUp(e){this.mTransformMode!=tt.NONE&&this.mControllers[this.mTransformMode].onMouseUp(e)}}const Pm=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));d.AccelerateDecelerateInterpolator=v0,d.AccelerateInterpolator=B0,d.AnimationCurve=Ri,d.AnimationCurveT=ur,d.AnimationMonitor=Fr,d.AnimatorEventKeyframe=_b,d.AnticipateInterpolator=S0,d.AnticipateOvershootInterpolator=Bi,d.ArrayHas=Zh,d.ArrayItemIndex=Yh,d.AtlasParser=mf,d.AtmosphericComponent=hb,d.AtmosphericScatteringSky=sd,d.AtmosphericScatteringSkySetting=nd,d.AtmosphericScatteringSky_shader=id,d.AttributeAnimCurve=bd,d.AxisObject=Im,d.B3DMLoader=Ga,d.B3DMLoaderBase=tf,d.B3DMParseUtil=Ws,d.B3DMParser=zs,d.BRDFLUT=cf,d.BRDFLUTGenerate=ff,d.BRDF_frag=ul,d.BatchTable=Ls,d.BiMap=cm,d.BillboardComponent=Ei,d.BillboardType=sr,d.BitUtil=Ol,d.BitmapTexture2D=La,d.BitmapTexture2DArray=sc,d.BitmapTextureCube=Ts,d.Blend=ic,d.BlendFactor=nc,d.BlendMode=te,d.BlendShapeData=Ao,d.BlendShapePropertyData=po,d.BloomPost=gg,d.BlurEffectCreatorBlur_cs=j0,d.BlurEffectCreatorSample_cs=W0,d.BlurTexture2DBufferCreator=Z0,d.BounceInterpolator=Vt,d.BoundUtil=us,d.BoundingBox=ge,d.BoundingSphere=Sr,d.BoundingVolume=Rr,d.BoxColliderShape=ri,d.BoxGeometry=va,d.BrdfLut_frag=rl,d.BsDF_frag=gl,d.BxDF_frag=bl,d.BxdfDebug_frag=Dl,d.BytesArray=kn,d.CEvent=qe,d.CEventDispatcher=Ia,d.CEventListener=Hi,d.CResizeEvent=Ya,d.CSM=Jt,d.Camera3D=Zr,d.CameraControllerBase=kb,d.CameraType=ze,d.CameraUtil=He,d.CapsuleColliderShape=Zb,d.CastPointShadowMaterialPass=_c,d.CastShadowMaterialPass=Dc,d.Clearcoat_frag=ml,d.ClusterBoundsSource_cs=Hc,d.ClusterConfig=pt,d.ClusterDebug_frag=Wo,d.ClusterLight=xl,d.ClusterLightingBuffer=Xc,d.ClusterLightingRender=qc,d.ClusterLighting_cs=Kc,d.CollectInfo=yc,d.ColliderComponent=Kt,d.ColliderShape=Ke,d.ColliderShapeType=ai,d.Color=O,d.ColorGradient=fm,d.ColorLitMaterial=im,d.ColorLitShader=ed,d.ColorPassFragmentOutput=rb,d.ColorPassRenderer=Yc,d.ColorUtil=qi,d.ComData=En,d.Combine_cs=Zf,d.Common_frag=tl,d.Common_vert=al,d.ComponentBase=Pe,d.ComponentCollect=ye,d.ComputeGPUBuffer=Kr,d.ComputeShader=fe,d.Context3D=Po,d.CubeCamera=Ds,d.CubeMapFaceEnum=Y0,d.CubeSky_Shader=Jn,d.CubicBezierCurve=In,d.CubicBezierPath=dm,d.CubicBezierType=yh,d.CycleInterpolator=x0,d.CylinderGeometry=Mh,d.DDGIIrradianceComputePass=u0,d.DDGIIrradianceGPUBufferReader=Gi,d.DDGIIrradianceVolume=Oc,d.DDGIIrradiance_shader=h0,d.DDGILightingPass=p0,d.DDGILighting_shader=m0,d.DDGIMultiBouncePass=g0,d.DDGIProbeRenderer=A0,d.DEGREES_TO_RADIANS=at,d.DRACO_DECODER_GLTF_JS=E0,d.DecelerateInterpolator=U0,d.Denoising_cs=Yf,d.Depth2DTextureArray=a0,d.DepthCubeArrayTexture=e0,d.DepthMaterialPass=Bc,d.DepthOfFieldPost=mg,d.DepthOfView_cs=Rf,d.DoubleArray=Zi,d.EditorInspector=zr,d.Engine3D=A,d.Entity=Vc,d.EntityBatchCollect=Cc,d.EntityCollect=W,d.EnvMap_frag=il,d.ErpImage2CubeMap=wt,d.ErpImage2CubeMapCreateCube_cs=X0,d.ErpImage2CubeMapRgbe2rgba_cs=H0,d.ExtrudeGeometry=qb,d.FAILED=fr,d.FASTFLOOR=fa,d.FXAAPost=_s,d.FXAAShader=c0,d.FastMathShader=sl,d.FatLineGeometry=$b,d.FatLineMaterial=nm,d.FatLine_FS=jl,d.FatLine_VS=Wl,d.FeatureTable=mn,d.FileLoader=At,d.FirstPersonCameraController=Eb,d.Float16ArrayTexture=hs,d.Float32ArrayTexture=Rm,d.FlyCameraController=Rb,d.FontChar=uf,d.FontInfo=df,d.FontPage=hf,d.FontParser=za,d.ForwardRenderJob=_0,d.FragmentOutput=Zn,d.FragmentVarying=ll,d.FrameCache=ao,d.Frustum=rs,d.FrustumCSM=rc,d.FrustumCulling_cs=ab,d.FullQuad_vert_wgsl=_l,d.GBufferFrame=oe,d.GBufferPass=Ac,d.GBufferPost=pg,d.GBufferStand=Ll,d.GBuffer_pass=Yn,d.GILighting=Is,d.GIProbeMaterial=Nd,d.GIProbeMaterialType=uo,d.GIProbeShader=td,d.GIRenderCompleteEvent=Bs,d.GIRenderStartEvent=cn,d.GLBChunk=G0,d.GLBHeader=L0,d.GLBParser=Qs,d.GLSLLexer=oc,d.GLSLLexerToken=bi,d.GLSLPreprocessor=lc,d.GLSLSyntax=hc,d.GLTFBinaryExtension=nf,d.GLTFMaterial=Eg,d.GLTFParser=Dt,d.GLTFSubParser=hn,d.GLTFSubParserCamera=R0,d.GLTFSubParserConverter=O0,d.GLTFSubParserMaterial=I0,d.GLTFSubParserMesh=w0,d.GLTFSubParserSkeleton=ws,d.GLTFSubParserSkin=Q0,d.GLTFType=Zt,d.GLTF_Accessors=o2,d.GLTF_Info=fn,d.GLTF_Light=r2,d.GLTF_Mesh=s2,d.GLTF_Node=i2,d.GLTF_Primitives=n2,d.GLTF_Scene=a2,d.GPUAddressMode=Pt,d.GPUBlendFactor=Xh,d.GPUBufferBase=Ta,d.GPUBufferType=ea,d.GPUCompareFunction=$e,d.GPUContext=S,d.GPUCullMode=Ft,d.GPUFilterMode=qa,d.GPUPrimitiveTopology=zn,d.GPUTextureFormat=Y,d.GPUVertexFormat=di,d.GPUVertexStepMode=qh,d.GSplatFormat=oi,d.GSplatGeometry=Tc,d.GSplatMaterial=Ec,d.GSplat_FS=kc,d.GSplat_VS=Fc,d.GTAOPost=Ag,d.GTAO_cs=wf,d.GUIAtlasTexture=gf,d.GUICanvas=Ti,d.GUIConfig=xr,d.GUIGeometry=_d,d.GUIGeometryRebuild=Ud,d.GUIMaterial=so,d.GUIPassRenderer=D0,d.GUIPick=Sd,d.GUIPickHelper=kd,d.GUIQuad=Da,d.GUIQuadAttrEnum=We,d.GUIRenderer=vd,d.GUIShader=no,d.GUISpace=Ht,d.GUISprite=qr,d.GUITexture=ir,d.GaussianSplatParser=xg,d.GenerayRandomDir=Cl,d.GeoJsonParser=Fg,d.GeoJsonUtil=kg,d.GeoType=xn,d.GeometryBase=Fe,d.GeometryIndicesBuffer=Ic,d.GeometryUtil=Qm,d.GeometryVertexBuffer=Rc,d.GeometryVertexType=bt,d.GetComponentClass=Vo,d.GetCountInstanceID=Ln,d.GetRepeat=ou,d.GetShader=Oo,d.GlassShader=ib,d.GlobalBindGroup=le,d.GlobalBindGroupLayout=is,d.GlobalFog=Dg,d.GlobalFog_shader=to,d.GlobalIlluminationComponent=Lb,d.GlobalUniform=Wn,d.GlobalUniformGroup=bs,d.GodRayPost=_g,d.GodRay_cs=If,d.GridObject=Tm,d.HDRTexture=Ns,d.HDRTextureCube=gn,d.Hair_frag=Fl,d.Hair_shader_op=nb,d.Hair_shader_tr=sb,d.HaltonSeq=an,d.Horizontal=wd,d.HoverCameraController=wb,d.I3DMLoader=sa,d.I3DMLoaderBase=sf,d.I3DMParser=lf,d.IBLEnvMapCreator=$0,d.IBLEnvMapCreator_cs=q0,d.IESProfiles=ra,d.IESProfiles_frag=fl,d.IKDTreeUserData=ag,d.ImageType=ti,d.IndicesGPUBuffer=wc,d.Inline_vert=el,d.InputSystem=No,d.InstanceDrawComponent=Gb,d.InstanceUniform=nl,d.InstancedMesh=of,d.Interpolator=rr,d.InterpolatorEnum=Us,d.IrradianceDataReaderCompleteEvent=Hd,d.IrradianceVolumeData_frag=$o,d.Irradiance_frag=hl,d.IsEditorInspector=Wh,d.IsNonSerialize=Vn,d.Joint=T0,d.JointPose=Rs,d.JumperInterpolator=C0,d.KDTreeEntity=ig,d.KDTreeNode=lr,d.KDTreeRange=Ld,d.KDTreeSpace=Gd,d.KDTreeUUID=Li,d.KHR_draco_mesh_compression=Es,d.KHR_lights_punctual=Rg,d.KHR_materials_clearcoat=N0,d.KHR_materials_emissive_strength=P0,d.KHR_materials_ior=wg,d.KHR_materials_unlit=V0,d.KMZParser=yf,d.KV=mo,d.KelvinUtil=Mm,d.KeyCode=Oe,d.KeyEvent=ba,d.Keyframe=_n,d.KeyframeT=ji,d.LDRTextureCube=pn,d.LOADED=Ba,d.LOADING=Do,d.LRUCache=mh,d.LambertMaterial=sm,d.Lambert_shader=El,d.LightBase=yi,d.LightData=tn,d.LightEntries=Lc,d.LightType=Ye,d.LightingFunction_frag=jo,d.Line=ot,d.LineClassification=xd,d.LinearInterpolator=y0,d.LitMaterial=pa,d.Lit_shader=pl,d.LoaderBase=yr,d.LoaderEvent=ng,d.LoaderManager=Sn,d.MAX_VALUE=au,d.MIN_VALUE=ru,d.Material=ut,d.MaterialDataUniformGPUBuffer=mc,d.MaterialUtilities=Fn,d.MathShader=Zo,d.MathUtil=vt,d.Matrix3=kr,d.Matrix4=R,d.MatrixBindGroup=Jc,d.MatrixGPUBuffer=zc,d.MatrixShader=Sl,d.MemoryDO=Xa,d.MemoryInfo=Go,d.MergeRGBACreator=lg,d.MergeRGBA_cs=Qf,d.MeshColliderShape=yn,d.MinMaxAnimationCurves=gm,d.MinMaxCurve=Rh,d.MinMaxCurveState=Eh,d.MinMaxPolyCurves=mm,d.MorePassParser=hg,d.MorePassShader=Yd,d.MorphTargetBlender=vb,d.MorphTargetData=jc,d.MorphTargetFrame=yb,d.MorphTargetTransformKey=pd,d.MorphTarget_shader=Nt,d.MouseCode=Cn,d.MultiBouncePass_cs=b0,d.Navi3DAstar=Qh,d.Navi3DConst=Yi,d.Navi3DEdge=ha,d.Navi3DFunnel=ja,d.Navi3DMaskType=br,d.Navi3DMesh=Fm,d.Navi3DPoint=Bt,d.Navi3DPoint2D=Io,d.Navi3DPointFat=da,d.Navi3DRouter=re,d.Navi3DTriangle=Th,d.NonSerialize=Pn,d.NormalMap_frag=ol,d.OAnimationEvent=M0,d.OBJParser=J0,d.Object3DEvent=sg,d.Object3DTransformTools=Qo,d.Object3DUtil=Nm,d.ObjectAnimClip=gd,d.OcclusionSystem=As,d.Octree=tr,d.OctreeEntity=xc,d.OrbitController=Ib,d.OrderMap=hm,d.Orientation3D=Wt,d.OutLineBlendColor_cs=Tf,d.OutlineCalcOutline_cs=Mf,d.OutlinePass=ob,d.OutlinePost=Bg,d.OutlinePostData=qd,d.OutlinePostManager=$d,d.OutlinePostSlot=Kd,d.Outline_cs=Nf,d.OvershootInterpolator=F0,d.PARSING=bh,d.PBRLItShader=Al,d.PBRLitSSSShader=ad,d.PLUGIN_REGISTERED=Yg,d.ParserBase=nt,d.ParserFormat=Ge,d.ParticleSystemCurveEvalMode=kh,d.ParticleSystemRandomnessIds=Ch,d.PassGenerate=Di,d.PassShader=Xd,d.PassType=H,d.PhysicMaterialUniform_frag=Yo,d.PickCompute=Pd,d.PickFire=Vd,d.PickGUIEvent3D=lt,d.PickResult=eh,d.Picker_cs=Pf,d.PingPong=Xn,d.PipelinePool=ls,d.Plane3D=wh,d.PlaneClassification=wr,d.PlaneGeometry=Hr,d.PointClassification=Fd,d.PointLightShadowRenderer=t0,d.PointShadowCubeCamera=$c,d.PointerEvent3D=L,d.Polynomial=Ua,d.PolynomialCurve=Wa,d.Polynomials=bm,d.PoolNode=yd,d.PostBase=Rt,d.PostProcessingComponent=Sf,d.PostRenderer=s0,d.PreDepthPassRenderer=i0,d.PreFilteredEnvironment_cs=o0,d.PreFilteredEnvironment_cs2=X2,d.PreIntegratedLut=Vf,d.PreIntegratedLutCompute=Zd,d.PrefabAvatarData=go,d.PrefabAvatarParser=oh,d.PrefabBoneData=bo,d.PrefabMaterialParser=ch,d.PrefabMeshData=fh,d.PrefabMeshParser=dh,d.PrefabNode=zi,d.PrefabParser=uh,d.PrefabStringUtil=Pg,d.PrefabTextureData=lh,d.PrefabTextureParser=hh,d.Preprocessor=ta,d.PriorityQueue=Bo,d.Probe=Md,d.ProbeEntries=cg,d.ProbeGBufferFrame=d0,d.ProfilerUtil=Ze,d.PropertyAnimClip=Db,d.PropertyAnimTag=md,d.PropertyAnimation=ro,d.PropertyAnimationClip=ko,d.PropertyAnimationClipState=ud,d.PropertyAnimationEvent=Ii,d.PropertyHelp=wi,d.QuadAABB=_t,d.QuadGlsl_fs=wl,d.QuadGlsl_vs=Rl,d.QuadRoot=Jd,d.QuadTree=zd,d.QuadTreeCell=cr,d.Quad_depth2dArray_frag_wgsl=$h,d.Quad_depth2d_frag_wgsl=vl,d.Quad_depthCube_frag_wgsl=yl,d.Quad_frag_wgsl=Ul,d.Quad_vert_wgsl=Bl,d.Quaternion=Z,d.R32UintTexture=Nc,d.RADIANS_TO_DEGREES=Wr,d.RGBEErrorCode=K0,d.RGBEHeader=Ps,d.RGBEParser=Vs,d.RTDescriptor=ke,d.RTFrame=Je,d.RTResourceConfig=ga,d.RTResourceMap=mt,d.Rand=hi,d.RandomSeed=lu,d.Ray=jt,d.RayCastMeshDetail=si,d.Reader=Yr,d.Rect=ui,d.Reference=me,d.Reflection=ld,d.ReflectionCG=zl,d.ReflectionEntries=Gc,d.ReflectionMaterial=fd,d.ReflectionRenderer=l0,d.ReflectionShader=cd,d.ReflectionShader_shader=Gl,d.RegisterComponent=Mt,d.RegisterShader=Qa,d.RenderContext=ps,d.RenderLayer=_i,d.RenderLayerUtil=cs,d.RenderNode=Oa,d.RenderShaderCollect=Sc,d.RenderShaderCompute=jd,d.RenderShaderPass=Ne,d.RenderTexture=gt,d.RendererBase=ma,d.RendererJob=f0,d.RendererMap=n0,d.RendererMask=De,d.RendererMaskUtil=zt,d.RendererPassState=Zc,d.RepeatSE=Hn,d.Res=Cf,d.RotationControlComponents=Vh,d.SHCommon_frag=Jl,d.SN_ArrayConstant=gi,d.SN_BinaryOperation=er,d.SN_Break=Vu,d.SN_CodeBlock=ia,d.SN_Constant=Pa,d.SN_Continue=sn,d.SN_Declaration=Ve,d.SN_Discard=Ou,d.SN_DoWhileLoop=Pu,d.SN_Expression=de,d.SN_ForLoop=_r,d.SN_Function=rn,d.SN_FunctionArgs=nn,d.SN_FunctionCall=Dr,d.SN_IFBranch=Ur,d.SN_Identifier=Na,d.SN_IndexOperation=vr,d.SN_Layout=Ai,d.SN_ParenExpression=fc,d.SN_Precision=on,d.SN_Return=mi,d.SN_SelectOperation=pi,d.SN_Struct=Ma,d.SN_TernaryOperation=dc,d.SN_UnaryOperation=Xr,d.SN_WhileLoop=Br,d.SSAO_cs=H2,d.SSGI2_cs=Of,d.SSGIPost=Ug,d.SSRPost=vg,d.SSR_BlendColor_cs=Lf,d.SSR_IS_Kernel=yg,d.SSR_IS_cs=Gf,d.SSR_RayTrace_cs=zf,d.ScaleControlComponents=Ph,d.Scene3D=Xb,d.Shader=it,d.ShaderAttributeInfo=os,d.ShaderConverter=uc,d.ShaderConverterResult=bc,d.ShaderLib=J,d.ShaderPassBase=Gn,d.ShaderReflection=dt,d.ShaderStage=na,d.ShaderState=gc,d.ShaderUniformInfo=ss,d.ShaderUtil=Va,d.ShadingInput=cl,d.ShadowLightsCollect=Et,d.ShadowMapPassRenderer=r0,d.ShadowMapping_frag=dl,d.Skeleton=Cb,d.SkeletonAnimationClip=dn,d.SkeletonAnimationClipState=hd,d.SkeletonAnimationCompute=Sb,d.SkeletonAnimation_shader=Jr,d.SkeletonBlendComputeArgs=xb,d.SkeletonPose=vi,d.SkeletonTransformComputeArgs=Fb,d.SkyGBufferPass=pc,d.SkyGBuffer_pass=Il,d.SkyMaterial=od,d.SkyRenderer=Dn,d.SolidColorSky=wm,d.SphereColliderShape=Yb,d.SphereGeometry=Cr,d.SphereReflection=dd,d.StandShader=z0,d.StatementNode=Ce,d.StorageGPUBuffer=_e,d.StringUtil=yt,d.Struct=fi,d.StructStorageGPUBuffer=fg,d.SubGeometry=Qc,d.TAACopyTex_cs=Jf,d.TAAPost=Cg,d.TAASharpTex_cs=Wf,d.TAA_cs=jf,d.TestComputeLoadBuffer=Xf,d.TextAnchor=Ed,d.TextFieldLayout=Qd,d.TextFieldLine=Id,d.Texture=Xe,d.TextureCube=un,d.TextureCubeFaceData=Os,d.TextureCubeStdCreator=bn,d.TextureCubeUtils=Ms,d.TextureMipmapCompute=dg,d.TextureMipmapGenerator=aa,d.TextureScaleCompute=Wd,d.ThirdPersonCameraController=Tb,d.Tile=_o,d.TileSet=qg,d.TileSetChild=em,d.TileSetChildContent=tm,d.TileSetChildContentMetaData=am,d.TileSetRoot=$g,d.TilesRenderer=Kg,d.Time=xe,d.TokenType=U,d.TorusGeometry=Nh,d.TouchData=Mo,d.TrailGeometry=km,d.Transform=kt,d.TransformAxisEnum=I,d.TransformControllerBaseComponent=Mn,d.TransformMode=tt,d.TransformSpaceMode=qt,d.TranslationControlComponents=Oh,d.TranslatorContext=ns,d.TriGeometry=Em,d.Triangle=Vi,d.UIButton=lo,d.UIButtonTransition=Td,d.UIComponentBase=oo,d.UIEvent=og,d.UIImage=Er,d.UIImageGroup=co,d.UIInteractive=vn,d.UIInteractiveStyle=Le,d.UIPanel=Pi,d.UIRenderAble=Ni,d.UIShadow=fo,d.UITextField=ho,d.UITransform=Ja,d.UNLOADED=dr,d.UUID=xt,d.UV=wo,d.Uint32ArrayTexture=Mc,d.Uint8ArrayTexture=ds,d.UnLit=kl,d.UnLitMaterial=st,d.UnLitMaterialUniform_frag=Xo,d.UnLitTexArrayMaterial=lm,d.UnLitTextureArray=rd,d.UnLit_frag=Ho,d.UniformGPUBuffer=ct,d.UniformNode=Ha,d.UniformType=ft,d.ValueEnumType=z,d.ValueOp=xm,d.ValueParser=_a,d.ValueSpread=pm,d.Vector2=K,d.Vector3=b,d.Vector3Ex=Qi,d.Vector4=$,d.VertexAttribute=tg,d.VertexAttributeIndexShader=$f,d.VertexAttributeName=V,d.VertexAttributeSize=Ka,d.VertexAttributeStride=Od,d.VertexAttributes_vert=Ko,d.VertexBufferLayout=eg,d.VertexFormat=Jo,d.VertexGPUBuffer=ln,d.Vertical=Rd,d.VideoUniform_frag=qo,d.View3D=Hb,d.ViewPanel=Bn,d.ViewQuad=ms,d.VirtualTexture=pe,d.WGS84_FLATTENING=jg,d.WGS84_HEIGHT=Zg,d.WGS84_RADIUS=Wg,d.WGSLTranslator=cc,d.WayLines3D=ki,d.WayPoint3D=Fi,d.WebGPUDescriptorCreator=Re,d.WorldMatrixUniform=jn,d.WorldPanel=Un,d.WrapMode=ii,d.WrapTimeMode=or,d.ZCullingCompute=bg,d.ZPassShader_cs=qf,d.ZPassShader_fs=Vl,d.ZPassShader_vs=Pl,d.ZSorterUtil=Uc,d.append=ac,d.arrayToString=ef,d.blendComponent=Hh,d.buildCurves=Dm,d.byteSizeOfType=rh,d.calculateCurveRangesValue=_m,d.calculateMinMax=Ji,d.castPointShadowMap_vert=Tl,d.clamp=ie,d.clampRepeat=Eu,d.computeAABBFromPositions=th,d.cos=Bu,d.crossProduct=xu,d.cubicPolynomialRoot=Sh,d.cubicPolynomialRootsGeneric=xh,d.curvesSupportProcedural=Am,d.deg2Rad=Au,d.detectGSplatFormat=ah,d.directionShadowCastMap_frag=Nl,d.dot=ht,d.doubleIntegrateSegment=Fh,d.downSample=kf,d.fastInvSqrt=ec,d.floorfToIntPos=$l,d.fonts=$r,d.generateRandom=Fu,d.generateRandom3=ku,d.getFloatFromInt=Hl,d.getGLTypeFromTypedArray=D2,d.getGLTypeFromTypedArrayType=A2,d.getGlobalRandomSeed=Uu,d.getTypedArray=_2,d.getTypedArrayTypeFromGLType=ks,d.grad1=Ro,d.grad2=Tn,d.grad3=Wi,d.grad4=li,d.inferSHOrder=ih,d.integrateSegment=Eo,d.irradianceDataReader=ug,d.kPI=um,d.lerp=Ar,d.lerpByte=su,d.lerpColor=nu,d.lerpVector3=iu,d.lruPriorityCallback=vh,d.magnitude=qn,d.makeAloneSprite=k2,d.makeGUISprite=bf,d.makeMatrix44=en,d.markUsedSetLeaves=So,d.markUsedTiles=wn,d.markVisibleTiles=xo,d.matrixMultiply=as,d.matrixRotate=Qu,d.matrixRotateY=Iu,d.mergeFunctions=Ki,d.multiplyMatrices4x4REF=tc,d.normal_distribution=Ih,d.normalizeFast=Su,d.normalizeSafe=Xl,d.normalizedToByte=Cu,d.normalizedToWord=yu,d.outlinePostData=ca,d.outlinePostManager=Sg,d.parsePlyGaussianSplat=sh,d.parsePlyHeader=nh,d.perm=ce,d.post=Ef,d.priorityCallback=Uh,d.quadraticPolynomialRootsGeneric=Qn,d.rad2Deg=Du,d.random01=jr,d.randomBarycentricCoord=pu,d.randomPointBetweenEllipsoid=mu,d.randomPointBetweenSphere=bu,d.randomPointInsideCube=hu,d.randomPointInsideEllipsoid=uu,d.randomPointInsideUnitCircle=gu,d.randomPointInsideUnitSphere=ql,d.randomQuaternion=fu,d.randomQuaternionUniformDistribution=du,d.randomUnitVector=$i,d.randomUnitVector2=Kl,d.rangedRandomFloat=rt,d.rangedRandomInt=cu,d.readByType=et,d.readMagicBytes=Gs,d.registerMaterial=om,d.repeat=ts,d.rotMatrix=wu,d.rotateVectorByQuat=tu,d.roundfToIntPos=$n,d.scale=Kn,d.shadowCastMap_frag=Ml,d.shadowCastMap_vert=Ql,d.simplex=Lt,d.sin=_u,d.snoise1=vm,d.snoise2=ym,d.snoise3=Cm,d.snoise4=Sm,d.sqrMagnitude=es,d.sqrtImpl=Yl,d.stencilStateFace=Kh,d.swap=vu,d.textureCompress=Hf,d.threshold=Ff,d.throttle=rm,d.toHalfFloat=ar,d.toggleTiles=Fo,d.traverseAncestors=Xg,d.traverseSet=ph,d.tw=tb,d.uniform_real_distribution=Bm,d.uniform_real_distribution2=Um,d.upSample=eo,d.webGPUContext=E,d.zSorterUtil=vc,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
11690
+ `);if(t<0)throw new Error("PLY: Invalid PLY header");const a=e.substring(0,t+11),r=a.split(/\r?\n/);let i="",n=0;const o=[];let l=!1;for(const c of r)if(c.startsWith("format "))i=c.split(/\s+/)[1];else if(c.startsWith("element ")){const f=c.split(/\s+/);l=f[1]==="vertex",l&&(n=parseInt(f[2]))}else if(l&&c.startsWith("property ")){const f=c.split(/\s+/),h=f[1],u=f[2];o.push({name:u,type:h})}if(i!=="binary_little_endian")throw new Error("PLY: Only binary_little_endian PLY is supported");return{format:i,vertexCount:n,properties:o,headerByteLength:a.length}}function sh(s){const e=nh(s),{vertexCount:t,properties:a,headerByteLength:r}=e,i=new DataView(s,r),n=C=>a.find(y=>y.name===C)!=null,o=C=>a.findIndex(y=>y.name===C),l=new Float32Array(t*3),c=n("scale_0")?new Float32Array(t*3):void 0,f=n("rot_0")?new Float32Array(t*4):void 0,h=n("opacity")?new Float32Array(t):void 0,u=[o("f_dc_0"),o("f_dc_1"),o("f_dc_2")],g=[];for(let C=0;C<a.length;C++)a[C].name.startsWith("f_rest_")&&g.push(C);const p=u[0]>=0&&u[1]>=0&&u[2]>=0;let m,D=0;if(p){const C=1+g.length/3;D=ih(C),m=new Float32Array(t*C*3)}const _=[];let B=0;for(const C of a)_.push(B),B+=rh(C.type);let v=0;for(let C=0;C<t;C++){const y=v,F=o("x"),k=o("y"),w=o("z");if(F<0||k<0||w<0)throw new Error("PLY: Missing x/y/z for vertex");if(l[C*3+0]=et(i,y+_[F],a[F].type),l[C*3+1]=et(i,y+_[k],a[k].type),l[C*3+2]=et(i,y+_[w],a[w].type),c){const x=o("scale_0"),M=o("scale_1"),N=o("scale_2");c[C*3+0]=et(i,y+_[x],a[x].type),c[C*3+1]=et(i,y+_[M],a[M].type),c[C*3+2]=et(i,y+_[N],a[N].type)}if(f){const x=o("rot_0"),M=o("rot_1"),N=o("rot_2"),Q=o("rot_3"),G=et(i,y+_[x],a[x].type),X=et(i,y+_[M],a[M].type),ne=et(i,y+_[N],a[N].type),q=et(i,y+_[Q],a[Q].type);f[C*4+0]=X,f[C*4+1]=ne,f[C*4+2]=q,f[C*4+3]=G}if(h){const x=o("opacity");h[C]=et(i,y+_[x],a[x].type)}if(p&&m){const x=1+g.length/3,M=C*x*3;m[M+0]=et(i,y+_[u[0]],a[u[0]].type),m[M+x+0]=et(i,y+_[u[1]],a[u[1]].type),m[M+2*x+0]=et(i,y+_[u[2]],a[u[2]].type);let N=1,Q=1,G=1;for(let X=0;X<g.length;X+=3){const ne=g[X+0],q=g[X+1],he=g[X+2];m[M+N]=et(i,y+_[ne],a[ne].type),m[M+x+Q]=et(i,y+_[q],a[q].type),m[M+2*x+G]=et(i,y+_[he],a[he].type),N++,Q++,G++}}v+=B}return{vertexCount:t,position:l,scale:c,rotation:f,opacity:h,sh:p&&m?{order:D,coeffs:m}:void 0}}class xg extends nt{static format=Ge.BIN;async parseBuffer(e){const t=ah(e);let a;switch(t){case oi.PLY:{const r=sh(e);a={count:r.vertexCount,position:r.position,rotation:r.rotation,scale:r.scale,opacity:r.opacity,sh:r.sh},a.bbox=th(r.position);break}case oi.SPLAT:throw new Error("SPLAT format is not yet supported");case oi.KSPLAT:throw new Error("KSPLAT format is not yet supported");case oi.UNKNOWN:default:throw new Error("Unknown or unsupported Gaussian Splatting file format")}return this.data=a,a}verification(){return!!this.data&&this.data.count>0}}var xn=(s=>(s.Point="Point",s.LineString="LineString",s.MultiPolygon="MultiPolygon",s))(xn||{});class Fg extends nt{static format=Ge.JSON;json;async parseString(e){this.json=e,this.data=JSON.parse(e)}}class kg{static getPath(e){let t=[];for(let a=0;a<e.features.length;a++){const r=e.features[a];switch(r.geometry.type){case xn.LineString:break;case xn.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 Eg{name;defines;doubleSided;baseColorFactor;emissiveFactor;metallicFactor;roughnessFactor;alphaCutoff;enableBlend;baseColorTexture;metallicRoughnessTexture;normalTexture;occlusionTexture;emissiveTexture;extensions;baseMapOffsetSize;normalMapOffsetSize;emissiveMapOffsetSize;roughnessMapOffsetSize;metallicMapOffsetSize;aoMapOffsetSize}class Rg{}class wg{}class bo{boneName;bonePath;parentBoneName;boneID;parentBoneID;instanceID;parentInstanceID;t;q;s;formBytes(e){this.boneName=e.readUTF(),this.bonePath=e.readUTF(),this.parentBoneName=e.readUTF(),this.boneID=e.readInt32(),this.parentBoneID=e.readInt32(),this.instanceID=e.readUTF(),this.parentInstanceID=e.readUTF(),this.t=e.readVector3(),this.q=e.readQuaternion(),this.s=e.readVector3()}}class go{name;count;boneData;boneMap;formBytes(e){this.boneData=[],this.boneMap=new Map,this.name=e.readUTF(),this.count=e.readInt32();for(let t=0;t<this.count;t++){let a=new bo;a.formBytes(e.readBytesArray()),this.boneData[t]=a,this.boneMap.set(a.boneName,a)}}}class oh extends nt{static format=Ge.BIN;static parser(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new go;i.formBytes(e.readBytesArray()),A.res.addObj(i.name,i)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}V.position,V.normal,V.color,V.TANGENT,V.uv,V.TEXCOORD_1,V.TEXCOORD_2,V.TEXCOORD_2,V.TEXCOORD_4,V.TEXCOORD_5,V.TEXCOORD_6,V.TEXCOORD_7,V.joints0,V.weights0;var z=(s=>(s[s.single=0]="single",s[s.boolean=1]="boolean",s[s.int=2]="int",s[s.int16=3]="int16",s[s.int32=4]="int32",s[s.float=5]="float",s[s.long=6]="long",s[s.uint=7]="uint",s[s.uint32=8]="uint32",s[s.uint64=9]="uint64",s[s.double=10]="double",s[s.string=11]="string",s[s.singleArray=12]="singleArray",s[s.stringArray=13]="stringArray",s[s.floatArray=14]="floatArray",s[s.vector2=15]="vector2",s[s.vector3=16]="vector3",s[s.vector4=17]="vector4",s[s.color=18]="color",s[s.color32=19]="color32",s[s.animationCurve=20]="animationCurve",s[s.quaternion=21]="quaternion",s[s.matrix4x4=22]="matrix4x4",s[s.mesh=23]="mesh",s[s.texture=24]="texture",s[s.material=25]="material",s[s.materials=26]="materials",s[s.skeleton=27]="skeleton",s[s.animClip=28]="animClip",s[s.vector2Int=29]="vector2Int",s[s.int32List=30]="int32List",s[s.colorList=31]="colorList",s[s.color32List=32]="color32List",s))(z||{});class Fn{static GetMaterial(e){let t=e,a=t.split("/");t=a[a.length-1],a=t.split("."),t=a[a.length-1];let r=Oo(t);if(r){let i=new ut;return i.shader=new r,i}else throw new Error("not found shader, shader name is "+t)}static applyMaterialTexture(e,t){for(let a=0;a<t.length;a++){const r=t[a];r.property in e?e[r.property]=r.texture:r.property in e.shader?e.shader[r.property]=r.texture:e.setTexture(r.property,r.texture)}}static applyMaterialProperties(e,t){for(let a=0;a<t.length;a++){const r=t[a],i=r.key;switch(r.type){case z.color:case z.color32:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformColor(i,n)}break;case z.single:case z.float:case z.int:case z.int16:case z.int32:case z.uint:case z.uint32:case z.uint64:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformFloat(i,n)}break;case z.singleArray:{let n=r.getValue()[0];i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformFloat(i,n)}break;case z.vector2:case z.vector2Int:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector2(i,n)}break;case z.vector3:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector3(i,n)}break;case z.vector4:{let n=r.getValue();i in e?e[i]=n:i in e.shader?e.shader[i]=n:e.setUniformVector4(i,n)}break}}}}class _a{static parser(e){switch(e.readInt32()){case z.single:return{t:z.single,v:e.readFloat32()};case z.boolean:return{t:z.boolean,v:e.readBoolean()};case z.int:return{t:z.int,v:e.readInt32()};case z.int16:return{t:z.int16,v:e.readInt16()};case z.int32:return{t:z.int32,v:e.readInt32()};case z.float:return{t:z.float,v:e.readFloat32()};case z.long:return{t:z.long,v:e.readFloat64()};case z.uint:return{t:z.uint,v:e.readUnit32()};case z.uint32:return{t:z.uint32,v:e.readUnit32()};case z.uint64:return{t:z.uint64,v:e.readUnit32()};case z.double:return{t:z.double,v:e.readFloat64()};case z.string:return{t:z.string,v:e.readUTF()};case z.singleArray:return{t:z.singleArray,v:e.readFloatArray()};case z.stringArray:return{t:z.stringArray,v:e.readStringArray()};case z.floatArray:return{t:z.floatArray,v:e.readFloatArray()};case z.vector2:return{t:z.vector2,v:e.readVector2()};case z.vector3:return{t:z.vector3,v:e.readVector3()};case z.vector4:return{t:z.vector4,v:e.readVector4()};case z.color:return{t:z.color,v:e.readColor()};case z.color32:return{t:z.color32,v:e.readColor()};case z.animationCurve:return{t:z.animationCurve,v:null};case z.quaternion:return{t:z.quaternion,v:e.readQuaternion()};case z.matrix4x4:return{t:z.matrix4x4,v:null};case z.mesh:{let o=e.readUTF(),l=A.res.getGeometry(o);return{t:z.mesh,v:l}}case z.texture:{let o=e.readUTF(),l=A.res.getTexture(o);return{t:z.texture,v:l}}case z.material:{let o=e.readUTF(),l=A.res.getMat(o);return{t:z.material,v:l}}case z.materials:{let o=e.readStringArray(),l=[];for(let c=0;c<o.length;c++){const f=o[c];let h=A.res.getMat(f);l.push(h)}return{t:z.materials,v:l}}case z.skeleton:break;case z.animClip:{let o=[],l=e.readInt32();for(let c=0;c<l;c++){let f=new ko;f.formBytes(e),o.push(f)}return{t:z.animClip,v:o}}case z.vector2Int:return{t:z.vector2Int,v:e.readVector2int()};case z.int32List:return{t:z.int32List,v:e.readInt32List()};case z.colorList:let a=e.readInt32(),r=[];for(let o=0;o<a;o++){const l=_a.parser(e).v;r.push(l)}return{t:z.colorList,v:r};case z.color32List:let i=e.readInt32(),n=[];for(let o=0;o<i;o++){const l=_a.parser(e).v;n.push(l)}return{t:z.color32List,v:n}}}}class mo{key;type;_data;getValue(){return this._data}formBytes(e){this.key=e.readUTF();let{t,v:a}=_a.parser(e);this.type=t,this._data=a}}class lh{property;name;texture;texelSize;wrapModeU;wrapModeV;wrapModeW;wrapMode;anisoLevel;dimension;filterMode}class ch extends nt{static format=Ge.TEXT;static parserMaterial(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=e.readBytesArray(),n=i.readUTF(),o=i.readUTF();i.readUTF();let l=i.readStringArray();i.readVector4(),i.readVector4();let c=i.readUTF(),f=[],h=[],u=i.readInt32();for(let m=0;m<u;m++){let D=new mo;D.formBytes(i),f.push(D)}let g=i.readInt32();for(let m=0;m<g;m++){let D=i.readBytesArray(),_=new lh;_.property=D.readUTF(),_.name=D.readUTF(),_.texture=A.res.getTexture(_.name),_.texelSize=D.readVector2(),_.wrapModeU=D.readUnit32(),_.wrapModeV=D.readUnit32(),_.wrapModeW=D.readUnit32(),_.wrapMode=D.readUnit32(),_.anisoLevel=D.readUnit32(),_.dimension=D.readUnit32(),_.filterMode=D.readUnit32(),h.push(_)}let p=Fn.GetMaterial(c);p.name=n;for(let m=0;m<l.length;m++){const D=l[m];p.shader.setDefine(D,!0)}Fn.applyMaterialTexture(p,h),Fn.applyMaterialProperties(p,f),A.res.addMat(o,p)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class po{shapeName;shapeIndex;frameCount;blendPositionList=new Float32Array;blendNormalList=new Float32Array;formBytes(e){let t=e.readBytesArray();this.shapeName=t.readUTF(),this.shapeIndex=t.readInt32(),this.frameCount=t.readInt32();let a=t.readInt32();this.blendPositionList=t.readFloat32Array(a*3);let r=t.readInt32();this.blendNormalList=t.readFloat32Array(r*3)}}class Ao{vertexCount;shapeNames;shapeIndexs;blendCount;blendShapePropertyDatas;blendShapeMap;formBytes(e){this.blendShapeMap=new Map,this.blendShapePropertyDatas=[];let t=e.readBytesArray();this.vertexCount=t.readInt32(),this.shapeNames=t.readStringArray(),this.shapeIndexs=t.readIntArray(),this.blendCount=t.readInt32();for(let a=0;a<this.blendCount;a++){let r=new po;r.formBytes(t),this.blendShapePropertyDatas.push(r),this.blendShapeMap.set(r.shapeName,r)}return e}}class fh{name;meshName;meshID;vertexCount;vertexStrip;vertexBuffer;indices;attributes;bones;bindPose;blendShapeData}class dh extends nt{static format=Ge.BIN;async parseBuffer(e){}static parserMeshs(e,t){let a=e.readInt32();for(let r=0;r<a;r++){let i=new fh,n=e.readBytesArray();i.meshName=n.readUTF(),i.meshID=n.readUTF(),n.readFloat32()>0,n.readFloat32()>0,n.readFloat32()>0;let o=n.readFloat32()>0,l=n.readFloat32()>0;o&&(i.bones=n.readStringArray(),i.bindPose=n.readMatrix44Array()),l&&(i.blendShapeData=new Ao,i.blendShapeData.formBytes(n));let c=n.readBytesArray(),f=n.readBytesArray(),h=c.readInt32(),u=0,g=[];for(let B=0;B<h;B++)g[B]={},g[B].att=Ig[c.readUTF()],g[B].dim=c.readInt32(),u+=g[B].dim,g[B].format=c.readUTF();i.vertexCount=c.readInt32(),i.vertexBuffer=f.getFloat32Array();let p=n.readInt32Array(),m=[],D=n.readInt32();for(let B=0;B<D;B++){let v=n.readInt32(),C=n.readInt32(),y=n.readInt32(),F=n.readInt32(),k=n.readInt32(),w=n.readInt32();n.readVector3(),n.readVector3();let x={indexStart:C,indexCount:y,vertexStart:F,vertexCount:w,firstStart:k,topology:v,index:B};m.push(x)}p.length>65535?i.indices=new Uint32Array(p):i.indices=new Uint16Array(p);let _=new Fe;if(_.vertexDim=u,_.geometryType=bt.compose_bin,_.setIndices(i.indices),_.setAttribute(V.all,i.vertexBuffer),o&&(_.skinNames=i.bones,_.bindPose=i.bindPose),l){_.blendShapeData=i.blendShapeData,_.morphTargetsRelative=!0,_.morphTargetDictionary={};for(let B=0;B<i.blendShapeData.blendCount;B++){_.setAttribute("a_morphPositions_"+B,i.blendShapeData.blendShapePropertyDatas[B].blendPositionList),_.setAttribute("a_morphNormals_"+B,i.blendShapeData.blendShapePropertyDatas[B].blendNormalList);for(let v=0;v<i.blendShapeData.blendCount;v++){let C=i.blendShapeData.shapeNames[v],y=i.blendShapeData.shapeIndexs[v];_.morphTargetDictionary[C]=y}}}for(let B=0;B<g.length;B++){const v=g[B].att;_.setAttribute(v,null)}for(let B=0;B<m.length;B++){const v=m[B];_.addSubGeometry(v)}_.name=i.meshName,A.res.addGeometry(i.meshID,_)}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}let Ig={Position:V.position,Normal:V.normal,Color:V.color,Tangent:V.TANGENT,TexCoord0:V.uv,TexCoord1:V.TEXCOORD_1,TexCoord2:V.TEXCOORD_2,TexCoord3:V.TEXCOORD_2,TexCoord4:V.TEXCOORD_4,TexCoord5:V.TEXCOORD_5,TexCoord6:V.TEXCOORD_6,TexCoord7:V.vIndex,BlendIndices:V.joints0,BlendWeight:V.weights0};class kn extends DataView{get buffer(){return super.buffer}get byteOffset(){return super.byteOffset}get byteLength(){return super.byteLength}getInt16(e,t){return super.getInt16(e,t)}getInt32(e,t){return super.getInt32(e,t)}getFloat32(e,t){return super.getFloat32(e,t)}getFloat64(e,t){return super.getFloat64(e,t)}getUint8(e){return super.getUint8(e)}getUint32(e,t){return super.getUint32(e,t)}getInt8(e){return super.getInt8(e)}getUint16(e,t){return super.getUint16(e,t)}position=0;littleEndian=!0;constructor(e,t,a){super(e,t,a),this.position=0,this.position+=this.byteOffset}readUTF(){let e=this.readInt32(),t=e%4;t>0&&t<4&&(t=4-t);let a="",r=new Int8Array(this.buffer,this.position,e);return this.position+=e*Int8Array.BYTES_PER_ELEMENT,a+=String.fromCharCode.apply(null,r),this.position+=t*Int8Array.BYTES_PER_ELEMENT,a}readStringArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readUTF());return e}readByte(){let e=this.buffer[this.position];return this.position+=1,e}readBoolean(){let e=this.readInt32();return this.position+=4,e==1}readBytes(e){let t=new DataView(this.buffer,this.position,e);return this.position+=e,t.buffer}readBytesArray(){let e=this.readInt32(),t=new kn(this.buffer.slice(this.position,this.position+e));return this.position+=e,t}readUnit8(){let e=this.getUint8(this.position);return this.position+=Uint8Array.BYTES_PER_ELEMENT,e}readUnit16(){let e=this.getUint16(this.position);return this.position+=Uint16Array.BYTES_PER_ELEMENT,e}readUnit32(){let e=this.getUint32(this.position);return this.position+=Uint32Array.BYTES_PER_ELEMENT,e}readInt8(){let e=this.getInt8(this.position);return this.position+=Int8Array.BYTES_PER_ELEMENT,e}readInt16(){let e=this.getInt16(this.position,this.littleEndian);return this.position+=Int16Array.BYTES_PER_ELEMENT,e}readInt32(){let e=this.getInt32(this.position,this.littleEndian);return this.position+=Int32Array.BYTES_PER_ELEMENT,e}readFloat32(){let e=this.getFloat32(this.position,this.littleEndian);return this.position+=Float32Array.BYTES_PER_ELEMENT,e}readFloat64(){let e=this.getFloat64(this.position,this.littleEndian);return this.position+=Float64Array.BYTES_PER_ELEMENT,e}readInt32Array(){let e=this.readInt32(),t=new Int32Array(this.buffer,this.position,e);return t=t.slice(0,e),this.position+=t.byteLength,t}readInt32List(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++)t.push(this.readInt32());return t}readFloatArray(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readFloat32();t.push(r)}return t}readIntArray(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readInt32();t.push(r)}return t}readVector2int(){let e=new K;return e.x=this.readInt32(),e.y=this.readInt32(),e}readVector2(){let e=new K;return e.x=this.readFloat32(),e.y=this.readFloat32(),e}readVector3(){let e=new b;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e}readVector3Array(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readVector3());return e}readVector4(){let e=new $;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e.w=this.readFloat32(),e}readVector4Array(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readVector4());return e}readColor(){let e=new O;return e.r=this.readFloat32(),e.g=this.readFloat32(),e.b=this.readFloat32(),e.a=this.readFloat32(),e}readColorArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readColor());return e}readQuaternion(){let e=new Z;return e.x=this.readFloat32(),e.y=this.readFloat32(),e.z=this.readFloat32(),e.w=this.readFloat32(),e}readQuaternionArray(){let e=[],t=this.readInt32();for(let a=0;a<t;a++)e.push(this.readQuaternion());return e}readMatrix44(){let e=new R,t=e.rawData;return t[0]=this.readFloat32(),t[1]=this.readFloat32(),t[2]=this.readFloat32(),t[3]=this.readFloat32(),t[4]=this.readFloat32(),t[5]=this.readFloat32(),t[6]=this.readFloat32(),t[7]=this.readFloat32(),t[8]=this.readFloat32(),t[9]=this.readFloat32(),t[10]=this.readFloat32(),t[11]=this.readFloat32(),t[12]=this.readFloat32(),t[13]=this.readFloat32(),t[14]=this.readFloat32(),t[15]=this.readFloat32(),e}readMatrix44Array(){let e=this.readInt32(),t=[];for(let a=0;a<e;a++){let r=this.readMatrix44();t.push(r)}return t}readFloat32Array(e){let t=new DataView(this.buffer),a=new Float32Array(e);for(let r=0;r<e;r++)a[r]=t.getFloat32(this.position+r*Float32Array.BYTES_PER_ELEMENT,this.littleEndian);return this.position+=e*Float32Array.BYTES_PER_ELEMENT,a}getFloat32Array(){let e=new Float32Array(this.buffer,this.byteOffset,this.byteLength/Float32Array.BYTES_PER_ELEMENT);return e=e.slice(0,this.byteLength),e}}class hh extends nt{static format=Ge.TEXT;static async parserTexture(e,t,a){let r=e.readInt32(),i=[];for(let o=0;o<r;o++){let l=e.readUTF();uh.useWebp?(l=l.replace("png","webp"),l=l.replace("jpb","webp"),i.push(t.baseUrl+"webp/"+l)):i.push(t.baseUrl+l)}let n=await A.res.loadBitmapTextures(i,A.setting.loader.numConcurrent,a,!0);for(const o of n)A.res.addTexture(o.name,o)}verification(){if(this.data)return!0;throw new Error("verify failed.")}}var Qg=Object.getOwnPropertyDescriptor,Tg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Qg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.LitSSSShader=class extends it{constructor(){super(),J.register("PBRLitSSSShader",ad);let e=new Ne("PBRLitSSSShader","PBRLitSSSShader");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefine("USE_CUSTOMUNIFORM",!0),this.setDefault(),this.computes=[new Zd(this)]}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new $(0,0,1,1)),this.setUniformVector4("transformUV2",new $(0,0,1,1)),this.setUniformColor("baseColor",new O),this.setUniformColor("emissiveColor",new O(1,1,1)),this.setUniformVector4("materialF0",new $(.04,.04,.04,1)),this.setUniformColor("specularColor",new O(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",0),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new O(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this.setUniformColor("skinColor",new O(1,0,0)),this.setUniformFloat("skinPower",3.4),this.setUniformFloat("skinColorIns",.5),this.setUniformFloat("curveFactor",1)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _SSSMap(e){this.setTexture("sssMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Ft.none:t.shaderState.cullMode}set _SkinColor(e){this.setUniformColor("skinColor",e)}set _SkinPower(e){this.setUniformFloat("skinPower",e)}set _SkinColorIns(e){this.setUniformFloat("skinColorIns",e)}set curveFactor(e){this.setUniformFloat("curveFactor",e)}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=te.NONE:t.blendMode=te.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.LitSSSShader=Tg([Qa(d.LitSSSShader,"LitSSSShader")],d.LitSSSShader);var Mg=Object.getOwnPropertyDescriptor,Ng=(s,e,t,a)=>{for(var r=a>1?void 0:a?Mg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.LitShader=class extends it{constructor(){super();let e=new Ne("PBRLItShader","PBRLItShader");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!0,t.castShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,this.setDefine("USE_BRDF",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformFloat("shadowBias",35e-5),this.setUniformVector4("transformUV1",new $(0,0,1,1)),this.setUniformVector4("transformUV2",new $(0,0,1,1)),this.setUniformColor("baseColor",new O),this.setUniformColor("emissiveColor",new O(0,0,0)),this.setUniformVector4("materialF0",new $(.04,.04,.04,1)),this.setUniformColor("specularColor",new O(.04,.04,.04)),this.setUniformFloat("envIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("roughness",1),this.setUniformFloat("metallic",0),this.setUniformFloat("ao",1),this.setUniformFloat("roughness_min",0),this.setUniformFloat("roughness_max",1),this.setUniformFloat("metallic_min",0),this.setUniformFloat("metallic_max",1),this.setUniformFloat("emissiveIntensity",0),this.setUniformFloat("alphaCutoff",0),this.setUniformFloat("ior",1.5),this.setUniformFloat("clearcoatFactor",0),this.setUniformFloat("clearcoatRoughnessFactor",0),this.setUniformColor("clearcoatColor",new O(1,1,1)),this.setUniformFloat("clearcoatWeight",0),this._MainTex=A.res.grayTexture,this._BumpMap=A.res.normalTexture,this._MaskTex=A.res.maskTexture}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Ft.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=te.NONE:t.blendMode=te.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.LitShader=Ng([Qa(d.LitShader,"LitShader")],d.LitShader);class En{comName;data;static parser(e){let t=e.readBytesArray(),a=new En;a.comName=t.readUTF(),a.data=[];let r=t.readInt32();for(let i=0;i<r;i++){let n=new mo;n.formBytes(t),a.data.push(n)}return a}}class zi{name;parentName;position;rotation;scale;comDatas;child;static parser(e){let t=e.readBytesArray(),a=new zi;a.name=t.readUTF(),a.parentName=t.readUTF(),a.position=t.readVector3(),a.rotation=t.readQuaternion(),a.scale=t.readVector3(),a.comDatas=[],a.child=[];let r=t.readInt32();for(let n=0;n<r;n++){const o=En.parser(t);a.comDatas.push(o)}let i=t.readInt32();for(let n=0;n<i;n++){const o=zi.parser(t);a.child.push(o)}return a}}class uh extends nt{static useWebp=!0;static format=Ge.BIN;avatarDic;nodeData;async parseBuffer(e){this.avatarDic={};let t=new kn(e,0);await hh.parserTexture(t,this,this.loaderFunctions),oh.parser(t,this),dh.parserMeshs(t,this),ch.parserMaterial(t,this),this.nodeData=this.parserPrefabNode(t),this.data=this.data=this.parserNodeTree(this.nodeData)}parserPrefabNode(e){return zi.parser(e)}parserNodeTree(e){let t=new d.Object3D;if(t.localPosition=b.serialize(e.position),t.localQuaternion=Z.serialize(e.rotation),t.localScale=b.serialize(e.scale),t.name=e.name,e.comDatas)for(let a=0;a<e.comDatas.length;a++){const r=e.comDatas[a];let i=null,n=Vo(r.comName);if(n){i=t.getOrAddComponent(n);for(let o=0;o<r.data.length;o++){const l=r.data[o];l.key in i&&(i[l.key]=l.getValue())}}}if(e.child&&e.child.length>0)for(let a=0;a<e.child.length;a++){let r=this.parserNodeTree(e.child[a]);t.addChild(r)}return t}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class Pg{static getNumber(e){return parseFloat(e)}static getInt(e){return parseInt(e)}static getBoolean(e){return e=="true"}static getNumberArray(e){let t=e.replaceAll("[","");t=t.replaceAll("]","");let a=t.split(",");for(let r=0;r<a.length;r++)parseFloat(a[r]);return t}static getStringArray(e){let t=e.replaceAll("[","");t=t.replaceAll("]","");let a=t.split(","),r=[];for(let i=0;i<a.length;i++){const n=a[i];r.push(n)}return r}static getVector2(e){}static getVector3(e){}static getVector4(e){}static getQuaternion(e){}static getColor(e){}}var Vg=Object.getOwnPropertyDescriptor,Og=(s,e,t,a)=>{for(var r=a>1?void 0:a?Vg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.FatLineShader=class extends it{constructor(){super();const e=new Ne("FatLine_VS","FatLine_FS");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);const t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1,t.cullMode=Ft.none,t.depthWriteEnabled=!0,this.setDefault()}setDefault(){this.setUniformColor("baseColor",new O(1,1,1,1)),this.setUniformFloat("lineWidth",1),this.setUniformFloat("opacity",1),this.setUniformVector2("resolution",new K(1920,1080));const e=new R;this.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}},d.FatLineShader=Og([Qa(d.FatLineShader,"FatLineShader")],d.FatLineShader);var Lg=Object.getOwnPropertyDescriptor,Gg=(s,e,t,a)=>{for(var r=a>1?void 0:a?Lg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.UnLitShader=class extends it{constructor(){super();let e=new Ne("UnLit","UnLit");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformVector4("transformUV1",new $(0,0,1,1)),this.setUniformVector4("transformUV2",new $(0,0,1,1)),this.setUniformColor("baseColor",new O),this.setUniformFloat("alphaCutoff",0)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Ft.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=te.NONE:t.blendMode=te.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.UnLitShader=Gg([Qa(d.UnLitShader,"UnLitShader")],d.UnLitShader);var zg=Object.getOwnPropertyDescriptor,Jg=(s,e,t,a)=>{for(var r=a>1?void 0:a?zg(e,t):e,i=s.length-1,n;i>=0;i--)(n=s[i])&&(r=n(r)||r);return r};d.UnLitTexArrayShader=class extends it{constructor(){super(),J.register("VertexAttributeIndexShader",$f),J.register("UnLitTextureArray",rd);let e=new Ne("UnLitTextureArray","UnLitTextureArray");e.setShaderEntry("VertMain","FragMain"),this.addRenderPass(e);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1,this.setDefine("USE_BRDF",!0),this.setDefine("USE_AO_R",!0),this.setDefine("USE_ROUGHNESS_G",!0),this.setDefine("USE_METALLIC_B",!0),this.setDefine("USE_ALPHA_A",!0),this.setDefault()}setDefault(){this.setUniformVector4("transformUV1",new $(0,0,1,1)),this.setUniformVector4("transformUV2",new $(0,0,1,1)),this.setUniformColor("baseColor",new O),this.setUniformFloat("alphaCutoff",0)}set _MainTex(e){this.setTexture("baseMap",e)}set _BumpMap(e){this.setTexture("normalMap",e)}set _MaskTex(e){this.setTexture("maskMap",e)}set _UVTransform(e){this.setUniformVector4("transformUV1",e)}set _Metallic(e){this.setUniformFloat("metallic",e)}set _Roughness(e){this.setUniformFloat("roughness",e)}set _MainColor(e){this.setUniformColor("baseColor",e)}set _AlphaCutoff(e){this.setUniformFloat("alphaCutoff",e)}set _DoubleSidedEnable(e){let t=this.getDefaultColorShader();t.shaderState.cullMode=e?Ft.none:t.shaderState.cullMode}set _SurfaceType(e){let t=this.getDefaultColorShader();e==0?t.blendMode=te.NONE:t.blendMode=te.ALPHA}set _AlphaCutoffEnable(e){e==0?this.setDefine("USE_ALPHACUT",!1):this.setDefine("USE_ALPHACUT",!0)}},d.UnLitTexArrayShader=Jg([Qa(d.UnLitTexArrayShader,"UnLitTexArrayShader")],d.UnLitTexArrayShader);const fr=-1,dr=0,Do=1,bh=2,Ba=3,Wg=6378137,jg=1/298.257223563,Zg=6356752314245179e-9,Yg=Symbol("PLUGIN_REGISTERED");class _o{boundingVolume;geometricError;refine;content;contents;transform;extensions;extras;parent=null;children=[];loadingState=dr;used=!1;visible=!1;active=!1;inFrustum=!1;error=1/0;distanceFromCamera=1/0;depth=0;depthFromRenderedParent=0;lastFrameVisited=-1;isLeaf=!1;allChildrenReady=!1;hasContent=!1;hasRenderableContent=!1;hasUnrenderableContent=!1;childrenProcessed=0;usedLastFrame=!1;priority;canTraverse=!1;canTraverseFrame=-1;basePath="";cached={};constructor(e,t=null){if(this.boundingVolume=e.boundingVolume,this.geometricError=e.geometricError,this.refine=e.refine,this.content=e.content,this.contents=e.contents,this.transform=e.transform,this.extensions=e.extensions,this.extras=e.extras,this.parent=t,this.depth=t?t.depth+1:0,this.depthFromRenderedParent=t?.hasContent?0:t?t.depthFromRenderedParent+1:0,this.hasContent=!!(this.content||this.contents&&this.contents.length>0),this.content?.uri){const a=this.content.uri.toLowerCase();this.hasUnrenderableContent=a.endsWith("tileset.json"),this.hasRenderableContent=!this.hasUnrenderableContent}else this.contents&&this.contents.length>0&&(this.hasRenderableContent=!0)}addChild(e){e.parent=this,e.depth=this.depth+1,e.depthFromRenderedParent=this.hasContent?0:this.depthFromRenderedParent+1,this.children.push(e)}resetFrameState(e){this.lastFrameVisited!==e&&(this.lastFrameVisited=e,this.used=!1,this.inFrustum=!1,this.isLeaf=!1,this.visible=!1,this.active=!1,this.error=1/0,this.distanceFromCamera=1/0,this.allChildrenReady=!1)}}const gh=2**30;class mh{minSize=6e3;maxSize=8e3;minBytesSize=.3*gh;maxBytesSize=.4*gh;unloadPercent=.05;autoMarkUnused=!0;_itemSet=new Map;_itemList=[];_usedSet=new Set;_callbacks=new Map;_unloadingHandle=-1;_cachedBytes=0;_bytesMap=new Map;_loadedSet=new Set;_unloadPriorityCallback=null;set unloadPriorityCallback(e){this._unloadPriorityCallback=e}get unloadPriorityCallback(){return this._unloadPriorityCallback}isFull(){return this._itemSet.size>=this.maxSize||this._cachedBytes>=this.maxBytesSize}getMemoryUsage(e){return this._bytesMap.get(e)||0}setMemoryUsage(e,t){if(!this._itemSet.has(e))return;const a=this._bytesMap.get(e)||0;this._cachedBytes-=a,this._bytesMap.set(e,t),this._cachedBytes+=t}add(e,t){return this._itemSet.has(e)||this.isFull()?!1:(this._itemList.push(e),this._usedSet.add(e),this._itemSet.set(e,Date.now()),this._callbacks.set(e,t),this._loadedSet.add(e),!0)}has(e){return this._itemSet.has(e)}remove(e){if(!this._itemSet.has(e))return!1;const t=this._bytesMap.get(e)||0;this._cachedBytes-=t,this._bytesMap.delete(e);const a=this._callbacks.get(e);a&&a(e);const r=this._itemList.indexOf(e);return r!==-1&&this._itemList.splice(r,1),this._usedSet.delete(e),this._itemSet.delete(e),this._callbacks.delete(e),this._loadedSet.delete(e),!0}markUsed(e){this._itemSet.has(e)&&(this._usedSet.add(e),this._itemSet.set(e,Date.now()))}markUnused(e){this._usedSet.delete(e)}scheduleUnload(){this._unloadingHandle===-1&&(this._unloadingHandle=requestAnimationFrame(()=>{this._unloadingHandle=-1,this._performUnload()}))}_performUnload(){if(!(this._itemSet.size>this.minSize||this._cachedBytes>this.minBytesSize))return;this.autoMarkUnused&&this._itemSet.forEach((o,l)=>{this._usedSet.has(l)||this.markUnused(l)});const t=[];this._itemList.forEach(o=>{this._usedSet.has(o)||t.push(o)}),this._unloadPriorityCallback&&t.sort(this._unloadPriorityCallback);const a=Math.floor(this._itemSet.size*(1-this.unloadPercent)),r=this._cachedBytes-(this._cachedBytes-this.minBytesSize);let i=0,n=0;for(let o=0;o<t.length;o++){const l=t[o];if(this._itemSet.size-i<=a&&this._cachedBytes-n<=r)break;const c=this._bytesMap.get(l)||0;this.remove(l)&&(i++,n+=c)}}clear(){Array.from(this._itemSet.keys()).forEach(t=>this.remove(t))}getStats(){return{size:this._itemSet.size,bytes:this._cachedBytes,usedCount:this._usedSet.size}}}class Bo{maxJobs=6;autoUpdate=!0;priorityCallback=null;_items=[];_callbacks=new Map;_currJobs=0;_scheduled=!1;_schedulingCallback;constructor(){this._schedulingCallback=e=>{requestAnimationFrame(e)}}set schedulingCallback(e){this._schedulingCallback=e}get running(){return this._items.length!==0||this._currJobs!==0}sort(){this.priorityCallback&&this._items.sort(this.priorityCallback)}has(e){return this._callbacks.has(e)}add(e,t){if(this._callbacks.has(e))return this._callbacks.get(e).promise;let a,r;const i=new Promise((o,l)=>{a=o,r=l}),n={callback:t,promise:i,resolve:a,reject:r};return this._items.unshift(e),this._callbacks.set(e,n),this.autoUpdate&&this._scheduleJobRun(),i}remove(e){const t=this._items.indexOf(e);if(t!==-1){const a=this._callbacks.get(e);a&&(a.promise.catch(()=>{}),a.reject(new Error("PriorityQueue: Item removed."))),this._items.splice(t,1),this._callbacks.delete(e)}}removeByFilter(e){const t=[];this._items.forEach(a=>{e(a)&&t.push(a)}),t.forEach(a=>this.remove(a))}_scheduleJobRun(){this._scheduled||(this._scheduled=!0,this._schedulingCallback(()=>{this._scheduled=!1,this._tryRunJobs()}))}_tryRunJobs(){this.sort();const e=this.maxJobs;let t=0;const a=()=>{this._currJobs--,this.autoUpdate&&this._scheduleJobRun()};for(;e>this._currJobs&&this._items.length>0&&t<e;){this._currJobs++,t++;const r=this._items.shift(),i=this._callbacks.get(r);this._callbacks.delete(r),Promise.resolve(i.callback(r)).then(()=>{i.resolve(),a()}).catch(n=>{i.reject(n),a()})}}clear(){Array.from(this._items).forEach(t=>this.remove(t))}getStats(){return{queued:this._items.length,running:this._currJobs}}}function ph(s,e=null,t=null){const a=[];for(a.push(s),a.push(null),a.push(0);a.length>0;){const r=a.pop(),i=a.pop(),n=a.pop();if(e&&e(n,i,r)===!0){t&&t(n,i,r);return}const o=n.children;if(o&&o.length>0)for(let l=o.length-1;l>=0;l--)a.push(o[l]),a.push(n),a.push(r+1);if(t&&t(n,i,r)===!0)return}}function Xg(s,e){let t=s;for(;t;){const a=t.depth,r=t.parent;e(t,r,a),t=r}}const Rn={inView:!1,error:1/0,distanceFromCamera:1/0},Ah=!0;function Dh(s){return s===Ba||s===fr}function hr(s,e){return s.lastFrameVisited===e&&s.used}function _h(s){return s.childrenProcessed===s.children.length}function Uo(s){return s.hasUnrenderableContent||s.parent!==null&&s.parent.geometricError<s.geometricError}function vo(s,e){s.lastFrameVisited!==e.frameCount&&(s.usedLastFrame=s.used,s.lastFrameVisited=e.frameCount,s.used=!1,s.inFrustum=!1,s.isLeaf=!1,s.visible=!1,s.active=!1,s.error=1/0,s.distanceFromCamera=1/0,s.allChildrenReady=!1,e.calculateTileViewError(s,Rn),s.inFrustum=Rn.inView,s.error=Rn.error,s.distanceFromCamera=Rn.distanceFromCamera)}function yo(s,e,t=!1){s.used||(t||(s.used=!0,e.stats.used++),e.markTileUsed(s),s.inFrustum===!0&&e.stats.inFrustum++)}function Hg(s,e){if(s.canTraverse&&s.canTraverseFrame===e.frameCount)return s.canTraverse;let t=!1;return s.error<=e.errorTarget&&!Uo(s)||s.depth>=e.maxDepth||!s.children||s.children.length===0?t=!1:t=!0,s.canTraverse=t,s.canTraverseFrame=e.frameCount,t}function Co(s,e,t=!1){if(e.ensureChildrenArePreprocessed(s),vo(s,e),yo(s,e,t),Uo(s)&&_h(s)){const a=s.children;for(let r=0,i=a.length;r<i;r++)Co(a[r],e,t)}}function wn(s,e){if(e.ensureChildrenArePreprocessed(s),vo(s,e),!s.inFrustum)return;if(!Hg(s,e)){yo(s,e);const n=s.children;if(!s.hasContent&&n&&n.length>0)for(let o=0,l=n.length;o<l;o++){const c=n[o];wn(c,e)}return}const a=s.children;let r=!1,i=!1;for(let n=0,o=a.length;n<o;n++){const l=a[n];wn(l,e),r=r||hr(l,e.frameCount),i=i||l.inFrustum}if(s.refine==="REPLACE"&&!i&&a.length!==0){s.inFrustum=!1;for(let n=0,o=a.length;n<o;n++)Co(a[n],e,!0);return}if(yo(s,e),s.refine==="REPLACE"&&(r&&s.depth!==0||Ah))for(let n=0,o=a.length;n<o;n++)Co(a[n],e)}function So(s,e){const t=e.frameCount;if(!hr(s,t))return;const a=s.children;let r=!1;for(let i=0,n=a.length;i<n;i++){const o=a[i];r=r||hr(o,t)}if(!r)s.isLeaf=!0;else{let i=!0;for(let n=0,o=a.length;n<o;n++){const l=a[n];if(So(l,e),hr(l,t)){const c=!Uo(l);let f=!l.hasContent||l.hasRenderableContent&&Dh(l.loadingState)||l.hasUnrenderableContent&&l.loadingState===fr;f=c&&f||l.allChildrenReady,i=i&&f}}s.allChildrenReady=i}}function Bh(s,e){if(e.ensureChildrenArePreprocessed(s),hr(s,e.frameCount)&&(s.hasContent&&e.queueTileForDownload(s),_h(s))){const t=s.children;for(let a=0,r=t.length;a<r;a++)Bh(t[a],e)}}function xo(s,e){const t=e.stats;if(!hr(s,e.frameCount))return;if(s.isLeaf){s.loadingState===Ba?(s.inFrustum&&(s.visible=!0,t.visible++),s.active=!0,t.active++):s.hasContent&&e.queueTileForDownload(s);return}const a=s.children,r=s.hasContent,i=Dh(s.loadingState)&&r,n=(e.errorTarget+1)*(e.errorThreshold||1),o=s.error<=n,l=s.refine==="ADD",c=s.allChildrenReady||s.depth===0&&!Ah;if(r&&(o||l)&&e.queueTileForDownload(s),(o&&i&&!c||i&&l)&&(s.inFrustum&&(s.visible=!0,t.visible++),s.active=!0,t.active++),!l&&o&&!c)for(let f=0,h=a.length;f<h;f++){const u=a[f];hr(u,e.frameCount)&&Bh(u,e)}else for(let f=0,h=a.length;f<h;f++)xo(a[f],e)}function Fo(s,e){const t=hr(s,e.frameCount);if(t||s.usedLastFrame){let a=!1,r=!1;if(t?(a=s.active,r=s.visible):vo(s,e),s.hasRenderableContent&&s.loadingState===Ba){const n=s.__wasSetVisible;s.__wasSetActive!==a&&(e.setTileActive(s,a),s.__wasSetActive=a),n!==r&&(e.setTileVisible(s,r),s.__wasSetVisible=r)}s.usedLastFrame=t;const i=s.children;for(let n=0,o=i.length;n<o;n++)Fo(i[n],e)}}class Rr{static s_tmpMatrix=null;_type;_data;_box;get box(){return this._box}_sphere;_matrix;constructor(e){if(Rr.s_tmpMatrix||(Rr.s_tmpMatrix=new R),this._data=e,e.box)this._type="box",this._parseBox(e.box);else if(e.sphere)this._type="sphere",this._parseSphere(e.sphere);else if(e.region)this._type="region",this._parseRegion(e.region);else throw new Error("BoundingVolume: Invalid bounding volume data")}_parseBox(e){if(e.length!==12)throw new Error("BoundingVolume: Box must have 12 elements");const t=new b(e[0],e[1],e[2]),a=new b(e[3],e[4],e[5]),r=new b(e[6],e[7],e[8]),i=new b(e[9],e[10],e[11]),n=a.length,o=r.length,l=i.length,c=a.clone().normalize(),f=r.clone().normalize(),h=i.clone().normalize();this._matrix=new R;const u=this._matrix.rawData;u[0]=c.x,u[1]=c.y,u[2]=c.z,u[3]=0,u[4]=f.x,u[5]=f.y,u[6]=f.z,u[7]=0,u[8]=h.x,u[9]=h.y,u[10]=h.z,u[11]=0,u[12]=t.x,u[13]=t.y,u[14]=t.z,u[15]=1;const g=new b(n*2,o*2,l*2);this._box=new ge(new b(0,0,0),g)}_parseSphere(e){if(e.length!==4)throw new Error("BoundingVolume: Sphere must have 4 elements");const t=new b(e[0],e[1],e[2]),a=e[3];this._sphere=new Sr(t,a)}_parseRegion(e){if(e.length!==6)throw new Error("BoundingVolume: Region must have 6 elements");const[t,a,r,i,n,o]=e,l=new b((t+r)/2,(a+i)/2,(n+o)/2),c=new b(Math.abs(r-t),Math.abs(i-a),Math.abs(o-n));this._box=new ge(l,c),this._matrix=new R,this._matrix.identity()}getAABB(e,t){if(this._type==="sphere"&&this._sphere){const a=this._sphere.center,r=this._sphere.radius,i=new b(a.x-r,a.y-r,a.z-r),n=new b(a.x+r,a.y+r,a.z+r);if(e.setFromMinMax(i,n),t){const o=[new b(i.x,i.y,i.z),new b(n.x,i.y,i.z),new b(i.x,n.y,i.z),new b(n.x,n.y,i.z),new b(i.x,i.y,n.z),new b(n.x,i.y,n.z),new b(i.x,n.y,n.z),new b(n.x,n.y,n.z)];o.forEach(l=>{const c=new b;t.transformPoint(l,c),l.copyFrom(c)}),e.makeEmpty(),o.forEach(l=>{e.expandByPoint(l)})}return e}else if(this._box){const a=Rr.s_tmpMatrix;if(a.identity(),this._matrix?t?a.multiplyMatrices(t,this._matrix):a.copyFrom(this._matrix):t&&a.copyFrom(t),a){const r=this._box,i=[new b(r.min.x,r.min.y,r.min.z),new b(r.max.x,r.min.y,r.min.z),new b(r.min.x,r.max.y,r.min.z),new b(r.max.x,r.max.y,r.min.z),new b(r.min.x,r.min.y,r.max.z),new b(r.max.x,r.min.y,r.max.z),new b(r.min.x,r.max.y,r.max.z),new b(r.max.x,r.max.y,r.max.z)];i.forEach(n=>{const o=new b;a.transformPoint(n,o),n.copyFrom(o)}),e.makeEmpty(),i.forEach(n=>{e.expandByPoint(n)})}else e.setFromMinMax(this._box.min,this._box.max);return e}throw new Error("BoundingVolume: Invalid state")}getOBB(e,t){this._type==="box"&&this._box&&this._matrix?(e.setFromMinMax(this._box.min,this._box.max),t.copyFrom(this._matrix)):(this.getAABB(e),t.identity())}getSphere(e){if(this._type==="sphere"&&this._sphere)return e.center.copyFrom(this._sphere.center),e.radius=this._sphere.radius,e;const t=new ge;this.getAABB(t);const a=t.center,i=t.size.length*.5;return e.center.copyFrom(a),e.radius=i,e}get type(){return this._type}distanceToPoint(e,t){if(this._type==="sphere"&&this._sphere){const a=this._sphere.center;let r=a;if(t){const o=new b;t.transformPoint(a,o),r=o}const i=this._sphere.radius,n=e.clone().subtract(r).length;return Math.max(0,n-i)}else if(this._box){const a=new ge;this.getAABB(a,t);const r=a.center,i=a.size,n=Math.max(0,Math.abs(e.x-r.x)-i.x*.5),o=Math.max(0,Math.abs(e.y-r.y)-i.y*.5),l=Math.max(0,Math.abs(e.z-r.z)-i.z*.5);return Math.sqrt(n*n+o*o+l*l)}return 1/0}intersectsFrustum(e,t){if(this._type==="sphere"&&this._sphere){const a=new ge;return this.getAABB(a,t),e.containsBox2(a)>0}else if(this._box){const a=new ge;return this.getAABB(a,t),e.containsBox2(a)>0}return!1}}const Uh=(s,e)=>{const t=s.priority||0,a=e.priority||0;return t!==a?t>a?1:-1:s.used!==e.used?s.used?1:-1:s.error!==e.error?s.error>e.error?1:-1:s.distanceFromCamera!==e.distanceFromCamera?s.distanceFromCamera>e.distanceFromCamera?-1:1:s.depthFromRenderedParent!==e.depthFromRenderedParent?s.depthFromRenderedParent>e.depthFromRenderedParent?-1:1:0},vh=(s,e)=>{const t=s.priority||0,a=e.priority||0;return t!==a?t>a?1:-1:s.lastFrameVisited!==e.lastFrameVisited?s.lastFrameVisited>e.lastFrameVisited?-1:1:s.depthFromRenderedParent!==e.depthFromRenderedParent?s.depthFromRenderedParent>e.depthFromRenderedParent?1:-1:s.loadingState!==e.loadingState?s.loadingState>e.loadingState?-1:1:s.hasUnrenderableContent!==e.hasUnrenderableContent?s.hasUnrenderableContent?-1:1:s.error!==e.error?s.error>e.error?-1:1:0};class Kg{rootLoadingState=dr;rootTileSet=null;rootURL=null;fetchOptions={};frameCount=0;isLoading=!1;lruCache;loadQueue;processNodeQueue;plugins=[];_queuedTiles=[];_cachedSinceLoadComplete=new Set;_processedTiles=new WeakSet;_visibleTiles=new Set;_usedSet=new Set;_cacheHits=0;_cacheMisses=0;stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0,inCacheSinceLoad:0};errorTarget=16;errorThreshold=1;maxDepth=30;displayActiveTiles=!1;onRootTileLoaded;rtcOffset=null;_root=null;_activeTiles=new Set;group;cameras=[];_cameraMap=new Map;_cameraInfo=[];_upRotationMatrix=new R;_ellipsoid;_bytesUsed=new WeakMap;_eventListeners=new Map;performanceStats={updateTime:0,traverseTime:0,markUsedTime:0,markVisibleTime:0,toggleTime:0,queueProcessTime:0};constructor(e=null){this.rootURL=e,this.lruCache=new mh,this.lruCache.unloadPriorityCallback=vh,this.loadQueue=new Bo,this.loadQueue.maxJobs=10,this.loadQueue.priorityCallback=Uh,this.processNodeQueue=new Bo,this.processNodeQueue.maxJobs=25,this.group=new d.Object3D,this.group.name="TilesRendererGroup"}get root(){return this._root}get loadProgress(){const{stats:e,isLoading:t}=this,a=e.downloading,r=e.inCacheSinceLoad+(t?1:0);return r===0?1:1-a/r}update(){const{lruCache:e,_usedSet:t,stats:a,loadQueue:r,processNodeQueue:i}=this;this.rootLoadingState===dr&&(this.rootLoadingState=Do,this.isLoading=!0,this._loadRootTileSet().then(c=>{if(this.rootLoadingState=Ba,this.rootTileSet=c,c.root){const f=this._getBasePath(this.rootURL||""),h=this.preprocessNode(c.root,f,null);this._root=h;const u=new Rr(h.boundingVolume),g=new Sr;u.getSphere(g);const p=new ge;if(u.getAABB(p),this.rtcOffset=new b(-g.center.x,-g.center.y,-g.center.z),this.onRootTileLoaded)try{this.onRootTileLoaded({center:g.center,radius:g.radius,boundingBox:p,rtcOffset:this.rtcOffset})}catch(m){console.warn("Failed to calculate bounding volume for root tile:",m)}}this.dispatchEvent({type:"load-tile-set",tileSet:c,url:this.rootURL})}).catch(c=>{this.rootLoadingState=fr,console.error("Failed to load root tileset:",c),this.dispatchEvent({type:"load-error",tile:null,error:c,url:this.rootURL})}));const n=this.root;if(!n)return;a.inFrustum=0,a.used=0,a.active=0,a.visible=0,this.frameCount++,t.forEach(c=>e.markUnused(c)),t.clear(),this.updateCameraInfo(),wn(n,this),So(n,this),xo(n,this),Fo(n,this);const o=this._queuedTiles;e.unloadPriorityCallback&&o.sort(e.unloadPriorityCallback);for(let c=0,f=o.length;c<f&&!e.isFull();c++)this.requestTileContents(o[c]);o.length=0,e.scheduleUnload(),(r.running||i.running)===!1&&this.isLoading===!0&&(this._cachedSinceLoadComplete.clear(),a.inCacheSinceLoad=0,this.dispatchEvent({type:"tiles-load-end"}),this.isLoading=!1)}traverse(e,t,a=!0){this.root&&ph(this.root,(r,i,n)=>(a&&this.ensureChildrenArePreprocessed(r,!0),e?e(r,i,n):!1),t)}registerPlugin(e){if(this.plugins.includes(e))return;const t=e.priority||0;let a=this.plugins.length;for(let r=0;r<this.plugins.length;r++)if((this.plugins[r].priority||0)>t){a=r;break}this.plugins.splice(a,0,e),e.init&&e.init(this)}unregisterPlugin(e){const t=this.plugins;let a;if(typeof e=="string"?a=t.find(r=>r.name===e):a=e,a&&t.includes(a)){const r=t.indexOf(a);return t.splice(r,1),a.dispose&&a.dispose(),!0}return!1}getPluginByName(e){return this.plugins.find(t=>t.name===e)||null}calculateTileViewError(e,t){const a=e.cached,r=this.cameras,i=this._cameraInfo,n=a.boundingVolume;if(!n){t.inView=!1,t.error=1/0,t.distanceFromCamera=1/0;return}let o=!1,l=-1/0,c=1/0,f=-1/0,h=1/0;const u=a.worldTransform;for(let g=0,p=r.length;g<p;g++){const m=i[g];let D,_;if(m.isOrthographic){const v=m.pixelSize;D=e.geometricError/v,_=1/0}else{const v=m.sseDenominator;_=n.distanceToPoint(m.position,u),D=_===0?1/0:e.geometricError/(_*v)}const B=i[g].frustum;n.intersectsFrustum(B,u)&&(o=!0,l=Math.max(l,D),c=Math.min(c,_)),f=Math.max(f,D),h=Math.min(h,_)}o?(t.inView=!0,t.error=l,t.distanceFromCamera=c):(t.inView=!1,t.error=f,t.distanceFromCamera=h)}updateCameraInfo(){this._updateCameraInfo()}_updateCameraInfo(){const e=this.cameras,t=this._cameraInfo,a=this._cameraMap;for(;t.length<e.length;)t.push({position:new b,frustum:new rs,isOrthographic:!1});for(let r=0;r<e.length;r++){const i=e[r],n=t[r],o=a.get(i);if(!o)continue;const l=i.transform.worldPosition;if(n.position.copyFrom(l),n.frustum=i.frustum,n.isOrthographic=i.type===ze.ortho,n.isOrthographic){const c=i.frustumSize;n.pixelSize=c/o.height}else{const f=i.fov*Math.PI/180;n.sseDenominator=2*Math.tan(f/2)/o.height}}}preprocessNode(e,t,a=null){if(this._processedTiles.has(e))return e;this._processedTiles.add(e);let r;if(e instanceof _o?r=e:r=new _o(e,a),r.content){const c=r.content;!("uri"in c)&&"url"in c&&(c.uri=c.url,delete c.url)}if(r.basePath=t,r.boundingVolume){const c=new Rr(r.boundingVolume);r.cached.boundingVolume=c}const i=new b(r.boundingVolume.box[0],r.boundingVolume.box[1],r.boundingVolume.box[2]),n=new R;if(r.transform){const c=r.transform;for(let f=0;f<16;f++)n.rawData[f]=c[f]}if(!a){n.copyFrom(this._upRotationMatrix);const c=new b;c.copyFrom(i),c.applyMatrix4(n);const f=r.cached.boundingVolume.box,h=[new b(f.min.x,f.min.y,f.min.z),new b(f.max.x,f.min.y,f.min.z),new b(f.min.x,f.max.y,f.min.z),new b(f.max.x,f.max.y,f.min.z),new b(f.min.x,f.min.y,f.max.z),new b(f.max.x,f.min.y,f.max.z),new b(f.min.x,f.max.y,f.max.z),new b(f.max.x,f.max.y,f.max.z)];for(const p of h)p.applyMatrix4(n);const u=new ge;h.forEach(p=>{u.expandByPoint(p)}),n.rawData[12]=-c.x,n.rawData[13]=-c.y,n.rawData[14]=-c.z;const g=u.min;n.rawData[13]-=g.y}const o=new R;o.copyFrom(n),a&&a.cached.worldTransform&&o.multiplyMatrices(a.cached.worldTransform,n);const l=new R;if(l.copyFrom(o),l.invert(),r.cached.transfrom=n,r.cached.worldTransform=o,r.cached.transformInverse=l,e.children&&e.children.length>0){r.children=[];for(let c=0;c<e.children.length;c++){const f=e.children[c],h=this.preprocessNode(f,t,r);r.children.push(h)}r.childrenProcessed=r.children.length}return r}ensureChildrenArePreprocessed(e,t=!1){const a=e.children;for(let r=0,i=a.length;r<i;r++){const n=a[r];n.basePath!==void 0&&n.basePath!==""||n.cached.boundingVolume||(t?(this.processNodeQueue.remove(n),this.preprocessNode(n,e.basePath,e)):this.processNodeQueue.has(n)||this.processNodeQueue.add(n,o=>{this.preprocessNode(o,e.basePath,e)}))}}_recordCacheHit(){this._cacheHits++}_recordCacheMiss(){this._cacheMisses++}resetCacheStats(){this._cacheHits=0,this._cacheMisses=0}requestTileContents(e){if(e.loadingState!==dr){this._recordCacheHit();return}if(this.lruCache.isFull()){this._recordCacheMiss();return}this._recordCacheMiss(),e.loadingState=Do,this.stats.downloading++;const t=e.content||e.contents&&e.contents[0];if(!t||!t.uri){e.loadingState=fr,this.stats.downloading--,this.stats.failed++;return}const a=e.basePath||"",r=t.uri,i=this._resolveURL(a,r);this.loadQueue.add(e,async n=>{try{await this.parseTileContent(n,r,i),this.stats.downloading--}catch(o){n.loadingState=fr,this.stats.downloading--,this.stats.failed++,console.error("Failed to load tile:",o)}})}async parseTileContent(e,t,a){e.loadingState=bh;const i=(l=>{const c=l.split(".");return c.length>1?c[c.length-1]:""})(t),n=a;let o=null;switch(i.toLowerCase()){case"b3dm":o=(await new At().load(n,zs,{onProgress:f=>{},onComplete:f=>{}})).data;break;case"i3dm":o=await A.res.loadI3DM(n,{onProgress:f=>{},onComplete:f=>{}});break;case"glb":case"gltf":o=await A.res.loadGltf(n,{onProgress:f=>{},onComplete:f=>{}});break;case"pnts":console.warn("PNTS format not yet supported");break;case"json":try{const f=await A.res.loadJSON(n);e.children.length=0,e.childrenProcessed=0;const h=this._getBasePath(n);if(f.root){const u=this.preprocessNode(f.root,h,e);e.children.push(u),e.childrenProcessed=1,this.dispatchEvent({type:"load-tile-set",tileSet:f,url:n})}e.loadingState=Ba;return}catch(f){console.error("Failed to load external tileset:",f),e.loadingState=fr,this.stats.failed++;return}break;default:console.warn(`Unknown tile format: ${i}`);break}if(o){e.cached.scene=o,e.loadingState=Ba;const l=this._estimateBytesUsed(o);this._bytesUsed.set(o,l),this.lruCache.setMemoryUsage(e,l),this.lruCache.has(e)||this.lruCache.add(e,c=>{if(c.cached.scene){const f=c.cached.scene;f.parent&&f.parent.object3D.removeChild(f),f.destroy(!0),c.cached.scene=null}c.loadingState=dr}),e.active&&this.setTileActive(e,!0)}else e.loadingState=fr,this.stats.failed++}markTileUsed(e){this._usedSet.add(e),this.lruCache.markUsed(e)}setTileActive(e,t){t?this._activeTiles.add(e):this._activeTiles.delete(e);const a=e.cached.scene;a&&(t?(this.group.entityChildren.includes(a)||(a.parent&&a.parent.object3D.removeChild(a),this.group.addChild(a)),e.cached.worldTransform&&this._applyWorldTransform(a.transform,e.cached.worldTransform),a.transform.enable=!0):a.transform.enable=!1)}setTileVisible(e,t){t?this._visibleTiles.add(e):this._visibleTiles.delete(e);const a=e.cached.scene;a&&(a.transform.enable=t)}queueTileForDownload(e){e.loadingState!==dr||this.lruCache.isFull()||this._queuedTiles.push(e)}dispatchEvent(e){const t=this._eventListeners.get(e.type);t&&t.forEach(a=>{try{a(e)}catch(r){console.error("Error in event listener:",r)}})}async _loadRootTileSet(){if(!this.rootURL)throw new Error("Root URL is not set");const e=await A.res.loadJSON(this.rootURL);return e.asset&&e.asset.gltfUpAxis&&this._setupUpAxisRotation(e.asset.gltfUpAxis),e}_setupUpAxisRotation(e){const t=new R;switch(e.toLowerCase()){case"x":t.makeRotationAxis(b.Y_AXIS,-Math.PI/2);break;case"y":t.identity();break;case"z":t.makeRotationAxis(b.X_AXIS,-Math.PI/2);break;default:console.warn(`Unknown gltfUpAxis: ${e}, using default`),t.identity();break}this._upRotationMatrix=t}_applyLocalTransform(e,t){const a=t.decompose(Wt.EULER_ANGLES);e.localPosition=a[0];const r=new Z;r.fromEulerAngles(a[1].x,a[1].y,a[1].z),e.localRotQuat=r,e.localScale=a[2]}_applyWorldTransform(e,t){const a=t.decompose(Wt.EULER_ANGLES);e.localPosition=a[0];const r=new Z;r.fromEulerAngles(a[1].x,a[1].y,a[1].z),e.localRotQuat=r,e.localScale=a[2]}_getBasePath(e){const t=e.lastIndexOf("/");return t!==-1?e.substring(0,t):""}_resolveURL(e,t){return t.startsWith("http://")||t.startsWith("https://")?t:e+"/"+t}_getUrlExtension(e){const t=e.split(".");return t.length>1?t[t.length-1]:""}getMemoryStats(){const e=this.lruCache.getStats(),t=this.lruCache.maxBytesSize,a=e.bytes,r=t-a,i=this._cacheHits+this._cacheMisses,n=i>0?this._cacheHits/i:0;return{totalTiles:e.size,loadedTiles:e.usedCount,cachedTiles:e.size,totalBytes:t,usedBytes:a,freeBytes:r,cacheHitRate:n}}getLoadedTiles(){const e=[];return this.traverse(t=>(t.loadingState===Ba&&e.push(t),!1),null),e}getVisibleTiles(){return Array.from(this._visibleTiles)}getActiveTiles(){return Array.from(this._activeTiles)}getTileTreeStats(){let e=0,t=0,a=0,r=0,i=0,n=0;return this.traverse(o=>(e++,o.loadingState===Ba&&t++,o.visible&&a++,o.active&&r++,i=Math.max(i,o.depth),n+=o.depth,!1),null),{totalTiles:e,loadedTiles:t,visibleTiles:a,activeTiles:r,maxDepth:i,averageDepth:e>0?n/e:0}}printDebugInfo(){const e=this.stats,t=this.getMemoryStats(),a=this.getTileTreeStats(),r=this.performanceStats,i=this.lruCache.getStats();console.log("=== TilesRenderer Debug Info ==="),console.log("Stats:",e),console.log("Memory:",t),console.log("Tree:",a),console.log("Performance:",r),console.log("Cache:",i),console.log("Queues:",{load:this.loadQueue.getStats(),process:this.processNodeQueue.getStats()})}setPerformanceOptions(e){e.lruCacheMinSize!==void 0&&(this.lruCache.minSize=e.lruCacheMinSize),e.lruCacheMaxSize!==void 0&&(this.lruCache.maxSize=e.lruCacheMaxSize),e.lruCacheMinBytes!==void 0&&(this.lruCache.minBytesSize=e.lruCacheMinBytes),e.lruCacheMaxBytes!==void 0&&(this.lruCache.maxBytesSize=e.lruCacheMaxBytes),e.lruCacheUnloadPercent!==void 0&&(this.lruCache.unloadPercent=e.lruCacheUnloadPercent),e.downloadQueueMaxJobs!==void 0&&(this.loadQueue.maxJobs=e.downloadQueueMaxJobs),e.parseQueueMaxJobs!==void 0&&(this.loadQueue.maxJobs=e.parseQueueMaxJobs),e.processQueueMaxJobs!==void 0&&(this.processNodeQueue.maxJobs=e.processQueueMaxJobs),e.enablePerformanceStats!==void 0&&(this._enablePerformanceStats=e.enablePerformanceStats),e.enableCacheStats!==void 0&&(this._enableCacheStats=e.enableCacheStats)}dispose(e){[...this.plugins].forEach(a=>this.unregisterPlugin(a)),this.lruCache.clear(),this.loadQueue.clear(),this.processNodeQueue.clear(),this._root=null,this.rootTileSet=null,this.rootLoadingState=dr,this.frameCount=0,this.isLoading=!1,this.resetCacheStats(),this.group.destroy(e)}setCamera(e,t,a){this.cameras.includes(e)||this.cameras.push(e),this._cameraMap.set(e,{width:t,height:a}),this._updateCameraInfo()}deleteCamera(e){const t=this.cameras.indexOf(e);t!==-1&&this.cameras.splice(t,1),this._cameraMap.delete(e),this._updateCameraInfo()}setResolution(e,t,a){const r=this._cameraMap.get(e);r?(r.width=t,r.height=a):this._cameraMap.set(e,{width:t,height:a}),this._updateCameraInfo()}forEachLoadedModel(e){this.traverse(t=>(t.loadingState===Ba&&t.cached.scene&&e(t.cached.scene,t),!1),null)}_estimateBytesUsed(e){let t=0;return e.forChild(a=>{const r=a.getComponent(d.MeshRenderer);r&&r.geometry&&(t+=1024),r&&r.material&&(t+=512)}),t}addEventListener(e,t){this._eventListeners.has(e)||this._eventListeners.set(e,[]),this._eventListeners.get(e).push(t)}removeEventListener(e,t){const a=this._eventListeners.get(e);if(a){const r=a.indexOf(t);r!==-1&&a.splice(r,1)}}async loadTileSet(e,t){const r=(e.endsWith("/")?e.slice(0,-1):e)+"/"+t;this.rootURL=r}get modelList(){const e=[];return this.forEachLoadedModel(t=>{e.push(t)}),e}}class qg{asset;extras;geometricError;properties;refine;root;extensionsUsed;extensionsRequired;extensions}class $g{boundingVolume;children;geometricError;transform;content;contents;refine;extensions;extras}class em{boundingVolume;geometricError;refine;content;contents;children;transform;extensions;extras}class tm{uri;group;metadata}class am{class;properties}function rm(s,e){let t=0,a=null;return function(...r){const i=Date.now(),n=i-t;n>=e?(t=i,s.apply(this,r)):(a!==null&&clearTimeout(a),a=window.setTimeout(()=>{t=Date.now(),s.apply(this,r),a=null},e-n))}}class im extends ut{static count=0;constructor(){super(),J.register("ColorLitShader",ed),this.shader=new it;let e=new Ne("ColorLitShader","ColorLitShader");e.passType=H.COLOR,this.shader.addRenderPass(e),e.setDefine("USE_BRDF",!0),e.setShaderEntry("VertMain","FragMain"),e.setUniformColor("baseColor",new O),e.setUniformColor("emissiveColor",new O),e.setUniformFloat("envIntensity",1),e.setUniformFloat("normalScale",1),e.setUniformFloat("roughness",0),e.setUniformFloat("metallic",0),e.setUniformFloat("ao",1),e.setUniformFloat("alphaCutoff",0);let t=e.shaderState;t.acceptShadow=!0,t.receiveEnv=!0,t.acceptGI=!0,t.useLight=!0,e.setTexture("normalMap",A.res.normalTexture),e.setTexture("emissiveMap",A.res.blackTexture)}clone(){return null}debug(){}}class nm extends ut{constructor(){super(),this.shader=new d.FatLineShader,this.transparent=!0}setInstanceBuffer(e){this.shader.setStorageBuffer("instances",e)}setModelMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set lineWidth(e){this.shader.setUniformFloat("lineWidth",e)}get lineWidth(){return this.shader.getUniformFloat("lineWidth")}set opacity(e){this.shader.setUniformFloat("opacity",e)}get opacity(){return this.shader.getUniformFloat("opacity")}set resolution(e){this.shader.setUniformVector2("resolution",e)}get resolution(){return this.shader.getUniformVector2("resolution")}}class sm extends ut{constructor(){super();let e=new Ne("LambertShader","LambertShader");e.setShaderEntry("VertMain","FragMain"),e.passType=H.COLOR,e.setUniformVector4("transformUV1",new $(0,0,1,1)),e.setUniformVector4("transformUV2",new $(0,0,1,1)),e.setUniformColor("baseColor",new O(1,1,1,1)),e.setUniformFloat("alphaCutoff",.5);let t=e.shaderState;t.acceptShadow=!1,t.castShadow=!1,t.receiveEnv=!1,t.acceptGI=!1,t.useLight=!1;let a=new it;a.addRenderPass(e),this.shader=a,this.baseMap=A.res.grayTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set envMap(e){}set shadowMap(e){}}function om(s,e){}class lm extends ut{constructor(){super(),this.shader=new d.UnLitTexArrayShader,this.baseMap=A.res.whiteTexture}set baseMap(e){this.shader.setTexture("baseMap",e)}get baseMap(){return this.shader.getTexture("baseMap")}set baseColor(e){this.shader.setUniformColor("baseColor",e)}get baseColor(){return this.shader.getUniformColor("baseColor")}set shadowMap(e){}}class ko{clipName;loopTime;startTime;stopTime;sampleRate;useSkeletonPos;useSkeletonScale;positionCurves=new Map;rotationCurves=new Map;scaleCurves=new Map;floatCurves=new Map;formBytes(e){if(this.clipName=e.readUTF(),this.loopTime=!e.readInt32(),this.startTime=e.readFloat32(),this.stopTime=e.readFloat32(),this.sampleRate=e.readInt32(),this.useSkeletonPos=e.readInt32()>0,this.useSkeletonScale=e.readInt32()>0,this.useSkeletonPos){let r=e.readInt32();for(let i=0;i<r;i++){let n=new ur;n.formBytes(e),this.positionCurves.set(n.path,n)}}let t=e.readInt32();for(let r=0;r<t;r++){let i=new ur;i.formBytes(e),this.rotationCurves.set(i.path,i)}if(this.useSkeletonScale){let r=e.readInt32();for(let i=0;i<r;i++){let n=new ur;n.formBytes(e),this.scaleCurves.set(n.path,n)}}let a=e.readInt32();for(let r=0;r<a;r++){let i=new ur;i.formBytes(e),this.floatCurves.set(i.attribute,i)}}}class ur{path;attribute;propertys;preInfinity;postInfinity;rotationOrder;m_curves;k=0;_cacheValue;_kValue;constructor(e=1){this.k=e,this.m_curves=[],this.check()}check(){for(let e=0;e<this.k;e++)this.m_curves[e]||=new Ri;switch(this.k){case 1:this._cacheValue=0;break;case 2:this._cacheValue=new K;break;case 3:this._cacheValue=new b;break;case 4:this._cacheValue=new $;break}}get totalTime(){return this.m_curves[0].totalTime}addKeyFrame(e){for(let t=0;t<this.k;t++)this.m_curves[t].addKeyFrame(e.getK(t))}removeKeyFrame(e){for(let t=0;t<this.k;t++)this.m_curves[t].removeKeyFrame(e.getK(t))}getValue(e){switch(this.k){case 1:this._cacheValue=this.m_curves[0].getValue(e);break;case 2:this._cacheValue.x=this.m_curves[0].getValue(e),this._cacheValue.y=this.m_curves[1].getValue(e);break;case 3:this._cacheValue.x=this.m_curves[0].getValue(e),this._cacheValue.y=this.m_curves[1].getValue(e),this._cacheValue.z=this.m_curves[2].getValue(e);break;case 4:const t=this.m_curves[0].getCurveFramesExtent(e),a=t.lhsIndex,r=t.rhsIndex;e=t.time;let i=this.m_curves[0].getKey(a),n=this.m_curves[0].getKey(r);e%=this.m_curves[0].totalTime;let o=(e-i.time)/(n.time-i.time);Z.HELP_0.set(this.m_curves[0].getKey(a).value,this.m_curves[1].getKey(a).value,this.m_curves[2].getKey(a).value,this.m_curves[3].getKey(a).value),Z.HELP_1.set(this.m_curves[0].getKey(r).value,this.m_curves[1].getKey(r).value,this.m_curves[2].getKey(r).value,this.m_curves[3].getKey(r).value),Z.HELP_2.slerp(Z.HELP_0,Z.HELP_1,o),this._cacheValue.x=Z.HELP_2.x,this._cacheValue.y=Z.HELP_2.y,this._cacheValue.z=Z.HELP_2.z,this._cacheValue.w=Z.HELP_2.w;break}return this._cacheValue}getKeyCount(){return this.m_curves[0].getKeyCount()}getKey(e){let t=[];for(let a=0;a<this.k;a++)t.push(this.m_curves[a].getKey(e));return t}formBytes(e){this.path=e.readUTF(),this.k=e.readInt32(),this.check(),this.attribute=e.readUTF(),this.propertys=this.attribute.split("."),this.preInfinity=e.readInt32(),this.postInfinity=e.readInt32(),this.rotationOrder=e.readInt32();let t=e.readInt32();for(let a=0;a<t;a++){let r=new ji(0);r.formBytes(e),this.addKeyFrame(r)}}}class cm extends Map{negtive;constructor(e){if(super(e),this.negtive=new Map,e)for(let t of e)this.negtive.set(t[1],t[0])}delete(e){if(this.has(e)){let t=this.get(e);return this.negtive.delete(t),super.delete(e)}return!1}getKey(e){return this.negtive.get(e)}deleteValue(e){let t=this.negtive.get(e);return t&&this.delete(t),this.negtive.delete(e)}set(e,t){return super.set(e,t),this.negtive.set(t,e),this}clear(){this.negtive.clear(),super.clear()}}class fm{colorArray;constructor(e){this.colorArray=e}getColor(e){let t=e*this.colorArray.length,a=Math.floor(t),r=Math.min(a+1,this.colorArray.length-1),i=this.colorArray[a],n=this.colorArray[r];return O.lerp(t-a,i,n)}}class In{controlVertices;constructor(e){this.setControlVertices(e)}setControlVertices(e){e.length==4&&(this.controlVertices=e.concat())}getPoint(e){if(!(e>=0&&e<=1))return b.ZERO;let t=1-e,a=t*t*t,r=3*e*t*t,i=3*e*e*t,n=e*e*e;return this.controlVertices[0].mul(a).add(this.controlVertices[1].mul(r)).add(this.controlVertices[2].mul(i)).add(this.controlVertices[3].mul(n))}getTangent(e){if(!(e>=0&&e<=1))return b.ZERO;let t=this.controlVertices,a=t[0].add(t[1].add(t[0]).mul(e)),r=t[1].add(t[2].add(t[1]).mul(e)),i=t[2].add(t[3].add(t[2]).mul(e)),n=a.add(r.subtract(a).mul(e));return r.add(i.subtract(r).mul(e)).subtract(n)}getClosestParam(e,t=1e-6){return this.getClosestParamRec(e,0,1,t)}getClosestParamRec(e,t,a,r){let i=(t+a)/2;if(a-t<r)return i;let n=(t+i)/2,o=(i+a)/2,l=this.getPoint(n),c=this.getPoint(o),f=l.subtract(e).lengthSquared,h=c.subtract(e).lengthSquared;return f<h?a=i:t=i,this.getClosestParamRec(e,t,a,r)}}var yh=(s=>(s[s.Open=0]="Open",s[s.Closed=1]="Closed",s))(yh||{});class dm{type=0;numCurveSegments=0;numControlVertices=0;controlVertices=[];constructor(e,t=0){this.setControlVertices(e,t)}getPathType(){return this.type}isClosed(){return this.type==1}isValid(){return this.numCurveSegments>0}clear(){this.controlVertices.length=0,this.type=0,this.numCurveSegments=0,this.numControlVertices=0}computeApproxLength(){if(!this.isValid())return 0;let e=this.numCurveSegments+1;if(e<2)return 0;let t=0,a=this.controlVertices;for(let r=1;r<e;r++){let i=a[(r-1)*3],n=a[r*3];t+=i.subtract(n).lengthSquared}return t==0?0:t}computeApproxParamPerUnitLength(){let e=this.computeApproxLength();return this.numCurveSegments/e}computeApproxNormParamPerUnitLength(){return 1/this.computeApproxLength()}interpolatePoints(e,t){let a=e.length;a<2&&console.error("point count must great 1"),this.clear(),this.type=t;let r=this.controlVertices;switch(t){case 0:{this.numCurveSegments=a-1,this.numControlVertices=3*a-2,r.length=this.numControlVertices;for(let o=0;o<a;o++)r[o*3]=e[o];let i=e[1].subtract(e[0]).mul(.25);r[1]=e[0].add(i);let n=e[a-2].subtract(e[a-1]).mul(.25);r[this.numControlVertices-2]=e[a-1].add(n);for(let o=1;o<this.numCurveSegments;o++){let l=e[o-1].subtract(e[o]),c=e[o+1].subtract(e[o]),f=l.lengthSquared,h=c.lengthSquared;if(f>0&&h>0){let u=(f+h)/8,g=c.div(h).subtract(l.div(f));g.normalize(),g=g.mul(u),r[o*3-1]=e[o].subtract(g),r[o*3+1]=e[o].add(g)}else r[o*3-1]=e[o],r[o*3+1]=e[o]}break}case 1:{this.numCurveSegments=a,this.numControlVertices=3*a+1,r.length=this.numControlVertices;for(let i=0;i<a;i++)r[i*3]=e[i];r[this.numControlVertices-1]=e[0];for(let i=1;i<=this.numCurveSegments;i++){let n=i-1,o=(i+1)%this.numCurveSegments,l=i%this.numCurveSegments,c=e[n].subtract(e[l]),f=e[o].subtract(e[l]),h=c.lengthSquared,u=f.lengthSquared,g=3*i-1,p=(3*i+1)%(this.numControlVertices-1);if(h>0&&u>0){let m=(h+u)/8,D=f.div(u).subtract(c.div(h));D.normalize(),D=D.mul(m),r[g]=e[l].subtract(D),r[p]=e[l].add(D)}else r[g]=e[l],r[p]=e[l]}break}}}setControlVertices(e,t){let a=e.length;a<=0||t==0&&a<4||t==1&&a<7||(a-1)%3==0&&(this.clear(),this.type=t,this.numControlVertices=a,this.numCurveSegments=(a-1)/3,this.controlVertices=e)}getPoint(e){if(this.type==1){for(;e<0;)e+=this.numCurveSegments;for(;e>this.numCurveSegments;)e-=this.numCurveSegments}else e=vt.clampf(e,0,this.numCurveSegments);if(!(e>=0)&&e<=this.numCurveSegments)return;let t=Math.floor(e);t>=this.numCurveSegments&&(t=this.numCurveSegments-1);let a=[],r=this.controlVertices;return a[0]=r[3*t+0],a[1]=r[3*t+1],a[2]=r[3*t+2],a[3]=r[3*t+3],new In(a).getPoint(e-t)}getPointNorm(e){return this.getPoint(e*this.numCurveSegments)}getTangent(e){if(this.type==1){for(;e<0;)e+=this.numCurveSegments;for(;e>this.numCurveSegments;)e-=this.numCurveSegments}else e=vt.clampf(e,0,this.numCurveSegments);if(!(e>=0)&&e<=this.numCurveSegments)return;let t=Math.floor(e);t>=this.numCurveSegments&&(t=this.numCurveSegments-1);let a=this.controlVertices,r=[];return r[0]=a[3*t+0],r[1]=a[3*t+1],r[2]=a[3*t+2],r[3]=a[3*t+3],new In(r).getTangent(e-t)}getTangentNorm(e){return this.getTangent(e*this.numCurveSegments)}computeClosestParam(e,t){let a=Number.MAX_SAFE_INTEGER,r=0,i=[],n=new In(i);for(let o=0;o<this.controlVertices.length-1;o+=3){for(let h=0;h<4;h++)i[h]=this.controlVertices[o+h];n.setControlVertices(i);let l=n.getClosestParam(e,t),f=n.getPoint(l).subtract(e).lengthSquared;f<a&&(a=f,r=o/3+l)}return r}computeClosestNormParam(e,t){return this.computeClosestParam(e,t*this.numCurveSegments)}}class hm extends Map{valueList;keyList;isChange=!0;constructor(e,t,a){if(super(e),t&&(this.keyList=[]),a&&(this.valueList=[]),e)for(let r of e)this.valueList?.push(r[1]),this.keyList?.push(r[0])}delete(e){if(this.has(e)){let t=this.get(e);return this.valueList&&this.deleteValue(t),this.keyList&&this.deleteKey(e),this.isChange=!0,super.delete(e)}return!1}deleteValue(e){let t=this.valueList.indexOf(e);return t>=0&&this.valueList.splice(t,1),this}deleteKey(e){let t=this.keyList.indexOf(e);return t>=0&&this.keyList.splice(t,1),this}set(e,t){return this.delete(e),this.keyList?.push(e),this.valueList?.push(t),super.set(e,t),this.isChange=!0,this}clear(){this.valueList&&(this.valueList.length=0),this.keyList&&(this.keyList.length=0),this.isChange=!0,super.clear()}}var Ch=(s=>(s[s.kParticleSystemClampVelocityCurveId=322376503]="kParticleSystemClampVelocityCurveId",s[s.kParticleSystemForceCurveId=306581307]="kParticleSystemForceCurveId",s[s.kParticleSystemRotationCurveId=1793934638]="kParticleSystemRotationCurveId",s[s.kParticleSystemRotationBySpeedCurveId=3737431713]="kParticleSystemRotationBySpeedCurveId",s[s.kParticleSystemStartSpeedCurveId=2527743459]="kParticleSystemStartSpeedCurveId",s[s.kParticleSystemSizeCurveId=2368504881]="kParticleSystemSizeCurveId",s[s.kParticleSystemSizeBySpeedCurveId=4085612399]="kParticleSystemSizeBySpeedCurveId",s[s.kParticleSystemVelocityCurveId=3774601268]="kParticleSystemVelocityCurveId",s[s.kParticleSystemUVCurveId=326370691]="kParticleSystemUVCurveId",s[s.kParticleSystemColorGradientId=1494990940]="kParticleSystemColorGradientId",s[s.kParticleSystemColorByVelocityGradientId=1089181156]="kParticleSystemColorByVelocityGradientId",s[s.kParticleSystemMeshSelectionId=3159510623]="kParticleSystemMeshSelectionId",s[s.kParticleSystemUVRowSelectionId=2941263940]="kParticleSystemUVRowSelectionId",s))(Ch||{});const um=3.141592653589793;class bm{}function Sh(s,e,t){let a=.3333333333333333,r=.5,i=s*a,n=i*i,l=n*i-i*e*r+t*r,c=-n+e*a,f=c*c*c,h=f+l*l;if(h>=0){let p=Math.sqrt(h)-l;return p=p>0?Math.pow(p,a):-Math.pow(-p,a),-i-c/p+p}let u=Math.sqrt(-f),g=Math.acos(-l/u);return u=Math.pow(u,a),u=u-c/u,g=-i+u*Math.cos(g*a),g}function Qn(s,e,t,a){let r=1e-5;if(Math.abs(s)<r)return Math.abs(e)>r?(a.r0=-t/e,1):0;let i=e*e-4*s*t;if(i<0)return 0;let n=.5/s,o=Math.sqrt(i);return a.r0=(o-e)*n,a.r1=(-o-e)*n,2}function xh(s,e,t,a,r){let i=0;if(Math.abs(e)>=1e-4){let n=t/e,o=a/e,l=r/e;s[0]=Sh(n,o,l),i++;let c=e,f=t+e*s[0],h=a+t*s[0]+e*s[0]*s[0];i+=Qn(c,f,h,{r0:s[1],r1:s[2]})}else i+=Qn(t,a,r,{r0:s[1],r1:s[2]});return i}class Ua{coeff=[];static EvalSegment(e,t){return e*(e*(e*t[0]+t[1])+t[2])+t[3]}}class Wa{static kMaxNumSegments=8;segments=[];integrationCache=[];doubleIntegrationCache=[];times=[];segmentCount;constructor(){this.segments[Wa.kMaxNumSegments]=new Ua,this.integrationCache[Wa.kMaxNumSegments]=0,this.doubleIntegrationCache[Wa.kMaxNumSegments]=0,this.times[Wa.kMaxNumSegments]=0}calculateMinMax(e,t){e.x=Math.min(e.x,t),e.y=Math.max(e.y,t)}findMinMaxDoubleIntegrated(){let e=K.ZERO.clone(),t=20,a=1/t,r=a;for(let i=0;i<t;i++)this.calculateMinMax(e,this.evaluateDoubleIntegrated(r)),r+=a;return e}findMinMaxIntegrated(){let e=K.ZERO.clone(),t=[],a=[];for(let r=0;r<this.segmentCount;r++){let i=4*this.segments[r].coeff[0],n=3*this.segments[r].coeff[1],o=2*this.segments[r].coeff[2],l=1*this.segments[r].coeff[3],c=[],f=xh(c,i,n,o,l);for(let h=0;h<f;h++){let u=c[h]+t[r];u>=t[r]&&u<a[r]&&this.calculateMinMax(e,this.evaluateIntegrated(u))}this.calculateMinMax(e,this.evaluateIntegrated(a[r])),this.times[r]}return e}generateIntegrationCache(e){e.integrationCache[0]=0;let t=e.times[0],a=0;for(let r=1;r<e.segmentCount;r++){let i=e.segments[r-1].coeff;Eo(i);let n=t-a;e.integrationCache[r]=e.integrationCache[r-1]+Ua.EvalSegment(n,i)*n,a=t,t=e.times[r]}}generateDoubleIntegrationCache(e){let t=0,a=0;for(let r=0;r<e.segmentCount;r++){e.doubleIntegrationCache[r]=t;let i=e.times[r]-a;i=Math.max(i,0),t+=Ua.EvalSegment(i,e.segments[r].coeff)*i*i+e.integrationCache[r]*i,a=e.times[r]}}integrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)Eo(this.segments[e].coeff)}doubleIntegrate(){this.generateIntegrationCache(this);for(let e=0;e<this.segmentCount;e++)Fh(this.segments[e].coeff);this.generateDoubleIntegrationCache(this)}static isValidCurve(e){let t=e.getKeyCount(),a=t-1;return e.getKey(0).time!=0&&a++,e.getKey(t-1).time!=1&&a++,a<=Wa.kMaxNumSegments}evaluateDoubleIntegrated(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a]){let r=e-t;return this.doubleIntegrationCache[a]+this.integrationCache[a]*r+Ua.EvalSegment(r,this.segments[a].coeff)*r*r}t=this.times[a]}return 1}evaluateIntegrated(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a]){let r=e-t;return this.integrationCache[a]+Ua.EvalSegment(r,this.segments[a].coeff)*r}t=this.times[a]}return 1}evaluate(e){let t=0;for(let a=0;a<this.segmentCount;a++){if(e<=this.times[a])return Ua.EvalSegment(e-t,this.segments[a].coeff);t=this.times[a]}return 1}buildCurve(e,t){let a=e.getKeyCount();this.segmentCount=1;let r=1.01;if(this.segments.length=0,this.integrationCache.length=0,this.doubleIntegrationCache.length=0,this.times.length=0,this.times[0]=r,a!=0)if(a==1)this.segments[0]=new Ua,this.segments[0].coeff[3]=e.getKey(0).value*t;else{this.segmentCount=a-1;let i=0;e.getKey(0).time!=0&&(this.segments[0].coeff[3]=e.getKey(0).value,this.times[0]=e.getKey(0).time,i=1);for(let n=0;n<this.segmentCount;n++){let o;e.calculateCacheData(o,n,n+1,0),this.segments[n+i].coeff=o.coeff.concat(),this.times[n+i]=e.getKey(n+1).time}this.segmentCount+=i,e.getKey(a-1).time!=1&&(this.segments[this.segmentCount].coeff[3]=e.getKey(a-1).value,this.segmentCount++),this.times[this.segmentCount-1]=r;for(let n=0;n<this.segmentCount;n++)this.segments[n].coeff[0]*=t,this.segments[n].coeff[1]*=t,this.segments[n].coeff[2]*=t,this.segments[n].coeff[3]*=t}return!0}}function Fh(s){s[0]/=20,s[1]/=12,s[2]/=6,s[3]/=2}function Eo(s){s[0]/=4,s[1]/=3,s[2]/=2,s[3]/=1}var kh=(s=>(s[s.kEMScalar=0]="kEMScalar",s[s.kEMOptimized=1]="kEMOptimized",s[s.kEMOptimizedMinMax=2]="kEMOptimizedMinMax",s[s.kEMSlow=3]="kEMSlow",s))(kh||{}),Eh=(s=>(s[s.kMMCScalar=0]="kMMCScalar",s[s.kMMCCurve=1]="kMMCCurve",s[s.kMMCTwoCurves=2]="kMMCTwoCurves",s[s.kMMCTwoConstants=3]="kMMCTwoConstants",s))(Eh||{});class gm{max;min}class mm{max;min;integrate(){this.max.integrate(),this.min.integrate()}doubleIntegrate(){this.max.doubleIntegrate(),this.min.doubleIntegrate()}findMinMaxIntegrated(){return null}findMinMaxDoubleIntegrated(){return null}}class Rh{minMaxState;minCurve;maxCurve;_scalar=1;_minScalar;constructor(e=1){this._scalar=e,this.minMaxState=0,this.minCurve=new Ri,this.maxCurve=new Ri}setScalar(e){this._scalar=e}getScalar(){return this._scalar}static evaluateSlow(e,t,a){let r=e.maxCurve.getValue(t)*e.getScalar();return e.minMaxState==2?Ar(e.minCurve.getValue(t)*e.getScalar(),r,a):r}static evaluate(e,t,a=1){if(e.minMaxState==0)return e.getScalar();let r=e.maxCurve.getValue(t)*e.getScalar();return e.minMaxState==1?Ar(e.minCurve.getValue(t)*e.getScalar(),r,a):e.minMaxState==3?Ar(e._minScalar,e._scalar,a):e.minMaxState==2?Ar(e.minCurve.getValue(t)*e.getScalar(),r,1*Math.random()):this.evaluateSlow(e,t,1)}unSerialized(e){this.minMaxState=e.minMaxState,this._scalar=e.scalar,this._minScalar=e.minScalar,this.maxCurve.unSerialized(e.maxCurve),this.minCurve.unSerialized(e.minCurve)}}class pm{value=0;mode=0;spread=0;speed=new Rh;unSerialized(e){this.value=e.value,this.mode=e.mode,this.spread=e.spread,this.speed.unSerialized(e.speed)}}function Am(s,e){let t=Wa.isValidCurve(s.max);return e!=2&&e!=3?t:t&&Wa.isValidCurve(s.min)}function Dm(s,e,t,a){s.max.buildCurve(e.max,t),a!=2&&a!=3?s.min.buildCurve(e.max,t):s.min.buildCurve(e.min,t)}function _m(s,e){let t=e.getKeyCount();if(t!=0)if(t==1)Ji(s,e.getKey(0).value);else{let a=t-1;Ji(s,e.getKey(0).value);for(let r=0;r<a;r++){let i=new ao;e.calculateCacheData(i,r,r+1,0);let n=3*i.coeff[0],o=2*i.coeff[1],l=1*i.coeff[2],c=e.getKey(r).time,f=e.getKey(r+1).time,h=[],u=Qn(n,o,l,{r0:h[0],r1:h[1]});for(let g=0;g<u;g++)h[g]>=0&&h[g]+c<f&&Ji(s,Ua.EvalSegment(h[g],i.coeff));Ji(s,Ua.EvalSegment(f-c,i.coeff))}}}function Ji(s,e){s.x=Math.min(s.x,e),s.y=Math.max(s.y,e)}class wr{static BACK=0;static FRONT=1;static IN=0;static OUT=1;static INTERSECT=2}class wh{a;b;c;d;static ALIGN_ANY=0;static ALIGN_XY_AXIS=1;static ALIGN_YZ_AXIS=2;static ALIGN_XZ_AXIS=3;constructor(e=0,t=0,a=0,r=0){this.a=e,this.b=t,this.c=a,this.d=r}setTo(e=0,t=0,a=0,r=0){this.a=e,this.b=t,this.c=a,this.d=r}fromPoints(e,t,a){var r=t.x-e.x,i=t.y-e.y,n=t.z-e.z,o=a.x-e.x,l=a.y-e.y,c=a.z-e.z;this.a=i*c-n*l,this.b=n*o-r*c,this.c=r*l-i*o,this.d=-(this.a*e.x+this.b*e.y+this.c*e.z)}fromNormalAndPoint(e,t){this.a=e.x,this.b=e.y,this.c=e.z,this.d=-(this.a*t.x+this.b*t.y+this.c*t.z)}normalize(){var e=Math.sqrt(this.a*this.a+this.b*this.b+this.c*this.c);if(e>0){var t=1/e;this.a*=t,this.b*=t,this.c*=t,this.d*=t}return e}distance(e){return this.a*e.x+this.b*e.y+this.c*e.z+this.d}classifyPoint(e,t=.01){var a=this.distance(e);return a<-t?wr.BACK:a>t?wr.FRONT:wr.INTERSECT}toString(){return"Plane3D [a:"+this.a+", b:"+this.b+", c:"+this.c+", d:"+this.d+"]"}}function Bm(s,e){return Math.random()*e+Math.random()*s+(e-s)*Math.random()}function Um(s,e,t){let a=t*Math.random();return Math.random()*e*a+Math.random()*s*a+(e-s)*Math.random()*a}function Ih(s,e,t){let a=0,r=0;for(;a===0;)a=Math.random();for(;r===0;)r=Math.random();let i=Math.sqrt(-2*Math.log(a))*Math.cos(2*Math.PI*r);return i=i/10+.5,(i>1||i<0)&&(i=Ih(s,e,t)),i=Math.pow(i,t),i*=e-s,i+=s,i}function fa(s){return s>0?Math.floor(s):Math.floor(s)-1}let ce=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];function Ro(s,e){let t=s&15,a=1+(t&7);return t&8&&(a=-a),a*e}function Tn(s,e,t){let a=s&7,r=a<4?e:t,i=a<4?t:e;return(a&1?-r:r)+(a&2?-2*i:2*i)}function Wi(s,e,t,a){let r=s&15,i=r<8?e:t,n=r<4?t:r==12||r==14?e:a;return(r&1?-i:i)+(r&2?-n:n)}function li(s,e,t,a,r){let i=s&31,n=i<24?e:t,o=i<16?t:a,l=i<8?a:r;return(i&1?-n:n)+(i&2?-o:o)+(i&4?-l:l)}let Lt=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]];function vm(s){let e=fa(s),t=e+1,a=s-e,r=a-1,i,n,o=1-a*a;o*=o,i=o*o*Ro(ce[e&255],a);let l=1-r*r;return l*=l,n=l*l*Ro(ce[t&255],r),.25*(i+n)}function ym(s,e){const t=.366025403,a=.211324865;let r,i,n,o=(s+e)*t,l=s+o,c=e+o,f=fa(l),h=fa(c),u=(f+h)*a,g=f-u,p=h-u,m=s-g,D=e-p,_,B;m>D?(_=1,B=0):(_=0,B=1);let v=m-_+a,C=D-B+a,y=m-1+2*a,F=D-1+2*a,k=f&255,w=h&255,x=.5-m*m-D*D;x<0?r=0:(x*=x,r=x*x*Tn(ce[k+ce[w]],m,D));let M=.5-v*v-C*C;M<0?i=0:(M*=M,i=M*M*Tn(ce[k+_+ce[w+B]],v,C));let N=.5-y*y-F*F;return N<0?n=0:(N*=N,n=N*N*Tn(ce[k+1+ce[w+1]],y,F)),40*(r+i+n)}function Cm(s,e,t){const a=.333333333,r=.166666667;let i,n,o,l,c=(s+e+t)*a,f=s+c,h=e+c,u=t+c,g=fa(f),p=fa(h),m=fa(u),D=(g+p+m)*r,_=g-D,B=p-D,v=m-D,C=s-_,y=e-B,F=t-v,k,w,x,M,N,Q;C>=y?y>=F?(k=1,w=0,x=0,M=1,N=1,Q=0):C>=F?(k=1,w=0,x=0,M=1,N=0,Q=1):(k=0,w=0,x=1,M=1,N=0,Q=1):y<F?(k=0,w=0,x=1,M=0,N=1,Q=1):C<F?(k=0,w=1,x=0,M=0,N=1,Q=1):(k=0,w=1,x=0,M=1,N=1,Q=0);let G=C-k+r,X=y-w+r,ne=F-x+r,q=C-M+2*r,he=y-N+2*r,Be=F-Q+2*r,ae=C-1+3*r,ee=y-1+3*r,se=F-1+3*r,Ae=g&255,Ue=p&255,Se=m&255,Te=.6-C*C-y*y-F*F;Te<0?i=0:(Te*=Te,i=Te*Te*Wi(ce[Ae+ce[Ue+ce[Se]]],C,y,F));let ve=.6-G*G-X*X-ne*ne;ve<0?n=0:(ve*=ve,n=ve*ve*Wi(ce[Ae+k+ce[Ue+w+ce[Se+x]]],G,X,ne));let Me=.6-q*q-he*he-Be*Be;Me<0?o=0:(Me*=Me,o=Me*Me*Wi(ce[Ae+M+ce[Ue+N+ce[Se+Q]]],q,he,Be));let Ut=.6-ae*ae-ee*ee-se*se;return Ut<0?l=0:(Ut*=Ut,l=Ut*Ut*Wi(ce[Ae+1+ce[Ue+1+ce[Se+1]]],ae,ee,se)),32*(i+n+o+l)}function Sm(s,e,t,a){const r=.309016994,i=.138196601;let n,o,l,c,f,h=(s+e+t+a)*r,u=s+h,g=e+h,p=t+h,m=a+h,D=fa(u),_=fa(g),B=fa(p),v=fa(m),C=(D+_+B+v)*i,y=D-C,F=_-C,k=B-C,w=v-C,x=s-y,M=e-F,N=t-k,Q=a-w,G=x>M?32:0,X=x>N?16:0,ne=M>N?8:0,q=x>Q?4:0,he=M>Q?2:0,Be=N>Q?1:0,ae=G+X+ne+q+he+Be,ee,se,Ae,Ue,Se,Te,ve,Me,Ut,ya,Ca,It;ee=Lt[ae][0]>=3?1:0,se=Lt[ae][1]>=3?1:0,Ae=Lt[ae][2]>=3?1:0,Ue=Lt[ae][3]>=3?1:0,Se=Lt[ae][0]>=2?1:0,Te=Lt[ae][1]>=2?1:0,ve=Lt[ae][2]>=2?1:0,Me=Lt[ae][3]>=2?1:0,Ut=Lt[ae][0]>=1?1:0,ya=Lt[ae][1]>=1?1:0,Ca=Lt[ae][2]>=1?1:0,It=Lt[ae][3]>=1?1:0;let Qt=x-ee+i,Gt=M-se+i,Ct=N-Ae+i,Sa=Q-Ue+i,xa=x-Se+2*i,Fa=M-Te+2*i,ka=N-ve+2*i,Ea=Q-Me+2*i,gr=x-Ut+3*i,Ra=M-ya+3*i,Ir=N-Ca+3*i,mr=Q-It+3*i,Qr=x-1+4*i,Tr=M-1+4*i,wa=N-1+4*i,Mr=Q-1+4*i,Za=D&255,$t=_&255,Nr=B&255,pr=v&255,Pr=.6-x*x-M*M-N*N-Q*Q;Pr<0?n=0:(Pr*=Pr,n=Pr*Pr*li(ce[Za+ce[$t+ce[Nr+ce[pr]]]],x,M,N,Q));let Vr=.6-Qt*Qt-Gt*Gt-Ct*Ct-Sa*Sa;Vr<0?o=0:(Vr*=Vr,o=Vr*Vr*li(ce[Za+ee+ce[$t+se+ce[Nr+Ae+ce[pr+Ue]]]],Qt,Gt,Ct,Sa));let Or=.6-xa*xa-Fa*Fa-ka*ka-Ea*Ea;Or<0?l=0:(Or*=Or,l=Or*Or*li(ce[Za+Se+ce[$t+Te+ce[Nr+ve+ce[pr+Me]]]],xa,Fa,ka,Ea));let Lr=.6-gr*gr-Ra*Ra-Ir*Ir-mr*mr;Lr<0?c=0:(Lr*=Lr,c=Lr*Lr*li(ce[Za+Ut+ce[$t+ya+ce[Nr+Ca+ce[pr+It]]]],gr,Ra,Ir,mr));let Gr=.6-Qr*Qr-Tr*Tr-wa*wa-Mr*Mr;return Gr<0?f=0:(Gr*=Gr,f=Gr*Gr*li(ce[Za+1+ce[$t+1+ce[Nr+1+ce[pr+1]]]],Qr,Tr,wa,Mr)),27*(n+o+l+c+f)}class wo extends K{static uv_0=new wo;u=0;v=0;constructor(e=0,t=0){super(e,t),this.u=e,this.v=t}length(){return 0}static getUVSheet(e,t,a){let r=Math.floor(e%(t*a)),i=Math.floor(r/t),n=r%t;return new $(i/t,n/a,1/t,1/a)}}class ji{serializedVersion="2";time;tangentMode=0;weightedMode=0;propertyKeyFrame;constructor(e=0){this.time=e,this.propertyKeyFrame={}}getK(e){return this.propertyKeyFrame[e]}split(e,t,a){switch(e){case z.single:{let r=this.getKeyFrame(0);r[a]=t}break;case z.float:{let r=this.getKeyFrame(0);r[a]=t}break;case z.vector2:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y}break;case z.vector3:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z}break;case z.vector4:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z;let l=this.getKeyFrame(3);l[a]=r.w}break;case z.quaternion:{let r=t,i=this.getKeyFrame(0);i[a]=r.x;let n=this.getKeyFrame(1);n[a]=r.y;let o=this.getKeyFrame(2);o[a]=r.z;let l=this.getKeyFrame(3);l[a]=r.w}break}}getKeyFrame(e){let t=this.propertyKeyFrame[e];return t||(t=new _n,t.time=this.time,t.tangentMode=this.tangentMode,t.weightedMode=this.weightedMode,this.propertyKeyFrame[e]=t),t}formBytes(e){this.time=e.readFloat32();{let{t,v:a}=_a.parser(e);this.split(t,a,"value")}{let{t,v:a}=_a.parser(e);this.split(t,a,"inSlope")}{let{t,v:a}=_a.parser(e);this.split(t,a,"outSlope")}this.tangentMode=e.readInt32(),this.weightedMode=e.readInt32();{let{t,v:a}=_a.parser(e);this.split(t,a,"inWeight")}{let{t,v:a}=_a.parser(e);this.split(t,a,"outWeight")}}}class xm{static sub(e,t){switch(e.constructor.name){case"number":return e-t;case"Vector2":{let r=e,i=t;return new K(r.x-i.x,r.y-i.y)}case"Vector3":{let r=e,i=t;return new b(r.x-i.x,r.y-i.y,r.z-i.z)}case"Vector4":{let r=e,i=t;return new $(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}case"Quaternion":{let r=e,i=t;return new Z(r.x-i.x,r.y-i.y,r.z-i.z,r.w-i.w)}}}}class Zi{_keys=new Array;_values=new Array;getIndexByKey(e){return this._keys.indexOf(e)}getValueByKey(e){var t=this.getIndexByKey(e);return t>-1?this._values[t]:null}put(e,t){if(e==null)return null;var a=this.remove(e);return this._keys.push(e),this._values.push(t),a}remove(e){var t=this._keys.indexOf(e),a;return t>-1&&(a=this._values[t],this._keys.splice(t,1),this._values.splice(t,1)),a}getValues(){return this._values}getKeys(){return this._keys}clear(){this._values.length=0,this._keys.length=0}}class br{static WalkAble=1}class Yi{static SetConst(e){this.EPSILON=e,this.POWER_EPSILON=e*e}static EPSILON=.1;static POWER_EPSILON=this.EPSILON*this.EPSILON}class Bt extends b{static CALC_VECTOR3D1=new b;static CALC_VECTOR3D2=new b;static CALC_VECTOR3D3=new b;static CALC_VECTOR3D4=new b;static CALC_VECTOR3D5=new b;_pointId=0;constructor(e,t,a,r){super(t,a,r,0),this._pointId=e}get id(){return this._pointId}static equalPoint(e,t){return(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)+(e.z-t.z)*(e.z-t.z)<Yi.POWER_EPSILON}static calcDistance(e,t){return Bt.CALC_VECTOR3D3.setTo(e.x-t.x,e.y-t.y,e.z-t.z),Bt.CALC_VECTOR3D3.length}}class Qh{_openedList;_closedList;_endNode;_startNode;_triangleChannel;_navMesh;_findIndex=0;constructor(){this._openedList=new Array,this._closedList=new Array}findPath(e,t,a){return this._findIndex++,this._navMesh=e,this._startNode=t,this._endNode=a,this._openedList.length=0,this._closedList.length=0,this._startNode&&this._endNode?(this._startNode.gg=0,this._startNode.h=0,this._startNode.f=0,this._startNode.parent=null,this.search()):!1}search(){for(var e=this._startNode,t=[],a;e!=this._endNode;){t=e.getNeibourTriangles(t,br.WalkAble,br.WalkAble);for(a of t)if(a.closeId!=this._findIndex&&!(a==e||!a.walkAble)){var r=e.gg+Bt.calcDistance(a,e)*a.costMultiplier,i=Bt.calcDistance(a,this._endNode),n=r+i;a.openId==this._findIndex?a.f>n&&(a.f=n,a.gg=r,a.h=i,a.parent=e):(a.f=n,a.gg=r,a.h=i,a.parent=e,a.openId=this._findIndex,this._openedList.push(a))}if(e.closeId=this._findIndex,this._closedList.push(e),this._openedList.length==0)return!1;this._openedList.sort(function(o,l){return o.f-l.f}),e=this._openedList.shift()}return this.buildPath(),!0}buildPath(){this._triangleChannel=[];var e=this._endNode;for(this._triangleChannel.push(e);e!=this._startNode;)e=e.parent,this._triangleChannel.unshift(e)}get channel(){return this._triangleChannel}}class da extends Bt{_ownerPoint;_ownerEdge;radius=0;constructor(e,t){super(e.id,0,0,0),this._ownerEdge=t,this._ownerPoint=e}get ownerPoint(){return this._ownerPoint}get ownerEdge(){return this._ownerEdge}scalePoint(e=.7){var t=new da(this._ownerPoint,this._ownerEdge);return t.copyFrom(this),t.decrementBy(this._ownerPoint),t.scaleBy(e),t.radius=t.length,t.incrementBy(this._ownerPoint),t}}class ha{_edgeMask=0;_edgeSize=0;_pointA;_pointB;_triangleOwners;_centerPoint;_edgeDirA2B;crossPoint;fatPointA;fatPointB;static CALC_FAT_VECTOR=new b;constructor(e,t){if(this._pointA=e,this._pointB=t,e.id>=t.id)throw new Error("edge point order error!!!");this._triangleOwners=new Array,this._centerPoint=new b,this._edgeMask=br.WalkAble,Bt.CALC_VECTOR3D1.setTo(e.x-t.x,e.y-t.y,e.z-t.z),this._edgeSize=Bt.CALC_VECTOR3D1.length,this._centerPoint.setTo((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2)}get size(){return this._edgeSize}get triangleOwners(){return this._triangleOwners}get centerPoint(){return this._centerPoint}initFatPoints(e){this._edgeDirA2B=this._pointB.subtract(this._pointA),this._edgeDirA2B.normalize(),this.fatPointA=this.fatPointA||new da(this._pointA,this),this.fatPointB=this.fatPointB||new da(this._pointB,this),this.fatPointA.radius!=e&&(ha.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),ha.CALC_FAT_VECTOR.scaleBy(e),ha.CALC_FAT_VECTOR.incrementBy(this._pointA),this.fatPointA.copyFrom(ha.CALC_FAT_VECTOR),this.fatPointA.radius=e),this.fatPointB.radius!=e&&(ha.CALC_FAT_VECTOR.copyFrom(this._edgeDirA2B),ha.CALC_FAT_VECTOR.scaleBy(-e),ha.CALC_FAT_VECTOR.incrementBy(this._pointB),this.fatPointB.copyFrom(ha.CALC_FAT_VECTOR),this.fatPointB.radius=e)}getFatPoint(e){return e==this._pointA?this.fatPointA:this.fatPointB}getAnotherFatPoint(e){return e==this._pointA?this.fatPointB:this.fatPointA}getAnotherPoint(e){return e==this._pointA?this._pointB:this._pointA}containsPoint(e){return Bt.equalPoint(e,this._pointA)?this._pointA:Bt.equalPoint(e,this._pointB)?this._pointB:null}addTriangleOwners(e){if(e.edges.indexOf(this)==-1)throw new Error("the edge is not belong triangle!!!");this._triangleOwners.indexOf(e)==-1&&this._triangleOwners.push(e)}getPublicPoint(e){return this._pointA==e._pointA||this._pointA==e._pointB?this._pointA:this._pointB==e._pointA||this._pointB==e._pointB?this._pointB:null}getEqualPoint(e){return Bt.equalPoint(e,this._pointA)?this._pointA:Bt.equalPoint(e,this._pointB)?this._pointB:null}get pointA(){return this._pointA}get pointB(){return this._pointB}get walkAble(){return(this._edgeMask&br.WalkAble)==br.WalkAble}testMask(e){return(this._edgeMask&e)==e}}class re{endPoint;curPoint;rayA;rayB;rayAPoint;rayBPoint;static RAY_1=new b;static RAY_2=new b;static TEST_RAY=new b;static TEST_RAY_1=new b;static TEST_RAY_2=new b;static CALC_CROSS_POINT=new b;static CALC_CROSS_TEST=new b;cornerPoint;cornerEdge;continuePass(e,t,a){this.resetData(),this.curPoint=e,this.endPoint=t,this.cornerEdge=a}passEdge(e,t,a,r){if((this.rayA==null||this.rayB==null)&&(this.rayA=re.RAY_1,this.rayB=re.RAY_2,this.rayAPoint=e.pointA,this.rayBPoint=e.pointB,this.rayA.setTo(this.rayAPoint.x-this.curPoint.x,0,this.rayAPoint.z-this.curPoint.z),this.rayB.setTo(this.rayBPoint.x-this.curPoint.x,0,this.rayBPoint.z-this.curPoint.z)),r)return this.checkEndPoint(a);if(re.TEST_RAY.setTo(a.x-this.curPoint.x,0,a.z-this.curPoint.z),this.isPointAtCenter(re.TEST_RAY,this.rayA,this.rayB)){this.hasCrossPoint(t.pointA,t.pointB,this.rayAPoint,this.rayA)?(this.rayB.copyFrom(re.TEST_RAY),a instanceof Bt?this.rayBPoint=a:this.rayBPoint=null):(this.rayA.copyFrom(re.TEST_RAY),a instanceof Bt?this.rayAPoint=a:this.rayAPoint=null);var i=t.getAnotherPoint(a);re.TEST_RAY.setTo(i.x-this.curPoint.x,0,i.z-this.curPoint.z),(i==this.rayAPoint||i==this.rayBPoint||this.isPointAtCenter(re.TEST_RAY,this.rayA,this.rayB))&&(this.cornerEdge=t)}else{var n;if(re.TEST_RAY_1.copyFrom(t.pointA),re.TEST_RAY_1.decrementBy(this.curPoint),re.TEST_RAY_2.copyFrom(t.pointB),re.TEST_RAY_2.decrementBy(this.curPoint),re.TEST_RAY_1.y=0,re.TEST_RAY_2.y=0,this.isPointAtCenter(this.rayA,re.TEST_RAY_1,re.TEST_RAY_2)||this.isPointAtCenter(this.rayB,re.TEST_RAY_1,re.TEST_RAY_2)?n=!1:n=!0,n)return this.isPointAtCenter(this.rayA,re.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1}return!0}checkEndPoint(e){return re.TEST_RAY.setTo(e.x-this.curPoint.x,0,e.z-this.curPoint.z),this.isPointAtCenter(re.TEST_RAY,this.rayA,this.rayB)?!0:(this.isPointAtCenter(this.rayA,re.TEST_RAY,this.rayB)?this.cornerPoint=this.rayAPoint:this.cornerPoint=this.rayBPoint,this.cornerEdge.crossPoint=this.cornerPoint,!1)}calcCrossEdge(e,t,a){return this.calcCrossPoint(e.fatPointA,e.fatPointB,t,a)}calcCrossPoint(e,t,a,r){re.CALC_CROSS_POINT.copyFrom(t),re.CALC_CROSS_POINT.decrementBy(e);let i=re.CALC_CROSS_POINT.x*r.z-r.x*re.CALC_CROSS_POINT.z;var n=0;return i!=0&&(n=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/i),n>1?n=1:n<0&&(n=0),re.CALC_CROSS_POINT.scaleBy(n),re.CALC_CROSS_POINT.incrementBy(e),re.CALC_CROSS_POINT.clone()}calcCrossPointOut(e,t,a,r){re.CALC_CROSS_POINT.copyFrom(t),re.CALC_CROSS_POINT.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(re.CALC_CROSS_POINT.x*r.z-r.x*re.CALC_CROSS_POINT.z);return i<=1&&i>=0?null:(re.CALC_CROSS_POINT.scaleBy(i),re.CALC_CROSS_POINT.incrementBy(e),re.CALC_CROSS_POINT.clone())}hasCrossPoint(e,t,a,r){re.CALC_CROSS_TEST.copyFrom(t),re.CALC_CROSS_TEST.decrementBy(e);var i=((e.z-a.z)*r.x-(e.x-a.x)*r.z)/(re.CALC_CROSS_TEST.x*r.z-r.x*re.CALC_CROSS_TEST.z);return i<=1&&i>=0}isPointAtCenter(e,t,a){var r=t.crossProduct(e);if(r.length==0&&e.length<t.length)return!0;var i=a.crossProduct(e);return i.length==0&&e.length<a.length?!0:(r.normalize(),i.normalize(),r.incrementBy(i),r.length<.01)}resetData(){this.cornerEdge=null,this.cornerPoint=null,this.curPoint=null,this.rayA=this.rayB=null,this.rayAPoint=this.rayBPoint=null,re.RAY_1.setTo(0,0,0),re.RAY_2.setTo(0,0,0)}}class ja{_aiRadius=0;_router;_result;_tempPublicEdgeList=new Array;_tempSamePlaneList=new Array;static CROSS_TEST_DIRECTION=new b;constructor(){this._router=new re}searchPath(e,t,a,r=0){return r<=0&&(r=1),this._aiRadius=r*1.5,this.searchEnable(e,t,a)?(this.search(e,t,a),!0):!1}get path(){return this._result}searchEnable(e,t,a){return!(e==null||t==null||a==null||a[0].plane.classifyPoint(e,Yi.EPSILON)!=wr.INTERSECT||a[a.length-1].plane.classifyPoint(t,Yi.EPSILON)!=wr.INTERSECT)}search(e,t,a){this._tempPublicEdgeList.length=0,this._tempSamePlaneList.length=0;var r=0,i=a.length-1,n,o,l,c;for(r=0;r<i;r++)o=a[r].getPublicEdge(a[r+1]),o.crossPoint=null,o.initFatPoints(this._aiRadius),this._tempPublicEdgeList.push(o),n=a[r],c=n.plane,n=a[r+1],l=n.getEdgeAgainstPoint(o),this._tempSamePlaneList.push(c.classifyPoint(l,Yi.EPSILON)==wr.INTERSECT);this._router.continuePass(e,t,this._tempPublicEdgeList[0]),i=this._tempPublicEdgeList.length;var f,h,u,g;for(r=0;r<i;r++)o=this._tempPublicEdgeList[r],n=a[r+1],g=r==i-1,g?l=t:l=n.getEdgeAgainstPoint(o),u=this._router.passEdge(o,this._tempPublicEdgeList[r+1],l,g),u||(f=this._router.cornerPoint,h=this._router.cornerEdge,r=this._tempPublicEdgeList.indexOf(h),this._router.continuePass(f,t,this._tempPublicEdgeList[r+1]));this.pushAllPathPoint2(e,t),this._result.length>=3&&(this.optimusTerminusFat(),this.optimusByRadius());let p=[];for(let m of this._result)p.push(new b().copyFrom(m));this._result=p}optimusTerminusFat(){var e,t,a;a=this._result[1],a instanceof da&&(e=a),a=this._result[this._result.length-2],a instanceof da&&(t=a),e&&(this._result[1]=e.scalePoint()),t&&e!=t&&(this._result[this._result.length-2]=t.scalePoint())}pushAllPathPoint2(e,t){var a=this._tempPublicEdgeList.length,r,i;this._result=new Array,this._result.push(e);for(var n=e,o,l,c,f=0;f<a;f++)if(r=this._tempPublicEdgeList[f],l=null,r.crossPoint)l=this.getFatPoint(r,r.crossPoint),l?this._result.push(l):this._result.push(r.crossPoint),n=r.crossPoint;else{i=null,o=null;for(var h=f+1;h<a&&(i=this._tempPublicEdgeList[h],o=i.crossPoint,!o);h++);o==null&&(o=t),l=this.getFatPoint(r,o),l?this._result.push(l):(o==n?c=o.clone():(ja.CROSS_TEST_DIRECTION.setTo(o.x-n.x,0,o.z-n.z),c=this._router.calcCrossEdge(r,n,ja.CROSS_TEST_DIRECTION)),this._result.push(c))}this._result.push(t)}optimusByRadius(){var e=new Array;e.length=this._result.length;var t=this._result.length-2,a,r,i,n,o,l,c,f,h,u,g,p,m;for(m=0;m<t;m++)c=f=h=null,n=o=l=null,g=!1,p=null,a=this._result[m],r=this._result[m+1],i=this._result[m+2],a instanceof da&&(n=a),r instanceof da&&(o=r),i instanceof da&&(l=i),n&&(c=n.ownerPoint),o&&(f=o.ownerPoint),l&&(h=l.ownerPoint),c&&f&&c==f&&f!=h&&(g=!0),h&&f&&h==f&&c!=f&&(g=!0),g&&(ja.CROSS_TEST_DIRECTION.copyFrom(a),ja.CROSS_TEST_DIRECTION.decrementBy(i),u=o.ownerEdge,g=this._router.hasCrossPoint(u.pointA,u.pointB,i,ja.CROSS_TEST_DIRECTION),g&&(p=this._router.calcCrossPointOut(f,r,i,ja.CROSS_TEST_DIRECTION)),p&&(e[m+1]=p))}getFatPoint(e,t){if(e==null)return null;var a;t instanceof da&&(a=t);var r;return a?r=a.ownerPoint:r=e.getEqualPoint(t),r==null?null:(a=e.getFatPoint(r),a)}}class Th extends b{_id=0;_plane;_points=new Array;_edges=new Array;_neibourTriangles=new Zi;_pointAgainstEdge=new Zi;_edgeAgainstPoint=new Zi;_mask=0;_aabbBox;f=0;gg=0;h=0;parent;costMultiplier=1;openId=0;closeId=0;get aabb(){return this._aabbBox}initAABB(){this._aabbBox=new _t,this._aabbBox.addPoint(this._points[0]),this._aabbBox.addPoint(this._points[1]),this._aabbBox.addPoint(this._points[2])}calcGlobalQuadAABB(){}get isTriangle(){return!0}constructor(e,t,a,r){super(0,0,0,0),this._id=e,this._mask=br.WalkAble,this._edges.push(t,a,r);var i;for(i of this._edges)this._points.indexOf(i.pointA)==-1&&this._points.push(i.pointA),this._points.indexOf(i.pointB)==-1&&this._points.push(i.pointB);this.x=(this._points[0].x+this._points[1].x+this._points[2].x)/3,this.y=(this._points[0].y+this._points[1].y+this._points[2].y)/3,this.z=(this._points[0].z+this._points[1].z+this._points[2].z)/3,this._plane=new wh,this._plane.fromPoints(this._points[0],this._points[1],this._points[2]),this._plane.normalize(),this.genarateAgainstData(),this.initAABB()}genarateAgainstData(){var e,t;for(e of this._edges)for(t of this._points)e.pointA!=t&&e.pointB!=t&&(this._edgeAgainstPoint.put(e,t),this._pointAgainstEdge.put(t,e))}get id(){return this._id}get plane(){return this._plane}get points(){return this._points}addNeibour(e,t){if(this._edges.indexOf(e)>=0)this._neibourTriangles.put(e,t);else throw new Error("the edge is not in triangle!!!")}getNeibourTriangles(e=null,t=1,a=1){e=e||new Array,e.length=0;var r,i,n=this._neibourTriangles.getKeys(),o;for(o of n)i=o,i.testMask(t)&&(r=this._neibourTriangles.getValueByKey(i),r.testMask(a)&&e.push(r));return e}getEdges(e=null,t=1){e=e||new Array,e.length=0;var a;for(a of this._edges)a.testMask(t)&&e.push(a);return e}get walkAble(){return this.testMask(br.WalkAble)}get edges(){return this._edges}testMask(e){return(this._mask&e)==e}getEdgeAgainstPoint(e){return this._edgeAgainstPoint.getValueByKey(e)}getPointAgainstEdge(e){return this._pointAgainstEdge.getValueByKey(e)}getPublicEdge(e){if(e&&e!=this){var t=this._neibourTriangles.getKeys(),a;for(a of t)if(this._neibourTriangles.getValueByKey(a)==e)return a}return null}loopPublicEdge(e){var t,a;if(e&&e!=this){for(t of this._edges)for(a of e._edges)if(t==a)return t}return null}randomPoint(){var e=this._points[2].subtract(this._points[0]);e.scaleBy(Math.random()),e.incrementBy(this._points[0]);var t=this._points[1].subtract(e);return t.scaleBy(Math.random()),t.incrementBy(e),t}}class Fm{_nav3dPoints;_nav3dEdges;_nav3dTriangles;_path;_edgesDict;_nav3dAstar;_nav3dFunnel;_terrainQuad;_triangleList;get edges(){return this._nav3dEdges}get points(){return this._nav3dPoints}get path(){return this._path}get triangles(){return this._nav3dTriangles}constructor(e,t){this._nav3dPoints=new Array,this._nav3dEdges=new Array,this._nav3dTriangles=new Array,this._edgesDict=new Zi,this.initPoints(e),this.initEdgesAndTriangles(t),this.createConnections(),this._nav3dAstar=new Qh,this._nav3dFunnel=new ja,this._terrainQuad=new Jd(8,128),this._terrainQuad.createQuadTree(this._nav3dTriangles)}getTriangleAtPoint(e,t=5){return this._terrainQuad.getTriangleAtPoint(e,t)}findPath(e,t,a=5){this._path=null,this._triangleList=null;var r=this.getTriangleAtPoint(e,10),i=this.getTriangleAtPoint(t,10),n=this._nav3dAstar.findPath(this,r,i);return n?(this._triangleList=this._nav3dAstar.channel,n=this._nav3dFunnel.searchPath(e,t,this._triangleList,a),this._path=this._nav3dFunnel.path,n):!1}initPoints(e){for(var t,a,r=e.length,i=0;i<r;i++)t=e[i],a=new Bt(i,t.x,t.y,t.z),this._nav3dPoints.push(a)}initEdgesAndTriangles(e){for(var t,a,r,i,n,o=e.length,l=0;l<o;l++)t=e[l],a=this.tryCreateEdge(t[0],t[1]),r=this.tryCreateEdge(t[1],t[2]),i=this.tryCreateEdge(t[2],t[0]),!(a==null||r==null||i==null)&&(n=new Th(l,a,r,i),this._nav3dTriangles.push(n))}tryCreateEdge(e,t){if(e==t)throw new Error("edge point index error!!!");if(e>t){var a=e;e=t,t=a}var r=this._edgesDict.getValueByKey(e+"_"+t);return r==null&&(r=new ha(this._nav3dPoints[e],this._nav3dPoints[t]),this._nav3dEdges.push(r),this._edgesDict.put(e+"_"+t,r)),r}createConnections(){for(var e=this._nav3dTriangles.length,t=this._nav3dTriangles.length,a,r,i,n,o=0;o<e;o++){a=this._nav3dTriangles[o];for(i of a.edges)i.addTriangleOwners(a);for(var l=0;l<t;l++)r=this._nav3dTriangles[l],a!=r&&(n=a.loopPublicEdge(r),n&&(a.addNeibour(n,r),r.addNeibour(n,a)))}}}class Io{x;y;setTo(e,t){this.x=e,this.y=t}equals(e,t){return e==this.x&&t==this.y}equalPoint(e){return this.equals(e.x,e.y)}get length(){return Math.sqrt(this.x*this.x+this.y*this.y)}clone(){var e=new Io;return e.setTo(this.x,this.y),e}normalize(){var e=length;e!=0&&this.setTo(this.x/e,this.y/e)}}class va extends Fe{width;height;depth;constructor(e=1,t=1,a=1){super(),this.width=e,this.height=t,this.depth=a,this.initVertex()}initVertex(){let e=this.width/2,t=this.height/2,a=this.depth/2;this.bounds=new ge(b.ZERO.clone(),new b(this.width,this.height,this.depth));let r=new Float32Array([-e,t,a,e,t,a,e,t,-a,-e,t,-a,-e,t,a,e,t,-a,e,-t,a,-e,-t,a,-e,-t,-a,e,-t,-a,e,-t,a,-e,-t,-a,-e,-t,a,-e,t,a,-e,t,-a,-e,-t,-a,-e,-t,a,-e,t,-a,e,t,a,e,-t,a,e,-t,-a,e,t,-a,e,t,a,e,-t,-a,e,t,a,-e,t,a,-e,-t,a,-e,-t,a,e,-t,a,e,t,a,e,-t,-a,-e,-t,-a,-e,t,-a,e,t,-a,e,-t,-a,-e,t,-a]),i=new Float32Array([0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,-1]),n=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),o=[0,2,1,3,5,4,6,8,7,9,11,10,12,14,13,15,17,16,18,20,19,21,23,22,24,26,25,27,29,28,30,32,31,33,35,34],l=new Uint16Array(o.reverse());this.setIndices(l),this.setAttribute(V.position,r),this.setAttribute(V.normal,i),this.setAttribute(V.uv,n),this.setAttribute(V.TEXCOORD_1,n),this.addSubGeometry({indexStart:0,indexCount:o.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Mh extends Fe{radiusTop;radiusBottom;height;radialSegments;heightSegments;openEnded;thetaStart;thetaLength;constructor(e=1,t=1,a=1,r=8,i=8,n=!1,o=0,l=Math.PI*2){super(),this.radiusTop=e,this.radiusBottom=t,this.height=a,this.radialSegments=r,this.heightSegments=i,this.openEnded=n,this.thetaStart=o,this.thetaLength=l,this.instanceID=xt(),this.buildGeometry()}addGroup(e,t,a){this.addSubGeometry({indexStart:e,indexCount:t,vertexStart:e,vertexCount:0,firstStart:0,index:a,topology:0})}buildGeometry(){const e=this;this.radialSegments=Math.floor(this.radialSegments),this.heightSegments=Math.floor(this.heightSegments);const t=[],a=[],r=[],i=[];let n=0;const o=[],l=this.height/2;let c=0;p(),this.openEnded===!1&&(this.radiusTop>0&&m(!0),this.radiusBottom>0&&m(!1));let f=new Float32Array(t),h=new Float32Array(a),u=new Float32Array(r),g=new Uint16Array(i);this.setAttribute(V.position,f),this.setAttribute(V.normal,h),this.setAttribute(V.uv,u),this.setAttribute(V.TEXCOORD_1,u),this.setIndices(g);function p(){const D=new b,_=new b;let B=0;const v=(e.radiusBottom-e.radiusTop)/e.height;for(let C=0;C<=e.heightSegments;C++){const y=[],F=C/e.heightSegments,k=F*(e.radiusBottom-e.radiusTop)+e.radiusTop;for(let w=0;w<=e.radialSegments;w++){const x=w/e.radialSegments;let M=x*e.thetaLength+e.thetaStart;w==e.radialSegments&&Math.abs(e.thetaLength-e.thetaStart)==Math.PI*2&&(M=0);const N=Math.sin(M),Q=Math.cos(M);_.x=k*N,_.y=-F*e.height+l,_.z=k*Q,t.push(_.x,_.y,_.z),D.set(N,v,Q).normalize(),a.push(D.x,D.y,D.z),r.push(x,1-F),y.push(n++)}o.push(y)}for(let C=0;C<e.radialSegments;C++)for(let y=0;y<e.heightSegments;y++){const F=o[y][C],k=o[y+1][C],w=o[y+1][C+1],x=o[y][C+1];i.push(F,k,x),i.push(k,w,x),B+=6}e.addGroup(c,B,0),c+=B}function m(D){const _=n,B=new K,v=new b;let C=0;const y=D===!0?e.radiusTop:e.radiusBottom,F=D===!0?1:-1;for(let w=1;w<=e.radialSegments;w++)t.push(0,l*F,0),a.push(0,F,0),r.push(.5,.5),n++;const k=n;for(let w=0;w<=e.radialSegments;w++){const M=w/e.radialSegments*e.thetaLength+e.thetaStart,N=Math.cos(M),Q=Math.sin(M);v.x=y*Q,v.y=l*F,v.z=y*N,t.push(v.x,v.y,v.z),a.push(0,F,0),B.x=N*.5+.5,B.y=Q*.5*F+.5,r.push(B.x,B.y),n++}for(let w=0;w<e.radialSegments;w++){const x=_+w,M=k+w;D===!0?i.push(M,M+1,x):i.push(M+1,M,x),C+=3}e.addGroup(c,C,D===!0?1:2),c+=C}}}class Nh extends Fe{radius;tube;radialSegments;tubularSegments;constructor(e=.4,t=.1,a=32,r=32){super(),this.radius=e,this.tube=t,this.radialSegments=a,this.tubularSegments=r,this.initVertex()}initVertex(){const e=2*Math.PI,t=this.radius,a=this.tube,r=this.radialSegments,i=this.tubularSegments;this.bounds=new ge(b.ZERO.clone(),new b(t*2,a*2,t*2));var n=(r+1)*(i+1);let o=new Float32Array(n*3),l=new Float32Array(n*3),c=new Float32Array(n*2),f=new Uint16Array(r*i*2*3),h=0,u=0,g=0,p=0;for(let m=0;m<=r;m++)for(let D=0;D<=i;D++){const _=D/i,B=m/r,v=_*e,C=B*Math.PI*2;if(o[h++]=(t+a*Math.cos(C))*Math.sin(v),o[h++]=a*Math.sin(C),o[h++]=(t+a*Math.cos(C))*Math.cos(v),l[u++]=Math.sin(v)*Math.cos(C),l[u++]=Math.sin(C),l[u++]=Math.cos(v)*Math.cos(C),c[g++]=_,c[g++]=B,D<i&&m<r){const y=i+1,F=y*m+D,k=y*(m+1)+D,w=y*(m+1)+D+1,x=y*m+D+1;f[p++]=F,f[p++]=x,f[p++]=k,f[p++]=x,f[p++]=w,f[p++]=k}}this.setIndices(f),this.setAttribute(V.position,o),this.setAttribute(V.normal,l),this.setAttribute(V.uv,c),this.setAttribute(V.TEXCOORD_1,c),this.addSubGeometry({indexStart:0,indexCount:f.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class km extends Fe{segment;row=0;constructor(e){super(),this.segment=e,this.buildGeometry()}buildGeometry(){this.row=this.segment+1;let e=new Uint32Array(this.segment*6),t=new Float32Array(this.row*3*2),a=new Float32Array(this.row*3*2),r=new Float32Array(this.row*2*2);for(let i=0;i<this.row;i++){t[i*3*2+0]=0,t[i*3*2+1]=0,t[i*3*2+2]=0,t[i*3*2+3]=0,t[i*3*2+4]=0,t[i*3*2+5]=0,a[i*3*2+0]=0,a[i*3*2+1]=0,a[i*3*2+2]=1,a[i*3*2+3]=0,a[i*3*2+4]=0,a[i*3*2+5]=1,r[i*2*2+0]=0,r[i*2*2+1]=i/this.segment,r[i*2*2+2]=1,r[i*2*2+3]=i/this.segment;let n=i*2,o=n,l=n+1,c=n+2,f=n+3;e[i*6+0]=o,e[i*6+1]=l,e[i*6+2]=c,e[i*6+3]=l,e[i*6+4]=f,e[i*6+5]=c}this.setIndices(e),this.setAttribute(V.position,t),this.setAttribute(V.normal,a),this.setAttribute(V.uv,r),this.setAttribute(V.TEXCOORD_1,r),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Em extends Fe{faceCount=0;constructor(e){super(),this.faceCount=e,this.buildGeometry()}buildGeometry(){let e=new Uint32Array(this.faceCount*3),t=new Float32Array(this.faceCount*3*3),a=new Float32Array(this.faceCount*3*3),r=new Float32Array(this.faceCount*3*2),i=new Float32Array(this.faceCount*3*1);for(let n=0;n<this.faceCount;n++){let o=n*3+0,l=n*3+1,c=n*3+2;e[o]=o,e[l]=l,e[c]=c}this.setIndices(e),this.setAttribute(V.position,t),this.setAttribute(V.normal,a),this.setAttribute(V.uv,r),this.setAttribute(V.TEXCOORD_1,r),this.setAttribute(V.vIndex,i),this.addSubGeometry({indexStart:0,indexCount:e.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}class Rm extends Xe{create(e,t,a,r=!0){let i=E.device;const n=e*4*4;this.format=Y.rgba32float,this.createTextureDescriptor(e,t,1,this.format);const l=i.createBuffer({size:a.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(l,0,a);const c=S.beginCommandEncoder();c.copyBufferToTexture({buffer:l,bytesPerRow:n},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(c),r&&(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float"),this.gpuSampler=i.createSampler({})}fromBuffer(e,t,a){let r=E.device;const i=e*4*4;this.format=Y.rgba32float,this.mipmapCount=1,this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const n=S.beginCommandEncoder();return n.copyBufferToTexture({buffer:a,bytesPerRow:i},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),S.endCommandEncoder(n),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=r.createSampler({}),this}}class wm extends pn{_internalTexture;_minSize=32;_skyColor;constructor(e){super(),this._skyColor=e,this._internalTexture=new hs;let t=[];return A.res.fillColor(t,this._minSize,this._minSize,this.color.r,this.color.g,this.color.b,this.color.a),this._internalTexture.create(this._minSize,this._minSize,t,!1),this.createFromTexture(this._minSize,this._internalTexture),this}changeColor(e){return this._skyColor=e,A.res.fillColor(this._internalTexture.floatArray,this._minSize,this._minSize,this.color.r,this.color.g,this.color.b,this.color.a),this._internalTexture.updateTexture(this._minSize,this._minSize,this._internalTexture.floatArray,!1),this._faceData.uploadTexture(0,this._internalTexture),this}get color(){return this._skyColor}set color(e){this.changeColor(e)}}class Im extends d.Object3D{length=100;thickness=.1;constructor(e,t=.1){super(),this.length=e,this.thickness=t,this.init()}init(){let e=new d.Object3D,t=new d.Object3D,a=new d.Object3D,r=new va(2,2,2),i=new va(2,2,2),n=new va(2,2,2),o=new st;o.baseColor=new O(1,0,0);let l=new st;l.baseColor=new O(0,1,0);let c=new st;c.baseColor=new O(0,0,1);let f=e.addComponent(d.MeshRenderer),h=t.addComponent(d.MeshRenderer),u=a.addComponent(d.MeshRenderer);f.geometry=r,f.material=o,f.castShadow=!1,h.geometry=i,h.material=l,h.castShadow=!1,u.geometry=n,u.material=c,u.castShadow=!1,e.localScale=new b(this.length,this.thickness,this.thickness),e.x=this.length,t.localScale=new b(this.thickness,this.length,this.thickness),t.y=this.length,a.localScale=new b(this.thickness,this.thickness,this.length),a.z=this.length,this.addChild(e),this.addChild(t),this.addChild(a)}}class Qm{static merge(e,t,a){}static mergeNumber(e,t,a){let r=a||new Fe,i=e.getAttribute(V.position).data.length/3,n=new Float32Array(i*t);for(const f of e.vertexAttributeMap){let h=f[1].attribute;if(h==V.indices)continue;let u=e.getAttribute(h).data,g=u.length,p=new Float32Array(g*t);for(let m=0;m<t;m++){p.set(u,g*m);for(let D=0;D<i;D++)n[i*m+D]=m}r.setAttribute(h,p)}r.setAttribute(V.vIndex,n);let o=e.getAttribute(V.indices).data,l=o.length,c=new Uint32Array(o.length*t);for(let f=0;f<t;f++)for(let h=0;h<l;h++){let u=f*i,g=f*l;const p=o[h]+u;c[g+h]=p}return r.setIndices(c),r.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,index:0,vertexCount:0,firstStart:0,topology:0}),r}static generateNormal(){}static generateTangent(){}static packUV(){}}class Tm extends d.Object3D{size=100;divisions=10;constructor(e=100,t=10){super(),this.size=e,this.divisions=t,this.buildGeometry(),this.addAxis()}buildGeometry(){const e=[],t=[],a=this.size/this.divisions,r=this.size/2,i=this.divisions/2;for(let c=0,f=-r;c<=this.divisions;c++,f+=a)c!==i&&(e.push(-r,0,f,r,0,f),e.push(f,0,-r,f,0,r));for(let c=0;c<e.length/3;c+=2)t.push(c,c+1);let n=new Fe;n.setIndices(t.length>Uint16Array.length?new Uint32Array(t):new Uint16Array(t)),n.setAttribute(V.position,new Float32Array(e)),n.addSubGeometry({indexStart:0,indexCount:t.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});let o=new st;o.topology="line-list",o.baseColor=new O(1,1,1,.15),o.blendMode=te.ADD,o.castReflection=!1;let l=this.addComponent(d.MeshRenderer);l.geometry=n,l.material=o}addAxis(){const e=this.size/2;let t=new Float32Array([-e,0,0,e,0,0]),a=new Uint16Array([0,1,2,3]),r=new Fe;r.setIndices(a),r.setAttribute(V.position,t),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});{let i=new d.Object3D,n=i.addComponent(d.MeshRenderer);n.geometry=r;let o=n.material=new st;o.baseColor=new O(1,0,0,.5),o.blendMode=te.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}{let i=new d.Object3D;i.rotationY=90;let n=i.addComponent(d.MeshRenderer);n.geometry=r;let o=n.material=new st;o.baseColor=new O(0,1,0,.5),o.blendMode=te.ADD,o.castReflection=!1,o.topology="line-list",this.addChild(i)}}}class Mm{static color_temperature_to_rgb(e){e<1e3?e=1e3:e>4e4&&(e=4e4);let t=e/100,a=this.get_red(t),r=this.get_green(t),i=this.get_blue(t);return new O(a/255,r/255,i/255,1)}static get_red(e){if(e<=66)return 255;let t=329.698727446*Math.pow(e-60,-.1332047592);return this.bound(t)}static get_green(e){let t=0;return e<=66?t=99.4708025861*Math.log(e)-161.1195681661:t=288.1221695283*Math.pow(e-60,-.0755148492),this.bound(t)}static get_blue(e){let t=0;return e>=66?255:e<=19?0:(t=138.5177312231*Math.log(e-10)-305.0447927307,this.bound(t))}static bound(e,t=0,a=255){let r=Math.max(e,t);return Math.min(r,a)}}class Nm{static boxGeo;static planeGeo;static sphere;static material;static materialMap;static initHeap(){this.boxGeo||(this.boxGeo=new va),this.planeGeo||(this.planeGeo=new Hr(1,1,1,1,b.UP)),this.sphere||(this.sphere=new Cr(1,35,35)),this.material||(this.material=new pa),this.materialMap||(this.materialMap=new Map)}static get CubeMesh(){return this.initHeap(),this.boxGeo}static get SphereMesh(){return this.initHeap(),this.sphere}static GetCube(){this.initHeap();let e=new d.Object3D,t=e.addComponent(d.MeshRenderer);return t.geometry=this.boxGeo,t.material=this.material.clone(),t.castShadow=!0,e}static GetMaterial(e){let t=this.materialMap.get(e);return t||(t=new pa,t.baseMap=e,this.materialMap.set(e,t)),t.clone()}static GetPlane(e){this.initHeap();let t=new d.Object3D,a=t.addComponent(d.MeshRenderer);a.geometry=this.planeGeo;let r=this.GetMaterial(e);return r.blendMode=te.ADD,r.castShadow=!1,a.material=r,a.castGI=!1,a.castReflection=!1,t}static GetSingleCube(e,t,a,r,i,n){this.initHeap();let o=new pa;o.roughness=.5,o.metallic=.1,o.baseColor=new O(r,i,n,1);let l=new d.Object3D,c=l.addComponent(d.MeshRenderer);return c.castGI=!0,c.geometry=new va(e,t,a),c.material=o,l}static GetSingleSphere(e,t,a,r){this.initHeap();let i=new pa;i.baseColor=new O(t,a,r,1);let n=new d.Object3D,o=n.addComponent(d.MeshRenderer);return o.castGI=!0,o.geometry=new Cr(e,20,20),o.material=i,n}static get Sphere(){this.initHeap();let e=new d.Object3D,t=e.addComponent(d.MeshRenderer);return t.geometry=this.sphere,t.material=this.material,e}static GetSingleCube2(e,t=10){this.initHeap();let a=new d.Object3D,r=a.addComponent(d.MeshRenderer);return r.castShadow=!1,r.geometry=new va(t,t,t),r.material=e,a}static GetPointLight(e,t,a,r,i,n,o=1,l=!0){let c=new d.Object3D,f=c.addComponent(d.PointLight);f.lightColor=new O(r,i,n,1),f.intensity=o,f.range=a,f.at=8,f.radius=0,f.castShadow=l,c.localPosition=e,c.localRotation=t;let h=this.GetSingleSphere(.1,1,1,1);return c.addChild(h),f}}var I=(s=>(s[s.X=0]="X",s[s.Y=1]="Y",s[s.Z=2]="Z",s[s.XY=3]="XY",s[s.XZ=4]="XZ",s[s.YZ=5]="YZ",s[s.XYZ=6]="XYZ",s[s.MAX=7]="MAX",s[s.NONE=8]="NONE",s))(I||{}),qt=(s=>(s[s.Local=0]="Local",s[s.Global=1]="Global",s))(qt||{});class Mn extends Pe{mAxis;mAxisColor;mContainer;mAxisMaterial;mAxisCollider;constructor(){super(),this._enable=!1,this.mAxis=new Array(I.MAX),this.mAxisColor=new Array(I.MAX),this.mAxisMaterial=new Array(I.MAX),this.mAxisCollider=new Array(I.MAX)}get target(){return this.object3D.target}get mX(){return this.object3D.mXObj}get mY(){return this.object3D.mYObj}get mZ(){return this.object3D.mZObj}get transformSpaceMode(){return this.object3D.transformSpaceMode}init(e){this.mContainer=new d.Object3D;let t=new st;t.baseColor=new O(1,0,0),t.depthCompare=$e.always,this.mAxisColor[I.X]=t.baseColor,this.mAxisMaterial[I.X]=t;let a=new st;a.baseColor=new O(0,1,0),a.depthCompare=$e.always,this.mAxisColor[I.Y]=a.baseColor,this.mAxisMaterial[I.Y]=a;let r=new st;r.baseColor=new O(0,0,1),r.depthCompare=$e.always,this.mAxisColor[I.Z]=r.baseColor,this.mAxisMaterial[I.Z]=r;let i=this.createCustomAxis(I.X),n=this.createCustomAxis(I.Y),o=this.createCustomAxis(I.Z);this.mContainer.addChild(this.mAxis[I.X]=i),this.mContainer.addChild(this.mAxis[I.Y]=n),this.mContainer.addChild(this.mAxis[I.Z]=o),this.mAxisCollider[I.X]=i.getComponent(Kt),this.mAxisCollider[I.Y]=n.getComponent(Kt),this.mAxisCollider[I.Z]=o.getComponent(Kt)}start(){}onEnable(e){this.object3D.addChild(this.mContainer),this.reset()}onDisable(e){this.object3D.removeChild(this.mContainer)}reset(){switch(this.transformSpaceMode){case qt.Local:{let t=R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix).decompose();this.object3D.scaleX=1,this.object3D.scaleY=1,this.object3D.scaleZ=1,this.object3D.rotationX=t[1].x,this.object3D.rotationY=t[1].y,this.object3D.rotationZ=t[1].z,this.object3D.x=t[0].x,this.object3D.y=t[0].y,this.object3D.z=t[0].z}break;case qt.Global:{this.object3D.scaleX=1,this.object3D.scaleY=1,this.object3D.scaleZ=1,this.object3D.rotationX=0,this.object3D.rotationY=0,this.object3D.rotationZ=0;const e=this.mX.transform.worldPosition;this.object3D.x=e.x,this.object3D.y=e.y,this.object3D.z=e.z}break}}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(A.inputSystem.mouseX,A.inputSystem.mouseY),r,i;for(let n=0;n<=I.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r&&(!i||i.distance>r.distance||n==I.XYZ)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint},n==I.XYZ)))break}return i}currentAxis=I.NONE;beginPoint=new b;beginMousePos=new b;currentPoint=new b;onMouseDown(e){if(e.mouseCode!=Cn.MOUSE_LEFT)return;let t=this.pickAxis();if(!t)return;this.currentAxis=t.axis,e.stopImmediatePropagation();const r=this.object3D.transform.scene3D.view.camera;let i=r.worldToScreenPoint(this.mX.transform.worldPosition),n=r.screenPointToWorld(A.inputSystem.mouseX,A.inputSystem.mouseY,i.z);this.beginPoint.copyFrom(n),this.beginMousePos.x=A.inputSystem.mouseX,this.beginMousePos.y=A.inputSystem.mouseY}lastMoveObj;lastMoveAxis;onMouseMove(e){if(this.currentAxis==I.NONE){let t=this.lastMoveObj.getComponent(d.MeshRenderer).material;this.lastMoveObj&&"baseColor"in t&&(t.baseColor=this.mAxisColor[this.lastMoveAxis],this.lastMoveObj=null,this.lastMoveAxis==I.XYZ&&(this.mAxis[I.X].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[I.X]),this.mAxis[I.Y].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[I.Y]),this.mAxis[I.Z].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",this.mAxisColor[I.Z])),this.lastMoveAxis=I.NONE);let a=this.pickAxis();if(!a)return;t.setUniformColor("baseColor",new O(1,1,1)),this.lastMoveObj=a.obj,this.lastMoveAxis=a.axis,this.lastMoveAxis==I.XYZ&&(this.mAxis[I.X].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new O(1,1,1)),this.mAxis[I.Y].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new O(1,1,1)),this.mAxis[I.Z].getComponent(d.MeshRenderer).material.setUniformColor("baseColor",new O(1,1,1)))}else{const a=this.object3D.transform.scene3D.view.camera;let r=a.worldToScreenPoint(this.mX.transform.worldPosition),i=a.screenPointToWorld(A.inputSystem.mouseX,A.inputSystem.mouseY,r.z);this.currentPoint.copyFrom(i);let n=i.subtract(this.beginPoint);b.HELP_0.set(A.inputSystem.mouseX,A.inputSystem.mouseY,0);let o=b.distance(b.HELP_0,this.beginMousePos);switch(this.beginMousePos.copyFrom(b.HELP_0),this.transformSpaceMode){case qt.Local:this.applyLocalTransform(this.currentAxis,n,o);break;case qt.Global:this.applyGlobalTransform(this.currentAxis,n,o);break}this.beginPoint.copyFrom(i),this.reset()}}onMouseUp(e){e.mouseCode==Cn.MOUSE_LEFT&&(this.currentAxis=I.NONE,this.reset())}onUpdate(e){let a=b.distance(e.camera.transform.worldPosition,this.object3D.transform.worldPosition)/100;if(this.mContainer.scaleX=this.mContainer.scaleY=this.mContainer.scaleZ=a,this.mX){const r=this.mX.transform.worldPosition;this.object3D.x=r.x,this.object3D.y=r.y,this.object3D.z=r.z}}applyLocalTransform(e,t,a){console.warn("not imp")}applyGlobalTransform(e,t,a){console.warn("not imp")}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=0,a=0,r=0;switch(e){case I.X:t=1;break;case I.Y:a=1;break;case I.Z:r=1;break}let i=.4+t*20,n=.4+a*20,o=.4+r*20,l=new d.Object3D;l.x=i*.5,l.y=n*.5,l.z=o*.5;let c=l.addComponent(d.MeshRenderer);c.geometry=new va(i,n,o),c.material=this.mAxisMaterial[e];let f=l.addComponent(Kt),h=new ri;return h.setFromCenterAndSize(new b(0,0,0),new b(i+1,n+1,o+1)),f.shape=h,l}}class Ph extends Mn{init(e){super.init(e);let t=new st;t.doubleSide=!0,t.baseColor=new O(.9,.9,.9),t.depthCompare=$e.always,this.mAxisColor[I.XYZ]=t.baseColor,this.mAxisMaterial[I.XYZ]=t;let a=new d.Object3D,r=a.addComponent(d.MeshRenderer);r.geometry=new va(2,2,2),r.material=this.mAxisMaterial[I.XYZ];let i=a.addComponent(Kt),n=new ri;n.setFromCenterAndSize(new b(0,0,0),new b(2,2,2)),i.shape=n,this.mContainer.addChild(this.mAxis[I.XYZ]=a),this.mAxisCollider[I.XYZ]=a.getComponent(Kt)}applyLocalTransform(e,t,a){switch(this.currentAxis){case I.XYZ:{let r=0;Math.abs(t.x)>Math.abs(t.y)?Math.abs(t.x)>Math.abs(t.z)?r=t.x:r=t.z:r=t.y,this.mX.scaleX+=r,this.mX.scaleY+=r,this.mX.scaleZ+=r}break;default:this.mX.transform.worldMatrix.transformVector(t,t),(this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ)&&(this.mX.scaleX=Math.abs(this.mX.scaleX+t.x)),(this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ)&&(this.mX.scaleY=Math.abs(this.mX.scaleY+t.y)),(this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ)&&(this.mX.scaleZ=Math.abs(this.mX.scaleZ+t.z));break}}applyGlobalTransform(e,t,a){let r=b.HELP_0;r.set(0,0,0),(this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ)&&(r.x=t.x),(this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ)&&(r.y=t.y),(this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ)&&(r.z=t.z),this.mX.transform.worldMatrix.transformVector(r,b.HELP_1),this.mX.scaleX+=b.HELP_1.x,this.mX.scaleY+=b.HELP_1.y,this.mX.scaleZ+=b.HELP_1.z}createCustomAxis(e){let t=super.createAxis(e),a=this.createBox(e);return t.addChild(a),t}createBox(e){let t=0,a=0,r=0,i=new d.Object3D;switch(e){case I.X:t=1,i.rotationZ=-90;break;case I.Y:a=1;break;case I.Z:r=1,i.rotationX=90;break}let n=.2+t*20,o=.2+a*20,l=.2+r*20;i.x=n*.5,i.y=o*.5,i.z=l*.5;let c=i.addComponent(d.MeshRenderer);return c.geometry=new va(2,2,2),c.material=this.mAxisMaterial[e],i}}var tt=(s=>(s[s.Scale=0]="Scale",s[s.Rotation=1]="Rotation",s[s.Translation=2]="Translation",s[s.NONE=3]="NONE",s))(tt||{});class Vh extends Mn{applyLocalTransform(e,t,a){if(this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ,this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ){R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.identity(),R.help_matrix_1.createByRotation(1,b.Y_AXIS),R.help_matrix_2.multiplyMatrices(R.help_matrix_1,R.help_matrix_0),R.help_matrix_2.invert(),R.help_matrix_1.multiplyMatrices(R.help_matrix_2,R.help_matrix_0);let r=R.help_matrix_1.decompose();this.mX.rotationX+=r[1].x,this.mY.rotationY+=r[1].y,this.mZ.rotationZ+=r[1].z}this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ}getAngle(){const t=this.object3D.transform.scene3D.view.camera,a=this.mZ.transform.worldPosition;if(t.screenPointToRay(A.inputSystem.mouseX,A.inputSystem.mouseY),this.currentAxis==I.X){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(A.inputSystem.mouseX,A.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.x-a.x>0&&(n=360-n),n}if(this.currentAxis==I.Y){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(A.inputSystem.mouseX,A.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.y-a.y>0&&(n=360-n),n}if(this.currentAxis==I.Z){let r=t.worldToScreenPoint(a);b.HELP_1.set(r.x,r.y,0),b.HELP_2.set(A.inputSystem.mouseX,A.inputSystem.mouseY,0);let i=b.HELP_2.subtract(b.HELP_1),n=b.getAngle(b.X_AXIS,i);return i.y>0&&(n=360-n),t.transform.worldPosition.z-a.z>0&&(n=360-n),n}return 0}mLastAngle=0;applyGlobalTransform(e,t,a){if(this.currentAxis==I.X||this.currentAxis==I.Y||this.currentAxis==I.Z){let r=this.getAngle();switch(R.help_matrix_0.identity(),this.currentAxis){case I.X:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.X_AXIS);break;case I.Y:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Y_AXIS);break;case I.Z:R.help_matrix_0.createByRotation(this.mLastAngle-r,b.Z_AXIS);break}R.help_matrix_1.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.append(R.help_matrix_0),this.mX.parent&&(R.help_matrix_2.copyFrom(this.mX.parent.worldMatrix),R.help_matrix_2.invert(),R.help_matrix_1.multiply(R.help_matrix_2));let n=R.help_matrix_1.decompose(Wt.QUATERNION)[1];Z.HELP_0.set(n.x,n.y,n.z,n.w),this.mLastAngle=r,this.mX.transform.localRotQuat=Z.HELP_0}}onMouseDown(e){super.onMouseDown(e),this.currentAxis!=I.NONE&&(this.mAxis[I.X].getComponent(d.MeshRenderer).enable=!1,this.mAxis[I.Y].getComponent(d.MeshRenderer).enable=!1,this.mAxis[I.Z].getComponent(d.MeshRenderer).enable=!1,this.mAxis[this.currentAxis].getComponent(d.MeshRenderer).enable=!0,this.mLastAngle=this.getAngle())}onMouseUp(e){super.onMouseUp(e),this.currentAxis==I.NONE&&(this.mAxis[I.X].getComponent(d.MeshRenderer).enable=!0,this.mAxis[I.Y].getComponent(d.MeshRenderer).enable=!0,this.mAxis[I.Z].getComponent(d.MeshRenderer).enable=!0)}createCustomAxis(e){return this.createAxis(e)}createAxis(e){let t=new d.Object3D;switch(e){case I.X:t.rotationZ=90;break;case I.Y:break;case I.Z:t.rotationX=90;break}let a=t.addComponent(d.MeshRenderer);a.geometry=new Nh(20,.4),a.material=this.mAxisMaterial[e];let r=t.addComponent(Kt),i=new ri;return i.setFromCenterAndSize(new b,new b(40,.4,40)),r.shape=i,t}pickAxis(){let a=this.object3D.transform.scene3D.view.camera.screenPointToRay(A.inputSystem.mouseX,A.inputSystem.mouseY),r,i;for(let n=0;n<=I.MAX;n++){let o=this.mAxisCollider[n];if(o&&(r=o.rayPick(a),r)){let l=b.distance(r.intersectPoint,o.shape.center);if(l>20+.8||l<20-.8)continue;(!i||i.distance>r.distance)&&(i={axis:n,obj:o.object3D,distance:r.distance,intersectPoint:r.intersectPoint})}}return i}}class Oh extends Mn{init(e){super.init(e);let t=new st;t.doubleSide=!0,t.baseColor=new O(0,0,1),t.depthCompare=$e.always,this.mAxisColor[I.XY]=t.baseColor,this.mAxisMaterial[I.XY]=t;let a=new st;a.doubleSide=!0,a.baseColor=new O(0,1,0),a.depthCompare=$e.always,this.mAxisColor[I.XZ]=a.baseColor,this.mAxisMaterial[I.XZ]=a;let r=new st;r.doubleSide=!0,r.baseColor=new O(1,0,0),r.depthCompare=$e.always,this.mAxisColor[I.YZ]=r.baseColor,this.mAxisMaterial[I.YZ]=r;let i=this.createPlane(I.XY),n=this.createPlane(I.XZ),o=this.createPlane(I.YZ);this.mContainer.addChild(this.mAxis[I.XY]=i),this.mContainer.addChild(this.mAxis[I.XZ]=n),this.mContainer.addChild(this.mAxis[I.YZ]=o),this.mAxisCollider[I.XY]=i.getComponent(Kt),this.mAxisCollider[I.XZ]=n.getComponent(Kt),this.mAxisCollider[I.YZ]=o.getComponent(Kt)}applyLocalTransform(e,t,a){R.help_matrix_0.copyFrom(this.mX.transform.worldMatrix).invert(),R.help_matrix_0.transformVector(t,b.HELP_0),this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ||(b.HELP_0.x=0),this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ||(b.HELP_0.y=0),this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ||(b.HELP_0.z=0),this.mX.transform.worldMatrix.transformVector(b.HELP_0,b.HELP_1),this.mX.x+=b.HELP_1.x,this.mX.y+=b.HELP_1.y,this.mX.z+=b.HELP_1.z}applyGlobalTransform(e,t,a){R.help_matrix_0.identity(),(this.currentAxis==I.X||this.currentAxis==I.XY||this.currentAxis==I.XZ)&&R.help_matrix_0.appendTranslation(t.x,0,0),(this.currentAxis==I.Y||this.currentAxis==I.XY||this.currentAxis==I.YZ)&&R.help_matrix_0.appendTranslation(0,t.y,0),(this.currentAxis==I.Z||this.currentAxis==I.XZ||this.currentAxis==I.YZ)&&R.help_matrix_0.appendTranslation(0,0,t.z),R.help_matrix_1.copyFrom(this.mX.transform.worldMatrix),R.help_matrix_1.append(R.help_matrix_0),this.mX.parent&&(R.help_matrix_2.copyFrom(this.mX.parent.worldMatrix),R.help_matrix_2.invert(),R.help_matrix_1.multiply(R.help_matrix_2));let r=R.help_matrix_1.decompose(Wt.QUATERNION);this.mX.transform.localPosition=r[0],console.log(this.target.localPosition)}createCustomAxis(e){let t=super.createAxis(e),a=this.createArrows(e);return t.addChild(a),t}createArrows(e){let t=0,a=0,r=0,i=new d.Object3D;switch(e){case I.X:t=1,i.rotationZ=-90;break;case I.Y:a=1,i.rotationY=-90;break;case I.Z:r=1,i.rotationX=90;break}let n=.2+t*20,o=.2+a*20,l=.2+r*20;i.x=n*.5,i.y=o*.5,i.z=l*.5;let c=i.addComponent(d.MeshRenderer);return c.geometry=new Mh(0,1,4),c.material=this.mAxisMaterial[e],i}createPlane(e){let t=new d.Object3D,a=t.addComponent(d.MeshRenderer);a.material=this.mAxisMaterial[e];let r=t.addComponent(Kt),i=new ri;switch(r.shape=i,e){case I.XY:a.geometry=new Hr(4,4,1,1,b.Z_AXIS),t.x=8,t.y=8,i.setFromCenterAndSize(new b(0,0,0),new b(4,4,.1));break;case I.XZ:a.geometry=new Hr(4,4,1,1,b.Y_AXIS),t.x=8,t.z=8,i.setFromCenterAndSize(new b(0,0,0),new b(4,.1,4));break;case I.YZ:a.geometry=new Hr(4,4,1,1,b.X_AXIS),t.y=8,t.z=8,i.setFromCenterAndSize(new b(0,0,0),new b(.1,4,4));break}return t}}class Qo extends d.Object3D{static _instance;static get instance(){return this._instance||(this._instance=new Qo),this._instance}mTarget;mTransformMode=tt.NONE;mTransformSpaceType=qt.Global;mControllers;mXObj;mYObj;mZObj;constructor(){super(),this.mControllers=[null,null,null],this.mControllers[tt.Scale]=this.addComponent(Ph),this.mControllers[tt.Rotation]=this.addComponent(Vh),this.mControllers[tt.Translation]=this.addComponent(Oh),this.mControllers[tt.Scale].enable=!1,this.mControllers[tt.Rotation].enable=!1,this.mControllers[tt.Translation].enable=!1,this.mXObj=new d.Object3D,this.mYObj=new d.Object3D,this.mZObj=new d.Object3D,this.mXObj.addChild(this.mYObj),this.mYObj.addChild(this.mZObj)}get transformMode(){return this.mTransformMode}get transformSpaceMode(){return this.mTransformSpaceType}active(e){e.addChild(this),e.addChild(this.mXObj)}unActive(e){e.removeChild(this)}get target(){return this.mTarget}selectObject(e,t,a){this.mTarget!=e&&(e?this.activate():this.unactivate(),this.mTarget=e,this.mXObj.localPosition=e.transform.worldPosition.clone()),t!=null&&this.selectTransformMode(t),a!=null&&this.selectTransformSpaceMode(a)}selectTransformMode(e){this.mTransformMode!=e&&(this.mTransformMode!=tt.NONE&&(this.mControllers[this.mTransformMode].enable=!1),this.mTransformMode=e,this.mTransformMode!=tt.NONE&&(this.mControllers[this.mTransformMode].enable=!0))}selectTransformSpaceMode(e){this.mTransformSpaceType!=e&&(this.mTransformSpaceType=e,this.mTransformMode!=tt.NONE&&this.mControllers[this.mTransformMode].reset())}activate(){A.inputSystem.addEventListener(ba.KEY_DOWN,this.onKeyDown,this),A.inputSystem.addEventListener(L.POINTER_DOWN,this.onMouseDown,this,null,99999),A.inputSystem.addEventListener(L.POINTER_MOVE,this.onMouseMove,this,null,99999),A.inputSystem.addEventListener(L.POINTER_UP,this.onMouseUp,this,null,99999)}unactivate(){A.inputSystem.removeEventListener(ba.KEY_DOWN,this.onKeyDown,this),A.inputSystem.removeEventListener(L.POINTER_DOWN,this.onMouseDown,this),A.inputSystem.removeEventListener(L.POINTER_MOVE,this.onMouseMove,this),A.inputSystem.removeEventListener(L.POINTER_UP,this.onMouseUp,this)}onKeyDown(e){switch(e.keyCode){case Oe.Key_R:this.selectTransformMode(tt.Scale),this.selectTransformSpaceMode(qt.Local);break;case Oe.Key_E:this.selectTransformMode(tt.Rotation),this.selectTransformSpaceMode(qt.Global);break;case Oe.Key_W:this.selectTransformMode(tt.Translation),this.selectTransformSpaceMode(qt.Global);break;case Oe.Key_A:this.selectTransformSpaceMode(qt.Local);break;case Oe.Key_S:this.selectTransformSpaceMode(qt.Global);break}}onMouseDown(e){this.mTransformMode!=tt.NONE&&this.mControllers[this.mTransformMode].onMouseDown(e)}onMouseMove(e){this.mTransformMode!=tt.NONE&&this.mControllers[this.mTransformMode].onMouseMove(e)}onMouseUp(e){this.mTransformMode!=tt.NONE&&this.mControllers[this.mTransformMode].onMouseUp(e)}}const Pm=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));d.AccelerateDecelerateInterpolator=v0,d.AccelerateInterpolator=B0,d.AnimationCurve=Ri,d.AnimationCurveT=ur,d.AnimationMonitor=Fr,d.AnimatorEventKeyframe=_b,d.AnticipateInterpolator=S0,d.AnticipateOvershootInterpolator=Bi,d.ArrayHas=Zh,d.ArrayItemIndex=Yh,d.AtlasParser=mf,d.AtmosphericComponent=hb,d.AtmosphericScatteringSky=sd,d.AtmosphericScatteringSkySetting=nd,d.AtmosphericScatteringSky_shader=id,d.AttributeAnimCurve=bd,d.AxisObject=Im,d.B3DMLoader=Ga,d.B3DMLoaderBase=tf,d.B3DMParseUtil=Ws,d.B3DMParser=zs,d.BRDFLUT=cf,d.BRDFLUTGenerate=ff,d.BRDF_frag=ul,d.BatchTable=Ls,d.BiMap=cm,d.BillboardComponent=Ei,d.BillboardType=sr,d.BitUtil=Ol,d.BitmapTexture2D=La,d.BitmapTexture2DArray=sc,d.BitmapTextureCube=Ts,d.Blend=ic,d.BlendFactor=nc,d.BlendMode=te,d.BlendShapeData=Ao,d.BlendShapePropertyData=po,d.BloomPost=gg,d.BlurEffectCreatorBlur_cs=j0,d.BlurEffectCreatorSample_cs=W0,d.BlurTexture2DBufferCreator=Z0,d.BounceInterpolator=Vt,d.BoundUtil=us,d.BoundingBox=ge,d.BoundingSphere=Sr,d.BoundingVolume=Rr,d.BoxColliderShape=ri,d.BoxGeometry=va,d.BrdfLut_frag=rl,d.BsDF_frag=gl,d.BxDF_frag=bl,d.BxdfDebug_frag=Dl,d.BytesArray=kn,d.CEvent=qe,d.CEventDispatcher=Ia,d.CEventListener=Hi,d.CResizeEvent=Ya,d.CSM=Jt,d.Camera3D=Zr,d.CameraControllerBase=kb,d.CameraType=ze,d.CameraUtil=He,d.CapsuleColliderShape=Zb,d.CastPointShadowMaterialPass=_c,d.CastShadowMaterialPass=Dc,d.Clearcoat_frag=ml,d.ClusterBoundsSource_cs=Hc,d.ClusterConfig=pt,d.ClusterDebug_frag=Wo,d.ClusterLight=xl,d.ClusterLightingBuffer=Xc,d.ClusterLightingRender=qc,d.ClusterLighting_cs=Kc,d.CollectInfo=yc,d.ColliderComponent=Kt,d.ColliderShape=Ke,d.ColliderShapeType=ai,d.Color=O,d.ColorGradient=fm,d.ColorLitMaterial=im,d.ColorLitShader=ed,d.ColorPassFragmentOutput=rb,d.ColorPassRenderer=Yc,d.ColorUtil=qi,d.ComData=En,d.Combine_cs=Zf,d.Common_frag=tl,d.Common_vert=al,d.ComponentBase=Pe,d.ComponentCollect=ye,d.ComputeGPUBuffer=Kr,d.ComputeShader=fe,d.Context3D=Po,d.CubeCamera=Ds,d.CubeMapFaceEnum=Y0,d.CubeSky_Shader=Jn,d.CubicBezierCurve=In,d.CubicBezierPath=dm,d.CubicBezierType=yh,d.CycleInterpolator=x0,d.CylinderGeometry=Mh,d.DDGIIrradianceComputePass=u0,d.DDGIIrradianceGPUBufferReader=Gi,d.DDGIIrradianceVolume=Oc,d.DDGIIrradiance_shader=h0,d.DDGILightingPass=p0,d.DDGILighting_shader=m0,d.DDGIMultiBouncePass=g0,d.DDGIProbeRenderer=A0,d.DEGREES_TO_RADIANS=at,d.DRACO_DECODER_GLTF_JS=E0,d.DecelerateInterpolator=U0,d.Denoising_cs=Yf,d.Depth2DTextureArray=a0,d.DepthCubeArrayTexture=e0,d.DepthMaterialPass=Bc,d.DepthOfFieldPost=mg,d.DepthOfView_cs=Rf,d.DoubleArray=Zi,d.EditorInspector=zr,d.Engine3D=A,d.Entity=Vc,d.EntityBatchCollect=Cc,d.EntityCollect=W,d.EnvMap_frag=il,d.ErpImage2CubeMap=wt,d.ErpImage2CubeMapCreateCube_cs=X0,d.ErpImage2CubeMapRgbe2rgba_cs=H0,d.ExtrudeGeometry=qb,d.FAILED=fr,d.FASTFLOOR=fa,d.FXAAPost=_s,d.FXAAShader=c0,d.FastMathShader=sl,d.FatLineGeometry=$b,d.FatLineMaterial=nm,d.FatLine_FS=jl,d.FatLine_VS=Wl,d.FeatureTable=mn,d.FileLoader=At,d.FirstPersonCameraController=Eb,d.Float16ArrayTexture=hs,d.Float32ArrayTexture=Rm,d.FlyCameraController=Rb,d.FontChar=uf,d.FontInfo=df,d.FontPage=hf,d.FontParser=za,d.ForwardRenderJob=_0,d.FragmentOutput=Zn,d.FragmentVarying=ll,d.FrameCache=ao,d.Frustum=rs,d.FrustumCSM=rc,d.FrustumCulling_cs=ab,d.FullQuad_vert_wgsl=_l,d.GBufferFrame=oe,d.GBufferPass=Ac,d.GBufferPost=pg,d.GBufferStand=Ll,d.GBuffer_pass=Yn,d.GILighting=Is,d.GIProbeMaterial=Nd,d.GIProbeMaterialType=uo,d.GIProbeShader=td,d.GIRenderCompleteEvent=Bs,d.GIRenderStartEvent=cn,d.GLBChunk=G0,d.GLBHeader=L0,d.GLBParser=Qs,d.GLSLLexer=oc,d.GLSLLexerToken=bi,d.GLSLPreprocessor=lc,d.GLSLSyntax=hc,d.GLTFBinaryExtension=nf,d.GLTFMaterial=Eg,d.GLTFParser=Dt,d.GLTFSubParser=hn,d.GLTFSubParserCamera=R0,d.GLTFSubParserConverter=O0,d.GLTFSubParserMaterial=I0,d.GLTFSubParserMesh=w0,d.GLTFSubParserSkeleton=ws,d.GLTFSubParserSkin=Q0,d.GLTFType=Zt,d.GLTF_Accessors=o2,d.GLTF_Info=fn,d.GLTF_Light=r2,d.GLTF_Mesh=s2,d.GLTF_Node=i2,d.GLTF_Primitives=n2,d.GLTF_Scene=a2,d.GPUAddressMode=Pt,d.GPUBlendFactor=Xh,d.GPUBufferBase=Ta,d.GPUBufferType=ea,d.GPUCompareFunction=$e,d.GPUContext=S,d.GPUCullMode=Ft,d.GPUFilterMode=qa,d.GPUPrimitiveTopology=zn,d.GPUTextureFormat=Y,d.GPUVertexFormat=di,d.GPUVertexStepMode=qh,d.GSplatFormat=oi,d.GSplatGeometry=Tc,d.GSplatMaterial=Ec,d.GSplat_FS=kc,d.GSplat_VS=Fc,d.GTAOPost=Ag,d.GTAO_cs=wf,d.GUIAtlasTexture=gf,d.GUICanvas=Ti,d.GUIConfig=xr,d.GUIGeometry=_d,d.GUIGeometryRebuild=Ud,d.GUIMaterial=so,d.GUIPassRenderer=D0,d.GUIPick=Sd,d.GUIPickHelper=kd,d.GUIQuad=Da,d.GUIQuadAttrEnum=We,d.GUIRenderer=vd,d.GUIShader=no,d.GUISpace=Ht,d.GUISprite=qr,d.GUITexture=ir,d.GaussianSplatParser=xg,d.GenerayRandomDir=Cl,d.GeoJsonParser=Fg,d.GeoJsonUtil=kg,d.GeoType=xn,d.GeometryBase=Fe,d.GeometryIndicesBuffer=Ic,d.GeometryUtil=Qm,d.GeometryVertexBuffer=Rc,d.GeometryVertexType=bt,d.GetComponentClass=Vo,d.GetCountInstanceID=Ln,d.GetRepeat=ou,d.GetShader=Oo,d.GlassShader=ib,d.GlobalBindGroup=le,d.GlobalBindGroupLayout=is,d.GlobalFog=Dg,d.GlobalFog_shader=to,d.GlobalIlluminationComponent=Lb,d.GlobalUniform=Wn,d.GlobalUniformGroup=bs,d.GodRayPost=_g,d.GodRay_cs=If,d.GridObject=Tm,d.HDRTexture=Ns,d.HDRTextureCube=gn,d.Hair_frag=Fl,d.Hair_shader_op=nb,d.Hair_shader_tr=sb,d.HaltonSeq=an,d.Horizontal=wd,d.HoverCameraController=wb,d.I3DMLoader=sa,d.I3DMLoaderBase=sf,d.I3DMParser=lf,d.IBLEnvMapCreator=$0,d.IBLEnvMapCreator_cs=q0,d.IESProfiles=ra,d.IESProfiles_frag=fl,d.IKDTreeUserData=ag,d.ImageType=ti,d.IndicesGPUBuffer=wc,d.Inline_vert=el,d.InputSystem=No,d.InstanceDrawComponent=Gb,d.InstanceUniform=nl,d.InstancedMesh=of,d.Interpolator=rr,d.InterpolatorEnum=Us,d.IrradianceDataReaderCompleteEvent=Hd,d.IrradianceVolumeData_frag=$o,d.Irradiance_frag=hl,d.IsEditorInspector=Wh,d.IsNonSerialize=Vn,d.Joint=T0,d.JointPose=Rs,d.JumperInterpolator=C0,d.KDTreeEntity=ig,d.KDTreeNode=lr,d.KDTreeRange=Ld,d.KDTreeSpace=Gd,d.KDTreeUUID=Li,d.KHR_draco_mesh_compression=Es,d.KHR_lights_punctual=Rg,d.KHR_materials_clearcoat=N0,d.KHR_materials_emissive_strength=P0,d.KHR_materials_ior=wg,d.KHR_materials_unlit=V0,d.KMZParser=yf,d.KV=mo,d.KelvinUtil=Mm,d.KeyCode=Oe,d.KeyEvent=ba,d.Keyframe=_n,d.KeyframeT=ji,d.LDRTextureCube=pn,d.LOADED=Ba,d.LOADING=Do,d.LRUCache=mh,d.LambertMaterial=sm,d.Lambert_shader=El,d.LightBase=yi,d.LightData=tn,d.LightEntries=Lc,d.LightType=Ye,d.LightingFunction_frag=jo,d.Line=ot,d.LineClassification=xd,d.LinearInterpolator=y0,d.LitMaterial=pa,d.Lit_shader=pl,d.LoaderBase=yr,d.LoaderEvent=ng,d.LoaderManager=Sn,d.MAX_VALUE=au,d.MIN_VALUE=ru,d.Material=ut,d.MaterialDataUniformGPUBuffer=mc,d.MaterialUtilities=Fn,d.MathShader=Zo,d.MathUtil=vt,d.Matrix3=kr,d.Matrix4=R,d.MatrixBindGroup=Jc,d.MatrixGPUBuffer=zc,d.MatrixShader=Sl,d.MemoryDO=Xa,d.MemoryInfo=Go,d.MergeRGBACreator=lg,d.MergeRGBA_cs=Qf,d.MeshColliderShape=yn,d.MinMaxAnimationCurves=gm,d.MinMaxCurve=Rh,d.MinMaxCurveState=Eh,d.MinMaxPolyCurves=mm,d.MorePassParser=hg,d.MorePassShader=Yd,d.MorphTargetBlender=vb,d.MorphTargetData=jc,d.MorphTargetFrame=yb,d.MorphTargetTransformKey=pd,d.MorphTarget_shader=Nt,d.MouseCode=Cn,d.MultiBouncePass_cs=b0,d.Navi3DAstar=Qh,d.Navi3DConst=Yi,d.Navi3DEdge=ha,d.Navi3DFunnel=ja,d.Navi3DMaskType=br,d.Navi3DMesh=Fm,d.Navi3DPoint=Bt,d.Navi3DPoint2D=Io,d.Navi3DPointFat=da,d.Navi3DRouter=re,d.Navi3DTriangle=Th,d.NonSerialize=Pn,d.NormalMap_frag=ol,d.OAnimationEvent=M0,d.OBJParser=J0,d.Object3DEvent=sg,d.Object3DTransformTools=Qo,d.Object3DUtil=Nm,d.ObjectAnimClip=gd,d.OcclusionSystem=As,d.Octree=tr,d.OctreeEntity=xc,d.OrbitController=Ib,d.OrderMap=hm,d.Orientation3D=Wt,d.OutLineBlendColor_cs=Tf,d.OutlineCalcOutline_cs=Mf,d.OutlinePass=ob,d.OutlinePost=Bg,d.OutlinePostData=qd,d.OutlinePostManager=$d,d.OutlinePostSlot=Kd,d.Outline_cs=Nf,d.OvershootInterpolator=F0,d.PARSING=bh,d.PBRLItShader=Al,d.PBRLitSSSShader=ad,d.PLUGIN_REGISTERED=Yg,d.ParserBase=nt,d.ParserFormat=Ge,d.ParticleSystemCurveEvalMode=kh,d.ParticleSystemRandomnessIds=Ch,d.PassGenerate=Di,d.PassShader=Xd,d.PassType=H,d.PhysicMaterialUniform_frag=Yo,d.PickCompute=Pd,d.PickFire=Vd,d.PickGUIEvent3D=lt,d.PickResult=eh,d.Picker_cs=Pf,d.PingPong=Xn,d.PipelinePool=ls,d.Plane3D=wh,d.PlaneClassification=wr,d.PlaneGeometry=Hr,d.PointClassification=Fd,d.PointLightShadowRenderer=t0,d.PointShadowCubeCamera=$c,d.PointerEvent3D=L,d.Polynomial=Ua,d.PolynomialCurve=Wa,d.Polynomials=bm,d.PoolNode=yd,d.PostBase=Rt,d.PostProcessingComponent=Sf,d.PostRenderer=s0,d.PreDepthPassRenderer=i0,d.PreFilteredEnvironment_cs=o0,d.PreFilteredEnvironment_cs2=X2,d.PreIntegratedLut=Vf,d.PreIntegratedLutCompute=Zd,d.PrefabAvatarData=go,d.PrefabAvatarParser=oh,d.PrefabBoneData=bo,d.PrefabMaterialParser=ch,d.PrefabMeshData=fh,d.PrefabMeshParser=dh,d.PrefabNode=zi,d.PrefabParser=uh,d.PrefabStringUtil=Pg,d.PrefabTextureData=lh,d.PrefabTextureParser=hh,d.Preprocessor=ta,d.PriorityQueue=Bo,d.Probe=Md,d.ProbeEntries=cg,d.ProbeGBufferFrame=d0,d.ProfilerUtil=Ze,d.PropertyAnimClip=Db,d.PropertyAnimTag=md,d.PropertyAnimation=ro,d.PropertyAnimationClip=ko,d.PropertyAnimationClipState=ud,d.PropertyAnimationEvent=Ii,d.PropertyHelp=wi,d.QuadAABB=_t,d.QuadGlsl_fs=wl,d.QuadGlsl_vs=Rl,d.QuadRoot=Jd,d.QuadTree=zd,d.QuadTreeCell=cr,d.Quad_depth2dArray_frag_wgsl=$h,d.Quad_depth2d_frag_wgsl=vl,d.Quad_depthCube_frag_wgsl=yl,d.Quad_frag_wgsl=Ul,d.Quad_vert_wgsl=Bl,d.Quaternion=Z,d.R32UintTexture=Nc,d.RADIANS_TO_DEGREES=Wr,d.RGBEErrorCode=K0,d.RGBEHeader=Ps,d.RGBEParser=Vs,d.RTDescriptor=ke,d.RTFrame=Je,d.RTResourceConfig=ga,d.RTResourceMap=mt,d.Rand=hi,d.RandomSeed=lu,d.Ray=jt,d.RayCastMeshDetail=si,d.Reader=Yr,d.Rect=ui,d.Reference=me,d.Reflection=ld,d.ReflectionCG=zl,d.ReflectionEntries=Gc,d.ReflectionMaterial=fd,d.ReflectionRenderer=l0,d.ReflectionShader=cd,d.ReflectionShader_shader=Gl,d.RegisterComponent=Mt,d.RegisterShader=Qa,d.RenderContext=ps,d.RenderLayer=_i,d.RenderLayerUtil=cs,d.RenderNode=Oa,d.RenderShaderCollect=Sc,d.RenderShaderCompute=jd,d.RenderShaderPass=Ne,d.RenderTexture=gt,d.RendererBase=ma,d.RendererJob=f0,d.RendererMap=n0,d.RendererMask=De,d.RendererMaskUtil=zt,d.RendererPassState=Zc,d.RepeatSE=Hn,d.Res=Cf,d.RotationControlComponents=Vh,d.SHCommon_frag=Jl,d.SN_ArrayConstant=gi,d.SN_BinaryOperation=er,d.SN_Break=Vu,d.SN_CodeBlock=ia,d.SN_Constant=Pa,d.SN_Continue=sn,d.SN_Declaration=Ve,d.SN_Discard=Ou,d.SN_DoWhileLoop=Pu,d.SN_Expression=de,d.SN_ForLoop=_r,d.SN_Function=rn,d.SN_FunctionArgs=nn,d.SN_FunctionCall=Dr,d.SN_IFBranch=Ur,d.SN_Identifier=Na,d.SN_IndexOperation=vr,d.SN_Layout=Ai,d.SN_ParenExpression=fc,d.SN_Precision=on,d.SN_Return=mi,d.SN_SelectOperation=pi,d.SN_Struct=Ma,d.SN_TernaryOperation=dc,d.SN_UnaryOperation=Xr,d.SN_WhileLoop=Br,d.SSAO_cs=H2,d.SSGI2_cs=Of,d.SSGIPost=Ug,d.SSRPost=vg,d.SSR_BlendColor_cs=Lf,d.SSR_IS_Kernel=yg,d.SSR_IS_cs=Gf,d.SSR_RayTrace_cs=zf,d.ScaleControlComponents=Ph,d.Scene3D=Xb,d.Shader=it,d.ShaderAttributeInfo=os,d.ShaderConverter=uc,d.ShaderConverterResult=bc,d.ShaderLib=J,d.ShaderPassBase=Gn,d.ShaderReflection=dt,d.ShaderStage=na,d.ShaderState=gc,d.ShaderUniformInfo=ss,d.ShaderUtil=Va,d.ShadingInput=cl,d.ShadowLightsCollect=Et,d.ShadowMapPassRenderer=r0,d.ShadowMapping_frag=dl,d.Skeleton=Cb,d.SkeletonAnimationClip=dn,d.SkeletonAnimationClipState=hd,d.SkeletonAnimationCompute=Sb,d.SkeletonAnimation_shader=Jr,d.SkeletonBlendComputeArgs=xb,d.SkeletonPose=vi,d.SkeletonTransformComputeArgs=Fb,d.SkyGBufferPass=pc,d.SkyGBuffer_pass=Il,d.SkyMaterial=od,d.SkyRenderer=Dn,d.SolidColorSky=wm,d.SphereColliderShape=Yb,d.SphereGeometry=Cr,d.SphereReflection=dd,d.StandShader=z0,d.StatementNode=Ce,d.StorageGPUBuffer=_e,d.StringUtil=yt,d.Struct=fi,d.StructStorageGPUBuffer=fg,d.SubGeometry=Qc,d.TAACopyTex_cs=Jf,d.TAAPost=Cg,d.TAASharpTex_cs=Wf,d.TAA_cs=jf,d.TestComputeLoadBuffer=Xf,d.TextAnchor=Ed,d.TextFieldLayout=Qd,d.TextFieldLine=Id,d.Texture=Xe,d.TextureCube=un,d.TextureCubeFaceData=Os,d.TextureCubeStdCreator=bn,d.TextureCubeUtils=Ms,d.TextureMipmapCompute=dg,d.TextureMipmapGenerator=aa,d.TextureScaleCompute=Wd,d.ThirdPersonCameraController=Tb,d.Tile=_o,d.TileSet=qg,d.TileSetChild=em,d.TileSetChildContent=tm,d.TileSetChildContentMetaData=am,d.TileSetRoot=$g,d.TilesRenderer=Kg,d.Time=xe,d.TokenType=U,d.TorusGeometry=Nh,d.TouchData=Mo,d.TrailGeometry=km,d.Transform=kt,d.TransformAxisEnum=I,d.TransformControllerBaseComponent=Mn,d.TransformMode=tt,d.TransformSpaceMode=qt,d.TranslationControlComponents=Oh,d.TranslatorContext=ns,d.TriGeometry=Em,d.Triangle=Vi,d.UIButton=lo,d.UIButtonTransition=Td,d.UIComponentBase=oo,d.UIEvent=og,d.UIImage=Er,d.UIImageGroup=co,d.UIInteractive=vn,d.UIInteractiveStyle=Le,d.UIPanel=Pi,d.UIRenderAble=Ni,d.UIShadow=fo,d.UITextField=ho,d.UITransform=Ja,d.UNLOADED=dr,d.UUID=xt,d.UV=wo,d.Uint32ArrayTexture=Mc,d.Uint8ArrayTexture=ds,d.UnLit=kl,d.UnLitMaterial=st,d.UnLitMaterialUniform_frag=Xo,d.UnLitTexArrayMaterial=lm,d.UnLitTextureArray=rd,d.UnLit_frag=Ho,d.UniformGPUBuffer=ct,d.UniformNode=Ha,d.UniformType=ft,d.ValueEnumType=z,d.ValueOp=xm,d.ValueParser=_a,d.ValueSpread=pm,d.Vector2=K,d.Vector3=b,d.Vector3Ex=Qi,d.Vector4=$,d.VertexAttribute=tg,d.VertexAttributeIndexShader=$f,d.VertexAttributeName=V,d.VertexAttributeSize=Ka,d.VertexAttributeStride=Od,d.VertexAttributes_vert=Ko,d.VertexBufferLayout=eg,d.VertexFormat=Jo,d.VertexGPUBuffer=ln,d.Vertical=Rd,d.VideoUniform_frag=qo,d.View3D=Hb,d.ViewPanel=Bn,d.ViewQuad=ms,d.VirtualTexture=pe,d.WGS84_FLATTENING=jg,d.WGS84_HEIGHT=Zg,d.WGS84_RADIUS=Wg,d.WGSLTranslator=cc,d.WayLines3D=ki,d.WayPoint3D=Fi,d.WebGPUDescriptorCreator=Re,d.WorldMatrixUniform=jn,d.WorldPanel=Un,d.WrapMode=ii,d.WrapTimeMode=or,d.ZCullingCompute=bg,d.ZPassShader_cs=qf,d.ZPassShader_fs=Vl,d.ZPassShader_vs=Pl,d.ZSorterUtil=Uc,d.append=ac,d.arrayToString=ef,d.blendComponent=Hh,d.buildCurves=Dm,d.byteSizeOfType=rh,d.calculateCurveRangesValue=_m,d.calculateMinMax=Ji,d.castPointShadowMap_vert=Tl,d.clamp=ie,d.clampRepeat=Eu,d.computeAABBFromPositions=th,d.cos=Bu,d.crossProduct=xu,d.cubicPolynomialRoot=Sh,d.cubicPolynomialRootsGeneric=xh,d.curvesSupportProcedural=Am,d.deg2Rad=Au,d.detectGSplatFormat=ah,d.directionShadowCastMap_frag=Nl,d.dot=ht,d.doubleIntegrateSegment=Fh,d.downSample=kf,d.fastInvSqrt=ec,d.floorfToIntPos=$l,d.fonts=$r,d.generateRandom=Fu,d.generateRandom3=ku,d.getFloatFromInt=Hl,d.getGLTypeFromTypedArray=D2,d.getGLTypeFromTypedArrayType=A2,d.getGlobalRandomSeed=Uu,d.getTypedArray=_2,d.getTypedArrayTypeFromGLType=ks,d.grad1=Ro,d.grad2=Tn,d.grad3=Wi,d.grad4=li,d.inferSHOrder=ih,d.integrateSegment=Eo,d.irradianceDataReader=ug,d.kPI=um,d.lerp=Ar,d.lerpByte=su,d.lerpColor=nu,d.lerpVector3=iu,d.lruPriorityCallback=vh,d.magnitude=qn,d.makeAloneSprite=k2,d.makeGUISprite=bf,d.makeMatrix44=en,d.markUsedSetLeaves=So,d.markUsedTiles=wn,d.markVisibleTiles=xo,d.matrixMultiply=as,d.matrixRotate=Qu,d.matrixRotateY=Iu,d.mergeFunctions=Ki,d.multiplyMatrices4x4REF=tc,d.normal_distribution=Ih,d.normalizeFast=Su,d.normalizeSafe=Xl,d.normalizedToByte=Cu,d.normalizedToWord=yu,d.outlinePostData=ca,d.outlinePostManager=Sg,d.parsePlyGaussianSplat=sh,d.parsePlyHeader=nh,d.perm=ce,d.post=Ef,d.priorityCallback=Uh,d.quadraticPolynomialRootsGeneric=Qn,d.rad2Deg=Du,d.random01=jr,d.randomBarycentricCoord=pu,d.randomPointBetweenEllipsoid=mu,d.randomPointBetweenSphere=bu,d.randomPointInsideCube=hu,d.randomPointInsideEllipsoid=uu,d.randomPointInsideUnitCircle=gu,d.randomPointInsideUnitSphere=ql,d.randomQuaternion=fu,d.randomQuaternionUniformDistribution=du,d.randomUnitVector=$i,d.randomUnitVector2=Kl,d.rangedRandomFloat=rt,d.rangedRandomInt=cu,d.readByType=et,d.readMagicBytes=Gs,d.registerMaterial=om,d.repeat=ts,d.rotMatrix=wu,d.rotateVectorByQuat=tu,d.roundfToIntPos=$n,d.scale=Kn,d.shadowCastMap_frag=Ml,d.shadowCastMap_vert=Ql,d.simplex=Lt,d.sin=_u,d.snoise1=vm,d.snoise2=ym,d.snoise3=Cm,d.snoise4=Sm,d.sqrMagnitude=es,d.sqrtImpl=Yl,d.stencilStateFace=Kh,d.swap=vu,d.textureCompress=Hf,d.threshold=Ff,d.throttle=rm,d.toHalfFloat=ar,d.toggleTiles=Fo,d.traverseAncestors=Xg,d.traverseSet=ph,d.tw=tb,d.uniform_real_distribution=Bm,d.uniform_real_distribution2=Um,d.upSample=eo,d.webGPUContext=E,d.zSorterUtil=vc,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})}));
11691
11691
  //# sourceMappingURL=rings.umd.js.map