@rings-webgpu/core 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rings.es.js +116 -142
- package/dist/rings.es.js.map +2 -2
- package/dist/rings.es.max.js +184 -142
- package/dist/rings.umd.js +141 -167
- package/dist/rings.umd.js.map +2 -2
- package/dist/rings.umd.max.js +184 -142
- package/dist/types/components/anim/morphAnim/MorphTargetData.d.ts +1 -0
- package/dist/types/components/renderer/FatLineRenderer.d.ts +2 -0
- package/package.json +1 -1
package/dist/rings.es.js
CHANGED
|
@@ -5745,6 +5745,13 @@ struct InstanceData {
|
|
|
5745
5745
|
`}return r}return r}}function Xt(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 xh{_lexer;_rootNode;constructor(e){this._lexer=e,this._rootNode=new _e,this.parse()}get lexer(){return this._lexer}parse(){for(;this.peekToken(0).Type!==B.EOF;){if(this.peekToken(0).Type==B.SEMICOLON){this.skipToken(1);continue}let e=this.parseStatement();e!==null&&this._rootNode.addNode(e)}}parseStatement(){let e=this.peekToken();if(e.Type==B.LAYOUT&&this.peekToken(1).Type==B.LEFTSAMLL)return Ja.parse(this._lexer);if(e.Type==B.STRUCT)return this.skipToken(1),kr.parse(this._lexer);if((e.isBuiltinType()||e.Type==B.VOID)&&this.peekToken(1).Type==B.IDENT&&this.peekToken(2).Type==B.LEFTSAMLL)return Ns.parse(this._lexer);if(e.Type==B.CONST&&this.peekToken(1).isDataType())return ze.parse(this._lexer);if(e.isDataType()&&this.peekToken(1).Type==B.IDENT)return ze.parse(this._lexer);if(e.Type==B.OUT&&this.peekToken(1).isDataType()&&this.peekToken(2).Type==B.IDENT)return ze.parse(this._lexer);if(e.Type==B.PRECISION)return ks.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 vh{static VertexShader="VertexShader";static FragmentShader="FragmentShader";static convertGLSL(e){var t=new ph(e),r=new gh(t),i=new xh(r),a=new mh(i);return a.generateWGSL()}}class Uo{setID=0;bindingID=0;name="";type=""}class xo{name="";type="";locationID=0;builtinName="";isBuiltinAttribute(){return this.builtinName!=""}}class Bh{uniformInfo=[];inputAttribute=[];outputAttribute=[];sourceCode=""}var ar=(s=>(s[s.vertex=0]="vertex",s[s.fragment=1]="fragment",s[s.computer=2]="computer",s))(ar||{});class Ch{blendMode=ae.NONE;depthCompare=et.less_equal;depthWriteEnabled=!0;frontFace="ccw";cullMode=Et.back;topology=to.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 ae.ABOVE;case"ALPHA":return ae.ALPHA;case"NORMAL":return ae.NORMAL;case"ADD":return ae.ADD;case"BELOW":return ae.BELOW;case"ERASE":return ae.ERASE;case"MUL":return ae.MUL;case"SCREEN":return ae.SCREEN;case"DIVD":return ae.DIVD;case"SOFT_ADD":return ae.SOFT_ADD}return ae.NONE}}class Sh extends Tr{uniformNodes=[];_onChange=!0;constructor(){super(),this.bufferType=tr.MaterialDataUniformGPUBuffer}initDataUniform(e){this.uniformNodes=e;let t=0;for(const r in e){const i=e[r];i||console.error(r,"is empty"),t+=i.size*4}t=Math.floor(t/256+1)*256,this.createBuffer(GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,t/4,null,"MaterialDataUniformGPUBuffer");for(const r in e){const i=e[r];i||console.error(r,"is empty");let a=this.memory.allocation_node(i.size*4);i.memoryInfo=a,i.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 Mr{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 r=this.reference.get(e);r||=new Map,r.set(t,e),this.reference.set(e,r)}detached(e,t){let r=this.reference.get(e);r&&r.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 vo{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 Pe extends eo{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 O||console.error("Shader Not Register, Please Register Shader!",this.vsName),this.fsName in O||console.error("Shader Not Register, Please Register Shader!",this.fsName),O[this.vsName]&&(this._sourceVS=O[this.vsName]),O[this.fsName]&&(this._sourceFS=O[this.fsName]),this.textures={},this.bindGroups=[],this.shaderState=new Ch,this.materialDataUniformBuffer=new Sh,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==Et.none}set doubleSide(e){let t=e?Et.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!=ae.NORMAL&&e!=ae.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 r=this.createGroupLayouts();this.createPipeline(e,t,r)}reBuild(e,t){this.compileShader(ar.vertex,this._destVS,t),this.compileShader(ar.fragment,this._destFS,t),this.genRenderPipeline(e,t)}apply(e,t,r){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=Bt.genRenderShaderVariant(this),this.reBuild(e,t),this._valueChange=!1,r&&r())}preCompile(e){this.preDefine(e),this.preCompileShader(ar.vertex,this._sourceVS.concat()),this.preCompileShader(ar.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),m.setting.render.useCompressGBuffer?this.defineValue.USE_COMPRESSGBUFFER=!0:this.defineValue.USE_COMPRESSGBUFFER=!1,rr.parse(e,this.defineValue)}setBindGroup(e,t){this.bindGroups[e]=t}checkBuffer(e,t){}preCompileShader(e,t,r){let i=t;if(i.indexOf("version ")!=-1){var a=vh.convertGLSL(i);i=a.sourceCode}for(const o in this.constValues)if(Object.prototype.hasOwnProperty.call(this.constValues,o)){const n=this.constValues[o];i=i.replaceAll(`&${o}`,n.toString())}switch(e){case ar.vertex:this._destVS=i;break;case ar.fragment:this._destFS=i;break}}compileShader(e,t,r){let i=t;i=this.applyPostDefine(i,r);let a=t;for(let n in this.defineValue)a+=`${n}=${this.defineValue[n]},`;let o=Mr.renderShaderModulePool.get(a);switch(o||(i=this.applyPostDefine(i,r),o=Q.device.createShaderModule({label:e==ar.vertex?this.vsName:this.fsName,code:i}),o.getCompilationInfo().then(n=>{n.messages.length>0&&(console.log(i),console.log(n))}),Mr.renderShaderModulePool.set(a,o)),e){case ar.vertex:this._vsShaderModule=o,this._destVS=i;break;case ar.fragment:this._fsShaderModule=o,this._destFS=i;break}}getGroupLayout(e,t){let r=[];for(let i=0;i<t.length;i++){const a=t[i];if(a)if(a.varType=="uniform"){this._bufferDic.has(a.varName)||console.error(`not set ${a.varName} buffer`);let o=this._bufferDic.get(a.varName).visibility,n={binding:a.binding,visibility:o,buffer:{type:"uniform"}};r.push(n)}else if(a.varType=="storage-read"){this._bufferDic.has(a.varName)||console.error(`not set ${a.varName} buffer`);let o=this._bufferDic.get(a.varName).visibility,n={binding:a.binding,visibility:o,buffer:{type:"read-only-storage"}};r.push(n)}else if(a.varType=="var")switch(a.dataType){case"sampler":{let o=a.varName.replace("Sampler",""),n=this.textures[o]?this.textures[o]:m.res.redTexture,l={binding:a.binding,visibility:n.visibility,sampler:n.samplerBindingLayout};r.push(l),this._textureGroup=e}break;case"sampler_comparison":{let o=a.varName.replace("Sampler",""),n=this.textures[o]?this.textures[o]:m.res.redTexture,l={binding:a.binding,visibility:n.visibility,sampler:n.sampler_comparisonBindingLayout};r.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 o=this.textures[a.varName]?this.textures[a.varName]:m.res.redTexture,n={binding:a.binding,visibility:o.visibility,texture:o.textureBindingLayout};r.push(n),this._textureGroup=e,me.getInstance().attached(o,this)}break;case"texture_external":{let o=this.textures[a.varName]?this.textures[a.varName]:m.res.redTexture,n={binding:a.binding,visibility:o.visibility,externalTexture:{}};r.push(n),this._textureGroup=e,me.getInstance().attached(o,this)}break;default:{let o=this.textures[a.varName]?this.textures[a.varName]:m.res.redTexture,n={binding:a.binding,visibility:o.visibility,texture:o.textureBindingLayout};r.push(n),this._textureGroup=e,me.getInstance().attached(o,this)}break}else{debugger;console.error("bind group can't empty")}}return r}_cacheEntries;genGroups(e,t,r=!1){if(!this.bindGroups[e]||r){const i=t[e];let a=[];for(let n=0;n<i.length;n++){const l=i[n];if(l){if(l.varType=="uniform"){let h=this._bufferDic.get(l.varName);if(h){if(h.bufferType==tr.MaterialDataUniformGPUBuffer){let c=[];for(let f=0;f<l.dataFields.length;f++){const g=l.dataFields[f];this.uniforms[g.name]||console.error(`shader-${this.vsName}:${this.fsName} ${g.name}is empty`),c.push(this.uniforms[g.name])}this.materialDataUniformBuffer.initDataUniform(c)}let u={binding:l.binding,resource:{buffer:h.buffer,offset:0,size:h.memory.shareDataBuffer.byteLength}};a.push(u),this.checkBuffer(l.varName,h)}else console.error(`shader${this.vsName}-${this.fsName}`,`buffer ${l.varName} is missing!`)}else if(l.varType=="storage-read"){let h=this._bufferDic.get(l.varName);if(h){let u={binding:l.binding,resource:{buffer:h.buffer,offset:0,size:h.memory.shareDataBuffer.byteLength}};a.push(u),this.checkBuffer(l.varName,h)}else console.error(`buffer ${l.varName} is missing!`)}else if(l.varType=="var")if(l.dataType=="sampler"){let h=l.varName.replace("Sampler",""),u=this.textures[h];if(u||(u=m.res.blackTexture,this.setTexture(h,u)),u){let c={binding:l.binding,resource:u.gpuSampler};a.push(c)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}else if(l.dataType=="sampler_comparison"){let h=l.varName.replace("Sampler",""),u=this.textures[h];if(u){let c={binding:l.binding,resource:u.gpuSampler_comparison};a.push(c)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}else{let h=this.textures[l.varName];if(h||(h=m.res.whiteTexture,this.setTexture(l.varName,h)),h){let u={binding:l.binding,resource:h.getGPUView()};a.push(u)}else console.error(`shader${this.vsName}-${this.fsName}`,`texture ${l.varName} is missing! `)}}}let o=Q.device.createBindGroup({layout:this.bindGroupLayouts[e],entries:a});this.bindGroups[e]=o}}createPipeline(e,t,r){let i=e,a=this.shaderState,o=[];for(const h of t.renderTargetTextures)o.push({format:h.format});for(let h=0;h<o.length;h++){const u=o[h];a.writeMasks&&a.writeMasks.length>0&&(u.writeMask=a.writeMasks[h])}if(t.outColor!=-1){let h=o[t.outColor];a.blendMode!=ae.NONE?h.blend=fh.getBlend(a.blendMode):delete h.blend}let n={label:this.vsName+"|"+this.fsName,layout:r,primitive:{topology:a.topology,cullMode:a.cullMode,frontFace:a.frontFace},vertex:void 0};this.vsEntryPoint!=""&&(n.vertex={module:this._vsShaderModule,entryPoint:this.vsEntryPoint,buffers:i.vertexBuffer.vertexBufferLayouts}),this.fsEntryPoint!=""&&(n.fragment={module:this._fsShaderModule,entryPoint:this.fsEntryPoint,targets:o}),a.multisample>0&&(n.multisample={count:a.multisample}),(t.zPreTexture||t.depthTexture)&&(a.blendMode!=ae.NONE,m.setting.render.zPrePass&&t.zPreTexture&&a.useZ?n.depthStencil={depthWriteEnabled:!1,depthCompare:et.less,format:t.zPreTexture.format}:n.depthStencil={depthWriteEnabled:a.depthWriteEnabled,depthCompare:a.depthCompare,format:t.depthTexture.format});let l=vo.getSharePipeline(this.shaderVariant);l?this.pipeline=l:(this.pipeline=F.createPipeline(n),vo.setSharePipeline(this.shaderVariant,this.pipeline))}createGroupLayouts(){this._groupsShaderReflectionVarInfos=[];let e=this.shaderReflection;this.bindGroupLayouts=[mo.getGlobalDataBindGroupLayout()];for(let r=1;r<e.groups.length;r++){let i=e.groups[r];if(i){let a=this.getGroupLayout(r,i);this._groupsShaderReflectionVarInfos[r]=i;let o=Q.device.createBindGroupLayout({entries:a,label:`vs${this.vsName} fs${this.fsName} ${i.length}`});this.bindGroupLayouts[r]=o}else console.error("can't set empty group!",r)}let t=Q.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),r=e.hasAttribute(V.joints0),i=e.hasAttribute(V.a_morphPositions_0),a=e.hasAttribute(V.TANGENT),o=e.hasAttribute(V.color),n=this.shaderState.acceptGI,l=this.shaderState.useLight;t&&(this.defineValue.USE_SECONDUV=!0),r&&i?this.defineValue.USE_METAHUMAN=!0:(this.defineValue.USE_SKELETON=r,this.defineValue.USE_MORPHTARGETS=i),"USE_TANGENT"in this.defineValue||(this.defineValue.USE_TANGENT=a),this.defineValue.USE_GI=n,this.defineValue.USE_SHADOWMAPING=this.shaderState.acceptShadow,this.defineValue.USE_LIGHT=l,this.defineValue.USE_VERTXCOLOR=o,m.setting.pick.mode=="pixel"&&(this.defineValue.USE_WORLDPOS=!0),m.setting.gi.enable?this.defineValue.USEGI=!0:this.defineValue.USEGI=!1,m.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,m.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=m.setting.shadow.type=="PCF",this.defineValue.USE_HARD_SHADOW=m.setting.shadow.type=="HARD",this.defineValue.USE_SOFT_SHADOW=m.setting.shadow.type=="SOFT",this.defineValue.USE_CSM=Zt.Cascades>1,this.defineValue.USE_IES_PROFILE=gr.use}genReflection(){this.shaderVariant=Bt.genRenderShaderVariant(this);let e=Bt.poolGetReflection(this.shaderVariant);if(e)this.shaderReflection=e;else{let t=rr.parse(this._destVS,this.defineValue);t=rr.parse(t,this.defineValue),Bt.getShaderReflection2(t,this);let r=rr.parse(this._destFS,this.defineValue);r=rr.parse(r,this.defineValue),Bt.getShaderReflection2(r,this),Bt.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 r=this.textures[t];if(me.getInstance().detached(r,this),e&&!me.getInstance().hasReference(r))r.destroy(e);else{r.destroy(!1);let i=me.getInstance().getReference(r);if(i){let a=[];i.forEach((o,n)=>{"name"in o?a.push(o.name):a.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){Mr.renderShader.has(e)&&(Mr.renderShader.get(e).destroy(),Mr.renderShader.delete(e))}static getShader(e){return Mr.renderShader.get(e)}static createShader(e,t){let r=new Pe(e,t);return Mr.renderShader.set(r.instanceID,r),r.instanceID}}class _h extends Pe{constructor(){super("sky_vs_frag_wgsl","SkyGBuffer_fs"),this.passType=H.GI,this.setUniformVector3("eyesPos",new d),this.setUniformFloat("exposure",1),this.setUniformFloat("roughness",0);let e=this.shaderState;e.frontFace="ccw",e.cullMode=Et.front,e.depthWriteEnabled=!1,e.depthCompare=et.less}}class Fh extends Pe{transparency;constructor(){super("gbuffer_vs","gbuffer_fs"),this.setShaderEntry("VertMain","FragMain"),this.passType=H.GI,this.setUniformColor("baseColor",new P),this.setUniformColor("emissiveColor",new P),this.setUniformFloat("emissiveIntensity",1),this.setUniformFloat("normalScale",1),this.setUniformFloat("alphaCutoff",1),this.blendMode=ae.NONE,this.setTexture("normalMap",m.res.normalTexture)}}class yh extends Pe{constructor(){super("shadowCastMap_vert","directionShadowCastMap_frag"),this.passType=H.SHADOW,this.setShaderEntry("main"),this.setUniformFloat("cameraFar",5e3),this.setUniformVector3("lightWorldPos",d.ZERO),this.shaderState.receiveEnv=!1,this.shaderState.castShadow=!1,this.shaderState.acceptShadow=!1,this.setDefine("USE_ALPHACUT",!0)}}class bh extends Pe{constructor(){super("castPointShadowMap_vert","shadowCastMap_frag"),this.passType=H.POINT_SHADOW,this.setShaderEntry("main","main"),this.setUniformFloat("cameraFar",5e3),this.setUniformVector3("lightWorldPos",d.ZERO),this.shaderState.receiveEnv=!1,this.shaderState.castShadow=!1,this.shaderState.acceptShadow=!1,this.setDefine("USE_ALPHACUT",!0)}}class Qh extends Pe{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 ca{static createGIPass(e,t){if(Jt.hasMask(e.rendererMask,ve.Sky)){if(!t.passShader.get(H.GI)){let i=t.getSubShaders(H.COLOR)[0],a=new _h;a.setTexture("baseMap",i.getTexture("baseMap")),a.cullMode=i.cullMode,a.frontFace=i.frontFace,t.addRenderPass(a,0),a.preCompile(e.geometry)}}else this.castGBufferPass(e,t)}static castGBufferPass(e,t){let r=t.getDefaultShaders();for(let i=0;i<r.length;i++){const a=r[i];let o=t.getSubShaders(H.GI);if(!o||o.length==0||o.length<i){let n=new Fh;n.setTexture("baseMap",a.getTexture("baseMap")),n.setTexture("normalMap",a.getTexture("normalMap")),n.setTexture("emissiveMap",a.getTexture("emissiveMap")),n.setUniform("baseColor",a.getUniform("baseColor")),n.setUniform("envIntensity",a.getUniform("envIntensity")),n.setUniform("emissiveColor",a.getUniform("emissiveColor")),n.setUniform("emissiveIntensity",a.getUniform("emissiveIntensity")),n.setUniform("alphaCutoff",a.getUniform("alphaCutoff")),n.cullMode=a.cullMode,n.frontFace=a.frontFace,n.preCompile(e.geometry),t.addRenderPass(n)}}}static createShadowPass(e,t){let r=Jt.hasMask(e.rendererMask,ve.SkinnedMesh),i=e.geometry.hasAttribute(V.TANGENT),a=e.geometry.hasAttribute(Yt.MORPH_POSITION_PREFIX+"0"),o=e.geometry.hasAttribute(Yt.MORPH_NORMAL_PREFIX+"0"),n=t.getSubShaders(H.COLOR);for(let l=0;l<n.length;l++){const h=n[l];let u=t.getSubShaders(H.SHADOW);if(!u||u.length<l+1){let f=new yh;f.setTexture("baseMap",h.getTexture("baseMap")),f.setUniform("alphaCutoff",h.getUniform("alphaCutoff")),i&&f.setDefine("USE_TANGENT",i),r&&f.setDefine("USE_SKELETON",r),a&&f.setDefine("USE_MORPHTARGETS",a),o&&f.setDefine("USE_MORPHNORMALS",o),h.cullMode=="none"?f.shaderState.cullMode="none":h.cullMode=="back"?f.shaderState.cullMode="front":h.cullMode=="front"&&(f.shaderState.cullMode="back"),f.preCompile(e.geometry),t.addRenderPass(f)}let c=t.getSubShaders(H.POINT_SHADOW);if(!c||c.length<l+1){let f=new bh;f.setTexture("baseMap",h.getTexture("baseMap")),f.setUniform("alphaCutoff",h.getUniform("alphaCutoff")),f.setDefine("USE_ALPHACUT",1);for(let g=0;g<1;g++)i&&f.setDefine("USE_TANGENT",i),r&&f.setDefine("USE_SKELETON",r),a&&f.setDefine("USE_MORPHTARGETS",a),o&&f.setDefine("USE_MORPHNORMALS",o),f.shaderState.cullMode="front",f.preCompile(e.geometry);t.addRenderPass(f)}}}static createDepthPass(e,t){let r=t.getSubShaders(H.COLOR),i=e.geometry.hasAttribute("TANGENT"),a=e.geometry.hasAttribute(Yt.MORPH_POSITION_PREFIX+"0"),o=e.geometry.hasAttribute(Yt.MORPH_NORMAL_PREFIX+"0"),n=Jt.hasMask(e.rendererMask,ve.SkinnedMesh);for(let l=0;l<r.length;l++){const h=r[l];let u=t.getSubShaders(H.DEPTH);if(!u&&h.shaderState.useZ&&(!u||u.length<l)){let c=new Qh;c.setTexture("baseMap",h.getTexture("baseMap")),i||c.setDefine("USE_TANGENT",i),n&&c.setDefine("USE_SKELETON",n),a&&c.setDefine("USE_MORPHTARGETS",a),o&&c.setDefine("USE_MORPHNORMALS",o),c.cullMode=h.cullMode,c.frontFace=h.frontFace,c.preCompile(e.geometry),t.addRenderPass(c)}}}static createReflectionPass(e,t){let r=t.getDefaultShaders();for(let n=0;n<r.length;n++){const l=r[n];let h=t.getSubShaders(H.REFLECTION);if(!h||h.length==0||h.length<n){let u=new Pe(l.vsName,l.fsName);u.vsEntryPoint=l.vsEntryPoint,u.fsEntryPoint=l.fsEntryPoint,u.passType=H.REFLECTION;for(const c in l.shaderState){var i=l.shaderState[c];u.shaderState[c]=i}for(const c in l.textures){var a=l.getTexture(c);u.setTexture(c,a)}for(const c in l.uniforms){var o=l.getUniform(c);u.setUniform(c,o)}for(const c in l.defineValue){var o=l.defineValue[c];u.setDefine(c,o)}u.setDefine("USE_CASTREFLECTION",!0),u.preCompile(e.geometry),t.addRenderPass(u)}}}}class ci{static _v1=new d;static _v2=new d;entities;box;subTrees=[];parent;level;static maxSplitLevel=6;static autoSplitLevel=3;index;uuid;constructor(e,t=0,r=null,i=0){this.parent=r,this.box=e.clone(),this.level=i,this.index=t,this.uuid=i+"_"+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<ci.maxSplitLevel&&this.splitTree();let r;if(this.subTrees.length>0){for(let i of this.subTrees)if(i.tryInsertEntity(e)){r=!0;break}}return r||e.enterNode(this),!0}return!1}splitTree(){if(this.subTrees.length==0){const e=ci._v1,t=this.box.extents.clone();let r=this.level+1,i=0;for(let a=0;a<2;a++)for(let o=0;o<2;o++)for(let n=0;n<2;n++){const l=new Fe;this.box.min.add(e.set(a,o,n).multiply(t),l.min),l.min.add(t,l.max),l.setFromMinMax(l.min,l.max);let h=new ci(l,i++,this,r);this.subTrees.push(h)}}}__rayCastTempVector=new d;rayCasts(e,t){if(this.level==0||e.intersectBox(this.box,this.__rayCastTempVector)){this.entities.size>0&&t.push(...this.entities.values());for(let r of this.subTrees)r.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 r of this.entities.values())(this.level>ci.autoSplitLevel||e.containsBox2(r.renderer.object3D.bound)>0)&&t.push(r);for(let r of this.subTrees)r.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 r of this.entities.values())(this.level>ci.autoSplitLevel||e.containsBox2(r.renderer.object3D.bound)>0)&&(r.renderer.renderOrder<3e3?t.opaqueList.push(r.renderer):r.renderer.renderOrder>=3e3&&t.transparentList.push(r.renderer));for(let r of this.subTrees)r.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 r of this.subTrees)r.boxCasts(e,t);return!0}return!1}clean(){for(let e of this.entities.values())e.leaveNode();return this.entities.clear(),this}}class Rh{_pool=[];_worldPosition=new d;_viewPosition=new d;_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,r,i){this._zSortList=[];for(let a of t){let o=this.pop();o.userData=a,o.obj3d=r(a),o.z=this.worldToCameraDepth(o.obj3d,e),this._zSortList.push(o)}this._zSortList.sort((a,o)=>a.z-o.z>0?1:-1),i||=[];for(let a of this._zSortList)i.push(a.userData);return this.recycle(),i}worldToCameraDepth(e,t){t||=e.transform.view3D.camera;let r=0;return t&&(this._worldPosition.copyFrom(e.transform.worldPosition),t.worldToScreenPoint(this._worldPosition,this._viewPosition),r=this._viewPosition.z),r}}let Ih=new Rh;var fa=(s=>(s[s.None=2]="None",s[s.StaticBatch=4]="StaticBatch",s[s.DynamicBatch=8]="DynamicBatch",s[s.Hiden=16]="Hiden",s))(fa||{});class Bo{static addMask(e,t){return e|t}static removeMask(e,t){return e&~t}static hasMask(e,t){return(e&t)!=0}}class Eh{opaqueList=[];transparentList=[];sky;clean(){this.opaqueList.length=0,this.transparentList.length=0}}class wh{renderGroup;constructor(){this.renderGroup=new Map}collect_add(e){let t="",r="";t+=e.geometry.instanceID;for(let a=0;a<e.materials.length;a++){const o=e.materials[a];r+=o.shader.getDefaultColorShader().shaderVariant}let i=t+r;this.renderGroup.has(i)||this.renderGroup.set(i,{bundleMap:new Map,key:i,renderNodes:[]}),this.renderGroup.get(i).renderNodes.indexOf(e)==-1&&this.renderGroup.get(i).renderNodes.push(e)}}class Th{renderShaderUpdateList=new Map;renderNodeList=new Map;collect_add(e){let t=e.transform.view3D;t&&e.materials&&e.materials.forEach(r=>{let i=this.renderShaderUpdateList.get(t);i||(i=new Map,this.renderShaderUpdateList.set(t,i));let a=this.renderNodeList.get(t);a||(a=new Map,this.renderNodeList.set(t,a)),a.set(e.instanceID,e);let o=r.getAllPass();for(let n=0;n<o.length;n++){const l=o[n];let h=`${e.geometry.instanceID+l.instanceID}`,u=i.get(h);u||(u=new Map,i.set(h,u)),u.set(e.instanceID,e)}})}collect_remove(e){let t=e.transform.view3D;if(t&&e.materials){let r=this.renderShaderUpdateList.get(t);r&&e.materials.forEach(i=>{let a=i.getAllPass();for(let o=0;o<a.length;o++){const n=a[o];let l=`${e.geometry.instanceID+n.instanceID}`;r.delete(l)}})}}}class G{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 G),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 Eh,this._renderShaderCollect=new Th,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 r=e.length-1;r>0;r--)if(e[r].renderOrder<t.renderOrder){e.push(t);return}e.push(t)}addRenderNode(e,t){if(!e)return;let r=t.renderOrder>=3e3;if(t.hasMask(ve.Sky))this.sky=t;else if(t.hasMask(ve.Reflection)){this.removeRenderNode(e,t);let i=this._reflections.get(e);i||(i=[],this._reflections.set(e,i),i.push(t)),i.includes(t)||i.push(t)}else if(t.hasMask(ve.Graphic3D))this._graphics.indexOf(t)==-1&&this._graphics.push(t);else if(Bo.hasMask(t.renderLayer,fa.None)){this.removeRenderNode(e,t);let i=r?this._tr_RenderNodes:this._op_RenderNodes;i.has(e)||i.set(e,[]),i.get(e).push(t),m.setting.occlusionQuery.octree&&t.attachSceneOctree(this.getOctree(e));let a=this.getPashList(e,t);a.indexOf(t)==-1&&this.sortRenderNode(a,t)}else{this.removeRenderNode(e,t);let i=r?this._tr_renderGroup:this._op_renderGroup;i.has(e)||i.set(e,new wh),i.get(e).collect_add(t)}t.object3D.renderNode=t,this._renderShaderCollect.collect_add(t)}getOctree(e){let t,r=m.setting.occlusionQuery.octree;if(r&&(t=this._octreeRenderNodes.get(e),!t)){let i=new d(r.x,r.y,r.z),a=new d(r.width,r.height,r.depth),o=new Fe(i,a);t=new ci(o),this._octreeRenderNodes.set(e,t)}return t}removeRenderNode(e,t){if(t.detachSceneOctree(),t.hasMask(ve.Sky))this.sky=null;else if(t.hasMask(ve.Reflection)){let r=this._reflections.get(e);if(r){let i=r.indexOf(t);i!=-1&&r.splice(i,1)}}else if(Bo.hasMask(t.renderLayer,fa.None)){let r=this.getPashList(e,t);if(r){let i=r.indexOf(t);i!=-1&&r.splice(i,1)}}this._renderShaderCollect.collect_remove(t)}addLight(e,t){if(!this._sceneLights.has(e))this._sceneLights.set(e,[t]);else{let r=this._sceneLights.get(e);if(r.length>=m.setting.light.maxLight){console.warn("Alreay meet maxmium light number:",m.setting.light.maxLight);return}r.indexOf(t)!=-1||r.push(t)}}removeLight(e,t){if(this._sceneLights.has(e)){let r=this._sceneLights.get(e),i=r.indexOf(t);i!=-1&&r.splice(i,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 r=this._sceneGIProbes.get(e),i=r.indexOf(t);i!=-1&&r.splice(i,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 r=!1;for(const i of t)if(i.isRenderOrderChange||i.needSortOnCameraZ){r=!0;break}if(r){for(const i of t){let a=i.renderOrder;if(i.needSortOnCameraZ){let o=Ih.worldToCameraDepth(i.object3D);o=1-Math.max(0,Math.min(1,o)),a+=o}i.__renderOrder=a,i.isRenderOrderChange=!1}t.sort((i,a)=>i.__renderOrder>a.__renderOrder?1:-1)}return this}getRenderNodes(e,t){if(this.autoSortRenderNodes(e),this._collectInfo.clean(),this._collectInfo.sky=this.sky,m.setting.occlusionQuery.octree)this.rendererOctree=this.getOctree(e),this.rendererOctree.getRenderNode(t.frustum,this._collectInfo);else{let r=this._op_RenderNodes.get(e);r&&(this._collectInfo.opaqueList=r.concat());let i=this._tr_RenderNodes.get(e);i&&(this._collectInfo.transparentList=i.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 Dh{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 Og=Object.defineProperty,zg=Object.getOwnPropertyDescriptor,Co=(s,e,t,r)=>{for(var i=zg(e,t),a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(e,t,i)||i);return i&&Og(e,t,i),i};class Nr extends ke{instanceCount=0;lodLevel=0;alwaysRender=!1;instanceID;drawType=0;_geometry;_materials=[];_castShadow=!0;_castReflection=!0;_castGI=!1;_rendererMask=ve.Default;_inRenderer=!1;_readyPipeline=!1;_combineShaderRefection;_ignoreEnvMap;_ignorePrefilterMap;__renderOrder=0;_renderOrder=0;_passInit=new Map;isRenderOrderChange;needSortOnCameraZ;isRecievePostEffectUI;_octreeBinder;_renderLayer=fa.None;_computes;init(e){this.renderOrder=0,this.rendererMask=ve.Default,this.instanceID=$s().toString(),this._computes=[]}attachSceneOctree(e){this._octreeBinder={octree:e,entity:new Dh(this)},this.transform.eventDispatcher.addEventListener(Dt.LOCAL_ONCHANGE,this.updateOctreeEntity,this)}detachSceneOctree(){this._octreeBinder&&(this._octreeBinder.entity?.leaveNode(),this.transform.eventDispatcher.removeEventListener(Dt.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=Jt.addMask(this.rendererMask,e)}removeMask(e){this._rendererMask=Jt.removeMask(this.rendererMask,e)}hasMask(e){return Jt.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 r=0;r<this._materials.length;r++){let i=this._materials[r];me.getInstance().detached(i,this),i.shader&&i.shader.computes&&this.removeComputes(i.shader.computes)}for(let r=0;r<e.length;r++){let i=e[r];me.getInstance().attached(i,this),i.shader&&i.shader.computes&&this.addComputes(i.shader.computes)}this._materials=e;let t=0;for(let r=0;r<e.length;r++){const o=e[r].getPass(H.COLOR)[0];o.shaderState.transparent&&(t=t>o.renderOrder?t:o.renderOrder)}this.renderOrder=t,this._readyPipeline||this.initPipeline()}addComputes(e){this._computes.push(...e)}removeComputes(e){for(const t of e){let r=this._computes.indexOf(t);r!=-1&&this._computes.splice(r,1)}}addRendererMask(e){this._rendererMask=Jt.addMask(this._rendererMask,e)}removeRendererMask(e){this._rendererMask=Jt.removeMask(this._rendererMask,e)}onEnable(){this._readyPipeline||this.initPipeline(),G.instance.addRenderNode(this.transform.scene3D,this),this.updateOctreeEntity()}onDisable(){this._enable=!1,G.instance.removeRenderNode(this.transform.scene3D,this),super.onDisable?.()}selfCloneMaterials(e){let t=[];for(let r=0,i=this.materials.length;r<i;r++){const a=this.materials[r].clone();t.push(a)}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 i=this._materials[t].getPass(H.COLOR);for(let a=0;a<i.length;a++){const o=i[a];o.shaderReflection||o.preCompile(this._geometry),this._geometry.generate(o.shaderReflection)}this.object3D.bound=this._geometry.bounds.clone()}this._readyPipeline=!0;let e=0;for(let t=0;t<this.materials.length;t++){const a=this.materials[t].getPass(H.COLOR)[0];a.renderOrder>=3e3?e=e>a.renderOrder?e:a.renderOrder:e=Math.max(e-3e3,0),this.castNeedPass()}this.renderOrder=e,this.enable&&this.transform&&this.transform.scene3D&&G.instance.addRenderNode(this.transform.scene3D,this)}}castNeedPass(){if(this.castGI)for(let t=0;t<this.materials.length;t++){const r=this.materials[t];ca.createGIPass(this,r.shader)}for(let t=0;t<this.materials.length;t++){const r=this.materials[t];r.castShadow&&ca.createShadowPass(this,r.shader)}if(this.castReflection)for(let t=0;t<this.materials.length;t++){const r=this.materials[t];r.castReflection&&ca.createReflectionPass(this,r.shader)}if(!Jt.hasMask(this.rendererMask,ve.IgnoreDepthPass)&&m.setting.render.zPrePass)for(let t=0;t<this.materials.length;t++){const r=this.materials[t];ca.createDepthPass(this,r.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,r){if(!this._geometry)return;let i=this,a=i.transform._worldMatrix;const o=Math.max(i.materials.length,i._geometry.subGeometries.length);for(let n=0;n<o;n++){const l=n>=i.materials.length?i.materials[0]:i.materials[n];if(!l||!l.enable)continue;let h=l.getPass(t);if(!(!h||h.length==0)){F.bindGeometryBuffer(r.encoder,i._geometry),Ye.viewCount_vertex(e,H[t],i._geometry.vertexCount);for(let u=0;u<h.length;u++){if(!h||h.length==0)continue;const f=h[u];if(f.pipeline){f.shaderState.splitTexture&&(r.endRenderPass(),Ct.WriteSplitColorTexture(i.instanceID),r.beginOpaqueRenderPass(),F.bindCamera(r.encoder,e.camera),F.bindGeometryBuffer(r.encoder,i._geometry)),F.bindPipeline(r.encoder,f)&&Ye.viewCount_pipeline(e,H[t]);let U=(n>=i._geometry.subGeometries.length?i._geometry.subGeometries[0]:i._geometry.subGeometries[n]).lodLevels[i.lodLevel];i.instanceCount>0?(Ye.viewCount_instance(e,H[t],i.instanceCount),Ye.viewCount_indices(e,H[t],U.indexCount),Ye.viewCount_tri(e,H[t],U.indexCount/3*i.instanceCount),F.drawIndexed(r.encoder,U.indexCount,i.instanceCount,U.indexStart,0,0)):(Ye.viewCount_indices(e,H[t],U.indexCount),Ye.viewCount_tri(e,H[t],U.indexCount/3),F.drawIndexed(r.encoder,U.indexCount,1,U.indexStart,0,a.index)),Ye.viewCount_draw(e,H[t])}}}}}renderPass2(e,t,r,i,a,o=!1){if(!this.enable||!this._geometry)return;let n=this,l=n.object3D.transform._worldMatrix;for(let h=0;h<this.materials.length;h++){const u=this.materials[h];if(!u.castShadow&&t==H.SHADOW)continue;let c=u.getPass(t);if(!c||c.length==0)return;if(this.drawType==2)for(let f of c)f.pipeline&&(F.bindPipeline(a,f),F.draw(a,6,1,0,l.index));else{F.bindGeometryBuffer(a,n._geometry);for(let f of c)if(f.pipeline){F.bindPipeline(a,f);let U=n._geometry.subGeometries[h].lodLevels[n.lodLevel];F.drawIndexed(a,U.indexCount,1,U.indexStart,0,l.index)}}}}recordRenderPass2(e,t,r,i,a,o=!1){if(!this.enable)return;let n=this;for(let l=0;l<this.materials.length;l++){let u=this.materials[l].getPass(t);if(!u||u.length==0)return;let c=n.object3D.transform._worldMatrix;for(let f=0;f<u.length;f++){const g=u[f];F.bindPipeline(a,g);let x=n._geometry.subGeometries[l].lodLevels[n.lodLevel];F.drawIndexed(a,x.indexCount,1,x.indexStart,0,c.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,r,i){let a=this,o=e.scene.envMap;for(let n=0;n<a.materials.length;n++){let h=a.materials[n].getPass(t);if(h)for(let u=0;u<h.length;u++){const f=h[u];if(f.shaderState.splitTexture){let S=Ct.CreateSplitTexture(a.instanceID);f.setTexture("splitTexture_Map",S)}!a._ignoreEnvMap&&f.envMap!=o&&f.setTexture("envMap",o),f.prefilterMap||f.setTexture("prefilterMap",o);let g=ne.getReflectionEntries(e.scene);if(!f.reflectionMap&&g&&g.reflectionMap&&(f.setTexture("reflectionMap",g.reflectionMap),f.setStorageBuffer("reflectionBuffer",g.storageGPUBuffer)),f.pipeline){f.apply(a._geometry,r,()=>a.noticeShaderChange());continue}let p=m.res.getTexture("BRDFLUT");f.setTexture("brdflutMap",p);let A=m.getRenderJob(e).shadowMapPassRenderer;A&&A.depth2DArrayTexture&&f.setTexture("shadowMap",m.getRenderJob(e).shadowMapPassRenderer.depth2DArrayTexture);let U=m.getRenderJob(e).pointLightShadowRenderer;U&&U.cubeArrayTexture&&f.setTexture("pointShadowMap",U.cubeArrayTexture);let x=gr.iesTexture;x&&f.setTexture("iesTextureArrayMap",x),r.irradianceBuffer&&r.irradianceBuffer.length>0&&(f.setTexture("irradianceMap",r.irradianceBuffer[0]),f.setTexture("irradianceDepthMap",r.irradianceBuffer[1]));let v=ne.getLightEntries(e.scene);v&&(f.setStorageBuffer("lightBuffer",v.storageGPUBuffer),v.irradianceVolume&&f.setUniformBuffer("irradianceData",v.irradianceVolume.irradianceVolumeBuffer)),i&&(f.setStorageBuffer("clustersUniform",i.clustersUniformBuffer),f.setStorageBuffer("lightAssignBuffer",i.lightAssignBuffer),f.setStorageBuffer("assignTable",i.assignTableBuffer),f.setStorageBuffer("clusterBuffer",i.clusterBuffer)),f.apply(a._geometry,r),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 r=this._materials[t];me.getInstance().detached(r,this),me.getInstance().hasReference(r)||r.destroy(e)}super.beforeDestroy(e)}destroy(e){super.destroy(e),this._geometry=void 0,this._materials.length=0,this._combineShaderRefection=void 0}}Co([Oi],Nr.prototype,"materials"),Co([Oi],Nr.prototype,"castShadow"),Co([Oi],Nr.prototype,"castGI");class At{instanceID;name;enable=!0;_defaultSubShader;_shader;constructor(){this.instanceID=It()}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 r of t)r.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 r of t)r.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 At;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 Mh=`
|
|
5746
5746
|
#include "GlobalUniform"
|
|
5747
5747
|
|
|
5748
|
+
// Constants
|
|
5749
|
+
const ALPHA_THRESHOLD: f32 = 0.00392156863; // 1.0 / 255.0
|
|
5750
|
+
const COV_COMPENSATION: f32 = 0.3;
|
|
5751
|
+
const MAX_SPLAT_SIZE: f32 = 1024.0;
|
|
5752
|
+
const MIN_LAMBDA: f32 = 0.1;
|
|
5753
|
+
const LOG_255: f32 = 5.541263545; // log(255.0) - natural log for WGSL
|
|
5754
|
+
|
|
5748
5755
|
struct MaterialUniform {
|
|
5749
5756
|
modelMatrix: mat4x4<f32>,
|
|
5750
5757
|
tex_params: vec4<f32>, // [numSplats, texWidth, validCount, visBoost]
|
|
@@ -5764,107 +5771,92 @@ struct InstanceData {
|
|
|
5764
5771
|
@group(1) @binding(3) var transformB: texture_2d<f32>;
|
|
5765
5772
|
@group(1) @binding(4) var splatOrder: texture_2d<u32>;
|
|
5766
5773
|
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5774
|
+
struct SplatData {
|
|
5775
|
+
center: vec3f,
|
|
5776
|
+
covA: vec3f,
|
|
5777
|
+
covB: vec3f,
|
|
5778
|
+
};
|
|
5771
5779
|
|
|
5772
|
-
//
|
|
5773
|
-
fn
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5780
|
+
// Helper function to discard splat
|
|
5781
|
+
fn discardSplat() -> VSOut {
|
|
5782
|
+
var o: VSOut;
|
|
5783
|
+
o.member = vec4f(0.0, 0.0, 2.0, 1.0);
|
|
5784
|
+
o.vColor = vec4f(0.0);
|
|
5785
|
+
o.vTexCoord = vec2f(0.0);
|
|
5786
|
+
return o;
|
|
5787
|
+
}
|
|
5788
|
+
|
|
5789
|
+
// === calcSplatUV() - returns optional UV ===
|
|
5790
|
+
fn calcSplatUV(orderId: u32, textureWidth: u32, numSplats: u32) -> vec2<i32> {
|
|
5781
5791
|
let orderUV = vec2<i32>(
|
|
5782
5792
|
i32(orderId % textureWidth),
|
|
5783
5793
|
i32(orderId / textureWidth)
|
|
5784
5794
|
);
|
|
5785
5795
|
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
splatUV = vec2<i32>(
|
|
5796
|
+
let splatId = textureLoad(splatOrder, orderUV, 0).r;
|
|
5797
|
+
return vec2<i32>(
|
|
5789
5798
|
i32(splatId % textureWidth),
|
|
5790
5799
|
i32(splatId / textureWidth)
|
|
5791
5800
|
);
|
|
5792
|
-
|
|
5793
|
-
return true;
|
|
5794
|
-
}
|
|
5795
|
-
|
|
5796
|
-
// === getCenter() - returns vec3 ===
|
|
5797
|
-
fn getCenter() -> vec3f {
|
|
5798
|
-
tA = textureLoad(transformA, splatUV, 0);
|
|
5799
|
-
return vec3f(bitcast<f32>(tA.x), bitcast<f32>(tA.y), bitcast<f32>(tA.z));
|
|
5800
5801
|
}
|
|
5801
5802
|
|
|
5802
|
-
//
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
covB: vec3f,
|
|
5806
|
-
};
|
|
5807
|
-
|
|
5808
|
-
// === getCovariance() - returns struct ===
|
|
5809
|
-
fn getCovariance() -> CovarianceData {
|
|
5810
|
-
let tB = textureLoad(transformB, splatUV, 0);
|
|
5803
|
+
// === getSplatData() - unified texture loading ===
|
|
5804
|
+
fn getSplatData(splatUV: vec2<i32>) -> SplatData {
|
|
5805
|
+
var data: SplatData;
|
|
5811
5806
|
|
|
5812
|
-
//
|
|
5807
|
+
// Load both textures once
|
|
5808
|
+
let tA = textureLoad(transformA, splatUV, 0);
|
|
5809
|
+
let tB = textureLoad(transformB, splatUV, 0);
|
|
5813
5810
|
let tC = unpack2x16float(tA.w);
|
|
5814
5811
|
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
result.covB = vec3f(tC.x, tC.y, tB.w);
|
|
5812
|
+
// Extract center
|
|
5813
|
+
data.center = vec3f(bitcast<f32>(tA.x), bitcast<f32>(tA.y), bitcast<f32>(tA.z));
|
|
5818
5814
|
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
// === getRotationMatrix() - returns mat3x3 ===
|
|
5823
|
-
fn getRotationMatrix() -> mat3x3f {
|
|
5824
|
-
let cov_data = getCovariance();
|
|
5825
|
-
let covA = cov_data.covA;
|
|
5826
|
-
let covB = cov_data.covB;
|
|
5815
|
+
// Extract covariance
|
|
5816
|
+
data.covA = tB.xyz;
|
|
5817
|
+
data.covB = vec3f(tC.x, tC.y, tB.w);
|
|
5827
5818
|
|
|
5828
|
-
return
|
|
5829
|
-
vec3f(1.0 - 2.0 * (covA.z * covA.z + covB.x * covB.x), 2.0 * (covA.y * covA.z + covB.y * covB.x), 2.0 * (covA.y * covB.x - covB.y * covA.z)),
|
|
5830
|
-
vec3f(2.0 * (covA.y * covA.z - covB.y * covB.x), 1.0 - 2.0 * (covA.y * covA.y + covB.x * covB.x), 2.0 * (covA.z * covB.x + covA.y * covB.y)),
|
|
5831
|
-
vec3f(2.0 * (covA.y * covB.x + covB.y * covA.z), 2.0 * (covA.z * covB.x - covA.y * covB.y), 1.0 - 2.0 * (covA.y * covA.y + covA.z * covA.z))
|
|
5832
|
-
);
|
|
5819
|
+
return data;
|
|
5833
5820
|
}
|
|
5834
5821
|
|
|
5835
5822
|
// === calcV1V2() - returns vec4 ===
|
|
5836
5823
|
fn calcV1V2(splat_cam: vec3f, covA: vec3f, covB: vec3f, W: mat3x3f, viewport: vec2f, projMat: mat4x4f) -> vec4f {
|
|
5824
|
+
// Construct symmetric covariance matrix
|
|
5837
5825
|
let Vrk = mat3x3f(
|
|
5838
5826
|
vec3f(covA.x, covA.y, covA.z),
|
|
5839
5827
|
vec3f(covA.y, covB.x, covB.y),
|
|
5840
5828
|
vec3f(covA.z, covB.y, covB.z)
|
|
5841
5829
|
);
|
|
5842
5830
|
|
|
5831
|
+
// Calculate Jacobian
|
|
5843
5832
|
let focal = viewport.x * projMat[0][0];
|
|
5844
|
-
|
|
5845
|
-
let J1 = focal
|
|
5846
|
-
let J2 = -J1
|
|
5833
|
+
let inv_z = 1.0 / splat_cam.z;
|
|
5834
|
+
let J1 = focal * inv_z;
|
|
5835
|
+
let J2 = -J1 * inv_z * splat_cam.xy;
|
|
5847
5836
|
let J = mat3x3f(
|
|
5848
5837
|
vec3f(J1, 0.0, J2.x),
|
|
5849
5838
|
vec3f(0.0, J1, J2.y),
|
|
5850
5839
|
vec3f(0.0, 0.0, 0.0)
|
|
5851
5840
|
);
|
|
5852
5841
|
|
|
5842
|
+
// Project covariance to screen space
|
|
5853
5843
|
let T = W * J;
|
|
5854
5844
|
let cov = transpose(T) * Vrk * T;
|
|
5855
5845
|
|
|
5856
|
-
|
|
5846
|
+
// Eigenvalue decomposition with compensation
|
|
5847
|
+
let diagonal1 = cov[0][0] + COV_COMPENSATION;
|
|
5857
5848
|
let offDiagonal = cov[0][1];
|
|
5858
|
-
let diagonal2 = cov[1][1] +
|
|
5849
|
+
let diagonal2 = cov[1][1] + COV_COMPENSATION;
|
|
5859
5850
|
|
|
5860
5851
|
let mid = 0.5 * (diagonal1 + diagonal2);
|
|
5861
|
-
let radius = length(vec2f((diagonal1 - diagonal2)
|
|
5852
|
+
let radius = length(vec2f((diagonal1 - diagonal2) * 0.5, offDiagonal));
|
|
5862
5853
|
let lambda1 = mid + radius;
|
|
5863
|
-
let lambda2 = max(mid - radius,
|
|
5854
|
+
let lambda2 = max(mid - radius, MIN_LAMBDA);
|
|
5864
5855
|
let diagonalVector = normalize(vec2f(offDiagonal, lambda1 - diagonal1));
|
|
5865
5856
|
|
|
5866
|
-
|
|
5867
|
-
let
|
|
5857
|
+
// Calculate axis vectors with size clamping
|
|
5858
|
+
let v1 = min(sqrt(2.0 * lambda1), MAX_SPLAT_SIZE) * diagonalVector;
|
|
5859
|
+
let v2 = min(sqrt(2.0 * lambda2), MAX_SPLAT_SIZE) * vec2f(diagonalVector.y, -diagonalVector.x);
|
|
5868
5860
|
|
|
5869
5861
|
// WebGPU Y-axis flip: WebGPU NDC Y goes from top(-1) to bottom(1), opposite of WebGL
|
|
5870
5862
|
return vec4f(v1.x, -v1.y, v2.x, -v2.y);
|
|
@@ -5878,135 +5870,117 @@ struct InstanceData {
|
|
|
5878
5870
|
@builtin(instance_index) iid : u32,
|
|
5879
5871
|
@location(0) position: vec3<f32> // vertex_position from mesh (x, y, local_index)
|
|
5880
5872
|
) -> VSOut {
|
|
5881
|
-
var o: VSOut;
|
|
5882
|
-
let discardVec = vec4f(0.0, 0.0, 2.0, 1.0);
|
|
5883
|
-
|
|
5884
5873
|
// Calculate splat ID
|
|
5885
|
-
// orderId = vertex_id_attrib + uint(vertex_position.z)
|
|
5886
|
-
// In our case: vertex_id_attrib = iid * batchSize
|
|
5887
5874
|
let batchSize = u32(materialUniform.pixelCull.w);
|
|
5888
|
-
let
|
|
5889
|
-
let local_splat_index = u32(position.z);
|
|
5890
|
-
let orderId = base_splat_index + local_splat_index;
|
|
5875
|
+
let orderId = iid * batchSize + u32(position.z);
|
|
5891
5876
|
|
|
5892
|
-
//
|
|
5893
|
-
let
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
o.member = discardVec;
|
|
5898
|
-
o.vColor = vec4f(0.0);
|
|
5899
|
-
o.vTexCoord = vec2f(0.0);
|
|
5900
|
-
return o;
|
|
5877
|
+
// Early bounds check
|
|
5878
|
+
let textureWidth = u32(materialUniform.tex_params.y);
|
|
5879
|
+
let numSplats = u32(materialUniform.tex_params.x);
|
|
5880
|
+
if (orderId >= numSplats) {
|
|
5881
|
+
return discardSplat();
|
|
5901
5882
|
}
|
|
5902
5883
|
|
|
5903
|
-
//
|
|
5904
|
-
let
|
|
5884
|
+
// Calculate splat UV and load all data in one go
|
|
5885
|
+
let splatUV = calcSplatUV(orderId, textureWidth, numSplats);
|
|
5886
|
+
let splatData = getSplatData(splatUV);
|
|
5887
|
+
|
|
5888
|
+
// Load color early for alpha test
|
|
5889
|
+
let color = textureLoad(splatColor, splatUV, 0);
|
|
5890
|
+
if (color.a < ALPHA_THRESHOLD) {
|
|
5891
|
+
return discardSplat();
|
|
5892
|
+
}
|
|
5905
5893
|
|
|
5906
|
-
//
|
|
5894
|
+
// Transform matrices
|
|
5895
|
+
let matrix_model = materialUniform.modelMatrix;
|
|
5907
5896
|
let matrix_view = globalUniform.viewMat;
|
|
5908
5897
|
let matrix_projection = globalUniform.projMat;
|
|
5909
|
-
let matrix_model = materialUniform.modelMatrix;
|
|
5910
|
-
|
|
5911
5898
|
let model_view = matrix_view * matrix_model;
|
|
5912
|
-
let splat_cam = model_view * vec4f(center, 1.0);
|
|
5913
|
-
let splat_proj = matrix_projection * splat_cam;
|
|
5914
5899
|
|
|
5915
|
-
//
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
return
|
|
5900
|
+
// Transform center to camera and clip space
|
|
5901
|
+
let splat_cam = model_view * vec4f(splatData.center, 1.0);
|
|
5902
|
+
|
|
5903
|
+
// Early depth culling
|
|
5904
|
+
if (splat_cam.z <= 0.0) {
|
|
5905
|
+
return discardSplat();
|
|
5921
5906
|
}
|
|
5922
5907
|
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5908
|
+
let splat_proj = matrix_projection * splat_cam;
|
|
5909
|
+
|
|
5910
|
+
// Frustum culling with NDC check
|
|
5911
|
+
let inv_w = 1.0 / splat_proj.w;
|
|
5912
|
+
let ndc = splat_proj.xyz * inv_w;
|
|
5913
|
+
if (ndc.x < -1.0 || ndc.x > 1.0 ||
|
|
5914
|
+
ndc.y < -1.0 || ndc.y > 1.0 ||
|
|
5928
5915
|
ndc.z < 0.0 || ndc.z > 1.0) {
|
|
5929
|
-
|
|
5930
|
-
o.vColor = vec4f(0.0);
|
|
5931
|
-
o.vTexCoord = vec2f(0.0);
|
|
5932
|
-
return o;
|
|
5916
|
+
return discardSplat();
|
|
5933
5917
|
}
|
|
5934
5918
|
|
|
5935
|
-
//
|
|
5936
|
-
let cov_data = getCovariance();
|
|
5937
|
-
|
|
5919
|
+
// Calculate v1v2 (screen-space ellipse axes)
|
|
5938
5920
|
let viewport = vec2f(globalUniform.windowWidth, globalUniform.windowHeight);
|
|
5939
|
-
let
|
|
5940
|
-
|
|
5941
|
-
// get color
|
|
5942
|
-
let color = textureLoad(splatColor, splatUV, 0);
|
|
5943
|
-
if (color.a < 1.0 / 255.0) {
|
|
5944
|
-
o.member = discardVec;
|
|
5945
|
-
o.vColor = vec4f(0.0);
|
|
5946
|
-
o.vTexCoord = vec2f(0.0);
|
|
5947
|
-
return o;
|
|
5948
|
-
}
|
|
5921
|
+
let W = transpose(mat3x3f(model_view[0].xyz, model_view[1].xyz, model_view[2].xyz));
|
|
5922
|
+
let v1v2 = calcV1V2(splat_cam.xyz, splatData.covA, splatData.covB, W, viewport, matrix_projection);
|
|
5949
5923
|
|
|
5950
|
-
//
|
|
5951
|
-
let scale = min(1.0, sqrt(
|
|
5924
|
+
// Calculate scale based on alpha (optimized formula)
|
|
5925
|
+
let scale = min(1.0, sqrt(LOG_255 + log(color.a)) * 0.5);
|
|
5952
5926
|
|
|
5953
|
-
//
|
|
5927
|
+
// Apply visBoost (size multiplier)
|
|
5954
5928
|
let visBoost = materialUniform.tex_params.w;
|
|
5955
|
-
|
|
5929
|
+
let v1v2_scaled = v1v2 * (scale * visBoost);
|
|
5956
5930
|
|
|
5957
|
-
// Pixel coverage culling
|
|
5958
|
-
let
|
|
5959
|
-
let
|
|
5931
|
+
// Pixel coverage culling (vectorized squared length calculation)
|
|
5932
|
+
let v1v2_sq = v1v2_scaled * v1v2_scaled;
|
|
5933
|
+
let v1_len_sq = v1v2_sq.x + v1v2_sq.y;
|
|
5934
|
+
let v2_len_sq = v1v2_sq.z + v1v2_sq.w;
|
|
5960
5935
|
|
|
5961
5936
|
let minPixels = materialUniform.pixelCull.x;
|
|
5962
5937
|
let maxPixels = materialUniform.pixelCull.y;
|
|
5963
|
-
let maxPixelCullDistance = materialUniform.pixelCull.z;
|
|
5964
5938
|
|
|
5965
5939
|
// Early out tiny splats
|
|
5966
5940
|
if (v1_len_sq < minPixels && v2_len_sq < minPixels) {
|
|
5967
|
-
|
|
5968
|
-
o.vColor = vec4f(0.0);
|
|
5969
|
-
o.vTexCoord = vec2f(0.0);
|
|
5970
|
-
return o;
|
|
5941
|
+
return discardSplat();
|
|
5971
5942
|
}
|
|
5972
5943
|
|
|
5973
5944
|
// Cull oversized splats
|
|
5974
5945
|
if (maxPixels > 0.0) {
|
|
5946
|
+
let maxPixelCullDistance = materialUniform.pixelCull.z;
|
|
5975
5947
|
let splatDistance = length(splat_cam.xyz);
|
|
5976
5948
|
if (maxPixelCullDistance <= 0.0 || splatDistance < maxPixelCullDistance) {
|
|
5977
5949
|
let maxAxisSq = maxPixels * maxPixels;
|
|
5978
5950
|
if (v1_len_sq > maxAxisSq || v2_len_sq > maxAxisSq) {
|
|
5979
|
-
|
|
5980
|
-
o.vColor = vec4f(0.0);
|
|
5981
|
-
o.vTexCoord = vec2f(0.0);
|
|
5982
|
-
return o;
|
|
5951
|
+
return discardSplat();
|
|
5983
5952
|
}
|
|
5984
5953
|
}
|
|
5985
5954
|
}
|
|
5986
5955
|
|
|
5987
|
-
// Final position
|
|
5988
|
-
|
|
5989
|
-
|
|
5956
|
+
// Final position calculation (optimized)
|
|
5957
|
+
let vertex_pos = position.xy;
|
|
5958
|
+
let inv_viewport = 1.0 / viewport;
|
|
5959
|
+
let offset = (vertex_pos.x * v1v2_scaled.xy + vertex_pos.y * v1v2_scaled.zw) * inv_viewport * splat_proj.w;
|
|
5960
|
+
|
|
5961
|
+
var o: VSOut;
|
|
5962
|
+
o.member = splat_proj + vec4f(offset, 0.0, 0.0);
|
|
5963
|
+
o.vTexCoord = vertex_pos * (scale * 0.5);
|
|
5990
5964
|
o.vColor = color;
|
|
5991
5965
|
|
|
5992
5966
|
return o;
|
|
5993
5967
|
}
|
|
5994
5968
|
`,Nh=`
|
|
5995
5969
|
#include "FragmentOutput"
|
|
5970
|
+
|
|
5971
|
+
// Constants
|
|
5972
|
+
const ALPHA_THRESHOLD: f32 = 0.00392156863; // 1.0 / 255.0
|
|
5973
|
+
const GAUSSIAN_SCALE: f32 = 4.0;
|
|
5996
5974
|
|
|
5997
|
-
// === evalSplat() -
|
|
5975
|
+
// === evalSplat() - optimized gaussian evaluation ===
|
|
5998
5976
|
fn evalSplat(texCoord: vec2f, color: vec4f) -> vec4f {
|
|
5999
5977
|
let A = dot(texCoord, texCoord);
|
|
6000
|
-
var B = exp(-A * 4.0) * color.a;
|
|
6001
|
-
if (A > 1.0) {
|
|
6002
|
-
B = 0.0;
|
|
6003
|
-
}
|
|
6004
5978
|
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
5979
|
+
// Branch-less optimization using select
|
|
5980
|
+
let gaussian = exp(-A * GAUSSIAN_SCALE) * color.a;
|
|
5981
|
+
let alpha = select(gaussian, 0.0, A > 1.0 || gaussian < ALPHA_THRESHOLD);
|
|
6008
5982
|
|
|
6009
|
-
return vec4f(color.rgb,
|
|
5983
|
+
return vec4f(color.rgb, alpha);
|
|
6010
5984
|
}
|
|
6011
5985
|
|
|
6012
5986
|
@fragment
|
|
@@ -6018,7 +5992,7 @@ struct InstanceData {
|
|
|
6018
5992
|
o.color = evalSplat(vTexCoord, vColor);
|
|
6019
5993
|
return o;
|
|
6020
5994
|
}
|
|
6021
|
-
`;class ot{computes;passShader;constructor(){this.computes=[],this.passShader=new Map}addRenderPass(e,t=-1){let r=this.passShader.get(e.passType)||[];t==-1?r.push(e):r.splice(t,-1,e),this.passShader.set(e.passType,r)}removeShader(e,t=-1){let r=this.passShader.get(e.passType);if(r)if(t==-1){let i=r.indexOf(e);i!=-1&&r.splice(i)}else r.splice(t,1)}removeShaderByIndex(e,t=-1){let r=this.passShader.get(e);r&&(t==-1?this.passShader.delete(e):r.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 r of this.passShader)for(const i of r[1])i.setDefine(e,t)}hasDefine(e){for(const t of this.passShader)for(const r of t[1]){let i=r.hasDefine(e);if(i)return i}return!1}deleteDefine(e){for(const t of this.passShader)for(const r of t[1])r.deleteDefine(e)}setUniform(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniform(e,t)}setUniformFloat(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformFloat(e,t)}setUniformVector2(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformVector2(e,t)}setUniformVector3(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformVector3(e,t)}setUniformVector4(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformVector4(e,t)}setUniformColor(e,t){for(const r of this.passShader)for(const i of r[1])i.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 r of this.passShader)for(const i of r[1])i.setTexture(e,t);this.setDefine(`USE_${e.toLocaleUpperCase()}`,!0)}getTexture(e){return this.getDefaultColorShader().textures[e]}setUniformBuffer(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformBuffer(e,t)}getUniformBuffer(e){return this.getDefaultColorShader().getBuffer(e)}setStorageBuffer(e,t){for(const r of this.passShader)for(const i of r[1])i.setStorageBuffer(e,t)}getStorageBuffer(e){return this.getDefaultColorShader().getBuffer(e)}setStructStorageBuffer(e,t){for(const r of this.passShader)for(const i of r[1])i.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 ot,t=this.getDefaultShaders();for(const r of t)e.addRenderPass(r);return e}applyUniform(){for(const e of this.passShader)for(const t of e[1])t.applyUniform()}}var Gg=Object.getOwnPropertyDescriptor,Wg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Gg(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let da=class extends ot{constructor(){super();const s=new Pe("gsplat_vs_dc","gsplat_fs_dc");s.passType=H.COLOR,s.setShaderEntry("VertMain","FragMain"),s.topology=to.triangle_list,s.depthWriteEnabled=!1,s.cullMode=Et.none,s.shaderState.transparent=!0,s.shaderState.blendMode=ae.NORMAL,s.shaderState.writeMasks=[15,15],this.addRenderPass(s),this.setDefault()}setDefault(){const s=this.getDefaultColorShader(),e=new I;s.setUniform("modelMatrix",e.rawData),s.setUniform("pixelCull",new Float32Array([2,0,0,0]))}};da=Wg([wr(da,"GSplatShader")],da);class Vh extends At{_pixelCullArray=new Float32Array(4);constructor(){super(),O.register("gsplat_vs_dc",Mh),O.register("gsplat_fs_dc",Nh),this.shader=new da}setSplatTextures(e,t,r,i,a){const o=this.shader.getDefaultColorShader();o.setTexture("splatColor",e),o.setTexture("transformA",t),o.setTexture("transformB",r),o.setUniformArray("tex_params",i),a&&o.setTexture("splatOrder",a),o.shaderState.depthCompare=et.less}setTransformMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}setPixelCulling(e,t,r=0,i=128){this._pixelCullArray[0]=e,this._pixelCullArray[1]=t,this._pixelCullArray[2]=r,this._pixelCullArray[3]=i,this.shader.getDefaultColorShader().setUniform("pixelCull",this._pixelCullArray)}}class gs extends Tr{node;constructor(e){super(),this.bufferType=tr.VertexGPUBuffer,this.createVertexBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,e)}createVertexBuffer(e,t){let r=Q.device;this.byteSize=t*Float32Array.BYTES_PER_ELEMENT,this.usage=e,this.buffer&&this.destroy(),this.buffer=r.createBuffer({label:"VertexGPUBuffer",size:this.byteSize,usage:e,mappedAtCreation:!1}),this.memory=new jr,this.memoryNodes=new Map,this.memory.allocation(this.byteSize),this.node=this.memory.allocation_node(this.byteSize)}}var dt=(s=>(s[s.split=0]="split",s[s.compose=1]="compose",s[s.compose_bin=2]="compose_bin",s))(dt||{});class Ph{vertexCount=0;vertexGPUBuffer;geometryType=dt.compose;_vertexBufferLayouts;_attributeSlotLayouts;_attributeLocation;constructor(){this._vertexBufferLayouts=[],this._attributeLocation={},this._attributeSlotLayouts=[]}get vertexBufferLayouts(){return this._vertexBufferLayouts}createVertexBuffer(e,t){switch(this.geometryType){case dt.split:this.createSplitVertexBuffer(e,t);break;case dt.compose:this.createComposeVertexBuffer(e,t);break;case dt.compose_bin:this.createComposBinVertexBuffer(e,t);break}}createSplitVertexBuffer(e,t){let r=0;for(let i=0;i<t.attributes.length;i++){const a=t.attributes[i];if(a.name=="index")continue;this._attributeLocation[a.name]=a.location;let o={name:a.name,format:a.format,offset:0,shaderLocation:a.location,stride:qr[a.format]};this._attributeSlotLayouts[a.location]=[o];let n=e.get(a.name);n||(n={attribute:a.name,data:new Float32Array(a.size*this.vertexCount)},e.set(a.name,n));let l=n.data.length/o.stride;this.vertexCount!=0&&this.vertexCount!=l&&console.error(" vertex count not match attribute count"),this.vertexCount=l,this._vertexBufferLayouts[a.location]={name:a.name,arrayStride:a.size*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[a.location],offset:r*4,size:this.vertexCount*a.size*4},r+=this.vertexCount*a.size}this.vertexGPUBuffer=new gs(r)}createComposeVertexBuffer(e,t){this._attributeSlotLayouts[0]=[];let r=0;for(let i=0;i<t.attributes.length;i++){const a=t.attributes[i];if(a.name=="index"||a.type=="builtin")continue;this._attributeLocation[a.name]=a.location;let o={name:a.name,format:a.format,offset:r*4,shaderLocation:a.location,stride:qr[a.format]};this._attributeSlotLayouts[0][a.location]=o;let n=e.get(a.name);if(n||(n={attribute:a.name,data:new Float32Array(a.size*this.vertexCount)},e.set(a.name,n)),n.data){let l=n.data.length/o.stride;this.vertexCount!=0&&this.vertexCount!=l&&console.error(" vertex count not match attribute count"),this.vertexCount=l}r+=a.size}this._vertexBufferLayouts[0]={name:"composeStruct",arrayStride:r*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[0],offset:0,size:this.vertexCount*r*4},this.vertexGPUBuffer=new gs(this.vertexCount*r)}createComposBinVertexBuffer(e,t){this._attributeSlotLayouts[0]=[];let r=0;for(let o=0;o<t.attributes.length;o++){const n=t.attributes[o];if(n.name=="index"||n.type=="builtin")continue;this._attributeLocation[n.name]=n.location;let l={name:n.name,format:n.format,offset:r*4,shaderLocation:n.location,stride:qr[n.format]};this._attributeSlotLayouts[0][n.location]=l;let h=e.get(n.name);if(h||(h={attribute:n.name,data:new Float32Array(n.size*this.vertexCount)},e.set(n.name,h)),h.data){let u=h.data.length/l.stride;this.vertexCount!=0&&this.vertexCount!=u&&console.error(" vertex count not match attribute count"),this.vertexCount=u}r+=n.size}let a=e.get(V.all).data.length/r;this.vertexCount=a,this._vertexBufferLayouts[0]={name:"composeStruct",arrayStride:r*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[0],offset:0,size:this.vertexCount*r*4},this.vertexGPUBuffer=new gs(this.vertexCount*r)}upload(e,t){if(this.vertexGPUBuffer){switch(this.geometryType){case dt.split:{let r=this._attributeLocation[e],i=this._vertexBufferLayouts[r];this.vertexGPUBuffer.node.setFloat32Array(i.offset/4,t.data)}break;case dt.compose:for(let r=0;r<this.vertexCount;r++){const i=this._attributeSlotLayouts[0][this._attributeLocation[e]];for(let a=0;a<i.stride;a++){let o=t.data[r*i.stride+a],n=r*(this._vertexBufferLayouts[0].arrayStride/4)+i.offset/4+a;this.vertexGPUBuffer.node.setFloat(o,n)}}break;case dt.compose_bin:this.vertexGPUBuffer.node.setFloat32Array(0,t.data);break}this.vertexGPUBuffer?.apply()}}updateAttributes(e){switch(this.geometryType){case dt.split:for(let t=0;t<this._vertexBufferLayouts.length;t++){const r=this._vertexBufferLayouts[t];let i=e.get(r.name);this.vertexGPUBuffer.node.setFloat32Array(r.offset/4,i.data)}break;case dt.compose:for(let t=0;t<this.vertexCount;t++)this._attributeSlotLayouts.forEach(r=>{for(let i=0;i<r.length;i++){const a=r[i];let o=e.get(a.name);for(let n=0;n<a.stride;n++){let l=o.data[t*a.stride+n],h=t*(this._vertexBufferLayouts[0].arrayStride/4)+a.offset/4+n;this.vertexGPUBuffer.node.setFloat(l,h)}}});break;case dt.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 kh extends Tr{indicesNode;constructor(e){super(),this.bufferType=tr.IndicesGPUBuffer,this.createIndicesBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.INDEX|GPUBufferUsage.INDIRECT,e)}createIndicesBuffer(e,t){let r=Q.device;if(this.byteSize=t.length*4,this.usage=e,this.buffer&&this.destroy(),this.buffer=r.createBuffer({label:"IndicesGPUBuffer",size:this.byteSize,usage:e,mappedAtCreation:!1}),this.memory=new jr,this.memoryNodes=new Map,this.memory.allocation(this.byteSize),t){this.indicesNode=this.memory.allocation_node(t.length*4);const i=t.buffer instanceof ArrayBuffer?t.buffer:new Uint8Array(t.buffer).buffer;this.indicesNode.setArrayBuffer(0,i),this.apply()}}}class Lh{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 kh(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 Oh{lodLevels}class Ie{instanceID;name;subGeometries=[];morphTargetsRelative;morphTargetDictionary;skinNames;bindPose;blendShapeData;vertexDim;vertexCount=0;_bounds;_attributeMap;_attributes;_indicesBuffer;_vertexBuffer;_onChange=!0;_wireframeLines;constructor(){this.instanceID=It(),this._attributeMap=new Map,this._attributes=[],this._vertexBuffer=new Ph}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 Fe(new d,new d(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 r=e.data[t*3+0],i=e.data[t*3+1],a=e.data[t*3+2];this._bounds.min.x>r&&(this._bounds.min.x=r),this._bounds.min.y>i&&(this._bounds.min.y=i),this._bounds.min.z>a&&(this._bounds.min.z=a),this._bounds.max.x<r&&(this._bounds.max.x=r),this._bounds.max.y<i&&(this._bounds.max.y=i),this._bounds.max.z<a&&(this._bounds.max.z=a)}this._bounds.setFromMinMax(this._bounds.min,this._bounds.max)}return this._bounds}set bounds(e){this._bounds=e}addSubGeometry(...e){let t=new Oh;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 Lh,this._indicesBuffer.createIndicesBuffer(t)}}setAttribute(e,t){if(e==V.indices)this.setIndices(t);else{let r={attribute:e,data:t};this._attributeMap.set(e,r),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==dt.split||this.geometryType==dt.compose){let e=this.getAttribute(V.position),t=this.getAttribute(V.indices);if(t&&e&&t.data.length>0){let r=e.data,i=[];for(let a=0;a<t.data.length/3;a++){const o=t.data[a*3+0],n=t.data[a*3+1],l=t.data[a*3+2];let h=new d(r[o*3+0],r[o*3+1],r[o*3+2]),u=new d(r[n*3+0],r[n*3+1],r[n*3+2]),c=new d(r[l*3+0],r[l*3+1],r[l*3+2]);i.push(h,u),i.push(u,c),i.push(c,h)}return this._wireframeLines=i,i}}else if(this.geometryType==dt.compose_bin){let e=this.getAttribute(V.all),t=this.vertexDim,r=this.getAttribute(V.indices);if(r&&e&&r.data.length>0){let i=e.data,a=[];for(let o=0;o<r.data.length/3;o++){const n=r.data[o*3+0],l=r.data[o*3+1],h=r.data[o*3+2];let u=new d(i[n*t+0],i[n*t+1],i[n*t+2]),c=new d(i[l*t+0],i[l*t+1],i[l*t+2]),f=new d(i[h*t+0],i[h*t+1],i[h*t+2]);a.push(u,c),a.push(c,f),a.push(f,u)}return this._wireframeLines=a,a}}return null}compute(){this._indicesBuffer&&this._indicesBuffer.compute(),this._vertexBuffer&&this._vertexBuffer.compute()}static crossA=d.UP.clone();static crossB=d.UP.clone();static crossRet=d.UP.clone();static point1=d.UP.clone();static point2=d.UP.clone();static point3=d.UP.clone();computeNormals(){let e=this.getAttribute(V.position),t=this.getAttribute(V.normal),r=this.getAttribute(V.indices);if(!e||!t||!r)return this;let i=r.data.length/3,a=Ie.point1,o=Ie.point2,n=Ie.point3,l=Ie.crossA,h=Ie.crossB,u=Ie.crossRet;for(let c=0;c<i;c++){let f=r.data[c*3],g=r.data[c*3+1],p=r.data[c*3+2];a.set(e.data[f*3],e.data[f*3+1],e.data[f*3+2]),o.set(e.data[g*3],e.data[g*3+1],e.data[g*3+2]),n.set(e.data[p*3],e.data[p*3+1],e.data[p*3+2]),d.sub(a,o,l).normalize(),d.sub(a,n,h).normalize();let A=l.crossProduct(h,u).normalize();t.data[f*3]=t.data[g*3]=t.data[p*3]=A.x,t.data[f*3+1]=t.data[g*3+1]=t.data[p*3+1]=A.y,t.data[f*3+2]=t.data[g*3+2]=t.data[p*3+2]=A.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 zh extends Ie{batchSize;constructor(e=128){super(),this.batchSize=e;const t=new Float32Array(12*e);for(let i=0;i<e;++i)t.set([-2,-2,i,2,-2,i,2,2,i,-2,2,i],i*12);const r=new Uint32Array(6*e);for(let i=0;i<e;++i){const a=i*4;r.set([0+a,1+a,2+a,0+a,2+a,3+a],i*6)}this.setAttribute(V.position,t),this.setIndices(r),this.addSubGeometry({indexStart:0,indexCount:r.length,vertexStart:0,vertexCount:t.length/3,firstStart:0,index:0,topology:0})}}class So extends je{_dataBuffer;create(e,t,r,i=!1){let a=Q.device;const o=Math.ceil(e*4/256)*256;this.format=X.rgba8unorm,this.mipmapCount=Math.floor(i?Math.log2(e):1),this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const n=this._dataBuffer=a.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});a.queue.writeBuffer(n,0,r);const l=F.beginCommandEncoder();return l.copyBufferToTexture({buffer:n,bytesPerRow:o},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),F.endCommandEncoder(l),i&&dr.webGPUGenerateMipmap(this),this}updateTexture(e,t,r){let i=Q.device;const a=Math.ceil(e*4/256)*256;this.mipmapCount=Math.floor(Math.log2(e)),this._dataBuffer&&this._dataBuffer.destroy(),this._dataBuffer=null;const o=this._dataBuffer=i.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(o,0,r);const n=F.beginCommandEncoder();n.copyBufferToTexture({buffer:o,bytesPerRow:a},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),F.endCommandEncoder(n),this.gpuSampler=i.createSampler(this),this.mipmapCount>1&&dr.webGPUGenerateMipmap(this)}}class Gh extends je{_dataBuffer;create(e,t,r){let i=Q.device;const a=e*4*4;this.format=X.rgba32uint,this.createTextureDescriptor(e,t,1,this.format);const n=this._dataBuffer=i.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(n,0,r.buffer);const l=i.createCommandEncoder();return l.copyBufferToTexture({buffer:n,bytesPerRow:a},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),i.queue.submit([l.finish()]),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="uint",this.gpuSampler=i.createSampler({}),this}updateTexture(e,t,r){let i=Q.device;const a=e*4*4;i.queue.writeTexture({texture:this.getGPUTexture()},r.buffer,{bytesPerRow:a},{width:e,height:t,depthOrArrayLayers:1})}}class Wh extends je{_dataBuffer;create(e,t,r){let i=Q.device;const a=e*4;this.format=X.r32uint,this.createTextureDescriptor(e,t,1,this.format);const n=this._dataBuffer=i.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(n,0,r.buffer);const l=i.createCommandEncoder();return l.copyBufferToTexture({buffer:n,bytesPerRow:a},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),i.queue.submit([l.finish()]),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="uint",this.gpuSampler=i.createSampler({}),this}updateTexture(e,t,r){let i=Q.device;const a=e*4;i.queue.writeTexture({texture:this.getGPUTexture()},r.buffer,{bytesPerRow:a},{width:e,height:t,depthOrArrayLayers:1})}}const Jh=new Float32Array(1),Jg=new Int32Array(Jh.buffer);let ri=function(s){Jh[0]=s;const e=Jg[0];let t=e>>16&32768,r=e>>12&2047;const i=e>>23&255;return i<103?t:i>142?(t|=31744,t|=(i==255?1:0)&&e&8388607,t):i<114?(r|=2048,t|=(r>>114-i)+(r>>113-i&1),t):(t|=i-112<<10|r>>1,t+=r&1,t)};class _o extends je{uint16Array;floatArray;_dataBuffer;create(e,t,r=null,i=!0){if(r==null){r=[];for(let a=0,o=e*t*4;a<o;a++)r[a]=0}return this.updateTexture(e,t,r,i),this}updateTexture(e,t,r,i=!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=r;let a=Q.device;const o=e*4*2;this.format=X.rgba16float,this.mipmapCount=Math.floor(i?Math.log2(e):1),this.createTextureDescriptor(e,t,this.mipmapCount,this.format),(!this.uint16Array||this.uint16Array.length!=r.length)&&(this.uint16Array=new Uint16Array(r.length));let n=this.uint16Array;for(let u=0,c=n.length;u<c;u++)n[u]=ri(r[u]);const l=this._dataBuffer=a.createBuffer({size:n.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});a.queue.writeBuffer(l,0,n);const h=F.beginCommandEncoder();h.copyBufferToTexture({buffer:l,bytesPerRow:o},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),this.useMipmap||(this.samplerBindingLayout.type="filtering",this.textureBindingLayout.sampleType="float"),F.endCommandEncoder(h),this.gpuSampler=a.createSampler(this),this.gpuTexture=this.getGPUTexture(),this.mipmapCount>1&&dr.webGPUGenerateMipmap(this)}}var Zg=Object.getOwnPropertyDescriptor,Yg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Zg(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let ga=class extends Nr{count=0;size=new j;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(s){this.count=s.count,this._fullCount=s.count,this.size=this.evalTextureSize(s.count),this.buildColor(s),this.buildTransform(s),this.texParams=new Float32Array([this.count,this.size.x,this.count,1]),this._positions=s.position;const e=this.size.x*this.size.y;this._orderData=new Uint32Array(e);for(let t=0;t<e;t++)this._orderData[t]=t<this.count?t:this.count>0?this.count-1:0;this.splatOrder=new Wh().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 Vh,this.geometry=new zh(this._batchSize),this.materials=[this.gsplatMaterial],this.instanceCount=0}onBeforeUpdate(s){this.count>0&&s?.camera&&(this._lodEnabled&&this.updateLOD(s),s.camera.viewMatrix&&this.scheduleOrder(s.camera.viewMatrix))}updateLOD(s){if(!this._worldPositions||this._fullCount===0)return;const t=s.camera.viewMatrix.rawData,r=-(t[0]*t[12]+t[1]*t[13]+t[2]*t[14]),i=-(t[4]*t[12]+t[5]*t[13]+t[6]*t[14]),a=-(t[8]*t[12]+t[9]*t[13]+t[10]*t[14]);let o=0,n=0,l=0;const h=Math.min(100,this._fullCount);for(let A=0;A<h;A++){const U=Math.floor(A/h*this._fullCount)*3;o+=this._worldPositions[U+0],n+=this._worldPositions[U+1],l+=this._worldPositions[U+2]}o/=h,n/=h,l/=h;const u=r-o,c=i-n,f=a-l,g=Math.sqrt(u*u+c*c+f*f);let p=this._lodDistances.length;for(let A=0;A<this._lodDistances.length;A++)if(g<this._lodDistances[A]){p=A;break}if(p!==this._currentLodLevel){this._currentLodLevel=p;const A=this._lodRatios[p],U=Math.floor(this._fullCount*A);if(this._mapping){const x=this._mapping;this._mapping=new Uint32Array(Math.min(U,x.length));for(let v=0;v<this._mapping.length;v++)this._mapping[v]=x[v];this.setMapping(this._mapping)}else this.count=U,this.texParams[0]=this.count,this.texParams[2]=this.count}}setMapping(s){this._mapping=s&&s.length>0?s: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 e=this.size.x*this.size.y;for(let t=0;t<e;t++)this._orderData[t]=t<this.count?t:this.count>0?this.count-1:0;if(this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData),this._sortWorker){const t=this._worldPositions||this._positions,r=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(t);if(this._mapping)for(let i=0;i<this._mapping.length;++i){const a=this._mapping[i]*3,o=i*3;r[o+0]=t[a+0],r[o+1]=t[a+1],r[o+2]=t[a+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(s){this.texParams[3]=Math.max(0,s)}setSortThrottle(s){this._minIntervalMs=Math.max(0,s|0)}setAdaptiveSorting(s){this._adaptiveSorting=s}setLOD(s,e,t){this._lodEnabled=s,e&&(this._lodDistances=e),t&&(this._lodRatios=t)}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(s,e=0,t=0){this._minPixelCoverage=Math.max(0,s),this._maxPixelCoverage=Math.max(0,e),this._maxPixelCullDistance=Math.max(0,t)}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(s){let e=Math.ceil(Math.sqrt(s));const t=64;e=Math.ceil(e/t)*t;const r=Math.ceil(s/e);return new j(e,r)}buildColor(s){const e=this.size.x|0,t=this.size.y|0,r=new Uint8Array(e*t*4),i=.28209479177387814,a=s.count,o=s.sh?.coeffs,n=o?o.length/(3*a):1;for(let l=0;l<a;l++){let h=.5,u=.5,c=.5;if(o&&n>=1){const p=l*n*3;h=.5+o[p+0]*i,u=.5+o[p+n+0]*i,c=.5+o[p+2*n+0]*i}const f=s.opacity?1/(1+Math.exp(-s.opacity[l])):1,g=l*4;r[g+0]=Math.max(0,Math.min(255,Math.floor(h*255))),r[g+1]=Math.max(0,Math.min(255,Math.floor(u*255))),r[g+2]=Math.max(0,Math.min(255,Math.floor(c*255))),r[g+3]=Math.max(0,Math.min(255,Math.floor(f*255)))}this.splatColor=new So().create(e,t,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(s){const e=this.size.x|0,t=this.size.y|0,r=s.count,i=new Uint32Array(e*t*4),a=new Array(e*t*4).fill(0),o=new ArrayBuffer(4),n=new Float32Array(o),l=new Uint32Array(o),h=g=>(n[0]=g,l[0]),u=s.position,c=s.rotation,f=s.scale;for(let g=0;g<r;g++){const p=g*4,A=u[g*3+0],U=u[g*3+1],x=u[g*3+2];i[p+0]=h(A),i[p+1]=h(U),i[p+2]=h(x);let v=0,S=0,C=0,_=1;if(c){v=c[g*4+0],S=c[g*4+1],C=c[g*4+2],_=c[g*4+3];const Wt=1/Math.hypot(v,S,C,_);v*=Wt,S*=Wt,C*=Wt,_*=Wt}let y=1,b=1,w=1;f&&(y=Math.exp(f[g*3+0]),b=Math.exp(f[g*3+1]),w=Math.exp(f[g*3+2]));const R=v+v,E=S+S,N=C+C,z=v*R,Y=v*E,ee=v*N,oe=S*E,te=S*N,ge=C*N,Ce=_*R,J=_*E,ce=_*N,he=1-(oe+ge),Ue=Y+ce,xe=ee-J,Ve=Y-ce,Ee=1-(z+ge),ye=te+Ce,Ne=ee+J,lt=te-Ce,pr=1-(z+oe),Nt=he*y,Qt=Ue*y,Rt=xe*y,Vt=Ve*b,_t=Ee*b,mr=ye*b,Ar=Ne*w,Ur=lt*w,xr=pr*w,pi=Nt*Nt+Vt*Vt+Ar*Ar,Zr=Nt*Qt+Vt*_t+Ar*Ur,vr=Nt*Rt+Vt*mr+Ar*xr,mi=Qt*Qt+_t*_t+Ur*Ur,Yr=Qt*Rt+_t*mr+Ur*xr,Ai=Rt*Rt+mr*mr+xr*xr,Br=p;a[Br+0]=pi,a[Br+1]=Zr,a[Br+2]=vr,a[Br+3]=Ai;const Ui=ri(mi)&65535,xi=ri(Yr)&65535;i[p+3]=Ui|xi<<16}this.transformA=new Gh().create(e,t,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 _o().create(e,t,a,!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 s=this.object3D.transform.worldMatrix,e=this._positions,t=this._fullCount;this._worldPositions||(this._worldPositions=new Float32Array(e.length));const r=s.rawData;for(let i=0;i<t;i++){const a=i*3,o=e[a+0],n=e[a+1],l=e[a+2];this._worldPositions[a+0]=r[0]*o+r[4]*n+r[8]*l+r[12],this._worldPositions[a+1]=r[1]*o+r[5]*n+r[9]*l+r[13],this._worldPositions[a+2]=r[2]*o+r[6]*n+r[10]*l+r[14]}this._centersSent=!1}scheduleOrder(s){if(this.count===0)return;const e=this.object3D.transform.localChange;(e||!this._worldPositions)&&this.updateWorldPositions();const t=s.rawData,r=t[2],i=t[6],a=t[10],o=-(t[0]*t[12]+t[1]*t[13]+t[2]*t[14]),n=-(t[4]*t[12]+t[5]*t[13]+t[6]*t[14]),l=-(t[8]*t[12]+t[9]*t[13]+t[10]*t[14]),h=performance.now(),u=(h-this._lastSentTime)/1e3,c=Math.floor(o*1e3)^Math.floor(n*1e3)^Math.floor(l*1e3),f=Math.floor(r*1e3)^Math.floor(i*1e3)^Math.floor(a*1e3),g=c^f;if(g===this._lastViewMatrixHash&&!e)return;let p=this._minIntervalMs;if(this._adaptiveSorting&&this._minIntervalMs>0){const U=Math.abs(g-this._lastViewMatrixHash)/Math.max(u,.001);U<1e3?p=this._minIntervalMs:U<1e4?p=this._minIntervalMs*.5:p=this._minIntervalMs*.2,this._lastCameraSpeed=U}if(!(h-this._lastSentTime<p)){if(this._lastViewMatrixHash=g,this._lastSentTime=h,!this._sortWorker){this._sortWorker=this.createSortWorker(),this._sortWorker.onmessage=v=>{const S=v.data.order,C=this._orderData.buffer;this._sortWorker.postMessage({order:C},[C]);const _=new Uint32Array(S),y=this.size.x*this.size.y,b=this.count;(!this._orderData||this._orderData.length!==y)&&(this._orderData=new Uint32Array(y));const w=Math.min(b,_.length);if(this._orderData.set(_.subarray(0,w),0),w<y){const N=b>0?b-1:0;this._orderData.fill(N,w,y)}this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData);const R=Math.max(0,Math.min(this.count,v.data.count|0));this.texParams[2]=R;const E=Math.ceil(R/this._batchSize);this.instanceCount=E};const A=this._worldPositions||this._positions,U=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(A);if(this._mapping)for(let v=0;v<this._mapping.length;++v){const S=this._mapping[v]*3,C=v*3;U[C+0]=A[S+0],U[C+1]=A[S+1],U[C+2]=A[S+2]}const x=new Uint32Array(this.count);for(let v=0;v<this.count;v++)x[v]=v;this._sortWorker.postMessage({order:x.buffer,centers:U.buffer,mapping:this._mapping},[x.buffer,U.buffer]),this._centersSent=!0}if(!this._centersSent&&this._sortWorker){const A=this._worldPositions||this._positions,U=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(A);if(this._mapping)for(let x=0;x<this._mapping.length;++x){const v=this._mapping[x]*3,S=x*3;U[S+0]=A[v+0],U[S+1]=A[v+1],U[S+2]=A[v+2]}this._sortWorker.postMessage({type:"centers",centers:U.buffer,mapping:this._mapping?this._mapping:null},[U.buffer]),this._centersSent=!0}this._sortWorker.postMessage({cameraPosition:{x:o,y:n,z:l},cameraDirection:{x:-r,y:-i,z:-a}})}}createSortWorker(){function s(){let o,n,l,h,u,c=!1;const f={x:0,y:0,z:0},g={x:0,y:0,z:0},p={x:0,y:0,z:0},A={x:0,y:0,z:0};let U,x;const v=(C,_,y)=>{for(;C<=_;){const b=_+C>>1,w=y(b);if(w>0)C=b+1;else if(w<0)_=b-1;else return b}return~C},S=()=>{if(!o||!n||!h||!u)return;const C=h.x,_=h.y,y=h.z,b=u.x,w=u.y,R=u.z,E=.001;if(!c&&Math.abs(C-f.x)<E&&Math.abs(_-f.y)<E&&Math.abs(y-f.z)<E&&Math.abs(b-g.x)<E&&Math.abs(w-g.y)<E&&Math.abs(R-g.z)<E)return;c=!1,f.x=C,f.y=_,f.z=y,g.x=b,g.y=w,g.z=R;const N=n.length/3;U?.length!==N&&(U=new Uint32Array(N));let z,Y;for(let J=0;J<8;++J){const ce=(J&1?p.x:A.x)-C,he=(J&2?p.y:A.y)-_,Ue=(J&4?p.z:A.z)-y,xe=ce*b+he*w+Ue*R;J===0?z=Y=xe:(z=Math.min(z,xe),Y=Math.max(Y,xe))}x?x.fill(0):x=new Uint32Array(65537);const ee=Y-z,oe=ee<1e-6?0:1/ee*2**16;for(let J=0;J<N;++J){const ce=J*3,he=n[ce+0]-C,Ue=n[ce+1]-_,xe=n[ce+2]-y,Ve=he*b+Ue*w+xe*R,Ee=Math.floor((Ve-z)*oe);U[J]=Ee,x[Ee]++}for(let J=1;J<65537;J++)x[J]+=x[J-1];for(let J=0;J<N;J++){const ce=U[J],he=--x[ce];o[he]=J}const te=J=>U[o[J]]/oe+z,ge=()=>{const J=v(0,N-1,ce=>-te(ce));return Math.min(N,Math.abs(J))},Ce=te(N-1)>=0?ge():N;if(l)for(let J=0;J<N;++J)o[J]=l[o[J]];self.postMessage({order:o.buffer,count:Ce},[o.buffer]),o=null};self.onmessage=C=>{if(C.data.order&&(o=new Uint32Array(C.data.order)),C.data.centers){n=new Float32Array(C.data.centers),p.x=A.x=n[0],p.y=A.y=n[1],p.z=A.z=n[2];const _=n.length/3;for(let y=1;y<_;++y){const b=n[y*3+0],w=n[y*3+1],R=n[y*3+2];p.x=Math.min(p.x,b),p.y=Math.min(p.y,w),p.z=Math.min(p.z,R),A.x=Math.max(A.x,b),A.y=Math.max(A.y,w),A.z=Math.max(A.z,R)}c=!0}C.data.hasOwnProperty("mapping")&&(l=C.data.mapping?new Uint32Array(C.data.mapping):null,c=!0),C.data.cameraPosition&&(h=C.data.cameraPosition),C.data.cameraDirection&&(u=C.data.cameraDirection),S()}}const e=`(${s.toString()})()`,t=new Blob([e],{type:"application/javascript"}),r=URL.createObjectURL(t);return new Worker(r)}nodeUpdate(s,e,t,r){const i=this.object3D.transform.worldMatrix;this.gsplatMaterial.setTransformMatrix(i);const a=`${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;a!==this._lastPixelCullParams&&(this.gsplatMaterial.setPixelCulling(this._minPixelCoverage,this._maxPixelCoverage,this._maxPixelCullDistance,this._batchSize),this._lastPixelCullParams=a),this._texturesInitialized||(this.gsplatMaterial.setSplatTextures(this.splatColor,this.transformA,this.transformB,this.texParams,this.splatOrder),this._texturesInitialized=!0),super.nodeUpdate(s,e,t,r)}renderPass(s,e,t){const r=t.encoder;for(let i of this.materials){const a=i.getPass(e);if(!(!a||a.length===0))for(const o of a){if(!o.pipeline)continue;o.apply(this.geometry,t.rendererPassState||t),F.bindPipeline(r,o),F.bindGeometryBuffer(r,this.geometry);const l=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?F.drawIndexed(r,l.indexCount,this.instanceCount,l.indexStart,0,0):F.drawIndexed(r,l.indexCount,1,l.indexStart,0,0)}}}destroy(s){this._sortWorker&&(this._sortWorker.terminate(),this._sortWorker=null),super.destroy(s)}};ga=Yg([Pt(ga,"GSplatRenderer")],ga);class Fo{static maxVector=new d(Number.MAX_VALUE*.1,Number.MAX_VALUE*.1,Number.MAX_VALUE*.1);static minVector=this.maxVector.clone().multiplyScalar(-1);static genMeshMaxVector=d.ZERO.clone();static genMeshMinVector=d.ZERO.clone();static genMeshVectorList8=[new d,new d,new d,new d,new d,new d,new d,new d];static genGSplatBounds(e,t){t||=new Fe(d.ZERO,d.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let r=e.getComponent(ga);if(!r)return console.warn("genGSplatBounds: No GSplatRenderer found on object"),t;const i=r.positions,a=r.fullCount;if(!i||a===0)return console.warn("genGSplatBounds: No position data available"),t;const o=e.transform.worldMatrix,n=new d;for(let l=0;l<a;l++){const h=l*3;n.set(i[h+0],i[h+1],i[h+2]),o.transformPoint(n,n),t.expandByPoint(n)}return t.setFromMinMax(t.min,t.max),t}static genMeshBounds(e,t){let r=this.genMeshMinVector,i=this.genMeshMaxVector,a=this.genMeshVectorList8;t||=new Fe(d.ZERO,d.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let o=e.getComponents(K);for(const n of o)if(n&&n.geometry){let l=n.object3D.transform.worldMatrix;r.copy(n.geometry.bounds.min),i.copy(n.geometry.bounds.max),a[0].set(r.x,r.y,r.z),a[1].set(r.x,r.y,i.z),a[2].set(r.x,i.y,r.z),a[3].set(r.x,i.y,i.z),a[4].set(i.x,r.y,r.z),a[5].set(i.x,r.y,i.z),a[6].set(i.x,i.y,r.z),a[7].set(i.x,i.y,i.z);for(const h of a)l.transformPoint(h,h),t.expandByPoint(h)}return i.copyFrom(t.max),r.copyFrom(t.min),t.setFromMinMax(r,i),t}static transformBound(e,t,r){let i=this.genMeshMinVector.copyFrom(t.min),a=this.genMeshMaxVector.copyFrom(t.max),o=this.genMeshVectorList8;r||=new Fe(d.ZERO,d.ZERO),r.setFromMinMax(this.maxVector,this.minVector),o[0].set(i.x,i.y,i.z),o[1].set(i.x,i.y,a.z),o[2].set(i.x,a.y,i.z),o[3].set(i.x,a.y,a.z),o[4].set(a.x,i.y,i.z),o[5].set(a.x,i.y,a.z),o[6].set(a.x,a.y,i.z),o[7].set(a.x,a.y,a.z);for(const n of o)e.transformPoint(n,n),r.expandByPoint(n);return a.copyFrom(r.max),i.copyFrom(r.min),r.setFromMinMax(i,a),r}}class Zh extends Er{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 r=e.split("/"),i=this;for(;r.length>0&&i;){let a=r.shift();if(i=i.getChildByName(a,!1),!i)return null}return i}else return this.getChildByName(e,!1)}constructor(){super(),this.entityChildren=[],this.components=new Map,this._instanceID=$s().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 r=null;for(const i of this.entityChildren){if(i.name==e)return r=i,r;if(t&&(r=i.getChildByName(e,t),r))return r}return r}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 Fe,this._boundWorld=this._bound.clone(),this._isBoundChange=!0),this._isBoundChange&&(Fo.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()):Se.waitStartComponent.forEach((e,t)=>{for(;e.length>0;){const r=e.shift();r.__start(),Se.waitStartComponent.delete(r.object3D)}})}noticeComponents(e,t){for(let r of this.components.values())r[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 Xg=Object.getOwnPropertyDescriptor,Hg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Xg(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let q=class extends Zh{_isScene3D;prefabRef;serializeTag;constructor(){super(),this.transform=this.addComponent(Dt),this.transform.eventDispatcher.addEventListener(Dt.LOCAL_ONCHANGE,this.onTransformLocalChange,this)}get isScene3D(){return this._isScene3D}forChild(s){this.entityChildren.forEach(e=>{s(e),e.forChild(s)})}addComponent(s,e){if(!this.components.has(s)){let t=new s;return t.object3D=this,this.components.set(s,t),t.__init(e),Se.appendWaitStart(t),t}return this.components.get(s)}getOrAddComponent(s){let e=this.components.get(s);return e||(e=this.addComponent(s)),e}removeComponent(s){if(this.components.has(s)){let e=this.components.get(s);Se.removeWaitStart(this,e),this.components.delete(s),e.__stop(),e.beforeDestroy(),e.destroy()}}hasComponent(s){return this.components.has(s)}getComponent(s){return this.components.get(s)}getComponentFromParent(s){if(!this.parent)return null;let e=this.parent.object3D.getComponent(s);return e||this.parent.object3D.getComponentFromParent(s)}getComponentsInChild(s){let e=[],t=this.components.get(s);t&&e.push(t);for(let r=0;r<this.entityChildren.length;r++){let a=this.entityChildren[r].getComponentsInChild(s);e.push(...a)}return e}getComponents(s,e,t){e||=[];let r=this.getComponent(s);r&&(r.enable||t)&&e.push(r);for(let i=0,a=this.entityChildren.length;i<a;i++){let o=this.entityChildren[i];o&&o instanceof q&&o.getComponents(s,e,t)}return e}getComponentsExt(s,e,t){e||=[];let r=this.components.get(s);if(r&&(r.enable||t))e.push(r);else for(const i of this.entityChildren)i instanceof q&&i.getComponentsExt(s,e,t);return e}getComponentsByProperty(s,e,t=!0,r,i){r||=[];let a;for(const o of this.components.values())o&&(o.enable||i)&&o[s]===e&&(r.push(o),a=!0);if(!(a&&t))for(const o of this.entityChildren)o instanceof q&&o.getComponentsByProperty(s,e,t,r,i);return r}clone(){return this.instantiate()}instantiate(){let s=new q;return s.name=this.name,s.serializeTag=this.serializeTag,s.prefabRef=this.prefabRef,this.entityChildren.forEach((e,t)=>{let r=e.instantiate();s.addChild(r)}),this.components.forEach((e,t)=>{e.cloneTo(s)}),s}get localPosition(){return this.transform.localPosition}set localPosition(s){this.transform.localPosition=s}get localRotation(){return this.transform.localRotation}set localRotation(s){this.transform.localRotation=s}get localScale(){return this.transform.localScale}set localScale(s){this.transform.localScale=s}get localQuaternion(){return this.transform.localRotQuat}set localQuaternion(s){this.transform.localRotQuat=s}notifyChange(){this.transform.notifyChange()}get parent(){return this.transform.parent}get parentObject(){return this.transform.parent.object3D}set x(s){this.transform.x=s}get x(){return this.transform.x}set y(s){this.transform.y=s}get y(){return this.transform.y}set z(s){this.transform.z=s}get z(){return this.transform.z}set scaleX(s){this.transform.scaleX=s}get scaleX(){return this.transform.scaleX}set scaleY(s){this.transform.scaleY=s}get scaleY(){return this.transform.scaleY}set scaleZ(s){this.transform.scaleZ=s}get scaleZ(){return this.transform.scaleZ}set rotationX(s){this.transform.rotationX=s}get rotationX(){return this.transform.rotationX}set rotationY(s){this.transform.rotationY=s}get rotationY(){return this.transform.rotationY}set rotationZ(s){this.transform.rotationZ=s}get rotationZ(){return this.transform.rotationZ}fixedUpdate(){}lateUpdate(){}traverse(s){s(this);for(let e=0,t=this.entityChildren.length;e<t;e++){let r=this.entityChildren[e];r instanceof q&&r.traverse(s)}}destroy(s){this.transform.eventDispatcher.removeEventListener(Dt.LOCAL_ONCHANGE,this.onTransformLocalChange,this),super.destroy(s)}};q=Hg([jg],q);function jg(s,e){return class extends q{set active(t){this.transform.enable=t>0}get active(){return this.transform.enable?1:0}get materialColor(){return this.getComponent(K)?.material?.shader.getDefaultColorShader().baseColor}set materialColor(t){let r=this.getComponent(K)?.material;r&&(r.shader.getDefaultColorShader().baseColor=t)}notifyMaterialColorChange(t,r){this.getComponent(K).materials?.[t]?.shader.getDefaultColorShader().uniforms[r].onChange()}}}class Ke{static createCamera3DObject(e,t){return this.createCamera3D(null,e,t)}static createCamera3D(e,t,r){return e||=new q,t&&t.addChild(e),r&&(e.name=r),e.getOrAddComponent(Ji)}static UnProjection(e,t,r=1,i){let a=new d(e,t,0),o=1,n=d.HELP_0,l=Q.canvas.offsetLeft,h=Q.canvas.offsetTop,u=Q.canvas.clientWidth,c=Q.canvas.clientHeight;n.x=((a.x-l)*o/u-.5)*2,n.y=-((a.y-h)*o/c-.5)*2,n.z=r;let f=new d(0,0,0),g=I.helpMatrix2;g.copyFrom(i.projectionMatrix),g.invert();let p=I.helpMatrix;return p.identity(),p.multiply(g),p.multiply(i.transform.worldMatrix),p.perspectiveMultiplyPoint3(n,f),f}static Projection(e,t,r){let i=r||new d(0,0,0),a=I.helpMatrix;a.copyFrom(t.viewMatrix),a.multiply(t.projectionMatrix),a.perspectiveMultiplyPoint3(e,i);let o=Q.canvas.clientWidth/2,n=Q.canvas.clientHeight/2;return i.x=i.x*o+o,i.y=n-i.y*n,i}static UnProjection2(e,t,r,i,a){let o=a||new d(0,0,0),n=I.helpMatrix;n.copyFrom(i.pvMatrixInv);let l=Q.canvas.clientWidth/2,h=Q.canvas.clientHeight/2;return o.x=(e-l)/l,o.y=(h-t)/h,o.z=r,n.perspectiveMultiplyPoint3(o,o),o}}class Tt{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==Xe.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==Xe.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==Xe.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==Xe.DirectionLight){let r=this.directionLightList.get(e);return r||(r=[],this.directionLightList.set(e,r)),r}else if(t==Xe.PointLight){let r=this.pointLightList.get(e);return r||(r=[],this.pointLightList.set(e,r)),r}}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==Xe.DirectionLight){let r=this.directionLightList.get(t);if(r||(r=[],this.directionLightList.set(t,r)),!e.shadowCamera){e.shadowCamera=Ke.createCamera3DObject(null,"shadowCamera"),e.shadowCamera.isShadowCamera=!0;let i=-1e3;e.shadowCamera.orthoOffCenter(i,-i,i,-i,1,1e4)}return r.indexOf(e)==-1&&r.push(e),r}else if(e.lightData.lightType==Xe.PointLight||e.lightData.lightType==Xe.SpotLight){let r=this.pointLightList.get(t);return r&&r.length>=8||(r||(r=[],this.pointLightList.set(t,r)),r.indexOf(e)==-1&&r.push(e)),r}}static removeShadowLight(e){if(e.lightData.castShadowIndex=-1,!e.transform.view3D)return null;if(e.lightData.lightType==Xe.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);if(t){let r=t.indexOf(e);r!=-1&&t.splice(r,1)}return e.lightData.castShadowIndex=-1,t}else if(e.lightData.lightType==Xe.PointLight||e.lightData.lightType==Xe.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);if(t){let r=t.indexOf(e);r!=-1&&t.splice(r,1)}return e.lightData.castShadowIndex=-1,t}}static update(e){let t=this.shadowLights.get(e.scene),r=Tt.directionLightList.get(e.scene),i=Tt.pointLightList.get(e.scene),a=0,o=0,n=0,l=0;if(t.fill(0),r){let u=0;for(let c=0;c<r.length;c++){const f=r[c];t[c]=f.lightData.index,f.lightData.castShadowIndex=u++}o=r.length}if(i){n=o;let u=0;for(let c=n;c<i.length;c++){const f=i[c];t[c]=f.lightData.index,f.lightData.castShadowIndex=u++}l=n+i.length}ne.getAllCameraGroup().forEach(u=>{u.dirShadowStart=a,u.dirShadowEnd=o,u.pointShadowStart=n,u.pointShadowEnd=l,u.shadowLights.set(new Float32Array(t))})}}class yo{uuid;usage;globalBindGroup;uniformGPUBuffer;matrixBindGroup;uniformByteLength;matrixesByteLength;shadowMatrixRaw=new Float32Array(128);csmMatrixRaw=new Float32Array(Zt.Cascades*16);csmShadowBias=new Float32Array(4);shadowLights=new Float32Array(16);dirShadowStart=0;dirShadowEnd=0;pointShadowStart=0;pointShadowEnd=0;constructor(e){this.uuid=It(),this.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.uniformGPUBuffer=new ut(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=I.block*4*I.maxCount,this.globalBindGroup=Q.device.createBindGroup({label:"global_bindGroupLayout",layout:mo.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=Tt.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 h=t[l].shadowCamera;this.shadowMatrixRaw.set(h.pvMatrix.rawData,l*16)}else this.shadowMatrixRaw.set(e.transform.worldMatrix.rawData,l*16);this.uniformGPUBuffer.setFloat32Array("shadowMatrix",this.shadowMatrixRaw);let r=m.setting.shadow.shadowSize;if(Zt.Cascades>1&&e.enableCSM&&t[0])for(let l=0;l<Zt.Cascades;l++){let h=e.csm.children[l].shadowCamera;this.csmMatrixRaw.set(h.pvMatrix.rawData,l*16),this.csmShadowBias[l]=e.getCSMShadowBiasScale(h)}this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights);let i=m.setting.reflectionSetting,a=G.instance.getReflections(e.transform.scene3D).length;this.uniformGPUBuffer.setFloat("reflectionProbeSize",i.reflectionProbeSize),this.uniformGPUBuffer.setFloat("reflectionProbeMaxCount",i.reflectionProbeMaxCount),this.uniformGPUBuffer.setFloat("reflectionMapWidth",i.width),this.uniformGPUBuffer.setFloat("reflectionMapHeight",i.height),this.uniformGPUBuffer.setFloat("reflectionCount",a),this.uniformGPUBuffer.setFloat("test2",Ye.testObj.testValue2),this.uniformGPUBuffer.setFloat("test3",Ye.testObj.testValue3),this.uniformGPUBuffer.setFloat("test4",Ye.testObj.testValue4),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",Qe.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",Qe.time),this.uniformGPUBuffer.setFloat("delta",Qe.delta),this.uniformGPUBuffer.setFloat("shadowBias",e.getShadowBias(r)),this.uniformGPUBuffer.setFloat("skyExposure",m.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",m.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",m.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",m.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",m.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",m.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",m.setting.render.renderState_split);let o=m.inputSystem.mouseX*Q.pixelRatio,n=m.inputSystem.mouseY*Q.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",o),this.uniformGPUBuffer.setFloat("mouseY",n),this.uniformGPUBuffer.setFloat("windowWidth",Q.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",Q.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",m.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",r),this.uniformGPUBuffer.setFloat("shadowSoft",m.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",e.enableCSM?1:0),this.uniformGPUBuffer.setFloat("csmMargin",m.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",Qe.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",Qe.time),this.uniformGPUBuffer.setFloat("delta",Qe.delta),this.uniformGPUBuffer.setFloat("shadowBias",m.setting.shadow.shadowBias),this.uniformGPUBuffer.setFloat("skyExposure",m.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",m.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",m.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",m.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",m.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",m.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",m.setting.render.renderState_split);let t=m.inputSystem.mouseX*Q.pixelRatio,r=m.inputSystem.mouseY*Q.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",t),this.uniformGPUBuffer.setFloat("mouseY",r),this.uniformGPUBuffer.setFloat("windowWidth",Q.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",Q.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",m.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",m.setting.shadow.shadowSize),this.uniformGPUBuffer.setFloat("shadowSoft",m.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",0),this.uniformGPUBuffer.setFloat("csmMargin",m.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 Yh{setting;probesBufferData;probesBuffer;isVolumeFrameChange=!0;randomOrientation;startPosition=new d;isVolumeChange=!0;irradianceVolumeBuffer;directionDistance=20;randomSeedCount=3;useRandomIndex=0;centerDirection=new d(0,0,this.directionDistance).normalize(1);arroundPositions=[];updateOrientation(){return this.useRandomIndex++,this.useRandomIndex>=this.arroundPositions.length&&(this.useRandomIndex=0),I.fromToRotation(this.centerDirection,this.arroundPositions[this.useRandomIndex],this.randomOrientation),this.randomOrientation}init(e){this.setting=e,this.randomOrientation=new I(!1),this.randomOrientation.identity(),this.irradianceVolumeBuffer=new ut(80),this.createFramesBuffer(),this.arroundPositions.push(this.centerDirection.clone());for(let t=0;t<this.randomSeedCount;t++){let r=Math.PI*2*t/this.randomSeedCount,i=new d(Math.sin(r),Math.cos(r),this.directionDistance).normalize(1);this.arroundPositions.push(i)}}setVolumeDataChange(){this.isVolumeChange=!0}updateProbes(e){let t=this.probesBufferData;for(let r of e){let i=r.index*4;t[i+3]=r.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 Be(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,r,i){let a=this.setting,o=this.setting.probeSpace;return i=i||new d,i.x=e*o-o*(a.probeXCount-1)*.5+a.offsetX,i.y=t*o-o*(a.probeYCount-1)*.5+a.offsetY,i.z=r*o-o*(a.probeZCount-1)*.5+a.offsetZ,i}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 Xh{storageGPUBuffer;irradianceVolume;_lightList=[];constructor(){this.storageGPUBuffer=new Be(fs.lightSize*m.setting.light.maxLight,GPUBufferUsage.COPY_SRC),this.irradianceVolume=new Yh,this.irradianceVolume.init(m.setting.gi);for(let e=0;e<m.setting.light.maxLight;e++){let t=this.storageGPUBuffer.memory.allocation_node(fs.lightSize*4);this._lightList.push(t)}this.storageGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e){this.storageGPUBuffer.clean();let t=G.instance.getLights(e.scene);for(let r=0;r<t.length;r++){const i=t[r].lightData;i.index=r,this.writeLightBytes(i,this._lightList[r])}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 Hh{storageGPUBuffer;reflectionMap;sourceReflectionMap;count;constructor(){this.storageGPUBuffer=new Be(768)}update(e){this.storageGPUBuffer.clean();let t=G.instance.getReflections(e.scene);for(let r=0;r<t.length;r++){const i=t[r];i.gid=r,this.storageGPUBuffer.setFloat("gid",i.gid),this.storageGPUBuffer.setVector3("worldPosition",i.transform.worldPosition),this.storageGPUBuffer.setFloat("radius",i.radius),this.storageGPUBuffer.setVector3("bound",i.transform.worldPosition)}this.count=t.length,this.storageGPUBuffer.apply()}}class jh extends Tr{size;constructor(e,t=0,r){super(),this.bufferType=tr.StorageGPUBuffer,this.size=e,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|t,e,r,"MatrixGPUBuffer")}writeBufferByHeap(e,t){let r;e instanceof Float64Array?r=new Float32Array(e):r=e;let i=Q.device;if(r.length>0){let a=null;for(;this.mapAsyncReady.length&&(a=this.mapAsyncReady.shift(),a.usedSize!=r.byteLength);)a.destroy(),this.mapAsyncBuffersOutstanding--,a=null;a||(a=i.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,mappedAtCreation:!0}),a.usedSize=r.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 o=new Float32Array(r.buffer,r.byteOffset,t);new Float32Array(a.getMappedRange(0,t*4)).set(o),a.unmap();const l=i.createCommandEncoder();l.copyBufferToBuffer(a,0,this.buffer,0,t*4),i.queue.submit([l.finish()]),a.mapAsync(GPUMapMode.WRITE).then(()=>this.mapAsyncReady.push(a))}}}class Kh{uuid;index;usage;groupBufferSize;matrixBufferDst;constructor(){this.uuid=It(),this.groupBufferSize=0,this.usage=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.cacheWorldMatrix()}cacheWorldMatrix(){this.groupBufferSize=I.maxCount*I.blockBytes,this.matrixBufferDst=new jh(this.groupBufferSize/4),this.matrixBufferDst.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBufferDst.buffer.label=this.groupBufferSize.toString()}writeBuffer(e){const t=I.dynamicMatrixBytes;this.matrixBufferDst.mapAsyncWrite(t,e)}}class ne{static _cameraBindGroups;static _lightEntriesMap;static _reflectionEntriesMap;static modelMatrixBindGroup;static init(){this.modelMatrixBindGroup=new Kh,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 yo(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 yo(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 Xh,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 Hh,this._reflectionEntriesMap.set(e,t)),this._reflectionEntriesMap.get(e)}}class F{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(F.lastShader!=t)F.lastShader=t;else return!1;F.lastPipeline!=t.pipeline&&(F.lastPipeline=t.pipeline,e.setPipeline(t.pipeline));for(let r=1;r<t.bindGroups.length;r++){const i=t.bindGroups[r];i&&e.setBindGroup(r,i)}return!0}static bindCamera(e,t){let r=ne.getCameraGroup(t);e.setBindGroup(0,r.globalBindGroup)}static bindGeometryBuffer(e,t){if(this.lastGeometry!=t&&(this.lastGeometry=t,t.indicesBuffer)){e.setIndexBuffer(t.indicesBuffer.indicesGPUBuffer.buffer,t.indicesBuffer.indicesFormat);let r=t.vertexBuffer.vertexGPUBuffer,i=t.vertexBuffer.vertexBufferLayouts;for(let a=0;a<i.length;a++){const o=i[a];e.setVertexBuffer(a,r.buffer,o.offset,o.size)}}}static cleanCache(){this.lastGeometry=null,this.lastPipeline=null,this.lastShader=null}static createPipeline(e){return Ye.countStart("GPUContext","pipeline"),Q.device.createRenderPipeline(e)}static beginCommandEncoder(){return Ye.countStart("GPUContext","beginCommandEncoder"),this.LastCommand&&Q.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=Q.device.createCommandEncoder(),this.LastCommand}static endCommandEncoder(e){this.LastCommand==e&&(Q.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=null,Ye.countStart("GPUContext","endCommandEncoder"))}static recordBundleEncoder(e){return Q.device.createRenderBundleEncoder(e)}static beginRenderPass(e,t){if(this.cleanCache(),this.renderPassCount++,this.lastRenderPassState=t,t.depthTexture){let r=t.renderPassDescriptor.depthStencilAttachment;r.view=t.depthTexture.getGPUView()}if(t.renderTargets&&t.renderTargets.length>0){for(let r=0;r<t.renderTargets.length;++r){const i=t.renderTargets[r];let a=t.renderPassDescriptor.colorAttachments[r];t.multisample>0&&t.renderTargets.length==1?(a.view=t.multiTexture.createView(),a.resolveTarget=i.getGPUView()):a.view=i.getGPUTexture().createView()}return e.beginRenderPass(t.renderPassDescriptor)}else{let r=t.renderPassDescriptor.colorAttachments[0];return r&&(t.multisample>0?(r.view=t.multiTexture.createView(),r.resolveTarget=Q.context.getCurrentTexture().createView()):r.view=Q.context.getCurrentTexture().createView()),e.beginRenderPass(t.renderPassDescriptor)}}static drawIndexed(e,t,r,i,a,o){e.drawIndexed(t,r,i,a,o),this.drawCount++}static draw(e,t,r,i,a){e.draw(t,r,i,a),this.drawCount++}static endPass(e){e.insertDebugMarker("end"),e.end()}static computeCommand(e,t){let r=e.beginComputePass();for(let i=0;i<t.length;i++)t[i].compute(r);r.end()}static copyTexture(e,t,r){e.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:r.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:r.width,height:r.height,depthOrArrayLayers:1})}}class qh{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 Be(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 Be(e*3,t),this.output.apply()}}}}class $h{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 qh,this._normalAttrDataGroup=new qh}initMorphTarget(e){this._collectMorphTargetData=this.collectMorphTargetList(e),this._computeShader&&this._computeShader.destroy();let t=kt.CsMain;this._computeShader=new ue(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,F.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),r=t.length,i=t[0].data.length/3;if(this._blendTarget={},e.blendShapeData)for(let l=0;l<e.blendShapeData.shapeIndexs.length;l++){let h=e.blendShapeData.shapeIndexs[l],u=e.blendShapeData.shapeNames[l].split("."),c=u[u.length-1];this._blendTarget[c]=f=>this.updateInfluence(h,f)}let a=new Float32Array(i*r*3);{let l=0;for(let h=0;h<r;h++){let u=t[h];a.set(u.data,l),l+=u.data.length}}let o=this.collectAttribute("a_morphNormals_",e),n;if(o&&o.length>0){let l=0;n=new Float32Array(i*r*3);for(let h=0;h<r;h++){let u=o[h];n.set(u.data,l),l+=u.data.length}}return{mtCount:r,vCount:i,mergedPos:a,mergedNormal:n}}collectAttribute(e,t){let r=[];for(let i=0;i<this.MaxMorphTargetCount;i++){let a=e+i,o=t.getAttribute(a);if(o)r[i]=o;else break}return r}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)),r=Math.ceil(Math.log2(t));return t=Math.pow(2,r),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 ut(4),this._morphInfluenceArray=new Float32Array(this.MaxMorphTargetCount);let e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this._morphInfluenceBuffer=new Be(this.MaxMorphTargetCount,e)}}var Kg=Object.defineProperty,qg=Object.getOwnPropertyDescriptor,bo=(s,e,t,r)=>{for(var i=r>1?void 0:r?qg(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Kg(e,t,i),i};let K=class extends Nr{receiveShadow;morphData;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(s){s.addComponent(K).copyComponent(this)}copyComponent(s){return super.copyComponent(s),this.receiveShadow=s.receiveShadow,this}get geometry(){return this._geometry}set geometry(s){if(super.geometry=s,s){let e=s.morphTargetDictionary!=null;e&&(this.morphData||=new $h,this.morphData.morphTargetsRelative=s.morphTargetsRelative,this.morphData.initMorphTarget(s)),this.morphData&&(this.morphData.enable=e),this.morphData?.enable?this.addRendererMask(ve.MorphTarget):this.removeRendererMask(ve.MorphTarget),this.object3D.bound=this._geometry.bounds.clone()}else this.morphData&&(this.morphData.enable=!1),this.removeRendererMask(ve.MorphTarget);this._readyPipeline||(this.initPipeline(),this._computes&&(this.onCompute=ls(this.onCompute,()=>{for(let e=0;e<this._computes.length;e++)this._computes[e].onUpdate()})))}get material(){return this._materials[0]}set material(s){this.materials=[s]}setMorphInfluence(s,e){if(this.morphData&&this.morphData.enable){let t=this._geometry.morphTargetDictionary[s];t>=0&&this.morphData.updateInfluence(t,e)}}setMorphInfluenceIndex(s,e){this.morphData&&this.morphData.enable&&s>=0&&this.morphData.updateInfluence(s,e)}onCompute(s,e){this.morphData&&this.morphData.enable&&this.morphData.computeMorphTarget(e)}nodeUpdate(s,e,t,r){if(this.morphData&&this.morphData.enable)for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(e);if(o)for(let n=0;n<o.length;n++)this.morphData.applyRenderShader(o[n])}super.nodeUpdate(s,e,t,r)}destroy(s){super.destroy(s)}};bo([Oi],K.prototype,"geometry",1),bo([Oi],K.prototype,"material",1),K=bo([Pt(K,"MeshRenderer")],K);class Sr{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 eu{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]:m.res.redTexture}}class Ut extends je{resolveTarget;sampleCount;autoResize;clear;constructor(e,t,r=X.rgba8unorm,i=!1,a,o=1,n=0,l=!0,h=!0){super(e,t,o),this.name=It(),this.autoResize=h,this.useMipmap=i,this.sampleCount=n,this.format=r,this.numberLayer=o,this.clear=l,a!=null?this.usage=a:this.usage=a|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST,this.resize(e,t),this.autoResize&&Q.addEventListener(Hr.RESIZE,u=>{let{width:c,height:f}=u.data;this.resize(c,f),this._textureChange=!0},this)}resize(e,t){let r=Q.device;this.gpuTexture&&(je.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==X.rgba32float?(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=r.createSampler({})):this.format==X.depth32float?(this.samplerBindingLayout.type="filtering",this.sampler_comparisonBindingLayout.type="comparison",this.textureBindingLayout.sampleType="depth",this.gpuSampler=Q.device.createSampler({}),this.gpuSampler_comparison=Q.device.createSampler({compare:"less",label:"sampler_comparison"})):this.format==X.depth24plus?(this.samplerBindingLayout={type:"filtering"},this.sampler_comparisonBindingLayout={type:"comparison"},this.textureBindingLayout.sampleType="depth",this.gpuSampler=Q.device.createSampler({}),this.gpuSampler_comparison=Q.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=Lt.clamp_to_edge,this.addressModeV=Lt.clamp_to_edge,this.gpuSampler=r.createSampler(this)),this._textureChange=!0}create(e,t,r=!0){let i=Q.device;const a=e*4;let o=new Float32Array(e*t*4);const n=i.createBuffer({size:o.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(n,0,o);const l=F.beginCommandEncoder();l.copyBufferToTexture({buffer:n,bytesPerRow:a},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),F.endCommandEncoder(l)}clone(){let e=new Ut(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=Q.device,t=Q.windowWidth,r=Q.windowHeight,i=new Float32Array(t*r*4);const a=e.createBuffer({size:i.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});return F.beginCommandEncoder().copyTextureToBuffer({texture:this.getGPUTexture()},{buffer:a},[t,r]),a.getMappedRange(0,i.byteLength)}}class Re{storeOp="store";loadOp="clear";clearValue=[0,0,0,0]}class Ze{label;customSize=!1;renderTargets;rtDescriptors;zPreTexture;depthTexture;depthViewIndex=0;depthCleanValue=1;depthLoadOp="clear";isOutTarget=!0;constructor(e,t,r,i,a=!0){this.renderTargets=e,this.rtDescriptors=t,this.depthTexture=r,this.zPreTexture=i,this.isOutTarget=a}clone2Frame(e){e.renderTargets.push(...this.renderTargets.concat());for(let t=0;t<this.rtDescriptors.length;t++){const r=this.rtDescriptors[t];let i=new Re;i.loadOp=r.loadOp,i.storeOp=r.storeOp,i.clearValue=r.clearValue,e.rtDescriptors.push(i)}e.depthTexture=this.depthTexture,e.zPreTexture=this.zPreTexture,e.customSize=this.customSize}clone(){let e=new Ze([],[]);return this.clone2Frame(e),e}}class se extends Ze{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,r,i=!0,a=!0,o){let n=this.renderTargets,l=this.rtDescriptors;if(a){let u=new Re;u.loadOp="clear",this._colorBufferTex=Ct.createRTTexture(e+Sr.colorBufferTex_NAME,t,r,X.rgba16float,!0),n.push(this._colorBufferTex),l.push(u)}this._compressGBufferTex=new Ut(t,r,X.rgba32float,!1,void 0,1,0,!0,!0),n.push(this._compressGBufferTex),o?this.depthTexture=o:(this.depthTexture=new Ut(t,r,X.depth24plus,!1,void 0,1,0,!0,!0),this.depthTexture.name=e+"_depthTexture");let h;h=new Re,l.push(h)}getPositionMap(){return this.renderTargets[1]}getNormalMap(){return this.renderTargets[2]}getColorTexture(){return this._colorBufferTex}getCompressGBufferTexture(){return this._compressGBufferTex}static getGBufferFrame(e,t=0,r=0,i=!0,a){let o;if(se.gBufferMap.has(e))o=se.gBufferMap.get(e);else{o=new se;let n=Q.presentationSize;o.createGBuffer(e,t==0?n[0]:t,r==0?n[1]:r,t!=0&&r!=0,i,a),se.gBufferMap.set(e,o)}return o}static getGUIBufferFrame(){let e=this.getGBufferFrame(this.colorPass_GBuffer);return se.getGBufferFrame(se.gui_GBuffer,0,0,!0,e.depthTexture)}clone(){let e=new se;return this.clone2Frame(e),e}}class De{static rendererPassState=new Map;static createRendererPassState(e,t=null){let r=De.rendererPassState.get(e);if(r||(r=new eu,r.label=e.label,r.customSize=e.customSize,r.rtFrame=e,r.zPreTexture=e.zPreTexture,r.depthTexture=e.depthTexture,r.depthViewIndex=e.depthViewIndex,r.isOutTarget=e.isOutTarget,r.depthCleanValue=e.depthCleanValue,r.depthLoadOp=e.depthLoadOp,De.rendererPassState.set(e,r)),e&&e.renderTargets.length>0){r.renderTargets=e.renderTargets,r.rtTextureDescriptors=e.rtDescriptors,r.renderPassDescriptor=De.getRenderPassDescriptor(r),r.renderPassDescriptor.depthStencilAttachment&&(r.renderPassDescriptor.depthStencilAttachment.depthLoadOp=e.depthLoadOp),t=="load"&&e?.renderTargets[0]&&e.renderTargets[0].name.startsWith(se.gui_GBuffer)&&(r.renderPassDescriptor.colorAttachments[0].loadOp="load"),r.depthLoadOp=e.depthLoadOp,r.renderBundleEncoderDescriptor=De.getRenderBundleDescriptor(r),r.renderTargetTextures=[];for(let i=0;i<e.renderTargets.length;i++){const a=e.renderTargets[i];r.renderTargetTextures[i]={format:a.format},a.name.indexOf(Sr.colorBufferTex_NAME)!=-1&&(r.outColor=i)}}else r.renderPassDescriptor=De.getRenderPassDescriptor(r,t),r.renderBundleEncoderDescriptor=De.getRenderBundleDescriptor(r),r.renderTargetTextures=[{format:Q.presentationFormat}],r.outColor=0;return r}static getRenderPassDescriptor(e,t=null){if(e.renderPassDescriptor)return e.renderPassDescriptor;Q.device,Q.presentationSize;let r=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let a=0;a<e.renderTargets.length;a++){const o=e.renderTargets[a],n=e.rtTextureDescriptors[a];r.push({view:o.getGPUView(),resolveTarget:void 0,loadOp:n.loadOp,clearValue:n.clearValue,storeOp:n.storeOp})}}else if(!e.customSize){let a=Q.canvasConfig&&Q.canvasConfig.alpha?[1,1,1,0]:[0,0,0,1];e.isOutTarget==!0&&r.push({view:void 0,resolveTarget:void 0,loadOp:Q.canvasConfig&&Q.canvasConfig.alpha||t!=null?"load":"clear",clearValue:a,storeOp:"store"})}let i=null;return e.depthTexture||e.zPreTexture?(e.zPreTexture&&(e.depthTexture=e.zPreTexture),i={label:`${e.label} renderPassDescriptor zPreTexture${e.zPreTexture?"load":"clear"}`,colorAttachments:r,depthStencilAttachment:{view:e.depthTexture.getGPUView(),depthLoadOp:e.zPreTexture?"load":e.depthLoadOp,depthClearValue:e.zPreTexture?1:e.depthCleanValue,depthStoreOp:"store"}}):i={colorAttachments:r,label:"renderPassDescriptor not writeDepth"},e.renderPassDescriptor=i,i}static getRenderBundleDescriptor(e){if(e.renderBundleEncoderDescriptor)return e.renderBundleEncoderDescriptor;Q.presentationSize;let t=[];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 a=e.renderTargets[i];t.push(a.format)}}let r=null;return e.depthTexture?r={colorFormats:t,depthStencilFormat:e.depthTexture.format}:r={colorFormats:t},e.renderBundleEncoderDescriptor=r,e.renderBundleEncoderDescriptor}}class Xi extends Ie{width;height;segmentW;segmentH;up;constructor(e,t,r=1,i=1,a=d.Y_AXIS){super(),this.width=e,this.height=t,this.segmentW=r,this.segmentH=i,this.up=a,this.buildGeometry(this.up)}buildGeometry(e){var t,r,i,a,o=this.segmentW+1;(this.segmentH+1)*o,this.bounds=new Fe(d.ZERO.clone(),new d(this.width,1,this.height)),i=this.segmentH*this.segmentW*6;let n=(this.segmentW+1)*(this.segmentH+1),l=new Float32Array(n*3),h=new Float32Array(n*3),u=new Float32Array(n*2),c;this.segmentW*this.segmentH*2*3>=Uint16Array.length?c=new Uint32Array(this.segmentW*this.segmentH*2*3):c=new Uint16Array(this.segmentW*this.segmentH*2*3),i=0;for(var g=0,p=0,A=0,U=0;U<=this.segmentH;++U)for(var x=0;x<=this.segmentW;++x){switch(t=(x/this.segmentW-.5)*this.width,r=(U/this.segmentH-.5)*this.height,e){case d.Y_AXIS:l[g++]=t,l[g++]=0,l[g++]=r,h[p++]=0,h[p++]=1,h[p++]=0;break;case d.Z_AXIS:l[g++]=t,l[g++]=-r,l[g++]=0,h[p++]=0,h[p++]=0,h[p++]=1;break;case d.X_AXIS:l[g++]=0,l[g++]=t,l[g++]=r,h[p++]=1,h[p++]=0,h[p++]=0;break;default:l[g++]=t,l[g++]=0,l[g++]=r,h[p++]=0,h[p++]=1,h[p++]=0;break}u[A++]=x/this.segmentW,u[A++]=U/this.segmentH,x!=this.segmentW&&U!=this.segmentH&&(a=x+U*o,c[i++]=a+1,c[i++]=a,c[i++]=a+o,c[i++]=a+1,c[i++]=a+o,c[i++]=a+o+1)}this.setIndices(c),this.setAttribute(V.position,l),this.setAttribute(V.normal,h),this.setAttribute(V.uv,u),this.setAttribute(V.TEXCOORD_1,u),this.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}var $g=Object.getOwnPropertyDescriptor,ep=(s,e,t,r)=>{for(var i=r>1?void 0:r?$g(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let pa=class extends ot{constructor(s="QuadGlsl_vs",e="QuadGlsl_fs"){super();let t=new Pe(s,e);this.addRenderPass(t);let r=t.shaderState;t.blendMode=ae.NONE,r.frontFace="cw",r.depthWriteEnabled=!1,r.depthCompare=et.always,r.multisample=0,this.setTexture("baseMap",m.res.blackTexture),this.setUniformFloat("x",0),this.setUniformFloat("y",0),this.setUniformFloat("width",100),this.setUniformFloat("height",100)}};pa=ep([wr(pa,"QuadShader")],pa);class Qo extends q{width=128;height=128;quadRenderer;material;rendererPassState;quadShader;constructor(e="QuadGlsl_vs",t="QuadGlsl_fs",r,i=0,a=!1){super();let o=r?r.renderTargets:[];this.material=new At,this.quadShader=new pa(e,t),this.material.shader=this.quadShader,this.quadRenderer=this.addComponent(K),this.quadRenderer.material=this.material,this.quadRenderer.castGI=!1,this.quadRenderer.castShadow=!1,this.quadRenderer.drawType=a?2:0,this.quadRenderer.geometry=new Xi(100,100,1,1),this.quadRenderer.material=this.material,this.quadRenderer.__start(),this.quadRenderer._enable=!0,this.quadRenderer.onEnable(),this.rendererPassState=De.createRendererPassState(r,"load"),i>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=Q.device.createTexture({size:{width:Q.presentationSize[0],height:Q.presentationSize[1]},sampleCount:i,format:o.length>0?o[0].format:Q.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT})),Q.addEventListener(Hr.RESIZE,n=>{this.rendererPassState=De.createRendererPassState(r,"load"),i>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=Q.device.createTexture({size:{width:Q.presentationSize[0],height:Q.presentationSize[1]},sampleCount:i,format:o.length>0?o[0].format:Q.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT}))},this)}renderTarget(e,t,r){let i=e.camera,a=F.beginRenderPass(r,t.rendererPassState);F.bindCamera(a,i),t.quadRenderer.nodeUpdate(e,H.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,H.COLOR,t.rendererPassState,null,a),F.endPass(a)}renderToViewQuad(e,t,r,i){let a=e.camera;t.quadShader.setTexture("baseMap",i);let o=F.beginRenderPass(r,t.rendererPassState);F.bindCamera(o,a),t.quadRenderer.nodeUpdate(e,H.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,H.COLOR,t.rendererPassState,null,o),F.endPass(o)}}class Ct{static rtTextureMap;static rtViewQuad;static init(){this.rtTextureMap=new Map,this.rtViewQuad=new Map}static createRTTexture(e,t,r,i,a=!1,o=0){let n=this.rtTextureMap.get(e);return n||(e==Sr.colorBufferTex_NAME?n=new Ut(t,r,i,a,void 0,1,o,!1):n=new Ut(t,r,i,a,void 0,1,o,!0),n.name=e,Ct.rtTextureMap.set(e,n)),n}static createRTTextureArray(e,t,r,i,a=1,o=!1,n=0){let l=this.rtTextureMap.get(e);return l||(l=new Ut(t,r,i,o,void 0,a,n),l.name=e,Ct.rtTextureMap.set(e,l)),l}static createViewQuad(e,t,r,i,a=0){let o=new Ze([i],[new Re]),n=new Qo(t,r,o,a);return Ct.rtViewQuad.set(e,n),n}static getTexture(e){return this.rtTextureMap.get(e)}static CreateSplitTexture(e){let t=this.getTexture(Sr.colorBufferTex_NAME),r=this.getTexture(e+"_split");return r||(r=this.createRTTexture(e+"_split",t.width,t.height,t.format,!1)),r}static WriteSplitColorTexture(e){let t=this.getTexture(Sr.colorBufferTex_NAME),r=this.getTexture(e+"_split");const i=F.beginCommandEncoder();i.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:r.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:r.width,height:r.height,depthOrArrayLayers:1}),F.endCommandEncoder(i)}}class Ro{command;encoder;rendererPassStates;rtFrame;constructor(e){this.rtFrame=e,this.rendererPassStates=[]}clean(){this.rendererPassStates.length=0,F.cleanCache()}beginContinueRendererPassState(e="load",t="load"){if(this.rendererPassStates.length>0){let r=this.rtFrame.clone();for(const a of r.rtDescriptors)a.loadOp="load";r.depthLoadOp=t;let i=De.createRendererPassState(r,e);return this.rendererPassStates.push(i),i}else{this.rtFrame.depthLoadOp=t;let r=De.createRendererPassState(this.rtFrame,e);return this.rendererPassStates.push(r),r}}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=F.beginCommandEncoder(),this.command}endCommand(){F.endCommandEncoder(this.command),this.command=null}beginNewEncoder(){return this.encoder=F.beginRenderPass(this.command,this.rendererPassState),this.encoder}endEncoder(){F.endPass(this.encoder),this.encoder=null}}class _r extends Er{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=De.createRendererPassState(e);let t=e.clone();t.depthLoadOp="load";for(const r of t.rtDescriptors)r.loadOp="load";this.splitRendererPassState=De.createRendererPassState(t)}this.renderContext=new Ro(e)}getRenderContext(e){return this._rtFrame=e,new Ro(e)}setIrradiance(e,t){this.rendererPassState.irradianceBuffer=[e,t]}compute(e,t){}render(e,t,r,i=!1){F.cleanCache();let a=e.camera,o=e.scene;this.rendererPassState.camera3D=a;let n=G.instance.getRenderNodes(o,a),l=this.renderBundleOp(e,n,t,r),h=i?[]:this.renderBundleTr(e,n,t,r);{let u=F.beginCommandEncoder(),c=F.beginRenderPass(u,this.rendererPassState);l.length>0&&c.executeBundles(l),!i&&G.instance.sky&&(F.bindCamera(c,a),G.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,r,c)),this.drawRenderNodes(e,c,u,n.opaqueList,t),F.endPass(c),F.endCommandEncoder(u)}{let u=F.beginCommandEncoder(),c=F.beginRenderPass(u,this.rendererPassState);h.length>0&&c.executeBundles(h),i||(F.bindCamera(c,a),this.drawRenderNodes(e,c,u,n.transparentList,t)),F.endPass(c),F.endCommandEncoder(u)}}nodeUpload(e,t,r){}occlusionRenderNodeTest(e,t,r){return r?r.occlusionRenderNodeTest(e)>0:!0}renderOp(e,t,r,i,a){}renderTr(e,t,r,i,a){}renderBundleOp(e,t,r,i){let a=G.instance.getOpRenderGroup(e.scene);if(a){let o=[];return a.renderGroup.forEach(n=>{if(n.bundleMap.has(this._rendererType))o.push(n.bundleMap.get(this._rendererType));else{let l=F.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,n.renderNodes,i);let h=l.finish();n.bundleMap.set(this._rendererType,h),o.push(h)}}),o}return[]}renderBundleTr(e,t,r,i){let a=G.instance.getTrRenderGroup(e.scene);if(a){let o=[];return a.renderGroup.forEach(n=>{if(n.bundleMap.has(this._rendererType))o.push(n.bundleMap.get(this._rendererType));else{let l=F.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,n.renderNodes,i);let h=l.finish();n.bundleMap.set(this._rendererType,h),o.push(h)}}),o}return[]}recordRenderBundleNode(e,t,r,i){F.bindCamera(t,e.camera),F.bindGeometryBuffer(t,r[0].geometry);for(let a=0;a<r.length;++a){let o=r[a];o.transform.worldMatrix.index,o.transform.enable&&o.recordRenderPass2(e,this._rendererType,this.rendererPassState,i,t)}}drawRenderNodes(e,t,r,i,a,o){F.bindCamera(t,e.camera);for(let n=m.setting.render.drawOpMin;n<Math.min(i.length,m.setting.render.drawOpMax);++n){let l=i[n];l.transform.enable&&l.enable&&l.renderPass2(e,this._rendererType,this.rendererPassState,o,t)}}}class tu extends _r{constructor(){super(),this.passType=H.COLOR}render(e,t,r,i=!1){this.renderContext.clean();let a=e.scene,o=e.camera;ne.updateCameraGroup(o),this.rendererPassState.camera3D=o;let n=G.instance.getRenderNodes(a,o),l=this.renderBundleOp(e,n,t,r),h=i?[]:this.renderBundleTr(e,n,t,r);{this.renderContext.beginOpaqueRenderPass();let u=this.renderContext.encoder;l.length>0&&(G.instance.getOpRenderGroup(a),u.executeBundles(l)),!i&&G.instance.sky&&(F.bindCamera(u,o),G.instance.sky.preInit(this._rendererType)||G.instance.sky.nodeUpdate(e,this._rendererType,this.rendererPassState,r),G.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,r,u)),n.opaqueList&&(F.bindCamera(u,o),this.drawNodes(e,this.renderContext,n.opaqueList,t,r))}{let u=this.renderContext.encoder;h.length>0&&u.executeBundles(h),!i&&n.transparentList&&(F.bindCamera(u,o),this.drawNodes(e,this.renderContext,n.transparentList,t,r));let c=G.instance.getGraphicList();for(let f=0;f<c.length;f++){const g=c[f];g.nodeUpdate(e,this._rendererType,this.splitRendererPassState,r),g.renderPass2(e,this._rendererType,this.splitRendererPassState,r,u)}this.renderContext.endRenderPass(),Ye.end("ColorPass Draw Transparent")}}drawNodes(e,t,r,i,a){let o=G.instance.getRenderShaderCollect(e);if(o){for(const n of o){let l=n[1];for(const h of l){let u=h[1];if(!u.isDestroyed&&u.preInit(this._rendererType)){u.nodeUpdate(e,this._rendererType,this.rendererPassState,a);break}}}for(let n=m.setting.render.drawOpMin;n<Math.min(r.length,m.setting.render.drawOpMax);++n){let l=r[n];l.transform.enable&&l.enable&&(l.hasMask(ve.UI)&&!l.isRecievePostEffectUI||l.isDestroyed||(l.preInit(this._rendererType)||l.nodeUpdate(e,this._rendererType,this.rendererPassState,a),l.renderPass(e,this.passType,this.renderContext)))}}}occlusionRenderNodeTest(e,t,r){return r.zDepthRenderNodeTest(t)>0}}class Io{frustumCullingList;zVisibleList;_renderList;static enable=!0;constructor(){this._renderList=new Map}occlusionRenderNodeTest(e){return m.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 Hi extends Tr{constructor(e,t){super(),this.bufferType=tr.ComputeGPUBuffer,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,e,t,"ComputeGPUBuffer")}}class ru{clusterBuffer;lightAssignBuffer;assignTableBuffer;clustersUniformBuffer;constructor(e,t){this.clusterBuffer=new Hi(e*2*4),this.clustersUniformBuffer=new ut(10),this.clustersUniformBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.lightAssignBuffer=new Hi(e*t),this.lightAssignBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.assignTableBuffer=new Hi(e*4),this.assignTableBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e,t,r,i,a,o,n,l,h,u){this.clustersUniformBuffer.setFloat("clusterTileX",i),this.clustersUniformBuffer.setFloat("clusterTileY",a),this.clustersUniformBuffer.setFloat("clusterTileZ",o),this.clustersUniformBuffer.setFloat("numLights",n),this.clustersUniformBuffer.setFloat("maxNumLightsPerCluster",l),this.clustersUniformBuffer.setFloat("near",h),this.clustersUniformBuffer.setFloat("far",u),this.clustersUniformBuffer.setFloat("screenWidth",e),this.clustersUniformBuffer.setFloat("screenHeight",t),this.clustersUniformBuffer.setFloat("clusterPix",r),this.clustersUniformBuffer.apply()}}class gt{static clusterTileX=16;static clusterTileY=16;static clusterTileZ=32}let iu=`
|
|
5995
|
+
`;class ot{computes;passShader;constructor(){this.computes=[],this.passShader=new Map}addRenderPass(e,t=-1){let r=this.passShader.get(e.passType)||[];t==-1?r.push(e):r.splice(t,-1,e),this.passShader.set(e.passType,r)}removeShader(e,t=-1){let r=this.passShader.get(e.passType);if(r)if(t==-1){let i=r.indexOf(e);i!=-1&&r.splice(i)}else r.splice(t,1)}removeShaderByIndex(e,t=-1){let r=this.passShader.get(e);r&&(t==-1?this.passShader.delete(e):r.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 r of this.passShader)for(const i of r[1])i.setDefine(e,t)}hasDefine(e){for(const t of this.passShader)for(const r of t[1]){let i=r.hasDefine(e);if(i)return i}return!1}deleteDefine(e){for(const t of this.passShader)for(const r of t[1])r.deleteDefine(e)}setUniform(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniform(e,t)}setUniformFloat(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformFloat(e,t)}setUniformVector2(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformVector2(e,t)}setUniformVector3(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformVector3(e,t)}setUniformVector4(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformVector4(e,t)}setUniformColor(e,t){for(const r of this.passShader)for(const i of r[1])i.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 r of this.passShader)for(const i of r[1])i.setTexture(e,t);this.setDefine(`USE_${e.toLocaleUpperCase()}`,!0)}getTexture(e){return this.getDefaultColorShader().textures[e]}setUniformBuffer(e,t){for(const r of this.passShader)for(const i of r[1])i.setUniformBuffer(e,t)}getUniformBuffer(e){return this.getDefaultColorShader().getBuffer(e)}setStorageBuffer(e,t){for(const r of this.passShader)for(const i of r[1])i.setStorageBuffer(e,t)}getStorageBuffer(e){return this.getDefaultColorShader().getBuffer(e)}setStructStorageBuffer(e,t){for(const r of this.passShader)for(const i of r[1])i.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 ot,t=this.getDefaultShaders();for(const r of t)e.addRenderPass(r);return e}applyUniform(){for(const e of this.passShader)for(const t of e[1])t.applyUniform()}}var Gg=Object.getOwnPropertyDescriptor,Wg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Gg(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let da=class extends ot{constructor(){super();const s=new Pe("gsplat_vs_dc","gsplat_fs_dc");s.passType=H.COLOR,s.setShaderEntry("VertMain","FragMain"),s.topology=to.triangle_list,s.depthWriteEnabled=!1,s.cullMode=Et.none,s.shaderState.transparent=!0,s.shaderState.blendMode=ae.NORMAL,s.shaderState.writeMasks=[15,15],s.shaderState.castReflection=!1,this.addRenderPass(s),this.setDefault()}setDefault(){const s=this.getDefaultColorShader(),e=new I;s.setUniform("modelMatrix",e.rawData),s.setUniform("pixelCull",new Float32Array([2,0,0,0]))}};da=Wg([wr(da,"GSplatShader")],da);class Vh extends At{_pixelCullArray=new Float32Array(4);constructor(){super(),O.register("gsplat_vs_dc",Mh),O.register("gsplat_fs_dc",Nh),this.shader=new da}setSplatTextures(e,t,r,i,a){const o=this.shader.getDefaultColorShader();o.setTexture("splatColor",e),o.setTexture("transformA",t),o.setTexture("transformB",r),o.setUniformArray("tex_params",i),a&&o.setTexture("splatOrder",a),o.shaderState.depthCompare=et.less}setTransformMatrix(e){this.shader.getDefaultColorShader().setUniform("modelMatrix",e.rawData)}setPixelCulling(e,t,r=0,i=128){this._pixelCullArray[0]=e,this._pixelCullArray[1]=t,this._pixelCullArray[2]=r,this._pixelCullArray[3]=i,this.shader.getDefaultColorShader().setUniform("pixelCull",this._pixelCullArray)}}class gs extends Tr{node;constructor(e){super(),this.bufferType=tr.VertexGPUBuffer,this.createVertexBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,e)}createVertexBuffer(e,t){let r=Q.device;this.byteSize=t*Float32Array.BYTES_PER_ELEMENT,this.usage=e,this.buffer&&this.destroy(),this.buffer=r.createBuffer({label:"VertexGPUBuffer",size:this.byteSize,usage:e,mappedAtCreation:!1}),this.memory=new jr,this.memoryNodes=new Map,this.memory.allocation(this.byteSize),this.node=this.memory.allocation_node(this.byteSize)}}var dt=(s=>(s[s.split=0]="split",s[s.compose=1]="compose",s[s.compose_bin=2]="compose_bin",s))(dt||{});class Ph{vertexCount=0;vertexGPUBuffer;geometryType=dt.compose;_vertexBufferLayouts;_attributeSlotLayouts;_attributeLocation;constructor(){this._vertexBufferLayouts=[],this._attributeLocation={},this._attributeSlotLayouts=[]}get vertexBufferLayouts(){return this._vertexBufferLayouts}createVertexBuffer(e,t){switch(this.geometryType){case dt.split:this.createSplitVertexBuffer(e,t);break;case dt.compose:this.createComposeVertexBuffer(e,t);break;case dt.compose_bin:this.createComposBinVertexBuffer(e,t);break}}createSplitVertexBuffer(e,t){let r=0;for(let i=0;i<t.attributes.length;i++){const a=t.attributes[i];if(a.name=="index")continue;this._attributeLocation[a.name]=a.location;let o={name:a.name,format:a.format,offset:0,shaderLocation:a.location,stride:qr[a.format]};this._attributeSlotLayouts[a.location]=[o];let n=e.get(a.name);n||(n={attribute:a.name,data:new Float32Array(a.size*this.vertexCount)},e.set(a.name,n));let l=n.data.length/o.stride;this.vertexCount!=0&&this.vertexCount!=l&&console.error(" vertex count not match attribute count"),this.vertexCount=l,this._vertexBufferLayouts[a.location]={name:a.name,arrayStride:a.size*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[a.location],offset:r*4,size:this.vertexCount*a.size*4},r+=this.vertexCount*a.size}this.vertexGPUBuffer=new gs(r)}createComposeVertexBuffer(e,t){this._attributeSlotLayouts[0]=[];let r=0;for(let i=0;i<t.attributes.length;i++){const a=t.attributes[i];if(a.name=="index"||a.type=="builtin")continue;this._attributeLocation[a.name]=a.location;let o={name:a.name,format:a.format,offset:r*4,shaderLocation:a.location,stride:qr[a.format]};this._attributeSlotLayouts[0][a.location]=o;let n=e.get(a.name);if(n||(n={attribute:a.name,data:new Float32Array(a.size*this.vertexCount)},e.set(a.name,n)),n.data){let l=n.data.length/o.stride;this.vertexCount!=0&&this.vertexCount!=l&&console.error(" vertex count not match attribute count"),this.vertexCount=l}r+=a.size}this._vertexBufferLayouts[0]={name:"composeStruct",arrayStride:r*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[0],offset:0,size:this.vertexCount*r*4},this.vertexGPUBuffer=new gs(this.vertexCount*r)}createComposBinVertexBuffer(e,t){this._attributeSlotLayouts[0]=[];let r=0;for(let o=0;o<t.attributes.length;o++){const n=t.attributes[o];if(n.name=="index"||n.type=="builtin")continue;this._attributeLocation[n.name]=n.location;let l={name:n.name,format:n.format,offset:r*4,shaderLocation:n.location,stride:qr[n.format]};this._attributeSlotLayouts[0][n.location]=l;let h=e.get(n.name);if(h||(h={attribute:n.name,data:new Float32Array(n.size*this.vertexCount)},e.set(n.name,h)),h.data){let u=h.data.length/l.stride;this.vertexCount!=0&&this.vertexCount!=u&&console.error(" vertex count not match attribute count"),this.vertexCount=u}r+=n.size}let a=e.get(V.all).data.length/r;this.vertexCount=a,this._vertexBufferLayouts[0]={name:"composeStruct",arrayStride:r*4,stepMode:"vertex",attributes:this._attributeSlotLayouts[0],offset:0,size:this.vertexCount*r*4},this.vertexGPUBuffer=new gs(this.vertexCount*r)}upload(e,t){if(this.vertexGPUBuffer){switch(this.geometryType){case dt.split:{let r=this._attributeLocation[e],i=this._vertexBufferLayouts[r];this.vertexGPUBuffer.node.setFloat32Array(i.offset/4,t.data)}break;case dt.compose:for(let r=0;r<this.vertexCount;r++){const i=this._attributeSlotLayouts[0][this._attributeLocation[e]];for(let a=0;a<i.stride;a++){let o=t.data[r*i.stride+a],n=r*(this._vertexBufferLayouts[0].arrayStride/4)+i.offset/4+a;this.vertexGPUBuffer.node.setFloat(o,n)}}break;case dt.compose_bin:this.vertexGPUBuffer.node.setFloat32Array(0,t.data);break}this.vertexGPUBuffer?.apply()}}updateAttributes(e){switch(this.geometryType){case dt.split:for(let t=0;t<this._vertexBufferLayouts.length;t++){const r=this._vertexBufferLayouts[t];let i=e.get(r.name);this.vertexGPUBuffer.node.setFloat32Array(r.offset/4,i.data)}break;case dt.compose:for(let t=0;t<this.vertexCount;t++)this._attributeSlotLayouts.forEach(r=>{for(let i=0;i<r.length;i++){const a=r[i];let o=e.get(a.name);for(let n=0;n<a.stride;n++){let l=o.data[t*a.stride+n],h=t*(this._vertexBufferLayouts[0].arrayStride/4)+a.offset/4+n;this.vertexGPUBuffer.node.setFloat(l,h)}}});break;case dt.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 kh extends Tr{indicesNode;constructor(e){super(),this.bufferType=tr.IndicesGPUBuffer,this.createIndicesBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.INDEX|GPUBufferUsage.INDIRECT,e)}createIndicesBuffer(e,t){let r=Q.device;if(this.byteSize=t.length*4,this.usage=e,this.buffer&&this.destroy(),this.buffer=r.createBuffer({label:"IndicesGPUBuffer",size:this.byteSize,usage:e,mappedAtCreation:!1}),this.memory=new jr,this.memoryNodes=new Map,this.memory.allocation(this.byteSize),t){this.indicesNode=this.memory.allocation_node(t.length*4);const i=t.buffer instanceof ArrayBuffer?t.buffer:new Uint8Array(t.buffer).buffer;this.indicesNode.setArrayBuffer(0,i),this.apply()}}}class Lh{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 kh(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 Oh{lodLevels}class Ie{instanceID;name;subGeometries=[];morphTargetsRelative;morphTargetDictionary;skinNames;bindPose;blendShapeData;vertexDim;vertexCount=0;_bounds;_attributeMap;_attributes;_indicesBuffer;_vertexBuffer;_onChange=!0;_wireframeLines;constructor(){this.instanceID=It(),this._attributeMap=new Map,this._attributes=[],this._vertexBuffer=new Ph}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 Fe(new d,new d(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 r=e.data[t*3+0],i=e.data[t*3+1],a=e.data[t*3+2];this._bounds.min.x>r&&(this._bounds.min.x=r),this._bounds.min.y>i&&(this._bounds.min.y=i),this._bounds.min.z>a&&(this._bounds.min.z=a),this._bounds.max.x<r&&(this._bounds.max.x=r),this._bounds.max.y<i&&(this._bounds.max.y=i),this._bounds.max.z<a&&(this._bounds.max.z=a)}this._bounds.setFromMinMax(this._bounds.min,this._bounds.max)}return this._bounds}set bounds(e){this._bounds=e}addSubGeometry(...e){let t=new Oh;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 Lh,this._indicesBuffer.createIndicesBuffer(t)}}setAttribute(e,t){if(e==V.indices)this.setIndices(t);else{let r={attribute:e,data:t};this._attributeMap.set(e,r),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==dt.split||this.geometryType==dt.compose){let e=this.getAttribute(V.position),t=this.getAttribute(V.indices);if(t&&e&&t.data.length>0){let r=e.data,i=[];for(let a=0;a<t.data.length/3;a++){const o=t.data[a*3+0],n=t.data[a*3+1],l=t.data[a*3+2];let h=new d(r[o*3+0],r[o*3+1],r[o*3+2]),u=new d(r[n*3+0],r[n*3+1],r[n*3+2]),c=new d(r[l*3+0],r[l*3+1],r[l*3+2]);i.push(h,u),i.push(u,c),i.push(c,h)}return this._wireframeLines=i,i}}else if(this.geometryType==dt.compose_bin){let e=this.getAttribute(V.all),t=this.vertexDim,r=this.getAttribute(V.indices);if(r&&e&&r.data.length>0){let i=e.data,a=[];for(let o=0;o<r.data.length/3;o++){const n=r.data[o*3+0],l=r.data[o*3+1],h=r.data[o*3+2];let u=new d(i[n*t+0],i[n*t+1],i[n*t+2]),c=new d(i[l*t+0],i[l*t+1],i[l*t+2]),f=new d(i[h*t+0],i[h*t+1],i[h*t+2]);a.push(u,c),a.push(c,f),a.push(f,u)}return this._wireframeLines=a,a}}return null}compute(){this._indicesBuffer&&this._indicesBuffer.compute(),this._vertexBuffer&&this._vertexBuffer.compute()}static crossA=d.UP.clone();static crossB=d.UP.clone();static crossRet=d.UP.clone();static point1=d.UP.clone();static point2=d.UP.clone();static point3=d.UP.clone();computeNormals(){let e=this.getAttribute(V.position),t=this.getAttribute(V.normal),r=this.getAttribute(V.indices);if(!e||!t||!r)return this;let i=r.data.length/3,a=Ie.point1,o=Ie.point2,n=Ie.point3,l=Ie.crossA,h=Ie.crossB,u=Ie.crossRet;for(let c=0;c<i;c++){let f=r.data[c*3],g=r.data[c*3+1],p=r.data[c*3+2];a.set(e.data[f*3],e.data[f*3+1],e.data[f*3+2]),o.set(e.data[g*3],e.data[g*3+1],e.data[g*3+2]),n.set(e.data[p*3],e.data[p*3+1],e.data[p*3+2]),d.sub(a,o,l).normalize(),d.sub(a,n,h).normalize();let A=l.crossProduct(h,u).normalize();t.data[f*3]=t.data[g*3]=t.data[p*3]=A.x,t.data[f*3+1]=t.data[g*3+1]=t.data[p*3+1]=A.y,t.data[f*3+2]=t.data[g*3+2]=t.data[p*3+2]=A.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 zh extends Ie{batchSize;constructor(e=128){super(),this.batchSize=e;const t=new Float32Array(12*e);for(let i=0;i<e;++i)t.set([-2,-2,i,2,-2,i,2,2,i,-2,2,i],i*12);const r=new Uint32Array(6*e);for(let i=0;i<e;++i){const a=i*4;r.set([0+a,1+a,2+a,0+a,2+a,3+a],i*6)}this.setAttribute(V.position,t),this.setIndices(r),this.addSubGeometry({indexStart:0,indexCount:r.length,vertexStart:0,vertexCount:t.length/3,firstStart:0,index:0,topology:0})}}class So extends je{_dataBuffer;create(e,t,r,i=!1){let a=Q.device;const o=Math.ceil(e*4/256)*256;this.format=X.rgba8unorm,this.mipmapCount=Math.floor(i?Math.log2(e):1),this.createTextureDescriptor(e,t,this.mipmapCount,this.format);const n=this._dataBuffer=a.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});a.queue.writeBuffer(n,0,r);const l=F.beginCommandEncoder();return l.copyBufferToTexture({buffer:n,bytesPerRow:o},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),F.endCommandEncoder(l),i&&dr.webGPUGenerateMipmap(this),this}updateTexture(e,t,r){let i=Q.device;const a=Math.ceil(e*4/256)*256;this.mipmapCount=Math.floor(Math.log2(e)),this._dataBuffer&&this._dataBuffer.destroy(),this._dataBuffer=null;const o=this._dataBuffer=i.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(o,0,r);const n=F.beginCommandEncoder();n.copyBufferToTexture({buffer:o,bytesPerRow:a},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),F.endCommandEncoder(n),this.gpuSampler=i.createSampler(this),this.mipmapCount>1&&dr.webGPUGenerateMipmap(this)}}class Gh extends je{_dataBuffer;create(e,t,r){let i=Q.device;const a=e*4*4;this.format=X.rgba32uint,this.createTextureDescriptor(e,t,1,this.format);const n=this._dataBuffer=i.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(n,0,r.buffer);const l=i.createCommandEncoder();return l.copyBufferToTexture({buffer:n,bytesPerRow:a},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),i.queue.submit([l.finish()]),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="uint",this.gpuSampler=i.createSampler({}),this}updateTexture(e,t,r){let i=Q.device;const a=e*4*4;i.queue.writeTexture({texture:this.getGPUTexture()},r.buffer,{bytesPerRow:a},{width:e,height:t,depthOrArrayLayers:1})}}class Wh extends je{_dataBuffer;create(e,t,r){let i=Q.device;const a=e*4;this.format=X.r32uint,this.createTextureDescriptor(e,t,1,this.format);const n=this._dataBuffer=i.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(n,0,r.buffer);const l=i.createCommandEncoder();return l.copyBufferToTexture({buffer:n,bytesPerRow:a},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),i.queue.submit([l.finish()]),this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="uint",this.gpuSampler=i.createSampler({}),this}updateTexture(e,t,r){let i=Q.device;const a=e*4;i.queue.writeTexture({texture:this.getGPUTexture()},r.buffer,{bytesPerRow:a},{width:e,height:t,depthOrArrayLayers:1})}}const Jh=new Float32Array(1),Jg=new Int32Array(Jh.buffer);let ri=function(s){Jh[0]=s;const e=Jg[0];let t=e>>16&32768,r=e>>12&2047;const i=e>>23&255;return i<103?t:i>142?(t|=31744,t|=(i==255?1:0)&&e&8388607,t):i<114?(r|=2048,t|=(r>>114-i)+(r>>113-i&1),t):(t|=i-112<<10|r>>1,t+=r&1,t)};class _o extends je{uint16Array;floatArray;_dataBuffer;create(e,t,r=null,i=!0){if(r==null){r=[];for(let a=0,o=e*t*4;a<o;a++)r[a]=0}return this.updateTexture(e,t,r,i),this}updateTexture(e,t,r,i=!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=r;let a=Q.device;const o=e*4*2;this.format=X.rgba16float,this.mipmapCount=Math.floor(i?Math.log2(e):1),this.createTextureDescriptor(e,t,this.mipmapCount,this.format),(!this.uint16Array||this.uint16Array.length!=r.length)&&(this.uint16Array=new Uint16Array(r.length));let n=this.uint16Array;for(let u=0,c=n.length;u<c;u++)n[u]=ri(r[u]);const l=this._dataBuffer=a.createBuffer({size:n.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});a.queue.writeBuffer(l,0,n);const h=F.beginCommandEncoder();h.copyBufferToTexture({buffer:l,bytesPerRow:o},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),this.useMipmap||(this.samplerBindingLayout.type="filtering",this.textureBindingLayout.sampleType="float"),F.endCommandEncoder(h),this.gpuSampler=a.createSampler(this),this.gpuTexture=this.getGPUTexture(),this.mipmapCount>1&&dr.webGPUGenerateMipmap(this)}}var Zg=Object.getOwnPropertyDescriptor,Yg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Zg(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let ga=class extends Nr{count=0;size=new j;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(s){this.count=s.count,this._fullCount=s.count,this.size=this.evalTextureSize(s.count),this.buildColor(s),this.buildTransform(s),this.texParams=new Float32Array([this.count,this.size.x,this.count,1]),this._positions=s.position;const e=this.size.x*this.size.y;this._orderData=new Uint32Array(e);for(let t=0;t<e;t++)this._orderData[t]=t<this.count?t:this.count>0?this.count-1:0;this.splatOrder=new Wh().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 Vh,this.geometry=new zh(this._batchSize),this.materials=[this.gsplatMaterial],this.instanceCount=0}onBeforeUpdate(s){this.count>0&&s?.camera&&(this._lodEnabled&&this.updateLOD(s),s.camera.viewMatrix&&this.scheduleOrder(s.camera.viewMatrix))}updateLOD(s){if(!this._worldPositions||this._fullCount===0)return;const t=s.camera.viewMatrix.rawData,r=-(t[0]*t[12]+t[1]*t[13]+t[2]*t[14]),i=-(t[4]*t[12]+t[5]*t[13]+t[6]*t[14]),a=-(t[8]*t[12]+t[9]*t[13]+t[10]*t[14]);let o=0,n=0,l=0;const h=Math.min(100,this._fullCount);for(let A=0;A<h;A++){const U=Math.floor(A/h*this._fullCount)*3;o+=this._worldPositions[U+0],n+=this._worldPositions[U+1],l+=this._worldPositions[U+2]}o/=h,n/=h,l/=h;const u=r-o,c=i-n,f=a-l,g=Math.sqrt(u*u+c*c+f*f);let p=this._lodDistances.length;for(let A=0;A<this._lodDistances.length;A++)if(g<this._lodDistances[A]){p=A;break}if(p!==this._currentLodLevel){this._currentLodLevel=p;const A=this._lodRatios[p],U=Math.floor(this._fullCount*A);if(this._mapping){const x=this._mapping;this._mapping=new Uint32Array(Math.min(U,x.length));for(let v=0;v<this._mapping.length;v++)this._mapping[v]=x[v];this.setMapping(this._mapping)}else this.count=U,this.texParams[0]=this.count,this.texParams[2]=this.count}}setMapping(s){this._mapping=s&&s.length>0?s: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 e=this.size.x*this.size.y;for(let t=0;t<e;t++)this._orderData[t]=t<this.count?t:this.count>0?this.count-1:0;if(this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData),this._sortWorker){const t=this._worldPositions||this._positions,r=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(t);if(this._mapping)for(let i=0;i<this._mapping.length;++i){const a=this._mapping[i]*3,o=i*3;r[o+0]=t[a+0],r[o+1]=t[a+1],r[o+2]=t[a+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(s){this.texParams[3]=Math.max(0,s)}setSortThrottle(s){this._minIntervalMs=Math.max(0,s|0)}setAdaptiveSorting(s){this._adaptiveSorting=s}setLOD(s,e,t){this._lodEnabled=s,e&&(this._lodDistances=e),t&&(this._lodRatios=t)}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(s,e=0,t=0){this._minPixelCoverage=Math.max(0,s),this._maxPixelCoverage=Math.max(0,e),this._maxPixelCullDistance=Math.max(0,t)}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(s){let e=Math.ceil(Math.sqrt(s));const t=64;e=Math.ceil(e/t)*t;const r=Math.ceil(s/e);return new j(e,r)}buildColor(s){const e=this.size.x|0,t=this.size.y|0,r=new Uint8Array(e*t*4),i=.28209479177387814,a=s.count,o=s.sh?.coeffs,n=o?o.length/(3*a):1;for(let l=0;l<a;l++){let h=.5,u=.5,c=.5;if(o&&n>=1){const p=l*n*3;h=.5+o[p+0]*i,u=.5+o[p+n+0]*i,c=.5+o[p+2*n+0]*i}const f=s.opacity?1/(1+Math.exp(-s.opacity[l])):1,g=l*4;r[g+0]=Math.max(0,Math.min(255,Math.floor(h*255))),r[g+1]=Math.max(0,Math.min(255,Math.floor(u*255))),r[g+2]=Math.max(0,Math.min(255,Math.floor(c*255))),r[g+3]=Math.max(0,Math.min(255,Math.floor(f*255)))}this.splatColor=new So().create(e,t,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(s){const e=this.size.x|0,t=this.size.y|0,r=s.count,i=new Uint32Array(e*t*4),a=new Array(e*t*4).fill(0),o=new ArrayBuffer(4),n=new Float32Array(o),l=new Uint32Array(o),h=g=>(n[0]=g,l[0]),u=s.position,c=s.rotation,f=s.scale;for(let g=0;g<r;g++){const p=g*4,A=u[g*3+0],U=u[g*3+1],x=u[g*3+2];i[p+0]=h(A),i[p+1]=h(U),i[p+2]=h(x);let v=0,S=0,C=0,_=1;if(c){v=c[g*4+0],S=c[g*4+1],C=c[g*4+2],_=c[g*4+3];const Wt=1/Math.hypot(v,S,C,_);v*=Wt,S*=Wt,C*=Wt,_*=Wt}let y=1,b=1,w=1;f&&(y=Math.exp(f[g*3+0]),b=Math.exp(f[g*3+1]),w=Math.exp(f[g*3+2]));const R=v+v,E=S+S,N=C+C,z=v*R,Y=v*E,ee=v*N,oe=S*E,te=S*N,ge=C*N,Ce=_*R,J=_*E,ce=_*N,he=1-(oe+ge),Ue=Y+ce,xe=ee-J,Ve=Y-ce,Ee=1-(z+ge),ye=te+Ce,Ne=ee+J,lt=te-Ce,pr=1-(z+oe),Nt=he*y,Qt=Ue*y,Rt=xe*y,Vt=Ve*b,_t=Ee*b,mr=ye*b,Ar=Ne*w,Ur=lt*w,xr=pr*w,pi=Nt*Nt+Vt*Vt+Ar*Ar,Zr=Nt*Qt+Vt*_t+Ar*Ur,vr=Nt*Rt+Vt*mr+Ar*xr,mi=Qt*Qt+_t*_t+Ur*Ur,Yr=Qt*Rt+_t*mr+Ur*xr,Ai=Rt*Rt+mr*mr+xr*xr,Br=p;a[Br+0]=pi,a[Br+1]=Zr,a[Br+2]=vr,a[Br+3]=Ai;const Ui=ri(mi)&65535,xi=ri(Yr)&65535;i[p+3]=Ui|xi<<16}this.transformA=new Gh().create(e,t,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 _o().create(e,t,a,!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 s=this.object3D.transform.worldMatrix,e=this._positions,t=this._fullCount;this._worldPositions||(this._worldPositions=new Float32Array(e.length));const r=s.rawData;for(let i=0;i<t;i++){const a=i*3,o=e[a+0],n=e[a+1],l=e[a+2];this._worldPositions[a+0]=r[0]*o+r[4]*n+r[8]*l+r[12],this._worldPositions[a+1]=r[1]*o+r[5]*n+r[9]*l+r[13],this._worldPositions[a+2]=r[2]*o+r[6]*n+r[10]*l+r[14]}this._centersSent=!1}scheduleOrder(s){if(this.count===0)return;const e=this.object3D.transform.localChange;(e||!this._worldPositions)&&this.updateWorldPositions();const t=s.rawData,r=t[2],i=t[6],a=t[10],o=-(t[0]*t[12]+t[1]*t[13]+t[2]*t[14]),n=-(t[4]*t[12]+t[5]*t[13]+t[6]*t[14]),l=-(t[8]*t[12]+t[9]*t[13]+t[10]*t[14]),h=performance.now(),u=(h-this._lastSentTime)/1e3,c=Math.floor(o*1e3)^Math.floor(n*1e3)^Math.floor(l*1e3),f=Math.floor(r*1e3)^Math.floor(i*1e3)^Math.floor(a*1e3),g=c^f;if(g===this._lastViewMatrixHash&&!e)return;let p=this._minIntervalMs;if(this._adaptiveSorting&&this._minIntervalMs>0){const U=Math.abs(g-this._lastViewMatrixHash)/Math.max(u,.001);U<1e3?p=this._minIntervalMs:U<1e4?p=this._minIntervalMs*.5:p=this._minIntervalMs*.2,this._lastCameraSpeed=U}if(!(h-this._lastSentTime<p)){if(this._lastViewMatrixHash=g,this._lastSentTime=h,!this._sortWorker){this._sortWorker=this.createSortWorker(),this._sortWorker.onmessage=v=>{const S=v.data.order,C=this._orderData.buffer;this._sortWorker.postMessage({order:C},[C]);const _=new Uint32Array(S),y=this.size.x*this.size.y,b=this.count;(!this._orderData||this._orderData.length!==y)&&(this._orderData=new Uint32Array(y));const w=Math.min(b,_.length);if(this._orderData.set(_.subarray(0,w),0),w<y){const N=b>0?b-1:0;this._orderData.fill(N,w,y)}this.splatOrder.updateTexture(this.size.x,this.size.y,this._orderData);const R=Math.max(0,Math.min(this.count,v.data.count|0));this.texParams[2]=R;const E=Math.ceil(R/this._batchSize);this.instanceCount=E};const A=this._worldPositions||this._positions,U=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(A);if(this._mapping)for(let v=0;v<this._mapping.length;++v){const S=this._mapping[v]*3,C=v*3;U[C+0]=A[S+0],U[C+1]=A[S+1],U[C+2]=A[S+2]}const x=new Uint32Array(this.count);for(let v=0;v<this.count;v++)x[v]=v;this._sortWorker.postMessage({order:x.buffer,centers:U.buffer,mapping:this._mapping},[x.buffer,U.buffer]),this._centersSent=!0}if(!this._centersSent&&this._sortWorker){const A=this._worldPositions||this._positions,U=this._mapping?new Float32Array(this._mapping.length*3):new Float32Array(A);if(this._mapping)for(let x=0;x<this._mapping.length;++x){const v=this._mapping[x]*3,S=x*3;U[S+0]=A[v+0],U[S+1]=A[v+1],U[S+2]=A[v+2]}this._sortWorker.postMessage({type:"centers",centers:U.buffer,mapping:this._mapping?this._mapping:null},[U.buffer]),this._centersSent=!0}this._sortWorker.postMessage({cameraPosition:{x:o,y:n,z:l},cameraDirection:{x:-r,y:-i,z:-a}})}}createSortWorker(){function s(){let o,n,l,h,u,c=!1;const f={x:0,y:0,z:0},g={x:0,y:0,z:0},p={x:0,y:0,z:0},A={x:0,y:0,z:0};let U,x;const v=(C,_,y)=>{for(;C<=_;){const b=_+C>>1,w=y(b);if(w>0)C=b+1;else if(w<0)_=b-1;else return b}return~C},S=()=>{if(!o||!n||!h||!u)return;const C=h.x,_=h.y,y=h.z,b=u.x,w=u.y,R=u.z,E=.001;if(!c&&Math.abs(C-f.x)<E&&Math.abs(_-f.y)<E&&Math.abs(y-f.z)<E&&Math.abs(b-g.x)<E&&Math.abs(w-g.y)<E&&Math.abs(R-g.z)<E)return;c=!1,f.x=C,f.y=_,f.z=y,g.x=b,g.y=w,g.z=R;const N=n.length/3;U?.length!==N&&(U=new Uint32Array(N));let z,Y;for(let J=0;J<8;++J){const ce=(J&1?p.x:A.x)-C,he=(J&2?p.y:A.y)-_,Ue=(J&4?p.z:A.z)-y,xe=ce*b+he*w+Ue*R;J===0?z=Y=xe:(z=Math.min(z,xe),Y=Math.max(Y,xe))}x?x.fill(0):x=new Uint32Array(65537);const ee=Y-z,oe=ee<1e-6?0:1/ee*2**16;for(let J=0;J<N;++J){const ce=J*3,he=n[ce+0]-C,Ue=n[ce+1]-_,xe=n[ce+2]-y,Ve=he*b+Ue*w+xe*R,Ee=Math.floor((Ve-z)*oe);U[J]=Ee,x[Ee]++}for(let J=1;J<65537;J++)x[J]+=x[J-1];for(let J=0;J<N;J++){const ce=U[J],he=--x[ce];o[he]=J}const te=J=>U[o[J]]/oe+z,ge=()=>{const J=v(0,N-1,ce=>-te(ce));return Math.min(N,Math.abs(J))},Ce=te(N-1)>=0?ge():N;if(l)for(let J=0;J<N;++J)o[J]=l[o[J]];self.postMessage({order:o.buffer,count:Ce},[o.buffer]),o=null};self.onmessage=C=>{if(C.data.order&&(o=new Uint32Array(C.data.order)),C.data.centers){n=new Float32Array(C.data.centers),p.x=A.x=n[0],p.y=A.y=n[1],p.z=A.z=n[2];const _=n.length/3;for(let y=1;y<_;++y){const b=n[y*3+0],w=n[y*3+1],R=n[y*3+2];p.x=Math.min(p.x,b),p.y=Math.min(p.y,w),p.z=Math.min(p.z,R),A.x=Math.max(A.x,b),A.y=Math.max(A.y,w),A.z=Math.max(A.z,R)}c=!0}C.data.hasOwnProperty("mapping")&&(l=C.data.mapping?new Uint32Array(C.data.mapping):null,c=!0),C.data.cameraPosition&&(h=C.data.cameraPosition),C.data.cameraDirection&&(u=C.data.cameraDirection),S()}}const e=`(${s.toString()})()`,t=new Blob([e],{type:"application/javascript"}),r=URL.createObjectURL(t);return new Worker(r)}nodeUpdate(s,e,t,r){const i=this.object3D.transform.worldMatrix;this.gsplatMaterial.setTransformMatrix(i);const a=`${this._minPixelCoverage},${this._maxPixelCoverage},${this._maxPixelCullDistance},${this._batchSize}`;a!==this._lastPixelCullParams&&(this.gsplatMaterial.setPixelCulling(this._minPixelCoverage,this._maxPixelCoverage,this._maxPixelCullDistance,this._batchSize),this._lastPixelCullParams=a),this._texturesInitialized||(this.gsplatMaterial.setSplatTextures(this.splatColor,this.transformA,this.transformB,this.texParams,this.splatOrder),this._texturesInitialized=!0),super.nodeUpdate(s,e,t,r)}renderPass(s,e,t){const r=t.encoder;for(let i of this.materials){const a=i.getPass(e);if(!(!a||a.length===0))for(const o of a){if(!o.pipeline)continue;o.apply(this.geometry,t.rendererPassState||t),F.bindPipeline(r,o),F.bindGeometryBuffer(r,this.geometry);const l=this.geometry.subGeometries[0].lodLevels[0];this.instanceCount>0?F.drawIndexed(r,l.indexCount,this.instanceCount,l.indexStart,0,0):F.drawIndexed(r,l.indexCount,1,l.indexStart,0,0)}}}destroy(s){this._sortWorker&&(this._sortWorker.terminate(),this._sortWorker=null),this.splatColor&&(this.splatColor.destroy(s),this.splatColor=null),this.transformA&&(this.transformA.destroy(s),this.transformA=null),this.transformB&&(this.transformB.destroy(s),this.transformB=null),this.splatOrder&&(this.splatOrder.destroy(s),this.splatOrder=null),this._positions=null,this._worldPositions=null,this._orderData=null,this.texParams=null,this._mapping=null,super.destroy(s)}};ga=Yg([Pt(ga,"GSplatRenderer")],ga);class Fo{static maxVector=new d(Number.MAX_VALUE*.1,Number.MAX_VALUE*.1,Number.MAX_VALUE*.1);static minVector=this.maxVector.clone().multiplyScalar(-1);static genMeshMaxVector=d.ZERO.clone();static genMeshMinVector=d.ZERO.clone();static genMeshVectorList8=[new d,new d,new d,new d,new d,new d,new d,new d];static genGSplatBounds(e,t){t||=new Fe(d.ZERO,d.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let r=e.getComponent(ga);if(!r)return console.warn("genGSplatBounds: No GSplatRenderer found on object"),t;const i=r.positions,a=r.fullCount;if(!i||a===0)return console.warn("genGSplatBounds: No position data available"),t;const o=e.transform.worldMatrix,n=new d;for(let l=0;l<a;l++){const h=l*3;n.set(i[h+0],i[h+1],i[h+2]),o.transformPoint(n,n),t.expandByPoint(n)}return t.setFromMinMax(t.min,t.max),t}static genMeshBounds(e,t){let r=this.genMeshMinVector,i=this.genMeshMaxVector,a=this.genMeshVectorList8;t||=new Fe(d.ZERO,d.ZERO),t.setFromMinMax(this.maxVector,this.minVector);let o=e.getComponents(K);for(const n of o)if(n&&n.geometry){let l=n.object3D.transform.worldMatrix;r.copy(n.geometry.bounds.min),i.copy(n.geometry.bounds.max),a[0].set(r.x,r.y,r.z),a[1].set(r.x,r.y,i.z),a[2].set(r.x,i.y,r.z),a[3].set(r.x,i.y,i.z),a[4].set(i.x,r.y,r.z),a[5].set(i.x,r.y,i.z),a[6].set(i.x,i.y,r.z),a[7].set(i.x,i.y,i.z);for(const h of a)l.transformPoint(h,h),t.expandByPoint(h)}return i.copyFrom(t.max),r.copyFrom(t.min),t.setFromMinMax(r,i),t}static transformBound(e,t,r){let i=this.genMeshMinVector.copyFrom(t.min),a=this.genMeshMaxVector.copyFrom(t.max),o=this.genMeshVectorList8;r||=new Fe(d.ZERO,d.ZERO),r.setFromMinMax(this.maxVector,this.minVector),o[0].set(i.x,i.y,i.z),o[1].set(i.x,i.y,a.z),o[2].set(i.x,a.y,i.z),o[3].set(i.x,a.y,a.z),o[4].set(a.x,i.y,i.z),o[5].set(a.x,i.y,a.z),o[6].set(a.x,a.y,i.z),o[7].set(a.x,a.y,a.z);for(const n of o)e.transformPoint(n,n),r.expandByPoint(n);return a.copyFrom(r.max),i.copyFrom(r.min),r.setFromMinMax(i,a),r}}class Zh extends Er{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 r=e.split("/"),i=this;for(;r.length>0&&i;){let a=r.shift();if(i=i.getChildByName(a,!1),!i)return null}return i}else return this.getChildByName(e,!1)}constructor(){super(),this.entityChildren=[],this.components=new Map,this._instanceID=$s().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 r=null;for(const i of this.entityChildren){if(i.name==e)return r=i,r;if(t&&(r=i.getChildByName(e,t),r))return r}return r}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 Fe,this._boundWorld=this._bound.clone(),this._isBoundChange=!0),this._isBoundChange&&(Fo.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()):Se.waitStartComponent.forEach((e,t)=>{for(;e.length>0;){const r=e.shift();r.__start(),Se.waitStartComponent.delete(r.object3D)}})}noticeComponents(e,t){for(let r of this.components.values())r[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 Xg=Object.getOwnPropertyDescriptor,Hg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Xg(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let q=class extends Zh{_isScene3D;prefabRef;serializeTag;constructor(){super(),this.transform=this.addComponent(Dt),this.transform.eventDispatcher.addEventListener(Dt.LOCAL_ONCHANGE,this.onTransformLocalChange,this)}get isScene3D(){return this._isScene3D}forChild(s){this.entityChildren.forEach(e=>{s(e),e.forChild(s)})}addComponent(s,e){if(!this.components.has(s)){let t=new s;return t.object3D=this,this.components.set(s,t),t.__init(e),Se.appendWaitStart(t),t}return this.components.get(s)}getOrAddComponent(s){let e=this.components.get(s);return e||(e=this.addComponent(s)),e}removeComponent(s){if(this.components.has(s)){let e=this.components.get(s);Se.removeWaitStart(this,e),this.components.delete(s),e.__stop(),e.beforeDestroy(),e.destroy()}}hasComponent(s){return this.components.has(s)}getComponent(s){return this.components.get(s)}getComponentFromParent(s){if(!this.parent)return null;let e=this.parent.object3D.getComponent(s);return e||this.parent.object3D.getComponentFromParent(s)}getComponentsInChild(s){let e=[],t=this.components.get(s);t&&e.push(t);for(let r=0;r<this.entityChildren.length;r++){let a=this.entityChildren[r].getComponentsInChild(s);e.push(...a)}return e}getComponents(s,e,t){e||=[];let r=this.getComponent(s);r&&(r.enable||t)&&e.push(r);for(let i=0,a=this.entityChildren.length;i<a;i++){let o=this.entityChildren[i];o&&o instanceof q&&o.getComponents(s,e,t)}return e}getComponentsExt(s,e,t){e||=[];let r=this.components.get(s);if(r&&(r.enable||t))e.push(r);else for(const i of this.entityChildren)i instanceof q&&i.getComponentsExt(s,e,t);return e}getComponentsByProperty(s,e,t=!0,r,i){r||=[];let a;for(const o of this.components.values())o&&(o.enable||i)&&o[s]===e&&(r.push(o),a=!0);if(!(a&&t))for(const o of this.entityChildren)o instanceof q&&o.getComponentsByProperty(s,e,t,r,i);return r}clone(){return this.instantiate()}instantiate(){let s=new q;return s.name=this.name,s.serializeTag=this.serializeTag,s.prefabRef=this.prefabRef,this.entityChildren.forEach((e,t)=>{let r=e.instantiate();s.addChild(r)}),this.components.forEach((e,t)=>{e.cloneTo(s)}),s}get localPosition(){return this.transform.localPosition}set localPosition(s){this.transform.localPosition=s}get localRotation(){return this.transform.localRotation}set localRotation(s){this.transform.localRotation=s}get localScale(){return this.transform.localScale}set localScale(s){this.transform.localScale=s}get localQuaternion(){return this.transform.localRotQuat}set localQuaternion(s){this.transform.localRotQuat=s}notifyChange(){this.transform.notifyChange()}get parent(){return this.transform.parent}get parentObject(){return this.transform.parent.object3D}set x(s){this.transform.x=s}get x(){return this.transform.x}set y(s){this.transform.y=s}get y(){return this.transform.y}set z(s){this.transform.z=s}get z(){return this.transform.z}set scaleX(s){this.transform.scaleX=s}get scaleX(){return this.transform.scaleX}set scaleY(s){this.transform.scaleY=s}get scaleY(){return this.transform.scaleY}set scaleZ(s){this.transform.scaleZ=s}get scaleZ(){return this.transform.scaleZ}set rotationX(s){this.transform.rotationX=s}get rotationX(){return this.transform.rotationX}set rotationY(s){this.transform.rotationY=s}get rotationY(){return this.transform.rotationY}set rotationZ(s){this.transform.rotationZ=s}get rotationZ(){return this.transform.rotationZ}fixedUpdate(){}lateUpdate(){}traverse(s){s(this);for(let e=0,t=this.entityChildren.length;e<t;e++){let r=this.entityChildren[e];r instanceof q&&r.traverse(s)}}destroy(s){this.transform.eventDispatcher.removeEventListener(Dt.LOCAL_ONCHANGE,this.onTransformLocalChange,this),super.destroy(s)}};q=Hg([jg],q);function jg(s,e){return class extends q{set active(t){this.transform.enable=t>0}get active(){return this.transform.enable?1:0}get materialColor(){return this.getComponent(K)?.material?.shader.getDefaultColorShader().baseColor}set materialColor(t){let r=this.getComponent(K)?.material;r&&(r.shader.getDefaultColorShader().baseColor=t)}notifyMaterialColorChange(t,r){this.getComponent(K).materials?.[t]?.shader.getDefaultColorShader().uniforms[r].onChange()}}}class Ke{static createCamera3DObject(e,t){return this.createCamera3D(null,e,t)}static createCamera3D(e,t,r){return e||=new q,t&&t.addChild(e),r&&(e.name=r),e.getOrAddComponent(Ji)}static UnProjection(e,t,r=1,i){let a=new d(e,t,0),o=1,n=d.HELP_0,l=Q.canvas.offsetLeft,h=Q.canvas.offsetTop,u=Q.canvas.clientWidth,c=Q.canvas.clientHeight;n.x=((a.x-l)*o/u-.5)*2,n.y=-((a.y-h)*o/c-.5)*2,n.z=r;let f=new d(0,0,0),g=I.helpMatrix2;g.copyFrom(i.projectionMatrix),g.invert();let p=I.helpMatrix;return p.identity(),p.multiply(g),p.multiply(i.transform.worldMatrix),p.perspectiveMultiplyPoint3(n,f),f}static Projection(e,t,r){let i=r||new d(0,0,0),a=I.helpMatrix;a.copyFrom(t.viewMatrix),a.multiply(t.projectionMatrix),a.perspectiveMultiplyPoint3(e,i);let o=Q.canvas.clientWidth/2,n=Q.canvas.clientHeight/2;return i.x=i.x*o+o,i.y=n-i.y*n,i}static UnProjection2(e,t,r,i,a){let o=a||new d(0,0,0),n=I.helpMatrix;n.copyFrom(i.pvMatrixInv);let l=Q.canvas.clientWidth/2,h=Q.canvas.clientHeight/2;return o.x=(e-l)/l,o.y=(h-t)/h,o.z=r,n.perspectiveMultiplyPoint3(o,o),o}}class Tt{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==Xe.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==Xe.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==Xe.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==Xe.DirectionLight){let r=this.directionLightList.get(e);return r||(r=[],this.directionLightList.set(e,r)),r}else if(t==Xe.PointLight){let r=this.pointLightList.get(e);return r||(r=[],this.pointLightList.set(e,r)),r}}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==Xe.DirectionLight){let r=this.directionLightList.get(t);if(r||(r=[],this.directionLightList.set(t,r)),!e.shadowCamera){e.shadowCamera=Ke.createCamera3DObject(null,"shadowCamera"),e.shadowCamera.isShadowCamera=!0;let i=-1e3;e.shadowCamera.orthoOffCenter(i,-i,i,-i,1,1e4)}return r.indexOf(e)==-1&&r.push(e),r}else if(e.lightData.lightType==Xe.PointLight||e.lightData.lightType==Xe.SpotLight){let r=this.pointLightList.get(t);return r&&r.length>=8||(r||(r=[],this.pointLightList.set(t,r)),r.indexOf(e)==-1&&r.push(e)),r}}static removeShadowLight(e){if(e.lightData.castShadowIndex=-1,!e.transform.view3D)return null;if(e.lightData.lightType==Xe.DirectionLight){let t=this.directionLightList.get(e.transform.view3D.scene);if(t){let r=t.indexOf(e);r!=-1&&t.splice(r,1)}return e.lightData.castShadowIndex=-1,t}else if(e.lightData.lightType==Xe.PointLight||e.lightData.lightType==Xe.SpotLight){let t=this.pointLightList.get(e.transform.view3D.scene);if(t){let r=t.indexOf(e);r!=-1&&t.splice(r,1)}return e.lightData.castShadowIndex=-1,t}}static update(e){let t=this.shadowLights.get(e.scene),r=Tt.directionLightList.get(e.scene),i=Tt.pointLightList.get(e.scene),a=0,o=0,n=0,l=0;if(t.fill(0),r){let u=0;for(let c=0;c<r.length;c++){const f=r[c];t[c]=f.lightData.index,f.lightData.castShadowIndex=u++}o=r.length}if(i){n=o;let u=0;for(let c=n;c<i.length;c++){const f=i[c];t[c]=f.lightData.index,f.lightData.castShadowIndex=u++}l=n+i.length}ne.getAllCameraGroup().forEach(u=>{u.dirShadowStart=a,u.dirShadowEnd=o,u.pointShadowStart=n,u.pointShadowEnd=l,u.shadowLights.set(new Float32Array(t))})}}class yo{uuid;usage;globalBindGroup;uniformGPUBuffer;matrixBindGroup;uniformByteLength;matrixesByteLength;shadowMatrixRaw=new Float32Array(128);csmMatrixRaw=new Float32Array(Zt.Cascades*16);csmShadowBias=new Float32Array(4);shadowLights=new Float32Array(16);dirShadowStart=0;dirShadowEnd=0;pointShadowStart=0;pointShadowEnd=0;constructor(e){this.uuid=It(),this.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.uniformGPUBuffer=new ut(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=I.block*4*I.maxCount,this.globalBindGroup=Q.device.createBindGroup({label:"global_bindGroupLayout",layout:mo.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=Tt.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 h=t[l].shadowCamera;this.shadowMatrixRaw.set(h.pvMatrix.rawData,l*16)}else this.shadowMatrixRaw.set(e.transform.worldMatrix.rawData,l*16);this.uniformGPUBuffer.setFloat32Array("shadowMatrix",this.shadowMatrixRaw);let r=m.setting.shadow.shadowSize;if(Zt.Cascades>1&&e.enableCSM&&t[0])for(let l=0;l<Zt.Cascades;l++){let h=e.csm.children[l].shadowCamera;this.csmMatrixRaw.set(h.pvMatrix.rawData,l*16),this.csmShadowBias[l]=e.getCSMShadowBiasScale(h)}this.uniformGPUBuffer.setFloat32Array("csmShadowBias",this.csmShadowBias),this.uniformGPUBuffer.setFloat32Array("csmMatrix",this.csmMatrixRaw),this.uniformGPUBuffer.setFloat32Array("shadowLights",this.shadowLights);let i=m.setting.reflectionSetting,a=G.instance.getReflections(e.transform.scene3D).length;this.uniformGPUBuffer.setFloat("reflectionProbeSize",i.reflectionProbeSize),this.uniformGPUBuffer.setFloat("reflectionProbeMaxCount",i.reflectionProbeMaxCount),this.uniformGPUBuffer.setFloat("reflectionMapWidth",i.width),this.uniformGPUBuffer.setFloat("reflectionMapHeight",i.height),this.uniformGPUBuffer.setFloat("reflectionCount",a),this.uniformGPUBuffer.setFloat("test2",Ye.testObj.testValue2),this.uniformGPUBuffer.setFloat("test3",Ye.testObj.testValue3),this.uniformGPUBuffer.setFloat("test4",Ye.testObj.testValue4),this.uniformGPUBuffer.setVector3("CameraPos",e.transform.worldPosition),this.uniformGPUBuffer.setFloat("frame",Qe.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",Qe.time),this.uniformGPUBuffer.setFloat("delta",Qe.delta),this.uniformGPUBuffer.setFloat("shadowBias",e.getShadowBias(r)),this.uniformGPUBuffer.setFloat("skyExposure",m.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",m.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",m.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",m.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",m.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",m.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",m.setting.render.renderState_split);let o=m.inputSystem.mouseX*Q.pixelRatio,n=m.inputSystem.mouseY*Q.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",o),this.uniformGPUBuffer.setFloat("mouseY",n),this.uniformGPUBuffer.setFloat("windowWidth",Q.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",Q.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",m.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",r),this.uniformGPUBuffer.setFloat("shadowSoft",m.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",e.enableCSM?1:0),this.uniformGPUBuffer.setFloat("csmMargin",m.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",Qe.frame),this.uniformGPUBuffer.setFloat32Array("SH",e.sh),this.uniformGPUBuffer.setFloat("time",Qe.time),this.uniformGPUBuffer.setFloat("delta",Qe.delta),this.uniformGPUBuffer.setFloat("shadowBias",m.setting.shadow.shadowBias),this.uniformGPUBuffer.setFloat("skyExposure",m.setting.sky.skyExposure),this.uniformGPUBuffer.setFloat("renderPassState",m.setting.render.renderPassState),this.uniformGPUBuffer.setFloat("quadScale",m.setting.render.quadScale),this.uniformGPUBuffer.setFloat("hdrExposure",m.setting.render.hdrExposure),this.uniformGPUBuffer.setInt32("renderState_left",m.setting.render.renderState_left),this.uniformGPUBuffer.setInt32("renderState_right",m.setting.render.renderState_right),this.uniformGPUBuffer.setFloat("renderState_split",m.setting.render.renderState_split);let t=m.inputSystem.mouseX*Q.pixelRatio,r=m.inputSystem.mouseY*Q.pixelRatio;this.uniformGPUBuffer.setFloat("mouseX",t),this.uniformGPUBuffer.setFloat("mouseY",r),this.uniformGPUBuffer.setFloat("windowWidth",Q.windowWidth),this.uniformGPUBuffer.setFloat("windowHeight",Q.windowHeight),this.uniformGPUBuffer.setFloat("near",e.near),this.uniformGPUBuffer.setFloat("far",e.far),this.uniformGPUBuffer.setFloat("pointShadowBias",m.setting.shadow.pointShadowBias),this.uniformGPUBuffer.setFloat("shadowMapSize",m.setting.shadow.shadowSize),this.uniformGPUBuffer.setFloat("shadowSoft",m.setting.shadow.shadowSoft),this.uniformGPUBuffer.setFloat("enableCSM",0),this.uniformGPUBuffer.setFloat("csmMargin",m.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 Yh{setting;probesBufferData;probesBuffer;isVolumeFrameChange=!0;randomOrientation;startPosition=new d;isVolumeChange=!0;irradianceVolumeBuffer;directionDistance=20;randomSeedCount=3;useRandomIndex=0;centerDirection=new d(0,0,this.directionDistance).normalize(1);arroundPositions=[];updateOrientation(){return this.useRandomIndex++,this.useRandomIndex>=this.arroundPositions.length&&(this.useRandomIndex=0),I.fromToRotation(this.centerDirection,this.arroundPositions[this.useRandomIndex],this.randomOrientation),this.randomOrientation}init(e){this.setting=e,this.randomOrientation=new I(!1),this.randomOrientation.identity(),this.irradianceVolumeBuffer=new ut(80),this.createFramesBuffer(),this.arroundPositions.push(this.centerDirection.clone());for(let t=0;t<this.randomSeedCount;t++){let r=Math.PI*2*t/this.randomSeedCount,i=new d(Math.sin(r),Math.cos(r),this.directionDistance).normalize(1);this.arroundPositions.push(i)}}setVolumeDataChange(){this.isVolumeChange=!0}updateProbes(e){let t=this.probesBufferData;for(let r of e){let i=r.index*4;t[i+3]=r.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 Be(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,r,i){let a=this.setting,o=this.setting.probeSpace;return i=i||new d,i.x=e*o-o*(a.probeXCount-1)*.5+a.offsetX,i.y=t*o-o*(a.probeYCount-1)*.5+a.offsetY,i.z=r*o-o*(a.probeZCount-1)*.5+a.offsetZ,i}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 Xh{storageGPUBuffer;irradianceVolume;_lightList=[];constructor(){this.storageGPUBuffer=new Be(fs.lightSize*m.setting.light.maxLight,GPUBufferUsage.COPY_SRC),this.irradianceVolume=new Yh,this.irradianceVolume.init(m.setting.gi);for(let e=0;e<m.setting.light.maxLight;e++){let t=this.storageGPUBuffer.memory.allocation_node(fs.lightSize*4);this._lightList.push(t)}this.storageGPUBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e){this.storageGPUBuffer.clean();let t=G.instance.getLights(e.scene);for(let r=0;r<t.length;r++){const i=t[r].lightData;i.index=r,this.writeLightBytes(i,this._lightList[r])}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 Hh{storageGPUBuffer;reflectionMap;sourceReflectionMap;count;constructor(){this.storageGPUBuffer=new Be(768)}update(e){this.storageGPUBuffer.clean();let t=G.instance.getReflections(e.scene);for(let r=0;r<t.length;r++){const i=t[r];i.gid=r,this.storageGPUBuffer.setFloat("gid",i.gid),this.storageGPUBuffer.setVector3("worldPosition",i.transform.worldPosition),this.storageGPUBuffer.setFloat("radius",i.radius),this.storageGPUBuffer.setVector3("bound",i.transform.worldPosition)}this.count=t.length,this.storageGPUBuffer.apply()}}class jh extends Tr{size;constructor(e,t=0,r){super(),this.bufferType=tr.StorageGPUBuffer,this.size=e,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|t,e,r,"MatrixGPUBuffer")}writeBufferByHeap(e,t){let r;e instanceof Float64Array?r=new Float32Array(e):r=e;let i=Q.device;if(r.length>0){let a=null;for(;this.mapAsyncReady.length&&(a=this.mapAsyncReady.shift(),a.usedSize!=r.byteLength);)a.destroy(),this.mapAsyncBuffersOutstanding--,a=null;a||(a=i.createBuffer({size:r.byteLength,usage:GPUBufferUsage.COPY_SRC|GPUBufferUsage.MAP_WRITE,mappedAtCreation:!0}),a.usedSize=r.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 o=new Float32Array(r.buffer,r.byteOffset,t);new Float32Array(a.getMappedRange(0,t*4)).set(o),a.unmap();const l=i.createCommandEncoder();l.copyBufferToBuffer(a,0,this.buffer,0,t*4),i.queue.submit([l.finish()]),a.mapAsync(GPUMapMode.WRITE).then(()=>this.mapAsyncReady.push(a))}}}class Kh{uuid;index;usage;groupBufferSize;matrixBufferDst;constructor(){this.uuid=It(),this.groupBufferSize=0,this.usage=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,this.cacheWorldMatrix()}cacheWorldMatrix(){this.groupBufferSize=I.maxCount*I.blockBytes,this.matrixBufferDst=new jh(this.groupBufferSize/4),this.matrixBufferDst.visibility=GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.matrixBufferDst.buffer.label=this.groupBufferSize.toString()}writeBuffer(e){const t=I.dynamicMatrixBytes;this.matrixBufferDst.mapAsyncWrite(t,e)}}class ne{static _cameraBindGroups;static _lightEntriesMap;static _reflectionEntriesMap;static modelMatrixBindGroup;static init(){this.modelMatrixBindGroup=new Kh,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 yo(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 yo(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 Xh,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 Hh,this._reflectionEntriesMap.set(e,t)),this._reflectionEntriesMap.get(e)}}class F{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(F.lastShader!=t)F.lastShader=t;else return!1;F.lastPipeline!=t.pipeline&&(F.lastPipeline=t.pipeline,e.setPipeline(t.pipeline));for(let r=1;r<t.bindGroups.length;r++){const i=t.bindGroups[r];i&&e.setBindGroup(r,i)}return!0}static bindCamera(e,t){let r=ne.getCameraGroup(t);e.setBindGroup(0,r.globalBindGroup)}static bindGeometryBuffer(e,t){if(this.lastGeometry!=t&&(this.lastGeometry=t,t.indicesBuffer)){e.setIndexBuffer(t.indicesBuffer.indicesGPUBuffer.buffer,t.indicesBuffer.indicesFormat);let r=t.vertexBuffer.vertexGPUBuffer,i=t.vertexBuffer.vertexBufferLayouts;for(let a=0;a<i.length;a++){const o=i[a];e.setVertexBuffer(a,r.buffer,o.offset,o.size)}}}static cleanCache(){this.lastGeometry=null,this.lastPipeline=null,this.lastShader=null}static createPipeline(e){return Ye.countStart("GPUContext","pipeline"),Q.device.createRenderPipeline(e)}static beginCommandEncoder(){return Ye.countStart("GPUContext","beginCommandEncoder"),this.LastCommand&&Q.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=Q.device.createCommandEncoder(),this.LastCommand}static endCommandEncoder(e){this.LastCommand==e&&(Q.device.queue.submit([this.LastCommand.finish()]),this.LastCommand=null,Ye.countStart("GPUContext","endCommandEncoder"))}static recordBundleEncoder(e){return Q.device.createRenderBundleEncoder(e)}static beginRenderPass(e,t){if(this.cleanCache(),this.renderPassCount++,this.lastRenderPassState=t,t.depthTexture){let r=t.renderPassDescriptor.depthStencilAttachment;r.view=t.depthTexture.getGPUView()}if(t.renderTargets&&t.renderTargets.length>0){for(let r=0;r<t.renderTargets.length;++r){const i=t.renderTargets[r];let a=t.renderPassDescriptor.colorAttachments[r];t.multisample>0&&t.renderTargets.length==1?(a.view=t.multiTexture.createView(),a.resolveTarget=i.getGPUView()):a.view=i.getGPUTexture().createView()}return e.beginRenderPass(t.renderPassDescriptor)}else{let r=t.renderPassDescriptor.colorAttachments[0];return r&&(t.multisample>0?(r.view=t.multiTexture.createView(),r.resolveTarget=Q.context.getCurrentTexture().createView()):r.view=Q.context.getCurrentTexture().createView()),e.beginRenderPass(t.renderPassDescriptor)}}static drawIndexed(e,t,r,i,a,o){e.drawIndexed(t,r,i,a,o),this.drawCount++}static draw(e,t,r,i,a){e.draw(t,r,i,a),this.drawCount++}static endPass(e){e.insertDebugMarker("end"),e.end()}static computeCommand(e,t){let r=e.beginComputePass();for(let i=0;i<t.length;i++)t[i].compute(r);r.end()}static copyTexture(e,t,r){e.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:r.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:r.width,height:r.height,depthOrArrayLayers:1})}}class qh{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 Be(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 Be(e*3,t),this.output.apply()}}}}class $h{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 qh,this._normalAttrDataGroup=new qh}initMorphTarget(e){this._collectMorphTargetData=this.collectMorphTargetList(e),this._computeShader&&this._computeShader.destroy();let t=kt.CsMain;this._computeShader=new ue(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,F.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),r=t.length,i=t[0].data.length/3;if(this._blendTarget={},e.blendShapeData)for(let l=0;l<e.blendShapeData.shapeIndexs.length;l++){let h=e.blendShapeData.shapeIndexs[l],u=e.blendShapeData.shapeNames[l].split("."),c=u[u.length-1];this._blendTarget[c]=f=>this.updateInfluence(h,f)}let a=new Float32Array(i*r*3);{let l=0;for(let h=0;h<r;h++){let u=t[h];a.set(u.data,l),l+=u.data.length}}let o=this.collectAttribute("a_morphNormals_",e),n;if(o&&o.length>0){let l=0;n=new Float32Array(i*r*3);for(let h=0;h<r;h++){let u=o[h];n.set(u.data,l),l+=u.data.length}}return{mtCount:r,vCount:i,mergedPos:a,mergedNormal:n}}collectAttribute(e,t){let r=[];for(let i=0;i<this.MaxMorphTargetCount;i++){let a=e+i,o=t.getAttribute(a);if(o)r[i]=o;else break}return r}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)),r=Math.ceil(Math.log2(t));return t=Math.pow(2,r),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 ut(4),this._morphInfluenceArray=new Float32Array(this.MaxMorphTargetCount);let e=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST;this._morphInfluenceBuffer=new Be(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 Kg=Object.defineProperty,qg=Object.getOwnPropertyDescriptor,bo=(s,e,t,r)=>{for(var i=r>1?void 0:r?qg(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Kg(e,t,i),i};let K=class extends Nr{receiveShadow;morphData;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(s){s.addComponent(K).copyComponent(this)}copyComponent(s){return super.copyComponent(s),this.receiveShadow=s.receiveShadow,this}get geometry(){return this._geometry}set geometry(s){if(super.geometry=s,s){let e=s.morphTargetDictionary!=null;e&&(this.morphData||=new $h,this.morphData.morphTargetsRelative=s.morphTargetsRelative,this.morphData.initMorphTarget(s)),this.morphData&&(this.morphData.enable=e),this.morphData?.enable?this.addRendererMask(ve.MorphTarget):this.removeRendererMask(ve.MorphTarget),this.object3D.bound=this._geometry.bounds.clone()}else this.morphData&&(this.morphData.enable=!1),this.removeRendererMask(ve.MorphTarget);this._readyPipeline||(this.initPipeline(),this._computes&&(this.onCompute=ls(this.onCompute,()=>{for(let e=0;e<this._computes.length;e++)this._computes[e].onUpdate()})))}get material(){return this._materials[0]}set material(s){this.materials=[s]}setMorphInfluence(s,e){if(this.morphData&&this.morphData.enable){let t=this._geometry.morphTargetDictionary[s];t>=0&&this.morphData.updateInfluence(t,e)}}setMorphInfluenceIndex(s,e){this.morphData&&this.morphData.enable&&s>=0&&this.morphData.updateInfluence(s,e)}onCompute(s,e){this.morphData&&this.morphData.enable&&this.morphData.computeMorphTarget(e)}nodeUpdate(s,e,t,r){if(this.morphData&&this.morphData.enable)for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(e);if(o)for(let n=0;n<o.length;n++)this.morphData.applyRenderShader(o[n])}super.nodeUpdate(s,e,t,r)}destroy(s){this.morphData&&(this.morphData.destroy(s),this.morphData=null),super.destroy(s)}};bo([Oi],K.prototype,"geometry",1),bo([Oi],K.prototype,"material",1),K=bo([Pt(K,"MeshRenderer")],K);class Sr{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 eu{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]:m.res.redTexture}}class Ut extends je{resolveTarget;sampleCount;autoResize;clear;constructor(e,t,r=X.rgba8unorm,i=!1,a,o=1,n=0,l=!0,h=!0){super(e,t,o),this.name=It(),this.autoResize=h,this.useMipmap=i,this.sampleCount=n,this.format=r,this.numberLayer=o,this.clear=l,a!=null?this.usage=a:this.usage=a|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST,this.resize(e,t),this.autoResize&&Q.addEventListener(Hr.RESIZE,u=>{let{width:c,height:f}=u.data;this.resize(c,f),this._textureChange=!0},this)}resize(e,t){let r=Q.device;this.gpuTexture&&(je.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==X.rgba32float?(this.samplerBindingLayout.type="non-filtering",this.textureBindingLayout.sampleType="unfilterable-float",this.gpuSampler=r.createSampler({})):this.format==X.depth32float?(this.samplerBindingLayout.type="filtering",this.sampler_comparisonBindingLayout.type="comparison",this.textureBindingLayout.sampleType="depth",this.gpuSampler=Q.device.createSampler({}),this.gpuSampler_comparison=Q.device.createSampler({compare:"less",label:"sampler_comparison"})):this.format==X.depth24plus?(this.samplerBindingLayout={type:"filtering"},this.sampler_comparisonBindingLayout={type:"comparison"},this.textureBindingLayout.sampleType="depth",this.gpuSampler=Q.device.createSampler({}),this.gpuSampler_comparison=Q.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=Lt.clamp_to_edge,this.addressModeV=Lt.clamp_to_edge,this.gpuSampler=r.createSampler(this)),this._textureChange=!0}create(e,t,r=!0){let i=Q.device;const a=e*4;let o=new Float32Array(e*t*4);const n=i.createBuffer({size:o.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});i.queue.writeBuffer(n,0,o);const l=F.beginCommandEncoder();l.copyBufferToTexture({buffer:n,bytesPerRow:a},{texture:this.getGPUTexture()},{width:e,height:t,depthOrArrayLayers:1}),F.endCommandEncoder(l)}clone(){let e=new Ut(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=Q.device,t=Q.windowWidth,r=Q.windowHeight,i=new Float32Array(t*r*4);const a=e.createBuffer({size:i.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.COPY_SRC});return F.beginCommandEncoder().copyTextureToBuffer({texture:this.getGPUTexture()},{buffer:a},[t,r]),a.getMappedRange(0,i.byteLength)}}class Re{storeOp="store";loadOp="clear";clearValue=[0,0,0,0]}class Ze{label;customSize=!1;renderTargets;rtDescriptors;zPreTexture;depthTexture;depthViewIndex=0;depthCleanValue=1;depthLoadOp="clear";isOutTarget=!0;constructor(e,t,r,i,a=!0){this.renderTargets=e,this.rtDescriptors=t,this.depthTexture=r,this.zPreTexture=i,this.isOutTarget=a}clone2Frame(e){e.renderTargets.push(...this.renderTargets.concat());for(let t=0;t<this.rtDescriptors.length;t++){const r=this.rtDescriptors[t];let i=new Re;i.loadOp=r.loadOp,i.storeOp=r.storeOp,i.clearValue=r.clearValue,e.rtDescriptors.push(i)}e.depthTexture=this.depthTexture,e.zPreTexture=this.zPreTexture,e.customSize=this.customSize}clone(){let e=new Ze([],[]);return this.clone2Frame(e),e}}class se extends Ze{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,r,i=!0,a=!0,o){let n=this.renderTargets,l=this.rtDescriptors;if(a){let u=new Re;u.loadOp="clear",this._colorBufferTex=Ct.createRTTexture(e+Sr.colorBufferTex_NAME,t,r,X.rgba16float,!0),n.push(this._colorBufferTex),l.push(u)}this._compressGBufferTex=new Ut(t,r,X.rgba32float,!1,void 0,1,0,!0,!0),n.push(this._compressGBufferTex),o?this.depthTexture=o:(this.depthTexture=new Ut(t,r,X.depth24plus,!1,void 0,1,0,!0,!0),this.depthTexture.name=e+"_depthTexture");let h;h=new Re,l.push(h)}getPositionMap(){return this.renderTargets[1]}getNormalMap(){return this.renderTargets[2]}getColorTexture(){return this._colorBufferTex}getCompressGBufferTexture(){return this._compressGBufferTex}static getGBufferFrame(e,t=0,r=0,i=!0,a){let o;if(se.gBufferMap.has(e))o=se.gBufferMap.get(e);else{o=new se;let n=Q.presentationSize;o.createGBuffer(e,t==0?n[0]:t,r==0?n[1]:r,t!=0&&r!=0,i,a),se.gBufferMap.set(e,o)}return o}static getGUIBufferFrame(){let e=this.getGBufferFrame(this.colorPass_GBuffer);return se.getGBufferFrame(se.gui_GBuffer,0,0,!0,e.depthTexture)}clone(){let e=new se;return this.clone2Frame(e),e}}class De{static rendererPassState=new Map;static createRendererPassState(e,t=null){let r=De.rendererPassState.get(e);if(r||(r=new eu,r.label=e.label,r.customSize=e.customSize,r.rtFrame=e,r.zPreTexture=e.zPreTexture,r.depthTexture=e.depthTexture,r.depthViewIndex=e.depthViewIndex,r.isOutTarget=e.isOutTarget,r.depthCleanValue=e.depthCleanValue,r.depthLoadOp=e.depthLoadOp,De.rendererPassState.set(e,r)),e&&e.renderTargets.length>0){r.renderTargets=e.renderTargets,r.rtTextureDescriptors=e.rtDescriptors,r.renderPassDescriptor=De.getRenderPassDescriptor(r),r.renderPassDescriptor.depthStencilAttachment&&(r.renderPassDescriptor.depthStencilAttachment.depthLoadOp=e.depthLoadOp),t=="load"&&e?.renderTargets[0]&&e.renderTargets[0].name.startsWith(se.gui_GBuffer)&&(r.renderPassDescriptor.colorAttachments[0].loadOp="load"),r.depthLoadOp=e.depthLoadOp,r.renderBundleEncoderDescriptor=De.getRenderBundleDescriptor(r),r.renderTargetTextures=[];for(let i=0;i<e.renderTargets.length;i++){const a=e.renderTargets[i];r.renderTargetTextures[i]={format:a.format},a.name.indexOf(Sr.colorBufferTex_NAME)!=-1&&(r.outColor=i)}}else r.renderPassDescriptor=De.getRenderPassDescriptor(r,t),r.renderBundleEncoderDescriptor=De.getRenderBundleDescriptor(r),r.renderTargetTextures=[{format:Q.presentationFormat}],r.outColor=0;return r}static getRenderPassDescriptor(e,t=null){if(e.renderPassDescriptor)return e.renderPassDescriptor;Q.device,Q.presentationSize;let r=[];if(e.renderTargets&&e.renderTargets.length>0){e.renderTargets[0].width,e.renderTargets[0].height;for(let a=0;a<e.renderTargets.length;a++){const o=e.renderTargets[a],n=e.rtTextureDescriptors[a];r.push({view:o.getGPUView(),resolveTarget:void 0,loadOp:n.loadOp,clearValue:n.clearValue,storeOp:n.storeOp})}}else if(!e.customSize){let a=Q.canvasConfig&&Q.canvasConfig.alpha?[1,1,1,0]:[0,0,0,1];e.isOutTarget==!0&&r.push({view:void 0,resolveTarget:void 0,loadOp:Q.canvasConfig&&Q.canvasConfig.alpha||t!=null?"load":"clear",clearValue:a,storeOp:"store"})}let i=null;return e.depthTexture||e.zPreTexture?(e.zPreTexture&&(e.depthTexture=e.zPreTexture),i={label:`${e.label} renderPassDescriptor zPreTexture${e.zPreTexture?"load":"clear"}`,colorAttachments:r,depthStencilAttachment:{view:e.depthTexture.getGPUView(),depthLoadOp:e.zPreTexture?"load":e.depthLoadOp,depthClearValue:e.zPreTexture?1:e.depthCleanValue,depthStoreOp:"store"}}):i={colorAttachments:r,label:"renderPassDescriptor not writeDepth"},e.renderPassDescriptor=i,i}static getRenderBundleDescriptor(e){if(e.renderBundleEncoderDescriptor)return e.renderBundleEncoderDescriptor;Q.presentationSize;let t=[];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 a=e.renderTargets[i];t.push(a.format)}}let r=null;return e.depthTexture?r={colorFormats:t,depthStencilFormat:e.depthTexture.format}:r={colorFormats:t},e.renderBundleEncoderDescriptor=r,e.renderBundleEncoderDescriptor}}class Xi extends Ie{width;height;segmentW;segmentH;up;constructor(e,t,r=1,i=1,a=d.Y_AXIS){super(),this.width=e,this.height=t,this.segmentW=r,this.segmentH=i,this.up=a,this.buildGeometry(this.up)}buildGeometry(e){var t,r,i,a,o=this.segmentW+1;(this.segmentH+1)*o,this.bounds=new Fe(d.ZERO.clone(),new d(this.width,1,this.height)),i=this.segmentH*this.segmentW*6;let n=(this.segmentW+1)*(this.segmentH+1),l=new Float32Array(n*3),h=new Float32Array(n*3),u=new Float32Array(n*2),c;this.segmentW*this.segmentH*2*3>=Uint16Array.length?c=new Uint32Array(this.segmentW*this.segmentH*2*3):c=new Uint16Array(this.segmentW*this.segmentH*2*3),i=0;for(var g=0,p=0,A=0,U=0;U<=this.segmentH;++U)for(var x=0;x<=this.segmentW;++x){switch(t=(x/this.segmentW-.5)*this.width,r=(U/this.segmentH-.5)*this.height,e){case d.Y_AXIS:l[g++]=t,l[g++]=0,l[g++]=r,h[p++]=0,h[p++]=1,h[p++]=0;break;case d.Z_AXIS:l[g++]=t,l[g++]=-r,l[g++]=0,h[p++]=0,h[p++]=0,h[p++]=1;break;case d.X_AXIS:l[g++]=0,l[g++]=t,l[g++]=r,h[p++]=1,h[p++]=0,h[p++]=0;break;default:l[g++]=t,l[g++]=0,l[g++]=r,h[p++]=0,h[p++]=1,h[p++]=0;break}u[A++]=x/this.segmentW,u[A++]=U/this.segmentH,x!=this.segmentW&&U!=this.segmentH&&(a=x+U*o,c[i++]=a+1,c[i++]=a,c[i++]=a+o,c[i++]=a+1,c[i++]=a+o,c[i++]=a+o+1)}this.setIndices(c),this.setAttribute(V.position,l),this.setAttribute(V.normal,h),this.setAttribute(V.uv,u),this.setAttribute(V.TEXCOORD_1,u),this.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0})}}var $g=Object.getOwnPropertyDescriptor,ep=(s,e,t,r)=>{for(var i=r>1?void 0:r?$g(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let pa=class extends ot{constructor(s="QuadGlsl_vs",e="QuadGlsl_fs"){super();let t=new Pe(s,e);this.addRenderPass(t);let r=t.shaderState;t.blendMode=ae.NONE,r.frontFace="cw",r.depthWriteEnabled=!1,r.depthCompare=et.always,r.multisample=0,this.setTexture("baseMap",m.res.blackTexture),this.setUniformFloat("x",0),this.setUniformFloat("y",0),this.setUniformFloat("width",100),this.setUniformFloat("height",100)}};pa=ep([wr(pa,"QuadShader")],pa);class Qo extends q{width=128;height=128;quadRenderer;material;rendererPassState;quadShader;constructor(e="QuadGlsl_vs",t="QuadGlsl_fs",r,i=0,a=!1){super();let o=r?r.renderTargets:[];this.material=new At,this.quadShader=new pa(e,t),this.material.shader=this.quadShader,this.quadRenderer=this.addComponent(K),this.quadRenderer.material=this.material,this.quadRenderer.castGI=!1,this.quadRenderer.castShadow=!1,this.quadRenderer.drawType=a?2:0,this.quadRenderer.geometry=new Xi(100,100,1,1),this.quadRenderer.material=this.material,this.quadRenderer.__start(),this.quadRenderer._enable=!0,this.quadRenderer.onEnable(),this.rendererPassState=De.createRendererPassState(r,"load"),i>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=Q.device.createTexture({size:{width:Q.presentationSize[0],height:Q.presentationSize[1]},sampleCount:i,format:o.length>0?o[0].format:Q.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT})),Q.addEventListener(Hr.RESIZE,n=>{this.rendererPassState=De.createRendererPassState(r,"load"),i>0&&(this.rendererPassState.multisample=this.quadShader.getDefaultColorShader().shaderState.multisample,this.rendererPassState.multiTexture=Q.device.createTexture({size:{width:Q.presentationSize[0],height:Q.presentationSize[1]},sampleCount:i,format:o.length>0?o[0].format:Q.presentationFormat,usage:GPUTextureUsage.RENDER_ATTACHMENT}))},this)}renderTarget(e,t,r){let i=e.camera,a=F.beginRenderPass(r,t.rendererPassState);F.bindCamera(a,i),t.quadRenderer.nodeUpdate(e,H.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,H.COLOR,t.rendererPassState,null,a),F.endPass(a)}renderToViewQuad(e,t,r,i){let a=e.camera;t.quadShader.setTexture("baseMap",i);let o=F.beginRenderPass(r,t.rendererPassState);F.bindCamera(o,a),t.quadRenderer.nodeUpdate(e,H.COLOR,t.rendererPassState,null),t.quadRenderer.renderPass2(e,H.COLOR,t.rendererPassState,null,o),F.endPass(o)}}class Ct{static rtTextureMap;static rtViewQuad;static init(){this.rtTextureMap=new Map,this.rtViewQuad=new Map}static createRTTexture(e,t,r,i,a=!1,o=0){let n=this.rtTextureMap.get(e);return n||(e==Sr.colorBufferTex_NAME?n=new Ut(t,r,i,a,void 0,1,o,!1):n=new Ut(t,r,i,a,void 0,1,o,!0),n.name=e,Ct.rtTextureMap.set(e,n)),n}static createRTTextureArray(e,t,r,i,a=1,o=!1,n=0){let l=this.rtTextureMap.get(e);return l||(l=new Ut(t,r,i,o,void 0,a,n),l.name=e,Ct.rtTextureMap.set(e,l)),l}static createViewQuad(e,t,r,i,a=0){let o=new Ze([i],[new Re]),n=new Qo(t,r,o,a);return Ct.rtViewQuad.set(e,n),n}static getTexture(e){return this.rtTextureMap.get(e)}static CreateSplitTexture(e){let t=this.getTexture(Sr.colorBufferTex_NAME),r=this.getTexture(e+"_split");return r||(r=this.createRTTexture(e+"_split",t.width,t.height,t.format,!1)),r}static WriteSplitColorTexture(e){let t=this.getTexture(Sr.colorBufferTex_NAME),r=this.getTexture(e+"_split");const i=F.beginCommandEncoder();i.copyTextureToTexture({texture:t.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{texture:r.getGPUTexture(),mipLevel:0,origin:{x:0,y:0,z:0}},{width:r.width,height:r.height,depthOrArrayLayers:1}),F.endCommandEncoder(i)}}class Ro{command;encoder;rendererPassStates;rtFrame;constructor(e){this.rtFrame=e,this.rendererPassStates=[]}clean(){this.rendererPassStates.length=0,F.cleanCache()}beginContinueRendererPassState(e="load",t="load"){if(this.rendererPassStates.length>0){let r=this.rtFrame.clone();for(const a of r.rtDescriptors)a.loadOp="load";r.depthLoadOp=t;let i=De.createRendererPassState(r,e);return this.rendererPassStates.push(i),i}else{this.rtFrame.depthLoadOp=t;let r=De.createRendererPassState(this.rtFrame,e);return this.rendererPassStates.push(r),r}}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=F.beginCommandEncoder(),this.command}endCommand(){F.endCommandEncoder(this.command),this.command=null}beginNewEncoder(){return this.encoder=F.beginRenderPass(this.command,this.rendererPassState),this.encoder}endEncoder(){F.endPass(this.encoder),this.encoder=null}}class _r extends Er{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=De.createRendererPassState(e);let t=e.clone();t.depthLoadOp="load";for(const r of t.rtDescriptors)r.loadOp="load";this.splitRendererPassState=De.createRendererPassState(t)}this.renderContext=new Ro(e)}getRenderContext(e){return this._rtFrame=e,new Ro(e)}setIrradiance(e,t){this.rendererPassState.irradianceBuffer=[e,t]}compute(e,t){}render(e,t,r,i=!1){F.cleanCache();let a=e.camera,o=e.scene;this.rendererPassState.camera3D=a;let n=G.instance.getRenderNodes(o,a),l=this.renderBundleOp(e,n,t,r),h=i?[]:this.renderBundleTr(e,n,t,r);{let u=F.beginCommandEncoder(),c=F.beginRenderPass(u,this.rendererPassState);l.length>0&&c.executeBundles(l),!i&&G.instance.sky&&(F.bindCamera(c,a),G.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,r,c)),this.drawRenderNodes(e,c,u,n.opaqueList,t),F.endPass(c),F.endCommandEncoder(u)}{let u=F.beginCommandEncoder(),c=F.beginRenderPass(u,this.rendererPassState);h.length>0&&c.executeBundles(h),i||(F.bindCamera(c,a),this.drawRenderNodes(e,c,u,n.transparentList,t)),F.endPass(c),F.endCommandEncoder(u)}}nodeUpload(e,t,r){}occlusionRenderNodeTest(e,t,r){return r?r.occlusionRenderNodeTest(e)>0:!0}renderOp(e,t,r,i,a){}renderTr(e,t,r,i,a){}renderBundleOp(e,t,r,i){let a=G.instance.getOpRenderGroup(e.scene);if(a){let o=[];return a.renderGroup.forEach(n=>{if(n.bundleMap.has(this._rendererType))o.push(n.bundleMap.get(this._rendererType));else{let l=F.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,n.renderNodes,i);let h=l.finish();n.bundleMap.set(this._rendererType,h),o.push(h)}}),o}return[]}renderBundleTr(e,t,r,i){let a=G.instance.getTrRenderGroup(e.scene);if(a){let o=[];return a.renderGroup.forEach(n=>{if(n.bundleMap.has(this._rendererType))o.push(n.bundleMap.get(this._rendererType));else{let l=F.recordBundleEncoder(this.rendererPassState.renderBundleEncoderDescriptor);this.recordRenderBundleNode(e,l,n.renderNodes,i);let h=l.finish();n.bundleMap.set(this._rendererType,h),o.push(h)}}),o}return[]}recordRenderBundleNode(e,t,r,i){F.bindCamera(t,e.camera),F.bindGeometryBuffer(t,r[0].geometry);for(let a=0;a<r.length;++a){let o=r[a];o.transform.worldMatrix.index,o.transform.enable&&o.recordRenderPass2(e,this._rendererType,this.rendererPassState,i,t)}}drawRenderNodes(e,t,r,i,a,o){F.bindCamera(t,e.camera);for(let n=m.setting.render.drawOpMin;n<Math.min(i.length,m.setting.render.drawOpMax);++n){let l=i[n];l.transform.enable&&l.enable&&l.renderPass2(e,this._rendererType,this.rendererPassState,o,t)}}}class tu extends _r{constructor(){super(),this.passType=H.COLOR}render(e,t,r,i=!1){this.renderContext.clean();let a=e.scene,o=e.camera;ne.updateCameraGroup(o),this.rendererPassState.camera3D=o;let n=G.instance.getRenderNodes(a,o),l=this.renderBundleOp(e,n,t,r),h=i?[]:this.renderBundleTr(e,n,t,r);{this.renderContext.beginOpaqueRenderPass();let u=this.renderContext.encoder;l.length>0&&(G.instance.getOpRenderGroup(a),u.executeBundles(l)),!i&&G.instance.sky&&(F.bindCamera(u,o),G.instance.sky.preInit(this._rendererType)||G.instance.sky.nodeUpdate(e,this._rendererType,this.rendererPassState,r),G.instance.sky.renderPass2(e,this._rendererType,this.rendererPassState,r,u)),n.opaqueList&&(F.bindCamera(u,o),this.drawNodes(e,this.renderContext,n.opaqueList,t,r))}{let u=this.renderContext.encoder;h.length>0&&u.executeBundles(h),!i&&n.transparentList&&(F.bindCamera(u,o),this.drawNodes(e,this.renderContext,n.transparentList,t,r));let c=G.instance.getGraphicList();for(let f=0;f<c.length;f++){const g=c[f];g.nodeUpdate(e,this._rendererType,this.splitRendererPassState,r),g.renderPass2(e,this._rendererType,this.splitRendererPassState,r,u)}this.renderContext.endRenderPass(),Ye.end("ColorPass Draw Transparent")}}drawNodes(e,t,r,i,a){let o=G.instance.getRenderShaderCollect(e);if(o){for(const n of o){let l=n[1];for(const h of l){let u=h[1];if(!u.isDestroyed&&u.preInit(this._rendererType)){u.nodeUpdate(e,this._rendererType,this.rendererPassState,a);break}}}for(let n=m.setting.render.drawOpMin;n<Math.min(r.length,m.setting.render.drawOpMax);++n){let l=r[n];l.transform.enable&&l.enable&&(l.hasMask(ve.UI)&&!l.isRecievePostEffectUI||l.isDestroyed||(l.preInit(this._rendererType)||l.nodeUpdate(e,this._rendererType,this.rendererPassState,a),l.renderPass(e,this.passType,this.renderContext)))}}}occlusionRenderNodeTest(e,t,r){return r.zDepthRenderNodeTest(t)>0}}class Io{frustumCullingList;zVisibleList;_renderList;static enable=!0;constructor(){this._renderList=new Map}occlusionRenderNodeTest(e){return m.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 Hi extends Tr{constructor(e,t){super(),this.bufferType=tr.ComputeGPUBuffer,this.createBuffer(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST,e,t,"ComputeGPUBuffer")}}class ru{clusterBuffer;lightAssignBuffer;assignTableBuffer;clustersUniformBuffer;constructor(e,t){this.clusterBuffer=new Hi(e*2*4),this.clustersUniformBuffer=new ut(10),this.clustersUniformBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.lightAssignBuffer=new Hi(e*t),this.lightAssignBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE,this.assignTableBuffer=new Hi(e*4),this.assignTableBuffer.visibility=GPUShaderStage.FRAGMENT|GPUShaderStage.COMPUTE}update(e,t,r,i,a,o,n,l,h,u){this.clustersUniformBuffer.setFloat("clusterTileX",i),this.clustersUniformBuffer.setFloat("clusterTileY",a),this.clustersUniformBuffer.setFloat("clusterTileZ",o),this.clustersUniformBuffer.setFloat("numLights",n),this.clustersUniformBuffer.setFloat("maxNumLightsPerCluster",l),this.clustersUniformBuffer.setFloat("near",h),this.clustersUniformBuffer.setFloat("far",u),this.clustersUniformBuffer.setFloat("screenWidth",e),this.clustersUniformBuffer.setFloat("screenHeight",t),this.clustersUniformBuffer.setFloat("clusterPix",r),this.clustersUniformBuffer.apply()}}class gt{static clusterTileX=16;static clusterTileY=16;static clusterTileZ=32}let iu=`
|
|
6022
5996
|
#include "GlobalUniform"
|
|
6023
5997
|
|
|
6024
5998
|
struct ClusterBox{
|
|
@@ -7754,7 +7728,7 @@ $1\r
|
|
|
7754
7728
|
`;class mc{compute;constructor(){this.compute=new ue(pc)}generateBRDFLUTTexture(){let e=new Ae(256,256,X.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);this.compute.setStorageTexture("brdflutTexture",e),this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let t=F.beginCommandEncoder();return F.computeCommand(t,[this.compute]),F.endCommandEncoder(t),e}}class Ki{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 j;isSliced=!1;height=4;width=4;xadvance=0;xoffset=0;yoffset=0;constructor(e){this.guiTexture=e||m.res.defaultGUITexture}}class di{static _maxUid=-1;_staticId=-1;dynamicId=-1;texture;width=1;height=1;get staticId(){return this._staticId}constructor(e){e||=m.res.whiteTexture,e.addressModeU="clamp-to-edge",e.addressModeV="clamp-to-edge",this.texture=e,di._maxUid++,this._staticId=di._maxUid,this.init()}init(){this.dynamicId=-1,this.width=this.texture.width,this.height=this.texture.height}}class Qp{fntCache={};fntData={};addFontData(e,t,r){this.fntData[`${e}${t}`]=r}getFontData(e,t){return this.fntData[`${e}${t}`]}addFnt(e,t,r,i){let a=`${e}${t}`;this.fntCache[a]||(this.fntCache[a]={}),this.fntCache[a][r]=i}getFnt(e,t,r){let i=`${e}${t}`,a=this.fntCache[i];return a?a[r]:this.fntCache[" "]}}let qi=new Qp;class Ac{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 Uc{id=0;file=""}class xc{id=-1;x=0;y=0;width=0;height=0;xoffset=0;yoffset=0;xadvance=0;page=0;chnl=0}class zr extends st{static format=Ge.TEXT;static parseSprite(e,t){for(const r in t.fontChar)if(Object.prototype.hasOwnProperty.call(t.fontChar,r)){const i=t.fontChar[r];let a=new Ki;a.id=i.id.toString(),a.offsetSize.set(0,0,i.width,i.height),a.trimSize.set(i.width,i.height),a.width=i.width,a.height=i.height,a.xadvance=i.xadvance,a.xoffset=i.xoffset,a.yoffset=i.yoffset,a.guiTexture=e[i.page],a.uvRec.set(i.x/t.scaleW,(t.scaleH-(i.y+i.height))/t.scaleH,i.width/t.scaleW,i.height/t.scaleH),qi.addFnt(t.face,t.size,a.id,a)}}verification(){if(this.data)return!0;throw new Error("Method not implemented.")}async parseString(e){let t=this.getNewLine(e),r=e,i=new Ac;r.trim().split(t).forEach((a,o)=>{if(o<2)zr.readLineProperty(a,i);else if(o<i.pages+2){let n=new Uc;zr.readLineProperty(a,n),i.fontPage.push(n)}else if(o<i.pages+3)zr.readLineProperty(a,i);else if(i.count>0){let n=new xc;zr.readLineProperty(a,n),i.fontChar[n.id]=n,i.count--}}),r="",this.data=i,await this.loadFontTextures()}getNewLine(e){return e.indexOf(`\r
|
|
7755
7729
|
`)!=-1?`\r
|
|
7756
7730
|
`:e.indexOf("\r")!=-1?"\r":`
|
|
7757
|
-
`}async loadFontTextures(){let e=[],t=this.data;for(const r of t.fontPage){let i=this.baseUrl+r.file;await m.res.loadTexture(i,null,!0);let a=m.res.getTexture(i),o=new di(a);e.push(o)}zr.parseSprite(e,t),t.fontChar[" "]||zr.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let r=new Ki,i=e.size*.5,a=e.lineHeight*.5;r.id=" ",r.offsetSize.set(0,0,e.size,e.size),r.trimSize.set(i,a),r.width=i,r.height=a,r.xadvance=0,r.xoffset=0,r.yoffset=0,r.guiTexture=t,r.uvRec.set(0,0,1e-6,1e-6),qi.addFnt(e.face,e.size,r.id,r)}static readLineProperty(e,t){e.trim().split(" ").forEach((r,i)=>{let a=r.split("=");if(a.length>1){let o=a[0],n=a[1];Object.prototype.hasOwnProperty.call(t,o)&&(n.indexOf('"')==-1?t[o]=parseFloat(a[1]):t[o]=n.replace('"',"").replace('"',""))}})}}function Rp(s,e){let t=new Ki;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 di(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function vc(s,e,t){let r=new Ki;r.guiTexture=s,r.id=e,r.uvRec.copyFrom(t.textureRect),r.trimSize.x=t.textureRect.z,r.trimSize.y=t.textureRect.w,r.offsetSize.x=t.textureRectOffset.x,r.offsetSize.y=t.textureRectOffset.y,r.offsetSize.z=t.size.x,r.offsetSize.w=t.size.y,r.width=t.size.x,r.height=t.size.y;let i=1/s.width,a=1/s.height;r.uvRec.set(r.uvRec.x*i,r.uvRec.y*a,r.uvRec.z*i,r.uvRec.w*a);let o=.1;return t.border.x<=o&&t.border.y<=o&&t.border.z<=o&&t.border.x<=o?r.isSliced=!1:(r.borderSize.copyFrom(t.border),r.uvBorder.copyFrom(t.border),r.uvBorder.x-=t.textureRectOffset.x,r.uvBorder.y-=t.textureRectOffset.y,r.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),r.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),r.uvBorder.x/=t.textureRect.z,r.uvBorder.z/=t.textureRect.z,r.uvBorder.y/=t.textureRect.w,r.uvBorder.w/=t.textureRect.w,r.isSliced=!0),r}class Bc{_spriteMap=new Map;_spriteList=[];textureSize=new j;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,r){let i=vc(e,t,r);return this._spriteMap.set(i.id,i),this._spriteList.push(i),i}getSprite(e){return this._spriteMap.get(e)}get spriteList(){return this._spriteList}}class Cc extends st{static format=Ge.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await m.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 Bc(this._json.size),t=new di(this._texture),r=this._json.atlas;for(const i in r)e.setTexture(t,i,r[i]);m.res.addAtlas(this.baseUrl,e),this.data=e}}var Ot=Uint8Array,$i=Uint16Array,Ip=Int32Array,Sc=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]),_c=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]),Ep=new Ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Fc=function(s,e){for(var t=new $i(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var i=new Ip(t[30]),r=1;r<30;++r)for(var a=t[r];a<t[r+1];++a)i[a]=a-t[r]<<5|r;return{b:t,r:i}},yc=Fc(Sc,2),bc=yc.b,wp=yc.r;bc[28]=258,wp[258]=28;for(var Tp=Fc(_c,0),Dp=Tp.b,an=new $i(32768),Me=0;Me<32768;++Me){var ii=(Me&43690)>>1|(Me&21845)<<1;ii=(ii&52428)>>2|(ii&13107)<<2,ii=(ii&61680)>>4|(ii&3855)<<4,an[Me]=((ii&65280)>>8|(ii&255)<<8)>>1}for(var Ca=(function(s,e,t){for(var r=s.length,i=0,a=new $i(e);i<r;++i)s[i]&&++a[s[i]-1];var o=new $i(e);for(i=1;i<e;++i)o[i]=o[i-1]+a[i-1]<<1;var n;if(t){n=new $i(1<<e);var l=15-e;for(i=0;i<r;++i)if(s[i])for(var h=i<<4|s[i],u=e-s[i],c=o[s[i]-1]++<<u,f=c|(1<<u)-1;c<=f;++c)n[an[c]>>l]=h}else for(n=new $i(r),i=0;i<r;++i)s[i]&&(n[i]=an[o[s[i]-1]++]>>15-s[i]);return n}),Sa=new Ot(288),Me=0;Me<144;++Me)Sa[Me]=8;for(var Me=144;Me<256;++Me)Sa[Me]=9;for(var Me=256;Me<280;++Me)Sa[Me]=7;for(var Me=280;Me<288;++Me)Sa[Me]=8;for(var Qc=new Ot(32),Me=0;Me<32;++Me)Qc[Me]=5;var Mp=Ca(Sa,9,1),Np=Ca(Qc,5,1),sn=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},sr=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},on=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Vp=function(s){return(s+7)/8|0},nn=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))},Pp=["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"],Ht=function(s,e,t){var r=new Error(e||Pp[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,Ht),!t)throw r;return r},kp=function(s,e,t,r){var i=s.length,a=r?r.length:0;if(!i||e.f&&!e.l)return t||new Ot(0);var o=!t,n=o||e.i!=2,l=e.i;o&&(t=new Ot(i*3));var h=function(Qt){var Rt=t.length;if(Qt>Rt){var Vt=new Ot(Math.max(Rt*2,Qt));Vt.set(t),t=Vt}},u=e.f||0,c=e.p||0,f=e.b||0,g=e.l,p=e.d,A=e.m,U=e.n,x=i*8;do{if(!g){u=sr(s,c,1);var v=sr(s,c+1,3);if(c+=3,v)if(v==1)g=Mp,p=Np,A=9,U=5;else if(v==2){var y=sr(s,c,31)+257,b=sr(s,c+10,15)+4,w=y+sr(s,c+5,31)+1;c+=14;for(var R=new Ot(w),E=new Ot(19),N=0;N<b;++N)E[Ep[N]]=sr(s,c+N*3,7);c+=b*3;for(var z=sn(E),Y=(1<<z)-1,ee=Ca(E,z,1),N=0;N<w;){var oe=ee[sr(s,c,Y)];c+=oe&15;var S=oe>>4;if(S<16)R[N++]=S;else{var te=0,ge=0;for(S==16?(ge=3+sr(s,c,3),c+=2,te=R[N-1]):S==17?(ge=3+sr(s,c,7),c+=3):S==18&&(ge=11+sr(s,c,127),c+=7);ge--;)R[N++]=te}}var Ce=R.subarray(0,y),J=R.subarray(y);A=sn(Ce),U=sn(J),g=Ca(Ce,A,1),p=Ca(J,U,1)}else Ht(1);else{var S=Vp(c)+4,C=s[S-4]|s[S-3]<<8,_=S+C;if(_>i){l&&Ht(0);break}n&&h(f+C),t.set(s.subarray(S,_),f),e.b=f+=C,e.p=c=_*8,e.f=u;continue}if(c>x){l&&Ht(0);break}}n&&h(f+131072);for(var ce=(1<<A)-1,he=(1<<U)-1,Ue=c;;Ue=c){var te=g[on(s,c)&ce],xe=te>>4;if(c+=te&15,c>x){l&&Ht(0);break}if(te||Ht(2),xe<256)t[f++]=xe;else if(xe==256){Ue=c,g=null;break}else{var Ve=xe-254;if(xe>264){var N=xe-257,Ee=Sc[N];Ve=sr(s,c,(1<<Ee)-1)+bc[N],c+=Ee}var ye=p[on(s,c)&he],Ne=ye>>4;ye||Ht(3),c+=ye&15;var J=Dp[Ne];if(Ne>3){var Ee=_c[Ne];J+=on(s,c)&(1<<Ee)-1,c+=Ee}if(c>x){l&&Ht(0);break}n&&h(f+131072);var lt=f+Ve;if(f<J){var pr=a-J,Nt=Math.min(J,lt);for(pr+f<0&&Ht(3);f<Nt;++f)t[f]=r[pr+f]}for(;f<lt;++f)t[f]=t[f-J]}}e.l=g,e.p=Ue,e.b=f,e.f=u,g&&(u=1,e.m=A,e.d=p,e.n=U)}while(!u);return f!=t.length&&o?nn(t,0,f):t.subarray(0,f)},Lp=new Ot(0),Fr=function(s,e){return s[e]|s[e+1]<<8},or=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},ln=function(s,e){return or(s,e)+or(s,e+4)*4294967296};function Op(s,e){return kp(s,{i:2},e&&e.out,e&&e.dictionary)}var hn=typeof TextDecoder<"u"&&new TextDecoder,zp=0;try{hn.decode(Lp,{stream:!0}),zp=1}catch{}var Gp=function(s){for(var e="",t=0;;){var r=s[t++],i=(r>127)+(r>223)+(r>239);if(t+i>s.length)return{s:e,r:nn(s,t-1)};i?i==3?(r=((r&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|s[t++]&63):e+=String.fromCharCode((r&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(r)}};function Rc(s,e){if(e){for(var t="",r=0;r<s.length;r+=16384)t+=String.fromCharCode.apply(null,s.subarray(r,r+16384));return t}else{if(hn)return hn.decode(s);var i=Gp(s),a=i.s,t=i.r;return t.length&&Ht(8),a}}var Wp=function(s,e){return e+30+Fr(s,e+26)+Fr(s,e+28)},Jp=function(s,e,t){var r=Fr(s,e+28),i=Rc(s.subarray(e+46,e+46+r),!(Fr(s,e+8)&2048)),a=e+46+r,o=or(s,e+20),n=t&&o==4294967295?Zp(s,a):[o,or(s,e+24),or(s,e+42)],l=n[0],h=n[1],u=n[2];return[Fr(s,e+10),l,h,i,a+Fr(s,e+30)+Fr(s,e+32),u]},Zp=function(s,e){for(;Fr(s,e)!=1;e+=4+Fr(s,e+2));return[ln(s,e+12),ln(s,e+4),ln(s,e+20)]};function Yp(s,e){for(var t={},r=s.length-22;or(s,r)!=101010256;--r)(!r||s.length-r>65558)&&Ht(13);var i=Fr(s,r+8);if(!i)return{};var a=or(s,r+16),o=a==4294967295||i==65535;if(o){var n=or(s,r-12);o=or(s,n)==101075792,o&&(i=or(s,n+32),a=or(s,n+48))}for(var l=0;l<i;++l){var h=Jp(s,a,o),u=h[0],c=h[1],f=h[2],g=h[3],p=h[4],A=h[5],U=Wp(s,A);a=p,u?u==8?t[g]=Op(s.subarray(U,U+c),{out:new Ot(f)}):Ht(14,"unknown compression type "+u):t[g]=nn(s,U,U+c)}return t}class mt extends At{constructor(){super(),this.shader=new Da,this.baseMap=m.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 Qi extends Ie{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,r,i,a,o,n){super(),this.radius=e,this.widthSegments=t,this.heightSegments=r,this.phiStart=i,this.phiLength=a,this.thetaStart=o,this.thetaLength=n,this.buildGeometry()}buildGeometry(){var e,t,r=0;let i=this.heightSegments,a=this.widthSegments,o=this.radius;var n=(i+1)*(a+1);let l=new Float32Array(n*3),h=new Float32Array(n*3),u=new Float32Array(n*2),c=new Uint16Array(a*i*2*3),f=0,g=0,p=0;for(t=0;t<=i;++t){var A=Math.PI*t/i,U=o*Math.cos(A),x=o*Math.sin(A);for(e=0;e<=a;++e){var v=2*Math.PI*e/a,S=x*Math.cos(v),C=x*Math.sin(v),_=1/Math.sqrt(S*S+U*U+C*C);if(l[f++]=S,l[f++]=U,l[f++]=C,h[g++]=S*_,h[g++]=U*_,h[g++]=C*_,u[p++]=e/a,u[p++]=t/i,e>0&&t>0){var y=(a+1)*t+e,b=(a+1)*t+e-1,w=(a+1)*(t-1)+e-1,R=(a+1)*(t-1)+e;t==i?(c[r++]=y,c[r++]=w,c[r++]=R):t==1?(c[r++]=y,c[r++]=b,c[r++]=w):(c[r++]=y,c[r++]=b,c[r++]=w,c[r++]=y,c[r++]=w,c[r++]=R)}}}this.setIndices(c),this.setAttribute(V.position,l),this.setAttribute(V.normal,h),this.setAttribute(V.uv,u),this.setAttribute(V.TEXCOORD_1,u),this.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Fe(d.ZERO,new d(this.radius*2,this.radius*2,this.radius*2))}}class rs extends q{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 d(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),rs.register3DRepresentation)this.marker=rs.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new q;const e=this.marker.addComponent(K);e.geometry=new Qi(.1,32,16),e.material=new mt,e.material.baseColor=this.positionValid?new P(0,1,0,1):new P(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class is extends q{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const r=new rs(t);this.addChild(r)}this.entityChildren=this.entityChildren.sort((t,r)=>t.positionIndex-r.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),is.register3DRepresentation?(this.line=is.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new P(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const r=new Ie,i=new Float32Array(e.length*3);for(let h=0;h<e.length;h++)i[h*3]=e[h].x,i[h*3+1]=e[h].y,i[h*3+2]=e[h].z;const a=new Uint16Array((e.length-1)*2);for(let h=0;h<e.length-1;h++)a[h*2]=h,a[h*2+1]=h+1;r.setIndices(a),r.setAttribute(V.position,i),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const o=new q,n=o.addComponent(K),l=new mt;return l.topology="line-list",l.baseColor=t,l.blendMode=ae.ADD,l.castReflection=!1,n.geometry=r,n.material=l,o}}class Ic extends st{static format=Ge.BIN;parseBuffer(e){try{const t={template:null,waylines:null},r=Yp(new Uint8Array(e));for(const a in r){const o=r[a],l=new DOMParser().parseFromString(Rc(o),"application/xml"),h={};this.parseNode(l,h);const u=a.replace("wpmz/","").split(".")[0];Object.assign(t,{[u]:h["#document"].kml.Document})}const i=new is(t.waylines);this.data=i}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const r=["Placemark","actionGroup","action"],i=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[i]=void 0;else{let a=null,o=!1;for(let n=0;n<e.childNodes.length;++n){const l=e.childNodes[n];if(l.nodeType==Node.TEXT_NODE){const h=l.nodeValue?.trim();h&&h.length>0&&(a=h)}else l.nodeType==Node.ELEMENT_NODE&&(o=!0)}if(a&&!o)t[i]=a;else if(o){r.includes(i)?t[i]?.length?t[i].push({}):t[i]=[{}]:t[i]={};for(let n=0;n<e.childNodes.length;++n){const l=e.childNodes[n];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[i])?t[i].at(-1):t[i])}}else t[i]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class Ec{_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 r=t.getSprite(e);if(r)return r}return null}async load(e,t,r){return(await new pt().load(e,t,r)).data}async loadGltf(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let r,i=e.substring(e.lastIndexOf(".")).toLowerCase(),a=new pt;i==".gltf"?r=await a.load(e,xt,t):r=await a.load(e,Zo,t);let o=r.data;return this._prefabPool.set(e,o),this._gltfPool.set(e,r.gltf),o}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let r,i=e.substring(e.lastIndexOf(".")).toLowerCase(),a=new pt;i==".obj"&&(r=await a.load(e,ju,t));let o=r.data;return this._prefabPool.set(e,o),o}async loadB3DM(e,t,r){if(this._prefabPool.has(e))return this._prefabPool.get(e);let o=(await new pt().load(e,lc,t,r)).data;return this._prefabPool.set(e,o),o}async loadI3DM(e,t,r){if(this._prefabPool.has(e))return this._prefabPool.get(e);let o=(await new pt().load(e,gc,t,r)).data;return this._prefabPool.set(e,o),o}async loadTexture(e,t,r){if(this._texturePool.has(e))return this._texturePool.get(e);let i=new Vr;return i.flipY=r,await i.load(e,t),this._texturePool.set(e,i),i}async loadTextureCount(e,t,r,i){return new Promise(async(a,o)=>{let n=0,l=[];t==0&&a(l);for(let h=0;h<t;h++){const u=e.shift();this.loadTexture(u,r,i).then(c=>{l.push(c),n++,n==t&&a(l)})}})}async loadBitmapTextures(e,t=5,r,i){let a=[],o=Math.floor(e.length/t)+1,n=Math.floor(e.length%t);for(let l=0;l<o;l++){let h=await this.loadTextureCount(e,l==o-1?n:t,r,i);a.push(...h)}return a}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Ho;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadHDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new xs;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadLDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Bs;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadTextureCubeMaps(e){let t=e[0];if(this._texturePool.has(t))return this._texturePool.get(t);let r=new Yo;return await r.load(e),this._texturePool.set(e[0],r),r}async loadTextureCubeStd(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Yo;return await r.loadStd(e),r}async loadJSON(e,t){return await new pt().loadJson(e,t).then(async r=>r).catch(r=>{console.log(r)})}async loadFont(e,t,r){let a=await new pt().load(e,zr,t,r),o=a.data;return qi.addFontData(o.face,o.size,o),a.data}async loadAtlas(e,t){return(await new pt().load(e,Cc,t,e)).data}async loadKMZ(e,t){return(await new pt().load(e,Ic,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,r,i,a,o,n){let l=32,h=32,u=new Uint8Array(l*h*4);this.fillColor(u,e,t,r,i,a,o);let c=new So;return c.name=n,c.create(16,16,u,!0),n&&this.addTexture(n,c),c}fillColor(e,t,r,i,a,o,n){for(let l=0;l<t;l++)for(let h=0;h<r;h++){let u=h*t+l;e[u*4+0]=i,e[u*4+1]=a,e[u*4+2]=o,e[u*4+3]=n}}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 mc().generateBRDFLUTTexture(),r=t.name="BRDFLUT";this.addTexture(r,t),this.defaultSky=new xs,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 di(this.whiteTexture),this.defaultGUISprite=new Ki(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new Qr}}class wc extends ke{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(r=>{t.addPost(r)})}unActivePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(r=>{t.removePost(r)})}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 r=this.transform.view3D;m.getRenderJob(r).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Xp="1.0.13";class m{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 Q.presentationSize}static get aspect(){return Q.aspect}static get width(){return Q.windowWidth}static get height(){return Q.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 P(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",Xp),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await pe.init(I.allocCount,this.setting.doublePrecision),await Q.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,se.getGBufferFrame(se.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),O.init(),Mr.init(),ne.init(),Ct.init(),Tt.init(),this.res=new Ec,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new zn,this.inputSystem.initCanvas(Q.canvas)}static startRenderJob(e){let t=new bu(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(wc).addPost(wo),(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 r=performance.now();await new Promise(i=>{setTimeout(()=>{e+=performance.now()-r,i(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){Qe.delta=e-Qe.time,Qe.time=e,Qe.frame+=1,fi.tick(Qe.delta);let t=this.views,r=0;for(r=0;r<t.length;r++){const o=t[r];o.scene.waitUpdate();let[n,l]=Q.presentationSize;o.camera.viewPort.setTo(0,0,n,l)}this._beforeRender&&await this._beforeRender();for(const o of Se.componentsBeforeUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}let i=Q.device.createCommandEncoder();for(const o of Se.componentsComputeList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n,i)}}Q.device.queue.submit([i.finish()]);for(const o of Se.componentsUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}for(const o of Se.graphicComponent){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];n&&u.enable&&c(n)}}this._renderLoop&&await this._renderLoop(),pe.updateAllContinueTransform(0,I.useCount,16),ne.modelMatrixBindGroup.writeBuffer(I.useCount*16),this.renderJobs.forEach((o,n)=>{o.renderState||o.start(),o.renderFrame()});for(const o of Se.componentsLateUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}this._lateRender&&await this._lateRender()}}let Cs=`
|
|
7731
|
+
`}async loadFontTextures(){let e=[],t=this.data;for(const r of t.fontPage){let i=this.baseUrl+r.file;await m.res.loadTexture(i,null,!0);let a=m.res.getTexture(i),o=new di(a);e.push(o)}zr.parseSprite(e,t),t.fontChar[" "]||zr.insertSpaceChar(t,e[0])}static insertSpaceChar(e,t){let r=new Ki,i=e.size*.5,a=e.lineHeight*.5;r.id=" ",r.offsetSize.set(0,0,e.size,e.size),r.trimSize.set(i,a),r.width=i,r.height=a,r.xadvance=0,r.xoffset=0,r.yoffset=0,r.guiTexture=t,r.uvRec.set(0,0,1e-6,1e-6),qi.addFnt(e.face,e.size,r.id,r)}static readLineProperty(e,t){e.trim().split(" ").forEach((r,i)=>{let a=r.split("=");if(a.length>1){let o=a[0],n=a[1];Object.prototype.hasOwnProperty.call(t,o)&&(n.indexOf('"')==-1?t[o]=parseFloat(a[1]):t[o]=n.replace('"',"").replace('"',""))}})}}function Rp(s,e){let t=new Ki;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 di(e),t.uvRec.set(0,0,1,1),e.isVideoTexture||(e.flipY=!0),t}function vc(s,e,t){let r=new Ki;r.guiTexture=s,r.id=e,r.uvRec.copyFrom(t.textureRect),r.trimSize.x=t.textureRect.z,r.trimSize.y=t.textureRect.w,r.offsetSize.x=t.textureRectOffset.x,r.offsetSize.y=t.textureRectOffset.y,r.offsetSize.z=t.size.x,r.offsetSize.w=t.size.y,r.width=t.size.x,r.height=t.size.y;let i=1/s.width,a=1/s.height;r.uvRec.set(r.uvRec.x*i,r.uvRec.y*a,r.uvRec.z*i,r.uvRec.w*a);let o=.1;return t.border.x<=o&&t.border.y<=o&&t.border.z<=o&&t.border.x<=o?r.isSliced=!1:(r.borderSize.copyFrom(t.border),r.uvBorder.copyFrom(t.border),r.uvBorder.x-=t.textureRectOffset.x,r.uvBorder.y-=t.textureRectOffset.y,r.uvBorder.z=t.border.z-(t.size.x-t.textureRect.z-t.textureRectOffset.x),r.uvBorder.w=t.border.w-(t.size.y-t.textureRect.w-t.textureRectOffset.y),r.uvBorder.x/=t.textureRect.z,r.uvBorder.z/=t.textureRect.z,r.uvBorder.y/=t.textureRect.w,r.uvBorder.w/=t.textureRect.w,r.isSliced=!0),r}class Bc{_spriteMap=new Map;_spriteList=[];textureSize=new j;name;constructor(e){this.textureSize.set(e.x,e.y)}setTexture(e,t,r){let i=vc(e,t,r);return this._spriteMap.set(i.id,i),this._spriteList.push(i),i}getSprite(e){return this._spriteMap.get(e)}get spriteList(){return this._spriteList}}class Cc extends st{static format=Ge.TEXT;_json;_texture;async parseString(e){this._json=JSON.parse(e);let t=this.userData.replace(".json",".png");this._texture=await m.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 Bc(this._json.size),t=new di(this._texture),r=this._json.atlas;for(const i in r)e.setTexture(t,i,r[i]);m.res.addAtlas(this.baseUrl,e),this.data=e}}var Ot=Uint8Array,$i=Uint16Array,Ip=Int32Array,Sc=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]),_c=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]),Ep=new Ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Fc=function(s,e){for(var t=new $i(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var i=new Ip(t[30]),r=1;r<30;++r)for(var a=t[r];a<t[r+1];++a)i[a]=a-t[r]<<5|r;return{b:t,r:i}},yc=Fc(Sc,2),bc=yc.b,wp=yc.r;bc[28]=258,wp[258]=28;for(var Tp=Fc(_c,0),Dp=Tp.b,an=new $i(32768),Me=0;Me<32768;++Me){var ii=(Me&43690)>>1|(Me&21845)<<1;ii=(ii&52428)>>2|(ii&13107)<<2,ii=(ii&61680)>>4|(ii&3855)<<4,an[Me]=((ii&65280)>>8|(ii&255)<<8)>>1}for(var Ca=(function(s,e,t){for(var r=s.length,i=0,a=new $i(e);i<r;++i)s[i]&&++a[s[i]-1];var o=new $i(e);for(i=1;i<e;++i)o[i]=o[i-1]+a[i-1]<<1;var n;if(t){n=new $i(1<<e);var l=15-e;for(i=0;i<r;++i)if(s[i])for(var h=i<<4|s[i],u=e-s[i],c=o[s[i]-1]++<<u,f=c|(1<<u)-1;c<=f;++c)n[an[c]>>l]=h}else for(n=new $i(r),i=0;i<r;++i)s[i]&&(n[i]=an[o[s[i]-1]++]>>15-s[i]);return n}),Sa=new Ot(288),Me=0;Me<144;++Me)Sa[Me]=8;for(var Me=144;Me<256;++Me)Sa[Me]=9;for(var Me=256;Me<280;++Me)Sa[Me]=7;for(var Me=280;Me<288;++Me)Sa[Me]=8;for(var Qc=new Ot(32),Me=0;Me<32;++Me)Qc[Me]=5;var Mp=Ca(Sa,9,1),Np=Ca(Qc,5,1),sn=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},sr=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},on=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},Vp=function(s){return(s+7)/8|0},nn=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))},Pp=["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"],Ht=function(s,e,t){var r=new Error(e||Pp[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,Ht),!t)throw r;return r},kp=function(s,e,t,r){var i=s.length,a=r?r.length:0;if(!i||e.f&&!e.l)return t||new Ot(0);var o=!t,n=o||e.i!=2,l=e.i;o&&(t=new Ot(i*3));var h=function(Qt){var Rt=t.length;if(Qt>Rt){var Vt=new Ot(Math.max(Rt*2,Qt));Vt.set(t),t=Vt}},u=e.f||0,c=e.p||0,f=e.b||0,g=e.l,p=e.d,A=e.m,U=e.n,x=i*8;do{if(!g){u=sr(s,c,1);var v=sr(s,c+1,3);if(c+=3,v)if(v==1)g=Mp,p=Np,A=9,U=5;else if(v==2){var y=sr(s,c,31)+257,b=sr(s,c+10,15)+4,w=y+sr(s,c+5,31)+1;c+=14;for(var R=new Ot(w),E=new Ot(19),N=0;N<b;++N)E[Ep[N]]=sr(s,c+N*3,7);c+=b*3;for(var z=sn(E),Y=(1<<z)-1,ee=Ca(E,z,1),N=0;N<w;){var oe=ee[sr(s,c,Y)];c+=oe&15;var S=oe>>4;if(S<16)R[N++]=S;else{var te=0,ge=0;for(S==16?(ge=3+sr(s,c,3),c+=2,te=R[N-1]):S==17?(ge=3+sr(s,c,7),c+=3):S==18&&(ge=11+sr(s,c,127),c+=7);ge--;)R[N++]=te}}var Ce=R.subarray(0,y),J=R.subarray(y);A=sn(Ce),U=sn(J),g=Ca(Ce,A,1),p=Ca(J,U,1)}else Ht(1);else{var S=Vp(c)+4,C=s[S-4]|s[S-3]<<8,_=S+C;if(_>i){l&&Ht(0);break}n&&h(f+C),t.set(s.subarray(S,_),f),e.b=f+=C,e.p=c=_*8,e.f=u;continue}if(c>x){l&&Ht(0);break}}n&&h(f+131072);for(var ce=(1<<A)-1,he=(1<<U)-1,Ue=c;;Ue=c){var te=g[on(s,c)&ce],xe=te>>4;if(c+=te&15,c>x){l&&Ht(0);break}if(te||Ht(2),xe<256)t[f++]=xe;else if(xe==256){Ue=c,g=null;break}else{var Ve=xe-254;if(xe>264){var N=xe-257,Ee=Sc[N];Ve=sr(s,c,(1<<Ee)-1)+bc[N],c+=Ee}var ye=p[on(s,c)&he],Ne=ye>>4;ye||Ht(3),c+=ye&15;var J=Dp[Ne];if(Ne>3){var Ee=_c[Ne];J+=on(s,c)&(1<<Ee)-1,c+=Ee}if(c>x){l&&Ht(0);break}n&&h(f+131072);var lt=f+Ve;if(f<J){var pr=a-J,Nt=Math.min(J,lt);for(pr+f<0&&Ht(3);f<Nt;++f)t[f]=r[pr+f]}for(;f<lt;++f)t[f]=t[f-J]}}e.l=g,e.p=Ue,e.b=f,e.f=u,g&&(u=1,e.m=A,e.d=p,e.n=U)}while(!u);return f!=t.length&&o?nn(t,0,f):t.subarray(0,f)},Lp=new Ot(0),Fr=function(s,e){return s[e]|s[e+1]<<8},or=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},ln=function(s,e){return or(s,e)+or(s,e+4)*4294967296};function Op(s,e){return kp(s,{i:2},e&&e.out,e&&e.dictionary)}var hn=typeof TextDecoder<"u"&&new TextDecoder,zp=0;try{hn.decode(Lp,{stream:!0}),zp=1}catch{}var Gp=function(s){for(var e="",t=0;;){var r=s[t++],i=(r>127)+(r>223)+(r>239);if(t+i>s.length)return{s:e,r:nn(s,t-1)};i?i==3?(r=((r&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?e+=String.fromCharCode((r&31)<<6|s[t++]&63):e+=String.fromCharCode((r&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(r)}};function Rc(s,e){if(e){for(var t="",r=0;r<s.length;r+=16384)t+=String.fromCharCode.apply(null,s.subarray(r,r+16384));return t}else{if(hn)return hn.decode(s);var i=Gp(s),a=i.s,t=i.r;return t.length&&Ht(8),a}}var Wp=function(s,e){return e+30+Fr(s,e+26)+Fr(s,e+28)},Jp=function(s,e,t){var r=Fr(s,e+28),i=Rc(s.subarray(e+46,e+46+r),!(Fr(s,e+8)&2048)),a=e+46+r,o=or(s,e+20),n=t&&o==4294967295?Zp(s,a):[o,or(s,e+24),or(s,e+42)],l=n[0],h=n[1],u=n[2];return[Fr(s,e+10),l,h,i,a+Fr(s,e+30)+Fr(s,e+32),u]},Zp=function(s,e){for(;Fr(s,e)!=1;e+=4+Fr(s,e+2));return[ln(s,e+12),ln(s,e+4),ln(s,e+20)]};function Yp(s,e){for(var t={},r=s.length-22;or(s,r)!=101010256;--r)(!r||s.length-r>65558)&&Ht(13);var i=Fr(s,r+8);if(!i)return{};var a=or(s,r+16),o=a==4294967295||i==65535;if(o){var n=or(s,r-12);o=or(s,n)==101075792,o&&(i=or(s,n+32),a=or(s,n+48))}for(var l=0;l<i;++l){var h=Jp(s,a,o),u=h[0],c=h[1],f=h[2],g=h[3],p=h[4],A=h[5],U=Wp(s,A);a=p,u?u==8?t[g]=Op(s.subarray(U,U+c),{out:new Ot(f)}):Ht(14,"unknown compression type "+u):t[g]=nn(s,U,U+c)}return t}class mt extends At{constructor(){super(),this.shader=new Da,this.baseMap=m.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 Qi extends Ie{shape_vertices=[];shape_indices=[];radius;widthSegments;heightSegments;phiStart;phiLength;thetaStart;thetaLength;constructor(e,t,r,i,a,o,n){super(),this.radius=e,this.widthSegments=t,this.heightSegments=r,this.phiStart=i,this.phiLength=a,this.thetaStart=o,this.thetaLength=n,this.buildGeometry()}buildGeometry(){var e,t,r=0;let i=this.heightSegments,a=this.widthSegments,o=this.radius;var n=(i+1)*(a+1);let l=new Float32Array(n*3),h=new Float32Array(n*3),u=new Float32Array(n*2),c=new Uint16Array(a*i*2*3),f=0,g=0,p=0;for(t=0;t<=i;++t){var A=Math.PI*t/i,U=o*Math.cos(A),x=o*Math.sin(A);for(e=0;e<=a;++e){var v=2*Math.PI*e/a,S=x*Math.cos(v),C=x*Math.sin(v),_=1/Math.sqrt(S*S+U*U+C*C);if(l[f++]=S,l[f++]=U,l[f++]=C,h[g++]=S*_,h[g++]=U*_,h[g++]=C*_,u[p++]=e/a,u[p++]=t/i,e>0&&t>0){var y=(a+1)*t+e,b=(a+1)*t+e-1,w=(a+1)*(t-1)+e-1,R=(a+1)*(t-1)+e;t==i?(c[r++]=y,c[r++]=w,c[r++]=R):t==1?(c[r++]=y,c[r++]=b,c[r++]=w):(c[r++]=y,c[r++]=b,c[r++]=w,c[r++]=y,c[r++]=w,c[r++]=R)}}}this.setIndices(c),this.setAttribute(V.position,l),this.setAttribute(V.normal,h),this.setAttribute(V.uv,u),this.setAttribute(V.TEXCOORD_1,u),this.addSubGeometry({indexStart:0,indexCount:c.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.bounds=new Fe(d.ZERO,new d(this.radius*2,this.radius*2,this.radius*2))}}class rs extends q{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 d(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),rs.register3DRepresentation)this.marker=rs.register3DRepresentation(this),this.marker&&this.addChild(this.marker);else{this.marker=new q;const e=this.marker.addComponent(K);e.geometry=new Qi(.1,32,16),e.material=new mt,e.material.baseColor=this.positionValid?new P(0,1,0,1):new P(1,0,0,1),this.addChild(this.marker),this.marker.name="WayPoint3DMarker"}}}class is extends q{static register3DRepresentation=null;line;constructor(e){super(),this.parseWayLineFile(e),this.setup3DRepresentation()}parseWayLineFile(e){for(const t of e.Folder.Placemark){const r=new rs(t);this.addChild(r)}this.entityChildren=this.entityChildren.sort((t,r)=>t.positionIndex-r.positionIndex)}setup3DRepresentation(){this.line&&(this.removeChild(this.line),this.line=null),is.register3DRepresentation?(this.line=is.register3DRepresentation(this),this.line&&this.addChild(this.line)):(this.line=this.createMultiLine(this.entityChildren.map(e=>e.localPosition),new P(1,1,1,1)),this.addChild(this.line),this.line.name="WayLines3DLine")}createMultiLine(e,t){if(e.length<2)return null;const r=new Ie,i=new Float32Array(e.length*3);for(let h=0;h<e.length;h++)i[h*3]=e[h].x,i[h*3+1]=e[h].y,i[h*3+2]=e[h].z;const a=new Uint16Array((e.length-1)*2);for(let h=0;h<e.length-1;h++)a[h*2]=h,a[h*2+1]=h+1;r.setIndices(a),r.setAttribute(V.position,i),r.addSubGeometry({indexStart:0,indexCount:a.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0});const o=new q,n=o.addComponent(K),l=new mt;return l.topology="line-list",l.baseColor=t,l.blendMode=ae.ADD,l.castReflection=!1,n.geometry=r,n.material=l,o}}class Ic extends st{static format=Ge.BIN;parseBuffer(e){try{const t={template:null,waylines:null},r=Yp(new Uint8Array(e));for(const a in r){const o=r[a],l=new DOMParser().parseFromString(Rc(o),"application/xml"),h={};this.parseNode(l,h);const u=a.replace("wpmz/","").split(".")[0];Object.assign(t,{[u]:h["#document"].kml.Document})}const i=new is(t.waylines);this.data=i}catch(t){this.parserError(`KMZ parsing failed: ${t}`,-1)}}parseNode(e,t){const r=["Placemark","actionGroup","action"],i=e.nodeName.replace("wpml:","");if(!e.childNodes.length)t[i]=void 0;else{let a=null,o=!1;for(let n=0;n<e.childNodes.length;++n){const l=e.childNodes[n];if(l.nodeType==Node.TEXT_NODE){const h=l.nodeValue?.trim();h&&h.length>0&&(a=h)}else l.nodeType==Node.ELEMENT_NODE&&(o=!0)}if(a&&!o)t[i]=a;else if(o){r.includes(i)?t[i]?.length?t[i].push({}):t[i]=[{}]:t[i]={};for(let n=0;n<e.childNodes.length;++n){const l=e.childNodes[n];l.nodeType==Node.ELEMENT_NODE&&this.parseNode(l,Array.isArray(t[i])?t[i].at(-1):t[i])}}else t[i]=void 0}}verification(){if(this.data)return!0;throw new Error("verify failed.")}}class Ec{_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 r=t.getSprite(e);if(r)return r}return null}async load(e,t,r){return(await new pt().load(e,t,r)).data}async loadGltf(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let r,i=e.substring(e.lastIndexOf(".")).toLowerCase(),a=new pt;i==".gltf"?r=await a.load(e,xt,t):r=await a.load(e,Zo,t);let o=r.data;return this._prefabPool.set(e,o),this._gltfPool.set(e,r.gltf),o}async loadObj(e,t){if(this._prefabPool.has(e))return this._prefabPool.get(e);let r,i=e.substring(e.lastIndexOf(".")).toLowerCase(),a=new pt;i==".obj"&&(r=await a.load(e,ju,t));let o=r.data;return this._prefabPool.set(e,o),o}async loadB3DM(e,t,r){if(this._prefabPool.has(e))return this._prefabPool.get(e);let o=(await new pt().load(e,lc,t,r)).data;return this._prefabPool.set(e,o),o}async loadI3DM(e,t,r){if(this._prefabPool.has(e))return this._prefabPool.get(e);let o=(await new pt().load(e,gc,t,r)).data;return this._prefabPool.set(e,o),o}async loadTexture(e,t,r){if(this._texturePool.has(e))return this._texturePool.get(e);let i=new Vr;return i.flipY=r,await i.load(e,t),this._texturePool.set(e,i),i}async loadTextureCount(e,t,r,i){return new Promise(async(a,o)=>{let n=0,l=[];t==0&&a(l);for(let h=0;h<t;h++){const u=e.shift();this.loadTexture(u,r,i).then(c=>{l.push(c),n++,n==t&&a(l)})}})}async loadBitmapTextures(e,t=5,r,i){let a=[],o=Math.floor(e.length/t)+1,n=Math.floor(e.length%t);for(let l=0;l<o;l++){let h=await this.loadTextureCount(e,l==o-1?n:t,r,i);a.push(...h)}return a}async loadHDRTexture(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Ho;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadHDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new xs;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadLDRTextureCube(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Bs;return r=await r.load(e,t),this._texturePool.set(e,r),r}async loadTextureCubeMaps(e){let t=e[0];if(this._texturePool.has(t))return this._texturePool.get(t);let r=new Yo;return await r.load(e),this._texturePool.set(e[0],r),r}async loadTextureCubeStd(e,t){if(this._texturePool.has(e))return this._texturePool.get(e);let r=new Yo;return await r.loadStd(e),r}async loadJSON(e,t){return await new pt().loadJson(e,t).then(async r=>r).catch(r=>{console.log(r)})}async loadFont(e,t,r){let a=await new pt().load(e,zr,t,r),o=a.data;return qi.addFontData(o.face,o.size,o),a.data}async loadAtlas(e,t){return(await new pt().load(e,Cc,t,e)).data}async loadKMZ(e,t){return(await new pt().load(e,Ic,t)).data}normalTexture;maskTexture;whiteTexture;blackTexture;redTexture;blueTexture;greenTexture;yellowTexture;grayTexture;defaultSky;defaultGUITexture;defaultGUISprite;defaultMaterial;createTexture(e,t,r,i,a,o,n){let l=32,h=32,u=new Uint8Array(l*h*4);this.fillColor(u,e,t,r,i,a,o);let c=new So;return c.name=n,c.create(16,16,u,!0),n&&this.addTexture(n,c),c}fillColor(e,t,r,i,a,o,n){for(let l=0;l<t;l++)for(let h=0;h<r;h++){let u=h*t+l;e[u*4+0]=i,e[u*4+1]=a,e[u*4+2]=o,e[u*4+3]=n}}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 mc().generateBRDFLUTTexture(),r=t.name="BRDFLUT";this.addTexture(r,t),this.defaultSky=new xs,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 di(this.whiteTexture),this.defaultGUISprite=new Ki(this.defaultGUITexture),this.defaultGUISprite.trimSize.set(4,4),this.defaultMaterial=new Qr}}class wc extends ke{_postList;init(e){this._postList=new Map}start(){}stop(){}onEnable(){this.activePost()}onDisable(){this.unActivePost()}activePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(r=>{t.addPost(r)})}unActivePost(){let e=this.transform.view3D,t=m.getRenderJob(e);this._postList.forEach(r=>{t.removePost(r)})}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 r=this.transform.view3D;m.getRenderJob(r).removePost(t)}getPost(e){return this._postList.has(e)?this._postList.get(e):null}}const Xp="1.0.15";class m{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 Q.presentationSize}static get aspect(){return Q.aspect}static get width(){return Q.windowWidth}static get height(){return Q.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 P(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",Xp),window.isSecureContext||console.warn("WebGPU is only supported in secure contexts (HTTPS or localhost)"),this.setting={...this.setting,...e.engineSetting},await pe.init(I.allocCount,this.setting.doublePrecision),await Q.init(e.canvasConfig),this.setting.reflectionSetting.width=this.setting.reflectionSetting.reflectionProbeSize*6,this.setting.reflectionSetting.height=this.setting.reflectionSetting.reflectionProbeSize*this.setting.reflectionSetting.reflectionProbeMaxCount,se.getGBufferFrame(se.reflections_GBuffer,this.setting.reflectionSetting.width,this.setting.reflectionSetting.height,!1),O.init(),Mr.init(),ne.init(),Ct.init(),Tt.init(),this.res=new Ec,this.res.initDefault(),this._beforeRender=e.beforeRender,this._renderLoop=e.renderLoop,this._lateRender=e.lateRender,this.inputSystem=new zn,this.inputSystem.initCanvas(Q.canvas)}static startRenderJob(e){let t=new bu(e);return this.renderJobs.set(e,t),this.setting.pick.mode=="pixel"&&e.scene.getOrAddComponent(wc).addPost(wo),(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 r=performance.now();await new Promise(i=>{setTimeout(()=>{e+=performance.now()-r,i(!0)},this._frameRateValue-t)})}this._time=e}await this.updateFrame(e),this._requestAnimationFrameID=0,this.resume()}static async updateFrame(e){Qe.delta=e-Qe.time,Qe.time=e,Qe.frame+=1,fi.tick(Qe.delta);let t=this.views,r=0;for(r=0;r<t.length;r++){const o=t[r];o.scene.waitUpdate();let[n,l]=Q.presentationSize;o.camera.viewPort.setTo(0,0,n,l)}this._beforeRender&&await this._beforeRender();for(const o of Se.componentsBeforeUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}let i=Q.device.createCommandEncoder();for(const o of Se.componentsComputeList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n,i)}}Q.device.queue.submit([i.finish()]);for(const o of Se.componentsUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}for(const o of Se.graphicComponent){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];n&&u.enable&&c(n)}}this._renderLoop&&await this._renderLoop(),pe.updateAllContinueTransform(0,I.useCount,16),ne.modelMatrixBindGroup.writeBuffer(I.useCount*16),this.renderJobs.forEach((o,n)=>{o.renderState||o.start(),o.renderFrame()});for(const o of Se.componentsLateUpdateList){let n=o[0],l=o[1];for(const h of l){let u=h[0],c=h[1];u.enable&&c(n)}}this._lateRender&&await this._lateRender()}}let Cs=`
|
|
7758
7732
|
struct BloomCfg{
|
|
7759
7733
|
downSampleStep: f32,
|
|
7760
7734
|
downSampleBlurSize: f32,
|
|
@@ -11652,7 +11626,7 @@ fn frag(){
|
|
|
11652
11626
|
${this.fs}
|
|
11653
11627
|
`}class An extends At{_scissorRect;_screenSize=new j(1024,768);_scissorEnable=!1;constructor(e){super(),O.register("GUI_shader_view",mn.GUI_shader_view),O.register("GUI_shader_world",mn.GUI_shader_world);let t=new ot;this.addColorPass(t,H.COLOR,e),this.addColorPass(t,H.UI,e),this.shader=t}addColorPass(e,t,r){let i=r==jt.View?"GUI_shader_view":"GUI_shader_world",a=new Pe(i,i);a.passType=t,a.setShaderEntry("VertMain","FragMain"),a.setUniformVector4("scissorRect",new $),a.setUniformVector2("screenSize",this._screenSize),a.setUniformFloat("scissorCornerRadius",0),a.setUniformFloat("scissorFadeOutSize",0),a.setUniformFloat("pixelRatio",1),a.setUniformVector3("v3",d.ZERO);let o=a.shaderState;o.depthWriteEnabled=!1,a.blendMode=ae.NORMAL,a.depthCompare=r==jt.View?et.always:et.less_equal,a.cullMode=Et.back,e.addRenderPass(a)}setPanelRatio(e){this.shader.setUniformFloat("pixelRatio",e)}setScissorRect(e,t,r,i){this._scissorRect||=new $,this._scissorRect.set(e,t,r,i),this.shader.setUniformVector4("scissorRect",this._scissorRect)}setScissorEnable(e){this._scissorEnable!=e&&(this._scissorEnable=e,e?this.shader.setDefine("SCISSOR_ENABLE",!0):this.shader.deleteDefine("SCISSOR_ENABLE"),this.shader.noticeValueChange())}setScissorCorner(e,t){this.shader.setUniformFloat("scissorCornerRadius",e),this.shader.setUniformFloat("scissorFadeOutSize",t)}setScreenSize(e,t){return this._screenSize.set(e,t),this.shader.setUniformVector2("screenSize",this._screenSize),this}setTextures(e){for(let t=0;t<7;t++){let r=e[t]||m.res.whiteTexture;this.shader.setTexture(`tex_${t}`,r),this.setVideoTextureDefine(t,r.isVideoTexture)}}_videoTextureFlags={};setVideoTextureDefine(e,t){let r=!1;t!=this._videoTextureFlags[e]&&(t?this.shader.setDefine(`VideoTexture${e}`,!0):this.shader.deleteDefine(`VideoTexture${e}`),this._videoTextureFlags[e]=t,r=!0),r&&this.shader.noticeValueChange()}set envMap(e){}set shadowMap(e){}set baseMap(e){}set normalMap(e){}set emissiveMap(e){}set irradianceMap(e){}set irradianceDepthMap(e){}}class If extends K{_guiGeometry;init(e){super.init(),this.addRendererMask(ve.UI),this.removeRendererMask(ve.Default),this.castGI=!1,this.castShadow=!1,this.alwaysRender=!0,this._ignoreEnvMap=this._ignorePrefilterMap=!0}get geometry(){return super.geometry}set geometry(e){super.geometry=e,this._guiGeometry=e}nodeUpdate(e,t,r,i){for(let a=0;a<this.materials.length;a++){let n=this.materials[a].getPass(t),l=this._guiGeometry.getPositionBuffer(),h=this._guiGeometry.getSpriteBuffer(),u=this._guiGeometry.getColorBuffer();if(n)for(let c=0;c<n.length;c++){const f=n[c];f.pipeline||(f.setStorageBuffer("vPositionBuffer",l),f.setStorageBuffer("vSpriteBuffer",h),f.setStorageBuffer("vColorBuffer",u))}}super.nodeUpdate(e,t,r,i)}onUpdate(e){}}class Ef{_use;_unUse;constructor(){this._use=[],this._unUse=[]}pushBack(e){let t=this._use.indexOf(e);t!=-1&&(this._use.splice(t,1),this._unUse.push(e))}getUseList(){return this._use}getOne(e,t){let r;return this._unUse.length>0?(r=this._unUse[0],this._unUse.splice(0,1),this._use.push(r),r):(r=new e(t),this._use.push(r),r)}hasFree(){return this._unUse.length>0}}let Ra;class Ir{x=0;y=0;z=0;width=1;height=1;_globalX=0;_globalY=0;_globalWidth=0;_globalHeight=0;_visible=!0;_offsetX=0;_offsetY=0;_sprite=m.res.defaultGUISprite;_color=new P(1,1,1,1);_imageType=ea.Simple;dirtyAttributes=Je.MAX;cacheTextureId=-1;static textPool;static get quadPool(){return this.textPool||=new Ef,this.textPool}static recycleQuad(e){e.sprite=null,e.dirtyAttributes=Je.MAX,e.x=0,e.y=0,e.z=-1,e.cacheTextureId=-1,Ir.quadPool.pushBack(e)}static spawnQuad(){return Ir.quadPool.getOne(Ir)}get imageType(){return this._imageType}set imageType(e){this._imageType=e,this.setAttrChange(Je.SPRITE|Je.POSITION)}get color(){return this._color}set color(e){this._color.copyFrom(e),this.setAttrChange(Je.COLOR)}get visible(){return this._visible}set visible(e){e!=this._visible&&(this._visible=e,this.setAttrChange(Je.SPRITE))}get sprite(){return this._sprite}set sprite(e){this._sprite!=e&&(this._sprite=e,this.setAttrChange(Je.SPRITE|Je.POSITION))}get left(){return this._globalX-this._offsetX}get right(){return this.left+this._globalWidth}get top(){return this._globalY-this._offsetY}get bottom(){return this.top+this._globalHeight}setSize(e,t){this.width=e,this.height=t,this.setAttrChange(Je.POSITION)}setXY(e,t){this.x=e,this.y=t,this.setAttrChange(Je.POSITION)}setAttrChange(e){this.dirtyAttributes=this.dirtyAttributes|e}applyTransform(e){this.setAttrChange(Je.POSITION);let t=this._sprite,r=e.getWorldMatrix();(this.x!=0||this.y!=0)&&(r=this.getQuadMatrix(r));let i=r.getScaleX(),a=r.getScaleY(),o=t.isSliced&&this._imageType==ea.Sliced;if(this._offsetX=e.width*.5*i,this._offsetY=e.height*.5*a,o)this._globalWidth=i*(e.width-(t.offsetSize.z-t.trimSize.x)),this._globalHeight=a*(e.height-(t.offsetSize.w-t.trimSize.y)),this._globalX=r.tx+t.offsetSize.x*i,this._globalY=r.ty+t.offsetSize.y*a;else{let n=this.width/t.offsetSize.z,l=this.height/t.offsetSize.w;this._globalWidth=i*t.trimSize.x*n,this._globalHeight=a*t.trimSize.y*l,this._globalX=r.tx+t.offsetSize.x*n*i,this._globalY=r.ty+t.offsetSize.y*l*a}return this}getQuadMatrix(e){return Ra||=new wi,Ra.identity(),Ra.setTranslate(this.x,this.y),Ra.mul(e),Ra}writeToGeometry(e,t){return e.fillQuad(this,t),this.dirtyAttributes=Je.NONE,this}}class Un extends ke{_uiTransform;_visible=!0;destroy(){this._uiTransform.setNeedUpdateUIPanel(),super.destroy()}get uiTransform(){return this._uiTransform}get visible(){return this._visible}set visible(e){this._visible!=e&&(this._visible=e,this.onUIComponentVisible?.(this._visible))}init(e){super.init?.(e),this._uiTransform=this.object3D.getOrAddComponent(Jr),this._uiTransform.setNeedUpdateUIPanel()}copyComponent(e){return this.visible=e.visible,this}}class Ia extends Un{_mainQuads;_shadowRender;_shadowSource;isUIShadow;isShadowless;needUpdateShadow;init(e){super.init?.(e),this._mainQuads=[]}destroy(){this.detachQuads(),this._shadowRender?.setShadowSource(null),this._shadowSource?.setShadowRenderer(null),super.destroy(),this._shadowRender=null,this._shadowSource=null}start(){super.start?.(),this.isUIShadow?this.autoBindShadow(null,this):this.isShadowless||this.autoBindShadow(this,null),this.setShadowDirty()}setShadowDirty(){this._shadowRender&&(this._shadowRender.needUpdateShadow=!0)}get mainQuads(){return this._mainQuads}setShadowRenderer(e){this._shadowRender=e}setShadowSource(e){this._shadowSource=e}getShadowRender(){return this._shadowRender}autoBindShadow(e,t){let r=this.object3D.components.values();if(!e)for(let i of r){let a=i;if(!(a.isShadowless||a.isUIShadow)&&a.mainQuads){e=a;break}}if(!t)for(let i of r){let a=i;if(a.isUIShadow&&a.mainQuads){t=a;break}}return e&&t?(e.setShadowRenderer(t),t.setShadowSource(e),!0):!1}recycleQuad(e){if(e&&this._mainQuads){let t=this._mainQuads.indexOf(e);t>=0?(this._mainQuads.splice(t,1),Ir.recycleQuad(e)):e=null}return e}attachQuad(e){return this._mainQuads&&this._mainQuads.push(e),this}detachQuads(){if(this._mainQuads)for(;this._mainQuads.length>0;){let e=this._mainQuads.shift();this.recycleQuad(e)}return this}copyComponent(e){return super.copyComponent(e),this.isUIShadow=e.isUIShadow,this.isShadowless=e.isShadowless,this}}class Ti extends Ia{init(e){super.init?.(e),this.attachQuad(Ir.spawnQuad()),this.sprite=m.res.defaultGUISprite}cloneTo(e){e.getOrAddComponent(Ti).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.sprite=e.sprite,this.color=e.color,this.imageType=e.imageType,this}set sprite(e){e||=m.res.defaultGUISprite;for(let t of this._mainQuads)t.sprite=e,t.setSize(this._uiTransform.width,this._uiTransform.height);this.setShadowDirty()}onTransformResize(){this.applyTransformSize()}applyTransformSize(){for(let e of this._mainQuads)e.setSize(this._uiTransform.width,this._uiTransform.height);this.setShadowDirty()}get sprite(){return this._mainQuads[0].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}get color(){return this._mainQuads[0].color}set color(e){for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get imageType(){return this._mainQuads[0].imageType}set imageType(e){for(let t of this._mainQuads)t.imageType=e;this.setShadowDirty()}}class Ha extends Ti{space=jt.World;needUpdateGeometry=!0;panelOrder=0;needSortOnCameraZ;_billboard;_rebuild;scissorEnable=!1;scissorCornerRadius=0;scissorFadeOutSize=0;_uiRenderer;_geometry;_maxCount=128;panelRatio=1;isUIPanel=!0;cloneTo(e){e.getOrAddComponent(Ha).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.panelOrder=e.panelOrder,this.needSortOnCameraZ=e.needSortOnCameraZ,this.cullMode=e.cullMode,this.billboard=e.billboard,this.scissorEnable=e.scissorEnable,this.scissorCornerRadius=e.scissorCornerRadius,this.scissorFadeOutSize=e.scissorFadeOutSize,this}init(e){super.init(e),this._uiTransform.resize(Q.canvas.width,Q.canvas.height),this.create(this.space),this.visible=!1}updateDrawCallSegment(e,t,r){this._geometry.updateSubGeometry(e,t,r);let i=this._uiRenderer.material,a=this._uiRenderer.materials[e];if(!a){a=new An(this.space);let o=this._uiRenderer.materials.slice();o.push(a),this._uiRenderer.materials=o,a.cullMode=i.cullMode,a.depthCompare=i.depthCompare}}create(e){this._maxCount=this.space==jt.World?Ri.quadMaxCountForWorld:Ri.quadMaxCountForView,this._uiRenderer=this.object3D.addComponent(If),this._geometry=this._uiRenderer.geometry=new bf(this._maxCount).create(),this._uiRenderer.material=new An(e),this._uiRenderer.renderOrder=Ri.SortOrderStartWorld,this._rebuild=new Rf,this.object3D.bound=new Fe(new d,new d(1,1,1).multiplyScalar(Number.MAX_VALUE*.1))}get quadMaxCount(){return this._maxCount}get renderer(){return this._uiRenderer}set billboard(e){this.space==jt.View&&(e=ai.None,console.warn("Cannot enable billboard in view space")),e==ai.BillboardXYZ||e==ai.BillboardY?(this._billboard=this.object3D.getOrAddComponent(Ya),this._billboard.type=e):(this.object3D.removeComponent(Ya),this._billboard=null)}get billboard(){return this._billboard?this._billboard.type:ai.None}set cullMode(e){if(this.space==jt.World)for(let t of this._uiRenderer.materials)t.cullMode=e;else console.warn("Cannot change cullMode in view space")}get cullMode(){return this._uiRenderer.material.cullMode}onUpdate(e){super.onUpdate?.(e),this.rebuildGUIMesh(e)}_collectTransform=[];rebuildGUIMesh(e){let t=this,r=t._collectTransform;if(r.length=0,t.object3D.getComponents(Jr,r),r.length>0){t._rebuild.build(r,t,t.needUpdateGeometry);for(const n of r)n.needUpdateQuads=!1}let i=t.object3D.getComponentFromParent(Xa),a=i?i.index:0;t._uiRenderer.enable=r.length>0;let o=t.isViewPanel?Ri.SortOrderStartView:Ri.SortOrderStartWorld;if(t._uiRenderer.renderOrder=a*Ri.SortOrderCanvasSpan+o+t.panelOrder,t._uiRenderer.needSortOnCameraZ=t.needSortOnCameraZ,this.space==jt.View){let n=Q.canvas.clientWidth,l=Q.canvas.clientHeight,h=this._uiTransform.width,u=this._uiTransform.height;this.panelRatio=this.updateGUIPixelRatio(n,l,h,u)}else this.panelRatio=1;for(let n of t._uiRenderer.materials){let l=n;if(l.setPanelRatio(this.panelRatio),l.setScreenSize(Q.canvas.clientWidth,Q.canvas.clientHeight),l.setScissorEnable(t.scissorEnable),t.scissorEnable){let h=t.mainQuads[0];l.setScissorRect(h.left,h.bottom,h.right,h.top),l.setScissorCorner(t.scissorCornerRadius,t.scissorFadeOutSize)}}t.needUpdateGeometry=!1}updateGUIPixelRatio(e,t,r,i){let a=r/i,o=e/t,n=1;return a<o?n=t/i:n=e/r,n}}class zs extends Ha{isViewPanel=!0;space=jt.View;constructor(){super()}cloneTo(e){e.getOrAddComponent(zs).copyComponent(this)}}class Gs extends Ha{isWorldPanel=!0;space=jt.World;_depthTest=!0;constructor(){super()}cloneTo(e){e.getOrAddComponent(Gs).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.depthTest=e.depthTest,this}get depthTest(){return this._depthTest}set depthTest(e){if(this._depthTest!=e){this._depthTest=e;let t=this.depthTest?et.less_equal:et.always;for(let r of this._uiRenderer.materials)r.depthCompare=t}}}let wf;class Jr extends ke{useParentPivot=!1;parent;pivotX=.5;pivotY=.5;_width=100;_height=100;_localVisible=!0;_globalVisible=!0;_uiInteractiveList;get uiInteractiveList(){return this._uiInteractiveList}constructor(){super(),this._localMatrix=new wi,this._worldMatrix=new wi}init(e){super.init(e),this.transform.eventDispatcher.addEventListener(this.transform.eventLocalChange.type,this.onTransformChange,this),this.onParentChange(null,this.object3D.parent?.object3D)}onTransformChange(e){this.onChange=!0}addUIInteractive(e){return this._uiInteractiveList||=[],this._uiInteractiveList.push(e),this}removeUIInteractive(e){if(this._uiInteractiveList){let t=this._uiInteractiveList.indexOf(e);if(t>=0)return this._uiInteractiveList.slice(t,1),e}return null}get globalVisible(){return this._globalVisible}set visible(e){if(this._localVisible!=e){this._localVisible=e;let t=this.parent?this.parent._globalVisible:!0;this.onUITransformVisible(this._localVisible&&t)}}get visible(){return this._localVisible}onUITransformVisible(e){let t=this._localVisible&&e;t!=this._globalVisible&&(this._globalVisible=t,this.object3D.components.forEach((r,i)=>{let a=r;if(a.onUITransformVisible)if(a==this)for(let o of this.object3D.entityChildren){let n=o.getComponent(Jr);n&&n.onUITransformVisible(this._globalVisible)}else a.onUITransformVisible(this._globalVisible)}))}onParentChange(e,t){this.parent?.setNeedUpdateUIPanel(),this.parent=t?.getComponent(Jr),this.parent?.setNeedUpdateUIPanel()}get width(){return this._width}get height(){return this._height}resize(e,t){if(this._width!=e||this._height!=t){this._width=e,this._height=t,this.onChange=!0;for(let r of this.object3D.components.values())r.onTransformResize?.();return!0}return!1}get x(){return this.object3D.x}set x(e){e!=this.object3D.x&&(this.object3D.x=e,this.onChange=!0)}get y(){return this.object3D.y}set y(e){e!=this.object3D.y&&(this.object3D.y=e,this.onChange=!0)}setXY(e,t){let r=this.object3D.localPosition;r.set(e,t,r.z),this.object3D.localPosition=r,this.onChange=!0}get z(){return this.object3D.z}set z(e){e!=this.object3D.z&&(this.object3D.z=e,this.onChange=!0)}get scaleX(){return this.object3D.scaleX}set scaleX(e){this.onChange=!0,this.object3D.scaleX=e}get scaleY(){return this.object3D.scaleY}set scaleY(e){this.onChange=!0,this.object3D.scaleY=e}get scaleZ(){return this.object3D.scaleZ}set scaleZ(e){this.onChange=!0,this.object3D.scaleZ=e}_localMatrix;_worldMatrix;_onChange=!0;needUpdateQuads=!0;get onChange(){return this._onChange}_tempTransforms=[];set onChange(e){if(this._onChange!=e&&(this._onChange=e,e)){this._tempTransforms.length=0;let t=this.object3D.getComponents(Jr,this._tempTransforms,!0);for(let r of t)r._onChange=!0,r.needUpdateQuads=!0}}onEnable(){this.setNeedUpdateUIPanel(),this.onChange=!0}onDisable(){this.setNeedUpdateUIPanel(),this.onChange=!0}setNeedUpdateUIPanel(){let e;e=this.object3D.getComponentFromParent(Gs),e||(e=this.object3D.getComponentFromParent(zs)),e&&(e.needUpdateGeometry=!0)}cloneTo(e){let t=e.getOrAddComponent(Jr);t.visible=this.visible,t.x=this.x,t.y=this.y,t.z=this.z,t.resize(this.width,this.height),t.pivotX=this.pivotX,t.pivotY=this.pivotY,t.scaleX=this.scaleX,t.scaleY=this.scaleY}matrix(){let e=this._localMatrix,t=this.object3D.rotationZ;return this.parent?(e.updateScaleAndRotation(this.object3D.scaleX,this.object3D.scaleY,t,t),e.tx=this.object3D.x,e.ty=this.object3D.y):e.updateScaleAndRotation(1,1,0,0),(this.pivotX!=.5||this.pivotY!=.5)&&(wf||=new wi().identity(),e.mul(wf.setTo(1,0,0,1,-(this.pivotX-.5)*this.width,-(this.pivotY-.5)*this.height))),e}getWorldMatrix(){let e=this,t=e._worldMatrix;return this._onChange&&(t.copyFrom(e.matrix()),e.parent&&t.mul(e.parent.getWorldMatrix()),e._onChange=!1),t}beforeDestroy(e){this.transform.eventDispatcher.addEventListener(this.transform.eventLocalChange.type,this.onTransformChange,this),super.beforeDestroy?.(e)}}class Tf{_ray;_mouseCode;_clickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_view;init(e){this._view=e,this._ray=new $t,this._clickEvent=new ht(ht.PICK_CLICK_GUI),this._outEvent=new ht(ht.PICK_OUT_GUI),this._overEvent=new ht(ht.PICK_OVER_GUI),this._upEvent=new ht(ht.PICK_UP_GUI),this._downEvent=new ht(ht.PICK_DOWN_GUI),m.inputSystem.addEventListener(k.POINTER_DOWN,this.onTouchDown,this,null,1),m.inputSystem.addEventListener(k.POINTER_UP,this.onTouchUp,this,null,1),m.inputSystem.addEventListener(k.POINTER_MOVE,this.onTouchMove,this,null,1),m.inputSystem.addEventListener(k.POINTER_CLICK,this.onTouchClick,this,null,1)}_lastDownTarget;_lastOverTarget;onTouchClick(e){this._lastOverTarget&&e.stopImmediatePropagation()}onTouchMove(e){this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);if(t){e.stopImmediatePropagation();let r=t.collider;r!=this._lastOverTarget&&(r.mouseStyle=Oe.OVER,Object.assign(this._overEvent,e),this._overEvent.type=ht.PICK_OVER_GUI,this._overEvent.target=r.object3D,this._overEvent.data=t,r.object3D.dispatchEvent(this._overEvent),this._lastOverTarget&&(this._lastOverTarget.mouseStyle=Oe.NORMAL,Object.assign(this._outEvent,e),this._outEvent.type=ht.PICK_OUT_GUI,this._outEvent.target=r.object3D,this._outEvent.data=t,this._lastOverTarget.object3D.dispatchEvent(this._outEvent))),this._lastOverTarget=r}else this._lastOverTarget&&(this._lastOverTarget.mouseStyle=Oe.NORMAL,Object.assign(this._outEvent,e),this._outEvent.type=ht.PICK_OUT_GUI,this._outEvent.target=this._lastOverTarget.object3D,this._outEvent.data=t,this._lastOverTarget.object3D.dispatchEvent(this._outEvent),this._lastOverTarget=null)}_lastDownPosition=new j;_calcDistanceVec2=new j;_lastDownTime=0;_clickTimeSpan=200;_clickDistanceSpan=10;onTouchDown(e){this._lastDownTime=Qe.time,this._lastDownPosition.set(e.mouseX,e.mouseY),this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);t&&e.stopImmediatePropagation();let r=t?t.collider:null;r&&(r.mouseStyle=Oe.DOWN,Object.assign(this._downEvent,e),this._downEvent.type=ht.PICK_DOWN_GUI,this._downEvent.target=r.object3D,this._downEvent.data=t,r.object3D.dispatchEvent(this._downEvent)),this._lastDownTarget=r}onTouchUp(e){this._calcDistanceVec2.set(e.mouseX,e.mouseY),this._mouseCode=e.mouseCode,this.collectEntities();let t=this.pick(this._colliderOut);t&&e.stopImmediatePropagation();let r=t?t.collider:null;this._lastDownTarget&&this._lastDownTarget.enable&&(this._lastDownTarget.mouseStyle=Oe.NORMAL),r&&r==this._lastDownTarget&&Qe.time-this._lastDownTime<=this._clickTimeSpan&&(this._calcDistanceVec2.set(e.mouseX,e.mouseY),this._calcDistanceVec2.distance(this._lastDownPosition)<=this._clickDistanceSpan&&(Object.assign(this._clickEvent,e),this._clickEvent.type=ht.PICK_CLICK_GUI,this._clickEvent.target=r.object3D,this._clickEvent.data=t,r.object3D.dispatchEvent(this._clickEvent))),this._lastDownTarget=null}_colliderOut=[];_transformList=[];_sortWorldPanelList=[];_iteractive2PanelDict=new Map;collectEntities(){return this._colliderOut.length=0,this._sortWorldPanelList.length=0,this._iteractive2PanelDict.clear(),this._view.canvasList.slice().reverse().forEach(t=>{if(t&&t.transform&&t.transform.parent){let r=t.object3D.getComponentsByProperty("isUIPanel",!0,!0);r.sort((i,a)=>{let o=i._uiRenderer.__renderOrder,n=a._uiRenderer.__renderOrder;return o>n?-1:1});for(let i of r){this._transformList.length=0,i.object3D.getComponents(Jr,this._transformList),this._transformList.reverse();for(const a of this._transformList){let o=a.uiInteractiveList;if(o&&o.length>0)for(let n of o)this._colliderOut.push(n),this._iteractive2PanelDict.set(n,i)}}}}),this._colliderOut}pick(e){this._ray=this._view.camera.screenPointToRay(m.inputSystem.mouseX,m.inputSystem.mouseY);let t=new j(m.inputSystem.mouseX,m.inputSystem.mouseY),r=new j(Q.canvas.clientWidth,Q.canvas.clientHeight),i;for(const a of e)if(a.interactive&&a.enable&&a.interactiveVisible){let o=this._iteractive2PanelDict.get(a);if(i=a.rayPick(this._ray,o,t,r),i)return i.collider=a,i}return null}}var Df=(s=>(s[s.COLLINEAR=0]="COLLINEAR",s[s.LINES_INTERSECT=1]="LINES_INTERSECT",s[s.SEGMENTS_INTERSECT=2]="SEGMENTS_INTERSECT",s[s.A_BISECTS_B=3]="A_BISECTS_B",s[s.B_BISECTS_A=4]="B_BISECTS_A",s[s.PARALELL=5]="PARALELL",s))(Df||{}),Mf=(s=>(s[s.ON_LINE=0]="ON_LINE",s[s.LEFT_SIDE=1]="LEFT_SIDE",s[s.RIGHT_SIDE=2]="RIGHT_SIDE",s))(Mf||{});class nt{static cacluteLine0=new nt(null,null);static cacluteLine1=new nt(null,null);start;end;color=new P(1,1,1,1);_normal;_normalCalculated=!1;constructor(e,t){this.start=e,this.end=t}set(e,t){this.start=e,this.end=t}getCenter(){let e=d.HELP_0;return this.start.subtract(this.end,e),e.scaleBy(.5),e.add(this.end),e}inverse(){let e=this.start;this.start=this.end,this.end=e}equals(e){return this.start==e.start&&this.end==e.end||this.start==e.end&&this.end==e.start}toArray(){return[this.start.x,this.start.y,this.start.z,this.end.x,this.end.y,this.end.z]}static getLines(e){let t=[];for(let r=0;r<e.length;r++){let i=r,a=go(r+1,e.length),o=e[i],n=e[a];t.push(new nt(o,n))}return t}intersection(e,t=null){var r=(e.end.z-e.start.z)*(this.end.x-this.start.x)-(e.end.x-e.start.x)*(this.end.z-this.start.z),i=(e.end.x-e.start.x)*(this.start.z-e.start.z)-(e.end.z-e.start.z)*(this.start.x-e.start.x),a=(e.start.x-this.start.x)*(this.end.z-this.start.z)-(e.start.z-this.start.z)*(this.end.x-this.start.x);if(r==0)return i==0&&a==0?0:5;i=i/r,a=a/r;var o=this.start.x+i*(this.end.x-this.start.x),n=this.start.z+i*(this.end.z-this.start.z);return t!=null&&(t.x=o,t.y=0,t.z=n),i>=0&&i<=1&&a>=0&&a<=1?2:a>=0&&a<=1?3:i>=0&&i<=1?4:1}getDirection(){var e=this.end.subtract(this.start),t=new d(e.x,e.y);return t.normalize()}copyFrom(e){this.start||(this.start=new d),this.end||(this.end=new d),this.start.copyFrom(e.start),this.end.copyFrom(e.end)}static IsEqual(e,t){return Math.abs(e-t)<1e-7}static squreDistanceSegmentToSegment(e,t,r){let i=e.start,a=e.end,o=t.start,n=t.end,l=i.x,h=i.y,u=i.z,c=a.x,f=a.y,g=a.z,p=o.x,A=o.y,U=o.z,x=n.x,v=n.y,S=n.z,C=c-l,_=f-h,y=g-u,b=x-p,w=v-A,R=S-U,E=l-p,N=h-A,z=u-U,Y=C*C+_*_+y*y,ee=C*b+_*w+y*R,oe=b*b+w*w+R*R,te=C*E+_*N+y*z,ge=b*E+w*N+R*z,Ce=Y*oe-ee*ee,J=Ce,ce=Ce,he=0,Ue=0;this.IsEqual(Ce,0)?(he=0,J=1,Ue=ge,ce=oe):(he=ee*ge-oe*te,Ue=Y*ge-ee*te,he<0?(he=0,Ue=ge,ce=oe):he>J&&(he=J,Ue=ge+ee,ce=oe)),Ue<0?(Ue=0,-te<0?he=0:-te>Y?he=J:(he=-te,J=Y)):Ue>ce&&(Ue=ce,-te+ee<0?he=0:-te+ee>Y?he=J:(he=-te+ee,J=Y));let xe=0,Ve=0;this.IsEqual(he,0)?xe=0:xe=he/J,this.IsEqual(Ue,0)?Ve=0:Ve=Ue/ce;let Ee=E+xe*C-Ve*b,ye=N+xe*_-Ve*w,Ne=z+xe*y-Ve*R;return Ee*Ee+ye*ye+Ne*Ne}isNear(e,t=0,r){let i=d.HELP_0,a=d.HELP_1;i.copyFrom(e.origin),a.copyFrom(e.direction),a.scaleBy(9999),a.add(i,a),nt.cacluteLine0.set(i,a),nt.cacluteLine1.copyFrom(this),r&&(r.perspectiveMultiplyPoint3(nt.cacluteLine1.start,nt.cacluteLine1.start),r.perspectiveMultiplyPoint3(nt.cacluteLine1.end,nt.cacluteLine1.end));let o=nt.squreDistanceSegmentToSegment(nt.cacluteLine0,nt.cacluteLine1,r);return o+1e-4<=t?(e.length=o,!0):(e.length=-999999,!1)}}class ja{static ID=-1;v1;v2;v3;u1;u2;u3;n1;n2;n3;t0;t;u;v;min=new d;max=new d;id=0;constructor(e,t,r){this.id=ja.ID+++200,e&&t&&r&&this.set(e,t,r)}set(e,t,r){this.v1=e,this.v2=t,this.v3=r;let i=this.min,a=this.max;return i.x=Math.min(this.v1.x,this.v2.x,this.v3.x),i.y=Math.min(this.v1.y,this.v2.y,this.v3.y),i.z=Math.min(this.v1.z,this.v2.z,this.v3.z),a.x=Math.max(this.v1.x,this.v2.x,this.v3.x),a.y=Math.max(this.v1.y,this.v2.y,this.v3.y),a.z=Math.max(this.v1.z,this.v2.z,this.v3.z),this}getNormal(){let e=this.v1,t=this.v2,r=this.v3,i=new d(t.x-e.x,t.y-e.y,t.z-e.z),o=new d(r.x-e.x,r.y-e.y,r.z-e.z).crossProduct(i);return o.normalize(),o}turnBack(){let e=this.v3;this.v3=this.v1,this.v1=e}getLines(){let e=this.v1,t=this.v2,r=this.v3;return[new nt(e,t),new nt(t,r),new nt(r,e)]}equals(e){let t=this.getLines(),r=e.getLines(),i=0;for(let a=0;a<t.length;a++)for(let o=0;o<r.length;o++)t[a].equals(r[o])&&i++;return i==3}getCenter(){let e=this.min,t=this.max,r=new d;return r.x=(e.x+t.x)*.5,r.y=(e.y+t.y)*.5,r.z=(e.z+t.z)*.5,r}intersects(e){var t=this.max,r=this.min,i=e.max,a=e.min;return r.x<=i.x&&t.x>=a.x&&r.y<=i.y&&t.y>=a.y&&r.z<=i.z&&t.z>=a.z}sign2D(e,t,r){return(e.x-r.x)*(t.z-r.z)-(t.x-r.x)*(e.z-r.z)}pointInTriangle2D(e){let t=this.v1,r=this.v2,i=this.v3,a,o,n,l,h;return a=this.sign2D(e,t,r),o=this.sign2D(e,r,i),n=this.sign2D(e,i,t),l=a<0||o<0||n<0,h=a>0||o>0||n>0,!(l&&h)}toArray(){return[this.v1.x,this.v1.y,this.v1.z,this.v2.x,this.v2.y,this.v2.z,this.v3.x,this.v3.y,this.v3.z]}}class Nf{static _pt0;static _pt1;static _pt2;static _pt3;static _hitPoint;static _worldMatrix;static _ray;static _triangle;static _isInit;static init(){this._pt0=new d,this._pt1=new d,this._pt2=new d,this._pt3=new d,this._ray=new $t,this._triangle=new ja,this._hitPoint=new d,this._worldMatrix=new I}static rayPick(e,t,r,i,a,o,n){this._isInit||(this.init(),this._isInit=!0);let l=this._worldMatrix;if(i==jt.World){let h;this.calculateHotArea_World(o,this._pt0,this._pt1,this._pt2,this._pt3),l.copyFrom(n).invert();let u=this._ray;if(u.copy(e).applyMatrix(l),this._triangle.set(this._pt0,this._pt1,this._pt2),h=u.intersectTriangle(u.origin,u.direction,this._triangle),h||(this._triangle.set(this._pt1,this._pt2,this._pt3),h=u.intersectTriangle(u.origin,u.direction,this._triangle)),h)return{distance:0,intersectPoint:h}}else{this.calculateHotArea_View(o,a,this._pt0,this._pt1,this._pt2,this._pt3);let h=r.x,u=r.y,c=Math.min(this._pt0.x,this._pt1.x,this._pt2.x,this._pt3.x)+h*.5,f=Math.min(this._pt0.y,this._pt1.y,this._pt2.y,this._pt3.y)+u*.5,g=Math.max(this._pt0.x,this._pt1.x,this._pt2.x,this._pt3.x)+h*.5,p=Math.max(this._pt0.y,this._pt1.y,this._pt2.y,this._pt3.y)+u*.5;return t.x<=g&&t.x>=c&&t.y<=p&&t.y>=f?(this._hitPoint.set(t.x,t.y,0),{distance:0,intersectPoint:this._hitPoint}):null}return null}static calculateHotArea_View(e,t,r,i,a,o){let n=e.getWorldMatrix(),l=n.getScaleX(),h=n.getScaleY(),u=e.width*.5*l,c=e.height*.5*h;r.set(-u,-c,0),i.set(u,-c,0),a.set(-u,c,0),o.set(u,c,0);let f=n.tx;r.x+=f,i.x+=f,a.x+=f,o.x+=f,f=n.ty,r.y-=f,i.y-=f,a.y-=f,o.y-=f,r.multiplyScalar(t),i.multiplyScalar(t),a.multiplyScalar(t),o.multiplyScalar(t)}static calculateHotArea_World(e,t,r,i,a){let o=e.getWorldMatrix(),n=o.getScaleX(),l=o.getScaleY(),h=e.width*.5*n,u=e.height*.5*l;t.set(-h,u,0),r.set(h,u,0),i.set(-h,-u,0),a.set(h,-u,0);let c=o.tx;t.x+=c,r.x+=c,i.x+=c,a.x+=c,c=o.ty,t.y+=c,r.y+=c,i.y+=c,a.y+=c}}var Vf=(s=>(s[s.UpperLeft=0]="UpperLeft",s[s.UpperCenter=1]="UpperCenter",s[s.UpperRight=2]="UpperRight",s[s.MiddleLeft=3]="MiddleLeft",s[s.MiddleCenter=4]="MiddleCenter",s[s.MiddleRight=5]="MiddleRight",s[s.LowerLeft=6]="LowerLeft",s[s.LowerCenter=7]="LowerCenter",s[s.LowerRight=8]="LowerRight",s))(Vf||{}),Pf=(s=>(s[s.Upper=0]="Upper",s[s.Middle=1]="Middle",s[s.Lower=2]="Lower",s))(Pf||{}),kf=(s=>(s[s.Left=0]="Left",s[s.Center=1]="Center",s[s.Right=2]="Right",s))(kf||{});class Lf{charList=[];quadList=[];width=0;index=0}class Of{layout(e){let t=[],r=e.originSize,i=qi.getFontData(e.font,r),a=e.fontSize/r;return this.makeTextLine(e.uiTransform,e.alignment,t,e.font,i,e.text,a,r,e.lineSpacing),t}makeTextLine(e,t,r,i,a,o,n,l,h){let u=-1,c=0,f=l*n,g=f*.5,p=e.width/n,A=e.height/n,U=0,x=e.height,v=()=>{c=0,u++;let y=new Lf;return y.index=u,r.push(y),y},S=(y,b)=>{const w=y.charCodeAt(0).toString();let R=qi.getFnt(i,l,w),E=null;return R?(E=Ir.spawnQuad(),E.sprite=R,E.x=(c+R.xoffset)*n-U,E.y=(a.base-R.height-R.yoffset-a.base)*n+x,E.width=R.offsetSize.width*n,E.height=R.offsetSize.height*n,c+=R.xadvance):y==`
|
|
11654
11628
|
`||(y==" "?c+=f:c+=g),b.width=c,b.quadList.push(E),b.charList.push(y),E},C=()=>{let y=this.getAlignment(t);switch(y.v){case 0:for(let b=0,w=r.length;b<w;b++){let R=r[b];if(b>0){let E=b*f*h;for(let N=0,z=R.quadList.length;N<z;N++){let Y=R.quadList[N];Y&&(Y.y-=E)}}}break;case 1:for(let b=0,w=r.length;b<w;b++){let R=r[b],E=(A-w*l*h)*.5*n+b*f*h;for(let N=0,z=R.quadList.length;N<z;N++){let Y=R.quadList[N];Y&&(Y.y-=E)}}break;case 2:for(let b=0,w=r.length;b<w;b++){let R=r[b],E=(A-w*l*h)*n+b*f*h;for(let N=0,z=R.quadList.length;N<z;N++){let Y=R.quadList[N];Y&&(Y.y-=E)}}break}switch(y.h){case 0:break;case 1:for(let b=0,w=r.length;b<w;b++){let R=r[b],E=(p-R.width)*.5*n;for(let N=0,z=R.quadList.length;N<z;N++){let Y=R.quadList[N];Y&&(Y.x+=E)}}break;case 2:for(let b=0,w=r.length;b<w;b++){let R=r[b],E=(p-R.width)*n;for(let N=0,z=R.quadList.length;N<z;N++){let Y=R.quadList[N];Y&&(Y.x+=E)}}break}};(()=>{let y=null,b=o.length;for(let w=0;w<b;w++){y||=v();let R=o.charAt(w);R==`
|
|
11655
|
-
`||R==" "?y=null:(S(R,y),y.width+g>=p&&(y=v()))}})(),C()}getAlignment(e){let t={v:0,h:0};switch(e){case 1:t.v=0,t.h=1;break;case 0:t.v=0,t.h=0;break;case 2:t.v=0,t.h=2;break;case 4:t.v=1,t.h=1;break;case 3:t.v=1,t.h=0;break;case 5:t.v=1,t.h=2;break;case 7:t.v=2,t.h=1;break;case 6:t.v=2,t.h=0;break;case 8:t.v=2,t.h=2;break}return t}}class Ws extends Un{_style=Oe.NORMAL;_interactive=!1;set interactive(e){this._interactive=e}get interactive(){return this._interactive}set mouseStyle(e){this._style=e}get interactiveVisible(){return this._uiTransform.globalVisible&&this._visible}init(e){super.init(e),this._uiTransform.addUIInteractive(this)}destroy(){this._uiTransform.removeUIInteractive(this),super.destroy()}rayPick(e,t,r,i){return Nf.rayPick(e,r,i,t.space,t.panelRatio,this._uiTransform,t.transform.worldMatrix)}cloneTo(e){e.getOrAddComponent(Ws).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.enable=e._enable,this.interactive=e._interactive,this.mouseStyle=e._style,this}}var zf=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=1]="COLOR",s[s.SPRITE=2]="SPRITE",s))(zf||{});class Rn extends Ws{_spriteMap;_colorMap;_image;_isCreateImage;_transition=2;init(e){super.init(e),this._interactive=!0,this._spriteMap=new Map,this._colorMap=new Map,this._image=this.object3D.getComponent(Ti),this._isCreateImage=this._image==null,this._image||(this._image=this.object3D.addComponent(Ti)),this.imageType=ea.Sliced}onEnable(){this.mouseStyle=Oe.NORMAL}onDisable(){this.mouseStyle=Oe.DISABLE}set transition(e){this._transition!=e&&(this._transition=e,this.validateStyle(this._style,!0))}get transition(){return this._transition}get imageType(){return this._image.imageType}set imageType(e){this._image.imageType=e}setStyleColor(e,t){return this._colorMap.set(e,t),this._style==e&&this.validateStyle(this._style,!0),this}getStyleColor(e){return this._colorMap.get(e)}set mouseStyle(e){super.mouseStyle=e,this.validateStyle(e,!0)}get normalSprite(){return this._spriteMap.get(Oe.NORMAL)}set normalSprite(e){this._spriteMap.set(Oe.NORMAL,e),this._style==Oe.NORMAL&&this.validateStyle(this._style,!0)}get overSprite(){return this._spriteMap.get(Oe.OVER)}set overSprite(e){this._spriteMap.set(Oe.OVER,e),this._style==Oe.OVER&&this.validateStyle(this._style,!0)}set downSprite(e){this._spriteMap.set(Oe.DOWN,e),this._style==Oe.DOWN&&this.validateStyle(this._style,!0)}get downSprite(){return this._spriteMap.get(Oe.DOWN)}set disableSprite(e){this._spriteMap.set(Oe.DISABLE,e),this._style==Oe.DISABLE&&this.validateStyle(this._style,!0)}get disableSprite(){return this._spriteMap.get(Oe.DISABLE)}validateStyle(e,t){if(this._transition&2){let r=this._spriteMap.get(e);this._image.sprite=r}if(this._transition&1){let r=this._colorMap.get(e);r&&(this._image.color=r)}}cloneTo(e){e.getOrAddComponent(Rn).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.imageType=e.imageType,this.transition=e.transition,e._spriteMap.forEach((t,r)=>{t&&this._spriteMap.set(r,t)}),e._colorMap.forEach((t,r)=>{t&&this._colorMap.set(r,t.clone())}),this.mouseStyle=e.mouseStyle,this}destroy(){this._isCreateImage&&this._image&&(this.object3D.removeComponent(Ti),this._image=null),super.destroy()}}class In extends Ia{_count=0;constructor(){super()}init(e){super.init?.(e),this._count=e?e.count:1;for(let t=0;t<this._count;t++)this.attachQuad(Ir.spawnQuad());this._uiTransform.resize(0,0)}getQuad(e){return this._mainQuads[e]}cloneTo(e){e.addComponent(In,{count:this._count}).copyComponent(this)}copyComponent(e){super.copyComponent(e);for(let t=0;t<e._count;t++)this.setSprite(t,e.getSprite(t)),this.setColor(t,e.getColor(t)),this.setImageType(t,e.getImageType(t));return this}setSprite(e,t){this._mainQuads[e].sprite=t||m.res.defaultGUISprite,this.setShadowDirty()}getSprite(e){return this._mainQuads[e].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}getColor(e){return this._mainQuads[e].color}setColor(e,t){this._mainQuads[e].color=t,this.setShadowDirty()}getImageType(e){return this._mainQuads[e].imageType}setImageType(e,t){this._mainQuads[e].imageType=t,this.setShadowDirty()}setSize(e,t,r){this._mainQuads[e].setSize(t,r),this.setShadowDirty()}setXY(e,t,r){this._mainQuads[e].setXY(t,r),this.setShadowDirty()}getXY(e,t){t||=new j;let r=this._mainQuads[e];return t.x=r.x,t.y=r.y,t}}class En extends Ia{_shadowQuality=1;_shadowOffset;_shadowRadius;_shadowColor;_subShadowColor;needUpdateShadow=!1;init(e){super.init?.(e),this._shadowRadius=2,this._shadowQuality=1,this._shadowOffset=new j(4,-4),this._shadowColor=new P(.1,.1,.1,.8),this._subShadowColor=this._shadowColor.clone(),this.isUIShadow=!0}cloneTo(e){e.getOrAddComponent(En).copyComponent(this)}copyComponent(e){return super.copyComponent(this),this._shadowColor=e._shadowColor,this._shadowOffset=e._shadowOffset,this._shadowRadius=e._shadowRadius,this._shadowQuality=e.shadowQuality,this}get shadowColor(){return this._shadowColor}set shadowColor(e){this._shadowColor.copyFrom(e),this.needUpdateShadow=!0}set shadowQuality(e){e=ie(e,0,4),this._shadowQuality!=e&&(this._shadowQuality=e,this.needUpdateShadow=!0)}get shadowQuality(){return this._shadowQuality}set shadowOffset(e){this._shadowOffset=e,this.needUpdateShadow=!0}get shadowOffset(){return this._shadowOffset||=new j(4,-4),this._shadowOffset}set shadowRadius(e){this._shadowRadius!=e&&(this._shadowRadius=e,this.applyShadow())}get shadowRadius(){return this._shadowRadius}onUpdate(e){this.needUpdateShadow&&(this.applyShadow(),this.needUpdateShadow=!1)}applyShadow(){if(this.detachQuads(),this._shadowSource&&this._shadowQuality>0){let e=this._shadowSource.mainQuads;if(e.length>0)for(let t of e)this.createQuadShadow(t)}this._uiTransform.setNeedUpdateUIPanel()}createQuadShadow(e){let t=this._shadowQuality,r=Math.PI*2;this._subShadowColor.copyFrom(this._shadowColor),this._subShadowColor.a=1/Math.max(1,t);for(let i=0;i<t;i++){let a=Ir.spawnQuad(),o=0,n=0;if(i==0)a.color=this._shadowColor;else{let l=r*(i-1)/(t-1);o=Math.sin(l)*this._shadowRadius,n=Math.cos(l)*this._shadowRadius,a.color=this._subShadowColor}a.setXY(o+this._shadowOffset.x+e.x,n+this._shadowOffset.y+e.y),a.setSize(e.width,e.height),a.sprite=e.sprite,a.visible=e.visible,a.imageType=e.imageType,this.attachQuad(a)}}}class wn extends Ia{_font="\u5FAE\u8F6F\u96C5\u9ED1";_fontSize=14;_originSize=42;_alignment=0;_lineSpacing=1;_text="";_color=new P(1,1,1,1);constructor(){super()}cloneTo(e){e.getOrAddComponent(wn).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this._font=e._font,this._fontSize=e._fontSize,this._originSize=e._originSize,this._alignment=e._alignment,this._lineSpacing=e._lineSpacing,this._color.copyFrom(e._color),this.text=e.text,this}get originSize(){return this._originSize}get font(){return this._font}set font(e){this._font=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!=e&&(this._fontSize=e,this.layoutText())}get text(){return this._text}set text(e){this._text!=e&&(e||(e=""),this._text=e,this.layoutText())}textLine=null;layoutProxy=new Of;layoutText(){this.detachQuads(),this.textLine=this.layoutProxy.layout(this);for(let e=0,t=this.textLine.length;e<t;e++){let r=this.textLine[e];for(let i=0,a=r.quadList.length;i<a;i++){let o=r.quadList[i];o&&this.attachQuad(o)}}this.color=this._color,this._uiTransform.setNeedUpdateUIPanel(),this.onUIComponentVisible(this._visible),this.setShadowDirty()}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t&&(t.visible=!e);this.setShadowDirty()}onTransformResize(){this.layoutText()}get color(){return this._color}set color(e){this._color.copyFrom(e);for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get alignment(){return this._alignment}set alignment(e){this._alignment!=e&&(this._alignment=e,this.layoutText())}get lineSpacing(){return this._lineSpacing}set lineSpacing(e){this._lineSpacing!=e&&(this._lineSpacing=e,this.layoutText())}}var Pm=Object.getOwnPropertyDescriptor,km=(s,e,t,r)=>{for(var i=r>1?void 0:r?Pm(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let Fs=class extends Ua{constructor(){super()}init(){super.init(),this.lightData.lightType=Xe.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+It())}get range(){return this.lightData.range}set range(s){this.lightData.range=s,this.onChange()}get at(){return this.lightData.linear}set at(s){this.lightData.linear=s,this.onChange()}get radius(){return this.lightData.radius}set radius(s){this.lightData.radius=s,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(s){this.lightData.quadratic=s,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(s){let e=s.scene.getChildByName("graphic3D");if(!e)return;let t=e.createCustomShape(`PointLight_${this.object3D.instanceID}`,this.transform);t.buildAxis(),t.buildCircle(d.ZERO,this.range,32,d.X_AXIS),t.buildCircle(d.ZERO,this.range,32,d.Y_AXIS),t.buildCircle(d.ZERO,this.range,32,d.Z_AXIS)}debug(){}debugDraw(s){}};Fs=km([Pt(Fs,"Light")],Fs);var Lm=Object.getOwnPropertyDescriptor,Om=(s,e,t,r)=>{for(var i=r>1?void 0:r?Lm(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let Ea=class extends Nr{_fatLineMaterial=null;_fatLineGeometry=null;constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(s){s.addComponent(Ea).copyComponent(this)}copyComponent(s){return super.copyComponent(s),this}set geometry(s){super.geometry=s,this._fatLineGeometry=s,s&&(this.instanceCount=s.instanceCount,this._fatLineMaterial&&s.instanceBuffer&&this._fatLineMaterial.setInstanceBuffer(s.instanceBuffer))}get geometry(){return this._fatLineGeometry}set material(s){this.materials=[s],this._fatLineMaterial=s,this._fatLineGeometry&&this._fatLineGeometry.instanceBuffer&&s.setInstanceBuffer(this._fatLineGeometry.instanceBuffer)}get material(){return this._fatLineMaterial}nodeUpdate(s,e,t,r){if(this._fatLineMaterial&&this.object3D){this._fatLineMaterial.setModelMatrix(this.object3D.transform.worldMatrix);const i=Q.presentationSize[0],a=Q.presentationSize[1];i>0&&a>0&&(this._fatLineMaterial.resolution=new j(i,a))}super.nodeUpdate(s,e,t,r)}};Ea=Om([Pt(Ea,"FatLineRenderer")],Ea);class Gf extends q{index=0;drawCallFrame=-1;constructor(){super()}}var xn=(s=>(s[s.CastGI=0]="CastGI",s[s.ReceiveGI=1]="ReceiveGI",s[s.CastDepth=2]="CastDepth",s[s.Other=3]="Other",s))(xn||{});class Wf extends At{static count=0;constructor(e=0,t=0){super(),O.register("GIProbeShader",lf);let r=new ot,i=new Pe("GIProbeShader","GIProbeShader");i.passType=H.COLOR,r.addRenderPass(i),i.setDefine("USE_BRDF",!0),i.setShaderEntry("VertMain","FragMain"),i.setUniformVector4("probeUniform",new $(t,e,0,0));let a=i.shaderState;a.acceptShadow=!1,a.castShadow=!1,a.receiveEnv=!1,a.acceptGI=!1,a.useLight=!1,r.setTexture("baseMap",m.res.whiteTexture),r.setTexture("normalMap",m.res.normalTexture),r.setTexture("emissiveMap",m.res.blackTexture),this.shader=r}}class zm extends ke{_probes;_volume;_debugMr=[];init(e){e||=m.views[0]?.scene,m.setting.gi.enable=!0,this._volume=ne.getLightEntries(e).irradianceVolume,this.initProbe(e)}initProbe(e){let t=this._volume.setting.probeXCount,r=this._volume.setting.probeYCount,i=this._volume.setting.probeZCount,a=new Qi(4,16,16),o=new d;this._probes=[];for(let n=0;n<t;n++)for(let l=0;l<r;l++)for(let h=0;h<i;h++){let u=n+h*t+l*(t*i),c=new Gf;c.index=u,c.name=`${n}_${l}_${h}`;let f=c.addComponent(K);f.material=new Wf(xn.CastGI,u),f.geometry=a,f.castGI=!1,f.castShadow=!1,this._debugMr.push(f),this.object3D.addChild(c),this._volume.calcPosition(n,l,h,o),c.x=o.x,c.y=o.y,c.z=o.z,this._probes[u]=c,this._debugMr.push(f)}for(let n=0;n<this._probes.length;n++)G.instance.addGIProbe(e,this._probes[n]);this.object3D.transform.enable=!1,this._volume.setting.debug&&this.debug()}debug(){}debugProbeRay(e,t){const r=m.setting.gi.rayNumber;let i=new Z(0,-.7071067811865475,.7071067811865475,0);for(let a=0;a<r;a++){let o=e*r+a,n=new d(-t[o*4+0],-t[o*4+1],-t[o*4+2],0);i.transformVector(n,n);let l=t[o*4+3],h=this._probes[e].transform.worldPosition.clone(),u=n.scaleBy(l);u.add(h,u)}}changeProbesVolumeData(){this._volume.setVolumeDataChange()}changeProbesPosition(){this._volume.setVolumeDataChange();let e=this._volume.setting.probeXCount,t=this._volume.setting.probeYCount,r=this._volume.setting.probeZCount,i=new d;for(let a=0;a<e;a++)for(let o=0;o<t;o++)for(let n=0;n<r;n++){let l=a+n*e+o*(e*r),h=this._probes[l];this._volume.calcPosition(a,o,n,i),h.x=i.x,h.y=i.y,h.z=i.z}}onUpdate(){m.setting.gi.maxDistance=m.setting.gi.probeSpace*1.5;let e=this.transform.scene3D.view.camera,t=d.distance(e.transform.worldPosition,e.transform.targetPos)/300;if(this._debugMr&&this._debugMr.length>0)for(let r=0;r<this._debugMr.length;r++){const i=this._debugMr[r].transform;i.scaleX=t,i.scaleY=t,i.scaleZ=t}}}class Gm extends Nr{_keyRenderGroup;_keyBufferGroup;_keyIdsGroup;constructor(){super()}init(e){this._keyRenderGroup=new Map,this._keyBufferGroup=new Map,this._keyIdsGroup=new Map}start(){let e=[];this.object3D.getComponents(K,e,!0);for(let t=0;t<e.length;t++){const r=e[t];r.transform.updateWorldMatrix(!0),r.enable=!1;let i=r.geometry.instanceID;for(let a=0;a<r.materials.length;a++){const o=r.materials[a];i+=o.instanceID}if(this._keyRenderGroup.has(i))this._keyRenderGroup.get(i).push(r),this._keyIdsGroup.get(i).push(r.transform.worldMatrix.index);else{let a=new Be(e.length);a.visibility=GPUShaderStage.VERTEX,this._keyRenderGroup.set(i,[r]),this._keyBufferGroup.set(i,a),this._keyIdsGroup.set(i,[r.transform.worldMatrix.index])}}this._keyBufferGroup.forEach((t,r)=>{let i=this._keyIdsGroup.get(r),a=this._keyBufferGroup.get(r);a.setInt32Array("matrixIDs",new Int32Array(i)),a.apply()})}reset(){this._keyRenderGroup.size>0&&(this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this.start())}nodeUpdate(e,t,r,i){this._keyRenderGroup.forEach((a,o)=>{let n=this._keyBufferGroup.get(o),l=a[0];for(let h=0;h<l.materials.length;h++){let c=l.materials[h].getPass(t);if(c)for(let f=0;f<c.length;f++){const g=c[f];g.setDefine("USE_INSTANCEDRAW",!0),g.setStorageBuffer("instanceDrawID",n)}}l.nodeUpdate(e,t,r,i)})}renderPass(e,t,r){this._keyRenderGroup.forEach((i,a)=>{let o=i[0];o.instanceCount=i.length,this.renderItem(e,t,o,r)})}renderItem(e,t,r,i){let a=r.transform._worldMatrix;for(let o=0;o<r.materials.length;o++){let l=r.materials[o].getPass(t);if(!(!l||l.length==0))for(let h=0;h<l.length;h++){let u=l[h];F.bindGeometryBuffer(i.encoder,r.geometry);const c=u;c.shaderState.splitTexture&&(i.endRenderPass(),Ct.WriteSplitColorTexture(r.instanceID),i.beginOpaqueRenderPass(),F.bindCamera(i.encoder,e.camera),F.bindGeometryBuffer(i.encoder,r.geometry)),F.bindPipeline(i.encoder,c);let A=r.geometry.subGeometries[o].lodLevels[r.lodLevel];r.instanceCount>0?F.drawIndexed(i.encoder,A.indexCount,r.instanceCount,A.indexStart,0,0):F.drawIndexed(i.encoder,A.indexCount,1,A.indexStart,0,a.index)}}}beforeDestroy(e){this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this._keyRenderGroup=this._keyBufferGroup=this._keyIdsGroup=void 0,Se.removeWaitStart(this.object3D,this)}}var Wm=Object.getOwnPropertyDescriptor,Jm=(s,e,t,r)=>{for(var i=r>1?void 0:r?Wm(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let ys=class extends K{constructor(){super()}get geometry(){return null}set geometry(s){}cloneTo(s){}set meshURL(s){let e=m.res.getGeometry(s);e?this.geometry=e:console.error("no geometry set",s)}};ys=Jm([Pt(ys,"MeshFilter")],ys);var Zm=Object.getOwnPropertyDescriptor,Ym=(s,e,t,r)=>{for(var i=r>1?void 0:r?Zm(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let wa=class extends K{skinJointsName;mInverseBindMatrixData;mInverseBindMatrixBuffer;mSkeletonAnimation;mJointIndexTableBuffer;constructor(){super(),this.addRendererMask(ve.SkinnedMesh)}start(){if(super.start(),this.skeletonAnimation=this.object3D.getComponent(si),!this.skeletonAnimation){let s=this.object3D.parentObject.parentObject.getComponentsInChild(si);s.length>0&&(this.skeletonAnimation=s[0]);let e=this.object3D;for(;!this.skeletonAnimation&&e;)this.skeletonAnimation=e.getComponentFromParent(si),e.parent&&(e=e.parent.object3D)}}onEnable(){super.onEnable()}get skeletonAnimation(){return this.mSkeletonAnimation}set skeletonAnimation(s){if(this.mSkeletonAnimation=s,!!s&&!this.mJointIndexTableBuffer){let e=this.mSkeletonAnimation.getJointIndexTable(this.skinJointsName);this.mJointIndexTableBuffer=new Be(e.length*4,0,new Float32Array(e)),this.mJointIndexTableBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}}get skinInverseBindMatrices(){return this.mInverseBindMatrixData}set skinInverseBindMatrices(s){this.mInverseBindMatrixData=s;var e=new Float32Array(s.length*16);for(let t=0;t<s.length;t++){let r=t*16,i=s[t];e.set(i,r)}this.mInverseBindMatrixBuffer=new Be(e.byteLength,0,e),this.mInverseBindMatrixBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}get inverseBindMatrixBuffer(){return this.mInverseBindMatrixBuffer}get jointIndexTableBuffer(){return this.mJointIndexTableBuffer.buffer}cloneTo(s){let e=s.addComponent(wa);e.geometry=this.geometry,e.material=this.material.clone(),e.castShadow=this.castShadow,e.castGI=this.castGI,e.receiveShadow=this.receiveShadow,e.rendererMask=this.rendererMask,e.skinJointsName=this.skinJointsName,e.skinInverseBindMatrices=this.skinInverseBindMatrices,e.mJointIndexTableBuffer=this.mJointIndexTableBuffer}nodeUpdate(s,e,t,r){for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(e);if(o)for(let n=0;n<o.length;n++){const l=o[n];!l.pipeline&&this.mSkeletonAnimation&&(l.setStorageBuffer("jointsMatrixIndexTable",this.mSkeletonAnimation.jointMatrixIndexTableBuffer),l.setStorageBuffer("jointsInverseMatrix",this.mInverseBindMatrixBuffer),l.setStorageBuffer("jointsIndexMapingTable",this.mJointIndexTableBuffer))}}super.nodeUpdate(s,e,t,r)}};wa=Ym([Pt(wa,"SkinnedMeshRenderer")],wa);class Xm extends qe{radius=2.5;height=10;constructor(){super(),this._shapeType=ta.Capsule}}class Js extends qe{mesh;static triangle;_pickRet;constructor(){super(),this._shapeType=ta.Mesh}rayPick(e,t){if(this.mesh){Js.triangle||=new ja(new d,new d,new d);let r=this.mesh.getAttribute(V.position),i=this.mesh.getAttribute(V.indices),a=qe.helpMatrix;a.copyFrom(t).invert();let o=qe.helpRay.copy(e);if(o.applyMatrix(a),o.intersectBox(this.mesh.bounds),!o.intersectBox(this.mesh.bounds,qe.v3_help_0))return null;if(i&&r&&i.data.length>0){let l=r.data;for(let h=0,u=i.data.length/3;h<u;h++){let c=h*3;const f=i.data[c+0]*3,g=i.data[c+1]*3,p=i.data[c+2]*3;let A=Js.triangle,U=A.v1.set(l[f+0],l[f+1],l[f+2]),x=A.v2.set(l[g+0],l[g+1],l[g+2]),v=A.v3.set(l[p+0],l[p+1],l[p+2]);A.set(U,x,v);let S=o.intersectTriangle(o.origin,o.direction,A);if(S){this._pickRet||={intersectPoint:new d,distance:0},this._pickRet.intersectPoint=S,this._pickRet.distance=d.distance(o.origin,S);let C=this.mesh.getAttribute(V.normal);if(C){let _=C.data,y=new d(_[f],_[f+1],_[f+2]);t.transformVector(y,y),y.normalize(),this._pickRet.normal=y}return this._pickRet}}}}return null}}class Hm extends qe{_pickRet;box;radius=.5;constructor(e){super(),this._shapeType=ta.Sphere,this.radius=e,this.box=new Za(new d,1)}rayPick(e,t){this.box.setFromCenterAndSize(this.center,this.radius);let i=qe.helpMatrix;i.copyFrom(t).invert();let a=qe.helpRay.copy(e);a.applyMatrix(i);let o=a.intersectSphere(a.origin,a.direction,this.box.center,this.box.radius);return o?(this._pickRet||(this._pickRet={intersect:!1,intersectPoint:new d,distance:0}),this._pickRet.intersect=!0,this._pickRet.intersectPoint=o,this._pickRet.distance=d.distance(a.origin,qe.v3_help_0),this._pickRet):null}}class jm extends q{_envMap;skyObject;envMapChange=!0;view;constructor(){super(),this.transform.scene3D=this,this.skyObject=new q,this.addChild(this.skyObject),this._isScene3D=!0,this.envMap||=m.res.defaultSky}get envMap(){return this._envMap}set envMap(e){this._envMap!=e&&(this.envMapChange=!0),this._envMap=e,G.instance.sky&&"map"in G.instance.sky&&(G.instance.sky.map=e)}get exposure(){return G.instance.sky&&"exposure"in G.instance.sky?G.instance.sky.exposure:0}set exposure(e){G.instance.sky&&"exposure"in G.instance.sky&&(G.instance.sky.exposure=e,m.setting.sky.skyExposure=e)}get roughness(){if(G.instance.sky&&"roughness"in G.instance.sky)return G.instance.sky.roughness}set roughness(e){G.instance.sky&&"roughness"in G.instance.sky&&(G.instance.sky.roughness=e)}}class Jf{_computeShader;_outBuffer;constructor(){}init(){let e=se.getGBufferFrame(se.colorPass_GBuffer);this._computeShader=new ue(Wc),this._outBuffer=new Hi(32),this._computeShader.setStorageBuffer("outBuffer",this._outBuffer),this._computeShader.setSamplerTexture("gBufferTexture",e.getCompressGBufferTexture())}compute(e){let t=ne.getCameraGroup(e.camera);this._computeShader.setStorageBuffer("globalUniform",t.uniformGPUBuffer);let r=F.beginCommandEncoder();F.computeCommand(r,[this._computeShader]),F.endCommandEncoder(r),this._outBuffer.readBuffer()}getPickMeshID(){var e=this._outBuffer.outFloat32Array[0]+.1;return Math.floor(e)}getPickWorldPosition(e){e||=new d;var t=this._outBuffer.outFloat32Array[4],r=this._outBuffer.outFloat32Array[5],i=this._outBuffer.outFloat32Array[6];return e.set(t,r,i),e}getPickWorldNormal(e){e||=new d;var t=this._outBuffer.outFloat32Array[8],r=this._outBuffer.outFloat32Array[9],i=this._outBuffer.outFloat32Array[10];return e.set(t*2-1,r*2-1,i*2-1).normalize(),e}getPickScreenUV(e){e||=new j;var t=this._outBuffer.outFloat32Array[2],r=this._outBuffer.outFloat32Array[3];return e.set(t,r),e}}class Zf extends Er{ray;isTouching=!1;_mouseCode;_pickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_mouseMove;_pickCompute;_lastDownTarget;mouseEnableMap;_view;constructor(e){super(),this._view=e,this.init()}init(){this.ray=new $t,this.mouseEnableMap=new Map,this._pickEvent=new k(k.PICK_CLICK),this._outEvent=new k(k.PICK_OUT),this._overEvent=new k(k.PICK_OVER),this._mouseMove=new k(k.PICK_MOVE),this._upEvent=new k(k.PICK_UP),this._downEvent=new k(k.PICK_DOWN)}start(){m.setting.pick.enable&&(m.inputSystem.addEventListener(k.POINTER_DOWN,this.onTouchStart,this),m.inputSystem.addEventListener(k.POINTER_UP,this.onTouchEnd,this),m.inputSystem.addEventListener(k.POINTER_CLICK,this.onTouchOnce,this),m.inputSystem.addEventListener(k.POINTER_RIGHT_CLICK,this.onTouchOnce,this),m.inputSystem.addEventListener(k.POINTER_MOVE,this.onTouchMove,this)),m.setting.pick.mode=="pixel"&&(this._pickCompute=new Jf,this._pickCompute.init())}stop(){m.inputSystem.removeEventListener(k.POINTER_DOWN,this.onTouchStart,this),m.inputSystem.removeEventListener(k.POINTER_UP,this.onTouchEnd,this),m.inputSystem.removeEventListener(k.POINTER_CLICK,this.onTouchOnce,this),m.inputSystem.removeEventListener(k.POINTER_RIGHT_CLICK,this.onTouchOnce,this),m.inputSystem.removeEventListener(k.POINTER_MOVE,this.onTouchMove,this)}onTouchStart(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);this._lastDownTarget=t,t&&(Object.assign(this._downEvent,e),this._downEvent.type=k.PICK_DOWN,this._downEvent.target=t.object3D,this._downEvent.data=this.getPickInfo(),this.dispatchEvent(this._downEvent),t.object3D.containEventListener(k.PICK_DOWN)&&t.object3D.dispatchEvent(this._downEvent))}onTouchEnd(e){this.isTouching=!1,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._upEvent,e),this._upEvent.type=k.PICK_UP,this._upEvent.target=t.object3D,this._upEvent.data=this.getPickInfo(),this.dispatchEvent(this._upEvent),t.object3D.containEventListener(k.PICK_UP)&&t.object3D.dispatchEvent(this._upEvent))}_lastFocus;getPickInfo(){if(m.setting.pick.mode=="pixel")return{worldPos:this._pickCompute.getPickWorldPosition(),worldNormal:this._pickCompute.getPickWorldNormal(),screenUv:this._pickCompute.getPickScreenUV(),meshID:this._pickCompute.getPickMeshID()};{let e=this._interestList[0];return{worldPos:e.intersectPoint,worldNormal:e.normal,meshID:e.collider.transform.worldMatrix.index,distance:e.distance}}}onTouchMove(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._mouseMove,e),this._mouseMove.type=k.PICK_MOVE,this._mouseMove.target=t.object3D,this._mouseMove.data=this.getPickInfo(),this.dispatchEvent(this._mouseMove),t.object3D.containEventListener(k.PICK_MOVE)&&t.object3D.dispatchEvent(this._mouseMove)),t!=this._lastFocus&&(this._lastFocus&&this._lastFocus.object3D&&(Object.assign(this._outEvent,e),this._outEvent.type=k.PICK_OUT,this._outEvent.target=this._lastFocus.object3D,this._outEvent.data=this.getPickInfo(),this.dispatchEvent(this._outEvent),this._lastFocus.object3D.containEventListener(k.PICK_OUT)&&this._lastFocus.object3D.dispatchEvent(this._outEvent)),t&&(Object.assign(this._overEvent,e),this._overEvent.type=k.PICK_OVER,this._overEvent.target=t.object3D,this._overEvent.data=this.getPickInfo(),this.dispatchEvent(this._overEvent),t.object3D.containEventListener(k.PICK_OVER)&&t.object3D.dispatchEvent(this._overEvent))),this._lastFocus=t}onTouchOnce(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);if(t){let r=this.getPickInfo();Object.assign(this._pickEvent,e),this._pickEvent.type=k.PICK_CLICK,this._pickEvent.target=t.object3D,this._pickEvent.data=r,this.dispatchEvent(this._pickEvent),t===this._lastDownTarget&&t.object3D.containEventListener(k.PICK_CLICK)&&t.object3D.dispatchEvent(this._pickEvent)}this._lastDownTarget=null}findNearestObj(e,t){return e.sort((r,i)=>r.distance>i.distance?1:-1),e[0]?.collider}_interestList=[];pick(e){if(this._interestList.length=0,m.setting.pick.mode=="pixel"){this._pickCompute.compute(this._view);let t=this._pickCompute.getPickMeshID(),r=this.mouseEnableMap.get(t);if(r){let i=this._pickCompute.getPickWorldPosition(),a=d.distance(i,this.ray.origin);this._interestList.push({distance:a,collider:r,intersectPoint:i})}}else if(m.setting.pick.mode=="bound"){this.ray=e.screenPointToRay(m.inputSystem.mouseX,m.inputSystem.mouseY);let t,r=Se.componentsEnablePickerList.get(this._view);if(r)for(const i of r){let a=i[0];a.enable&&(t=a.rayPick(this.ray),t&&(t.collider=a,this._interestList.push(t)))}}}}class Km extends ns{_camera;_scene;_viewPort;_enablePick=!1;_enable=!0;pickFire;guiPick;canvasList;constructor(e=0,t=0,r=0,i=0){super(),this.canvasList=[],this._viewPort=new $(e,t,r,i)}get enable(){return this._enable}set enable(e){this._enable=e}get enablePick(){return this._enablePick}set enablePick(e){this._enablePick!=e&&(this.pickFire=new Zf(this),this.pickFire.start()),this._enablePick=e}get scene(){return this._scene}set scene(e){this._scene=e,e.view=this,Tt.createBuffer(this),e&&this.canvasList.forEach(t=>{t&&e.addChild(t.object3D)})}get camera(){return this._camera}set camera(e){this._camera=e}get viewPort(){return this._viewPort}set viewPort(e){this._viewPort=e}enableUICanvas(e=0){let t=this.canvasList[e];if(!t){let r=new q;r.name="Canvas "+e,t=r.addComponent(Xa),t.index=e,this.canvasList[e]=t}return this.scene.addChild(t.object3D),this.guiPick||(this.guiPick=new Tf,this.guiPick.init(this)),t}disableUICanvas(e=0){let t=this.canvasList[e];t&&t.object3D&&t.object3D.removeFromParent()}}class qm{normal;fixNormal;center;rotateShape;distance=0;index;constructor(e){this.index=e,this.rotateShape=[]}}class $m extends Ie{vScale;uNegate;sections;build(e,t,r,i=1,a=!0){if(r.length<2)throw new Error("path length is not enough");return this.vScale=i,this.uNegate=a,e=e.slice(),t&&e.push(e[0]),this.sections=this.buildSections(e,r),this.buildGeometry(e,this.sections),this.bounds=new Fe(d.ZERO.clone(),new d(100,100,100)),this}buildSections(e,t){let r,i,a,o=[],n=t.length;for(let h=0;h<n;h++){let u=new qm(h);r=t[h],i=t[h+1],u.center=r.clone(),i==null?(u.normal=a.clone(),u.distance=0):(a=i.subtract(r),u.distance=a.length,u.normal=a.normalize()),o.push(u)}o[0].fixNormal=o[0].normal.clone();for(let h=1;h<n;h++){let u=o[h-1],c=o[h];c.fixNormal=c.normal.add(u.normal).normalize()}let l=new I().identity();for(let h=0;h<n;h++){let u=o[h],c,f;if(h==0)c=d.UP,f=e;else{let g=o[h-1];c=g.fixNormal,f=g.rotateShape}I.fromToRotation(c,u.fixNormal,l);for(let g=0,p=e.length;g<p;g++){let A=l.multiplyPoint3(f[g]);u.rotateShape.push(A)}}return o}buildGeometry(e,t){let r=t.length,i=e.length,a=r*i,o=r-1,n=new Float32Array(a*3),l=new Float32Array(a*3),h=new Float32Array(a*2),u=new Uint32Array(o*(i-1)*6),c=i-1,f=0,g=0,p=[0];for(let U=1;U<i;U++)g+=e[U-1].subtract(e[U]).length,p.push(g);for(let U=0;U<r;U++){let x=t[U];for(let v=0;v<i;v++){let S=(U*i+v)*3,C=x.rotateShape[v].add(x.center);n[S]=C.x,n[S+1]=C.y,n[S+2]=C.z,l[S+1]=1;let _=(U*i+v)*2,y=p[v]/g;h[_]=this.uNegate?1-y:y,h[_+1]=f*this.vScale}f+=x.distance}let A=0;for(let U=0;U<o;U++){let x=U*i;for(let v=0;v<c;v++){let S=v,C=v+1,_=S+i,y=C+i;u[A++]=S+x,u[A++]=C+x,u[A++]=_+x,u[A++]=C+x,u[A++]=y+x,u[A++]=_+x}}return this.setIndices(u),this.setAttribute(V.position,n),this.setAttribute(V.normal,l),this.setAttribute(V.uv,h),this.setAttribute(V.TEXCOORD_1,h),this.addSubGeometry({indexStart:0,indexCount:u.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.computeNormals(),this}}class eA extends Ie{_instanceBuffer;_instanceData;_instanceCount=0;constructor(){super(),this.initBaseGeometry()}initBaseGeometry(){const e=new Float32Array([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0]),t=new Float32Array([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2]),r=new Uint16Array([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]);this.setIndices(r),this.setAttribute(V.position,e),this.setAttribute(V.uv,t),this.addSubGeometry({indexStart:0,indexCount:r.length,vertexStart:0,vertexCount:e.length/3,firstStart:0,index:0,topology:0})}setPositions(e){const t=e instanceof Float32Array?e:new Float32Array(e),i=t.length/3-1;if(i<=0)return console.warn("FatLineGeometry: Need at least 2 points"),this;const a=new Float32Array(i*16);for(let o=0;o<i;o++){const n=o*3,l=(o+1)*3;a[o*16+0]=t[n+0],a[o*16+1]=t[n+1],a[o*16+2]=t[n+2],a[o*16+3]=0,a[o*16+4]=t[l+0],a[o*16+5]=t[l+1],a[o*16+6]=t[l+2],a[o*16+7]=0,a[o*16+8]=1,a[o*16+9]=1,a[o*16+10]=1,a[o*16+11]=0,a[o*16+12]=1,a[o*16+13]=1,a[o*16+14]=1,a[o*16+15]=0}return this._instanceData=a,this._instanceCount=i,this.computeBoundingBox(t),this}setColors(e){const t=e instanceof Float32Array?e:new Float32Array(e);if(!this._instanceData)return console.warn("FatLineGeometry: Must call setPositions() before setColors()"),this;const i=t.length/3-1;if(i!==this._instanceCount)return console.warn("FatLineGeometry: Color array length doesn't match segment count"),this;for(let a=0;a<i;a++){const o=a*3,n=(a+1)*3;this._instanceData[a*16+8]=t[o+0],this._instanceData[a*16+9]=t[o+1],this._instanceData[a*16+10]=t[o+2],this._instanceData[a*16+12]=t[n+0],this._instanceData[a*16+13]=t[n+1],this._instanceData[a*16+14]=t[n+2]}return this}computeBoundingBox(e){const t=new d(1/0,1/0,1/0),r=new d(-1/0,-1/0,-1/0);for(let a=0;a<e.length;a+=3){const o=e[a],n=e[a+1],l=e[a+2];t.x=Math.min(t.x,o),t.y=Math.min(t.y,n),t.z=Math.min(t.z,l),r.x=Math.max(r.x,o),r.y=Math.max(r.y,n),r.z=Math.max(r.z,l)}const i=d.sub(r,t);this.bounds=new Fe(d.ZERO.clone(),i),this.bounds.setFromMinMax(t,r)}get instanceData(){return this._instanceData}get instanceCount(){return this._instanceCount}get instanceBuffer(){return!this._instanceBuffer&&this._instanceData&&(this._instanceBuffer=new Be(this._instanceData.byteLength),this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply()),this._instanceBuffer}updateInstanceBuffer(){this._instanceBuffer&&this._instanceData&&(this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply())}}class tA{name;offset;size;arrayStride;stepMode;attributes}class rA{name;format;offset;shaderLocation;stride}var Yf=(s=>(s[s.position=3]="position",s[s.normal=3]="normal",s[s.TANGENT=4]="TANGENT",s[s.uv=2]="uv",s[s.TEXCOORD_1=2]="TEXCOORD_1",s[s.color=4]="color",s[s.joints0=4]="joints0",s[s.weights0=4]="weights0",s[s.joints1=4]="joints1",s[s.weights1=4]="weights1",s[s.vIndex=1]="vIndex",s[s.weight=1]="weight",s[s.a_morphPositions_0=3]="a_morphPositions_0",s))(Yf||{});class iA{get data(){return null}entity}class Xf{min=0;max=0;set(e,t){return this.max=t,this.min=e,this}copy(e){return this.max=e.max,this.min=e.min,this}isInterestRange(e){return!(this.max>e.min||e.max<this.min)}}class Hf{_spaceDesc;getRange(e){return this._spaceDesc[e]}initSpace(e){this._spaceDesc={};for(let t of e)(this._spaceDesc[t]=new Xf).set(-Number.MAX_VALUE,Number.MAX_VALUE);return this}isContain(e,t){let r=this._spaceDesc[e];return t>=r.min&&t<r.max}isInterestRange(e,t){let r=this._spaceDesc[e];return r?t.isInterestRange(r):!1}splitSpace(e,t,r){let i=this._spaceDesc[e];return t?i.max=r:i.min=r,this}copySpace(e){for(let t in e._spaceDesc){let r=e._spaceDesc[t];this._spaceDesc[t].copy(r)}return this}}class Ka{static MaxEntityCountInLeaf=4;static MaxLayer=10;static ClearLeafLayer=Ka.MaxLayer-4}class qa{static UUID=0;uuid="0";constructor(){this.uuid=(qa.UUID++).toString()}}class aA{map={};_count=0;get count(){return this._count}push(e){return this.map[e.uuid]?!1:(this.map[e.uuid]=e,this._count++,!0)}remove(e){return this.map[e]?(delete this.map[e],this._count--,!0):!1}}class ui extends qa{_dimensionIndex=0;_dimensions;_dimension;_left;_right;_space;_parent;_entities;layer;get dimension(){return this._dimension}constructor(e=0){super(),this.layer=e,ui.nodeCount++}initNode(e,t,r){return this._dimensions=t,this._dimensionIndex=r,this._dimension=t[r],this._space=new Hf().initSpace(t),e&&this._space.copySpace(e._space),this._parent=e,this._entities=new aA,this}updateEntity(e){if(e.isInNode(this,this._dimension)&&(e.attachTreeNode(this),this.autoSplit(),this._left&&this._right)){let t=(this._dimensionIndex+1)%this._dimensions.length,r=this._dimensions[t];e.isInNode(this._right,r)?this._right.updateEntity(e):e.isInNode(this._left,r)&&this._left.updateEntity(e)}}buildRoot(e){for(const t of e)t.entity.attachTreeNode(this);this.autoSplit()}_splitEntityList=[];autoSplit(){if(this._entities.count>Ka.MaxEntityCountInLeaf&&!this._right&&!this._left&&this.layer<Ka.MaxLayer){let e=this._splitEntityList,t=(this._dimensionIndex+1)%this._dimensions.length,r=this._dimensions[t],i=0;for(const a in this._entities.map){let o=this._entities.map[a];i+=o.centerValue(r),e.push(o)}i/=this._entities.count,this._left=new ui(this.layer+1),this._right=new ui(this.layer+1),this._left.initNode(this,this._dimensions,t),this._right.initNode(this,this._dimensions,t),this._left.setSpace(!0,i),this._right.setSpace(!1,i);for(let a of e)a.isInNode(this._right,r)?a.attachTreeNode(this._right):a.isInNode(this._left,r)&&a.attachTreeNode(this._left)}this._left&&this._left.autoSplit(),this._right&&this._right.autoSplit()}setSpace(e,t){return this._parent&&this._space.splitSpace(this._dimension,e,t),this}isEmpty(){return this._left==null&&this._right==null&&this._entities.count==0}pushEntity(e){return this._entities.push(e)}removeEntity(e){return this._entities.remove(e.uuid)}static nodeCount=0;autoClear(){let e=this;for(;e&&e.layer>Ka.ClearLeafLayer&&e.clearLeaf();)e=e._parent}clearLeaf(){let e=!this._left&&!this._right,t=!e&&this._left.isEmpty()&&this._right.isEmpty();return t&&(this._left=this._right=null,ui.nodeCount-=2),e||t}isContain(e){return this._space.isContain(this._dimension,e)}static rangeBox=new Fe(new d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),new d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE));nodeIntersectsBox(e){let t=this._space.getRange("x"),r=this._space.getRange("y"),i=this._space.getRange("z"),a=ui.rangeBox;return a.min.set(t.min,r.min,i.min),a.max.set(t.max,r.max,i.max),a.intersectsBox(e)}nodeIntersectsRay(e){let t=this._space.getRange("x"),r=this._space.getRange("y"),i=this._space.getRange("z"),a=ui.rangeBox;return a.min.set(t.min,r.min,i.min),a.max.set(t.max,r.max,i.max),!0}pointCast(e,t=0,r){if(r=r||[],this._entities.count>0){let i=this._entities.map;for(let a in i){let o=i[a],n=o.entityContainPoint(e);!n&&t>0&&(n=o.squareDistanceTo(e,this._dimensions)<=t),n&&r.push(o)}}this._left&&this._left.isContain(e[this._left.dimension])&&this._left.pointCast(e,t,r),this._right&&this._right.isContain(e[this._right.dimension])&&this._right.pointCast(e,t,r)}boxCast(e,t){if(t=t||[],this._entities.count>0){let r=this._entities.map;for(let i in r){let a=r[i];a.entityIntersectsBox(e)&&t.push(a)}}this._left&&this._left.nodeIntersectsBox(e)&&this._left.boxCast(e,t),this._right&&this._right.nodeIntersectsBox(e)&&this._right.boxCast(e,t)}pointIntersect=new d;rayCast(e,t,r){t=t||[],r=r||[];let i=this.pointIntersect;if(this._entities.count>0){let a=this._entities.map;for(let o in a){let n=a[o];n.entityIntersectsRay(e,i)&&(r.push(new d().copyFrom(i)),t.push(n))}}this._left&&this._left.nodeIntersectsRay(e)&&this._left.rayCast(e,t,r),this._right&&this._right.nodeIntersectsRay(e)&&this._right.rayCast(e,t,r)}}class sA extends qa{userData;node;constructor(e){super(),this.userData=e}centerValue(e){return 0}isInNode(e,t){return!1}entityContainPoint(e){return!1}squareDistanceTo(e,t){return Number.MAX_VALUE}entityIntersectsBox(e){return!1}entityIntersectsRay(e,t){return!1}attachTreeNode(e){return this.node&&this.detachTreeNode(),this.node=e,this.node.pushEntity(this)}detachTreeNode(){let e=this.node.removeEntity(this);return this.node=null,e}updateNode(e){let t=this.node;t&&this.detachTreeNode(),e.updateEntity(this),t&&t.autoClear()}}class St{minPosX=0;minPosY=0;maxPosX=0;maxPosY=0;testID=0;points;offsetPosition;static TINY=1e-6;constructor(){this.points=new Array,this.offsetPosition=new d(0,0,0,0),this.clear()}setAABox(e,t,r,i){this.minPosX=e-r/2-St.TINY,this.maxPosX=e+r/2+St.TINY,this.minPosY=t-i/2-St.TINY,this.maxPosY=t+i/2+St.TINY,this.offsetPosition.setTo(0,0,0)}setOffset(e){this.maxPosX+=e.x-this.offsetPosition.x,this.minPosX+=e.x-this.offsetPosition.x,this.minPosY+=e.z-this.offsetPosition.z,this.maxPosY+=e.z-this.offsetPosition.z,this.offsetPosition.copyFrom(e)}setContainRect(e,t,r,i){this.minPosX>e&&(this.minPosX=e),this.minPosY>t&&(this.minPosY=t),this.maxPosX<r&&(this.maxPosX=r),this.maxPosY<i&&(this.maxPosY=i)}clear(){var e=1e9;this.minPosX=this.minPosY=e,this.maxPosX=this.maxPosY=-e,this.points.length=0,this.testID=0,this.offsetPosition.setTo(0,0,0)}addPoint(e){this.points.indexOf(e)==-1&&(e.x<this.minPosX&&(this.minPosX=e.x-St.TINY),e.x>this.maxPosX&&(this.maxPosX=e.x+St.TINY),e.z<this.minPosY&&(this.minPosY=e.z-St.TINY),e.z>this.maxPosY&&(this.maxPosY=e.z+St.TINY),this.points.push(e))}clone(){var e=new St;return e.minPosX=this.minPosX,e.minPosY=this.minPosY,e.maxPosX=this.maxPosX,e.maxPosY=this.maxPosY,e}get radius(){return Math.sqrt((this.maxPosY-this.minPosY)*(this.maxPosY-this.minPosY)+(this.maxPosX-this.minPosX)*(this.maxPosX-this.minPosX))}get sideX(){return this.maxPosX-this.minPosX}get sideY(){return this.maxPosY-this.minPosY}get centreX(){return(this.maxPosX-this.minPosX)*.5+this.minPosX}get centreY(){return(this.maxPosY-this.minPosY)*.5+this.minPosY}overlapTest(e){return!(this.minPosY>=e.maxPosY||this.maxPosY<=e.minPosY||this.minPosX>=e.maxPosX||this.maxPosX<=e.minPosX)}isPointInside(e){return e.x>=this.minPosX&&e.x<=this.maxPosX&&e.z>=this.minPosY&&e.z<=this.maxPosY}isIntersectLineSegment(e,t,r,i){var a=!1,o=t-i,n=r-e,l=e*i-r*t,h=(-l-o*this.minPosX)/n;h<=this.maxPosY&&h>=this.minPosY&&(a=!0),h=(-l-o*this.maxPosX)/n,h<=this.maxPosY&&h>=this.minPosY&&(a=!0);var u=(-l-n*this.minPosY)/o;return u<=this.maxPosX&&u>=this.minPosX&&(a=!0),u=(-l-n*this.maxPosY)/o,u<=this.maxPosX&&u>=this.minPosX&&(a=!0),a}}class gi{static NUM_CHILDREN=4;childCellIndices;nodeIndices;aabb;points;constructor(e){this.childCellIndices=new Array,this.childCellIndices.length=gi.NUM_CHILDREN,this.nodeIndices=new Array,this.clear(),e?this.aabb=e.clone():this.aabb=new St}isLeaf(){return this.childCellIndices[0]==-1}clear(){for(var e=0;e<gi.NUM_CHILDREN;e++)this.childCellIndices[e]=-1;this.nodeIndices.splice(0,this.nodeIndices.length)}}class jf{_cells;_rootCell;_quadNodes;_aabb;_cellsToTest;_testID;constructor(){this._testID=0,this._cells=new Array,this._quadNodes=new Array,this._cellsToTest=new Array,this._aabb=new St}getQuadNode(e){return this._quadNodes[e]}clear(){this._cells.length=0,this._quadNodes.length=0}initNodes(e){this.clear();for(var t=0,r=e.length;t<r;)e[t].calcGlobalQuadAABB(),this._quadNodes.push(e[t]),t++}buildQuadTree(e,t){this._aabb.clear();for(var r of this._quadNodes)if(r.isTriangle)for(var i of r.aabb.points)this._aabb.addPoint(i);else this._aabb.setContainRect(r.aabb.minPosX,r.aabb.minPosY,r.aabb.maxPosX,r.aabb.maxPosY);this._cells.length=0,this._rootCell=new gi(this._aabb),this._cells.push(this._rootCell);for(var a=this._quadNodes.length,o=0;o<a;o++)this._cells[0].nodeIndices[o]=o;var n=new Array;n.push(0);for(var l,h,u;n.length!=0;)if(h=n.pop(),!(this._cells[h].nodeIndices.length<=e||this._cells[h].aabb.radius<t)){for(o=0;o<gi.NUM_CHILDREN;o++){this._cells[h].childCellIndices[o]=this._cells.length,n.push(this._cells.length),this._cells.push(new gi(this.createAABox(this._cells[h].aabb,o))),u=this._cells[this._cells.length-1],a=this._cells[h].nodeIndices.length;for(var c=0;c<a;c++)l=this._cells[h].nodeIndices[c],this.doesNodeIntersectCell(this._quadNodes[l],u)&&u.nodeIndices.push(l)}this._cells[h].nodeIndices.length=0}}createAABox(e,t){var r=e.centreX,i=e.centreY,a=e.sideX,o=e.sideY,n=new St;switch(t){case 0:n.setAABox(r+a/4,i+o/4,a/2,o/2);break;case 1:n.setAABox(r-a/4,i+o/4,a/2,o/2);break;case 2:n.setAABox(r-a/4,i-o/4,a/2,o/2);break;case 3:n.setAABox(r+a/4,i-o/4,a/2,o/2);break;default:n.setAABox(r+a/4,i-o/4,a/2,o/2);break}return n}doesNodeIntersectCell(e,t){var r=e.aabb;if(!r.overlapTest(t.aabb))return!1;if(!e.isTriangle)return!0;var i=r.points,a=i[0],o=i[1],n=i[2];if(t.aabb.isPointInside(a)||t.aabb.isPointInside(o)||t.aabb.isPointInside(n))return!0;var l=this.pointInTriangle(t.aabb.minPosX,t.aabb.minPosY,a,o,n)||this.pointInTriangle(t.aabb.minPosX,t.aabb.maxPosY,a,o,n)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.maxPosY,a,o,n)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.minPosY,a,o,n);return l?!0:(l=t.aabb.isIntersectLineSegment(a.x,a.z,o.x,o.z)||t.aabb.isIntersectLineSegment(a.x,a.z,n.x,n.z)||t.aabb.isIntersectLineSegment(o.x,o.z,n.x,n.z),l)}getNodesIntersectingtAABox(e,t){if(this._cells.length==0)return 0;this._cellsToTest.length=0,this._cellsToTest.push(0),this.incrementTestCounter();for(var r,i,a,o,n=0;this._cellsToTest.length!=0;)if(r=this._cellsToTest.pop(),a=this._cells[r],!!t.overlapTest(a.aabb))if(a.isLeaf())for(i=a.nodeIndices.length,n=0;n<i;n++)o=this.getQuadNode(a.nodeIndices[n]).aabb,o.testID!=this._testID&&(o.testID=this._testID,t.overlapTest(o)&&e.push(a.nodeIndices[n]));else for(n=0;n<gi.NUM_CHILDREN;n++)this._cellsToTest.push(a.childCellIndices[n]);return e.length}pointInTriangle(e,t,r,i,a){var o=r,n=i,l=a,h=o.z-n.z,u=n.x-o.x,c=o.x*n.z-n.x*o.z,f=n.z-l.z,g=l.x-n.x,p=n.x*l.z-l.x*n.z,A=l.z-o.z,U=o.x-l.x,x=l.x*o.z-o.x*l.z,v=!1,S=h*e+u*t+c,C=f*e+g*t+p,_=A*e+U*t+x;const y=.01;return(S>=-y&&C>=-y&&_>=-y||S<=y&&C<=y&&_<=y)&&(v=!0),v}incrementTestCounter(){if(++this._testID,this._testID==0){for(var e=this._quadNodes.length,t=0;t<e;t++)this._quadNodes[t].aabb.testID=0;this._testID=1}}logDeep=0;logTree(e){if(!(e<0)){this.logDeep++;for(var t=this._cells[e],r="",i=0;i<this.logDeep-1;i++)r+="-|";console.log(r+"i="+e+" "+t.aabb.minPosX.toFixed(2)+" "+t.aabb.maxPosX.toFixed(2)+" "+t.aabb.minPosY.toFixed(2)+" "+t.aabb.maxPosY.toFixed(2));var a;for(a=0;a<t.nodeIndices.length;a++)if(t.nodeIndices[a]>=0){var o=this._quadNodes[t.nodeIndices[a]];console.log(r+" t="+t.nodeIndices[a]+" "+o.aabb.minPosX.toFixed(2)+" "+o.aabb.maxPosX.toFixed(2)+" "+o.aabb.minPosY.toFixed(2)+" "+o.aabb.maxPosY.toFixed(2))}for(a=0;a<t.childCellIndices.length;a++)t.childCellIndices[a]>=0&&this.logTree(t.childCellIndices[a]);this.logDeep--}}}class Kf{_maxNodesPerCell;_minCellSize;_quadTree;_collisionNodesIdx;_segBox;_collisionNodes;constructor(e=10,t=500){this._maxNodesPerCell=e,this._minCellSize=t,this._segBox=new St,this._collisionNodesIdx=new Array,this._collisionNodes=new Array}createQuadTree(e){this._quadTree=new jf,this._quadTree.initNodes(e),this._quadTree.buildQuadTree(this._maxNodesPerCell,this._minCellSize)}getNodesByAABB(e,t,r,i){this._segBox.clear(),this._segBox.maxPosX=r,this._segBox.maxPosY=i,this._segBox.minPosX=e,this._segBox.minPosY=t,this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var a,o=0;o<this._collisionNodesIdx.length;o++)a=this._quadTree.getQuadNode(this._collisionNodesIdx[o]),this._collisionNodes.push(a);return this._collisionNodes}getTriangleAtPoint(e,t=5){this._segBox.clear(),this._segBox.setAABox(e.x,e.z,1,1),this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var r=4294967295,i=0,a,o,n,l,h=0;h<this._collisionNodesIdx.length;h++)o=this._quadTree.getQuadNode(this._collisionNodesIdx[h]),l=o.aabb,d.pointInsideTriangle(e,l.points[0],l.points[1],l.points[2])&&(n=o,i=Math.abs(n.plane.distance(e)),!(i>t)&&(o==null||i<=r)&&(a=n,r=i));return a}}var bs=(s=>(s[s.MOUSE_LEFT=0]="MOUSE_LEFT",s[s.MOUSE_MID=1]="MOUSE_MID",s[s.MOUSE_RIGHT=2]="MOUSE_RIGHT",s))(bs||{});class oA extends $e{static LOADER_PROGRESS="loaderProgress";static LOADER_COMPLETE="loaderComplete"}class nA extends $e{static ADDED="added";static REMOVED="removed";static CHILD_ADD_EVENT="childAddEvent";static CHILD_REMOVED="childRemoved"}class lA extends $e{static SHOW="show";static HIDE="hide";static UPDATE="update"}class hA{static merge(e,t,r,i){let a=0,o=0;a=Math.max(e.width,a),a=Math.max(t.width,a),a=Math.max(r.width,a),a=Math.max(i.width,a),o=Math.max(e.height,o),o=Math.max(t.height,o),o=Math.max(r.height,o),o=Math.max(i.height,o);let n=new Ae(a,o,X.rgba8unorm),l=new ue(Lc);l.setSamplerTexture("textureR",e),l.setSamplerTexture("textureG",t),l.setSamplerTexture("textureB",r),l.setSamplerTexture("textureA",i),l.setStorageTexture("outTex",n),l.workerSizeX=Math.ceil(a/8),l.workerSizeY=Math.ceil(o/8);let h=F.beginCommandEncoder();return F.computeCommand(h,[l]),F.endCommandEncoder(h),n}}class qf{computeShader;setInputes(e,t,r){this.computeShader=new ue(rf(e,t,r,8,8,1));for(let i=0;i<t.length;i++)this.computeShader.setSamplerTexture(`source${i}Map`,t[i]);for(let i=0;i<r.length;i++)this.computeShader.setStorageTexture(`dest${i}Map`,r[i]);e&&this.computeShader.setSamplerTexture("colorMap",e),this.computeShader.workerSizeX=r[0].width/8,this.computeShader.workerSizeY=r[0].height/8,this.computeShader.workerSizeZ=1}}class $f{sourceShader;compute;needUpdate=!0;constructor(e,t){this.sourceShader=t,this.compute=new ue(e),this.init()}init(){}onUpdate(){this.onFrame&&this.onFrame(),this.onOnce&&this.needUpdate&&(this.needUpdate=!1,this.onFrame())}}class ed extends $f{constructor(e){super(Jc,e)}init(){let e=new Ae(256,256,X.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);return this.compute.setStorageTexture("sssMap",e),this.sourceShader.setTexture("lutMap",e),e}onFrame(){this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let e=F.beginCommandEncoder();F.computeCommand(e,[this.compute]),F.endCommandEncoder(e)}}class uA{gpuBuffer;probes;memoryDo;_probeInfoList;initDataUniform(e){this.memoryDo=new jr,this.probes=e,this._probeInfoList=[],this.memoryDo.destroy(),this.memoryDo.allocation(e.length*17*4);for(let r=0;r<e.length;r++){var t=17;let i=this.memoryDo.allocation_node(t*4);this._probeInfoList.push(i);let a=e[r].transform.worldPosition;i.setArray(0,[a.x,a.y,a.z])}this.gpuBuffer=Q.device.createBuffer({size:this.memoryDo.shareDataBuffer.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE,label:"ProbeBuffer",mappedAtCreation:!1})}updateGPUBuffer(){const e=this.memoryDo.shareDataBuffer;let t=this.memoryDo.shareDataBuffer.byteLength,r=0;const i=5e3*64;for(;r<t;)Q.device.queue.writeBuffer(this.gpuBuffer,r,e,r,Math.floor(Math.min(i,t-r))),r+=i}}class cA extends Tr{constructor(e,t,r=0){super(),this.bufferType=tr.StructStorageGPUBuffer,this.createBufferByStruct(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|r,e,t)}}class fA{static codeMax=`
|
|
11629
|
+
`||R==" "?y=null:(S(R,y),y.width+g>=p&&(y=v()))}})(),C()}getAlignment(e){let t={v:0,h:0};switch(e){case 1:t.v=0,t.h=1;break;case 0:t.v=0,t.h=0;break;case 2:t.v=0,t.h=2;break;case 4:t.v=1,t.h=1;break;case 3:t.v=1,t.h=0;break;case 5:t.v=1,t.h=2;break;case 7:t.v=2,t.h=1;break;case 6:t.v=2,t.h=0;break;case 8:t.v=2,t.h=2;break}return t}}class Ws extends Un{_style=Oe.NORMAL;_interactive=!1;set interactive(e){this._interactive=e}get interactive(){return this._interactive}set mouseStyle(e){this._style=e}get interactiveVisible(){return this._uiTransform.globalVisible&&this._visible}init(e){super.init(e),this._uiTransform.addUIInteractive(this)}destroy(){this._uiTransform.removeUIInteractive(this),super.destroy()}rayPick(e,t,r,i){return Nf.rayPick(e,r,i,t.space,t.panelRatio,this._uiTransform,t.transform.worldMatrix)}cloneTo(e){e.getOrAddComponent(Ws).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.enable=e._enable,this.interactive=e._interactive,this.mouseStyle=e._style,this}}var zf=(s=>(s[s.NONE=0]="NONE",s[s.COLOR=1]="COLOR",s[s.SPRITE=2]="SPRITE",s))(zf||{});class Rn extends Ws{_spriteMap;_colorMap;_image;_isCreateImage;_transition=2;init(e){super.init(e),this._interactive=!0,this._spriteMap=new Map,this._colorMap=new Map,this._image=this.object3D.getComponent(Ti),this._isCreateImage=this._image==null,this._image||(this._image=this.object3D.addComponent(Ti)),this.imageType=ea.Sliced}onEnable(){this.mouseStyle=Oe.NORMAL}onDisable(){this.mouseStyle=Oe.DISABLE}set transition(e){this._transition!=e&&(this._transition=e,this.validateStyle(this._style,!0))}get transition(){return this._transition}get imageType(){return this._image.imageType}set imageType(e){this._image.imageType=e}setStyleColor(e,t){return this._colorMap.set(e,t),this._style==e&&this.validateStyle(this._style,!0),this}getStyleColor(e){return this._colorMap.get(e)}set mouseStyle(e){super.mouseStyle=e,this.validateStyle(e,!0)}get normalSprite(){return this._spriteMap.get(Oe.NORMAL)}set normalSprite(e){this._spriteMap.set(Oe.NORMAL,e),this._style==Oe.NORMAL&&this.validateStyle(this._style,!0)}get overSprite(){return this._spriteMap.get(Oe.OVER)}set overSprite(e){this._spriteMap.set(Oe.OVER,e),this._style==Oe.OVER&&this.validateStyle(this._style,!0)}set downSprite(e){this._spriteMap.set(Oe.DOWN,e),this._style==Oe.DOWN&&this.validateStyle(this._style,!0)}get downSprite(){return this._spriteMap.get(Oe.DOWN)}set disableSprite(e){this._spriteMap.set(Oe.DISABLE,e),this._style==Oe.DISABLE&&this.validateStyle(this._style,!0)}get disableSprite(){return this._spriteMap.get(Oe.DISABLE)}validateStyle(e,t){if(this._transition&2){let r=this._spriteMap.get(e);this._image.sprite=r}if(this._transition&1){let r=this._colorMap.get(e);r&&(this._image.color=r)}}cloneTo(e){e.getOrAddComponent(Rn).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this.imageType=e.imageType,this.transition=e.transition,e._spriteMap.forEach((t,r)=>{t&&this._spriteMap.set(r,t)}),e._colorMap.forEach((t,r)=>{t&&this._colorMap.set(r,t.clone())}),this.mouseStyle=e.mouseStyle,this}destroy(){this._isCreateImage&&this._image&&(this.object3D.removeComponent(Ti),this._image=null),super.destroy()}}class In extends Ia{_count=0;constructor(){super()}init(e){super.init?.(e),this._count=e?e.count:1;for(let t=0;t<this._count;t++)this.attachQuad(Ir.spawnQuad());this._uiTransform.resize(0,0)}getQuad(e){return this._mainQuads[e]}cloneTo(e){e.addComponent(In,{count:this._count}).copyComponent(this)}copyComponent(e){super.copyComponent(e);for(let t=0;t<e._count;t++)this.setSprite(t,e.getSprite(t)),this.setColor(t,e.getColor(t)),this.setImageType(t,e.getImageType(t));return this}setSprite(e,t){this._mainQuads[e].sprite=t||m.res.defaultGUISprite,this.setShadowDirty()}getSprite(e){return this._mainQuads[e].sprite}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t.visible=!e;this.setShadowDirty()}getColor(e){return this._mainQuads[e].color}setColor(e,t){this._mainQuads[e].color=t,this.setShadowDirty()}getImageType(e){return this._mainQuads[e].imageType}setImageType(e,t){this._mainQuads[e].imageType=t,this.setShadowDirty()}setSize(e,t,r){this._mainQuads[e].setSize(t,r),this.setShadowDirty()}setXY(e,t,r){this._mainQuads[e].setXY(t,r),this.setShadowDirty()}getXY(e,t){t||=new j;let r=this._mainQuads[e];return t.x=r.x,t.y=r.y,t}}class En extends Ia{_shadowQuality=1;_shadowOffset;_shadowRadius;_shadowColor;_subShadowColor;needUpdateShadow=!1;init(e){super.init?.(e),this._shadowRadius=2,this._shadowQuality=1,this._shadowOffset=new j(4,-4),this._shadowColor=new P(.1,.1,.1,.8),this._subShadowColor=this._shadowColor.clone(),this.isUIShadow=!0}cloneTo(e){e.getOrAddComponent(En).copyComponent(this)}copyComponent(e){return super.copyComponent(this),this._shadowColor=e._shadowColor,this._shadowOffset=e._shadowOffset,this._shadowRadius=e._shadowRadius,this._shadowQuality=e.shadowQuality,this}get shadowColor(){return this._shadowColor}set shadowColor(e){this._shadowColor.copyFrom(e),this.needUpdateShadow=!0}set shadowQuality(e){e=ie(e,0,4),this._shadowQuality!=e&&(this._shadowQuality=e,this.needUpdateShadow=!0)}get shadowQuality(){return this._shadowQuality}set shadowOffset(e){this._shadowOffset=e,this.needUpdateShadow=!0}get shadowOffset(){return this._shadowOffset||=new j(4,-4),this._shadowOffset}set shadowRadius(e){this._shadowRadius!=e&&(this._shadowRadius=e,this.applyShadow())}get shadowRadius(){return this._shadowRadius}onUpdate(e){this.needUpdateShadow&&(this.applyShadow(),this.needUpdateShadow=!1)}applyShadow(){if(this.detachQuads(),this._shadowSource&&this._shadowQuality>0){let e=this._shadowSource.mainQuads;if(e.length>0)for(let t of e)this.createQuadShadow(t)}this._uiTransform.setNeedUpdateUIPanel()}createQuadShadow(e){let t=this._shadowQuality,r=Math.PI*2;this._subShadowColor.copyFrom(this._shadowColor),this._subShadowColor.a=1/Math.max(1,t);for(let i=0;i<t;i++){let a=Ir.spawnQuad(),o=0,n=0;if(i==0)a.color=this._shadowColor;else{let l=r*(i-1)/(t-1);o=Math.sin(l)*this._shadowRadius,n=Math.cos(l)*this._shadowRadius,a.color=this._subShadowColor}a.setXY(o+this._shadowOffset.x+e.x,n+this._shadowOffset.y+e.y),a.setSize(e.width,e.height),a.sprite=e.sprite,a.visible=e.visible,a.imageType=e.imageType,this.attachQuad(a)}}}class wn extends Ia{_font="\u5FAE\u8F6F\u96C5\u9ED1";_fontSize=14;_originSize=42;_alignment=0;_lineSpacing=1;_text="";_color=new P(1,1,1,1);constructor(){super()}cloneTo(e){e.getOrAddComponent(wn).copyComponent(this)}copyComponent(e){return super.copyComponent(e),this._font=e._font,this._fontSize=e._fontSize,this._originSize=e._originSize,this._alignment=e._alignment,this._lineSpacing=e._lineSpacing,this._color.copyFrom(e._color),this.text=e.text,this}get originSize(){return this._originSize}get font(){return this._font}set font(e){this._font=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!=e&&(this._fontSize=e,this.layoutText())}get text(){return this._text}set text(e){this._text!=e&&(e||(e=""),this._text=e,this.layoutText())}textLine=null;layoutProxy=new Of;layoutText(){this.detachQuads(),this.textLine=this.layoutProxy.layout(this);for(let e=0,t=this.textLine.length;e<t;e++){let r=this.textLine[e];for(let i=0,a=r.quadList.length;i<a;i++){let o=r.quadList[i];o&&this.attachQuad(o)}}this.color=this._color,this._uiTransform.setNeedUpdateUIPanel(),this.onUIComponentVisible(this._visible),this.setShadowDirty()}onUIComponentVisible(e){this.applyComponentVisible()}onUITransformVisible(e){this.applyComponentVisible()}applyComponentVisible(){let e=!this._visible||!this._uiTransform.globalVisible;for(let t of this._mainQuads)t&&(t.visible=!e);this.setShadowDirty()}onTransformResize(){this.layoutText()}get color(){return this._color}set color(e){this._color.copyFrom(e);for(let t of this._mainQuads)t.color=e;this.setShadowDirty()}get alignment(){return this._alignment}set alignment(e){this._alignment!=e&&(this._alignment=e,this.layoutText())}get lineSpacing(){return this._lineSpacing}set lineSpacing(e){this._lineSpacing!=e&&(this._lineSpacing=e,this.layoutText())}}var Pm=Object.getOwnPropertyDescriptor,km=(s,e,t,r)=>{for(var i=r>1?void 0:r?Pm(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let Fs=class extends Ua{constructor(){super()}init(){super.init(),this.lightData.lightType=Xe.PointLight,this.object3D.name==""&&(this.object3D.name="PointLight"+It())}get range(){return this.lightData.range}set range(s){this.lightData.range=s,this.onChange()}get at(){return this.lightData.linear}set at(s){this.lightData.linear=s,this.onChange()}get radius(){return this.lightData.radius}set radius(s){this.lightData.radius=s,this.onChange()}get quadratic(){return this.lightData.quadratic}set quadratic(s){this.lightData.quadratic=s,this.onChange()}start(){this.transform.rotationX=90,super.start()}onUpdate(){}onGraphic(s){let e=s.scene.getChildByName("graphic3D");if(!e)return;let t=e.createCustomShape(`PointLight_${this.object3D.instanceID}`,this.transform);t.buildAxis(),t.buildCircle(d.ZERO,this.range,32,d.X_AXIS),t.buildCircle(d.ZERO,this.range,32,d.Y_AXIS),t.buildCircle(d.ZERO,this.range,32,d.Z_AXIS)}debug(){}debugDraw(s){}};Fs=km([Pt(Fs,"Light")],Fs);var Lm=Object.getOwnPropertyDescriptor,Om=(s,e,t,r)=>{for(var i=r>1?void 0:r?Lm(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let Ea=class extends Nr{_fatLineMaterial=null;_fatLineGeometry=null;_cachedResolution=new j(0,0);constructor(){super()}onEnable(){super.onEnable()}onDisable(){super.onDisable()}cloneTo(s){s.addComponent(Ea).copyComponent(this)}copyComponent(s){return super.copyComponent(s),this}set geometry(s){super.geometry=s,this._fatLineGeometry=s,s&&(this.instanceCount=s.instanceCount,this._fatLineMaterial&&s.instanceBuffer&&this._fatLineMaterial.setInstanceBuffer(s.instanceBuffer))}get geometry(){return this._fatLineGeometry}set material(s){this.materials=[s],this._fatLineMaterial=s,this._fatLineGeometry&&this._fatLineGeometry.instanceBuffer&&s.setInstanceBuffer(this._fatLineGeometry.instanceBuffer)}get material(){return this._fatLineMaterial}nodeUpdate(s,e,t,r){if(this._fatLineMaterial&&this.object3D){this._fatLineMaterial.setModelMatrix(this.object3D.transform.worldMatrix);const i=Q.presentationSize[0],a=Q.presentationSize[1];i>0&&a>0&&(this._cachedResolution.x!==i||this._cachedResolution.y!==a)&&(this._cachedResolution.set(i,a),this._fatLineMaterial.resolution=this._cachedResolution.clone())}super.nodeUpdate(s,e,t,r)}destroy(s){super.destroy(s)}};Ea=Om([Pt(Ea,"FatLineRenderer")],Ea);class Gf extends q{index=0;drawCallFrame=-1;constructor(){super()}}var xn=(s=>(s[s.CastGI=0]="CastGI",s[s.ReceiveGI=1]="ReceiveGI",s[s.CastDepth=2]="CastDepth",s[s.Other=3]="Other",s))(xn||{});class Wf extends At{static count=0;constructor(e=0,t=0){super(),O.register("GIProbeShader",lf);let r=new ot,i=new Pe("GIProbeShader","GIProbeShader");i.passType=H.COLOR,r.addRenderPass(i),i.setDefine("USE_BRDF",!0),i.setShaderEntry("VertMain","FragMain"),i.setUniformVector4("probeUniform",new $(t,e,0,0));let a=i.shaderState;a.acceptShadow=!1,a.castShadow=!1,a.receiveEnv=!1,a.acceptGI=!1,a.useLight=!1,r.setTexture("baseMap",m.res.whiteTexture),r.setTexture("normalMap",m.res.normalTexture),r.setTexture("emissiveMap",m.res.blackTexture),this.shader=r}}class zm extends ke{_probes;_volume;_debugMr=[];init(e){e||=m.views[0]?.scene,m.setting.gi.enable=!0,this._volume=ne.getLightEntries(e).irradianceVolume,this.initProbe(e)}initProbe(e){let t=this._volume.setting.probeXCount,r=this._volume.setting.probeYCount,i=this._volume.setting.probeZCount,a=new Qi(4,16,16),o=new d;this._probes=[];for(let n=0;n<t;n++)for(let l=0;l<r;l++)for(let h=0;h<i;h++){let u=n+h*t+l*(t*i),c=new Gf;c.index=u,c.name=`${n}_${l}_${h}`;let f=c.addComponent(K);f.material=new Wf(xn.CastGI,u),f.geometry=a,f.castGI=!1,f.castShadow=!1,this._debugMr.push(f),this.object3D.addChild(c),this._volume.calcPosition(n,l,h,o),c.x=o.x,c.y=o.y,c.z=o.z,this._probes[u]=c,this._debugMr.push(f)}for(let n=0;n<this._probes.length;n++)G.instance.addGIProbe(e,this._probes[n]);this.object3D.transform.enable=!1,this._volume.setting.debug&&this.debug()}debug(){}debugProbeRay(e,t){const r=m.setting.gi.rayNumber;let i=new Z(0,-.7071067811865475,.7071067811865475,0);for(let a=0;a<r;a++){let o=e*r+a,n=new d(-t[o*4+0],-t[o*4+1],-t[o*4+2],0);i.transformVector(n,n);let l=t[o*4+3],h=this._probes[e].transform.worldPosition.clone(),u=n.scaleBy(l);u.add(h,u)}}changeProbesVolumeData(){this._volume.setVolumeDataChange()}changeProbesPosition(){this._volume.setVolumeDataChange();let e=this._volume.setting.probeXCount,t=this._volume.setting.probeYCount,r=this._volume.setting.probeZCount,i=new d;for(let a=0;a<e;a++)for(let o=0;o<t;o++)for(let n=0;n<r;n++){let l=a+n*e+o*(e*r),h=this._probes[l];this._volume.calcPosition(a,o,n,i),h.x=i.x,h.y=i.y,h.z=i.z}}onUpdate(){m.setting.gi.maxDistance=m.setting.gi.probeSpace*1.5;let e=this.transform.scene3D.view.camera,t=d.distance(e.transform.worldPosition,e.transform.targetPos)/300;if(this._debugMr&&this._debugMr.length>0)for(let r=0;r<this._debugMr.length;r++){const i=this._debugMr[r].transform;i.scaleX=t,i.scaleY=t,i.scaleZ=t}}}class Gm extends Nr{_keyRenderGroup;_keyBufferGroup;_keyIdsGroup;constructor(){super()}init(e){this._keyRenderGroup=new Map,this._keyBufferGroup=new Map,this._keyIdsGroup=new Map}start(){let e=[];this.object3D.getComponents(K,e,!0);for(let t=0;t<e.length;t++){const r=e[t];r.transform.updateWorldMatrix(!0),r.enable=!1;let i=r.geometry.instanceID;for(let a=0;a<r.materials.length;a++){const o=r.materials[a];i+=o.instanceID}if(this._keyRenderGroup.has(i))this._keyRenderGroup.get(i).push(r),this._keyIdsGroup.get(i).push(r.transform.worldMatrix.index);else{let a=new Be(e.length);a.visibility=GPUShaderStage.VERTEX,this._keyRenderGroup.set(i,[r]),this._keyBufferGroup.set(i,a),this._keyIdsGroup.set(i,[r.transform.worldMatrix.index])}}this._keyBufferGroup.forEach((t,r)=>{let i=this._keyIdsGroup.get(r),a=this._keyBufferGroup.get(r);a.setInt32Array("matrixIDs",new Int32Array(i)),a.apply()})}reset(){this._keyRenderGroup.size>0&&(this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this.start())}nodeUpdate(e,t,r,i){this._keyRenderGroup.forEach((a,o)=>{let n=this._keyBufferGroup.get(o),l=a[0];for(let h=0;h<l.materials.length;h++){let c=l.materials[h].getPass(t);if(c)for(let f=0;f<c.length;f++){const g=c[f];g.setDefine("USE_INSTANCEDRAW",!0),g.setStorageBuffer("instanceDrawID",n)}}l.nodeUpdate(e,t,r,i)})}renderPass(e,t,r){this._keyRenderGroup.forEach((i,a)=>{let o=i[0];o.instanceCount=i.length,this.renderItem(e,t,o,r)})}renderItem(e,t,r,i){let a=r.transform._worldMatrix;for(let o=0;o<r.materials.length;o++){let l=r.materials[o].getPass(t);if(!(!l||l.length==0))for(let h=0;h<l.length;h++){let u=l[h];F.bindGeometryBuffer(i.encoder,r.geometry);const c=u;c.shaderState.splitTexture&&(i.endRenderPass(),Ct.WriteSplitColorTexture(r.instanceID),i.beginOpaqueRenderPass(),F.bindCamera(i.encoder,e.camera),F.bindGeometryBuffer(i.encoder,r.geometry)),F.bindPipeline(i.encoder,c);let A=r.geometry.subGeometries[o].lodLevels[r.lodLevel];r.instanceCount>0?F.drawIndexed(i.encoder,A.indexCount,r.instanceCount,A.indexStart,0,0):F.drawIndexed(i.encoder,A.indexCount,1,A.indexStart,0,a.index)}}}beforeDestroy(e){this._keyRenderGroup.clear(),this._keyBufferGroup.clear(),this._keyIdsGroup.clear(),this._keyRenderGroup=this._keyBufferGroup=this._keyIdsGroup=void 0,Se.removeWaitStart(this.object3D,this)}}var Wm=Object.getOwnPropertyDescriptor,Jm=(s,e,t,r)=>{for(var i=r>1?void 0:r?Wm(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let ys=class extends K{constructor(){super()}get geometry(){return null}set geometry(s){}cloneTo(s){}set meshURL(s){let e=m.res.getGeometry(s);e?this.geometry=e:console.error("no geometry set",s)}};ys=Jm([Pt(ys,"MeshFilter")],ys);var Zm=Object.getOwnPropertyDescriptor,Ym=(s,e,t,r)=>{for(var i=r>1?void 0:r?Zm(e,t):e,a=s.length-1,o;a>=0;a--)(o=s[a])&&(i=o(i)||i);return i};let wa=class extends K{skinJointsName;mInverseBindMatrixData;mInverseBindMatrixBuffer;mSkeletonAnimation;mJointIndexTableBuffer;constructor(){super(),this.addRendererMask(ve.SkinnedMesh)}start(){if(super.start(),this.skeletonAnimation=this.object3D.getComponent(si),!this.skeletonAnimation){let s=this.object3D.parentObject.parentObject.getComponentsInChild(si);s.length>0&&(this.skeletonAnimation=s[0]);let e=this.object3D;for(;!this.skeletonAnimation&&e;)this.skeletonAnimation=e.getComponentFromParent(si),e.parent&&(e=e.parent.object3D)}}onEnable(){super.onEnable()}get skeletonAnimation(){return this.mSkeletonAnimation}set skeletonAnimation(s){if(this.mSkeletonAnimation=s,!!s&&!this.mJointIndexTableBuffer){let e=this.mSkeletonAnimation.getJointIndexTable(this.skinJointsName);this.mJointIndexTableBuffer=new Be(e.length*4,0,new Float32Array(e)),this.mJointIndexTableBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}}get skinInverseBindMatrices(){return this.mInverseBindMatrixData}set skinInverseBindMatrices(s){this.mInverseBindMatrixData=s;var e=new Float32Array(s.length*16);for(let t=0;t<s.length;t++){let r=t*16,i=s[t];e.set(i,r)}this.mInverseBindMatrixBuffer=new Be(e.byteLength,0,e),this.mInverseBindMatrixBuffer.visibility=GPUShaderStage.VERTEX|GPUShaderStage.COMPUTE}get inverseBindMatrixBuffer(){return this.mInverseBindMatrixBuffer}get jointIndexTableBuffer(){return this.mJointIndexTableBuffer.buffer}cloneTo(s){let e=s.addComponent(wa);e.geometry=this.geometry,e.material=this.material.clone(),e.castShadow=this.castShadow,e.castGI=this.castGI,e.receiveShadow=this.receiveShadow,e.rendererMask=this.rendererMask,e.skinJointsName=this.skinJointsName,e.skinInverseBindMatrices=this.skinInverseBindMatrices,e.mJointIndexTableBuffer=this.mJointIndexTableBuffer}nodeUpdate(s,e,t,r){for(let i=0;i<this.materials.length;i++){let o=this.materials[i].getPass(e);if(o)for(let n=0;n<o.length;n++){const l=o[n];!l.pipeline&&this.mSkeletonAnimation&&(l.setStorageBuffer("jointsMatrixIndexTable",this.mSkeletonAnimation.jointMatrixIndexTableBuffer),l.setStorageBuffer("jointsInverseMatrix",this.mInverseBindMatrixBuffer),l.setStorageBuffer("jointsIndexMapingTable",this.mJointIndexTableBuffer))}}super.nodeUpdate(s,e,t,r)}};wa=Ym([Pt(wa,"SkinnedMeshRenderer")],wa);class Xm extends qe{radius=2.5;height=10;constructor(){super(),this._shapeType=ta.Capsule}}class Js extends qe{mesh;static triangle;_pickRet;constructor(){super(),this._shapeType=ta.Mesh}rayPick(e,t){if(this.mesh){Js.triangle||=new ja(new d,new d,new d);let r=this.mesh.getAttribute(V.position),i=this.mesh.getAttribute(V.indices),a=qe.helpMatrix;a.copyFrom(t).invert();let o=qe.helpRay.copy(e);if(o.applyMatrix(a),o.intersectBox(this.mesh.bounds),!o.intersectBox(this.mesh.bounds,qe.v3_help_0))return null;if(i&&r&&i.data.length>0){let l=r.data;for(let h=0,u=i.data.length/3;h<u;h++){let c=h*3;const f=i.data[c+0]*3,g=i.data[c+1]*3,p=i.data[c+2]*3;let A=Js.triangle,U=A.v1.set(l[f+0],l[f+1],l[f+2]),x=A.v2.set(l[g+0],l[g+1],l[g+2]),v=A.v3.set(l[p+0],l[p+1],l[p+2]);A.set(U,x,v);let S=o.intersectTriangle(o.origin,o.direction,A);if(S){this._pickRet||={intersectPoint:new d,distance:0},this._pickRet.intersectPoint=S,this._pickRet.distance=d.distance(o.origin,S);let C=this.mesh.getAttribute(V.normal);if(C){let _=C.data,y=new d(_[f],_[f+1],_[f+2]);t.transformVector(y,y),y.normalize(),this._pickRet.normal=y}return this._pickRet}}}}return null}}class Hm extends qe{_pickRet;box;radius=.5;constructor(e){super(),this._shapeType=ta.Sphere,this.radius=e,this.box=new Za(new d,1)}rayPick(e,t){this.box.setFromCenterAndSize(this.center,this.radius);let i=qe.helpMatrix;i.copyFrom(t).invert();let a=qe.helpRay.copy(e);a.applyMatrix(i);let o=a.intersectSphere(a.origin,a.direction,this.box.center,this.box.radius);return o?(this._pickRet||(this._pickRet={intersect:!1,intersectPoint:new d,distance:0}),this._pickRet.intersect=!0,this._pickRet.intersectPoint=o,this._pickRet.distance=d.distance(a.origin,qe.v3_help_0),this._pickRet):null}}class jm extends q{_envMap;skyObject;envMapChange=!0;view;constructor(){super(),this.transform.scene3D=this,this.skyObject=new q,this.addChild(this.skyObject),this._isScene3D=!0,this.envMap||=m.res.defaultSky}get envMap(){return this._envMap}set envMap(e){this._envMap!=e&&(this.envMapChange=!0),this._envMap=e,G.instance.sky&&"map"in G.instance.sky&&(G.instance.sky.map=e)}get exposure(){return G.instance.sky&&"exposure"in G.instance.sky?G.instance.sky.exposure:0}set exposure(e){G.instance.sky&&"exposure"in G.instance.sky&&(G.instance.sky.exposure=e,m.setting.sky.skyExposure=e)}get roughness(){if(G.instance.sky&&"roughness"in G.instance.sky)return G.instance.sky.roughness}set roughness(e){G.instance.sky&&"roughness"in G.instance.sky&&(G.instance.sky.roughness=e)}}class Jf{_computeShader;_outBuffer;constructor(){}init(){let e=se.getGBufferFrame(se.colorPass_GBuffer);this._computeShader=new ue(Wc),this._outBuffer=new Hi(32),this._computeShader.setStorageBuffer("outBuffer",this._outBuffer),this._computeShader.setSamplerTexture("gBufferTexture",e.getCompressGBufferTexture())}compute(e){let t=ne.getCameraGroup(e.camera);this._computeShader.setStorageBuffer("globalUniform",t.uniformGPUBuffer);let r=F.beginCommandEncoder();F.computeCommand(r,[this._computeShader]),F.endCommandEncoder(r),this._outBuffer.readBuffer()}getPickMeshID(){var e=this._outBuffer.outFloat32Array[0]+.1;return Math.floor(e)}getPickWorldPosition(e){e||=new d;var t=this._outBuffer.outFloat32Array[4],r=this._outBuffer.outFloat32Array[5],i=this._outBuffer.outFloat32Array[6];return e.set(t,r,i),e}getPickWorldNormal(e){e||=new d;var t=this._outBuffer.outFloat32Array[8],r=this._outBuffer.outFloat32Array[9],i=this._outBuffer.outFloat32Array[10];return e.set(t*2-1,r*2-1,i*2-1).normalize(),e}getPickScreenUV(e){e||=new j;var t=this._outBuffer.outFloat32Array[2],r=this._outBuffer.outFloat32Array[3];return e.set(t,r),e}}class Zf extends Er{ray;isTouching=!1;_mouseCode;_pickEvent;_outEvent;_overEvent;_upEvent;_downEvent;_mouseMove;_pickCompute;_lastDownTarget;mouseEnableMap;_view;constructor(e){super(),this._view=e,this.init()}init(){this.ray=new $t,this.mouseEnableMap=new Map,this._pickEvent=new k(k.PICK_CLICK),this._outEvent=new k(k.PICK_OUT),this._overEvent=new k(k.PICK_OVER),this._mouseMove=new k(k.PICK_MOVE),this._upEvent=new k(k.PICK_UP),this._downEvent=new k(k.PICK_DOWN)}start(){m.setting.pick.enable&&(m.inputSystem.addEventListener(k.POINTER_DOWN,this.onTouchStart,this),m.inputSystem.addEventListener(k.POINTER_UP,this.onTouchEnd,this),m.inputSystem.addEventListener(k.POINTER_CLICK,this.onTouchOnce,this),m.inputSystem.addEventListener(k.POINTER_RIGHT_CLICK,this.onTouchOnce,this),m.inputSystem.addEventListener(k.POINTER_MOVE,this.onTouchMove,this)),m.setting.pick.mode=="pixel"&&(this._pickCompute=new Jf,this._pickCompute.init())}stop(){m.inputSystem.removeEventListener(k.POINTER_DOWN,this.onTouchStart,this),m.inputSystem.removeEventListener(k.POINTER_UP,this.onTouchEnd,this),m.inputSystem.removeEventListener(k.POINTER_CLICK,this.onTouchOnce,this),m.inputSystem.removeEventListener(k.POINTER_RIGHT_CLICK,this.onTouchOnce,this),m.inputSystem.removeEventListener(k.POINTER_MOVE,this.onTouchMove,this)}onTouchStart(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);this._lastDownTarget=t,t&&(Object.assign(this._downEvent,e),this._downEvent.type=k.PICK_DOWN,this._downEvent.target=t.object3D,this._downEvent.data=this.getPickInfo(),this.dispatchEvent(this._downEvent),t.object3D.containEventListener(k.PICK_DOWN)&&t.object3D.dispatchEvent(this._downEvent))}onTouchEnd(e){this.isTouching=!1,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._upEvent,e),this._upEvent.type=k.PICK_UP,this._upEvent.target=t.object3D,this._upEvent.data=this.getPickInfo(),this.dispatchEvent(this._upEvent),t.object3D.containEventListener(k.PICK_UP)&&t.object3D.dispatchEvent(this._upEvent))}_lastFocus;getPickInfo(){if(m.setting.pick.mode=="pixel")return{worldPos:this._pickCompute.getPickWorldPosition(),worldNormal:this._pickCompute.getPickWorldNormal(),screenUv:this._pickCompute.getPickScreenUV(),meshID:this._pickCompute.getPickMeshID()};{let e=this._interestList[0];return{worldPos:e.intersectPoint,worldNormal:e.normal,meshID:e.collider.transform.worldMatrix.index,distance:e.distance}}}onTouchMove(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);t&&(Object.assign(this._mouseMove,e),this._mouseMove.type=k.PICK_MOVE,this._mouseMove.target=t.object3D,this._mouseMove.data=this.getPickInfo(),this.dispatchEvent(this._mouseMove),t.object3D.containEventListener(k.PICK_MOVE)&&t.object3D.dispatchEvent(this._mouseMove)),t!=this._lastFocus&&(this._lastFocus&&this._lastFocus.object3D&&(Object.assign(this._outEvent,e),this._outEvent.type=k.PICK_OUT,this._outEvent.target=this._lastFocus.object3D,this._outEvent.data=this.getPickInfo(),this.dispatchEvent(this._outEvent),this._lastFocus.object3D.containEventListener(k.PICK_OUT)&&this._lastFocus.object3D.dispatchEvent(this._outEvent)),t&&(Object.assign(this._overEvent,e),this._overEvent.type=k.PICK_OVER,this._overEvent.target=t.object3D,this._overEvent.data=this.getPickInfo(),this.dispatchEvent(this._overEvent),t.object3D.containEventListener(k.PICK_OVER)&&t.object3D.dispatchEvent(this._overEvent))),this._lastFocus=t}onTouchOnce(e){this.isTouching=!0,this._mouseCode=e.mouseCode,this.pick(this._view.camera);let t=this.findNearestObj(this._interestList,this._view.camera);if(t){let r=this.getPickInfo();Object.assign(this._pickEvent,e),this._pickEvent.type=k.PICK_CLICK,this._pickEvent.target=t.object3D,this._pickEvent.data=r,this.dispatchEvent(this._pickEvent),t===this._lastDownTarget&&t.object3D.containEventListener(k.PICK_CLICK)&&t.object3D.dispatchEvent(this._pickEvent)}this._lastDownTarget=null}findNearestObj(e,t){return e.sort((r,i)=>r.distance>i.distance?1:-1),e[0]?.collider}_interestList=[];pick(e){if(this._interestList.length=0,m.setting.pick.mode=="pixel"){this._pickCompute.compute(this._view);let t=this._pickCompute.getPickMeshID(),r=this.mouseEnableMap.get(t);if(r){let i=this._pickCompute.getPickWorldPosition(),a=d.distance(i,this.ray.origin);this._interestList.push({distance:a,collider:r,intersectPoint:i})}}else if(m.setting.pick.mode=="bound"){this.ray=e.screenPointToRay(m.inputSystem.mouseX,m.inputSystem.mouseY);let t,r=Se.componentsEnablePickerList.get(this._view);if(r)for(const i of r){let a=i[0];a.enable&&(t=a.rayPick(this.ray),t&&(t.collider=a,this._interestList.push(t)))}}}}class Km extends ns{_camera;_scene;_viewPort;_enablePick=!1;_enable=!0;pickFire;guiPick;canvasList;constructor(e=0,t=0,r=0,i=0){super(),this.canvasList=[],this._viewPort=new $(e,t,r,i)}get enable(){return this._enable}set enable(e){this._enable=e}get enablePick(){return this._enablePick}set enablePick(e){this._enablePick!=e&&(this.pickFire=new Zf(this),this.pickFire.start()),this._enablePick=e}get scene(){return this._scene}set scene(e){this._scene=e,e.view=this,Tt.createBuffer(this),e&&this.canvasList.forEach(t=>{t&&e.addChild(t.object3D)})}get camera(){return this._camera}set camera(e){this._camera=e}get viewPort(){return this._viewPort}set viewPort(e){this._viewPort=e}enableUICanvas(e=0){let t=this.canvasList[e];if(!t){let r=new q;r.name="Canvas "+e,t=r.addComponent(Xa),t.index=e,this.canvasList[e]=t}return this.scene.addChild(t.object3D),this.guiPick||(this.guiPick=new Tf,this.guiPick.init(this)),t}disableUICanvas(e=0){let t=this.canvasList[e];t&&t.object3D&&t.object3D.removeFromParent()}}class qm{normal;fixNormal;center;rotateShape;distance=0;index;constructor(e){this.index=e,this.rotateShape=[]}}class $m extends Ie{vScale;uNegate;sections;build(e,t,r,i=1,a=!0){if(r.length<2)throw new Error("path length is not enough");return this.vScale=i,this.uNegate=a,e=e.slice(),t&&e.push(e[0]),this.sections=this.buildSections(e,r),this.buildGeometry(e,this.sections),this.bounds=new Fe(d.ZERO.clone(),new d(100,100,100)),this}buildSections(e,t){let r,i,a,o=[],n=t.length;for(let h=0;h<n;h++){let u=new qm(h);r=t[h],i=t[h+1],u.center=r.clone(),i==null?(u.normal=a.clone(),u.distance=0):(a=i.subtract(r),u.distance=a.length,u.normal=a.normalize()),o.push(u)}o[0].fixNormal=o[0].normal.clone();for(let h=1;h<n;h++){let u=o[h-1],c=o[h];c.fixNormal=c.normal.add(u.normal).normalize()}let l=new I().identity();for(let h=0;h<n;h++){let u=o[h],c,f;if(h==0)c=d.UP,f=e;else{let g=o[h-1];c=g.fixNormal,f=g.rotateShape}I.fromToRotation(c,u.fixNormal,l);for(let g=0,p=e.length;g<p;g++){let A=l.multiplyPoint3(f[g]);u.rotateShape.push(A)}}return o}buildGeometry(e,t){let r=t.length,i=e.length,a=r*i,o=r-1,n=new Float32Array(a*3),l=new Float32Array(a*3),h=new Float32Array(a*2),u=new Uint32Array(o*(i-1)*6),c=i-1,f=0,g=0,p=[0];for(let U=1;U<i;U++)g+=e[U-1].subtract(e[U]).length,p.push(g);for(let U=0;U<r;U++){let x=t[U];for(let v=0;v<i;v++){let S=(U*i+v)*3,C=x.rotateShape[v].add(x.center);n[S]=C.x,n[S+1]=C.y,n[S+2]=C.z,l[S+1]=1;let _=(U*i+v)*2,y=p[v]/g;h[_]=this.uNegate?1-y:y,h[_+1]=f*this.vScale}f+=x.distance}let A=0;for(let U=0;U<o;U++){let x=U*i;for(let v=0;v<c;v++){let S=v,C=v+1,_=S+i,y=C+i;u[A++]=S+x,u[A++]=C+x,u[A++]=_+x,u[A++]=C+x,u[A++]=y+x,u[A++]=_+x}}return this.setIndices(u),this.setAttribute(V.position,n),this.setAttribute(V.normal,l),this.setAttribute(V.uv,h),this.setAttribute(V.TEXCOORD_1,h),this.addSubGeometry({indexStart:0,indexCount:u.length,vertexStart:0,vertexCount:0,firstStart:0,index:0,topology:0}),this.computeNormals(),this}}class eA extends Ie{_instanceBuffer;_instanceData;_instanceCount=0;constructor(){super(),this.initBaseGeometry()}initBaseGeometry(){const e=new Float32Array([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0]),t=new Float32Array([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2]),r=new Uint16Array([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]);this.setIndices(r),this.setAttribute(V.position,e),this.setAttribute(V.uv,t),this.addSubGeometry({indexStart:0,indexCount:r.length,vertexStart:0,vertexCount:e.length/3,firstStart:0,index:0,topology:0})}setPositions(e){const t=e instanceof Float32Array?e:new Float32Array(e),i=t.length/3-1;if(i<=0)return console.warn("FatLineGeometry: Need at least 2 points"),this;const a=new Float32Array(i*16);for(let o=0;o<i;o++){const n=o*3,l=(o+1)*3;a[o*16+0]=t[n+0],a[o*16+1]=t[n+1],a[o*16+2]=t[n+2],a[o*16+3]=0,a[o*16+4]=t[l+0],a[o*16+5]=t[l+1],a[o*16+6]=t[l+2],a[o*16+7]=0,a[o*16+8]=1,a[o*16+9]=1,a[o*16+10]=1,a[o*16+11]=0,a[o*16+12]=1,a[o*16+13]=1,a[o*16+14]=1,a[o*16+15]=0}return this._instanceData=a,this._instanceCount=i,this.computeBoundingBox(t),this}setColors(e){const t=e instanceof Float32Array?e:new Float32Array(e);if(!this._instanceData)return console.warn("FatLineGeometry: Must call setPositions() before setColors()"),this;const i=t.length/3-1;if(i!==this._instanceCount)return console.warn("FatLineGeometry: Color array length doesn't match segment count"),this;for(let a=0;a<i;a++){const o=a*3,n=(a+1)*3;this._instanceData[a*16+8]=t[o+0],this._instanceData[a*16+9]=t[o+1],this._instanceData[a*16+10]=t[o+2],this._instanceData[a*16+12]=t[n+0],this._instanceData[a*16+13]=t[n+1],this._instanceData[a*16+14]=t[n+2]}return this}computeBoundingBox(e){const t=new d(1/0,1/0,1/0),r=new d(-1/0,-1/0,-1/0);for(let a=0;a<e.length;a+=3){const o=e[a],n=e[a+1],l=e[a+2];t.x=Math.min(t.x,o),t.y=Math.min(t.y,n),t.z=Math.min(t.z,l),r.x=Math.max(r.x,o),r.y=Math.max(r.y,n),r.z=Math.max(r.z,l)}const i=d.sub(r,t);this.bounds=new Fe(d.ZERO.clone(),i),this.bounds.setFromMinMax(t,r)}get instanceData(){return this._instanceData}get instanceCount(){return this._instanceCount}get instanceBuffer(){return!this._instanceBuffer&&this._instanceData&&(this._instanceBuffer=new Be(this._instanceData.byteLength),this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply()),this._instanceBuffer}updateInstanceBuffer(){this._instanceBuffer&&this._instanceData&&(this._instanceBuffer.setFloat32Array("",this._instanceData),this._instanceBuffer.apply())}}class tA{name;offset;size;arrayStride;stepMode;attributes}class rA{name;format;offset;shaderLocation;stride}var Yf=(s=>(s[s.position=3]="position",s[s.normal=3]="normal",s[s.TANGENT=4]="TANGENT",s[s.uv=2]="uv",s[s.TEXCOORD_1=2]="TEXCOORD_1",s[s.color=4]="color",s[s.joints0=4]="joints0",s[s.weights0=4]="weights0",s[s.joints1=4]="joints1",s[s.weights1=4]="weights1",s[s.vIndex=1]="vIndex",s[s.weight=1]="weight",s[s.a_morphPositions_0=3]="a_morphPositions_0",s))(Yf||{});class iA{get data(){return null}entity}class Xf{min=0;max=0;set(e,t){return this.max=t,this.min=e,this}copy(e){return this.max=e.max,this.min=e.min,this}isInterestRange(e){return!(this.max>e.min||e.max<this.min)}}class Hf{_spaceDesc;getRange(e){return this._spaceDesc[e]}initSpace(e){this._spaceDesc={};for(let t of e)(this._spaceDesc[t]=new Xf).set(-Number.MAX_VALUE,Number.MAX_VALUE);return this}isContain(e,t){let r=this._spaceDesc[e];return t>=r.min&&t<r.max}isInterestRange(e,t){let r=this._spaceDesc[e];return r?t.isInterestRange(r):!1}splitSpace(e,t,r){let i=this._spaceDesc[e];return t?i.max=r:i.min=r,this}copySpace(e){for(let t in e._spaceDesc){let r=e._spaceDesc[t];this._spaceDesc[t].copy(r)}return this}}class Ka{static MaxEntityCountInLeaf=4;static MaxLayer=10;static ClearLeafLayer=Ka.MaxLayer-4}class qa{static UUID=0;uuid="0";constructor(){this.uuid=(qa.UUID++).toString()}}class aA{map={};_count=0;get count(){return this._count}push(e){return this.map[e.uuid]?!1:(this.map[e.uuid]=e,this._count++,!0)}remove(e){return this.map[e]?(delete this.map[e],this._count--,!0):!1}}class ui extends qa{_dimensionIndex=0;_dimensions;_dimension;_left;_right;_space;_parent;_entities;layer;get dimension(){return this._dimension}constructor(e=0){super(),this.layer=e,ui.nodeCount++}initNode(e,t,r){return this._dimensions=t,this._dimensionIndex=r,this._dimension=t[r],this._space=new Hf().initSpace(t),e&&this._space.copySpace(e._space),this._parent=e,this._entities=new aA,this}updateEntity(e){if(e.isInNode(this,this._dimension)&&(e.attachTreeNode(this),this.autoSplit(),this._left&&this._right)){let t=(this._dimensionIndex+1)%this._dimensions.length,r=this._dimensions[t];e.isInNode(this._right,r)?this._right.updateEntity(e):e.isInNode(this._left,r)&&this._left.updateEntity(e)}}buildRoot(e){for(const t of e)t.entity.attachTreeNode(this);this.autoSplit()}_splitEntityList=[];autoSplit(){if(this._entities.count>Ka.MaxEntityCountInLeaf&&!this._right&&!this._left&&this.layer<Ka.MaxLayer){let e=this._splitEntityList,t=(this._dimensionIndex+1)%this._dimensions.length,r=this._dimensions[t],i=0;for(const a in this._entities.map){let o=this._entities.map[a];i+=o.centerValue(r),e.push(o)}i/=this._entities.count,this._left=new ui(this.layer+1),this._right=new ui(this.layer+1),this._left.initNode(this,this._dimensions,t),this._right.initNode(this,this._dimensions,t),this._left.setSpace(!0,i),this._right.setSpace(!1,i);for(let a of e)a.isInNode(this._right,r)?a.attachTreeNode(this._right):a.isInNode(this._left,r)&&a.attachTreeNode(this._left)}this._left&&this._left.autoSplit(),this._right&&this._right.autoSplit()}setSpace(e,t){return this._parent&&this._space.splitSpace(this._dimension,e,t),this}isEmpty(){return this._left==null&&this._right==null&&this._entities.count==0}pushEntity(e){return this._entities.push(e)}removeEntity(e){return this._entities.remove(e.uuid)}static nodeCount=0;autoClear(){let e=this;for(;e&&e.layer>Ka.ClearLeafLayer&&e.clearLeaf();)e=e._parent}clearLeaf(){let e=!this._left&&!this._right,t=!e&&this._left.isEmpty()&&this._right.isEmpty();return t&&(this._left=this._right=null,ui.nodeCount-=2),e||t}isContain(e){return this._space.isContain(this._dimension,e)}static rangeBox=new Fe(new d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),new d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE));nodeIntersectsBox(e){let t=this._space.getRange("x"),r=this._space.getRange("y"),i=this._space.getRange("z"),a=ui.rangeBox;return a.min.set(t.min,r.min,i.min),a.max.set(t.max,r.max,i.max),a.intersectsBox(e)}nodeIntersectsRay(e){let t=this._space.getRange("x"),r=this._space.getRange("y"),i=this._space.getRange("z"),a=ui.rangeBox;return a.min.set(t.min,r.min,i.min),a.max.set(t.max,r.max,i.max),!0}pointCast(e,t=0,r){if(r=r||[],this._entities.count>0){let i=this._entities.map;for(let a in i){let o=i[a],n=o.entityContainPoint(e);!n&&t>0&&(n=o.squareDistanceTo(e,this._dimensions)<=t),n&&r.push(o)}}this._left&&this._left.isContain(e[this._left.dimension])&&this._left.pointCast(e,t,r),this._right&&this._right.isContain(e[this._right.dimension])&&this._right.pointCast(e,t,r)}boxCast(e,t){if(t=t||[],this._entities.count>0){let r=this._entities.map;for(let i in r){let a=r[i];a.entityIntersectsBox(e)&&t.push(a)}}this._left&&this._left.nodeIntersectsBox(e)&&this._left.boxCast(e,t),this._right&&this._right.nodeIntersectsBox(e)&&this._right.boxCast(e,t)}pointIntersect=new d;rayCast(e,t,r){t=t||[],r=r||[];let i=this.pointIntersect;if(this._entities.count>0){let a=this._entities.map;for(let o in a){let n=a[o];n.entityIntersectsRay(e,i)&&(r.push(new d().copyFrom(i)),t.push(n))}}this._left&&this._left.nodeIntersectsRay(e)&&this._left.rayCast(e,t,r),this._right&&this._right.nodeIntersectsRay(e)&&this._right.rayCast(e,t,r)}}class sA extends qa{userData;node;constructor(e){super(),this.userData=e}centerValue(e){return 0}isInNode(e,t){return!1}entityContainPoint(e){return!1}squareDistanceTo(e,t){return Number.MAX_VALUE}entityIntersectsBox(e){return!1}entityIntersectsRay(e,t){return!1}attachTreeNode(e){return this.node&&this.detachTreeNode(),this.node=e,this.node.pushEntity(this)}detachTreeNode(){let e=this.node.removeEntity(this);return this.node=null,e}updateNode(e){let t=this.node;t&&this.detachTreeNode(),e.updateEntity(this),t&&t.autoClear()}}class St{minPosX=0;minPosY=0;maxPosX=0;maxPosY=0;testID=0;points;offsetPosition;static TINY=1e-6;constructor(){this.points=new Array,this.offsetPosition=new d(0,0,0,0),this.clear()}setAABox(e,t,r,i){this.minPosX=e-r/2-St.TINY,this.maxPosX=e+r/2+St.TINY,this.minPosY=t-i/2-St.TINY,this.maxPosY=t+i/2+St.TINY,this.offsetPosition.setTo(0,0,0)}setOffset(e){this.maxPosX+=e.x-this.offsetPosition.x,this.minPosX+=e.x-this.offsetPosition.x,this.minPosY+=e.z-this.offsetPosition.z,this.maxPosY+=e.z-this.offsetPosition.z,this.offsetPosition.copyFrom(e)}setContainRect(e,t,r,i){this.minPosX>e&&(this.minPosX=e),this.minPosY>t&&(this.minPosY=t),this.maxPosX<r&&(this.maxPosX=r),this.maxPosY<i&&(this.maxPosY=i)}clear(){var e=1e9;this.minPosX=this.minPosY=e,this.maxPosX=this.maxPosY=-e,this.points.length=0,this.testID=0,this.offsetPosition.setTo(0,0,0)}addPoint(e){this.points.indexOf(e)==-1&&(e.x<this.minPosX&&(this.minPosX=e.x-St.TINY),e.x>this.maxPosX&&(this.maxPosX=e.x+St.TINY),e.z<this.minPosY&&(this.minPosY=e.z-St.TINY),e.z>this.maxPosY&&(this.maxPosY=e.z+St.TINY),this.points.push(e))}clone(){var e=new St;return e.minPosX=this.minPosX,e.minPosY=this.minPosY,e.maxPosX=this.maxPosX,e.maxPosY=this.maxPosY,e}get radius(){return Math.sqrt((this.maxPosY-this.minPosY)*(this.maxPosY-this.minPosY)+(this.maxPosX-this.minPosX)*(this.maxPosX-this.minPosX))}get sideX(){return this.maxPosX-this.minPosX}get sideY(){return this.maxPosY-this.minPosY}get centreX(){return(this.maxPosX-this.minPosX)*.5+this.minPosX}get centreY(){return(this.maxPosY-this.minPosY)*.5+this.minPosY}overlapTest(e){return!(this.minPosY>=e.maxPosY||this.maxPosY<=e.minPosY||this.minPosX>=e.maxPosX||this.maxPosX<=e.minPosX)}isPointInside(e){return e.x>=this.minPosX&&e.x<=this.maxPosX&&e.z>=this.minPosY&&e.z<=this.maxPosY}isIntersectLineSegment(e,t,r,i){var a=!1,o=t-i,n=r-e,l=e*i-r*t,h=(-l-o*this.minPosX)/n;h<=this.maxPosY&&h>=this.minPosY&&(a=!0),h=(-l-o*this.maxPosX)/n,h<=this.maxPosY&&h>=this.minPosY&&(a=!0);var u=(-l-n*this.minPosY)/o;return u<=this.maxPosX&&u>=this.minPosX&&(a=!0),u=(-l-n*this.maxPosY)/o,u<=this.maxPosX&&u>=this.minPosX&&(a=!0),a}}class gi{static NUM_CHILDREN=4;childCellIndices;nodeIndices;aabb;points;constructor(e){this.childCellIndices=new Array,this.childCellIndices.length=gi.NUM_CHILDREN,this.nodeIndices=new Array,this.clear(),e?this.aabb=e.clone():this.aabb=new St}isLeaf(){return this.childCellIndices[0]==-1}clear(){for(var e=0;e<gi.NUM_CHILDREN;e++)this.childCellIndices[e]=-1;this.nodeIndices.splice(0,this.nodeIndices.length)}}class jf{_cells;_rootCell;_quadNodes;_aabb;_cellsToTest;_testID;constructor(){this._testID=0,this._cells=new Array,this._quadNodes=new Array,this._cellsToTest=new Array,this._aabb=new St}getQuadNode(e){return this._quadNodes[e]}clear(){this._cells.length=0,this._quadNodes.length=0}initNodes(e){this.clear();for(var t=0,r=e.length;t<r;)e[t].calcGlobalQuadAABB(),this._quadNodes.push(e[t]),t++}buildQuadTree(e,t){this._aabb.clear();for(var r of this._quadNodes)if(r.isTriangle)for(var i of r.aabb.points)this._aabb.addPoint(i);else this._aabb.setContainRect(r.aabb.minPosX,r.aabb.minPosY,r.aabb.maxPosX,r.aabb.maxPosY);this._cells.length=0,this._rootCell=new gi(this._aabb),this._cells.push(this._rootCell);for(var a=this._quadNodes.length,o=0;o<a;o++)this._cells[0].nodeIndices[o]=o;var n=new Array;n.push(0);for(var l,h,u;n.length!=0;)if(h=n.pop(),!(this._cells[h].nodeIndices.length<=e||this._cells[h].aabb.radius<t)){for(o=0;o<gi.NUM_CHILDREN;o++){this._cells[h].childCellIndices[o]=this._cells.length,n.push(this._cells.length),this._cells.push(new gi(this.createAABox(this._cells[h].aabb,o))),u=this._cells[this._cells.length-1],a=this._cells[h].nodeIndices.length;for(var c=0;c<a;c++)l=this._cells[h].nodeIndices[c],this.doesNodeIntersectCell(this._quadNodes[l],u)&&u.nodeIndices.push(l)}this._cells[h].nodeIndices.length=0}}createAABox(e,t){var r=e.centreX,i=e.centreY,a=e.sideX,o=e.sideY,n=new St;switch(t){case 0:n.setAABox(r+a/4,i+o/4,a/2,o/2);break;case 1:n.setAABox(r-a/4,i+o/4,a/2,o/2);break;case 2:n.setAABox(r-a/4,i-o/4,a/2,o/2);break;case 3:n.setAABox(r+a/4,i-o/4,a/2,o/2);break;default:n.setAABox(r+a/4,i-o/4,a/2,o/2);break}return n}doesNodeIntersectCell(e,t){var r=e.aabb;if(!r.overlapTest(t.aabb))return!1;if(!e.isTriangle)return!0;var i=r.points,a=i[0],o=i[1],n=i[2];if(t.aabb.isPointInside(a)||t.aabb.isPointInside(o)||t.aabb.isPointInside(n))return!0;var l=this.pointInTriangle(t.aabb.minPosX,t.aabb.minPosY,a,o,n)||this.pointInTriangle(t.aabb.minPosX,t.aabb.maxPosY,a,o,n)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.maxPosY,a,o,n)||this.pointInTriangle(t.aabb.maxPosX,t.aabb.minPosY,a,o,n);return l?!0:(l=t.aabb.isIntersectLineSegment(a.x,a.z,o.x,o.z)||t.aabb.isIntersectLineSegment(a.x,a.z,n.x,n.z)||t.aabb.isIntersectLineSegment(o.x,o.z,n.x,n.z),l)}getNodesIntersectingtAABox(e,t){if(this._cells.length==0)return 0;this._cellsToTest.length=0,this._cellsToTest.push(0),this.incrementTestCounter();for(var r,i,a,o,n=0;this._cellsToTest.length!=0;)if(r=this._cellsToTest.pop(),a=this._cells[r],!!t.overlapTest(a.aabb))if(a.isLeaf())for(i=a.nodeIndices.length,n=0;n<i;n++)o=this.getQuadNode(a.nodeIndices[n]).aabb,o.testID!=this._testID&&(o.testID=this._testID,t.overlapTest(o)&&e.push(a.nodeIndices[n]));else for(n=0;n<gi.NUM_CHILDREN;n++)this._cellsToTest.push(a.childCellIndices[n]);return e.length}pointInTriangle(e,t,r,i,a){var o=r,n=i,l=a,h=o.z-n.z,u=n.x-o.x,c=o.x*n.z-n.x*o.z,f=n.z-l.z,g=l.x-n.x,p=n.x*l.z-l.x*n.z,A=l.z-o.z,U=o.x-l.x,x=l.x*o.z-o.x*l.z,v=!1,S=h*e+u*t+c,C=f*e+g*t+p,_=A*e+U*t+x;const y=.01;return(S>=-y&&C>=-y&&_>=-y||S<=y&&C<=y&&_<=y)&&(v=!0),v}incrementTestCounter(){if(++this._testID,this._testID==0){for(var e=this._quadNodes.length,t=0;t<e;t++)this._quadNodes[t].aabb.testID=0;this._testID=1}}logDeep=0;logTree(e){if(!(e<0)){this.logDeep++;for(var t=this._cells[e],r="",i=0;i<this.logDeep-1;i++)r+="-|";console.log(r+"i="+e+" "+t.aabb.minPosX.toFixed(2)+" "+t.aabb.maxPosX.toFixed(2)+" "+t.aabb.minPosY.toFixed(2)+" "+t.aabb.maxPosY.toFixed(2));var a;for(a=0;a<t.nodeIndices.length;a++)if(t.nodeIndices[a]>=0){var o=this._quadNodes[t.nodeIndices[a]];console.log(r+" t="+t.nodeIndices[a]+" "+o.aabb.minPosX.toFixed(2)+" "+o.aabb.maxPosX.toFixed(2)+" "+o.aabb.minPosY.toFixed(2)+" "+o.aabb.maxPosY.toFixed(2))}for(a=0;a<t.childCellIndices.length;a++)t.childCellIndices[a]>=0&&this.logTree(t.childCellIndices[a]);this.logDeep--}}}class Kf{_maxNodesPerCell;_minCellSize;_quadTree;_collisionNodesIdx;_segBox;_collisionNodes;constructor(e=10,t=500){this._maxNodesPerCell=e,this._minCellSize=t,this._segBox=new St,this._collisionNodesIdx=new Array,this._collisionNodes=new Array}createQuadTree(e){this._quadTree=new jf,this._quadTree.initNodes(e),this._quadTree.buildQuadTree(this._maxNodesPerCell,this._minCellSize)}getNodesByAABB(e,t,r,i){this._segBox.clear(),this._segBox.maxPosX=r,this._segBox.maxPosY=i,this._segBox.minPosX=e,this._segBox.minPosY=t,this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var a,o=0;o<this._collisionNodesIdx.length;o++)a=this._quadTree.getQuadNode(this._collisionNodesIdx[o]),this._collisionNodes.push(a);return this._collisionNodes}getTriangleAtPoint(e,t=5){this._segBox.clear(),this._segBox.setAABox(e.x,e.z,1,1),this._collisionNodesIdx.length=0,this._collisionNodes.length=0,this._quadTree.getNodesIntersectingtAABox(this._collisionNodesIdx,this._segBox);for(var r=4294967295,i=0,a,o,n,l,h=0;h<this._collisionNodesIdx.length;h++)o=this._quadTree.getQuadNode(this._collisionNodesIdx[h]),l=o.aabb,d.pointInsideTriangle(e,l.points[0],l.points[1],l.points[2])&&(n=o,i=Math.abs(n.plane.distance(e)),!(i>t)&&(o==null||i<=r)&&(a=n,r=i));return a}}var bs=(s=>(s[s.MOUSE_LEFT=0]="MOUSE_LEFT",s[s.MOUSE_MID=1]="MOUSE_MID",s[s.MOUSE_RIGHT=2]="MOUSE_RIGHT",s))(bs||{});class oA extends $e{static LOADER_PROGRESS="loaderProgress";static LOADER_COMPLETE="loaderComplete"}class nA extends $e{static ADDED="added";static REMOVED="removed";static CHILD_ADD_EVENT="childAddEvent";static CHILD_REMOVED="childRemoved"}class lA extends $e{static SHOW="show";static HIDE="hide";static UPDATE="update"}class hA{static merge(e,t,r,i){let a=0,o=0;a=Math.max(e.width,a),a=Math.max(t.width,a),a=Math.max(r.width,a),a=Math.max(i.width,a),o=Math.max(e.height,o),o=Math.max(t.height,o),o=Math.max(r.height,o),o=Math.max(i.height,o);let n=new Ae(a,o,X.rgba8unorm),l=new ue(Lc);l.setSamplerTexture("textureR",e),l.setSamplerTexture("textureG",t),l.setSamplerTexture("textureB",r),l.setSamplerTexture("textureA",i),l.setStorageTexture("outTex",n),l.workerSizeX=Math.ceil(a/8),l.workerSizeY=Math.ceil(o/8);let h=F.beginCommandEncoder();return F.computeCommand(h,[l]),F.endCommandEncoder(h),n}}class qf{computeShader;setInputes(e,t,r){this.computeShader=new ue(rf(e,t,r,8,8,1));for(let i=0;i<t.length;i++)this.computeShader.setSamplerTexture(`source${i}Map`,t[i]);for(let i=0;i<r.length;i++)this.computeShader.setStorageTexture(`dest${i}Map`,r[i]);e&&this.computeShader.setSamplerTexture("colorMap",e),this.computeShader.workerSizeX=r[0].width/8,this.computeShader.workerSizeY=r[0].height/8,this.computeShader.workerSizeZ=1}}class $f{sourceShader;compute;needUpdate=!0;constructor(e,t){this.sourceShader=t,this.compute=new ue(e),this.init()}init(){}onUpdate(){this.onFrame&&this.onFrame(),this.onOnce&&this.needUpdate&&(this.needUpdate=!1,this.onFrame())}}class ed extends $f{constructor(e){super(Jc,e)}init(){let e=new Ae(256,256,X.rgba8unorm,!1,GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING);return this.compute.setStorageTexture("sssMap",e),this.sourceShader.setTexture("lutMap",e),e}onFrame(){this.compute.workerSizeX=256/8,this.compute.workerSizeY=256/8;let e=F.beginCommandEncoder();F.computeCommand(e,[this.compute]),F.endCommandEncoder(e)}}class uA{gpuBuffer;probes;memoryDo;_probeInfoList;initDataUniform(e){this.memoryDo=new jr,this.probes=e,this._probeInfoList=[],this.memoryDo.destroy(),this.memoryDo.allocation(e.length*17*4);for(let r=0;r<e.length;r++){var t=17;let i=this.memoryDo.allocation_node(t*4);this._probeInfoList.push(i);let a=e[r].transform.worldPosition;i.setArray(0,[a.x,a.y,a.z])}this.gpuBuffer=Q.device.createBuffer({size:this.memoryDo.shareDataBuffer.byteLength,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.STORAGE,label:"ProbeBuffer",mappedAtCreation:!1})}updateGPUBuffer(){const e=this.memoryDo.shareDataBuffer;let t=this.memoryDo.shareDataBuffer.byteLength,r=0;const i=5e3*64;for(;r<t;)Q.device.queue.writeBuffer(this.gpuBuffer,r,e,r,Math.floor(Math.min(i,t-r))),r+=i}}class cA extends Tr{constructor(e,t,r=0){super(),this.bufferType=tr.StructStorageGPUBuffer,this.createBufferByStruct(GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|r,e,t)}}class fA{static codeMax=`
|
|
11656
11630
|
@group(0) @binding(0) var inputTexture : texture_2d<f32>;
|
|
11657
11631
|
@group(0) @binding(1) var inputTextureSampler : sampler;
|
|
11658
11632
|
@group(0) @binding(2) var outputTexture : texture_storage_2d<rgba8unorm, write>;
|