@babylonjs/lite 1.35.0 → 1.36.0

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Zz=Object.defineProperty,b=(A,e,g)=>()=>{if(g)throw g[0];try{return A&&(e=A(A=0)),e}catch(I){throw g=[I],I}},H=(A,e)=>{let g={};for(var I in A)Zz(g,I,{get:A[I],enumerable:!0});return e||Zz(g,Symbol.toStringTag,{value:"Module"}),g};function S3A(A){BY=A}function R(A,...e){const g=new Error(BY?.(A,e)??`#${A}`);throw g.lite=e,g}var BY,rA=b((()=>{BY=null})),oA,Bi,Ag,$1,ni,E3,He,a3,Ao,Ai,ZA=b((()=>{oA=Float32Array,Bi=Float64Array,Ag=Uint32Array,$1=Int32Array,ni=Uint16Array,E3=Int16Array,He=Uint8Array,a3=Int8Array,Ao=Uint8ClampedArray,Ai=DataView}));function N3A(){return new oA(16)}function QI(){return(Xz??N3A)()}function nY(){return QI()}function G3A(A){Xz=A}var Xz,Ut=b((()=>{ZA()})),RA,dA,MA,yC,te=b((()=>{RA=globalThis.GPUTextureUsage,dA=globalThis.GPUBufferUsage,MA=globalThis.GPUShaderStage,yC=globalThis.GPUColorWrite}));function $z(A){const e=A.size;return"canvas"in e?e.canvas:e}function c3(A){return{_descriptor:A,_resolveSize:$z,_colorTexture:null,_colorView:null,_depthTexture:null,_depthView:null,_width:0,_height:0}}function Nt(A){const e=c3(A);return"surface"in A.size&&(hi(A),e._resolveSize=hi),e}function xI(A,e){if(A._eager){A._syncEager?.(e);return}eI(A);const g=A._descriptor,I=(A._resolveSize??$z)(g);A._width=I.width,A._height=I.height;const i=e._device;g.format&&(A._colorTexture=i.createTexture(sY(g,I,g.format,RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING|RA.COPY_SRC|RA.COPY_DST)),A._colorView=A._colorTexture.createView()),g.dFormat&&(A._depthTexture=i.createTexture(sY(g,I,g.dFormat,RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING)),A._depthView=A._depthTexture.createView())}function sY(A,e,g,I){return{label:A.lbl,size:e,format:g,sampleCount:A.samples,usage:I}}function eI(A){if(!A||A._eager&&!A._disposeAttachments)return;const e=A._colorTexture,g=A._depthTexture;if(A._colorTexture=A._depthTexture=null,A._colorView=A._depthView=null,A._width=A._height=0,A._disposeAttachments)A._disposeAttachments(e,g);else try{e?.destroy()}finally{A._ownsDepthTexture!==!1&&g?.destroy()}}function hi(A){const e=A.size;if("surface"in e){const g=e.scale;(!Number.isFinite(g)||g<=0)&&R(61,g);const I=e.surface.canvas;return{width:Math.floor(I.width*g)||1,height:Math.floor(I.height*g)||1}}return"canvas"in e?e.canvas:e}var MI=b((()=>{rA(),te()})),QY,EY,aY=b((()=>{QY="1.35.0",EY=`Babylon Lite v${QY}`}));function Mm(A){return"clientWidth"in A}function m3A(A){return A.endsWith("-srgb")?A:`${A}-srgb`}function F3A(A,e,g){const I=AZ(A,e,g);return A._surfaces.push(I),p3(I),l3(I),I}function AZ(A,e,g){const I=e.getContext("webgpu");I||R(62),Mm(e)&&e.setAttribute("data-engine",EY);const i=g?.format??navigator.gpu.getPreferredCanvasFormat(),C=g?.srgb?m3A(i):i,o=g?.alphaMode??"opaque";I.configure({device:A._device,format:i,alphaMode:o,viewFormats:[C]});const r=g?.msaaSamples===1?1:4,B=c3({lbl:"swapchain",format:C,samples:1,size:{width:0,height:0}});return B._eager=!0,{engine:A,canvas:e,format:C,msaaSamples:r,scRT:B,maxDevicePixelRatio:g?.maxDevicePixelRatio??1/0,_uniqueId:eZ++,_context:I,_configureFormat:i,_alphaMode:o,_renderingContexts:[]}}function l3(A){const e=A._context.getCurrentTexture(),g=A.scRT;g._colorTexture=e,g._colorView=e.createView({format:A.format}),g._width=e.width,g._height=e.height}function p3(A){const e=A.canvas;if(!Mm(e))return;const g=A._w??e.clientWidth,I=A._h??e.clientHeight;if(!(g>0&&I>0))return;const i=Math.min(globalThis.devicePixelRatio||1,A.maxDevicePixelRatio);cY(A,g*i|0,I*i|0)}function cY(A,e,g){const I=A.canvas,i=e|0,C=g|0;if(i>0&&C>0&&!(i===I.width&&C===I.height)){I.width=i,I.height=C,A.scRT._width=i,A.scRT._height=C;for(const o of A._renderingContexts)o._resize?.()}}function b3A(A){A===A.engine&&R(63),A._renderingContexts.length=0,A._ro?.disconnect(),A._context.unconfigure();const e=A.engine._surfaces,g=e.indexOf(A);g!==-1&&e.splice(g,1)}var eZ,zs=b((()=>{rA(),MI(),aY(),eZ=1})),k3A=H({MAT4_STORAGE_F64_BUILD_TAG:()=>lY,allocateF64Mat4:()=>gZ});function gZ(){return new Bi(16)}var lY,K3A=b((()=>{ZA(),lY="@@MAT4_STORAGE_F64@@",gZ[lY]=!0}));function IZ(A){if(!Number.isFinite(A)||A<1)throw new Error(`setMaxLights: expected positive integer, got ${A}`);Zg=A|0}var Zg,vt=b((()=>{Zg=16})),U3A=H({applyLightFoOffset:()=>L3A,getFloatingOriginOffset:()=>tZ,lightFoVersion:()=>v3A,wrapRenderableForFO:()=>Y3A});function tZ(A){const e=A.camera;if(!e)return{x:0,y:0,z:0};const g=e.worldMatrix;return{x:g[12],y:g[13],z:g[14]}}function v3A(A){const e=A.camera,g=e?e.worldMatrixVersion:-1,I=iZ??=new WeakMap;let i=I.get(A);return i?(i[0]!==e||i[1]!==g)&&(i[0]=e,i[1]=g,i[2]++):I.set(A,i=[e,g,0]),i[2]}function L3A(A,e){const g=e.camera?.worldMatrix;if(!g)return;const I=g[12],i=g[13],C=g[14];let o=0;for(const r of e.lights){if(o>=Zg)break;if(!r._writeLightUbo)continue;const B=4+o*16,n=A[B+3];if(n===0||n===2){const Q=r.worldMatrix;A[B]=Q[12]-I,A[B+1]=Q[13]-i,A[B+2]=Q[14]-C}o++}}function Y3A(A,e,g){let I=-1,i;return()=>{const C=e.camera,o=C?C.worldMatrixVersion:-1;(o!==I||C!==i)&&(g(),I=o,i=C),A()}}var iZ,CZ=b((()=>{vt(),iZ=null})),J3A=H({makePackMeshWorld:()=>H3A,packMat4IntoF32WithOffset:()=>pY});function pY(A,e,g,I,i,C,o){const r=e,B=I,n=g;A[n+0]=r[B+0],A[n+1]=r[B+1],A[n+2]=r[B+2],A[n+3]=r[B+3],A[n+4]=r[B+4],A[n+5]=r[B+5],A[n+6]=r[B+6],A[n+7]=r[B+7],A[n+8]=r[B+8],A[n+9]=r[B+9],A[n+10]=r[B+10],A[n+11]=r[B+11],A[n+12]=r[B+12]-i,A[n+13]=r[B+13]-C,A[n+14]=r[B+14]-o,A[n+15]=r[B+15]}function H3A(A){return(e,g,I,i)=>{const C=A.camera;if(!C){pY(e,g,I,i,0,0,0);return}const o=C.worldMatrix;pY(e,g,I,i,o[12],o[13],o[14])}}var x3A=b((()=>{})),T3A=H({createGpuFrameTimer:()=>q3A,destroyGpuFrameTimer:()=>V3A,gpuFrameTimerBegin:()=>P3A,gpuFrameTimerEnd:()=>O3A,gpuFrameTimerResolve:()=>j3A,gpuTimingSupportedFor:()=>oZ});function oZ(A){return A.features.has("timestamp-query")}function q3A(A){return oZ(A)?{device:A,markerPipeline:A.createComputePipeline({layout:"auto",compute:{module:A.createShaderModule({code:"@compute @workgroup_size(1) fn main() {}"}),entryPoint:"main"}}),querySet:A.createQuerySet({type:"timestamp",count:2}),resolveBuf:A.createBuffer({size:16,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),pool:[],lastMs:0,inFlight:0}:null}function P3A(A,e){const g=e.beginComputePass({timestampWrites:{querySet:A.querySet,beginningOfPassWriteIndex:0}});g.setPipeline(A.markerPipeline),g.dispatchWorkgroups(1),g.end()}function O3A(A,e){const g=e.beginComputePass({timestampWrites:{querySet:A.querySet,endOfPassWriteIndex:1}});g.setPipeline(A.markerPipeline),g.dispatchWorkgroups(1),g.end()}function j3A(A){if(A.inFlight>3)return;const e=A.device,g=A.pool.pop()??e.createBuffer({size:16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),I=e.createCommandEncoder();I.resolveQuerySet(A.querySet,0,2,A.resolveBuf,0),I.copyBufferToBuffer(A.resolveBuf,0,g,0,16),e.queue.submit([I.finish()]),A.inFlight++,g.mapAsync(GPUMapMode.READ).then(()=>{const i=new BigInt64Array(g.getMappedRange()),C=Number(i[1]-i[0])/1e6;C>=0&&C<5e3&&(A.lastMs=A.lastMs>0?A.lastMs*.8+C*.2:C),g.unmap(),A.pool.push(g),A.inFlight--},()=>{A.inFlight--})}function V3A(A){A.querySet.destroy(),A.resolveBuf.destroy();for(const e of A.pool)e.destroy();A.pool.length=0}var W3A=b((()=>{}));function Vi(){Yn=Yn+1|0}function z3A(A){return A._renderingContexts}function Z3A(A){if(!A||typeof A._kind!="string")throw new TypeError("Invalid RenderingContext: missing internal kind discriminator");return A._kind}function DY(A,e){return A._renderingContexts.indexOf(e)!==-1}function Ln(A,e){return A._renderingContexts.indexOf(e)!==-1?!1:(A._renderingContexts.push(e),!0)}function Zs(A,e){const g=A._renderingContexts,I=g.indexOf(e);return I===-1?!1:(g.splice(I,1),!0)}function X3A(A){const e=hC?.deviceFeatures;hC=A,hC.deviceFeatures=e}function rZ(){return hC?hC():{}}function BZ(A){return EZ.filter(e=>A.features.has(e))}function $3A(A){const e=hC??(()=>({}));e.deviceFeatures=A,hC=e}async function nZ(A,e){const g=await navigator.gpu.requestAdapter({powerPreference:"high-performance",...hC?hC():{}});g||R(50);const I=hC?.deviceFeatures?.(g,e)??BZ(g),i=await g.requestDevice({requiredFeatures:I,requiredLimits:e?.requiredLimits});console.log(`${EY} - WebGPU engine`);const C=!!e?.useHighPrecisionMatrix,o=!!e?.useFloatingOrigin;if(o&&!C&&R(51),C){const{allocateF64Mat4:c}=await Promise.resolve().then(()=>(K3A(),k3A));G3A(c)}let r,B,n,Q;if(o){const[{wrapRenderableForFO:c,lightFoVersion:l,applyLightFoOffset:p},{makePackMeshWorld:D}]=await Promise.all([Promise.resolve().then(()=>(CZ(),U3A)),Promise.resolve().then(()=>(x3A(),J3A))]);r=c,B=D,n=l,Q=p}const E={_device:i},a=[E];return Object.assign(E,{engine:E,surfaces:a,_surfaces:a,_device:i,_options:e,drawCallCount:0,gpuFrameTimeMs:0,useHighPrecisionMatrix:C,useFloatingOrigin:o,_animFrameId:0,_renderFn:null,_currentEncoder:void 0,_currentDelta:0,_cbs:[],_wrapRenderableForFO:r,_makePackMeshWorld:B,_lightFoVersion:n,_applyLightFoOffset:Q},AZ(E,A,e)),p3(E),l3(E),E}function uY(A){for(const e of A.surfaces)p3(e)}function AKA(A,e,g){cY(A,e,g)}function D3(A){const e=A.canvas;return{width:e.width,height:e.height}}function Rm(A){return new Promise(e=>{let g=!0,I=0;A._renderFn=i=>{const C=g?0:I>0?i-I:16.667;I=i,uY(A),sZ(A,C),g&&(g=!1,e()),A._renderFn&&(A._animFrameId=requestAnimationFrame(A._renderFn))},A._animFrameId=requestAnimationFrame(A._renderFn)})}function eKA(A){return A._device.queue.onSubmittedWorkDone()}function u3(A){A._animFrameId&&cancelAnimationFrame(A._animFrameId),A._animFrameId=0,A._renderFn=null,A._flushGpuRetirements?.(A)}function gKA(A,e,g=A.surfaces){if(g!==A.surfaces)for(let I=g.length;I--;)g[I].engine!==A&&R(52);sZ(A,e,g)}function sZ(A,e,g=A._surfaces){let I=0;for(let C=g.length;C--;)I+=g[C]._renderingContexts.length;if(!I)return A.drawCallCount=0,A._flushGpuRetirements?.(A);const i=A._device.createCommandEncoder({label:"frame"});A._currentEncoder=i,A._currentDelta=e;try{A._gpuTimerBegin?.(i),I=0;for(let o=0;o<g.length;o++){const r=g[o];r._capturePreFrame?.(r),l3(r);const B=r._renderingContexts;for(let n=0;n<B.length;n++){const Q=B[n];Q._update(),I+=Q._drawCallsPre+Q._record()}}const C=A._currentEncoder;for(let o=0;o<g.length;o++){const r=g[o];r._captureService?.(r,C)}A._gpuTimerEnd?.(C),A._cbs[0]=C.finish(),A._device.queue.submit(A._cbs),A._flushGpuRetirements?.(A),A.drawCallCount=I,A._gpuTimerResolve?.()}finally{A._currentEncoder=void 0}}function QZ(A){return A._device.features.has("timestamp-query")}function IKA(A,e){if(!e){A._gpuTimerWanted=!1,A.gpuFrameTimeMs=0,A._gpuTimerBegin=void 0,A._gpuTimerEnd=void 0,A._gpuTimerResolve=A._gpuTaskTimerResolve;return}QZ(A)&&(A._gpuTimerWanted=!0,Promise.resolve().then(()=>(W3A(),T3A)).then(({createGpuFrameTimer:g,gpuFrameTimerBegin:I,gpuFrameTimerEnd:i,gpuFrameTimerResolve:C})=>{A._gpuTimer===void 0&&(A._gpuTimer=g(A._device));const o=A._gpuTimer;o&&A._gpuTimerWanted&&(A._gpuTimerBegin=r=>I(o,r),A._gpuTimerEnd=r=>i(o,r),A._gpuTimerResolve=()=>{C(o),A.gpuFrameTimeMs=o.lastMs,A._gpuTaskTimerResolve?.()})}))}var Yn,hC,EZ,lt=b((()=>{rA(),Ut(),zs(),aY(),Yn=0,hC=null,EZ=["float32-filterable","texture-compression-astc","texture-compression-bc","texture-compression-etc2","texture-compression-unaligned","timestamp-query","primitive-index"]}));rA(),lt();var aZ=!1;function tKA(){aZ||(aZ=!0,$3A((A,e)=>{const g=BZ(A);for(const I of e?.requiredFeatures??[])A.features.has(I)||R(934,I),g.includes(I)||g.push(I);return g}))}function iKA(A,e){return tKA(),nZ(A,e)}function cZ(A){const e=A._gpuEvents,g=A._device;e._device!==g&&(e._device?.removeEventListener("uncapturederror",e._onError),e._device=g,g.addEventListener("uncapturederror",e._onError),g.lost.then(I=>{if(e._device===g)for(const i of e._lost)i(I)}))}function lZ(A){let e=A._gpuEvents;if(!e){const g=new Set;e=A._gpuEvents={_errors:g,_lost:new Set,_device:null,_onError:I=>{const i=I.error;for(const C of g)C(i)}},A._attachGpuEvents=cZ}return cZ(A),e}function CKA(A,e){const g=lZ(A);return g._errors.add(e),()=>{g._errors.delete(e)}}function oKA(A,e){const g=lZ(A);return g._lost.add(e),()=>{g._lost.delete(e)}}function pZ(A){return A._device.limits}function rKA(A,e){return A._device.features.has(e)}function _3(A){wC(A.splice(0))}function wC(A){for(const e of A)try{e()}catch(g){console.error("GPU resource retirement failed.",g)}}function et(A,e){A._flushGpuRetirements??=d3,(A._retirements??=[]).push(e)}function DZ(A,e){if(!e.length)return;const g=e.slice();et(A,()=>wC(g))}function d3(A){const e=A._retirements;if(!e)return;A._retirements=null;const g=A._retiring??=new Set;g.add(e),queueMicrotask(()=>{A._device.queue.onSubmittedWorkDone().then(()=>{g.delete(e),_3(e)}).catch(()=>{})})}async function BKA(A){await Promise.resolve();do{d3(A);const e=A._retiring,g=e?[...e]:[];await A._device.queue.onSubmittedWorkDone();for(const I of g)e.delete(I),_3(I)}while(A._retirements?.length||A._retiring?.size)}function uZ(A){const e=A._retirements,g=A._retiring;A._retirements=null,A._retiring=null,e&&_3(e),g?.forEach(_3)}var kI=b((()=>{}));lt(),kI();function nKA(A){uZ(A),u3(A);const e=A._surfaces;for(const g of e)g._renderingContexts.length=0,g._ro?.disconnect(),g._context.unconfigure();e.length=0;try{A._disposeManagedResources?.(),A._disposeStorageBuffers?.()}finally{A._device.destroy()}}function sKA(A){const e={useHighPrecisionMatrix:!1,useFloatingOrigin:!1,drawCallCount:0,gpuFrameTimeMs:0,_animFrameId:0,_renderFn:null,_currentDelta:0,_cbs:[],_renderingContexts:[]};e.engine=e;const g=[e];return e.surfaces=g,e._surfaces=g,e}function _Z(A,e,g){A._currentDelta=g,e._update()}function QKA(A,e,g,I=1e3/60){for(let i=0;i<g;i++)_Z(A,e,I)}function f3(A,e){e.hooks.size===0&&(A._gpuTaskTimerResolve===e.dispatch&&(A._gpuTaskTimerResolve=void 0),A._gpuTimerResolve===e.dispatch&&(A._gpuTimerResolve=void 0),h3?.get(A)===e&&h3.delete(A))}function y3(A,e,g,I){const i=e==="frame"?A._currentEncoder:null;e==="frame"&&!i&&R(53);const C=h3??=new WeakMap;let o=C.get(A);if(!o){const B=new Set,n=(E=A._currentEncoder,a=!0)=>{if(!(!E||o.lastDispatchedEncoder===E)){if(!a){for(const c of B)c.encoder===E&&(B.delete(c),c.cancel?.());f3(A,o);return}o.lastDispatchedEncoder=E;for(const c of B){if(c.encoder&&c.encoder!==E){B.delete(c),c.cancel?.();continue}c.encoder&&B.delete(c),c.run(E)}f3(A,o)}};o={hooks:B,dispatch:n,lastDispatchedEncoder:null},C.set(A,o);const Q=A._gpuTaskTimerResolve;A._gpuTaskTimerResolve=n,(!A._gpuTimerResolve||A._gpuTimerResolve===Q)&&(A._gpuTimerResolve=n)}const r={run:g,cancel:I,encoder:i};return o.hooks.add(r),i&&queueMicrotask(()=>{o.hooks.has(r)&&A._currentEncoder!==i&&(o.hooks.delete(r),I?.(),f3(A,o))}),()=>{o.hooks.delete(r)&&f3(A,o)}}var h3,_Y=b((()=>{rA(),h3=null})),EKA=H({createGpuTaskTimer:()=>aKA,installGpuTaskTimer:()=>cKA});function aKA(A){return A.features.has("timestamp-query")?{device:A,querySet:A.createQuerySet({type:"timestamp",count:128}),resolveBuffer:A.createBuffer({size:1024,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),readbackPool:[],pendingReadbacks:new Set,records:[],wrappedGraphs:[],patchedContextLists:[],patchedSurfaceLists:[],taskCapacity:MZ,currentEncoder:null,patchedEncoderMethods:null,activeTaskTiming:null,nextQueryIndex:0,nextTaskIndex:0,frameIndex:0,lastPublishedFrameIndex:0,droppedTaskCount:0,inFlight:0,skipFrame:!1,disposed:!1}:null}function cKA(A,e,g){lKA(A,e._surfaces);for(const C of e.surfaces)dZ(A,C);const i=y3(e,"persistent",C=>{A.currentEncoder===C&&hKA(A,g)});return()=>{DKA(A,i),RKA(A)}}function lKA(A,e){for(const I of A.patchedSurfaceLists)if(I.list===e)return;const g=e.push;e.push=(...I)=>{const i=g.apply(e,I);for(const C of I)dZ(A,C);return i},A.patchedSurfaceLists.push({list:e,push:g})}function dZ(A,e){const g=e._renderingContexts;pKA(A,g);for(const I of g){const i=yZ(I);i&&fZ(A,i)}}function pKA(A,e){for(const I of A.patchedContextLists)if(I.list===e)return;const g=e.push;e.push=(...I)=>{const i=g.apply(e,I);for(const C of I){const o=yZ(C);o&&fZ(A,o)}return i},A.patchedContextLists.push({list:e,push:g})}function fZ(A,e){for(const i of A.wrappedGraphs)if(i.graph===e)return;const g=e.execute,I=()=>_KA(A,e);e.execute=I,A.wrappedGraphs.push({graph:e,execute:g})}function DKA(A,e){for(const g of A.patchedSurfaceLists)g.list.push=g.push;A.patchedSurfaceLists.length=0;for(const g of A.patchedContextLists)g.list.push=g.push;A.patchedContextLists.length=0;for(const g of A.wrappedGraphs)g.graph.execute=g.execute;A.wrappedGraphs.length=0,dY(A),e()}function yZ(A){const e=A,g=e._frameGraph??e.frameGraph;return uKA(g)?g:null}function uKA(A){return typeof A=="object"&&A!==null&&"_tasks"in A&&"execute"in A}function _KA(A,e){let g=0;for(const I of e._tasks)I.executionEnabled!==!1&&(g+=dKA(A,I));return g}function dKA(A,e){const g=e.engine._currentEncoder;A.currentEncoder!==g&&fKA(A,g);const I=A.nextTaskIndex++;if(A.skipFrame)return hZ(e);const i={beginQueryIndex:-1,endQueryIndex:-1,passCount:0,conflicted:!1,dropped:!1};A.activeTaskTiming=i;try{const C=hZ(e);return i.passCount>0&&!i.conflicted&&!i.dropped&&A.records.push({index:I,name:e.name,beginQueryIndex:i.beginQueryIndex,endQueryIndex:i.endQueryIndex}),C}finally{A.activeTaskTiming=null}}function hZ(A){if(A.execute)return A.execute();let e=0;for(const g of A._passes)e+=g._execute();return e}function fKA(A,e){dY(A),A.currentEncoder=e,A.patchedEncoderMethods=yKA(A,e),A.records.length=0,A.nextQueryIndex=0,A.nextTaskIndex=0,A.droppedTaskCount=0,A.skipFrame=A.inFlight>hY}function yKA(A,e){const g=e.beginRenderPass.bind(e),I=e.beginComputePass.bind(e),i=Object.getOwnPropertyDescriptor(e,"beginRenderPass"),C=Object.getOwnPropertyDescriptor(e,"beginComputePass");return Reflect.set(e,"beginRenderPass",o=>g(wZ(A,o)),e)||R(54),Reflect.set(e,"beginComputePass",o=>I(wZ(A,o)),e)||(fY(e,"beginRenderPass",i),R(55)),{encoder:e,beginRenderPass:i,beginComputePass:C}}function wZ(A,e){const g=A.activeTaskTiming;if(!g||g.conflicted||g.dropped)return e;if(e?.timestampWrites!==void 0)return g.conflicted=!0,e;const I=A.taskCapacity*2;if(g.passCount===0)return A.nextQueryIndex+2>I?(g.dropped=!0,A.droppedTaskCount++,e):(g.beginQueryIndex=A.nextQueryIndex++,g.endQueryIndex=A.nextQueryIndex++,g.passCount++,{...e,timestampWrites:{querySet:A.querySet,beginningOfPassWriteIndex:g.beginQueryIndex,endOfPassWriteIndex:g.endQueryIndex}});if(A.nextQueryIndex>=I)return g.dropped=!0,A.droppedTaskCount++,e;g.endQueryIndex=A.nextQueryIndex++,g.passCount++;const i={querySet:A.querySet,endOfPassWriteIndex:g.endQueryIndex};return{...e,timestampWrites:i}}function dY(A){const e=A.patchedEncoderMethods;e&&(fY(e.encoder,"beginRenderPass",e.beginRenderPass),fY(e.encoder,"beginComputePass",e.beginComputePass)),A.currentEncoder=null,A.patchedEncoderMethods=null,A.activeTaskTiming=null}function fY(A,e,g){g?Object.defineProperty(A,e,g):Reflect.deleteProperty(A,e)}function hKA(A,e){if(A.disposed)return;A.frameIndex++;const g=A.records.slice(),I=g.length,i=A.nextQueryIndex,C=A.droppedTaskCount;if(A.records.length=0,A.nextQueryIndex=0,A.droppedTaskCount=0,dY(A),A.skipFrame||A.inFlight>hY)return;if(I===0){C>0&&yY(A,e,eo("available",!0,!0,A.frameIndex,[],C,0));return}const o=i*8,r=A.readbackPool.pop()??wKA(A),B=A.device.createCommandEncoder({label:"gpu-task-timing-resolve"});B.resolveQuerySet(A.querySet,0,i,A.resolveBuffer,0),B.copyBufferToBuffer(A.resolveBuffer,0,r,0,o),A.device.queue.submit([B.finish()]),A.inFlight++,A.pendingReadbacks.add(r),MKA(A,{buffer:r,byteLength:o,frameIndex:A.frameIndex,records:g,droppedTaskCount:C,publish:e})}function wKA(A){return A.device.createBuffer({size:A.taskCapacity*16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}async function MKA(A,e){const g=e.buffer;try{if(await Promise.resolve(),await g.mapAsync(GPUMapMode.READ,0,e.byteLength),A.disposed)return;const I=new BigUint64Array(g.getMappedRange(0,e.byteLength)),i=[];let C=null,o=null;for(const B of e.records){const n=I[B.beginQueryIndex],Q=I[B.endQueryIndex];Q>=n&&(i.push({index:B.index,name:B.name,durationMs:Number(Q-n)/1e6}),C=C===null||n<C?n:C,o=o===null||Q>o?Q:o)}const r=C===null||o===null?0:Number(o-C)/1e6;g.unmap(),A.pendingReadbacks.delete(g),A.readbackPool.push(g),A.inFlight--,yY(A,e.publish,eo("available",!0,!0,e.frameIndex,i,e.droppedTaskCount,r))}catch(I){if(A.disposed)return;A.pendingReadbacks.delete(g),A.inFlight--,g.destroy(),yY(A,e.publish,eo("error",!0,!0,e.frameIndex,[],e.droppedTaskCount,0,SKA(I)))}}function yY(A,e,g){g.frameIndex>A.lastPublishedFrameIndex&&(A.lastPublishedFrameIndex=g.frameIndex,e(g))}function RKA(A){if(!A.disposed){A.disposed=!0,A.querySet.destroy(),A.resolveBuffer.destroy();for(const e of A.readbackPool)e.destroy();for(const e of A.pendingReadbacks)e.destroy();A.readbackPool.length=0,A.pendingReadbacks.clear(),A.inFlight=0}}function SKA(A){return A instanceof Error?A.message:String(A)}var MZ,hY,NKA=b((()=>{rA(),_Y(),GZ(),MZ=64,hY=3}));function mI(A,e,g,I,i,C){const o=g[I],r=g[I+1],B=g[I+2],n=g[I+3],Q=g[I+4],E=g[I+5],a=g[I+6],c=g[I+7],l=g[I+8],p=g[I+9],D=g[I+10],u=g[I+11],_=g[I+12],d=g[I+13],y=g[I+14],h=g[I+15];let w=i[C],M=i[C+1],N=i[C+2],S=i[C+3];A[e]=o*w+Q*M+l*N+_*S,A[e+1]=r*w+E*M+p*N+d*S,A[e+2]=B*w+a*M+D*N+y*S,A[e+3]=n*w+c*M+u*N+h*S,w=i[C+4],M=i[C+5],N=i[C+6],S=i[C+7],A[e+4]=o*w+Q*M+l*N+_*S,A[e+5]=r*w+E*M+p*N+d*S,A[e+6]=B*w+a*M+D*N+y*S,A[e+7]=n*w+c*M+u*N+h*S,w=i[C+8],M=i[C+9],N=i[C+10],S=i[C+11],A[e+8]=o*w+Q*M+l*N+_*S,A[e+9]=r*w+E*M+p*N+d*S,A[e+10]=B*w+a*M+D*N+y*S,A[e+11]=n*w+c*M+u*N+h*S,w=i[C+12],M=i[C+13],N=i[C+14],S=i[C+15],A[e+12]=o*w+Q*M+l*N+_*S,A[e+13]=r*w+E*M+p*N+d*S,A[e+14]=B*w+a*M+D*N+y*S,A[e+15]=n*w+c*M+u*N+h*S}var T1=b((()=>{}));function RZ(A,e,g,I,i){const C=1/Math.tan(e*.5),o=i-I;A[0]=C/g,A[5]=C,A[10]=-I/o,A[11]=1,A[14]=i*I/o}var SZ=b((()=>{}));function ei(A){const e=A.worldMatrixVersion;if(A._viewVer===e)return A._viewCache;const g=A._viewCache,I=A.worldMatrix,i=A._useFloatingOrigin,C=i?0:I[12],o=i?0:I[13],r=i?0:I[14];return g[0]=I[0],g[1]=I[4],g[2]=I[8],g[3]=0,g[4]=I[1],g[5]=I[5],g[6]=I[9],g[7]=0,g[8]=I[2],g[9]=I[6],g[10]=I[10],g[11]=0,g[12]=-(I[0]*C+I[1]*o+I[2]*r),g[13]=-(I[4]*C+I[5]*o+I[6]*r),g[14]=-(I[8]*C+I[9]*o+I[10]*r),g[15]=1,A._viewVer=e,g}function GKA(A){w3=A}function Wi(A){return(A._projFov!==A.fov||A._projNear!==A.nearPlane||A._projFar!==A.farPlane)&&(A._projFov=A.fov,A._projNear=A.nearPlane,A._projFar=A.farPlane,A._projRev=(A._projRev??0)+1),A.worldMatrixVersion+(A._projRev??0)}function IC(A,e){const g=Wi(A);if(A._projVer===g&&A._projAspect===e)return A._projCache;const I=A._projCache;return w3!==null&&A.ortho?w3(A,e,I):RZ(I,A.fov,e,A.nearPlane,A.farPlane),A._projVer=g,A._projAspect=e,I}function si(A,e){const g=Wi(A);if(A._vpVer===g&&A._vpAspect===e)return A._vpCache;const I=A._vpCache;return mI(I,0,IC(A,e),0,ei(A),0),A._vpVer=g,A._vpAspect=e,I}function Jn(A){const e=A.worldMatrix;return{x:e[12],y:e[13],z:e[14]}}function wi(A,e,g){const I=A?.viewport;return e/g*(I?I.width/I.height:1)}function NZ(A,e,g,I){const i=e?.viewport;if(!i)return;const C=Math.floor(i.x*g),o=Math.floor((1-i.y-i.height)*I),r=Math.ceil((i.x+i.width)*g)-C,B=Math.ceil((1-i.y)*I)-o;A.setViewport(C,o,r,B,0,1),A.setScissorRect(C,o,r,B)}var w3,FI=b((()=>{T1(),SZ(),w3=null})),mKA=H({_measureRenderTaskOverdrawCost:()=>FKA});async function FKA(A,e,g){const I=A._device;I.features.has("timestamp-query")||R(141);const i=g?.repeats??9;if(!Number.isInteger(i)||i<1)throw new RangeError("overdraw probe: repeats must be a positive integer");const C=e._config.rt,o=e._config.depth??C;(e._config.depth?e._config.depth._eager===!0:e._config.depthClear===!1)&&R(142);const r=C._width,B=C._height;(!r||!B)&&R(143);const n=C._descriptor.format??e._targetSignature._colorFormat,Q=e._targetSignature._depthStencilFormat,E=C._descriptor.samples??e._targetSignature._sampleCount??1;(!n||!Q?.startsWith("depth"))&&R(144);const a=[],c={index:0};for(const S of[e._opaqueBindings,e._directBindings,e._transparentBindings]){for(const G of S){const m=G.renderable.mesh;m&&m.visible===!1||a.push(G)}S!==e._transparentBindings&&(c.index=a.length)}a.length===0&&R(145);const l=e._sceneBG;l||R(146);const p=e._config.cam??e.scene.camera??null,D=(()=>{const S=a.slice(0,c.index);if(!p||S.length<=1)return a;const G=ei(p),m=K=>{const U=K.renderable._worldCenter??(()=>{const Y=K.renderable.mesh?.worldMatrix;return Y?[Y[12],Y[13],Y[14]]:null})();return U?U[0]*G[2]+U[1]*G[6]+U[2]*G[10]+G[14]:0},k=S.map(K=>({b:K,z:m(K)}));return k.sort((K,U)=>K.z-U.z),[...k.map(K=>K.b),...a.slice(c.index)]})(),u=I.createTexture({label:"overdraw-probe-color",size:{width:r,height:B},format:n,sampleCount:E,usage:GPUTextureUsage.RENDER_ATTACHMENT}),_=I.createTexture({label:"overdraw-probe-depth",size:{width:r,height:B},format:Q,sampleCount:E,usage:GPUTextureUsage.RENDER_ATTACHMENT}),d=Q==="depth24plus-stencil8"||Q==="depth32float-stencil8",y=o._descriptor.depthClearValue??0,h=I.createQuerySet({type:"timestamp",count:i*6}),w=I.createBuffer({label:"overdraw-probe-resolve",size:i*6*8,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),M=I.createBuffer({label:"overdraw-probe-read",size:i*6*8,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),N=(S,G)=>{const m=p?.viewport;if(m){const K=Math.floor(m.x*r),U=Math.floor((1-m.y-m.height)*B),Y=Math.ceil((m.x+m.width)*r)-K,x=Math.ceil((1-m.y)*B)-U;S.setViewport(K,U,Y,x,0,1),S.setScissorRect(K,U,Y,x)}S.setBindGroup(0,l);let k=null;for(const K of G)K.pipeline!==k&&(S.setPipeline(K.pipeline),k=K.pipeline),K.draw(S,A)};try{const S=u.createView(),G=_.createView();for(let X=0;X<i;X++){const Z=I.createCommandEncoder({label:"overdraw-probe"}),AA={view:G,depthClearValue:y,depthLoadOp:"clear",depthStoreOp:"store",...d?{stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}:{}},z={view:S,loadOp:"clear",storeOp:"discard",clearValue:{r:0,g:0,b:0,a:0}},IA=Z.beginRenderPass({label:"overdraw-probe-a",colorAttachments:[z],depthStencilAttachment:AA,timestampWrites:{querySet:h,beginningOfPassWriteIndex:X*6,endOfPassWriteIndex:X*6+1}});N(IA,a),IA.end();const sA=Z.beginRenderPass({label:"overdraw-probe-b",colorAttachments:[z],depthStencilAttachment:{view:G,depthLoadOp:"load",depthStoreOp:"discard",...d?{stencilLoadOp:"load",stencilStoreOp:"discard"}:{}},timestampWrites:{querySet:h,beginningOfPassWriteIndex:X*6+2,endOfPassWriteIndex:X*6+3}});N(sA,a),sA.end();const DA=Z.beginRenderPass({label:"overdraw-probe-c",colorAttachments:[z],depthStencilAttachment:{...AA,depthStoreOp:"discard",...d?{stencilStoreOp:"discard"}:{}},timestampWrites:{querySet:h,beginningOfPassWriteIndex:X*6+4,endOfPassWriteIndex:X*6+5}});N(DA,D),DA.end(),X===i-1&&(Z.resolveQuerySet(h,0,i*6,w,0),Z.copyBufferToBuffer(w,0,M,0,i*6*8)),I.queue.submit([Z.finish()])}await M.mapAsync(GPUMapMode.READ);const m=new BigUint64Array(M.getMappedRange()),k=[],K=[],U=[];for(let X=0;X<i;X++){const Z=Number(m[X*6+1]-m[X*6])/1e6,AA=Number(m[X*6+3]-m[X*6+2])/1e6,z=Number(m[X*6+5]-m[X*6+4])/1e6;Z>0&&Z<1e3&&k.push(Z),AA>0&&AA<1e3&&K.push(AA),z>0&&z<1e3&&U.push(z)}M.unmap(),(!k.length||!K.length||!U.length)&&R(147);const Y=X=>{const Z=X.slice().sort((AA,z)=>AA-z);return Z[Z.length>>1]},x=+Y(k).toFixed(3),q=+Y(K).toFixed(3),j=+Y(U).toFixed(3);return{width:r,height:B,sampleCount:E,bindings:a.length,msAsIs:x,msVisibleOnly:q,overdrawMs:+(x-q).toFixed(3),ratio:q>0?+(x/q).toFixed(3):0,msFrontToBack:j,sortGainMs:+(x-j).toFixed(3),repeats:i}}finally{h.destroy(),w.destroy(),M.destroy(),u.destroy(),_.destroy()}}var bKA=b((()=>{rA(),FI()}));function M3(A){return A._device.features.has("timestamp-query")}function R3(A){if(!M3(A))return eo("unsupported",!1,!1,0,[],0,0);const e=A._gpuTaskTimingResult;return e||(A._gpuTaskTimerWanted?eo("pending",!0,!0,0,[],0,0):eo("disabled",!0,!1,0,[],0,0))}async function kKA(A,e){if(!e){A._gpuTaskTimerEpoch=(A._gpuTaskTimerEpoch??0)+1,A._gpuTaskTimerWanted=!1,A._gpuTaskTimerDisable?.(),A._gpuTaskTimerDisable=void 0,A._gpuTaskTimer=void 0;const o=M3(A);return A._gpuTaskTimingResult=eo(o?"disabled":"unsupported",o,!1,0,[],0,0),A._gpuTaskTimingResult}if(!M3(A))return A._gpuTaskTimerWanted=!1,A._gpuTaskTimingResult=eo("unsupported",!1,!1,0,[],0,0),A._gpuTaskTimingResult;if(A._gpuTaskTimerWanted)return R3(A);const g=(A._gpuTaskTimerEpoch??0)+1;A._gpuTaskTimerEpoch=g,A._gpuTaskTimerWanted=!0,A._gpuTaskTimingResult=eo("pending",!0,!0,0,[],0,0);const{createGpuTaskTimer:I,installGpuTaskTimer:i}=await Promise.resolve().then(()=>(NKA(),EKA));if(!A._gpuTaskTimerWanted||A._gpuTaskTimerEpoch!==g)return R3(A);A._gpuTaskTimer===void 0&&(A._gpuTaskTimer=I(A._device));const C=A._gpuTaskTimer;return C?(A._gpuTaskTimerDisable=i(C,A,o=>{A._gpuTaskTimerWanted&&A._gpuTaskTimerEpoch===g&&(A._gpuTaskTimingResult=o)}),R3(A)):(A._gpuTaskTimerWanted=!1,A._gpuTaskTimingResult=eo("unsupported",!1,!1,0,[],0,0),A._gpuTaskTimingResult)}async function KKA(A,e,g){const{_measureRenderTaskOverdrawCost:I}=await Promise.resolve().then(()=>(bKA(),mKA));return I(A,e,g)}function eo(A,e,g,I,i,C,o,r){return{status:A,supported:e,enabled:g,frameIndex:I,tasks:i,totalDurationMs:o,droppedTaskCount:C,error:r}}var GZ=b((()=>{}));zs();function UKA(A){if(!Mm(A.canvas)||typeof ResizeObserver>"u")return()=>{};A._ro?.disconnect();const e=A._ro=new ResizeObserver(([g])=>{A._w=Math.round(g.contentRect.width),A._h=Math.round(g.contentRect.height)});return e.observe(A.canvas),()=>{e.disconnect(),A._ro===e&&(A._ro=void 0,A._w=A._h=void 0)}}var vKA=H({createCapturePreFrame:()=>TKA,createCaptureService:()=>xKA});function LKA(A){return Math.ceil(A*4/256)*256}function YKA(A){const e=A._captureQueue;!e||e.length===0||A._swapchainCopySrc||(A._swapchainCopySrc=!0,A._context.configure({device:A.engine._device,format:A._configureFormat,alphaMode:A._alphaMode,usage:RA.RENDER_ATTACHMENT|RA.COPY_SRC,viewFormats:[A.format]}))}function JKA(A,e){const g=A._captureQueue;if(!g||g.length===0||!A._swapchainCopySrc)return;A._captureQueue=void 0;const I=A.scRT._colorTexture;if(!I){const B=new Error("captureScreenshot: no swapchain texture available");for(const n of g)n.reject(B);return}const i=A.scRT._width,C=A.scRT._height,o=LKA(i),r=A.engine._device.createBuffer({label:"screenshot-readback",size:o*C,usage:dA.COPY_DST|dA.MAP_READ});e.copyTextureToBuffer({texture:I},{buffer:r,bytesPerRow:o,rowsPerImage:C},{width:i,height:C,depthOrArrayLayers:1}),HKA({buffer:r,width:i,height:C,bytesPerRow:o,bgra:A.format.startsWith("bgra"),reqs:g})}async function HKA(A){const{buffer:e,width:g,height:I,bytesPerRow:i,bgra:C,reqs:o}=A;try{await Promise.resolve(),await e.mapAsync(GPUMapMode.READ);const r=new Uint8Array(e.getMappedRange()),B=new Uint8ClampedArray(g*I*4);for(let Q=0;Q<I;Q++){const E=Q*i,a=Q*g*4;for(let c=0;c<g;c++){const l=E+c*4,p=a+c*4;C?(B[p]=r[l+2],B[p+1]=r[l+1],B[p+2]=r[l]):(B[p]=r[l],B[p+1]=r[l+1],B[p+2]=r[l+2]),B[p+3]=255}}e.unmap(),e.destroy();const n={width:g,height:I,data:B};for(const Q of o)Q.resolve(n)}catch(r){try{e.destroy()}catch{}for(const B of o)B.reject(r)}}function xKA(){return JKA}function TKA(){return YKA}var qKA=b((()=>{te()}));function PKA(A){const e=new Promise((g,I)=>{(A._captureQueue??=[]).push({resolve:g,reject:I})});return A._captureService||Promise.resolve().then(()=>(qKA(),vKA)).then(({createCaptureService:g,createCapturePreFrame:I})=>{A._captureService??=g(),A._capturePreFrame??=I()}),e}function Sm(A,e){return Math.ceil(A/e)*e}var Nm=b((()=>{}));function dg(A,e,g,I){const i=A._device.createBuffer({label:I,size:Sm(Math.max(e.byteLength,4),4),usage:g|dA.COPY_DST,mappedAtCreation:!0});return new He(i.getMappedRange()).set(new He(e.buffer,e.byteOffset,e.byteLength)),i.unmap(),i}var yt=b((()=>{ZA(),te(),Nm()})),OKA=H({getCpuStorageRecoveryLimits:()=>jKA,rebuildCpuStorageBuffers:()=>VKA});function jKA(A){for(const e of A._storageBuffers??[])if(e._data){const g=A._device.limits;return{maxBufferSize:g.maxBufferSize,maxStorageBufferBindingSize:g.maxStorageBufferBindingSize,maxStorageBuffersPerShaderStage:g.maxStorageBuffersPerShaderStage}}}function VKA(A){for(const e of A._storageBuffers??[])e._destroyed||(e._buffer=e._data?dg(A,e._data,dA.STORAGE,e._label):null)}var WKA=b((()=>{te(),yt()}));function I1(A,e={},g=""){const I=A._device,i=wY??=new WeakMap;let C=i.get(I);C||i.set(I,C=new Map);let o=g;for(const B in MY){const n=B;o+=`:${e[n]??MY[n]}`}let r=C.get(o);return r||C.set(o,r=I.createSampler(e)),r}function zKA(A){wY?.delete(A._device)}var wY,S3,N3,MY,m1=b((()=>{wY=null,S3="nearest",N3="clamp-to-edge",MY={minFilter:S3,magFilter:S3,mipmapFilter:S3,addressModeU:N3,addressModeV:N3,addressModeW:N3,maxAnisotropy:1}}));function go(A,e={}){const g=e.compare,I=e.lodMinClamp??0,i=e.lodMaxClamp??32;return I1(A,e,g!==void 0||I!==0||i!==32?`${g??""}:${I}:${i}`:"")}var Gm=b((()=>{m1()}));function G3(){return mZ??=new WeakMap}var mZ,RY=b((()=>{mZ=null}));function Mi(A){const e=G3();e.set(A,(e.get(A)??0)+1)}var Lr=b((()=>{RY()}));function LI(A){Mi(A.texture)}var Gt=b((()=>{Lr()}));function FZ(A){return G3().get(A.texture)===0}function m3(A){return G3().get(A.texture)??0}var SY=b((()=>{RY()}));function bZ(A){return I1(A,kZ)}function Qi(A){return I1(A,KZ)}function F3(A){return I1(A,UZ)}var kZ,KZ,UZ,F1=b((()=>{m1(),kZ={magFilter:"nearest",minFilter:"nearest"},KZ={magFilter:"linear",minFilter:"linear"},UZ={magFilter:"linear",minFilter:"linear",mipmapFilter:"linear"}})),Yr=H({generateMipmaps:()=>Xs,recordMipmaps:()=>b3});function ZKA(){$s?.clear(),$s=null,mm=null,k3=null,Fm=null,K3=null}function XKA(A){const e=A._device;e!==K3&&(ZKA(),K3=e),mm??=e.createShaderModule({code:vZ}),k3??=Qi(A),Fm??=e.createBindGroupLayout({entries:[{binding:0,visibility:MA.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:MA.FRAGMENT,sampler:{}}]})}function $KA(A,e){const g=A._device;XKA(A),$s??=new Map;let I=$s.get(e);return I||(I=g.createRenderPipeline({layout:g.createPipelineLayout({bindGroupLayouts:[Fm]}),vertex:{module:mm,entryPoint:"vs"},fragment:{module:mm,entryPoint:"fs",targets:[{format:e}]},primitive:{topology:"triangle-list"}}),$s.set(e,I)),I}function Xs(A,e,g){const I=A._device,i=I.createCommandEncoder();b3(A,e,i,g),I.queue.submit([i.finish()])}function b3(A,e,g,I){if(e.mipLevelCount<=1)return;const i=A._device,C=$KA(A,e.format),o=I!=null?{dimension:"2d",baseArrayLayer:I,arrayLayerCount:1}:{};for(let r=1;r<e.mipLevelCount;r++){const B=e.createView({baseMipLevel:r-1,mipLevelCount:1,...o}),n=e.createView({baseMipLevel:r,mipLevelCount:1,...o}),Q=i.createBindGroup({layout:Fm,entries:[{binding:0,resource:B},{binding:1,resource:k3}]}),E=g.beginRenderPass({colorAttachments:[{view:n,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});E.setPipeline(C),E.setBindGroup(0,Q),E.draw(3),E.end()}}var vZ,$s,mm,k3,Fm,K3,Ri=b((()=>{te(),F1(),vZ="@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1),p*vec2f(.5,-.5)+.5);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}",$s=null,mm=null,k3=null,Fm=null,K3=null})),A4A=H({rebuildDynamicTexture2D:()=>e4A});async function e4A(A,e){const g=e._recoverySource;if(!g||g.kind!=="dynamic")return;const{width:I,height:i,format:C,levels:o,samplerDesc:r}=g,B=A._device.createTexture({size:{width:I,height:i},format:C,mipLevelCount:o,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});if(g.source)try{A._device.queue.copyExternalImageToTexture({source:g.source,flipY:g.flipY},{texture:B,premultipliedAlpha:g.premultipliedAlpha},[I,i]),o>1&&Xs(A,B)}catch{g.source=null}e.texture=B,e.view=B.createView(),e.sampler=go(A,r),e.width=I,e.height=i,LI(e)}var g4A=b((()=>{te(),Gt(),Gm(),Ri()})),NY=H({rebuildTexture2D:()=>I4A,settleRebuiltTextureOwnership:()=>t4A});async function I4A(A,e){const g=e._recoverySource;if(!g||FZ(e))return;U3??=new WeakMap;const I=U3.get(g);if(I?.device===A._device){I.tex!==e&&(await I.done,i4A(A,e,I.tex));return}const i=m3(e),C=C4A(A,e,g);if(U3.set(g,{device:A._device,tex:e,done:C}),await C,i>0){const o=A._deviceLostRecovery;o&&(o._pendingOwnership??=[]).push([e,i])}}function t4A(A){const e=A._pendingOwnership;if(A._pendingOwnership=void 0,!!e)for(const[g,I]of e)for(let i=m3(g);i<I;i++)LI(g)}function i4A(A,e,g){const I=LZ(A,e)??g.sampler;e.texture=g.texture,e.view=g.view,e.width=g.width,e.height=g.height,e.sampler=I}function LZ(A,e){const g=A._deviceLostRecovery?._samplerDescriptors,I=g?.get(e.sampler);if(!I)return;const i=go(A,I);return g.set(i,I),i}async function C4A(A,e,g){if(g.kind==="url"){const B=await o4A(A,g.url,g.opts);e.texture=B.texture,e.view=B.view,e.sampler=B.sampler,e.width=B.width,e.height=B.height,e._recoverySource=g;return}if(g.kind==="solid"){const B=A._device.createTexture({size:{width:1,height:1},format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST}),n=new He(g.rgba.map(Q=>Math.round(Q*255)));A._device.queue.writeTexture({texture:B},n,{bytesPerRow:4,rowsPerImage:1},{width:1,height:1}),e.texture=B,e.view=B.createView(),e.sampler=Qi(A),e.width=1,e.height=1;return}if(g.kind==="dynamic"){const{rebuildDynamicTexture2D:B}=await Promise.resolve().then(()=>(g4A(),A4A));await B(A,e);return}if(g.kind==="pixels"){const B=g.options,n=A._device.createTexture({size:{width:g.width,height:g.height},format:B.srgb?"rgba8unorm-srgb":"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST});A._device.queue.writeTexture({texture:n},g.data,{bytesPerRow:g.width*4,rowsPerImage:g.height},{width:g.width,height:g.height}),e.texture=n,e.view=n.createView(),e.sampler=go(A,{addressModeU:B.addressModeU??"clamp-to-edge",addressModeV:B.addressModeV??"clamp-to-edge",minFilter:B.minFilter??"nearest",magFilter:B.magFilter??"nearest"}),e.width=g.width,e.height=g.height;return}if(g.kind==="render"){const B=A._device.createTexture({size:{width:g.width,height:g.height},format:g.format,usage:RA.TEXTURE_BINDING|RA.RENDER_ATTACHMENT|RA.COPY_DST});e.texture=B,e.view=B.createView(),e.sampler=go(A,g.samplerDesc),e.width=g.width,e.height=g.height;return}if(g.kind==="external"){if(!g.bitmap)throw new Error("Cannot recover a released external-image texture");const B=A._device.createTexture({size:{width:g.width,height:g.height},format:g.format,mipLevelCount:g.levels,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});if(A._device.queue.copyExternalImageToTexture({source:g.bitmap,flipY:g.flipY},{texture:B,premultipliedAlpha:g.premultipliedAlpha},{width:g.width,height:g.height}),g.levels>1){const{generateMipmaps:n}=await Promise.resolve().then(()=>(Ri(),Yr));n(A,B)}e.texture=B,e.view=B.createView(),e.sampler=go(A,g.samplerDesc),e.width=g.width,e.height=g.height;return}const I=g.bitmap?.width??1,i=g.bitmap?.height??1,C=g.srgb?"rgba8unorm-srgb":"rgba8unorm",o=g.mipMaps?Math.floor(Math.log2(Math.max(I,i)))+1:1,r=A._device.createTexture({size:{width:I,height:i},format:C,mipLevelCount:o,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.COPY_SRC|RA.RENDER_ATTACHMENT});if(g.bitmap){if(A._device.queue.copyExternalImageToTexture({source:g.bitmap},{texture:r,premultipliedAlpha:!1},{width:I,height:i}),g.mipMaps&&o>1){const{generateMipmaps:B}=await Promise.resolve().then(()=>(Ri(),Yr));B(A,r)}}else A._device.queue.writeTexture({texture:r},g.fallback??new He([255,255,255,255]),{bytesPerRow:4},{width:1,height:1});e.texture=r,e.view=r.createView(),e.sampler=LZ(A,e)??go(A,{addressModeU:"repeat",addressModeV:"repeat",minFilter:"linear",magFilter:"linear",mipmapFilter:"linear",maxAnisotropy:4}),e.width=I,e.height=i}async function o4A(A,e,g){const I=g.mipMaps??!0,i=g.addressModeU??"repeat",C=g.addressModeV??"repeat",o=g.invertY??!0,r=g.srgb??!1,B=g.premultiplyAlpha??!1,n=r?"rgba8unorm-srgb":"rgba8unorm",Q=await(await fetch(e)).blob(),E=await createImageBitmap(Q,{premultiplyAlpha:B?"premultiply":"none",colorSpaceConversion:"none"}),a=E.width,c=E.height,l=I?Math.floor(Math.log2(Math.max(a,c)))+1:1,p=A._device.createTexture({size:{width:a,height:c},format:n,mipLevelCount:l,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});if(A._device.queue.copyExternalImageToTexture({source:E,flipY:o},{texture:p,premultipliedAlpha:B},{width:a,height:c}),E.close(),I&&l>1){const{generateMipmaps:y}=await Promise.resolve().then(()=>(Ri(),Yr));y(A,p)}const D=g.minFilter??"linear",u=g.magFilter??"linear",_=I?"linear":"nearest",d=go(A,{addressModeU:i,addressModeV:C,minFilter:D,magFilter:u,mipmapFilter:_,maxAnisotropy:D==="linear"&&u==="linear"&&_==="linear"?4:1});return{texture:p,view:p.createView(),sampler:d,width:a,height:c}}var U3,GY=b((()=>{ZA(),te(),Gm(),Gt(),SY(),F1(),U3=null})),r4A=H({runDeviceLostRecovery:()=>B4A});function YZ(){return Promise.resolve().then(()=>(WKA(),OKA))}async function B4A(A,e,g){const I=new Map;for(const Q of g)I.set(Q._kind,Q);const i=A._renderFn!==null;u3(A),s4A(A,I),uZ(A);const C=await Jr("requesting a replacement adapter",()=>navigator.gpu.requestAdapter({powerPreference:"high-performance",...rZ()}));C||R(47);const o=e._requiredFeatures.filter(Q=>!C.features.has(Q));o.length&&R(48,o.join(", "));const r=A._storageBuffers?.size?await YZ():void 0;A._device=await Jr("requesting a replacement device",()=>C.requestDevice({requiredFeatures:e._requiredFeatures,requiredLimits:{...A._options?.requiredLimits,...r?.getCpuStorageRecoveryLimits(A)}})),A._attachGpuEvents?.(A),await Jr("rebuilding engine storage buffers",async()=>{(r??(A._storageBuffers?.size?await YZ():void 0))?.rebuildCpuStorageBuffers(A)}),await Jr("reconfiguring rendering surfaces",()=>{for(const Q of A.surfaces){const E=Q._swapchainCopySrc?RA.RENDER_ATTACHMENT|RA.COPY_SRC:RA.RENDER_ATTACHMENT;Q._context.configure({device:A._device,format:Q._configureFormat,alphaMode:Q._alphaMode,usage:E,viewFormats:[Q.format]}),l3(Q)}}),await Jr("resizing rendering surfaces",()=>uY(A));const B=await n4A(A,e),n=Array.from(I.values()).sort((Q,E)=>(Q._recoverOrder??0)-(E._recoverOrder??0));try{for(const Q of n)await Jr(`running "${Q._kind}" recovery`,()=>Q._recover(A))}finally{B?.()}i&&await Jr("restarting rendering",()=>Rm(A))}async function n4A(A,e){const g=e._textures,I=[];for(const o of g){const r=o.deref();r?I.push(r):g.delete(o)}if(I.length===0)return;const{rebuildTexture2D:i,settleRebuiltTextureOwnership:C}=await Promise.resolve().then(()=>(GY(),NY));try{await Jr("rebuilding recoverable textures",async()=>{const o=(await Promise.allSettled(I.map(r=>i(A,r)))).find(r=>r.status==="rejected");if(o)throw o.reason})}catch(o){throw C(e),o}return()=>C(e)}function s4A(A,e){const g=new Set;for(const I of A.surfaces)for(const i of I._renderingContexts)e.has(i._kind)||g.add(i._kind);if(g.size)throw new Error(`Device-lost recovery cannot rebuild registered rendering contexts of kind: ${Array.from(g).sort().join(", ")}. Recovering around them would leave them bound to the lost device and crash the browser's renderer process on the next frame. Enable that kind's device-lost recovery before the device is lost, or unregister the context.`)}async function Jr(A,e){try{return await e()}catch(g){const I=g instanceof Error?g.message:String(g);throw new Error(`Device-lost recovery failed while ${A}: ${I}`,{cause:g})}}var Q4A=b((()=>{rA(),lt(),kI(),te(),zs()}));function E4A(A){return A._deviceLostRecovery??={_forceNextLoss:!1,_requiredFeatures:[],_armedDevice:null,_registrations:[],_samplerDescriptors:new WeakMap,_captureRefs:0,_meshCaptureRefs:0,_textures:new Set,_texturesPruneAt:64}}function v3(A,e){const g=E4A(A),I=g._registrations;I.length===0&&(g._requiredFeatures=Array.from(A._device.features)),I.some(C=>C._kind===e._kind)||e._enable?.(A),I.push(e),JZ(A,g);let i=!1;return{disable(){if(i)return;i=!0;const C=I.indexOf(e);C>=0&&I.splice(C,1),I.some(o=>o._kind===e._kind)||e._disable?.(A)}}}function a4A(A){const e=A._deviceLostRecovery;return!!e?._registrations.length&&(e._forceNextLoss=!0)}function JZ(A,e){const g=A._device;e._armedDevice===g||e._recovering||(e._armedDevice=g,g.lost.then(I=>{if(e._registrations.length===0||e._armedDevice!==g||I.reason==="destroyed"&&!e._forceNextLoss)return;e._forceNextLoss=!1,e._recovering=!0;const i=[...e._registrations];for(const C of i)C._onLost?.(I);Promise.resolve().then(()=>(Q4A(),r4A)).then(({runDeviceLostRecovery:C})=>C(A,e,i)).then(()=>{e._recovering=!1,JZ(A,e);for(const C of i)C._onRecovered?.()},C=>{e._recovering=!1;for(const o of i)o._onRecoveryFailed?.(C)})}))}rA();function c4A(A){a4A(A)||R(49),A._device.destroy()}function L3(A,e){const g={...A,...e};return mY?.(A,g),FY?.(A,g),g}function l4A(A){mY=A}function p4A(A){FY=A}function AQ(A,e,g={}){const I=A._device;bm||(bm=new WeakMap);let i=bm.get(I);i||(i=new Map,bm.set(I,i));const C=`${e}\0${g.mipMaps??!0}\0${g.addressModeU??"repeat"}\0${g.addressModeV??"repeat"}\0${g.minFilter??"linear"}\0${g.magFilter??"linear"}\0${g.invertY??!0}\0${g.srgb??!1}\0${g.premultiplyAlpha??!1}`,o=i.get(C);if(o)return o;const r=i,B=D4A(A,e,g);return r.set(C,B),B.catch(()=>r.delete(C)),B}async function D4A(A,e,g){const I=A._device,i=g.mipMaps??!0,C=g.addressModeU??"repeat",o=g.addressModeV??"repeat",r=g.invertY??!0,B=g.srgb??!1,n=g.premultiplyAlpha??!1,Q=B?"rgba8unorm-srgb":"rgba8unorm",E=await(await fetch(e)).blob(),a=await createImageBitmap(E,{premultiplyAlpha:n?"premultiply":"none",colorSpaceConversion:"none"}),c=a.width,l=a.height,p=i?Math.floor(Math.log2(Math.max(c,l)))+1:1,D=I.createTexture({size:{width:c,height:l},format:Q,mipLevelCount:p,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});if(I.queue.copyExternalImageToTexture({source:a,flipY:r},{texture:D,premultipliedAlpha:n},{width:c,height:l}),a.close(),i&&p>1){const{generateMipmaps:w}=await Promise.resolve().then(()=>(Ri(),Yr));w(A,D)}const u=g.minFilter??"linear",_=g.magFilter??"linear",d=i?"linear":"nearest",y=I1(A,{addressModeU:C,addressModeV:o,minFilter:u,magFilter:_,mipmapFilter:d,maxAnisotropy:u==="linear"&&_==="linear"&&d==="linear"?4:1}),h={texture:D,view:D.createView(),sampler:y,width:c,height:l};return A._dlr?.u(h,e,g),LI(h),h}var mY,FY,bm,MC=b((()=>{te(),Gt(),m1(),mY=null,FY=null,bm=null}));function u4A(A){bY=A}function HZ(A,e){const g=G3(),I=(g.get(A)??1)-1;return I<=0?(A.destroy(),e&&bY?.(e),g.set(A,0),!0):(g.set(A,I),!1)}var bY,Y3=b((()=>{RY(),bY=null}));rA(),MC(),Y3();var _4A=64,xZ=null;function TZ(A,e,g){e._recoverySource=g;const I=A._textures;if(I.size>=A._texturesPruneAt){for(const i of I)i.deref()||I.delete(i);A._texturesPruneAt=Math.max(_4A,I.size*2)}I.add(new WeakRef(e))}function qZ(A,e){const g=A._recoverySource;if(!g)return;const I=xZ?.get(g)?.deref();I&&TZ(I,e,g)}function d4A(A){const e=A._recoverySource;e?.kind==="external"&&(e.bitmap?.close(),e.bitmap=null)}function f4A(A){const e=A._deviceLostRecovery,g=new WeakRef(e),I=(i,C)=>{(xZ??=new WeakMap).set(C,g),TZ(e,i,C)};p4A(qZ),u4A(d4A),A._dlr={t:I,async x(i,C,o,r,B,n,Q,E,a){const c=await createImageBitmap(i,{premultiplyAlpha:E?"premultiply":"none",colorSpaceConversion:"none"});try{const l=await a(c);return I(l,{kind:"external",bitmap:c,width:C,height:o,format:r,levels:B,samplerDesc:n,flipY:Q,premultipliedAlpha:E}),l}catch(l){throw c.close(),l}},d:qZ,u(i,C,o){I(i,{kind:"url",url:C,opts:{...o}})},s(i,C,o,r,B){I(i,{kind:"solid",rgba:[C,o,r,B]})},b(i,C,o,r,B){I(i,{kind:"bitmap",bitmap:C,srgb:o,mipMaps:r,fallback:B})},p(i,C,o){I(i,{kind:"pixels",data:C.slice(0,i.width*i.height*4),width:i.width,height:i.height,options:{...o}})},r(i,C,o,r,B){I(i,{kind:"render",width:C,height:o,format:r,samplerDesc:B})},w(i,C,o,r,B,n,Q=0,E=B*4){const a=i._recoverySource;if(a?.kind!=="pixels")return;const c=new Uint8Array(C.buffer,C.byteOffset,C.byteLength),l=B*4;for(let p=0;p<n;p++){const D=Q+p*E,u=((r+p)*a.width+o)*4;a.data.set(c.subarray(D,D+l),u)}},m(i,C,o,r,B,n){A._deviceLostRecovery?._meshCaptureRefs&&(i._cpuUv2s=C??null,i._cpuTangents=o??null,i._cpuColors=r??null,i._cpuGpuIndices=B,i._cpuIndexFormat=n)},e(i,C,o){e._meshCaptureRefs&&(i._envRecoverySource={kind:"env",url:C,brdfUrl:o})},h(i,C,o){e._meshCaptureRefs&&(i._envRecoverySource={kind:"hdr",url:C,faceSize:o})}}}function PZ(A,e=!1){const g=A._deviceLostRecovery;g||R(46),g._captureRefs++,e&&g._meshCaptureRefs++,g._captureRefs===1&&f4A(A)}function OZ(A,e=!1){const g=A._deviceLostRecovery;!g||g._captureRefs===0||(g._captureRefs--,e&&g._meshCaptureRefs>0&&g._meshCaptureRefs--,g._captureRefs===0&&(A._dlr=void 0))}var Ei,Hr=b((()=>{Ei=class{_x;_y;_z;_onDirty;constructor(A,e,g,I){this._x=A,this._y=e,this._z=g,this._onDirty=I}get x(){return this._x}set x(A){this._x!==A&&(this._x=A,this._onDirty())}get y(){return this._y}set y(A){this._y!==A&&(this._y=A,this._onDirty())}get z(){return this._z}set z(A){this._z!==A&&(this._z=A,this._onDirty())}set(A,e,g){this._x=A,this._y=e,this._z=g,this._onDirty()}copyFrom(A){this.set(A.x,A.y,A.z)}toArray(A,e=0){A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z}}})),km,J3=b((()=>{km=class{_x;_y;_z;_w;_onDirty;_version=0;constructor(A,e,g,I,i){this._x=A,this._y=e,this._z=g,this._w=I,this._onDirty=i}get version(){return this._version}get x(){return this._x}set x(A){this._x!==A&&(this._x=A,this._version++,this._onDirty())}get y(){return this._y}set y(A){this._y!==A&&(this._y=A,this._version++,this._onDirty())}get z(){return this._z}set z(A){this._z!==A&&(this._z=A,this._version++,this._onDirty())}get w(){return this._w}set w(A){this._w!==A&&(this._w=A,this._version++,this._onDirty())}set(A,e,g,I){this._x=A,this._y=e,this._z=g,this._w=I,this._version++,this._onDirty()}copyFrom(A){this.set(A.x,A.y,A.z,A.w)}toArray(A,e=0){A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z,A[e+3]=this._w}}}));function RC(A,e,g,I,i,C,o,r,B,n,Q,E){const a=C*C,c=o*o,l=r*r,p=C*o,D=C*r,u=o*r,_=B*C,d=B*o,y=B*r;A[e]=(1-2*(c+l))*n,A[e+1]=2*(p+y)*n,A[e+2]=2*(D-d)*n,A[e+3]=0,A[e+4]=2*(p-y)*Q,A[e+5]=(1-2*(a+l))*Q,A[e+6]=2*(u+_)*Q,A[e+7]=0,A[e+8]=2*(D+d)*E,A[e+9]=2*(u-_)*E,A[e+10]=(1-2*(a+c))*E,A[e+11]=0,A[e+12]=g,A[e+13]=I,A[e+14]=i,A[e+15]=1}var Io=b((()=>{}));function Km(A,e){A[KY]=e}function kY(A){return A===null?null:A[KY]??null}function Hn(A){kY(A)?._invalidate()}function y4A(A){kY(A)?.markLocalDirty()}function jZ(A,e,g){const I=QI();return VZ(I,A,e,g),I}function VZ(A,e,g,I){e.x===0&&e.y===0&&e.z===0&&g.x===0&&g.y===0&&g.z===0&&g.w===1&&I.x===1&&I.y===1&&I.z===1?(A.fill(0),A[0]=A[5]=A[10]=A[15]=1):RC(A,0,e.x,e.y,e.z,g.x,g.y,g.z,g.w,I.x,I.y,I.z)}function eQ(A){let e=0,g=-1,I=null,i=null;const C=QI();let o=null,r=null;const B=[];function n(){i=null,e++;for(const a of B)a._invalidate()}function Q(){const a=o.worldMatrixVersion;a!==g&&(g=a,n())}const E={get parent(){return o},set parent(a){a!==o&&(r!==null&&r._removeChild(E),o=a,r=kY(a),r!==null&&r._addChild(E),g=-1,n())},markLocalDirty(){I=null,n()},getWorldMatrix(){if(r===null&&o!==null&&Q(),i!==null)return i;const a=I??=A();if(o!==null){const c=o.worldMatrix;mI(C,0,c,0,a,0),i=C}else i=a;return i},getWorldMatrixVersion(){return r===null&&o!==null&&Q(),e},_invalidate:n,_addChild(a){B.push(a)},_removeChild(a){const c=B.indexOf(a);c>=0&&B.splice(c,1)}};return E}var KY,Lo=b((()=>{T1(),Ut(),Io(),KY=Symbol("wmState")}));function H3(A,e,g){const I=Math.cos(A*.5),i=Math.sin(A*.5),C=Math.cos(e*.5),o=Math.sin(e*.5),r=Math.cos(g*.5),B=Math.sin(g*.5);return[i*C*r+I*o*B,I*o*r-i*C*B,I*C*B+i*o*r,I*C*r-i*o*B]}function WZ(A,e,g,I){const i=2*(A*g+I*e),C=Math.asin(Math.max(-1,Math.min(1,i)));return[Math.atan2(-(2*(e*g-I*A)),1-2*(A*A+e*e)),C,Math.atan2(-(2*(A*e-I*g)),1-2*(e*e+g*g))]}var x3=b((()=>{}));function UY(A){let e=0,g=0,I=0,i=-1;const C=()=>{if(A.version!==i){const r=WZ(A.x,A.y,A.z,A.w);e=r[0],g=r[1],I=r[2],i=A.version}},o=(r,B,n)=>{e=r,g=B,I=n;const[Q,E,a,c]=H3(r,B,n);A.set(Q,E,a,c),i=A.version};return{get x(){return C(),e},set x(r){C(),o(r,g,I)},get y(){return C(),g},set y(r){C(),o(e,r,I)},get z(){return C(),I},set z(r){C(),o(e,g,r)},set:o}}function h4A(A,e=0,g=0,I=0,i=0,C=0,o=0,r=1,B=1,n=1,Q=1){return zZ(A,null,e,g,I,i,C,o,r,B,n,Q)}function xn(A,e,g,I,i){const C=zZ(A,e,g?.x,g?.y,g?.z,I?.x,I?.y,I?.z,I?.w,i?.x,i?.y,i?.z);return C._localMatrixLocked=g?void 0:!0,C}function zZ(A,e,g=0,I=0,i=0,C=0,o=0,r=0,B=1,n=1,Q=1,E=1){const a=T3({name:A,children:[]},g,I,i,C,o,r,B,n,Q,E);return e&&(a._localMatrix=e),a}function T3(A,e=0,g=0,I=0,i=0,C=0,o=0,r=1,B=1,n=1,Q=1){let E;const a=eQ(()=>_._localMatrix?_._localMatrix:(E??=QI(),VZ(E,l,p,u),E)),c=()=>{_._localMatrixLocked||(_._localMatrix=void 0,a.markLocalDirty())},l=new Ei(e,g,I,c),p=new km(i,C,o,r,c),D=UY(p),u=new Ei(B,n,Q,c),_={...A,position:l,rotationQuaternion:p,rotation:D,scaling:u,get parent(){return a.parent},set parent(d){a.parent=d},get worldMatrix(){return a.getWorldMatrix()},get worldMatrixVersion(){return a.getWorldMatrixVersion()}};return Km(_,a),_}var SC=b((()=>{Hr(),J3(),Lo(),x3(),Ut()}));function Tn(A,e=0,g=0,I=0,i=0,C=0,o=0,r=1,B=1,n=1){const[Q,E,a,c]=H3(i,C,o),l=T3({children:[],...A},e,g,I,Q,E,a,c,r,B,n);return Object.defineProperties(l,{worldMatrix:{enumerable:!1},worldMatrixVersion:{enumerable:!1}}),l}function q3(A,e,g,I,i,C,o,r){const B=A._device,n=dg(A,e,dA.VERTEX),Q=dg(A,g,dA.VERTEX),E=dg(A,I,dA.INDEX);let a;i&&i.length>0?a=dg(A,i,dA.VERTEX):(a=B.createBuffer({size:e.length/3*8,usage:dA.VERTEX,mappedAtCreation:!0}),a.unmap());let c=null;C&&C.length>0&&(c=dg(A,C,dA.VERTEX));const l=o&&o.length>0?dg(A,o,dA.VERTEX):null,p=r&&r.length>0?dg(A,r,dA.VERTEX):null;return{positionBuffer:n,normalBuffer:Q,uvBuffer:a,uv2Buffer:c,tangentBuffer:l,colorBuffer:p,hasUv:!!i&&i.length>0,hasUv2:!!C&&C.length>0,hasTangent:!!o&&o.length>0,hasColor:!!r&&r.length>0,indexBuffer:E,indexCount:I.length,indexFormat:"uint32"}}var xr=b((()=>{te(),yt(),SC(),x3()}));function ZZ(A,e){const g=A.indexCount;A._drawRangeSource=e,Object.defineProperty(A,"indexCount",{enumerable:!0,configurable:!0,get:()=>A._drawRangeSource?.indexCount??g})}var XZ=b((()=>{}));function Lt(A,e,g){return A._device.createBuffer({label:g,size:Sm(e,16),usage:dA.UNIFORM|dA.COPY_DST})}var b1=b((()=>{te(),Nm()}));function n1(A){const e=A._device,g=$Z??=new WeakMap;let I=g.get(e);return I||(I=e.createBindGroupLayout({label:"scene",entries:[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,buffer:{type:"uniform"}}]}),g.set(e,I)),I}function vY(A){const e=A._blend?{format:A._format,blend:A._blend}:{format:A._format};return{label:A._label,layout:A._engine._device.createPipelineLayout({bindGroupLayouts:A._bgls}),vertex:{module:A._vertModule,entryPoint:"main",buffers:A._vertexBuffers},fragment:{module:A._fragModule,entryPoint:"main",targets:[e]},depthStencil:{format:A._depthStencilFormat??"depth24plus-stencil8",depthCompare:A._depthCompare??"greater-equal",depthWriteEnabled:A._depthWriteEnabled??!0},multisample:{count:A._msaaSamples},primitive:{topology:"triangle-list",cullMode:A._cullMode??"back",frontFace:"ccw"}}}var $Z,s1=b((()=>{te(),MI(),$Z=null}));function wI(A,e,g){const I=A._device,i=Lt(A,e.byteLength,g);try{I.queue.writeBuffer(i,0,e.buffer,e.byteOffset,e.byteLength)}catch(C){throw i.destroy(),C}return i}var zI=b((()=>{b1()}));function LY(){return 16+Zg*16*4}function AX(A){let e=0;for(const g of A)e+=g._lightVersion??0;return e}function YY(A,e){A.fill(0);let g=0;const I=4;for(const i of e){if(g>=Zg)break;i._writeLightUbo&&(i._writeLightUbo(A,I+g*16),g++)}JY[0]=g,A[0]=eX[0]}function P3(A,e){let g=e._lightGpuState;const I=LY();if(g&&g._byteSize===I)return g;const i=!g;g?._buffer.destroy();const C=new oA(I/4);return YY(C,e.lights),A._applyLightFoOffset?.(C,e),g={_buffer:wI(A,C),_scratch:C,_version:AX(e.lights)+(A._lightFoVersion?.(e)??0),_listVersion:e._lightListVersion??0,_lightCount:e.lights.length,_byteSize:I},e._lightGpuState=g,i&&e._disposables.push(()=>{e._lightGpuState?._buffer.destroy(),e._lightGpuState=void 0}),g}function w4A(A,e){const g=P3(A,e),I=AX(e.lights)+(A._lightFoVersion?.(e)??0),i=e._lightListVersion??0;return(I!==g._version||i!==g._listVersion||e.lights.length!==g._lightCount)&&(g._version=I,g._listVersion=i,g._lightCount=e.lights.length,YY(g._scratch,e.lights),A._applyLightFoOffset?.(g._scratch,e),A._device.queue.writeBuffer(g._buffer,0,g._scratch)),g._buffer}function M4A(A,e,g){YY(e,g.lights),A._applyLightFoOffset?.(e,g)}var JY,eX,HY=b((()=>{ZA(),vt(),zI(),JY=new Ag(1),eX=new oA(JY.buffer)})),O3=b((()=>{}));function Si(A){return HZ(A)}var qn=b((()=>{Y3()}));function Yo(A,e){return Math.floor(Math.log2(Math.max(A,e)))+1}function R4A(A,e,g){return Math.max(1,Math.floor(Math.log2(Math.max(A,e))-g)+1)}var to=b((()=>{}));function gX(A){const e=new He(A);for(let l=0;l<8;l++)if(e[l]!==IX[l])throw new Error("Invalid .env file: bad magic");let g=8;for(;g<e.length&&e[g]!==0;)g++;const I=new TextDecoder().decode(e.subarray(8,g));g++;const i=g,C=JSON.parse(I),o=C.width,r=Yo(o,o),B=C.irradiance,n=new oA(27),Q=["x","y","z","xx","yy","zz","yz","zx","xy"];for(let l=0;l<9;l++){const p=B[Q[l]];n[l*3]=p[0],n[l*3+1]=p[1],n[l*3+2]=p[2]}const E=C.specular.mipmaps,a=C.imageType||"image/png",c=[];for(const l of E){const p=i+l.position,D=A.slice(p,p+l.length);c.push(new Blob([D],{type:a}))}return{faceBlobs:c,irradianceSH:n,width:o,mipCount:r}}var IX,tX=b((()=>{ZA(),to(),IX=new He([134,22,135,150,246,214,150,54])}));function iX(){return{minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}}function S4A(A,e,g,I){const i=g-I,C=g+I,o=e===0?"minX":e===1?"minY":"minZ",r=e===0?"maxX":e===1?"maxY":"maxZ";i<A[o]&&(A[o]=i),C>A[r]&&(A[r]=C)}function CX(A,e){const g=e.boundMin,I=e.boundMax;if(!g||!I)return;if(e._expandWorldBounds!==void 0){e._expandWorldBounds(A,e);return}const i=e.worldMatrix,C=[(g[0]+I[0])*.5,(g[1]+I[1])*.5,(g[2]+I[2])*.5],o=[(I[0]-g[0])*.5,(I[1]-g[1])*.5,(I[2]-g[2])*.5];for(let r=0;r<3;r++){let B=i[12+r],n=0;for(let Q=0;Q<3;Q++){const E=i[Q*4+r];B+=E*C[Q],n+=Math.abs(E)*o[Q]}S4A(A,r,B,n)}}var oX=b((()=>{})),rX=H({computeSceneSize:()=>BX});function BX(A,e){const g=iX();for(const u of A.meshes)CX(g,u);const I=g.minX,i=g.minY,C=g.minZ,o=g.maxX,r=g.maxY,B=g.maxZ;if(!isFinite(I))return{groundSize:15,skyboxSize:e??20,rootPosition:[0,0,0]};const n=o-I,Q=r-i,E=B-C,a=Math.sqrt(n*n+Q*Q+E*E);let c=15,l=e??20;const p=A.camera;p&&"upperRadiusLimit"in p&&p.upperRadiusLimit&&(c=p.upperRadiusLimit*2,l=c),a>c&&(c=a*2,l=c),c*=1.1,l*=1.5;const D=[I+n*.5,i-1e-5,C+E*.5];return{groundSize:c,skyboxSize:l,rootPosition:D}}var xY=b((()=>{oX()}));function N4A(A,e){const g=e.fog;g&&(A[80]=g.mode,A[81]=g.start,A[82]=g.end,A[83]=g.density,A[84]=g.color[0],A[85]=g.color[1],A[86]=g.color[2])}function G4A(A,e){const g=e.clipPlane;g&&(A[88]=g[0],A[89]=g[1],A[90]=g[2],A[91]=g[3])}function m4A(A,e){A[36]=e._environmentRotation??0;const g=e._envTextures?.sphericalHarmonics;g&&A.set(g,40)}function j3(A,e){const g=A._sceneUboContributors??=[];g.includes(e)||g.push(e)}function TY(A){for(const e of A._frameGraph._tasks)e._sceneUboCacheKey&&(e._sceneUboCacheKey.length=0)}function F4A(A,e){A.fog=e,j3(A,N4A)}function b4A(A,e){A.clipPlane=e,j3(A,G4A)}function Um(A){j3(A,m4A)}var Pn=b((()=>{})),V3=H({decodeBrdfPng:()=>k4A,uploadCubemapRGBD:()=>K4A});function nX(A,e){A!==PY&&(PY=A,OY=A.createShaderModule({code:EX}),W3=null,z3=null);const g=e?z3:W3;if(g)return g;const I=A.createComputePipeline({layout:"auto",compute:{module:OY,entryPoint:"main",constants:{[qY]:e?1:0}}});return e?z3=I:W3=I,I}function sX(A,e,g,I){return A.createBindGroup({layout:e.getBindGroupLayout(0),entries:[{binding:0,resource:g},{binding:1,resource:I}]})}function QX(A,e,g,I,i){const C=A.beginComputePass();C.setPipeline(e),C.setBindGroup(0,g),C.dispatchWorkgroups(Math.ceil(I/8),Math.ceil(i/8)),C.end()}function k4A(A,e){const g=A._device,I=nX(g,!1),i=e.width,C=e.height,o=g.createTexture({size:{width:i,height:C},format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});g.queue.copyExternalImageToTexture({source:e,flipY:!1},{texture:o,premultipliedAlpha:!1},{width:i,height:C});const r=g.createTexture({size:{width:i,height:C},format:"rgba16float",usage:RA.TEXTURE_BINDING|RA.STORAGE_BINDING}),B=sX(g,I,o.createView(),r.createView()),n=g.createCommandEncoder();return QX(n,I,B,i,C),g.queue.submit([n.finish()]),o.destroy(),r}function K4A(A,e,g,I){const i=A._device,C=nX(i,!0),o=i.createTexture({size:{width:g,height:g,depthOrArrayLayers:6},format:"rgba16float",mipLevelCount:I,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.COPY_SRC|RA.RENDER_ATTACHMENT,dimension:"2d"});for(let r=0;r<I;r++){const B=Math.max(1,g>>r),n=i.createTexture({size:{width:B,height:B},format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT}),Q=i.createTexture({size:{width:B,height:B},format:"rgba16float",usage:RA.STORAGE_BINDING|RA.COPY_SRC}),E=sX(i,C,n.createView(),Q.createView());for(let a=0;a<6;a++){const c=r*6+a;if(c>=e.length)break;i.queue.copyExternalImageToTexture({source:e[c],flipY:!1},{texture:n,premultipliedAlpha:!1},{width:B,height:B});const l=i.createCommandEncoder();QX(l,C,E,B,B),l.copyTextureToTexture({texture:Q},{texture:o,origin:{x:0,y:0,z:a},mipLevel:r},{width:B,height:B}),i.queue.submit([l.finish()])}n.destroy(),Q.destroy()}return o}var qY,EX,PY,OY,W3,z3,Z3=b((()=>{te(),qY=0,EX=`@id(${qY})override f:bool=false;@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var o:texture_storage_2d<rgba16float,write>;@compute@workgroup_size(8,8)fn main(@builtin(global_invocation_id)g:vec3u){let d=textureDimensions(t);if(any(g.xy>=d)){return;}let c=textureLoad(t,vec2u(g.x,select(g.y,d.y-1u-g.y,f)),0);textureStore(o,g.xy,vec4f(pow(c.rgb,vec3f(2.2))/max(c.a,1.0/255.0),1));}`,PY=null,OY=null,W3=null,z3=null})),jY,aX=b((()=>{jY="struct e{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:e;struct d{@builtin(position) clipPos:vec4<f32>,@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@vertex fn main(@location(0) b:vec3<f32>)->d{var a:d;a.positionUVW=b;let c=(mesh.world*vec4<f32>(b,0.0)).xyz+scene.vEyePosition.xyz;a.positionW=c;a.clipPos=scene.viewProjection*vec4<f32>(c,1.0);return a;}"})),cX,U4A=b((()=>{cX="struct c{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32}@group(1) @binding(0) var<uniform> mesh:c;struct d{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:d)->@location(0) vec4<f32>{var a=vec4<f32>(mesh.skyOutputColor,1.0);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.positionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}"}));function Q1(A){return`${A._colorFormat??"-"}|${A._depthStencilFormat??"-"}|${A._depthCompare??""}|${A._sampleCount}`}var E1=b((()=>{})),lX,X3,VY,$3=b((()=>{lX="fn perturbNormal(vNormalW:vec3<f32>,positionW:vec3<f32>,uv:vec2<f32>,bumpScale:f32)->vec3<f32>{let normalSample=textureSample(bT,bS,uv).rgb*2.0-1.0;let N=normalize(vNormalW)*bumpScale;let dp1=dpdx(positionW);let dp2=-dpdy(positionW);let duv1=dpdx(uv);let duv2=-dpdy(uv);let dp2perp=cross(dp2,N);let dp1perp=cross(N,dp1);var tangent=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent=dp2perp*duv1.y+dp1perp*duv2.y;let det=max(dot(tangent,tangent),dot(bitangent,bitangent));let invmax=select(inverseSqrt(det),0.0,det==0.0);let cotangentFrame=mat3x3<f32>(tangent*invmax,bitangent*invmax,N);return normalize(cotangentFrame*normalSample);}",X3="fn dither(seed:vec2<f32>,varianceAmount:f32)->f32{let rand=fract(sin(dot(seed,vec2<f32>(12.9898,78.233)))*43758.5453);let normVariance=varianceAmount/255.0;return mix(-normVariance,normVariance,rand);}",VY="fn dither(a:vec2<f32>,b:f32)->f32{return 0.0;}"})),pX,v4A=b((()=>{pX="struct a{viewProjection:mat4x4<f32>,view:mat4x4<f32>,vEyePosition:vec4<f32>,envRotationY:f32,_envPad0:f32,_envPad1:f32,_envPad2:f32,vSphericalL00:vec4<f32>,vSphericalL1_1:vec4<f32>,vSphericalL10:vec4<f32>,vSphericalL11:vec4<f32>,vSphericalL2_2:vec4<f32>,vSphericalL2_1:vec4<f32>,vSphericalL20:vec4<f32>,vSphericalL21:vec4<f32>,vSphericalL22:vec4<f32>,vImageInfos:vec4<f32>,vFogInfos:vec4<f32>,vFogColor:vec4<f32>,clipPlane:vec4<f32>}@group(0) @binding(0) var<uniform> scene:a;"})),q1,tC=b((()=>{v4A(),O3(),q1=pX}));function vm(A,e,g){return A._device.createBindGroupLayout({label:e,entries:[{binding:0,visibility:g,buffer:{type:"uniform"}}]})}var Lm=b((()=>{})),DX=H({buildSolidSkyboxRenderable:()=>uX});function L4A(A,e){const g=new oA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),I=new ni([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return{posBuffer:dg(A,g,dA.VERTEX),idxBuffer:dg(A,I,dA.INDEX)}}function Y4A(){function A(e){const g=e._device;return gQ&&eK===g||(gQ=vm(e,"skybox-material",MA.VERTEX|MA.FRAGMENT)),gQ}return{getPipeline(e,g){const I=e._device;eK!==I&&(AK.clear(),gQ=null,eK=I);const i=Q1(g),C=AK.get(i);if(C)return C;const o=I.createShaderModule({code:q1+jY,label:"skybox-vert"}),r=I.createShaderModule({code:X3+cX,label:"skybox-frag"}),B=I.createRenderPipeline(vY({_label:"skybox-pipeline",_engine:e,_bgls:[n1(e),A(e)],_vertModule:o,_fragModule:r,_vertexBuffers:dX,_format:g._colorFormat,_depthStencilFormat:g._depthStencilFormat,_depthCompare:g._depthCompare,_msaaSamples:g._sampleCount,_depthWriteEnabled:!1}));return AK.set(i,B),B},createBindGroup(e,g,I){return e._device.createBindGroup({layout:A(e),entries:[{binding:0,resource:{buffer:g}}]})}}}function uX(A,e,g,I,i){const C=A.surface.engine,o=A.clearColor,r=L4A(C,g),B=Y4A(),n=J4A(C,I,i,[o.r,o.g,o.b]),Q=B.createBindGroup(C,n,e),E={order:0,isTransparent:!1,bind(a,c){return{renderable:E,pipeline:B.getPipeline(a,c),draw(l){return l.setBindGroup(1,Q),l.setVertexBuffer(0,r.posBuffer),l.setIndexBuffer(r.idxBuffer,"uint16"),l.drawIndexed(36),1}}}};return E._rebuild=()=>uX(A,e,g,I,i),E}function J4A(A,e,g,I){const i=new oA(_X/4);return i[0]=i[5]=i[10]=i[15]=1,i[12]=e[0],i[13]=e[1],i[14]=e[2],i[16]=g[0],i[17]=g[1],i[18]=g[2],i[20]=I[0],i[21]=I[1],i[22]=I[2],wI(A,i)}var _X,dX,AK,gQ,eK,fX=b((()=>{ZA(),te(),aX(),U4A(),s1(),E1(),$3(),tC(),yt(),zI(),Lm(),_X=96,dX=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],AK=new Map,gQ=null,eK=null})),yX,H4A=b((()=>{yX="struct g{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:g;struct h{@location(0) position:vec3<f32>,@location(1) normal:vec3<f32>,@location(2) uv:vec2<f32>}struct e{@builtin(position) clipPos:vec4<f32>,@location(0) vPositionW:vec3<f32>,@location(1) vNormalW:vec3<f32>,@location(2) vUV:vec2<f32>}@vertex fn main(c:h)->e{var a:e;let b=mesh.world;let d=b*vec4<f32>(c.position,1.0);a.vPositionW=d.xyz;a.clipPos=scene.viewProjection*d;let f=mat3x3<f32>(b[0].xyz,b[1].xyz,b[2].xyz);a.vNormalW=normalize(f*c.normal);a.vUV=c.uv;return a;}"})),hX,x4A=b((()=>{hX="struct o{world:mat4x4<f32>,primaryColor:vec3<f32>,alpha:f32,backgroundCenter:vec3<f32>,_pad:f32}@group(1) @binding(0) var<uniform> mesh:o;@group(1) @binding(1) var n:texture_2d<f32>;@group(1) @binding(2) var m:sampler;struct p{@location(0) vPositionW:vec3<f32>,@location(1) vNormalW:vec3<f32>,@location(2) vUV:vec2<f32>}@fragment fn main(b:p)->@location(0) vec4<f32>{let g=normalize(b.vNormalW);let c=textureSample(n,m,b.vUV);let h=c.rgb;let f=max(h,vec3<f32>(0.0));let i=mesh.primaryColor;let j=f*i;var e=mesh.alpha*c.a;let k=dot(g,normalize(scene.vEyePosition.xyz-mesh.backgroundCenter));const l:f32=0.1;let d=clamp(k/l,0.0,1.0);e*=d*d;var a=vec4<f32>(j,e);if (scene.vImageInfos.w>=0.0){a=applyImageProcessing(a);}a=vec4<f32>(a.rgb*a.a,a.a);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.vPositionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}"})),wX=H({buildGroundRenderable:()=>MX});async function MX(A,e,g,I,i,C,o=!0){const r=T4A(o,q1+RX+(o?X3:VY)+hX),B=q4A(A,e),n=P4A(A,g,I),Q=(await O4A(A,i,C)).createView(),E=Qi(A),a=r.createBindGroup(A,n,Q,E),c={order:200,isTransparent:!0,bind(l,p){return{renderable:c,pipeline:r.getPipeline(l,p),draw(D){return D.setBindGroup(1,a),D.setVertexBuffer(0,B.posBuffer),D.setVertexBuffer(1,B.normBuffer),D.setVertexBuffer(2,B.uvBuffer),D.setIndexBuffer(B.idxBuffer,"uint16"),D.drawIndexed(6),1}}}};return c._rebuild=()=>MX(A,e,g,I,i,void 0,o),c}function T4A(A,e){function g(I){const i=I._device;return IQ&&Ym===i||(IQ=i.createBindGroupLayout({label:"ground-material",entries:[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d"}},{binding:2,visibility:MA.FRAGMENT,sampler:{type:"filtering"}}]}),Ym=i),IQ}return{getPipeline(I,i){const C=I._device;Ym!==C&&(gK.clear(),IQ=null,Ym=C);const o=`${+A}|${Q1(i)}`,r=gK.get(o);if(r)return r;const B=C.createShaderModule({code:q1+yX,label:"ground-vert"}),n=C.createShaderModule({code:e,label:"ground-frag"}),Q=C.createRenderPipeline({label:"ground-pipeline",layout:C.createPipelineLayout({bindGroupLayouts:[n1(I),g(I)]}),vertex:{module:B,entryPoint:"main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]},{arrayStride:12,attributes:[{shaderLocation:1,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:2,offset:0,format:"float32x2"}]}]},fragment:{module:n,entryPoint:"main",targets:[{format:i._colorFormat,blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},depthStencil:{format:i._depthStencilFormat??"depth24plus-stencil8",depthCompare:i._depthCompare??"greater-equal",depthWriteEnabled:!1},multisample:{count:i._sampleCount},primitive:{topology:"triangle-list",cullMode:"back",frontFace:"ccw"}});return gK.set(o,Q),Q},createBindGroup(I,i,C,o){return I._device.createBindGroup({layout:g(I),entries:[{binding:0,resource:{buffer:i}},{binding:1,resource:C},{binding:2,resource:o}]})}}}function q4A(A,e){const g=e/2,I=new oA([-g,-g,0,g,-g,0,g,g,0,-g,g,0]),i=new oA([0,0,1,0,0,1,0,0,1,0,0,1]),C=new oA([0,0,1,0,1,1,0,1]),o=new ni([0,2,1,0,3,2]);return{posBuffer:dg(A,I,dA.VERTEX),normBuffer:dg(A,i,dA.VERTEX),uvBuffer:dg(A,C,dA.VERTEX),idxBuffer:dg(A,o,dA.INDEX)}}function P4A(A,e,g){const I=new oA(SX/4),i=2220446049250313e-31;return I[0]=I[15]=1,I[5]=I[10]=i,I[6]=-1,I[9]=1,I[12]=e[0],I[13]=e[1],I[14]=e[2],I[16]=g[0],I[17]=g[1],I[18]=g[2],I[19]=.9,I[20]=0,I[21]=0,I[22]=0,wI(A,I)}async function O4A(A,e,g){const I=A._device;if(!e){const o=I.createTexture({size:[1,1],format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST});return I.queue.writeTexture({texture:o},new He([255,255,255,255]),{bytesPerRow:4},[1,1]),o}const i=g?await g:await fetch(e).then(o=>o.blob()).then(o=>createImageBitmap(o,{premultiplyAlpha:"none"})),C=I.createTexture({size:[i.width,i.height],format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});return I.queue.copyExternalImageToTexture({source:i},{texture:C},[i.width,i.height]),i.close(),C}var RX,SX,gK,IQ,Ym,NX=b((()=>{ZA(),te(),F1(),zI(),s1(),E1(),H4A(),x4A(),yt(),tC(),$3(),RX="fn applyImageProcessing(result:vec4<f32>)->vec4<f32>{var rgb=result.rgb;rgb*=scene.vImageInfos.x;const tonemappingCalibration:f32=1.590579;rgb=1.0-exp2(-tonemappingCalibration*rgb);rgb=pow(rgb,vec3<f32>(1.0/2.2));rgb=clamp(rgb,vec3<f32>(0.0),vec3<f32>(1.0));let highContrast=rgb*rgb*(3.0-2.0*rgb);if(scene.vImageInfos.y<1.0){rgb=mix(vec3<f32>(0.5),rgb,scene.vImageInfos.y);}else{rgb=mix(rgb,highContrast,scene.vImageInfos.y-1.0);}rgb=max(rgb,vec3<f32>(0.0));return vec4<f32>(rgb,result.a);}",SX=96,gK=new Map,IQ=null,Ym=null}));function GX(A,e,g){function I(i){const C=i._device;xm!==C&&(Jm.clear(),Hm.clear(),xm=C);const o=Hm.get(A);if(o)return o;const r=C.createBindGroupLayout({label:`${A}-material`,entries:[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube"}},{binding:2,visibility:MA.FRAGMENT,sampler:{type:"filtering"}}]});return Hm.set(A,r),r}return{getPipeline(i,C){const o=i._device;xm!==o&&(Jm.clear(),Hm.clear(),xm=o);const r=`${g}|${Q1(C)}`,B=Jm.get(r);if(B)return B;const n=o.createShaderModule({code:e,label:`${A}-vert`}),Q=o.createShaderModule({code:g,label:`${A}-frag`}),E=o.createRenderPipeline(vY({_label:`${A}-pipeline`,_engine:i,_bgls:[n1(i),I(i)],_vertModule:n,_fragModule:Q,_vertexBuffers:mX,_format:C._colorFormat,_depthStencilFormat:C._depthStencilFormat,_depthCompare:C._depthCompare,_msaaSamples:C._sampleCount,_depthWriteEnabled:!1}));return Jm.set(r,E),E},createBindGroup(i,C,o,r){return i._device.createBindGroup({layout:I(i),entries:[{binding:0,resource:{buffer:C}},{binding:1,resource:o},{binding:2,resource:r}]})}}}var mX,Jm,Hm,xm,FX=b((()=>{te(),s1(),E1(),mX=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],Jm=new Map,Hm=new Map,xm=null})),bX,j4A=b((()=>{bX="struct e{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:e;struct d{@builtin(position) clipPos:vec4<f32>,@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@vertex fn main(@location(0) b:vec3<f32>)->d{var a:d;a.positionUVW=b;let c=(mesh.world*vec4<f32>(b,1.0)).xyz;a.positionW=c;a.clipPos=scene.viewProjection*vec4<f32>(c,1.0);return a;}"})),V4A=b((()=>{})),W4A=H({buildDdsSkyboxRenderable:()=>WY});function z4A(A,e){const g=new oA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),I=new ni([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return[dg(A,g,dA.VERTEX),dg(A,I,dA.INDEX)]}async function WY(A,e,g,I,i,C=!0){const o=A.surface.engine,[r,B]=z4A(o,e),{cubeView:n,sampler:Q}=await X4A(o,i??KX),E=await A._environmentSkyboxShaderComposer?.("struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,exposureLinear:f32,contrast:f32,_pad1:f32,_pad2:f32,_pad3:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var c:texture_cube<f32>;@group(1) @binding(2) var d:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:h)->@location(0) vec4<f32>{var e=normalize(b.positionUVW);var a=textureSampleLevel(c,d,e,0.0).rgb;a*=mesh.primaryColor;if (scene.vImageInfos.w>=0.0){a*=mesh.exposureLinear;a=1.0-exp2(-1.590579*a);a=pow(a,vec3<f32>(1.0/2.2));a=saturate(a);let f=a*a*(3.0-2.0*a);a=mix(a,f,mesh.contrast-1.0);a=a+vec3<f32>(dither(b.positionW.xy,0.5));a=max(a,vec3<f32>(0.0));}return vec4<f32>(a,1.0);}","dds")??"struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,exposureLinear:f32,contrast:f32,_pad1:f32,_pad2:f32,_pad3:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var c:texture_cube<f32>;@group(1) @binding(2) var d:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:h)->@location(0) vec4<f32>{var e=normalize(b.positionUVW);var a=textureSampleLevel(c,d,e,0.0).rgb;a*=mesh.primaryColor;if (scene.vImageInfos.w>=0.0){a*=mesh.exposureLinear;a=1.0-exp2(-1.590579*a);a=pow(a,vec3<f32>(1.0/2.2));a=saturate(a);let f=a*a*(3.0-2.0*a);a=mix(a,f,mesh.contrast-1.0);a=a+vec3<f32>(dither(b.positionW.xy,0.5));a=max(a,vec3<f32>(0.0));}return vec4<f32>(a,1.0);}",a=q1+(C?X3:VY)+E,c=GX(C?"skybox-dds":"skybox-dds0",q1+bX,a),l=Z4A(o,g,I,A.imageProcessing.exposure,A.imageProcessing.contrast),p=c.createBindGroup(o,l,n,Q),D={order:0,isTransparent:!1,bind(u,_){return{renderable:D,pipeline:c.getPipeline(u,_),draw(d){return d.setBindGroup(1,p),d.setVertexBuffer(0,r),d.setIndexBuffer(B,"uint16"),d.drawIndexed(36),1}}}};return D._rebuild=()=>WY(A,e,g,I,i,C),D}function Z4A(A,e,g,I,i){const C=new oA(kX/4);return C[0]=C[5]=C[10]=C[15]=1,C[12]=e[0],C[13]=e[1],C[14]=e[2],C[16]=g[0],C[17]=g[1],C[18]=g[2],C[19]=I,C[20]=i,wI(A,C)}async function X4A(A,e){const g=A._device,I=await(await fetch(e)).arrayBuffer(),i=new $1(I,0,32),C=i[3],o=Math.max(i[7],1),r=i[21]===808540228?148:128,B=new He(I,r),n=g.createTexture({size:[C,C,6],format:"rgba16float",mipLevelCount:o,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});let Q=0;for(let E=0;E<6;E++)for(let a=0;a<o;a++){const c=Math.max(C>>a,1);g.queue.writeTexture({texture:n,origin:{x:0,y:0,z:E},mipLevel:a},B.buffer,{offset:B.byteOffset+Q,bytesPerRow:c*8},{width:c,height:c}),Q+=c*c*8}return{cubeView:n.createView({dimension:"cube"}),sampler:I1(A,{magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",maxAnisotropy:4})}}var kX,KX,UX=b((()=>{ZA(),te(),m1(),yt(),zI(),$3(),tC(),FX(),j4A(),V4A(),kX=96,KX="https://assets.babylonjs.com/core/environments/backgroundSkybox.dds"})),$4A=b((()=>{})),vX=H({buildHdrSkyboxRenderable:()=>LX});function A9A(A,e){const g=new oA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),I=new ni([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return[dg(A,g,dA.VERTEX),dg(A,I,dA.INDEX)]}async function LX(A,e,g,I,i){const C=A.surface.engine,[o,r]=A9A(C,g),B=await A._environmentSkyboxShaderComposer?.("struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32,exposureLinear:f32,contrast:f32,_pad3:f32,_pad4:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var b:texture_cube<f32>;@group(1) @binding(2) var c:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(d:h)->@location(0) vec4<f32>{var e=normalize(d.positionUVW);var a=textureSampleLevel(b,c,e,0.0).rgb;a*=mesh.exposureLinear;a=pow(a,vec3<f32>(1.0/2.2));a=clamp(a,vec3<f32>(0.0),vec3<f32>(1.0));let f=a*a*(3.0-2.0*a);if (mesh.contrast<1.0){a=mix(vec3<f32>(0.5),a,mesh.contrast);} else{a=mix(a,f,mesh.contrast-1.0);}a=max(a,vec3<f32>(0.0));return vec4<f32>(a,1.0);}","hdr")??"struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32,exposureLinear:f32,contrast:f32,_pad3:f32,_pad4:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var b:texture_cube<f32>;@group(1) @binding(2) var c:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(d:h)->@location(0) vec4<f32>{var e=normalize(d.positionUVW);var a=textureSampleLevel(b,c,e,0.0).rgb;a*=mesh.exposureLinear;a=pow(a,vec3<f32>(1.0/2.2));a=clamp(a,vec3<f32>(0.0),vec3<f32>(1.0));let f=a*a*(3.0-2.0*a);if (mesh.contrast<1.0){a=mix(vec3<f32>(0.5),a,mesh.contrast);} else{a=mix(a,f,mesh.contrast-1.0);}a=max(a,vec3<f32>(0.0));return vec4<f32>(a,1.0);}",n=GX("skybox-hdr",q1+jY,B),Q=e9A(C,I,i,A.clearColor,A.imageProcessing.exposure,A.imageProcessing.contrast),E=n.createBindGroup(C,Q,e.specularCubeView,e.cubeSampler),a={order:0,isTransparent:!1,bind(c,l){return{renderable:a,pipeline:n.getPipeline(c,l),draw(p){return p.setBindGroup(1,E),p.setVertexBuffer(0,o),p.setIndexBuffer(r,"uint16"),p.drawIndexed(36),1}}}};return a._rebuild=()=>LX(A,e,g,I,i),a}function e9A(A,e,g,I,i,C){const o=new oA(YX/4);return o[0]=o[5]=o[10]=o[15]=1,o[12]=e[0],o[13]=e[1],o[14]=e[2],o[16]=g[0],o[17]=g[1],o[18]=g[2],o[20]=I.r,o[21]=I.g,o[22]=I.b,o[24]=i,o[25]=C,wI(A,o)}var YX,JX=b((()=>{ZA(),te(),FX(),aX(),$4A(),tC(),yt(),zI(),YX=112}));async function g9A(A,e,g){const I=A.surface.engine,i=fetch(e).then(w=>w.arrayBuffer()),C=IK(g.brdfUrl),{faceBlobs:o,irradianceSH:r,width:B,mipCount:n}=gX(await i),Q=await Promise.all(o.map(w=>createImageBitmap(w,{premultiplyAlpha:"none",colorSpaceConversion:"none"}))),E=await Promise.resolve().then(()=>(Z3(),V3)),a=E.uploadCubemapRGBD(I,Q,B,n);for(const w of Q)w.close();const c=await C,l=E.decodeBrdfPng(I,c);c.close();const p=tQ(a,l,r,.8,I);A._envTextures=p,Um(A),Mi(a),Mi(l),A._disposables.push(()=>{Si(a),Si(l)}),A.imageProcessing.toneMappingEnabled=!0,A.imageProcessing.exposure=.8,A.imageProcessing.contrast=1.2;const D=g?.groundTextureUrl,u=D?fetch(D).then(w=>w.blob()).then(w=>createImageBitmap(w,{premultiplyAlpha:"none"})):void 0,_=g?.skyboxUrl,d=_!=null&&_.toLowerCase().endsWith(".dds"),y=_!=null&&(_===e||_.toLowerCase().endsWith(".env")),h={skipSkybox:d||y||g?.skipSkybox,skipGround:g?.skipGround};return I._dlr?.e(A,e,g.brdfUrl),A._deferredBuilders.push(async()=>{const w=A.environmentPrimaryColor??[.08697355964132344,.08697355964132344,.2122208331110881],{groundSize:M,skyboxSize:N,rootPosition:S}=BX(A,g?.skyboxSize),G=N/2;if(!h.skipSkybox){const m=await Promise.resolve().then(()=>(fX(),DX));A._renderables.push(m.buildSolidSkyboxRenderable(A,p,G,S,w))}if(!h.skipGround){const m=await Promise.resolve().then(()=>(NX(),wX));A._renderables.push(await m.buildGroundRenderable(I,M,S,w,D,u))}if(d){const m=await Promise.resolve().then(()=>(UX(),W4A));A._renderables.push(await m.buildDdsSkyboxRenderable(A,G,S,w,_))}if(y){const m=await Promise.resolve().then(()=>(JX(),vX));A._renderables.push(await m.buildHdrSkyboxRenderable(A,p,G,S,w))}}),p}function HX(A){const e=.3333338747897695,g=.33333298856284405,I=1.4999984284682104,i=3.999982863580422,C=1.3333326611423701,o=.6666653397393608,r=1.999991431790211,B=new oA(36);for(let n=0;n<3;n++){const Q=A[n],E=A[3+n],a=A[6+n],c=A[9+n],l=A[12+n],p=A[15+n],D=A[18+n],u=A[21+n],_=A[24+n];B[n]=(c+l)*e+p*g,B[4+n]=E*I,B[8+n]=a*I,B[12+n]=Q*I,B[16+n]=_*i,B[20+n]=D*i,B[24+n]=p*C-(c+l)*o,B[28+n]=u*i,B[32+n]=(c-l)*r}return B}var zY=b((()=>{ZA(),Lr(),qn(),Tm(),tX(),xY(),Pn()}));async function IK(A){const e=await fetch(A);if(e.ok)try{return await createImageBitmap(await e.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"})}catch{}throw new Error(`BRDF LUT '${A}' is not an image (${e.status} ${e.headers.get("content-type")??""}).`)}function tQ(A,e,g,I,i,C){return{specularCube:A,specularCubeView:A.createView({dimension:"cube"}),brdfLut:e,brdfLutView:e.createView(),cubeSampler:F3(i),brdfSampler:Qi(i),irradianceSH:g,sphericalHarmonics:C??HX(g),lodGenerationScale:I}}var Tm=b((()=>{zY(),F1()}));function xX(A){const e=1/Math.PI,g=new oA(27);for(let I=0;I<3;I++){const i=I*9,C=A[i],o=A[i+1],r=A[i+2],B=A[i+3],n=A[i+4],Q=A[i+5],E=A[i+6],a=A[i+7],c=A[i+8];g[0+I]=B*1.02333*e,g[3+I]=o*1.02333*e,g[6+I]=r*1.02333*e,g[9+I]=(C*.886227-E*.247708+c*.429043)*e,g[12+I]=(C*.886227-E*.247708-c*.429043)*e,g[15+I]=(C*.886227+E*.495417)*e,g[18+I]=Q*.858086*e,g[21+I]=a*.858086*e,g[24+I]=n*.858086*e}return g}var TX=b((()=>{ZA()})),I9A=H({computeSHFromEquirect:()=>OX,parseRGBE:()=>qX});function qX(A){const e=new He(A);let g=0;function I(){let E="";for(;g<e.length;){const a=e[g++];if(a===10)break;a!==13&&(E+=String.fromCharCode(a))}return E}I().startsWith("#?")||R(199);let i="";for(;g<e.length;){const E=I();if(E==="")break;E.startsWith("FORMAT=")&&(i=E.slice(7))}i&&i!=="32-bit_rle_rgbe"&&R(200,i);const C=I(),o=C.match(/-Y\s+(\d+)\s+\+X\s+(\d+)/);o||R(201,C);const r=parseInt(o[1],10),B=parseInt(o[2],10),n=new oA(B*r*3),Q=new He(B*4);for(let E=0;E<r;E++)g=t9A(e,g,B,n,E*B*3,Q);return{width:B,height:r,data:n}}function t9A(A,e,g,I,i,C){if(g>=8&&g<=32767&&A[e]===2&&A[e+1]===2&&(A[e+2]&128)===0){(A[e+2]<<8)+A[e+3]!==g&&R(202),e+=4;for(let o=0;o<4;o++){let r=o,B=0;for(;B<g;){e>=A.length&&R(203);const n=A[e++];if(n===0&&R(204),n>128){const Q=n-128;(Q>g-B||e>=A.length)&&R(205);const E=A[e++];for(let a=0;a<Q;a++)C[r]=E,r+=4;B+=Q}else{(n>g-B||e+n>A.length)&&R(206);for(let Q=0;Q<n;Q++)C[r]=A[e++],r+=4;B+=n}}}for(let o=0;o<g;o++)PX(C[o*4],C[o*4+1],C[o*4+2],C[o*4+3],I,i+o*3)}else{e+g*4>A.length&&R(207);for(let o=0;o<g;o++)PX(A[e],A[e+1],A[e+2],A[e+3],I,i+o*3),e+=4}return e}function PX(A,e,g,I,i,C){if(I===0)i[C]=i[C+1]=i[C+2]=0;else{const o=Math.pow(2,I-136);i[C]=A*o,i[C+1]=e*o,i[C+2]=g*o}}function OX(A,e,g){const I=.282094791773878,i=.48860251190292,C=1.092548430592079,o=.31539156525252,r=.54627421529604,B=new Bi(27);let n=0;for(let a=0;a<g;a++){const c=(a+.5)/g*Math.PI,l=Math.sin(c),p=Math.cos(c),D=l*(Math.PI/g)*(2*Math.PI/e);for(let u=0;u<e;u++){const _=(2*(u+.5)/e-1)*Math.PI,d=l*Math.sin(_),y=p,h=l*Math.cos(_),w=(a*e+u)*3;let M=A[w],N=A[w+1],S=A[w+2];const G=Math.max(M,N,S);if(G>4096){const K=4096/G;M*=K,N*=K,S*=K}const m=D;n+=m;const k=[I,i*y,i*h,i*d,C*d*y,C*y*h,o*(3*h*h-1),C*d*h,r*(d*d-y*y)];for(let K=0;K<9;K++){const U=k[K]*m;B[K]=B[K]+M*U,B[9+K]=B[9+K]+N*U,B[18+K]=B[18+K]+S*U}}}const Q=4*Math.PI/n;for(let a=0;a<27;a++)B[a]=B[a]*Q;const E=[1,2/3,2/3,2/3,.25,.25,.25,.25,.25];for(let a=0;a<3;a++)for(let c=0;c<9;c++)B[a*9+c]=B[a*9+c]*E[c];return xX(B)}var jX=b((()=>{rA(),ZA(),TX()})),VX,i9A=b((()=>{VX="struct t{faceSize:u32,equirectWidth:u32,equirectHeight:u32,_pad:u32}@group(0) @binding(0) var p:texture_2d<f32>;@group(0) @binding(1) var k:texture_storage_2d_array<rgba16float,write>;@group(0) @binding(2) var<uniform> params:t;const i=3.14159265359;const d=array<vec3<f32>,24>(vec3(1.0,-1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(1.0,-1.0,-1.0),vec3(-1.0,1.0,-1.0),vec3(1.0,1.0,-1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,1.0,-1.0));@compute @workgroup_size(8,8,1) fn main(@builtin(global_invocation_id) a:vec3u){let h=a.z;let c=params.faceSize;if (a.x>=c||a.y>=c||h>=6u){return;}let f=f32(a.x)/f32(c);let e=f32(a.y)/f32(c);let b=h*4u;let g=normalize(d[b]*(1.0-f)*(1.0-e)+d[b+1u]*f*(1.0-e)+d[b+2u]*(1.0-f)*e+d[b+3u]*f*e);let l=atan2(g.z,g.x);let m=acos(clamp(g.y,-1.0,1.0));let n=l/i*0.5+0.5;let o=m/i;let j=clamp(i32(round(n*f32(params.equirectWidth))),0,i32(params.equirectWidth)-1);let q=clamp(i32(round(o*f32(params.equirectHeight))),0,i32(params.equirectHeight)-1);let r=i32(params.equirectHeight)-q-1;let s=textureLoad(p,vec2<i32>(j,r),0);textureStore(k,vec2<i32>(a.xy),i32(h),vec4<f32>(s.rgb,1.0));}"})),WX,C9A=b((()=>{WX="struct ha{faceSize:u32,mipLevel:u32,totalMips:u32,srcSize:u32}@group(0) @binding(0) var x:texture_cube<f32>;@group(0) @binding(1) var F:sampler;@group(0) @binding(2) var z:texture_storage_2d_array<rgba16float,write>;@group(0) @binding(3) var<uniform> params:ha;const k=3.14159265359;const n=1024u;const g=array<vec3<f32>,24>(vec3(1.0,-1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(1.0,-1.0,-1.0),vec3(-1.0,1.0,-1.0),vec3(1.0,1.0,-1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,1.0,-1.0));fn I(ca:u32,j:f32,d:f32)->vec3<f32>{let i=ca*4u;return normalize(g[i]*(1.0-j)*(1.0-d)+g[i+1u]*j*(1.0-d)+g[i+2u]*(1.0-j)*d+g[i+3u]*j*d);}fn J(ba:u32)->f32{var a=ba;a=(a<<16u)|(a>>16u);a=((a&0x55555555u)<<1u)|((a&0xAAAAAAAAu)>>1u);a=((a&0x33333333u)<<2u)|((a&0xCCCCCCCCu)>>2u);a=((a&0x0F0F0F0Fu)<<4u)|((a&0xF0F0F0F0u)>>4u);a=((a&0x00FF00FFu)<<8u)|((a&0xFF00FF00u)>>8u);return f32(a)*2.3283064365386963e-10;}fn K(aa:f32,C:f32,s:f32)->vec3<f32>{let Z=s*s;let u=2.0*k*aa;let o=sqrt((1.0-C)/(1.0+(Z-1.0)*C));let w=sqrt(1.0-o*o);return vec3<f32>(cos(u)*w,sin(u)*w,o);}fn L(y:f32,t:f32)->f32{let A=y*y*(t-1.0)+1.0;return t/(k*A*A);}fn H(Y:u32,M:f32,S:f32)->vec3<f32>{return I(Y,M,S);}@compute @workgroup_size(8,8,1) fn main(@builtin(global_invocation_id) c:vec3u){let f=c.z;let h=params.faceSize>>params.mipLevel;if (c.x>=h||c.y>=h||f>=6u){return;}let R=f32(c.x)/f32(h);let Q=f32(c.y)/f32(h);let b=normalize(H(f,R,Q));let q=pow(2.0,f32(params.mipLevel)/0.8)/f32(params.srcSize);if (params.mipLevel==0u){let O=textureSampleLevel(x,F,b,0.0);textureStore(z,vec2<i32>(c.xy),i32(f),vec4<f32>(O.rgb,1.0));return;}var X=select(vec3<f32>(1.0,0.0,0.0),vec3<f32>(0.0,0.0,1.0),abs(b.z)<0.999);let v=normalize(cross(X,b));let P=cross(b,v);var p=vec3<f32>(0.0);var m=0.0;let E=f32(params.srcSize);let T=4.0*k/(6.0*E*E);let U=f32(params.totalMips)-1.0;for(var e=0u;e<n;e++){let W=f32(e)/f32(n);let N=J(e);let r=K(W,N,q);let B=v*r.x+P*r.y+b*r.z;let D=max(dot(b,B),0.0);let G=2.0*D*B-b;let l=dot(b,G);if (l>0.0){let da=q*q;let ea=L(D,da)/4.0;let fa=1.0/(f32(n)*max(ea,0.0001));let ga=clamp(0.5*log2(fa/T)+1.0,0.0,U);let V=textureSampleLevel(x,F,G,ga);p+=V.rgb*l;m+=l;}}if (m>0.0){p/=m;}textureStore(z,vec2<i32>(c.xy),i32(f),vec4<f32>(p,1.0));}"})),ZY,zX=b((()=>{ZY="@group(0) @binding(0) var z:texture_storage_2d<rgba16float,write>;fn x(G:u32)->f32{var a=G;a=(a<<16u)|(a>>16u);a=((a&0x55555555u)<<1u)|((a&0xAAAAAAAAu)>>1u);a=((a&0x33333333u)<<2u)|((a&0xCCCCCCCCu)>>2u);a=((a&0x0F0F0F0Fu)<<4u)|((a&0xF0F0F0F0u)>>4u);a=((a&0x00FF00FFu)<<8u)|((a&0xFF00FF00u)>>8u);return f32(a)*2.3283064365386963e-10;}fn w(B:f32,u:f32,J:f32)->vec3f{let t=2.0*3.14159265359*B;let k=sqrt((1.0-u)/(1.0+(J-1.0)*u));let q=sqrt(1.0-k*k);return vec3f(cos(t)*q,sin(t)*q,k);}fn y(b:f32,n:f32)->vec2f{let o=vec3f(sqrt(1.0-b*b),0.0,b);let p=n*n;let e=p*p;var r=0.0;var l=0.0;let g=1024u;for(var f=0u;f<g;f++){let F=f32(f)/f32(g);let E=x(f);let j=w(F,E,e);let i=max(dot(o,j),0.0);let A=2.0*i*j-o;let d=max(A.z,0.0);let s=max(j.z,0.0);if (d>0.0&&s>0.0){let C=d*sqrt(b*b*(1.0-e)+e);let D=b*sqrt(d*d*(1.0-e)+e);let v=(0.5/max(C+D,1e-6))*d*(4.0*i/s);let m=pow(1.0-i,5.0);r+=(1.0-m)*v;l+=m*v;}}return vec2f(r/f32(g),l/f32(g));}@compute @workgroup_size(8,8) fn main(@builtin(global_invocation_id) c:vec3u){if (c.x>=256u||c.y>=256u){return;}let H=max((f32(c.x)+0.5)/256.0,0.001);let I=max((f32(c.y)+0.5)/256.0,0.04);let h=y(H,I);textureStore(z,vec2u(c.x,c.y),vec4f(h.y,h.x+h.y,0.0,1.0));}"})),o9A=H({HDR_LOD_GENERATION_SCALE:()=>XY,_enableHdrEnvironmentCopySource:()=>ZX,equirectToCubemapGPU:()=>XX,generateBrdfLut:()=>A$,prefilterCubemapGPU:()=>$X});function ZX(){$Y=RA.COPY_SRC}function XX(A,e,g){const I=A._device,i=I.createTexture({size:[e.width,e.height],format:"rgba32float",usage:RA.TEXTURE_BINDING|RA.COPY_DST});{const a=new oA(e.width*e.height*4);for(let c=0;c<e.width*e.height;c++)a[c*4]=e.data[c*3],a[c*4+1]=e.data[c*3+1],a[c*4+2]=e.data[c*3+2],a[c*4+3]=1;I.queue.writeTexture({texture:i},a.buffer,{bytesPerRow:e.width*16},{width:e.width,height:e.height})}const C=I.createTexture({size:[g,g,6],format:"rgba16float",usage:RA.TEXTURE_BINDING|RA.STORAGE_BINDING|RA.COPY_SRC,dimension:"2d"}),o=I.createShaderModule({code:VX}),r=I.createComputePipeline({layout:"auto",compute:{module:o,entryPoint:"main"}}),B=wI(A,new Ag([g,e.width,e.height,0])),n=I.createBindGroup({layout:r.getBindGroupLayout(0),entries:[{binding:0,resource:i.createView()},{binding:1,resource:C.createView()},{binding:2,resource:{buffer:B}}]}),Q=I.createCommandEncoder(),E=Q.beginComputePass();return E.setPipeline(r),E.setBindGroup(0,n),E.dispatchWorkgroups(Math.ceil(g/8),Math.ceil(g/8),6),E.end(),I.queue.submit([Q.finish()]),i.destroy(),B.destroy(),C}function $X(A,e,g,I){const i=A._device,C=i.createTexture({size:{width:g,height:g,depthOrArrayLayers:6},mipLevelCount:I,format:"rgba16float",usage:RA.TEXTURE_BINDING|RA.STORAGE_BINDING|RA.COPY_DST|$Y}),o=e.createView({dimension:"cube"}),r=Qi(A),B=i.createComputePipeline({layout:"auto",compute:{module:i.createShaderModule({code:WX}),entryPoint:"main"}}),n=Lt(A,16);{const Q=i.createCommandEncoder();Q.copyTextureToTexture({texture:e},{texture:C,mipLevel:0},{width:g,height:g,depthOrArrayLayers:6}),i.queue.submit([Q.finish()])}for(let Q=1;Q<I;Q++){const E=g>>Q;if(E<1)break;i.queue.writeBuffer(n,0,new Ag([g,Q,I,g]));const a=C.createView({baseMipLevel:Q,mipLevelCount:1}),c=i.createBindGroup({layout:B.getBindGroupLayout(0),entries:[{binding:0,resource:o},{binding:1,resource:r},{binding:2,resource:a},{binding:3,resource:{buffer:n}}]}),l=i.createCommandEncoder(),p=l.beginComputePass();p.setPipeline(B),p.setBindGroup(0,c),p.dispatchWorkgroups(Math.ceil(E/8),Math.ceil(E/8),6),p.end(),i.queue.submit([l.finish()])}return e.destroy(),n.destroy(),C}function A$(A){const e=A._device;(!qm||A5!==e)&&(qm=e.createComputePipeline({layout:"auto",compute:{module:e.createShaderModule({code:ZY}),entryPoint:"main"}}),A5=e);const g=256,I=e.createTexture({size:{width:g,height:g},format:"rgba16float",usage:RA.TEXTURE_BINDING|RA.STORAGE_BINDING}),i=e.createBindGroup({layout:qm.getBindGroupLayout(0),entries:[{binding:0,resource:I.createView()}]}),C=e.createCommandEncoder(),o=C.beginComputePass();return o.setPipeline(qm),o.setBindGroup(0,i),o.dispatchWorkgroups(Math.ceil(g/8),Math.ceil(g/8)),o.end(),e.queue.submit([C.finish()]),I}var XY,$Y,qm,A5,e5=b((()=>{ZA(),te(),F1(),zI(),b1(),i9A(),C9A(),zX(),XY=.8,$Y=0,qm=null,A5=null})),r9A=H({rebuildSceneEnvironment:()=>B9A});async function B9A(A,e){const g=e._envTextures;if(!g)return;const I=e._envRecoverySource;I||R(162);const i=g.sphericalHarmonics;e._envTextures=void 0;let C;if(I.kind==="env")C=await n9A(A,I,i);else{const B=await Promise.resolve().then(()=>(jX(),I9A)),n=await Promise.resolve().then(()=>(e5(),o9A)),Q=await e$(I.url),E=B.parseRGBE(Q),a=B.computeSHFromEquirect(E.data,E.width,E.height),c=n.equirectToCubemapGPU(A,E,I.faceSize);C=tQ(n.prefilterCubemapGPU(A,c,I.faceSize,Math.floor(Math.log2(I.faceSize))+1),n.generateBrdfLut(A),a,n.HDR_LOD_GENERATION_SCALE,A,i)}Object.assign(g,C);const{specularCube:o,brdfLut:r}=g;Mi(o),Mi(r),e._disposables.push(()=>{Si(o),Si(r)}),e._envTextures=g,e._envRecoverySource=I}async function n9A(A,e,g){const I=IK(e.brdfUrl);I.catch(()=>{});const{faceBlobs:i,irradianceSH:C,width:o,mipCount:r}=gX(await e$(e.url)),B=await Promise.all(i.map(c=>createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"}))),n=await Promise.resolve().then(()=>(Z3(),V3)),Q=n.uploadCubemapRGBD(A,B,o,r);for(const c of B)c.close();const E=await I,a=n.decodeBrdfPng(A,E);return E.close(),tQ(Q,a,C,.8,A,g)}async function e$(A){const e=await fetch(A);return e.ok||R(163,A,e.status,e.statusText),e.arrayBuffer()}var s9A=b((()=>{rA(),Lr(),qn(),Tm(),tX()}));function gt(A,e,g=0,I=0){const i=e;if(I===0&&i.length===16){A.set(i,g);return}const C=I,o=g;A[o+0]=i[C+0],A[o+1]=i[C+1],A[o+2]=i[C+2],A[o+3]=i[C+3],A[o+4]=i[C+4],A[o+5]=i[C+5],A[o+6]=i[C+6],A[o+7]=i[C+7],A[o+8]=i[C+8],A[o+9]=i[C+9],A[o+10]=i[C+10],A[o+11]=i[C+11],A[o+12]=i[C+12],A[o+13]=i[C+13],A[o+14]=i[C+14],A[o+15]=i[C+15]}var gi=b((()=>{}));function g5(A,e){gt(A,e._lightMatrix,0),A[16]=e._depthValues[0],A[17]=e._depthValues[1],A[18]=0,A[19]=0,A[20]=e._shadowsInfo[0],A[21]=e._shadowsInfo[1],A[22]=e._shadowsInfo[2],A[23]=e._shadowsInfo[3]}function g$(A,e,g,I,i,C){const o=Math.sqrt(A*A+e*e+g*g)||1,r=A/o,B=e/o,n=g/o;let Q=0,E=1,a=0;Math.abs(B)>.99&&(Q=0,E=0,a=1);let c=E*n-a*B,l=a*r-Q*n,p=Q*B-E*r;const D=Math.sqrt(c*c+l*l+p*p)||1;c/=D,l/=D,p/=D;const u=B*p-n*l,_=n*c-r*p,d=r*l-B*c;return new oA([c,u,r,0,l,_,B,0,p,d,n,0,-(c*I+l*i+p*C),-(u*I+_*i+d*C),-(r*I+B*i+n*C),1])}function I$(A,e){const g=new oA(16);for(let I=0;I<4;I++)for(let i=0;i<4;i++){let C=0;for(let o=0;o<4;o++)C+=A[I+o*4]*e[o+i*4];g[I+i*4]=C}return g}function t$(A,e,g,I,i=0,C=0,o=0){const r=A.worldMatrix,B=A.direction,n=g$(r[0]*B.x+r[4]*B.y+r[8]*B.z,r[1]*B.x+r[5]*B.y+r[9]*B.z,r[2]*B.x+r[6]*B.y+r[10]*B.z,r[12]-i,r[13]-C,r[14]-o);let Q=1/0,E=-1/0,a=1/0,c=-1/0;for(const u of e){const _=u.worldMatrix,d=u.boundMin??[-.5,-.5,-.5],y=u.boundMax??[.5,.5,.5];for(let h=0;h<8;h++){const w=h&1?y[0]:d[0],M=h&2?y[1]:d[1],N=h&4?y[2]:d[2],S=_[0]*w+_[4]*M+_[8]*N+_[12]-i,G=_[1]*w+_[5]*M+_[9]*N+_[13]-C,m=_[2]*w+_[6]*M+_[10]*N+_[14]-o,k=n[0]*S+n[4]*G+n[8]*m+n[12],K=n[1]*S+n[5]*G+n[9]*m+n[13];Q=Math.min(Q,k),E=Math.max(E,k),a=Math.min(a,K),c=Math.max(c,K)}}Number.isFinite(Q)||(Q=-1,E=1,a=-1,c=1);const l=(E-Q)*.1,p=(c-a)*.1;Q-=l,E+=l,a-=p,c+=p;const D=new oA(16);return D[0]=2/(E-Q),D[5]=2/(c-a),D[10]=1/(I-g),D[12]=-(E+Q)/(E-Q),D[13]=-(c+a)/(c-a),D[14]=-g/(I-g),D[15]=1,{_view:n,_viewProj:I$(D,n),_near:g,_far:I}}function Pm(A,e,g){const I=new oA(8);return I[0]=e,I[2]=g,I[4]=0,I[5]=1,wI(A,I)}function i$(A,e=null,g=A._depthTexture){const I=A._config._mapSize;return{_descriptor:{size:{width:I,height:I},format:e?"rgba16float":void 0,dFormat:"depth32float",depthClearValue:1,depthCompare:"less-equal",samples:1},_colorTexture:e,_colorView:e?.createView()??null,_depthTexture:g,_depthView:g.createView(),_width:I,_height:I,_eager:!0,_ownsDepthTexture:!1}}function I5(A,e,g,I){const i=new oA(24);return g5(i,{_lightMatrix:e,_depthValues:g,_shadowsInfo:I}),{ubo:wI(A,i),data:i}}function t5(A){let e=0;for(const g of A)e+=g.worldMatrixVersion+~~g.thinInstances?._version;return e}function tK(A){return{fov:1,nearPlane:1,farPlane:1,children:[],_viewCache:QI(),_projCache:QI(),_vpCache:QI(),get worldMatrix(){return A._light.worldMatrix},get worldMatrixVersion(){return this._shadowCameraVersion??A._light._lightVersion}}}function iK(A,e,g,I,i,C){A.nearPlane=g,A.farPlane=I,A._shadowCameraVersion=e,A._viewCache=i,A._viewVer=e,A._vpCache=C,A._vpVer=Wi(A),A._vpAspect=1}var Tr=b((()=>{ZA(),FI(),zI(),gi(),Ut()}));function C$(A,e,g,I,i){A.fill(0);const C=si(I,i),o=ei(I),r=I.worldMatrix;gt(A,C,0),gt(A,o,16),e.useFloatingOrigin?(A[32]=0,A[33]=0,A[34]=0):(A[32]=r[12],A[33]=r[13],A[34]=r[14]),A[87]=e.canvas.width;const B=g.imageProcessing;A[76]=B.exposure,A[77]=B.contrast,A[78]=g._envTextures?.lodGenerationScale??.8,A[79]=+B.toneMappingEnabled,A[37]=e.canvas.height}var o$=b((()=>{FI(),gi()}));function r$(A,e){return{_renderables:A,_opaqueBindings:[],_directBindings:[],_transparentBindings:[],_ob:[],_lastVersion:e}}function i5(A,e,g){A.clr??=!0;const I=A.rt._descriptor,i=A.depth?._descriptor,C={_colorFormat:I.format,_depthStencilFormat:i?.dFormat??I.dFormat,_depthCompare:I.depthCompare??i?.depthCompare,_sampleCount:I.samples},o={loadOp:"clear",storeOp:"store"},r={targetWidth:0,targetHeight:0},B={...r$([],-1),name:A.name,_config:A,_ownsTargets:!A.sharedRt,engine:e,scene:g,_passes:[],_renderPassDescriptor:{colorAttachments:[o]},_colorAttachment:o,_sceneUBO:Lt(e,368),_suData:new oA(92),_sceneUboCacheKey:[],_targetSignature:C,_updateContext:r,record(){if(B._disposed)throw new Error("RenderTask has been disposed.");B._recordExplicit?B._recordExplicit(B,!0):CK(B,A.autoMirror!==!1?g._renderables.slice():B._renderables,!0)},execute(){return l9A(B,e,C)},dispose(){if(B._disposed)return;B._disposed=!0;const n=B._pendingMeshes;n&&(n.length=0);for(const E of B._renderables)B._retireRenderable?.(B.engine,E);B._passes.length=B._opaqueBindings.length=B._directBindings.length=0,B._transparentBindings.length=B._renderables.length=B._ob.length=0,B._ownsTargets&&(eI(A.rt),eI(A.rst)),A.depth?._eager||eI(A.depth);const Q=B._sceneUBO;et(B.engine,()=>Q.destroy()),B._batchState?._release(B.engine),B._batchState=void 0}};return B}function B$(A,e){if(!A._renderables)return;A._removeMesh?.(e);let g=!1;for(let I=A._renderables.length-1;I>=0;I--)A._renderables[I].mesh===e&&(A._retireRenderable?.(A.engine,A._renderables[I]),A._renderables.splice(I,1),g=!0);for(const I of[A._opaqueBindings,A._directBindings,A._transparentBindings])for(let i=I.length-1;i>=0;i--)I[i].renderable.mesh===e&&(I.splice(i,1),g=!0);if(g){const I=A._batchState;A._batchState=I?._select([A._opaqueBindings,A._directBindings,A._transparentBindings]),I?._release(A.engine,[A._batchState]),A._ob.length=0,A._lastVersion=-1}}function Q9A(A,e){return e._sortDistance-A._sortDistance||A.renderable.order-e.renderable.order}function n$(A,e){return A.renderable.order-e.renderable.order}function E9A(A,e){const g=A._transparentBindings;if(g.length<=1||!e)return;const I=ei(e);for(const i of g){const C=i.renderable._worldCenter;i._sortDistance=C?C[0]*I[2]+C[1]*I[6]+C[2]*I[10]+I[14]:0}g.sort(Q9A)}function CK(A,e=A._renderables,g=!1,I=!0,i){const C=A._config,o=C.rt,r=A._batchState,B=r$(e,A.scene._renderableVersion);if(g){const a=(c,l)=>{c&&(l||A._ownsTargets||c._eager)&&xI(c,A.engine)};a(o),o._descriptor.samples>1&&a(C.rst),a(C.depth,!0)}const{_opaqueBindings:n,_directBindings:Q,_transparentBindings:E}=B;try{for(const a of e){const c=a.bind(A.engine,A._targetSignature);B._batchState=A._targetSignature._collectBatches?.(B._batchState,c),a.isTransparent||a._transmissive?E.push(c):a._direct?Q.push(c):n.push(c)}n.sort(n$),Q.sort(n$),g&&s$(A,A.engine,!1)}catch(a){throw B._batchState?._release(void 0,i??[r]),a}return g&&(a9A(A,o),A._updateContext.targetWidth=o._width,A._updateContext.targetHeight=o._height),I&&(Object.assign(A,B),r?._release(A.engine,[B._batchState])),B}function a9A(A,e){const g=A._config,I=A._colorAttachment;I.view=e._colorView,A._renderPassDescriptor.colorAttachments=e._colorView?[I]:[];const i=g.depth??e,C=i._depthView;let o;if(C){const r=i._descriptor,B=(g.depth?i._eager:g.depthClear===!1)?"load":"clear";o={view:C,depthClearValue:r.depthClearValue??0,depthLoadOp:B,depthStoreOp:"store"},r.dFormat?.includes("stencil")&&(o.stencilClearValue=0,o.stencilLoadOp=B,o.stencilStoreOp="store")}A._renderPassDescriptor.depthStencilAttachment=o}function c9A(A,e,g){const I=A.scene;A._config.autoMirror!==!1&&A._lastVersion!==I._renderableVersion&&CK(A,I._renderables.slice()),s$(A,e);const i=A._updateContext,C=A._config.cam??I.camera;g._colorFormat&&(A._config._skipClusteredLights||I._clusteredLightUpdater?.(C,i.targetWidth,i.targetHeight),w4A(e,I)),D9A(A,e,I,C),i._camera=C,A._batchState?._reset(),C5(A._opaqueBindings,i),C5(A._directBindings,i),C5(A._transparentBindings,i),A._batchState?._flush(e),E9A(A,C)}function l9A(A,e,g){if(A.enabled===!1)return 0;const I=A.scene;c9A(A,e,g);const i=A._colorAttachment,C=A._config;if(C.rt._colorView&&(C.rt===I.surface.scRT&&(i.view=C.rt._colorView),i.resolveTarget=C.rst?._colorView??void 0,i.clearValue=C.clrColor??I.clearColor,i.loadOp=C.clr?"clear":"load"),A._executeWithTransmission)return A._executeWithTransmission(g._sampleCount);const o=e._currentEncoder.beginRenderPass(A._renderPassDescriptor),r=p9A(A,o);return o.end(),r}function p9A(A,e){const g=A.engine,I=A._config,i=I.rt,C=A.scene,o=A._opaqueBindings,r=A._ob,B=A._sceneBG;if(NZ(e,I.cam??C.camera,i._width,i._height),e.setBindGroup(0,B),A._lastVis!==Yn||!r.length){const Q=i._descriptor,E=g._device.createRenderBundleEncoder({colorFormats:Q.format?[Q.format]:[],depthStencilFormat:A._targetSignature._depthStencilFormat,sampleCount:Q.samples});E.setBindGroup(0,B),iQ(E,o,g),r[0]=E.finish(),A._lastVis=Yn}let n=o.length;return e.executeBundles(r),e.setBindGroup(0,B),n+=iQ(e,A._directBindings,g),n+=iQ(e,A._transparentBindings,g),n}function s$(A,e,g=!0){const I=P3(e,A.scene)._buffer;if(I===A._lightsUBO)return;const i=e._device.createBindGroup({layout:n1(e),entries:[{binding:0,resource:{buffer:A._sceneUBO}},{binding:1,resource:{buffer:I}}]});A._lightsUBO=I,A._sceneBG=i,g&&(A._ob=[])}function D9A(A,e,g,I){if(!I)return;const i=I.viewport,C=A._config.rt,o=(A._config.cs?e.canvas.width/e.canvas.height:C._width/C._height)*(i?i.width/i.height:1),r=g.fog,B=g.imageProcessing,n=Wi(I),Q=g._envTextures,E=A._sceneUboCacheKey;if(E[0]===I&&E[1]===r&&E[2]===n&&E[3]===o&&E[4]===B.exposure&&E[5]===B.contrast&&E[6]===Q)return;E[0]=I,E[1]=r,E[2]=n,E[3]=o,E[4]=B.exposure,E[5]=B.contrast,E[6]=Q;const a=A._suData;C$(a,e,g,I,o);const c=g._sceneUboContributors;if(c)for(const l of c)l(a,g);e._device.queue.writeBuffer(A._sceneUBO,0,a)}function C5(A,e){for(const g of A)g.update?.(e)}function iQ(A,e,g){let I=null,i=0;for(const C of e){const o=C.renderable.mesh;o&&o.visible===!1||(C.pipeline!==I&&(A.setPipeline(C.pipeline),I=C.pipeline),i+=C.draw(A,g))}return i}var CQ=b((()=>{ZA(),lt(),kI(),MI(),FI(),s1(),o$(),b1(),O3(),HY()}));function o5(A,e){const g=A._groups.get(e);return g?g.r:e._sceneIndependentRebuild?e._rebuildSingle:void 0}var r5=b((()=>{}));function B5(A,e=[]){for(const{mesh:g,material:I}of A._pendingMeshes){if(!I)continue;const i={_lifetimeDisposers:[]},C=o5(A.scene,I._buildGroup);C||R(156),e.push(i);const o=C(A.scene,g,I,i);o._lifetimeDisposers=i._lifetimeDisposers,A._renderables.push(o)}return A._pendingMeshes.length=0,e}function u9A(A){const e=[],g={scene:A.scene,_renderables:A._renderables.slice(),_pendingMeshes:A._pendingMeshes.slice()},I=()=>{for(const i of e)wC(i._lifetimeDisposers);e.length=0};try{A._prepareTaskMeshes?.(g),B5(g,e)}catch(i){throw I(),i}return{renderables:g._renderables,dispose:I}}function Q$(A,e=!1){A._disposed&&R(157);const g=A._batchState,I=[],i=A._pendingMeshes.length>0,C=A._config.autoMirror!==!1,o={scene:A.scene,_renderables:C?i?[]:A.scene._renderables.slice():A._renderables.slice(),_pendingMeshes:A._pendingMeshes.slice()};let r;try{A._prepareTaskMeshes?.(o,!0),B5(o,I),r=CK(A,o._renderables,e,!1)}catch(B){for(const n of I)wC(n._lifetimeDisposers);throw B}i&&(A._config.autoMirror=!1),A._pendingMeshes=o._pendingMeshes,Object.assign(A,r),g?._release(A.engine,[r._batchState])}var E$=b((()=>{rA(),kI(),r5(),CQ()}));function oQ(A,e,g){return i5(A,e,g)}function Om(A,e,g){jm(A),A._addMesh(e,g)}function jm(A){A._addMesh||(A._pendingMeshes??=[],A._addMesh=d9A,A._recordExplicit=Q$,A._retireRenderable=_9A)}function _9A(A,e){e._lifetimeDisposers&&DZ(A,e._lifetimeDisposers)}function d9A(A,e){if(this._disposed)throw new Error("RenderTask has been disposed.");const g=e?.material??A.material;g&&(this._pendingMeshes.push({mesh:A,material:g}),this._sceneBG&&n5(this))}function f9A(A,e){const g=A._pendingMeshes;if(g)for(let I=g.length-1;I>=0;I--)g[I].mesh===e&&g.splice(I,1);B$(A,e)}function n5(A){Q$(A)}var rQ=b((()=>{kI(),CQ(),E$()})),a$,y9A=b((()=>{a$="struct c{@builtin(position) clipPos:vec4<f32>,@location(0) sampleCenter:vec2<f32>}@vertex fn main(@builtin(vertex_index) d:u32)->c{var e=array<vec2<f32>,3>(vec2<f32>(-1.0,-1.0),vec2<f32>(3.0,-1.0),vec2<f32>(-1.0,3.0));var a:c;let b=e[d];a.clipPos=vec4<f32>(b,0.0,1.0);a.sampleCenter=b*vec2<f32>(0.5,-0.5)+0.5;return a;}"}));function iC(A,e){const g=t1(A);return Object.create(g,{source:{value:g,enumerable:!0},_renderFeatures:{value:{features:e.features,features2:e.features2},writable:!0,enumerable:!0,configurable:!0}})}function oK(A){const e=A;return!!e.source&&!!e._renderFeatures}function t1(A){return oK(A)?A.source:A}var It=b((()=>{}));function h9A(A){Wm=A}function CC(A){(EK??=new Map).set(A._id,A),zm=null}function c$(){return EK??=new Map}function rK(){if(!zm){const A=EK;zm=A?Array.from(A.values()).sort((e,g)=>e._id.localeCompare(g._id)):[]}return zm}var BK,nK,s5,Q5,E5,On,a5,Vm,c5,BQ,l$,l5,p5,sK,D5,QK,Wm,EK,zm,aK,bI=b((()=>{BK=1024,nK=2048,s5=4096,Q5=8192,E5=16384,On=65536,a5=1<<17,Vm=1<<18,c5=1<<19,BQ=1<<20,l$=1<<21,l5=32768,p5=1<<22,sK=1<<24,D5=1<<26,QK=1<<27,Wm=null,EK=null,zm=null,aK=3456})),w9A=H({createStandardEsmShadowMaterialView:()=>M9A});function M9A(A,e){const g=iC(A,{features:(A._renderFeatures??{features:0}).features&~On|BQ});return Object.defineProperty(g,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(g,"_esmShadowDepthCode",{value:p$,enumerable:!1}),g}var p$,R9A=b((()=>{It(),bI(),p$="let depthMetricSM=(input.clipPos.z+shadowParams.depthValues.x)/shadowParams.depthValues.y+shadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,shadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),Zm,Xm,cK,u5,lK,pK,_5,DK,uK,d5,nQ,f5,_K,dK,fK,$m,sQ,Ii=b((()=>{Zm=1024,Xm=2048,cK=4096,u5=32768,lK=1<<17,pK=1<<21,_5=1<<22,DK=1<<25,uK=1<<26,d5=1<<27,nQ=1<<28,f5=1<<29,_K=1024,dK=2048,fK=4096,$m=32768,sQ=65536})),S9A=H({PBR2_ESM_SHADOW_OUTPUT:()=>sQ,PBR2_HAS_BASE_COLOR_FACTOR:()=>fK,PBR2_HAS_REFLECTANCE_FACTORS:()=>_K,PBR2_HAS_REFRACTION:()=>16,PBR2_HAS_UV2:()=>dK,PBR2_HAS_UV_TRANSFORM:()=>512,PBR2_NO_COLOR_OUTPUT:()=>$m,PBR_HAS_ALPHA_BLEND:()=>64,PBR_HAS_ALPHA_TEST:()=>8,PBR_HAS_ANISOTROPY:()=>uK,PBR_HAS_COTANGENT_NORMAL:()=>512,PBR_HAS_DOUBLE_SIDED:()=>256,PBR_HAS_EMISSIVE:()=>2,PBR_HAS_EMISSIVE_COLOR:()=>pK,PBR_HAS_ENV:()=>4,PBR_HAS_FOG:()=>32,PBR_HAS_GAMMA_ALBEDO:()=>DK,PBR_HAS_METALLIC_REFLECTANCE_MAP:()=>Zm,PBR_HAS_NORMAL_MAP:()=>1,PBR_HAS_OCCLUSION:()=>u5,PBR_HAS_REFLECTANCE_MAP:()=>Xm,PBR_HAS_SHEEN:()=>_5,PBR_HAS_SKYBOX:()=>f5,PBR_HAS_SPECULAR_AA:()=>lK,PBR_HAS_SPEC_GLOSS:()=>128,PBR_HAS_SUBSURFACE:()=>d5,PBR_HAS_THICKNESS_MAP:()=>nQ,PBR_HAS_TONEMAP:()=>16,PBR_HAS_USE_ALPHA_ONLY_MR:()=>cK,_getPbrExts:()=>qr,_getPbrExtsSorted:()=>D$,_getPbrSceneHooks:()=>u$,_registerPbrExt:()=>TI,_registerPbrSceneHook:()=>y5});function TI(A){(yK??=new Map).set(A.id,A),AF=null}function qr(){return yK??=new Map}function D$(){if(!AF){const A=yK;AF=A?Array.from(A.values()).sort((e,g)=>e.id.localeCompare(g.id)):[]}return AF}function y5(A){(h5??=new Set).add(A)}function u$(){return h5??[]}var yK,AF,h5,lI=b((()=>{Ii(),yK=null,AF=null,h5=null})),N9A=H({createPbrEsmShadowMaterialView:()=>G9A});function G9A(A,e){const g=A._renderFeatures??{features:0,features2:0},I=iC(A,{features:g.features&-65,features2:(g.features2??0)|sQ});return Object.defineProperty(I,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(I,"_esmShadowDepthCode",{value:_$,enumerable:!1}),I}var _$,m9A=b((()=>{It(),lI(),_$="let depthMetricSM=(input.clipPos.z+shadowParams.depthValues.x)/shadowParams.depthValues.y+shadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,shadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),hK=b((()=>{})),F9A=H({createNodeEsmShadowMaterialView:()=>b9A});function b9A(A,e){const g=iC(A,{features:(A._renderFeatures??{features:0}).features|2});return Object.defineProperty(g,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(g,"_esmShadowDepthCode",{value:d$,enumerable:!1}),g}var d$,k9A=b((()=>{It(),hK(),d$="let depthMetricSM=(in.position.z+nmeShadowParams.depthValues.x)/nmeShadowParams.depthValues.y+nmeShadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,nmeShadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),K9A=H({createEsmDirectionalShadowGenerator:()=>M$,ensureEsmShadowTaskState:()=>h$,getEsmShadowTaskResources:()=>w5,setEsmShadowTaskResources:()=>f$});function f$(A,e){A._esmResources=e}function w5(A){return A._esmResources??null}async function U9A(A){const e=[];let g=!1,I=!1,i=!1;for(const C of A){const o=C.material?._buildGroup._materialFamily;g||=o==="standard",I||=o==="pbr",i||=o==="node"}g&&!M5&&e.push(Promise.resolve().then(()=>(R9A(),w9A)).then(C=>{M5=C.createStandardEsmShadowMaterialView})),I&&!R5&&e.push(Promise.resolve().then(()=>(m9A(),N9A)).then(C=>{R5=C.createPbrEsmShadowMaterialView})),i&&!S5&&e.push(Promise.resolve().then(()=>(k9A(),F9A)).then(C=>{S5=C.createNodeEsmShadowMaterialView})),await Promise.all(e)}function v9A(A){const e=Math.round(Math.max(A,1));for(const g of[e,e-1,e+1,e-2,e+2])if(g%2!==0&&Math.floor(g/2)%2===0&&g>0)return Math.max(g,3);return Math.max(e,3)}function L9A(A){const e=.3333333333333333;return Math.exp(-(A*A/(2*e*e)))/(Math.sqrt(2*Math.PI)*e)}function Y9A(A){const e=v9A(A),g=(e-1)/2,I=[],i=[];let C=0;for(let B=0;B<e;B++){const n=L9A(B/(e-1)*2-1);I[B]=B-g,i[B]=n,C+=n}for(let B=0;B<i.length;B++)i[B]=i[B]/C;const o=[],r=[];for(let B=0;B<=g;B+=2){const n=Math.min(B+1,Math.floor(g));if(B===n){o.push(I[B]),r.push(i[B]);continue}const Q=n===g,E=i[B]+i[n]*(Q?.5:1),a=I[B]+1/(1+i[B]/i[n]);a===0?(o.push(I[B],I[B+1]),r.push(i[B],i[B+1])):(o.push(a,-a),r.push(E,E))}return{offsets:o,weights:r}}function y$(A){let e=(Object.is(A,-0)?0:A).toPrecision(10);return/[.eE]/.test(e)||(e+=".0"),e}function J9A(A){const{offsets:e,weights:g}=Y9A(A),I=e.length;return`struct BlurParams{delta:vec2<f32>,_pad:vec2<f32>,};@group(0)@binding(0)var<uniform>params:BlurParams;@group(0)@binding(1)var srcTex:texture_2d<f32>;@group(0)@binding(2)var srcSampler:sampler;const OFFSETS=array<f32,${I}>(${e.map(y$).join(",")});const WEIGHTS=array<f32,${I}>(${g.map(y$).join(",")});@fragment fn main(@location(0)sampleCenter:vec2<f32>)->@location(0)vec4<f32>{var blend=vec4<f32>(0.0);for(var i=0u;i<${I}u;i=i+1u){blend+=textureSample(srcTex,srcSampler,sampleCenter+params.delta*OFFSETS[i])*WEIGHTS[i];}return blend;}`}function h$(A,e,g,I,i){const C=i;if(C){if(C._casterMeshes===I)return C;et(A,C._task.dispose)}const o=w5(g);if(!o)throw new Error("ShadowTask: missing ESM metadata.");const r=new Map,B=tK(g),n={_task:oQ({name:"esm",rt:i$(g,o._esmTexture,o._depthBuffer),clr:!0,clrColor:{r:0,g:0,b:0,a:0},cam:B,autoMirror:!1,_skipClusteredLights:!0},A,e),_camera:B,_lastCasterVersion:-1,_lastLightVersion:-1,_lastFoVersion:-1,_casterMeshes:I,_scene:e};for(const Q of I){const E=Q.material;E&&Om(n._task,Q,{material:T9A(E,r,g._shadowParamsUBO)})}return n}function H9A(A,e,g){const I=w5(e);if(!I)return 0;const i=g._casterMeshes,C=t5(i),o=e._light._lightVersion,r=A.useFloatingOrigin?g._scene.camera:null,B=r?r.worldMatrixVersion:0,n=r?r.worldMatrix[12]:0,Q=r?r.worldMatrix[13]:0,E=r?r.worldMatrix[14]:0;if(!e._config._forceRefreshEveryFrame&&C===g._lastCasterVersion&&o===g._lastLightVersion&&B===g._lastFoVersion&&r===g._lastFoCamera)return 0;const a=t$(e._light,i,e._config._orthoMinZ,e._config._orthoMaxZ,n,Q,E);q9A(e._lightMatrix,a._viewProj)&&(gt(e._lightMatrix,a._viewProj,0),e._version++,g5(I._shadowUboData,e),A._device.queue.writeBuffer(e._shadowUBO,0,I._shadowUboData)),x9A(g,a),g._lastCasterVersion=C,g._lastLightVersion=o,g._lastFoVersion=B,g._lastFoCamera=r;const c=g._task.execute?.()??0,l=A._currentEncoder;return w$(l,I._blurPipeline,I._blurTexH,I._blurHBG),w$(l,I._blurPipeline,e._depthTexture,I._blurVBG),c+2}function w$(A,e,g,I){const i=A.beginRenderPass({colorAttachments:[{view:g.createView(),loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});i.setPipeline(e),i.setBindGroup(0,I),i.draw(3),i.end()}function x9A(A,e){const g=A._camera;iK(g,g.worldMatrixVersion+1,e._near,e._far,e._view,e._viewProj)}function T9A(A,e,g){const I=e.get(A);if(I)return I;const i=A._buildGroup._materialFamily;let C;return i==="standard"?C=M5(A,g):i==="pbr"?C=R5(A,g):i==="node"&&(C=S5(A,g)),e.set(A,C),C}function q9A(A,e){for(let g=0;g<16;g++)if(A[g]!==e[g])return!0;return!1}function M$(A,e,g={}){const I=A._device,i=g.mapSize??1024,C=g.depthScale??50,o=g.bias??5e-5,r=g.blurKernel??1,B=g.blurScale??2,n=g.darkness??0,Q=g.frustumEdgeFalloff??0,E=g.orthoMinZ??1,a=g.orthoMaxZ??1e4,c=g.forceRefreshEveryFrame??!1,l=i/B,p={_mapSize:i,_bias:o,_orthoMinZ:E,_orthoMaxZ:a,_forceRefreshEveryFrame:c},D=Pm(A,o,C),u=I.createTexture({size:{width:i,height:i},format:"rgba16float",usage:RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING}),_=I.createTexture({size:{width:i,height:i},format:"depth32float",usage:RA.RENDER_ATTACHMENT}),d=I.createTexture({size:{width:l,height:l},format:"rgba16float",usage:RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING}),y=I.createTexture({size:{width:l,height:l},format:"rgba16float",usage:RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING}),h=I.createShaderModule({code:a$}),w=I.createShaderModule({code:J9A(r)}),M=I.createBindGroupLayout({entries:[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:MA.FRAGMENT,sampler:{type:"filtering"}}]}),N=I.createRenderPipeline({layout:I.createPipelineLayout({bindGroupLayouts:[M]}),vertex:{module:h,entryPoint:"main"},fragment:{module:w,entryPoint:"main",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list",cullMode:"none"}}),S=Qi(A),G=wI(A,new oA([1/l,0,0,0])),m=I.createBindGroup({layout:M,entries:[{binding:0,resource:{buffer:G}},{binding:1,resource:u.createView()},{binding:2,resource:S}]}),k=wI(A,new oA([0,1/l,0,0])),K=I.createBindGroup({layout:M,entries:[{binding:0,resource:{buffer:k}},{binding:1,resource:d.createView()},{binding:2,resource:S}]}),U=new oA(16),Y=new oA([n,0,C,Q]),x=new oA([0,1]),{ubo:q,data:j}=I5(A,U,x,Y),X={_shadowType:"esm",_light:e,_depthTexture:y,_depthSampler:S,_lightMatrix:U,_shadowsInfo:Y,_depthValues:x,_shadowParamsUBO:D,_shadowUBO:q,_config:p,_version:0};return X._preloadShadowTask=U9A,X._ensureShadowTaskState=(Z,AA,z)=>{const IA=h$(Z,AA,X,z,X._shadowTaskState??null);return X._shadowTaskState=IA,IA},X._renderShadowMap=(Z,AA)=>H9A(Z,X,AA),f$(X,{_esmTexture:u,_depthBuffer:_,_blurTexH:d,_blurPipeline:N,_blurHBG:m,_blurVBG:K,_shadowUboData:j,_blurKernel:r,_blurScale:B}),X}var M5,R5,S5,R$=b((()=>{ZA(),kI(),te(),zI(),F1(),rQ(),Tr(),y9A(),gi()})),P9A=H({rebuildSceneShadowGenerators:()=>O9A});async function O9A(A,e){const g=new Set(e.shadowGenerators);for(const I of e.lights)I.shadowGenerator&&g.add(I.shadowGenerator);for(const I of g){if(I._shadowType!=="esm"&&I._shadowType!=="csm"&&R(721,I._shadowType),I._shadowTaskState?._task.dispose(),I._shadowTaskState=void 0,I._preloadPending=void 0,I._shadowType==="csm"){const B=A._device,n=I._config._mapSize;I._depthTexture=B.createTexture({size:{width:n,height:n,depthOrArrayLayers:I._csmCascadeCount},format:"depth32float",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|(I._csmCache?GPUTextureUsage.COPY_DST:0)}),I._depthSampler=B.createSampler({compare:"less",magFilter:"linear",minFilter:"linear"}),I._shadowParamsUBO=Pm(A,I._config._bias,1/n),I._shadowUBO=wI(A,new Float32Array(80));const Q=I._csmReceiverTexture;Q&&(Q.texture=I._depthTexture,Q.view=I._depthTexture.createView({dimension:"2d-array"}),Q.sampler=I._depthSampler,Q.width=n,Q.height=n,LI(Q)),I._version++;continue}const i=await Promise.resolve().then(()=>(R$(),K9A)),C=i.getEsmShadowTaskResources(I);C||R(722);const o=i.createEsmDirectionalShadowGenerator(A,I._light,{mapSize:I._config._mapSize,depthScale:I._shadowsInfo[2],bias:I._config._bias,blurKernel:C._blurKernel,blurScale:C._blurScale,darkness:I._shadowsInfo[0],frustumEdgeFalloff:I._shadowsInfo[3],orthoMinZ:I._config._orthoMinZ,orthoMaxZ:I._config._orthoMaxZ,forceRefreshEveryFrame:I._config._forceRefreshEveryFrame}),r=i.getEsmShadowTaskResources(o);r||R(723),I._depthTexture=o._depthTexture,I._depthSampler=o._depthSampler,I._lightMatrix=o._lightMatrix,I._shadowsInfo=o._shadowsInfo,I._depthValues=o._depthValues,I._shadowParamsUBO=o._shadowParamsUBO,I._shadowUBO=o._shadowUBO,I._version++,i.setEsmShadowTaskResources(I,r)}}var j9A=b((()=>{rA(),Gt(),zI(),Tr()})),N5=H({createSkeleton:()=>V9A});function V9A(A,e,g,I,i,C,o){const r=A._device,B=I*4,n=r.createTexture({size:[B,1],format:"rgba32float",usage:RA.TEXTURE_BINDING|RA.COPY_DST});r.queue.writeTexture({texture:n},i.buffer,{bytesPerRow:B*16},{width:B,height:1});const Q=new Ag(e.length);for(let p=0;p<e.length;p++)Q[p]=e[p];const E=dg(A,Q,dA.VERTEX),a=dg(A,g,dA.VERTEX);let c=null,l=null;if(C&&o){const p=new Ag(C.length);for(let D=0;D<C.length;D++)p[D]=C[D];c=dg(A,p,dA.VERTEX),l=dg(A,o,dA.VERTEX)}return{boneTexture:n,boneCount:I,jointsBuffer:E,weightsBuffer:a,joints:e,weights:g,boneMatrices:i,joints1Buffer:c,weights1Buffer:l,joints1:C??null,weights1:o??null,_skinBuffers:{jointsBuffer:E,weightsBuffer:a,joints1Buffer:c,weights1Buffer:l}}}var G5=b((()=>{ZA(),te(),yt()})),m5=H({MORPH_WEIGHTS_HEADER_BYTES:()=>16,createMorphTargets:()=>S$,setMorphTargetWeights:()=>N$});function S$(A,e,g,I){const i=e.length,C=new oA(i*g*wK);for(let a=0;a<i;a++){const c=e[a],l=a*g*wK;for(let p=0;p<g;p++){const D=l+p*wK;C[D]=c.positions[p*3],C[D+1]=c.positions[p*3+1],C[D+2]=c.positions[p*3+2],c.normals&&(C[D+3]=c.normals[p*3],C[D+4]=c.normals[p*3+1],C[D+5]=c.normals[p*3+2])}}const o=dg(A,C,dA.STORAGE),r=new ArrayBuffer(16+i*4),B=new Ag(r,0,2);B[0]=i,B[1]=g;const n=new oA(r,16,i);for(let a=0;a<i;a++)n[a]=I?.[a]??0;const Q=dg(A,new He(r),dA.STORAGE),E=new oA(i);return E.set(n),{deltasBuffer:o,count:i,weightsBuffer:Q,targets:e,weights:E}}function N$(A,e,g){if(e._disposed)throw new Error("Cannot update disposed morph targets");const I=Math.min(e.count,g.length);e.weights.fill(0);for(let i=0;i<I;i++)e.weights[i]=g[i]??0;A._device.queue.writeBuffer(e.weightsBuffer,16,e.weights)}var wK,MK=b((()=>{ZA(),te(),yt(),wK=6})),W9A=H({_rebuildMeshes:()=>m$,rebuildRegisteredScenes:()=>z9A,rebuildRenderables:()=>G$});async function z9A(A){A._pbrFallbackTex=void 0;for(const e of A.surfaces)for(const g of e._renderingContexts){if(g._kind!=="scene")continue;const I=g;!DY(e,I)||I._z||await Z9A(A,I)}}async function Z9A(A,e){if(e._envTextures){const{rebuildSceneEnvironment:I}=await Promise.resolve().then(()=>(s9A(),r9A));await QQ("rebuilding environment textures",()=>I(A,e))}if(await QQ("rebuilding material textures",()=>$9A(A,e)),await QQ("rebuilding meshes",()=>m$(A,e)),e._z)return;if(e.shadowGenerators.length>0||e.lights.some(I=>I.shadowGenerator)){const{rebuildSceneShadowGenerators:I}=await Promise.resolve().then(()=>(j9A(),P9A));await QQ("rebuilding shadows",()=>I(A,e))}if(e._z)return;const g=e._renderables.filter(I=>!!I._rebuild).map(I=>I._rebuild);e._renderables.length=e._uniformUpdaters.length=0,e._meshDisposables.clear(),e._lightGpuState&&(e._lightGpuState=void 0);for(const[I,i]of e._groups){const C=await QQ("rebuilding material groups",()=>I(e,i));if(e._z)return;i.r=e._runtimeBuilds?.base(I,C.rebuildSingle)??C.rebuildSingle,i.o=C.renderables,e._renderables.push(...C.renderables),C.updater&&e._uniformUpdaters.push(C.updater)}g.length>0&&e._renderables.push(...await QQ("rebuilding renderables",()=>G$(g))),e._renderables.sort((I,i)=>I.order-i.order),e._renderableVersion++,X9A(A,e),e._frameGraph.build()}async function G$(A){const e=[];for(const g of A)e.push(await g());return e}async function QQ(A,e){try{return await e()}catch(g){const I=g instanceof Error?g.message:String(g);throw new Error(`Device-lost Scene recovery failed while ${A}: ${I}`,{cause:g})}}function X9A(A,e){for(const g of e._frameGraph._tasks){if(!("_sceneUBO"in g&&"_targetSignature"in g&&"_opaqueBindings"in g))continue;const I=g;I._sceneUBO=Lt(A,368),I._lightsUBO=P3(A,e)._buffer,I._sceneBG=A._device.createBindGroup({layout:n1(A),entries:[{binding:0,resource:{buffer:I._sceneUBO}},{binding:1,resource:{buffer:I._lightsUBO}}]}),I._opaqueBindings.length=0,I._directBindings.length=0,I._transparentBindings.length=0,I._ob.length=0,I._lastVersion=-1,I._sceneUboCacheKey.length=0}}async function m$(A,e){let g=null,I=null;for(const i of e.meshes){if(i._cpuPositions&&i._cpuNormals&&i._cpuIndices){const C=i._gpu._recoverShared;i._gpu=C?C(A,i,F$):F$(A,i)}if(i.skeleton){g??=(await Promise.resolve().then(()=>(G5(),N5))).createSkeleton;const C=i.skeleton,o=g(A,C.joints,C.weights,C.boneCount,C.boneMatrices,C.joints1,C.weights1);Object.assign(C,o)}if(i.morphTargets){I??=(await Promise.resolve().then(()=>(MK(),m5))).createMorphTargets;const C=i.morphTargets,o=I(A,C.targets.map(r=>({positions:r.positions,normals:r.normals})),i._cpuPositions?i._cpuPositions.length/3:0,Array.from(C.weights));Object.assign(C,o)}}}function F$(A,e){const g=e._gpu,I=g._drawRangeSource;if(I){const Q=q3(A,I.positions,I.normals,I.indices,I.uvs,I.uvs2,I.tangents,I.colors);return ZZ(Q,{...I}),Q._firstIndex=g._firstIndex,Q._baseVertex=g._baseVertex,Q._vertexCapacity=I.positions.length/3,Q._indexCapacity=I.indices.length,Q}const i=e._cpuPositions,C=e._cpuNormals,o=e._cpuUvs,r=e._cpuGpuIndices??e._cpuIndices,B=A._device;let n;return o&&o.length>0?n=dg(A,o,dA.VERTEX):(n=B.createBuffer({size:i.length/3*8,usage:dA.VERTEX,mappedAtCreation:!0}),n.unmap()),{positionBuffer:dg(A,i,dA.VERTEX),normalBuffer:dg(A,C,dA.VERTEX),tangentBuffer:e._cpuTangents?.length?dg(A,e._cpuTangents,dA.VERTEX):null,uvBuffer:n,uv2Buffer:e._cpuUv2s?dg(A,e._cpuUv2s,dA.VERTEX):null,colorBuffer:e._cpuColors?dg(A,e._cpuColors,dA.VERTEX):null,hasUv:!!o&&o.length>0,hasUv2:!!e._cpuUv2s&&e._cpuUv2s.length>0,hasTangent:!!e._cpuTangents&&e._cpuTangents.length>0,hasColor:!!e._cpuColors&&e._cpuColors.length>0,indexBuffer:dg(A,r,dA.INDEX),indexCount:r.length,indexFormat:e._cpuIndexFormat??e._gpu.indexFormat}}async function $9A(A,e){const g=new Set,I=new WeakSet,i=[],C=r=>{if(!r||typeof r!="object")return;const B=r;if(B.texture&&B.view&&B.sampler&&typeof B.width=="number"&&typeof B.height=="number"){const n=B;g.has(n)||(g.add(n),i.push(n));return}if(!I.has(r)){I.add(r);for(const n of Object.values(B))C(n)}};for(const r of e.meshes)C(r.material);if(i.length===0)return;const{rebuildTexture2D:o}=await Promise.resolve().then(()=>(GY(),NY));await Promise.all(i.map(r=>o(A,r)))}var AUA=b((()=>{te(),lt(),xr(),XZ(),b1(),yt(),s1(),HY(),O3()}));function eUA(A,e={}){return v3(A,{_kind:"scene",_recoverOrder:100,_enable(g){PZ(g,!0)},_disable(g){OZ(g,!0)},async _recover(g){const{rebuildRegisteredScenes:I}=await Promise.resolve().then(()=>(AUA(),W9A));await I(g)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function gUA(A){F5=A}function zi(){return F5}function b$(A){b5=A}function Pr(){return b5}var F5,b5,NC=b((()=>{F5=null,b5=null}));function RK(A,e){const g=e.cellWidthPx,I=e.cellHeightPx,i=e.marginPx??0,C=e.spacingPx??0,o=e.columns??Math.max(1,Math.floor((A.width-i*2+C)/(g+C))),r=e.rows??Math.max(1,Math.floor((A.height-i*2+C)/(I+C))),B=e.pivot??[.5,.5],n=A.width,Q=A.height,E=[];for(let a=0;a<r;a++)for(let c=0;c<o;c++){const l=i+c*(g+C),p=i+a*(I+C);E.push({uvMin:[l/n,p/Q],uvMax:[(l+g)/n,(p+I)/Q],sourceSizePx:[g,I],pivot:[B[0],B[1]]})}return{texture:A,textureSizePx:[n,Q],frames:E,premultipliedAlpha:e.premultipliedAlpha??!1}}async function IUA(A,e,g={}){return g.metadataUrl!==void 0&&R(750),g.gridSize||R(751),RK(await AQ(A,e,{invertY:!1,addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",mipMaps:!1,minFilter:g.sampling==="nearest"?"nearest":"linear",magFilter:g.sampling==="nearest"?"nearest":"linear",premultiplyAlpha:g.premultiplyOnLoad??!1,...g.textureOptions}),{cellWidthPx:g.gridSize[0],cellHeightPx:g.gridSize[1],premultipliedAlpha:g.premultipliedAlpha??!1})}function eF(A,e){return(e<0||e>=A.frames.length)&&R(752,e,A.frames.length),e}function tUA(A){A.texture.texture.destroy()}var gF=b((()=>{rA(),MC()})),k5,K5,k$=b((()=>{k5={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},K5={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}})),K$,SK,U$,U5,v5,v$,L5=b((()=>{k$(),K$={_key:"opaque"},SK={_key:"alpha",_descriptor:k5},U$={_key:"premultiplied",_descriptor:K5,_premultipliedOpacity:!0},U5={_key:"additive",_descriptor:{color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}},v5={_key:"oneone",_descriptor:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}},v$={_key:"multiply",_descriptor:{color:{srcFactor:"dst",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"dst-alpha",dstFactor:"zero",operation:"add"}}}}));function iUA(A){x5=A}function EQ(){return x5}function Y5(A,e={}){const g=e.depth??"none",I=e.blendMode??SK,i=Math.max(1,e.capacity??H$),C={positionPx:[e.view?.positionPx?.[0]??0,e.view?.positionPx?.[1]??0],zoom:e.view?.zoom??1,rotation:e.view?.rotation??0},o=g==="none"?13:14,r=o*4,B=new oA(i*o),n={_entityType:"sprite-2d-layer",atlas:A,depth:g,blendMode:I,opacity:e.opacity??1,visible:e.visible??!0,order:e.order??0,view:C,pivot:[e.pivot?.[0]??.5,e.pivot?.[1]??.5],layerZ:e.layerZ??.5,count:0,_capacity:i,_instanceFloatsPerSprite:o,_instanceStrideBytes:r,_instanceData:B,_savedSize:new oA(i*2),_version:0,_dirtyMin:0,_dirtyMax:0};return zi()?.initLayer(n,e),n}function CUA(A,e){const g=A.shaderParams??=[0,0,0,0];g[0]=e[0],g[1]=e[1],g[2]=e[2],g[3]=e[3]}function oUA(A,e){let g=A._capacity;for(;g<e;)g*=2;const I=new oA(g*A._instanceFloatsPerSprite);I.set(A._instanceData),A._instanceData=I;const i=new oA(g*2);i.set(A._savedSize),A._savedSize=i,A._capacity=g}function NK(A,e){A.count=e}function L$(A,e,g,I){const i=A._instanceData,C=e*A._instanceFloatsPerSprite,o=e*2,r=I===null,B=g.frame!==void 0?A.atlas.frames[eF(A.atlas,g.frame)]:null,n=g.positionPx?g.positionPx[0]:I[0],Q=g.positionPx?g.positionPx[1]:I[1];let E,a;g.sizePx?(E=g.sizePx[0],a=g.sizePx[1]):B?(E=B.sourceSizePx[0],a=B.sourceSizePx[1]):r?(E=0,a=0):(E=A._savedSize[o],a=A._savedSize[o+1]),A._savedSize[o]=E,A._savedSize[o+1]=a;let c;g.visible!==void 0?c=g.visible:r?c=!0:c=I[2]!==0||I[3]!==0;let l,p,D,u;B?(l=B.uvMin[0],p=B.uvMin[1],D=B.uvMax[0],u=B.uvMax[1]):r?(l=0,p=0,D=1,u=1):(l=I[4],p=I[5],D=I[6],u=I[7]);const _=l>D,d=p>u,y=!r&&I[4]>I[6],h=!r&&I[5]>I[7],w=g.flipX!==void 0?g.flipX===!0:y,M=g.flipY!==void 0?g.flipY===!0:h;if(_!==w){const m=l;l=D,D=m}if(d!==M){const m=p;p=u,u=m}const N=g.rotation??(I?I[8]:0),S=A.depth!=="none",G=S?g.z??(I?I[13]:A.layerZ):0;i[C+0]=n,i[C+1]=Q,i[C+2]=c?E:0,i[C+3]=c?a:0,i[C+4]=l,i[C+5]=p,i[C+6]=D,i[C+7]=u,i[C+8]=N,g.color?(i[C+9]=g.color[0],i[C+10]=g.color[1],i[C+11]=g.color[2],i[C+12]=g.color[3]):r&&(i[C+9]=1,i[C+10]=1,i[C+11]=1,i[C+12]=1),S&&(i[C+13]=G)}function IF(A,e,g){A._dirtyMin>=A._dirtyMax?(A._dirtyMin=e,A._dirtyMax=g):(e<A._dirtyMin&&(A._dirtyMin=e),g>A._dirtyMax&&(A._dirtyMax=g)),A._version=A._version+1|0,EQ()?.dirty(A,e,g)}function jn(A,e,g){IF(A,e,g)}function Y$(A,e){e.positionPx===void 0&&R(766);const g=A.count;return g>=A._capacity&&oUA(A,g+1),L$(A,g,e,null),A._vertexExtension?._initInstance(A._instanceData,g*A._instanceFloatsPerSprite),NK(A,A.count+1),EQ()?.add(A,g),IF(A,g,g+1),g}function J$(A,e,g){(e<0||e>=A.count)&&R(767,e,A.count);const I=e*A._instanceFloatsPerSprite;L$(A,e,g,A._instanceData.subarray(I,I+A._instanceFloatsPerSprite)),IF(A,e,e+1)}function J5(A,e){(e<0||e>=A.count)&&R(768,e,A.count);const g=A.count-1;A._handleHooks?.removeIndex(e,g),e!==g&&(A._instanceData.copyWithin(e*A._instanceFloatsPerSprite,g*A._instanceFloatsPerSprite,(g+1)*A._instanceFloatsPerSprite),A._savedSize.copyWithin(e*2,g*2,(g+1)*2)),A._savedSize[g*2]=0,A._savedSize[g*2+1]=0,NK(A,g),EQ()?.remove(A,e,g),IF(A,e,e+1)}function rUA(A){const e=A.count;A._dirtyMin=0,A._dirtyMax=0,A._handleHooks?.clear(),e!==0&&(A._savedSize.fill(0,0,e*2),NK(A,0),EQ()?.clear(A,e),A._version=A._version+1|0)}function H5(A,e,g){(e<0||e>=A.count)&&R(769,e,A.count);const I=eF(A.atlas,g),i=A.atlas.frames[I],C=e*A._instanceFloatsPerSprite,o=A._instanceData[C+4]>A._instanceData[C+6],r=A._instanceData[C+5]>A._instanceData[C+7];A._instanceData[C+4]=o?i.uvMax[0]:i.uvMin[0],A._instanceData[C+5]=r?i.uvMax[1]:i.uvMin[1],A._instanceData[C+6]=o?i.uvMin[0]:i.uvMax[0],A._instanceData[C+7]=r?i.uvMin[1]:i.uvMax[1],IF(A,e,e+1)}var x5,H$,GC=b((()=>{rA(),ZA(),gF(),NC(),L5(),x5=null,H$=16}));function BUA(A){q5=A}function T5(){return q5}var q5,x$=b((()=>{q5=null}));function nUA(A){P5=A}function Vn(){return P5}var P5,Wn=b((()=>{P5=null}));function sUA(A,e,g){return`${O5(A,e,g)} @fragment fn fs(in:O)->@location(0)vec4f{let s=textureSample(atlasTex,atlasSamp,in.uv);return s*in.tint*L.opacityMul;}`}function O5(A,e,g=!1,I){const i=`@group(${e})`,C=A?",@location(6)z:f32":"",o=g?",@location(7)o:vec2f":"",r=A?"1 - in.z":"0";return`struct Lr{viewPos:vec2f,viewScale:f32,viewRot:f32,screenSize:vec2f,pivot:vec2f,opacityMul:vec4f,aa:vec4f,};${i} @binding(0)var<uniform>L:Lr;${i} @binding(1)var atlasTex:texture_2d<f32>;${i} @binding(2)var atlasSamp:sampler;struct I{@builtin(vertex_index)vid:u32,@location(0)p:vec2f,@location(1)s:vec2f,@location(2)a:vec2f,@location(3)b:vec2f,@location(4)r:f32,@location(5)c:vec4f${C}${o}${I?._input??""}};struct O{@builtin(position)p:vec4f,@location(0)uv:vec2f,@location(1)tint:vec4f,${I?._output??""}};@vertex fn vs(in:I)->O{var q=array<vec2f,4>(vec2f(0,0),vec2f(1,0),vec2f(1,1),vec2f(0,1));let c=q[in.vid];let l=(c-L.pivot)*in.s;let cr=cos(in.r);let sr=sin(in.r);let r=vec2f(l.x*cr-l.y*sr,l.x*sr+l.y*cr);let p=in.p+r-L.viewPos;let lc=cos(L.viewRot);let ls=sin(L.viewRot);let v=vec2f(p.x*lc-p.y*ls,p.x*ls+p.y*lc)*L.viewScale;let n=vec2f(v.x/L.screenSize.x*2-1,1-v.y/L.screenSize.y*2);let uv=mix(in.a,in.b,c)${g?" + in.o":""};var out:O;out.p=vec4f(n,${r},1);out.uv=uv;out.tint=in.c;${I?._assignment??""} return out;}`}function T$(){return{_devices:new WeakMap}}function q$(A){A._devices=new WeakMap}function QUA(){return aQ??=T$(),mK++,aQ}function P$(){mK>0&&--mK===0&&aQ&&(q$(aQ),aQ=null)}function tF(A,e,g,I,i,C,o=!1,r,B,n,Q="greater-equal"){const E=EUA(A,e),a=aUA(C,r),c=Vn(),l=C&&o&&I>1&&!!n&&!!c?.(n),p=cUA(g,I,i,C,o,a,l,n,Q),D=E._pipelines.get(p);if(D)return D;const u=pUA(A,E,g,I,i,C,o,a,l,B,n,Q);return E._pipelines.set(p,u),u}function O$(A,e,g,I,i,C){const o=I.atlas.texture,r=[{binding:0,resource:{buffer:i}},{binding:1,resource:o.view},{binding:2,resource:o.sampler}];if(C)for(const B of zi().bindEntries(C,3))r.push(B);return A._device.createBindGroup({layout:e.getBindGroupLayout(g),entries:r})}function EUA(A,e){let g=e._devices.get(A._device);return g||(g={_shaderModules:new Map,_pipelines:new Map},e._devices.set(A._device,g)),g}function aUA(A,e){return A?(e||R(781),e):null}function cUA(A,e,g,I,i,C,o,r,B="greater-equal"){const n=r?zi()?.pipelineKeyPart(r)??"":"",Q=r?._uvScrollAttr?"1":"0",E=r?T5()?.pipelineKeyPart(r)??"0":"0";return`${A}:${e}:${g._key}:${I?1:0}:${i?1:0}:${C??"-"}:${I?B:"-"}:${o?"a":"n"}:cs${n}:uv${Q}:cg${E}`}function lUA(A,e,g,I){const i=I?zi()?.shaderModule(A,g,I):null;if(i)return i;const C=I?T5()?.shaderModule(A,g,I):null;if(C)return C;const o=I?._uvScrollAttr!=null,r=`${g?1:0}:${o?1:0}`;let B=e._shaderModules.get(r);return B||(B=A._device.createShaderModule({code:sUA(g,g?1:0,o)}),e._shaderModules.set(r,B)),B}function pUA(A,e,g,I,i,C,o,r,B,n,Q,E="greater-equal"){const a=A._device,c=[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:MA.FRAGMENT,sampler:{type:"filtering"}}],l=Q?zi()?.layoutEntries(Q,3):null;if(l)for(const w of l)c.push(w);const p=a.createBindGroupLayout({entries:c}),D=lUA(A,e,C,Q);C&&!n&&R(782);const u=C?[n,p]:[p],_=[{shaderLocation:0,offset:Z$,format:"float32x2"},{shaderLocation:1,offset:X$,format:"float32x2"},{shaderLocation:2,offset:$$,format:"float32x2"},{shaderLocation:3,offset:AAA,format:"float32x2"},{shaderLocation:4,offset:eAA,format:"float32"},{shaderLocation:5,offset:gAA,format:"float32x4"}];C&&_.push({shaderLocation:6,offset:IAA,format:"float32"}),Q?._uvScrollAttr&&_.push(Q._uvScrollAttr);const d=Q?zi()?.vertexAttribute(Q):null;d&&_.push(d);const y=Q?._instanceStrideBytes??(C?56:52),h={layout:a.createPipelineLayout({bindGroupLayouts:u}),vertex:{module:D,entryPoint:"vs",buffers:[{arrayStride:y,stepMode:"instance",attributes:_}]},fragment:{module:D,entryPoint:"fs",targets:[{format:g,blend:i._descriptor,writeMask:yC.ALL}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:B?{count:I,alphaToCoverageEnabled:!0}:{count:I}};return C&&(h.depthStencil={format:r,depthCompare:E,depthWriteEnabled:o}),a.createRenderPipeline(h)}function GK(A,e,g){return A.createBuffer({size:e._capacity*e._instanceStrideBytes,usage:dA.VERTEX|dA.COPY_DST,label:g})}function j$(A,e,g,I,i){const C=e._capacity*e._instanceStrideBytes;return g.size>=C?{buffer:g,capacity:I,reallocated:!1}:(g.destroy(),{buffer:GK(A,e,i),capacity:e._capacity,reallocated:!0})}function V$(A,e,g,I){const i=EQ()?.upload(A,e,g,I);if(i!==void 0)return i;if(I===e._version)return I;if(e.count===0)return e._dirtyMin=0,e._dirtyMax=0,e._version;let C,o;if(I===-1?(C=0,o=e.count):(C=e._dirtyMin,o=Math.min(e._dirtyMax,e.count)),o>C){const r=C*e._instanceStrideBytes,B=(o-C)*e._instanceStrideBytes;A.queue.writeBuffer(g,r,e._instanceData.buffer,e._instanceData.byteOffset+r,B)}return e._dirtyMin=0,e._dirtyMax=0,e._version}function W$(A,e,g,I){I[0]=A.view.positionPx[0],I[1]=A.view.positionPx[1],I[2]=A.view.zoom,I[3]=A.view.rotation,I[4]=e,I[5]=g,I[6]=A.pivot[0],I[7]=A.pivot[1];const i=A.opacity;A.blendMode._premultipliedOpacity?(I[8]=i,I[9]=i,I[10]=i,I[11]=i):(I[8]=1,I[9]=1,I[10]=1,I[11]=i),T5()?.writeUbo(A,I)}function z$(A,e,g,I,i){let C=!i;if(!C){for(let o=0;o<16;o++)if(I[o]!==g[o]){C=!0;break}}return C&&(A.queue.writeBuffer(e,0,g.buffer,g.byteOffset,64),I.set(g)),!0}var Z$,X$,$$,AAA,eAA,gAA,IAA,aQ,mK,FK,iF=b((()=>{rA(),ZA(),te(),GC(),NC(),x$(),Wn(),Z$=0,X$=8,$$=16,AAA=24,eAA=32,gAA=36,IAA=52,aQ=null,mK=0,FK=new ni([0,1,2,0,2,3])})),DUA=H({rebuildRegisteredSpriteRenderers:()=>uUA});async function uUA(A){const e=[],g=new Set;for(const I of A.surfaces)for(const i of I._renderingContexts){if(i._kind!=="sprite-renderer")continue;const C=i;e.push(C),C._target&&g.add(C._target);for(const o of C.layers){g.add(o.atlas.texture);for(const r of o.customShader?._extraTextures??[])g.add(r.texture)}}if(g.size>0){const{rebuildTexture2D:I}=await Promise.resolve().then(()=>(GY(),NY));await Promise.all(Array.from(g,i=>I(A,i)))}for(const I of e)_UA(I)}function _UA(A){const e=A._surface.engine,g=zi();A._indexBuffer=dg(e,FK,dA.INDEX),A._targetView=A._target?.view??null,A._visibleBundles.length=0;for(const I of A._layerGpu.values())I.instanceBuffer=GK(e._device,I.layer),I.instanceBufferCapacity=I.layer._capacity,I.uniformBuffer=Lt(e,64),I.bindGroup=null,I.uploadedVersion=-1,I.fx&&(g.disposeFx(I.fx),I.fx=g.createLayerFx(e,"sprite-layer-fx-ubo",I.layer)),I.pipeline=null,I.lastUbo.fill(0),I.uboUploaded=!1,I.renderBundle=null,I.bundleCount=-1;for(const I of A.layers)tF(e,A._pipelineCache,A._surface.format,1,I.blendMode,!1,!1,void 0,void 0,I)}var dUA=b((()=>{te(),b1(),yt(),NC(),iF()}));function fUA(A,e={}){return v3(A,{_kind:"sprite-renderer",_enable:PZ,_disable:OZ,async _recover(g){const{rebuildRegisteredSpriteRenderers:I}=await Promise.resolve().then(()=>(dUA(),DUA));await I(g)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function yUA(A){KK=A}function j5(A){return KK?._key(A)??A.curveSet}function hUA(A,e,g,I,i,C,o,r){const B=I._atlas._glyphSlots.get(i);if(!B)return!1;const n=B._index;if(n>Z5||r>Z5)return!1;const Q=g*3;return A[Q]=C,A[Q+1]=o,e[Q+2]=n|r<<16,!0}function tAA(A,e,g){const I=g*3;A[I]=0,A[I+1]=0,e[I+2]=_AA}function iAA(A,e){e>cQ&&R(787,cQ);const g=e*8;if(A._styles.length>=g)return;let I=Math.max(A._styles.length*2,8);for(;I<g;)I*=2;I=Math.min(I,cQ*8);const i=new Float32Array(I);i.set(A._styles),A._styles=i}function CF(A){const e=A.glyphs;let g=1;for(let I=0;I<e.length;I++)e[I].color!==void 0&&g++;return g}function CAA(A,e){for(let g=0;g<e.length;g++)A._freeStyleSlots.push(e[g])}function oAA(A,e,g){if(g?.length===e)return g;const I=A._freeStyleSlots,i=Math.max(0,e-I.length-(g?.length??0));iAA(A,A._styleCount+i),g&&CAA(A,g);const C=A._styleCount,o=new Array(e);for(let r=0;r<e;r++)o[r]=I.pop()??A._styleCount++;return A._styleCount!==C&&A._styleVersion++,o}function rAA(A,e,g,I,i){const C=e*8,o=A._styles,r=Math.fround(g[0]),B=Math.fround(g[1]),n=Math.fround(g[2]),Q=Math.fround(g[3]),E=Math.fround(I),a=Math.fround(i);o[C]===r&&o[C+1]===B&&o[C+2]===n&&o[C+3]===Q&&o[C+4]===E&&o[C+5]===a||(o[C]=r,o[C+1]=B,o[C+2]=n,o[C+3]=Q,o[C+4]=E,o[C+5]=a,A._styleVersion++)}function wUA(A,e){const g=e*3;if(A._instances.length>=g)return;let I=Math.max(A._instances.length*2,3);for(;I<g;)I*=2;const i=new Float32Array(I);i.set(A._instances.subarray(0,A._instanceCount*3)),A._instances=i,A._instancesU32=new Uint32Array(i.buffer),A._dirtyStart=0,A._dirtyEnd=A._instanceCount}function bK(A,e,g){g<=e||(A._dirtyStart===A._dirtyEnd?(A._dirtyStart=e,A._dirtyEnd=g):(e<A._dirtyStart&&(A._dirtyStart=e),g>A._dirtyEnd&&(A._dirtyEnd=g)),A._version++)}function MUA(A){return A._freeSlots.length>0?A._freeSlots.pop():-1}function BAA(A,e,g,I){for(const i of A._groups)if(i!==I&&i._slotStart>=e){i._slotStart+=g;for(let C=0;C<i._freeSlots.length;C++)i._freeSlots[C]=i._freeSlots[C]+g}for(const i of A._runRecords.values()){const C=i._slots;for(let o=0;o<C.length;o++)C[o]>=e&&(C[o]=C[o]+g)}A._layoutVersion++}function RUA(A,e,g){const I=e._slotStart+e._slotCount;if(g<=0)return I;wUA(A,A._instanceCount+g);const i=g*3,C=I*3,o=A._instanceCount*3;return o>C&&A._instances.copyWithin(C+i,C,o),BAA(A,I,g,e),A._instanceCount+=g,e._slotCount+=g,bK(A,I,A._instanceCount),I}function nAA(A,e,g){const I=new Array(g).fill(-1);let i=!0,C=-1,o=g;for(let r=0;r<g;r++){const B=MUA(e);if(B===-1){o=r;break}I[r]=B,i&&=B>=C,C=B}if(o<g){const r=RUA(A,e,g-o);i&&=r>=C;for(let B=o,n=r;B<g;B++)I[B]=n++}return i||I.sort(SUA),I}function SUA(A,e){return A-e}function sAA(A,e,g){let I=Number.POSITIVE_INFINITY,i=-1;for(const C of g)tAA(A._instances,A._instancesU32,C),e._freeSlots.push(C),C<I&&(I=C),C>i&&(i=C);i>=0&&bK(A,I,i+1)}function NUA(A,e){for(const g of A._groups)if(g._groupKey===e)return g}function kK(A,e,g){const I=A._curveSets.get(e);return I||R(788,g,e),I}function QAA(A,e,g,I){return{_curveSetId:A,_curveSet:e,_slotStart:g,_slotCount:0,_liveCount:0,_freeSlots:[],_bindGroup:null,_bindGroupVersion:-1,_groupKey:I}}function GUA(A,e,g){const I=NUA(A,g);if(I)return I;const i=QAA(e,kK(A._storage,e,"addRun"),A._instanceCount,g);return A._groups.push(i),i}function V5(A,e,g,I,i){const C=g.pixelsPerFontUnit,o=C!==0?1/C:0,r=KK?._param(g)??0,B=i[0];rAA(A,B,g.defaultColor??dAA,o,r);let n=0,Q=null,E=Number.POSITIVE_INFINITY,a=-1;for(let c=0;c<g.glyphs.length;c++){const l=g.glyphs[c],p=I[c];let D=B;const u=l.color;u!==void 0&&(D=i[++n],rAA(A,D,u,o,r)),hUA(A._instances,A._instancesU32,p,e._curveSet,l.glyphId,l.x,l.y,D)?Q!==null&&Q.push(p):(Q===null&&(Q=I.slice(0,c)),tAA(A._instances,A._instancesU32,p),e._freeSlots.push(p)),p<E&&(E=p),p>a&&(a=p)}return a>=0&&bK(A,E,a+1),Q??I}function EAA(A,e,g){let I=0,i=0;for(const E of e)I+=E.glyphs.length,i+=CF(E);iAA(A,i);const C=I*3;if(A._instances.length<C){let E=Math.max(A._instances.length*2,3);for(;E<C;)E*=2;A._instances=new Float32Array(E),A._instancesU32=new Uint32Array(A._instances.buffer)}const o=new Map;for(const E of A._groups)o.set(E._groupKey,E);A._storage=g;const r=new Map;for(const E of e){const a=j5(E);let c=r.get(a);c||(c=[],r.set(a,c)),c.push(E)}const B=[],n=new Map;let Q=0;A._styleCount=0,A._freeStyleSlots.length=0,A._styleVersion++;for(const[E,a]of r){const c=a[0].curveSet,l=kK(g,c,"reset"),p=o.get(E)??QAA(c,l,Q,E);p._curveSet!==l&&(p._curveSet=l,p._bindGroup=null,p._bindGroupVersion=-1),p._slotStart=Q,p._freeSlots=[];const D=B.length;let u=0;for(const _ of a){const d=new Array(_.glyphs.length).fill(-1);for(let M=0;M<_.glyphs.length;M++)d[M]=Q++;const y=CF(_),h=new Array(y);for(let M=0;M<y;M++)h[M]=A._styleCount++;const w=V5(A,p,_,d,h);u+=w.length,n.set(_,{_run:_,_groupIdx:D,_slots:w,_styleSlots:h})}p._slotCount=Q-p._slotStart,p._liveCount=u,B.push(p)}A._instanceCount=Q,A._groups=B,A._runs.length=0;for(const E of e)A._runs.push(E);A._runRecords=n,A._dirtyStart=0,A._dirtyEnd=Q,A._version++,A._layoutVersion++}function aAA(A,e){return typeof e=="number"?cAA(A,e,"updateTextData"):e}function cAA(A,e,g){if(typeof e=="number"){const I=A._runs[e];return I||R(789,g,e,A._runs.length-1),I}return A._runRecords.has(e)||R(790,g),e}function W5(A,e){return typeof e=="number"?e:A._runs.indexOf(e)}function lAA(A,e,g){A._runRecords.has(e)&&R(791);const I=g??A._runs.length;kK(A._storage,e.curveSet,"addRun");const i=oAA(A,CF(e)),C=GUA(A,e.curveSet,j5(e)),o=A._groups.indexOf(C),r=V5(A,C,e,nAA(A,C,e.glyphs.length),i);C._liveCount+=r.length,A._runRecords.set(e,{_run:e,_groupIdx:o,_slots:r,_styleSlots:i}),A._runs.splice(I,0,e)}function pAA(A,e){const g=aAA(A,e),I=A._runRecords.get(g);I||R(792);const i=A._groups[I._groupIdx];sAA(A,i,I._slots),i._liveCount-=I._slots.length,CAA(A,I._styleSlots),A._runRecords.delete(g);const C=W5(A,e);C>=0&&A._runs.splice(C,1),i._liveCount===0&&mUA(A,i)}function mUA(A,e){const g=A._groups.indexOf(e);if(g<0)return;const I=e._slotStart,i=e._slotCount;A._groups.splice(g,1);for(const C of A._runRecords.values())C._groupIdx>g&&C._groupIdx--;if(i>0){const C=i*3,o=(I+i)*3,r=A._instanceCount*3;r>o&&A._instances.copyWithin(o-C,o,r),BAA(A,I,-i),A._instanceCount-=i,bK(A,I,A._instanceCount)}}function FUA(A,e,g){const I=aAA(A,e),i=A._runRecords.get(I);i||R(793),I!==g&&A._runRecords.has(g)&&R(794);const C=A._groups[i._groupIdx];if(j5(g)===C._groupKey&&g.glyphs.length>0){const r=oAA(A,CF(g),i._styleSlots),B=i._slots.length;let n=i._slots;g.glyphs.length!==B&&(sAA(A,C,n),n=nAA(A,C,g.glyphs.length));const Q=V5(A,C,g,n,r);if(C._liveCount+=Q.length-B,I===g)i._slots=Q,i._styleSlots=r;else{A._runRecords.delete(I),A._runRecords.set(g,{_run:g,_groupIdx:i._groupIdx,_slots:Q,_styleSlots:r});const E=W5(A,e);E>=0&&(A._runs[E]=g)}return}const o=W5(A,e);kK(A._storage,g.curveSet,"replaceRun"),CF(g)>A._freeStyleSlots.length+i._styleSlots.length+cQ-A._styleCount&&R(795,cQ),pAA(A,o>=0?o:I),lAA(A,g,o>=0?o:void 0)}function DAA(A,e){const g=[],I=new Float32Array(3),i={runs:g,_runs:g,_groups:[],_runRecords:new Map,_instances:I,_instancesU32:new Uint32Array(I.buffer),_instanceCount:0,_styles:new Float32Array(8),_styleCount:0,_freeStyleSlots:[],_styleVersion:1,_storage:A,_version:1,_layoutVersion:0,_dirtyStart:0,_dirtyEnd:0};return e&&e.length>0&&EAA(i,e,A),i}function z5(A,e){switch(e.update){case"reset":EAA(A,e.runs??A._runs.slice(),e.storage??A._storage);return;case"addRun":lAA(A,e.run,e.insertBefore);return;case"removeRun":pAA(A,e.run);return;case"replaceRun":FUA(A,e.previous,e.run);return}}function uAA(A){for(const e of A._groups)e._bindGroup=null;A._groups=[],A._instanceCount=0,A._styleCount=0,A._freeStyleSlots.length=0,A._runs.length=0,A._runRecords.clear()}var _AA,Z5,cQ,dAA,KK,Or=b((()=>{rA(),_AA=4294967295,Z5=65534,cQ=65535,dAA=[1,1,1,1],KK=null}));function UK(A,e){return A.createBuffer({label:"text-styles",size:e*32,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})}function fAA(A,e,g){const I=Math.max(1,e._styleCount);let i=!1;if(I*32>g._styleBuf.size&&(g._styleBuf.destroy(),g._styleBuf=UK(A,e._styles.byteLength/32),g._uploadedStyleVersion=-1,i=!0),g._uploadedStyleVersion!==e._styleVersion){if(e._styleCount>0){const C=e._styles;A.queue.writeBuffer(g._styleBuf,0,C.buffer,C.byteOffset,e._styleCount*32)}g._uploadedStyleVersion=e._styleVersion}return i}var X5=b((()=>{Or()}));function yAA(A){const e=new Map;if(A)for(const[g,I]of A)e.set(g,MAA(I));return{_curveSets:e}}function hAA(A,e,g){let I=A._curveSets.get(e);I||(I=MAA(new Map),A._curveSets.set(e,I));for(const[i,C]of g)I._curves.has(i)||(I._curves.set(i,C),I._atlas._glyphSlots.set(i,SAA(I._atlas,C)))}function wAA(A){for(const e of A._curveSets.values()){const g=e._atlas._gpu;g&&(g._curveTex.destroy(),g._bandTex.destroy(),g._metaBuf.destroy(),e._atlas._gpu=null)}A._curveSets.clear()}function bUA(){return{_curveTexData:new Float32Array(lQ),_curveTexelsUsed:0,_bandTexData:new Float32Array(lQ),_bandTexelsUsed:0,_glyphSlots:new Map,_metaData:new Float32Array(192),_slotCount:0,_version:0,_gpu:null}}function MAA(A){const e=bUA();for(const[g,I]of A)e._glyphSlots.set(g,SAA(e,I));return{_curves:A,_atlas:e}}function RAA(A,e){const g=e*4;if(A.length>=g)return A;let I=Math.max(A.length*2,lQ);for(;I<g;)I*=2;I=Math.ceil(I/lQ)*lQ;const i=new Float32Array(I);return i.set(A),i}function SAA(A,e){const g=KUA(e),I=e.curves;let i=A._curveTexelsUsed;const C=new Array(I.length);for(let K=0;K<I.length;K++){const U=i/mC|0,Y=(i+1)/mC|0;U!==Y&&(i=Y*mC),C[K]=i,i+=2}const o=i;A._curveTexData=RAA(A._curveTexData,o);const r=A._curveTexData;for(let K=0;K<I.length;K++){const U=I[K],Y=C[K],x=Y*4;r[x]=U.p0x,r[x+1]=U.p0y,r[x+2]=U.p1x,r[x+3]=U.p1y;const q=(Y+1)*4;r[q]=U.p2x,r[q+1]=U.p2y}A._curveTexelsUsed=o;const B=g._hBandCount+g._vBandCount;let n=A._bandTexelsUsed;n%4096+B>4096&&(n=((n/mC|0)+1)*mC);const Q=n%mC,E=n/mC|0,a=[...g._hBands,...g._vBands];let c=B;const l=new Array(a.length);for(let K=0;K<a.length;K++)l[K]=c,c+=a[K]._curveIndices.length;const p=n+c;A._bandTexData=RAA(A._bandTexData,p);const D=A._bandTexData;for(let K=0;K<a.length;K++){const U=(n+K)*4;D[U]=a[K]._curveIndices.length,D[U+1]=l[K]}for(let K=0;K<a.length;K++){const U=a[K],Y=n+l[K];for(let x=0;x<U._curveIndices.length;x++){const q=C[U._curveIndices[x]],j=q%mC,X=q/mC|0,Z=(Y+x)*4;D[Z]=j,D[Z+1]=X}}A._bandTexelsUsed=p,A._version++;const{xMin:u,yMin:_,xMax:d,yMax:y}=e.bounds,h=d-u,w=y-_,M=h>0?g._vBandCount/h:0,N=w>0?g._hBandCount/w:0,S=A._slotCount++,G=A._slotCount*12;if(A._metaData.length<G){const K=new Float32Array(Math.max(A._metaData.length*2,G));K.set(A._metaData),A._metaData=K}const m=S*12,k=A._metaData;return k[m]=u,k[m+1]=_,k[m+2]=d,k[m+3]=y,k[m+4]=Q,k[m+5]=E,k[m+6]=g._vBandCount-1,k[m+7]=g._hBandCount-1,k[m+8]=M,k[m+9]=N,k[m+10]=-u*M,k[m+11]=-_*N,{_index:S}}function oF(A,e){const g=A[e];if(!g)throw new Error("buildGlyphBands: invalid curve index");return g}function kUA(A){const{curves:e,bounds:g}=A,I=Math.max(1,Math.min(8,Math.floor(e.length/2))),{xMin:i,yMin:C,xMax:o,yMax:r}=g,B=o-i,n=r-C,Q=n/I,E=B/I,a=[],c=[];for(let l=0;l<I;l++)a.push({_curveIndices:[]}),c.push({_curveIndices:[]});for(let l=0;l<e.length;l++){const p=oF(e,l),D=Math.min(p.p0y,p.p1y,p.p2y),u=Math.max(p.p0y,p.p1y,p.p2y),_=Math.min(p.p0x,p.p1x,p.p2x),d=Math.max(p.p0x,p.p1x,p.p2x);if(n>0)for(let y=0;y<I;y++){const h=C+y*Q,w=C+(y+1)*Q;u>=h&&D<=w&&a[y]._curveIndices.push(l)}if(B>0)for(let y=0;y<I;y++){const h=i+y*E,w=i+(y+1)*E;d>=h&&_<=w&&c[y]._curveIndices.push(l)}}for(const l of a)l._curveIndices.sort((p,D)=>{const u=oF(e,p),_=oF(e,D);return Math.max(_.p0x,_.p1x,_.p2x)-Math.max(u.p0x,u.p1x,u.p2x)});for(const l of c)l._curveIndices.sort((p,D)=>{const u=oF(e,p),_=oF(e,D);return Math.max(_.p0y,_.p1y,_.p2y)-Math.max(u.p0y,u.p1y,u.p2y)});return{_hBands:a,_vBands:c,_hBandCount:I,_vBandCount:I}}function KUA(A){return A._bands??=kUA(A)}var mC,lQ,$5=b((()=>{mC=4096,lQ=mC*4}));function pQ(A){let e=1;for(;e<A;)e<<=1;return e}function NAA(A,e){return A.createBuffer({label:"text-glyph-metadata",size:e*g6,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})}function A6(A){return A<=0?1:Math.ceil(A/rF)}function vK(A,e,g){return A.createTexture({label:g,format:"rgba32float",size:{width:rF,height:e,depthOrArrayLayers:1},usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC})}function GAA(A,e,g,I){if(I===0)return;const i=A6(I);A.queue.writeTexture({texture:e},g.buffer,{offset:g.byteOffset,bytesPerRow:mAA,rowsPerImage:i},{width:rF,height:i,depthOrArrayLayers:1})}function e6(A,e){let g=e._gpu;const I=A6(e._curveTexelsUsed),i=A6(e._bandTexelsUsed),C=Math.max(1,e._slotCount);g&&g._device!==A&&(g._curveTex.destroy(),g._bandTex.destroy(),g._metaBuf.destroy(),g=null);let o=!1;if(g)I>g._curveTexRows&&(g._curveTex.destroy(),g._curveTexRows=pQ(I),g._curveTex=vK(A,g._curveTexRows,"text-slug-curves"),g._uploadedVersion=-1,o=!0),i>g._bandTexRows&&(g._bandTex.destroy(),g._bandTexRows=pQ(i),g._bandTex=vK(A,g._bandTexRows,"text-slug-bands"),g._uploadedVersion=-1,o=!0),C>g._metaCap&&(g._metaBuf.destroy(),g._metaCap=pQ(C),g._metaBuf=NAA(A,g._metaCap),g._uploadedVersion=-1,o=!0);else{const r=pQ(Math.max(1,I)),B=pQ(Math.max(1,i)),n=pQ(C);g={_device:A,_curveTex:vK(A,r,"text-slug-curves"),_bandTex:vK(A,B,"text-slug-bands"),_curveTexRows:r,_bandTexRows:B,_metaBuf:NAA(A,n),_metaCap:n,_uploadedVersion:-1},e._gpu=g,o=!0}if(g._uploadedVersion!==e._version){if(GAA(A,g._curveTex,e._curveTexData,e._curveTexelsUsed),GAA(A,g._bandTex,e._bandTexData,e._bandTexelsUsed),e._slotCount>0){const r=e._metaData;A.queue.writeBuffer(g._metaBuf,0,r.buffer,r.byteOffset,e._slotCount*g6)}g._uploadedVersion=e._version}return{_rebuilt:o,_gpu:g}}var rF,mAA,g6,I6=b((()=>{$5(),rF=4096,mAA=rF*4*4,g6=48})),UUA=H({rebuildRegisteredTextRenderers:()=>vUA});function vUA(A){for(const e of A.surfaces)for(const g of e._renderingContexts)g._kind==="text-renderer"&&LUA(g)}function LUA(A){const e=A._surface.engine,g=e._device;A._visibleBundles.length=0;for(const I of A._layerGpu.values())I._textU=Lt(e,FAA,"text-layer-ubo"),I._instanceBuf=g.createBuffer({label:"text-layer-instances",size:I._instanceCap*12,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),I._styleBuf=UK(g,I._styleBuf.size/32),I._uploadedStyleVersion=-1,I._pipeline=null,I._bindGroupCache.length=0,I._uploadedDataVersion=-1,I._uploadedViewportW=0,I._uploadedViewportH=0,I._lastMvpInputs.fill(0),I._mvpUploaded=!1,I._renderBundle=null,I._bundleLayoutVersion=-1,I._bundleDrawCalls=0;for(const I of A.layers)for(const i of I.data._groups)e6(g,i._curveSet._atlas);A._update()}var FAA,YUA=b((()=>{b1(),X5(),I6(),Or(),FAA=96}));function JUA(A,e={}){return v3(A,{_kind:"text-renderer",async _recover(g){const{rebuildRegisteredTextRenderers:I}=await Promise.resolve().then(()=>(YUA(),UUA));I(g)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function io(A){A._refCount=(A._refCount??1)+1}function oC(A){const e=A._refCount;return e===void 0||e<=1?!0:(A._refCount=e-1,!1)}var zn=b((()=>{})),bAA=H({rebuildScenePbrPipelines:()=>t6,rebuildSceneRenderables:()=>i6});async function t6(A,e=!1){await kAA(A,"pbr",e)}async function i6(A){await kAA(A,void 0,!1)}async function kAA(A,e,g){const I=A;if(!I._built&&!g)return;const i=I._lightListVersion??0,C=I.surface.engine,o=D=>{I._z?D.forEach(u=>u()):et(C,()=>D.forEach(u=>u()))};let r=!1,B=!1,n=!1,Q=!1;try{for(let D=1;;D++){if(e!==void 0){await E();break}if(c(I),await E(),!a(I))break;if(D>=UAA){I._rebuildHook=LK,Q=!0,B=!0;break}}n=!0}finally{if(r&&(I._renderables.sort(KAA),I._renderableVersion++,I._materialEpoch++,I._built&&I._frameGraph.build()),e===void 0&&n&&!B&&(I._lightListVersion??0)===i){const D=I._pendingTopologyRetirements?.splice(0);D?.length&&o(D),Q||(I._rebuildHook=void 0)}}async function E(){for(const[D,u]of I._groups){if(e!==void 0&&D._materialFamily!==e)continue;if(u.length===0){(u.o||u.r)&&(l(D,u),r=!0);continue}const _=I._runtimeBuilds;await _?.wait(u);let d=!1;const y=async()=>{const M=I._runtimeBuilds,N=[...u].filter(AA=>I.meshes.includes(AA)&&AA.material?._buildGroup===D);if(N.length===0){l(D,u);return}const S=!!u.r,G=I._disposables.length,m=new Map,k=new Map(N.map(AA=>[AA,AA.material]));for(const AA of N){const z=I._meshDisposables.get(AA);z&&(m.set(AA,z),I._meshDisposables.delete(AA),M?.holdPendingDisposers(AA,z))}let K,U;I._p=AA=>(U=AA,!0);try{K=await D(I,N)}catch(AA){U?.[1]();for(const z of N){const IA=m.get(z),sA=I._meshDisposables.get(z);if(sA&&sA!==IA)for(const EA of sA)EA();const DA=I.meshes.includes(z)&&z.material===k.get(z)&&z.material?._buildGroup===D&&u.includes(z);IA&&DA?I._meshDisposables.set(z,IA):(I._meshDisposables.delete(z),IA&&o(IA)),IA&&M?.releasePendingDisposers(z,IA)}throw AA}finally{delete I._p}if(I._z||_?._d()){U?.[1]();for(const z of N){const IA=I._meshDisposables.get(z),sA=m.get(z);if(IA&&IA!==sA)for(const DA of IA)DA();I._meshDisposables.delete(z)}for(const z of I._disposables.splice(0))z();const AA=[...m.values()].flat();o(AA);for(const[z,IA]of m)M?.releasePendingDisposers(z,IA);return}U?.[0](),D._rebuildSingle=K.rebuildSingle,u.r=I._runtimeBuilds?.base(D,K.rebuildSingle)??K.rebuildSingle,D._materialFamily==="pbr"&&K._G&&(u._w=null),S&&p(I,G);const Y=new Set(N.filter(AA=>I.meshes.includes(AA)&&AA.material===k.get(AA)&&AA.material?._buildGroup===D&&u.includes(AA)));if(Y.size!==N.length&&K.renderables.some(AA=>!AA.mesh)){for(const AA of N){const z=I._meshDisposables.get(AA),IA=m.get(AA);if(z&&z!==IA)for(const sA of z)sA();IA&&I.meshes.includes(AA)?I._meshDisposables.set(AA,IA):(I._meshDisposables.delete(AA),IA&&o(IA)),IA&&M?.releasePendingDisposers(AA,IA)}d=!0;return}const x=new Set;for(const AA of N){if(!Y.has(AA)){const z=m.get(AA),IA=I._meshDisposables.get(AA);if(IA&&IA!==z)for(const sA of IA)sA();z&&I.meshes.includes(AA)?(I._meshDisposables.set(AA,z),m.delete(AA),M?.releasePendingDisposers(AA,z)):I._meshDisposables.delete(AA);continue}x.add(AA.material),I._runtimeBuilds?.reset(AA)}for(const AA of x)AA._csmGen=(AA._csmGen??0)+1;const q=u.o,j=q?.length?new Set(q):null;for(let AA=I._renderables.length-1;AA>=0;AA--){const z=I._renderables[AA];(Y.has(z.mesh)||j?.has(z))&&I._renderables.splice(AA,1)}const X=K.renderables.filter(AA=>!AA.mesh||Y.has(AA.mesh));I._renderables.push(...X),u.o=X;const Z=[...m.values()].flat();o(Z);for(const[AA,z]of m)M?.releasePendingDisposers(AA,z)},{X:h}=await Promise.resolve().then(()=>(xK(),JK)),w=3;for(let M=1;;M++){if(d=!1,await h(I,D,y),I._z||_?._d()){B=!0;return}if(!d)break;if(M>=w){l(D,u),I._rebuildHook=LK,Q=!0,B=!0;break}}if(d){r=!0;continue}r=!0}}function a(D){for(const u of D.meshes){const _=u.material?._buildGroup;if(_&&!D._groups.get(_)?.includes(u))return!0}return!1}function c(D){const u=new Map;for(const _ of D.meshes){const d=_.material?._buildGroup;if(!d)continue;const y=u.get(d);y?y.push(_):u.set(d,[_])}for(const[_,d]of D._groups){const y=u.get(_)??[];(d.length!==y.length||y.some((h,w)=>d[w]!==h))&&(d.length=0,d.push(...y)),u.delete(_)}for(const[_,d]of u){const y=d;D._groups.set(_,y)}}function l(D,u){const _=u.o;if(_?.length){const d=new Set(_);for(let y=I._renderables.length-1;y>=0;y--)d.has(I._renderables[y])&&I._renderables.splice(y,1)}u.o=void 0,u.r=void 0,I._runtimeBuilds?.dropBase(D),I._rebuildHook=LK,Q=!0}function p(D,u){const _=new Set(D._disposables.slice(0,u));for(let d=D._disposables.length-1;d>=u;d--)_.has(D._disposables[d])&&D._disposables.splice(d,1)}}var KAA,UAA,LK,YK=b((()=>{kI(),KAA=(A,e)=>A.order-e.order,UAA=8,LK=A=>i6(A)})),JK=H({A:()=>LAA,B:()=>YAA,C:()=>HUA,X:()=>xUA});function vAA(A,e,g){A.pendingDisposers.set(e,g)}function C6(A,e,g){g&&A.pendingDisposers.get(e)===g&&A.pendingDisposers.delete(e)}function LAA(A,e,g,I){if(!e||g.material!==e)return I??Promise.resolve();const i=YAA(A,e._buildGroup,g);return I?Promise.all([I,i]).then(()=>{}):i}function HUA(A,e,g){let I=g;for(const i of e){const C=Array.isArray(i),o=C?i[0]:i;I=LAA(A,C?i[1]:o.material,o,I)}return(I??Promise.resolve()).catch(i=>{A._runtimeBuilds?._x(i)})}function YAA(A,e,g){if(A._z||!A.meshes.includes(g))return A._runtimeBuilds?.all().catch(()=>{})??Promise.resolve();TUA(A,e,g);const I=A._runtimeBuilds??JAA(A);return e._materialFamily==="pbr"&&(A._built||A._groups.get(e)?.r)?(I._n||(I._l=Promise.resolve(I._l).then(()=>Promise.resolve().then(()=>(YK(),bAA))).finally(()=>{I._n=void 0}).then(({rebuildScenePbrPipelines:i})=>A._z?void 0:i(A,!0)).catch(i=>{A._runtimeBuilds?._x(i)}),I._n=I.track(I._l)),I._n):I.queue(e,g).catch(()=>{})}function xUA(A,e,g){return A._z?Promise.resolve(void 0):(A._runtimeBuilds??JAA(A)).exclusive(e,g)}function JAA(A){const e={disposed:!1,error:null,active:new Set,chains:new WeakMap,generations:new WeakMap,installed:new WeakMap,installedMeshes:new Set,pendingDisposers:new WeakMap,tail:null},g=A,I={queue:(i,C)=>{const o=(e.generations.get(C)??0)+1,r=C.material;e.generations.set(C,o);const B=e.chains.get(C),n=[e.tail,Jo?.get(i)].filter(c=>!!c);let Q=()=>{};const E=new Promise(c=>{Q=c});e.tail=E,(Jo??=new WeakMap).set(i,E);const a=(B?B.catch(()=>{}):Promise.resolve()).then(()=>Promise.all(n)).then(()=>qUA(A,e,i,C,r,o)).catch(c=>{throw HK(A,e,i,C,r,o)&&(e.error=c instanceof Error?c:new Error("Runtime mesh build failed",{cause:c})),c}).finally(()=>{Q(),e.tail===E&&(e.tail=null),Jo?.get(i)===E&&Jo.delete(i)}).finally(()=>{e.chains.get(C)===a&&e.chains.delete(C)});return e.chains.set(C,a),I.track(a)},all:()=>Promise.all(e.active).then(()=>{}),track:i=>{const C=i.finally(()=>e.active.delete(C));return e.active.add(C),Promise.all(e.active).then(()=>{})},base:(i,C)=>{const o=jr?.get(i);return o&&o.bases.set(A,C),o?.dispatch??C},get w(){return!!e.tail},pendingDisposers:i=>e.pendingDisposers.get(i),holdPendingDisposers:(i,C)=>vAA(e,i,C),releasePendingDisposers:(i,C)=>C6(e,i,C),reset:i=>{xAA(A,e,i),g._pbrMeshGeomContexts?.delete(i)},remove:i=>{e.generations.set(i,(e.generations.get(i)??0)+1),e.chains.delete(i),HAA(A,e,i),g._pbrMeshGeomContexts?.delete(i)},dropBase:i=>{const C=jr?.get(i);C&&(C.bases.delete(A),C.scenes.delete(A))},wait:async i=>{const C=new Set;for(const o of i){const r=e.chains.get(o);r&&C.add(r)}await Promise.all(C)},_e:(i=!0)=>{if(e.error){const C=e.error;throw i&&(e.error=null),C}},_x:i=>{e.error=i instanceof Error?i:new Error("Runtime mesh build failed",{cause:i})},_d:()=>e.disposed,exclusive:(i,C)=>{const o=[];e.tail&&o.push(e.tail);const r=Jo?.get(i);r&&o.push(r);const B=Promise.all(o).then(C),n=B.then(()=>{},()=>{});return e.tail=n,(Jo??=new WeakMap).set(i,n),n.then(()=>{e.tail===n&&(e.tail=null),Jo?.get(i)===n&&Jo.delete(i)}),B}};return A._runtimeBuilds=I,(A._beforeRender??=[]).push(()=>{I._e()}),A._disposables.push(()=>{e.disposed=!0,e.active.clear();for(const i of e.installedMeshes)xAA(A,e,i);for(const i of A._groups.keys())jr?.get(i)?.bases.delete(A);A._runtimeBuilds=void 0,g._pbrMeshGeomContexts=void 0}),I}function TUA(A,e,g){for(const[i,C]of A._groups)if(i!==e){const o=C.indexOf(g);o>=0&&C.splice(o,1)}let I=A._groups.get(e);I||(I=[],A._groups.set(e,I)),I.includes(g)||I.push(g)}async function qUA(A,e,g,I,i,C){if(!HK(A,e,g,I,i,C))return;const o=A._meshDisposables.get(I);o&&(A._meshDisposables.delete(I),vAA(e,I,o));const r=g._rebuildSingle,B=jr?.get(g)?.bases.get(A)??A._groups.get(g)?.r,n=!!A._groups.get(g)?.r,Q=A._disposables.length,E=A,a=E._pbrGeomContext;let c,l;try{l=await g(A,[I]),c=E._pbrGeomContext}catch(u){if(TAA(A,e,I,o),qAA(A,e),!HK(A,e,g,I,i,C))return;throw u}finally{g._rebuildSingle=r,g._materialFamily==="pbr"&&n&&(E._pbrGeomContext=a)}if(!HK(A,e,g,I,i,C)){TAA(A,e,I,o),qAA(A,e);return}for(let u=A._renderables.length-1;u>=0;u--)A._renderables[u].mesh===I&&A._renderables.splice(u,1);if(o){for(const u of o){const _=A._disposables.indexOf(u);_>=0&&A._disposables.splice(_,1);const d=u.p;if(d){d._disposed=!0;const y=d._owner;if(y){const h=y.indexOf(d);h>=0&&y.splice(h,1),d._owner=void 0,y.length===0&&d._onOwnerEmpty?.()}else d._onOwnerEmpty?.();d._onOwnerEmpty&&(d._onOwnerEmpty=void 0)}}et(A.surface.engine,()=>{for(const u of o)u()})}C6(e,I,o),A._renderables.push(...l.renderables);const p=A._groups.get(g);p&&(p.o=[...(p.o??[]).filter(u=>u.mesh!==I),...l.renderables]),l.updater&&A._uniformUpdaters.push(l.updater),n&&OUA(A,Q),g._materialFamily==="pbr"&&n&&c&&(E._pbrMeshGeomContexts??=new WeakMap).set(I,c),PUA(A,e,g,I,l.rebuildSingle,n?B:l.rebuildSingle),I.material._csmGen=(I.material._csmGen??0)+1;const D=A._groups.get(g);D&&!n&&(D.r=l.rebuildSingle),A._renderables.sort(PAA),A._renderableVersion++,A._materialEpoch++}function PUA(A,e,g,I,i,C){let o=jr?.get(g);if(!o){const Q=new WeakMap,E=new WeakMap;o={bases:E,dispatch:(c,l,p,D)=>{const u=Q.get(c)?.get(l);if(u)return u(c,l,p,D);const _=E.get(c)??c._groups.get(g)?.r;if(_)return _(c,l,p,D);throw new Error("Material group has not completed its initial build")},scenes:Q},(jr??=new WeakMap).set(g,o)}let r=o.scenes.get(A);r||(r=new WeakMap,o.scenes.set(A,r)),r.set(I,i),o.bases.has(A)||o.bases.set(A,C??i);const B=A._groups.get(g);B&&(B.r=o.dispatch);let n=e.installed.get(I);n||(n=new Set,e.installed.set(I,n)),n.add(g),e.installedMeshes.add(I)}function HAA(A,e,g){const I=e.installed.get(g);if(I){for(const i of I)jr?.get(i)?.scenes.get(A)?.delete(g);e.installed.delete(g),e.installedMeshes.delete(g)}}function xAA(A,e,g){HAA(A,e,g)}function HK(A,e,g,I,i,C){return!e.disposed&&e.generations.get(I)===C&&A.meshes.includes(I)&&I.material===i&&i._buildGroup===g}function TAA(A,e,g,I){const i=A._meshDisposables.get(g);if(i&&i!==I){A._meshDisposables.delete(g);for(const C of i)C()}if(I)if(A.meshes.includes(g))A._meshDisposables.set(g,I);else if(e.disposed)for(const C of I)C();else et(A.surface.engine,()=>{for(const C of I)C()});C6(e,g,I)}function qAA(A,e){if(!e.disposed)return;const g=A._disposables.splice(0);for(const I of g)I()}function OUA(A,e){const g=new Set(A._disposables.slice(0,e));for(let I=A._disposables.length-1;I>=e;I--)g.has(A._disposables[I])&&A._disposables.splice(I,1)}var PAA,Jo,jr,xK=b((()=>{kI(),PAA=(A,e)=>A.order-e.order,Jo=null,jr=null}));function OAA(A,e,g,I=e.material){return Promise.resolve().then(()=>(xK(),JK)).then(i=>i.A(A,I,e,g)).catch(i=>console.error(i))}function TK(A,e,g){A._runtimeThinBuild=OAA,A.thinInstances?(A.thinInstances.matrices=e,A.thinInstances.count=g,A.thinInstances._capacity=g,A.thinInstances._version++,A.thinInstances._dirtyMin=0,A.thinInstances._dirtyMax=g):A.thinInstances={matrices:e,count:g,_capacity:g,_version:1,_gpuBuffer:null,_gpuVersion:0,_dirtyMin:0,_dirtyMax:g,_colorVersion:0,_colorDirtyMin:0,_colorDirtyMax:0,_colorGpuBuffer:null,_colorGpuBufferStorage:!1,_colorGpuVersion:0,_gpuCullingEnabled:!1}}function o6(A,e){const g=A.thinInstances;g&&(g.count=e,g._version++,g._dirtyMin=0,g._dirtyMax=e)}function jUA(A,e){const g=A.thinInstances;if(g){if(!Number.isInteger(e)||e<0||e>g._capacity)throw new RangeError(`Thin instance draw count ${e} must be an integer between 0 and capacity ${g._capacity}`);g.count!==e&&((!g._gpuBuffer||g._gpuVersion!==g._version||g.colors&&(!g._colorGpuBuffer||g._colorGpuVersion!==g._colorVersion))&&R(595),g.count=e,g._gpuVersion=++g._version)}}function VUA(A){const e=A.thinInstances;e||R(596),e._drawArgsBuffer||(e._drawArgsInstanceCount=-1)}function WUA(A,e){A._runtimeThinBuild=OAA;const g=A.thinInstances;if(!g){const C=new oA(256);return C.set(e,0),A.thinInstances={matrices:C,count:1,_capacity:16,_version:1,_gpuBuffer:null,_gpuVersion:0,_dirtyMin:0,_dirtyMax:1,_colorVersion:0,_colorDirtyMin:0,_colorDirtyMax:0,_colorGpuBuffer:null,_colorGpuBufferStorage:!1,_colorGpuVersion:0,_gpuCullingEnabled:!1},0}const I=g.count;if(I>=g._capacity){const i=g._capacity*2,C=new oA(i*16);C.set(g.matrices),g.matrices=C,g._capacity=i}return g.matrices.set(e,I*16),g.count++,g._version++,g._dirtyMin=0,g._dirtyMax=g.count,I}function zUA(A,e,g){const I=A.thinInstances;I.matrices.set(g,e*16),I._version++,I._dirtyMin=Math.min(I._dirtyMin,e),I._dirtyMax=Math.max(I._dirtyMax,e+1)}function ZUA(A,e){const g=A.thinInstances,I=g.count-1;e!==I&&g.matrices.copyWithin(e*16,I*16,I*16+16),g.count--,g._version++,g._dirtyMin=0,g._dirtyMax=g.count}function r6(A){const e=A.thinInstances;e._version++,e._dirtyMin=0,e._dirtyMax=e.count}function XUA(A,e){const g=A.thinInstances;g.colors=e,g._version++,g._colorVersion++,g._colorDirtyMin=0,g._colorDirtyMax=g.count}function $UA(A,e,g,I,i,C){const o=A.thinInstances,r=o.colors,B=e*4;r[B]=g,r[B+1]=I,r[B+2]=i,r[B+3]=C,o._version++,o._colorVersion++,o._colorDirtyMin=Math.min(o._colorDirtyMin,e),o._colorDirtyMax=Math.max(o._colorDirtyMax,e+1)}function AvA(A,e=!0){const g=A.thinInstances;g||R(597),g._gpuCullingEnabled!==e&&(g._gpuCullingEnabled=e,g._gpuVersion=-1,g._colorGpuVersion=-1)}function evA(A,e){const g=A.thinInstances;g||R(598),g._cullBoundsPad=e}function gvA(A,e,g){const I=A.thinInstances,i=e.thinInstances;if((!I||!i)&&R(599),A===e&&R(600),((I._refCount??1)>1||(i._refCount??1)>1)&&R(601),!Number.isFinite(g.distance)||g.distance<0)throw new RangeError("setThinInstanceLodPartner distance must be a finite non-negative number");const C=g.band??0;if(!Number.isFinite(C)||C<0)throw new RangeError("setThinInstanceLodPartner band must be a finite non-negative number");I._lodSource&&R(602),i._lodPartner&&R(603),i._lodSource&&i._lodSource!==A&&R(604),i.colors&&!I.colors&&R(605);const o=I._lodPartner;if(o&&o!==e){const B=o.thinInstances;B&&B._lodSource===A&&qK(B),o._clone=void 0,I._lodBuckets=null}I._lodPartner=e,I._lodDistance=g.distance,I._lodBand=C,i._lodSource=A,A._clone=e._clone="Cannot clone LOD-paired mesh";const r=I._lodBuckets??new WeakMap;I._lodBuckets=r,i._lodBuckets=r,i._gpuCullingEnabled||(i._lodAutoCull=!0,i._gpuCullingEnabled=!0,i._gpuVersion=-1,i._colorGpuVersion=-1)}function IvA(A){const e=A.thinInstances;if(!e?._lodPartner)return;const g=e._lodPartner,I=g.thinInstances;e._lodPartner=null,e._lodDistance=void 0,e._lodBand=void 0,e._lodBuckets=null,A._clone=void 0,g._clone=void 0,I&&I._lodSource===A&&qK(I)}function tvA(A){const e=A.thinInstances;if(!e)return;const g=e._lodSource,I=g?.thinInstances;g&&I?._lodPartner===A&&(I._lodPartner=null,I._lodDistance=void 0,I._lodBand=void 0,I._lodBuckets=null,g._clone=void 0),e._lodSource&&qK(e);const i=e._lodPartner,C=i?.thinInstances;e._lodPartner=null,e._lodDistance=void 0,e._lodBand=void 0,e._lodBuckets=null,A._clone=void 0,i&&C?._lodSource===A&&(i._clone=void 0,qK(C))}function qK(A){A._lodSource=null,A._lodBuckets=null,A._lodAutoCull&&(A._lodAutoCull=!1,A._gpuCullingEnabled=!1,A._gpuVersion=-1,A._colorGpuVersion=-1)}var DQ=b((()=>{rA(),ZA()}));function ivA(A){B6=A}function CvA(A){PK=A}function jAA(A){A.positionBuffer.destroy(),A.normalBuffer.destroy(),A.uvBuffer.destroy(),A.tangentBuffer?.destroy(),A.uv2Buffer?.destroy(),A.colorBuffer?.destroy()}function Zi(A){if(A._disposed)return;A._disposed=!0,B6?.(A);const e=A._gpu;oC(e)&&(PK?PK(e,jAA):(jAA(e),e.indexBuffer.destroy()),e._shaderColorFallback?.destroy());const g=A.thinInstances;g&&oC(g)&&(tvA(A),g._gpuBuffer?.destroy(),g._colorGpuBuffer?.destroy(),g._drawArgsBuffer?.destroy());const I=A.skeleton;I&&oC(I)&&(I._disposed=!0,I.boneTexture.destroy(),oC(I._skinBuffers)&&(I.jointsBuffer.destroy(),I.weightsBuffer.destroy(),I.joints1Buffer?.destroy(),I.weights1Buffer?.destroy()));const i=A.vat;i&&oC(i)&&(i.settingsBuffer.destroy(),i.instanceTexture?.destroy(),oC(i._textureResource)&&i._textureResource.texture.destroy(),oC(i._skinBuffers)&&(i.jointsBuffer.destroy(),i.weightsBuffer.destroy(),i.joints1Buffer?.destroy(),i.weights1Buffer?.destroy()));const C=A.morphTargets;C&&oC(C)&&(C._disposed=!0,C.deltasBuffer.destroy(),C.weightsBuffer.destroy())}var PK,B6,Co=b((()=>{zn(),DQ(),PK=null,B6=null}));function ovA(A){OK=A}function uQ(A,e){A._materialSwapQueue.includes(e)||A._materialSwapQueue.push(e)}function VAA(A){const e=_Q?.get(A);if(e)for(const g of e)uQ(g,A)}function rvA(A){return _Q?.get(A)}function BvA(A){let e=A.material;Object.defineProperty(A,"material",{get(){return e},set(g){if(g!==e){OK?.(A,g),e=g;const I=_Q?.get(A);if(I)for(const i of I)uQ(i,A),i._meshMaterialChange?.(A,g)}},configurable:!0,enumerable:!0})}function nvA(A,e){e._disposed&&R(715,e.name),OK?.(e,e.material);const g=_Q??=new WeakMap;let I=g.get(e);I||(g.set(e,I=new Set),BvA(e)),I.add(A)}function WAA(A,e){const g=_Q?.get(e);return g?(g.delete(A),g.size===0):!0}var _Q,OK,Zn=b((()=>{rA(),_Q=null,OK=null}));function n6(A){const e=A._materialSwapQueue;if(!e[0]||A._runtimeBuilds?.w)return;let g,I,i;const C=A._renderables;for(const r of e){const B=r.material;if(!B)continue;const n=r._runtimeThinBuild;if(n){I=n(A,r,I);continue}const Q=A._groups.get(B._buildGroup),E=Q?.r;if(!E){(i??=[]).push(r);continue}if(Q._w?.(r)){(i??=[]).push([r,B]);continue}const a=A._meshDisposables.get(r);a&&(A._meshDisposables.delete(r),et(A.surface.engine,()=>a.forEach(D=>D())));const c=Q.o;let l;for(let D=C.length;D--;)C[D].mesh===r&&(l=C.splice(D,1)[0]);B._csmGen=-~B._csmGen;const p=E(A,r);if(c){const D=c.indexOf(l);D<0?c.push(p):c[D]=p}g=C.push(p)}if(g&&(C.sort((r,B)=>r.order-B.order),A._renderableVersion++,A._materialEpoch++),e.length=0,!i)return I;const o=i;return Promise.resolve().then(()=>(xK(),JK)).then(({C:r})=>r(A,o,I),r=>{const B=A._runtimeBuilds;B?B._x(r):console.error(r)})}var zAA=b((()=>{kI()}));function svA(A){s6=A}function QvA(A,e,g){s6?.(A,e,g)}var s6,ZAA=b((()=>{s6=null}));function XAA(A){const e={_tasks:[],_currentProcessedTask:null,build(){for(let g=0;g<e._tasks.length;g++)$AA(e,e._tasks[g]);for(const g of e._tasks)for(const I of g._passes)I._initialize()},execute(){let g=0;for(const I of e._tasks)if(I.executionEnabled!==!1)if(I.execute)g+=I.execute();else for(const i of I._passes)g+=i._execute();return g},dispose(){for(const g of e._tasks)g.dispose();e._tasks.length=0,e._currentProcessedTask=null}};return e}function EvA(A,e){A._tasks.includes(e)||R(121,e.name),$AA(A,e);for(const g of e._passes)g._initialize()}function $AA(A,e){e._passes.length=0,A._currentProcessedTask=e;try{e.record()}finally{A._currentProcessedTask=null}}function AeA(A,e){A._tasks.push(e)}var jK=b((()=>{rA()})),eeA=H({configureSwapchainOverlayScene:()=>avA});function geA(A,e){for(const g of A._frameGraph._tasks)if(g?._config&&g._colorAttachment&&(g._config.rt===e.scRT||g._config.rst===e.scRT))return g}function avA(A,e){const g=A._renderingContexts[A._renderingContexts.length-1];if(!g?._frameGraph)return;const I=geA(e,A);if(!I)return;if(A.msaaSamples===1){I._config.clr=!1;return}const i=I.enabled;I._config.clr=!0,I.enabled=!1,e._beforeRender.unshift(()=>{const C=geA(g,A),o=C?._config.rst===A.scRT&&C._config.rt._colorView;I.enabled=o?i:!1,I._config.clr=!o,o&&(I._colorAttachment.view=o)})}var IeA=b((()=>{}));function cvA(){return VK??=new WeakMap,VK}function teA(A,e){cvA().set(A,e),WK&&WK(A,e).catch(g=>console.error(g))}function BF(A){return VK?.get(A)}function lvA(A,e){if(e!==1/0&&(!Number.isInteger(e)||e<0))throw new RangeError("setShadowCasterMaxCascade requires a non-negative integer or Infinity");A._shadowMaxCascade=e===1/0?void 0:e}function pvA(A){WK=A}var VK,WK,zK=b((()=>{VK=null,WK=null})),DvA=H({createShadowTask:()=>uvA});function uvA(A,e){const g=new Set;pvA(ieA);const I={name:"shadow",engine:A,scene:e,_passes:[],async _preload(){const i=[];for(const C of e.lights){const o=C.shadowGenerator,r=o?BF(o):null;o?._preloadShadowTask&&r&&i.push(ieA(o,r))}await Promise.all(i)},record(){I._passes.length=0;for(const i of e.lights){const C=i.shadowGenerator,o=C?BF(C):null;if(C?._ensureShadowTaskState&&o&&!C._preloadPending){g.add(C);const r=C._ensureShadowTaskState(A,e,o),B=e._renderableVersion;r._task.record(),r._recordedVersion=B}}},execute(){let i=0;for(const C of e.lights){const o=C.shadowGenerator,r=o?BF(o):null;if(o?._ensureShadowTaskState&&o._renderShadowMap&&r&&!o._preloadPending){g.add(o);const B=o._shadowTaskState??null,n=o._ensureShadowTaskState(A,e,r);if(n!==B||n._recordedVersion!==e._renderableVersion){const Q=e._renderableVersion;n._task.record(),n._recordedVersion=Q}i+=o._renderShadowMap(A,n)}}return i},dispose(){I._passes.length=0;for(const i of g){const C=i._shadowTaskState;C&&(C._task.dispose(),i._shadowTaskState=void 0)}g.clear()}};return I}async function ieA(A,e){A._preloadPending=e,await A._preloadShadowTask?.(e),A._preloadPending===e&&(A._preloadPending=void 0)}var _vA=b((()=>{zK()}));function dvA(A){Xn=A}function fvA(A){Q6=A}function CeA(A,e){const g=A.camera;g&&!g._useFloatingOrigin!=!e&&(g._useFloatingOrigin=e,g._viewVer=-1,g._projFov=void 0)}function oeA(A,e){const g=A.engine,I={_kind:"scene",surface:A,clearColor:{r:.2,g:.2,b:.3,a:1},camera:null,lights:[],meshes:[],animationGroups:[],fog:null,clipPlane:null,shadowGenerators:[],imageProcessing:{exposure:1,contrast:1,toneMappingEnabled:!1},_renderables:[],_prePasses:[],_pickSources:[],_uniformUpdaters:[],fixedDeltaMs:0,_beforeRender:[],_deferredBuilders:[],_groups:new Map,_disposables:[],_meshDisposables:new Map,_materialSwapQueue:[],_renderableVersion:0,_materialEpoch:0,_built:!1,_drawCallsPre:0,_update(){const C=I.fixedDeltaMs>0?I.fixedDeltaMs:g._currentDelta,o=g._currentEncoder;let r=0;CeA(I,g.useFloatingOrigin);for(const B of I._beforeRender)B(C);CeA(I,g.useFloatingOrigin),I._materialSwapQueue.length&&n6(I);for(const B of I._prePasses)r+=B.execute(o,g);for(const B of I._uniformUpdaters)B.update(g);I._drawCallsPre=r},_record(){return I._frameGraph.execute()},_resize(){I._frameGraph.build()}},i=XAA(g);if(I._frameGraph=i,e?.defaultRenderTask!==!1){const C=A.msaaSamples>1,o=C?c3({lbl:"scene-color",format:A.format,dFormat:"depth24plus-stencil8",samples:A.msaaSamples,size:A}):A.scRT,r=C?void 0:c3({lbl:"scene-depth",dFormat:"depth24plus-stencil8",samples:1,size:A});AeA(i,i5({name:"scene",rt:o,rst:C?A.scRT:void 0,depth:r},g,I))}return I._disposables.push(()=>i.dispose()),I}function dQ(A,e){A._beforeRender.unshift(e)}function yvA(){return Xn!==void 0}function hvA(A,e){Xn?.run(A,e)}function nF(A,e,g){Xn?.record(A,e,g)}function wvA(A){return A._frameGraph}function sF(A,e){const g=A;g._deferredBuilders.push(async()=>{const I=await e(g.surface.engine,g);g._renderables.push(...I.renderables),I.dispose&&g._disposables.push(I.dispose)})}function Pg(A,e){if(Xn&&A._sceneChanges&&A._sceneChanges.depth===0){Xn.run(A,()=>Pg(A,e));return}const g=A;if("entities"in e){const i=e;for(const C of i.entities)Pg(A,C);if(i.clearColor&&(g.clearColor=i.clearColor),i.camera&&!g.camera&&(g.camera=i.camera),i.animationGroups?.length){const C=g.surface.engine,o=i.animationGroups;g.animationGroups.push(...o);const r=B=>{for(const n of o)QvA(n,B,C)};i._beforeRenderHook=r,g._beforeRender.push(r)}i._sceneSetup?.(g,i),nF(g,e,"added");return}if("_gpu"in e&&"material"in e){const i=e;nvA(g,i),g.meshes.push(i),reA(g,i),g._meshMaterialChange?.(i,i.material)}else"lightType"in e?g.lights.push(e):"fov"in e&&(g.camera=e);nF(g,e,"added");const I=e.children;if(I?.length)for(const i of I)i.parent=e,Pg(A,i)}function reA(A,e){const g=e.material?._buildGroup;if(!g)return;let I=A._groups.get(g);I||(I=[],A._groups.set(g,I),A._built||A._deferredBuilders.push(async()=>{if(!I[0]){A._groups.delete(g);return}const i=await g(A,I);A._renderables.push(...i.renderables),I.o=i.renderables,i.updater&&A._uniformUpdaters.push(i.updater),I.r=i.rebuildSingle})),I.push(e),(A._built||I.r)&&uQ(A,e)}function BeA(A){const e=A;if(e._z)return;e._z=!0;const g=QF??=new WeakMap;g.set(e,()=>1),Zs(e.surface,e);const I=()=>{g.set(e,()=>{for(const i of e._meshDisposables.values())i.forEach(C=>C());return e._meshDisposables.clear(),e._disposables.splice(0).forEach(i=>i()),e._renderables.length=e._uniformUpdaters.length=0,1}),e._disposables.splice(0).forEach(i=>i());for(const i of e._meshDisposables.values())for(const C of i)C();e._meshDisposables.clear();for(const i of e.meshes)WAA(e,i)&&Zi(i);e._groups.clear(),e.meshes.length=0,e._renderables.length=0,e._prePasses.length=0,e._pickSources.length=0,e._uniformUpdaters.length=0,e._beforeRender.length=0,e._deferredBuilders.length=0,e._disposables.length=0,e._materialSwapQueue.length=0,e.lights.length=0,e.animationGroups.length=0,e.shadowGenerators.length=0,e.camera=null};Xn?.dispose(e),Q6?Q6(e,I):I()}async function neA(A){const e=A;for(!e._built&&e._materialSwapQueue.splice(0)[0]&&(e._groups.forEach(g=>g.length=0),e.meshes.forEach(g=>reA(e,g)));e._deferredBuilders.length;){const g=e._deferredBuilders.splice(0);await Promise.all(g.map(I=>I()))}await n6(e),QF?.get(e)?.()||(e._runtimeBuilds?._e(),e._renderableVersion++,e._built=!0),await e._rebuildHook?.(e)}function MvA(A){fQ=A}async function seA(A){const e=A,g=e.surface;DY(g,e)||(await neA(A),e._renderables.sort(E6),await Promise.all(e._frameGraph._tasks.map(I=>I._preload?.())),fQ&&await fQ(e),e._frameGraph.build(),g._renderingContexts[0]&&(await Promise.resolve().then(()=>(IeA(),eeA))).configureSwapchainOverlayScene(g,e),QF?.get(e)?.()||Ln(g,e))}async function RvA(A){const e=A,g=e.surface;DY(g,e)||(await neA(A),e._renderables.sort(E6),await SvA(g.engine,e),await Promise.all(e._frameGraph._tasks.map(I=>I._preload?.())),fQ&&await fQ(e),e._frameGraph.build(),g._renderingContexts[0]&&(await Promise.resolve().then(()=>(IeA(),eeA))).configureSwapchainOverlayScene(g,e),QF?.get(e)?.()||Ln(g,e))}async function SvA(A,e){if(e._frameGraph._tasks.some(I=>I.name==="shadow"))return;const{createShadowTask:g}=await Promise.resolve().then(()=>(_vA(),DvA));e._frameGraph._tasks.unshift(g(A,e))}function NvA(A){Zs(A.surface,A)}var QF,Xn,Q6,fQ,E6,ht=b((()=>{lt(),Co(),Zn(),zAA(),ZAA(),jK(),CQ(),MI(),QF=null,fQ=null,E6=(A,e)=>A.order-e.order}));CZ(),UX(),jX(),e5(),R$(),MK(),YK(),ht();var QeA=!1,EeA=!1;function aeA(A){if(A.length===1)throw A[0];if(A.length>1)throw new AggregateError(A)}function GvA(A,e){const g=A._sceneChanges;if(!g){e();return}g.depth++;let I=!1,i;try{e()}catch(o){I=!0,i=o}if(g.depth--,g.depth>0||g.dispatching){if(I)throw i;return}const C=I?[i]:[];g.dispatching=!0;try{for(;g.pending.length;){const o=g.pending.shift();for(const r of[...g.listeners])if(g.listeners.has(r))try{r(o)}catch(B){C.push(B)}}}finally{g.dispatching=!1,!g.listeners.size&&A._sceneChanges===g&&(A._sceneChanges=void 0)}aeA(C)}function mvA(A){const e=A._sceneChanges;e&&(e.listeners.clear(),e.pending.length=0,A._sceneChanges===e&&(A._sceneChanges=void 0))}function FvA(A,e){const g=[];for(const I of A._disposables.splice(0))try{I()}catch(i){g.push(i)}A._disposables.length=0;try{e()}catch(I){g.push(I)}aeA(g)}function ceA(){EeA||(EeA=!0,fvA(FvA))}function bvA(){QeA||(QeA=!0,ceA(),dvA({run:GvA,record:(A,e,g)=>{const I=A._sceneChanges;if(I){if(g==="added"){if(I.members.has(e))return;I.members.add(e)}else if(!I.members.delete(e))return;I.pending.push({type:g,entity:e})}},dispose:mvA}))}function kvA(A){const e=new WeakSet,g=I=>{if(!e.has(I)&&(e.add(I),"children"in I&&Array.isArray(I.children)))for(const i of I.children)typeof i=="object"&&i!==null&&(!("parent"in i)||i.parent===I)&&g(i)};for(const I of[...A.meshes,...A.lights,...A.shadowGenerators])g(I);return A.camera&&g(A.camera),e}function leA(A,e){if(A._z)throw new Error("Cannot observe a disposed scene.");bvA();const g=A._sceneChanges??={listeners:new Set,pending:[],members:kvA(A),depth:0,dispatching:!1},I=C=>e(C);g.listeners.add(I);let i=!0;return()=>{i&&(i=!1,g.listeners.delete(I),!g.listeners.size&&!g.depth&&!g.dispatching&&A._sceneChanges===g&&(A._sceneChanges=void 0))}}function peA(A,e){ceA();const g=A._disposables,I=()=>e();g.push(I);let i=!0;return()=>{if(!i)return;i=!1;const C=g.indexOf(I);C>=0&&g.splice(C,1)}}function a6(A,e,g,I){A[3]=0,A[7]=0,A[11]=0,A[12]=e.x,A[13]=e.y,A[14]=e.z,A[15]=1;let i=g.x-e.x,C=g.y-e.y,o=g.z-e.z;const r=Math.sqrt(i*i+C*C+o*o);let B=0,n=0,Q=0,E=0;if(r>=1e-10){const c=1/r;i*=c,C*=c,o*=c,B=I.y*o-I.z*C,n=I.z*i-I.x*o,Q=I.x*C-I.y*i,E=Math.sqrt(B*B+n*n+Q*Q)}if(E<1e-10){A[0]=1,A[1]=0,A[2]=0,A[4]=0,A[5]=1,A[6]=0,A[8]=0,A[9]=0,A[10]=1;return}const a=1/E;B*=a,n*=a,Q*=a,A[0]=B,A[1]=n,A[2]=Q,A[4]=C*Q-o*n,A[5]=o*B-i*Q,A[6]=i*n-C*B,A[8]=i,A[9]=C,A[10]=o}var c6=b((()=>{})),ZK,l6=b((()=>{ZK={x:0,y:1,z:0}}));c6(),l6(),Lo(),Hr(),Ut();function DeA(A,e,g,I){function i(){const E=Math.cos(Q.alpha),a=Math.sin(Q.alpha),c=Math.cos(Q.beta);let l=Math.sin(Q.beta);return l===0&&(l=1e-4),{x:Q.target.x+Q.radius*E*l,y:Q.target.y+Q.radius*c,z:Q.target.z+Q.radius*a*l}}const C=QI();function o(){return a6(C,i(),Q.target,ZK),C}const r=eQ(o),B=()=>r.markLocalDirty(),n={alpha:A,beta:e,radius:g},Q={alpha:0,beta:0,radius:0,target:new Ei(I.x,I.y,I.z,B),fov:.8,nearPlane:.1,farPlane:1e3,children:[],inertia:.9,panningInertia:.9,angularSensibility:1e3,panningSensibility:50,wheelPrecision:3,inertialAlphaOffset:0,inertialBetaOffset:0,inertialRadiusOffset:0,inertialPanningX:0,inertialPanningY:0,_viewCache:QI(),_projCache:QI(),_vpCache:QI(),get parent(){return r.parent},set parent(E){r.parent=E},get worldMatrix(){return r.getWorldMatrix()},get worldMatrixVersion(){return r.getWorldMatrixVersion()}};for(const E of["alpha","beta","radius"])Object.defineProperty(Q,E,{get:()=>n[E],set:a=>{n[E]!==a&&(n[E]=a,B(),Q._clampToLimits?.())},configurable:!0,enumerable:!0});return Km(Q,r),Q}function $n(A,e,g){return{x:A,y:e,z:g}}oX();function KvA(A){let e=1/0,g=1/0,I=1/0,i=-1/0,C=-1/0,o=-1/0;const r=iX();for(const l of A.meshes)l.visible!==!1&&CX(r,l);e=r.minX,g=r.minY,I=r.minZ,i=r.maxX,C=r.maxY,o=r.maxZ;const B=i-e,n=C-g,Q=o-I;let E=Math.sqrt(B*B+n*n+Q*Q)*1.5,a=$n(e+B*.5,g+n*.5,I+Q*.5);(!isFinite(E)||E===0)&&(E=1,a=$n(0,0,0));const c=DeA(-(Math.PI/2),Math.PI/2,E,a);return c.nearPlane=E*.01,c.farPlane=E*1e3,A.camera=c,c}function mt(A,e){if(yvA()&&A._sceneChanges&&A._sceneChanges.depth===0){hvA(A,()=>mt(A,e));return}if("entities"in e){const g=e;for(const o of g.entities)mt(A,o);g.camera&&A.camera===g.camera&&(A.camera=null);const I=g.animationGroups;if(I?.length)for(const o of I)yQ(A.animationGroups,o);const i=g._beforeRenderHook;i&&(yQ(A._beforeRender,i),g._beforeRenderHook=void 0);const C=g._sceneCleanups;if(C){const o=C.get(A);o&&(yQ(A._disposables,o),C.delete(A),A._z||o())}nF(A,e,"removed");return}if("_gpu"in e&&"material"in e){xvA(A,e),nF(A,e,"removed"),deA(A,e);return}if("lightType"in e){yQ(A.lights,e);const g=e.shadowGenerator;g?ueA(A,g):_eA(A)}else"fov"in e&&"nearPlane"in e?A.camera===e&&(A.camera=null):"_shadowType"in e&&"_light"in e&&ueA(A,e);HvA(e),nF(A,e,"removed"),deA(A,e)}function UvA(A,e){for(const g of e){yQ(A._disposables,g);const I=g.p;if(I){I._disposed=!0;const i=I._owner;if(i){const C=i.indexOf(I);C>=0&&i.splice(C,1),I._owner=void 0,i.length===0&&I._onOwnerEmpty?.()}else I._onOwnerEmpty?.();I._onOwnerEmpty&&(I._onOwnerEmpty=void 0)}}vvA(A,()=>{for(const g of e)g()})}function vvA(A,e){if(A._z){e();return}et(A.surface.engine,e)}function ueA(A,e){yQ(A.shadowGenerators,e);const g=e._light;g&&g.shadowGenerator===e&&(g.shadowGenerator=void 0),_eA(A);const I=e._shadowTaskState;I&&(e._shadowTaskState=void 0,LvA(A,()=>I._task.dispose()))}function LvA(A,e){A._pendingTopologyRetirements||(A._pendingTopologyRetirements=[],A._disposables.push(()=>YvA(A))),A._pendingTopologyRetirements.push(e)}function YvA(A){const e=A._pendingTopologyRetirements?.splice(0);if(!e?.length)return;const g=()=>{for(const i of e)try{i()}catch{}},I=A.surface.engine._device;I?I.queue.onSubmittedWorkDone().then(g,g):g()}function _eA(A){A._lightListVersion=(A._lightListVersion??0)+1,A._built&&(A._rebuildHook=JvA)}async function JvA(A){const{rebuildSceneRenderables:e}=await Promise.resolve().then(()=>(YK(),bAA));await e(A)}function yQ(A,e){const g=A.indexOf(e);g>=0&&A.splice(g,1)}function HvA(A){A&&typeof A=="object"&&"parent"in A&&(A.parent=null)}function deA(A,e){const g=e.children;if(g?.length)for(const I of[...g])mt(A,I)}function xvA(A,e){A._meshMaterialChange?.(e);for(const B of A._frameGraph._tasks)B._removeMesh?.(e);const g=A._meshDisposables.get(e);let I=!1;const i=[];g&&(I=!0,i.push(...g),A._meshDisposables.delete(e));const C=A.meshes.indexOf(e);C>=0&&(A.meshes.splice(C,1),I=!0);const o=A._renderables.findIndex(B=>B.mesh===e);o>=0&&(A._renderables.splice(o,1),I=!0),I&&A._renderableVersion++;for(const B of A._groups.values()){const n=B.indexOf(e);n>=0&&B.splice(n,1);const Q=B.o;if(Q)for(let E=Q.length;E--;)Q[E].mesh===e&&Q.splice(E,1)}const r=A._materialSwapQueue.indexOf(e);r>=0&&A._materialSwapQueue.splice(r,1),A._runtimeBuilds?.remove(e),e.parent=null;for(const B of A._frameGraph._tasks)"_renderables"in B&&B$(B,e);WAA(A,e)&&i.push(()=>Zi(e)),i.length&&UvA(A,i)}var Ni=b((()=>{ht(),Zn(),Co(),CQ(),kI()}));function YI(A,e){feA(A,e)&&Vi()}function feA(A,e){let g=A.visible!==e;A.visible=e;const I=A.children;for(let i=0;i<I.length;i++)feA(I[i],e)&&(g=!0);return g}var Ho=b((()=>{lt()})),TvA=H({_apply:()=>qvA}),yeA=/textureSampleLevel\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*0(?:\.0?)?\s*\)\.rgb/,qvA=(A,e)=>{const g=A.match(yeA),I=g?.[1],i=g?.[2],C=g?.[3];if(!I||!i||!C)throw new Error("Environment blur: skybox cubemap sample not found.");const o=`clamp(scene._envPad1*log2(f32(textureDimensions(${I}).x))*${e==="dds"?"0.8":"scene.vImageInfos.z+scene._envPad2"},0.0,f32(textureNumLevels(${I})-1))`;return A.replace(yeA,`textureSampleLevel(${I},${i},${C},0.0+(${o})).rgb`)};tC();function heA(A,e,g){const I=A._environmentSkyboxShaderPatchLoaders??=[];I[e]=g,A._environmentSkyboxShaderComposer??=async(i,C)=>{i=C==="hdr"?q1+i:i;for(const o of I.slice())o&&(i=(await o())._apply(i,C));return i}}Pn();var PvA=()=>TvA;function OvA(A,e){A[38]=e._environmentBlur??0,A[39]=e._envTextures?.lodGenerationOffset??0}function jvA(A,e){A._environmentBlur=e,heA(A,1,PvA),j3(A,OvA),TY(A)}var VvA=H({_apply:()=>weA}),p6,weA,WvA=b((()=>{rA(),p6=/var\s+([A-Za-z_]\w*)\s*=\s*normalize\(\w+\.positionUVW\)\s*;/,weA=A=>{const e=A.match(p6)?.[1];e||R(431);const g=`let _erc=cos(scene.envRotationY);let _ers=sin(scene.envRotationY);${e}=vec3f(${e}.x*_erc+${e}.z*_ers,${e}.y,-${e}.x*_ers+${e}.z*_erc);`;return A.replace(p6,`$&${g}`)}}));Pn();var zvA=()=>Promise.resolve().then(()=>(WvA(),VvA));function ZvA(A,e){Um(A),A._environmentRotation=e,heA(A,0,zvA),TY(A)}var XvA=[A=>`AnimationGroup "${A}" is already attached to another AnimationManager`,()=>"Animation task category is required.",()=>"AnimationTask is already attached to another AnimationManager",()=>"AnimationManager autonomous mode requires requestAnimationFrame",A=>`Animation weight fade duration must be a finite positive number, got ${A}`,A=>`Animation weight must be a finite number between 0 and 1, got ${A}`,A=>`Animation weight must be a finite number between 0 and 1, got ${A}`,()=>"createPropertyAnimationClip requires at least one track",()=>"Animation play range must have toTime greater than fromTime",A=>`Animation track "${A}" requires at least one key`,A=>`Animation track "${A}" requires a positive frameRate`,A=>`Animation track "${A}" key times must be monotonically increasing`,A=>`Animation track "${A}" requires at least one key`,A=>`Animation key for "${A}" must provide exactly one of time or frame`,A=>`Animation key for "${A}" must have a non-negative time`,(A,e)=>`Animation key for "${A}" expected ${e} values`,(A,e)=>`Animation key for "${A}" expected ${e} values`,A=>`Invalid animation property path "${A}"`,(A,e)=>`Animation property path "${A}" could not resolve "${e}"`,A=>`Animation property path "${A}" reached a non-object value`,(A,e)=>`Animation property path "${A}" could not resolve "${e}"`,(A,e)=>`Animation property path "${A}" has unsupported vector size ${e}`,(A,e)=>`Animation property path "${A}" could not resolve component "${e}"`,()=>"Additive animation reference must use either referenceFrame or referenceTime, not both",A=>`Additive animation reference time must be a finite non-negative number, got ${A}`,()=>"Weighted glTF animation requires an AnimationManager engine",()=>"Weighted glTF animation requires an AnimationManager engine",()=>"Weighted animation channels for the same property must use the same value size",()=>"Weighted animation channels for the same property must use the same mixing strategy",()=>"Audio engine media streams require a real-time AudioContext.",()=>"Unable to get a 2D context from the visualizer canvas.",()=>"Invalid splat voxel collision data.",(A,e)=>`Collision data: HTTP ${A} for ${e}`,()=>"Collision URL must be an HTTP(S) .voxel.json URL.",()=>"setEffectUniforms: wrapper has no uniform binding.",A=>`setEffectUniforms: unknown uniform binding "${A}".`,A=>`setEffectTexture: unknown texture binding "${A}".`,A=>`EffectRenderTask "${A}" executed before record().`,A=>`EffectRenderer "${A}" recorded before registerEffectRenderer().`,A=>`createEffectWrapper: duplicate binding ${A}.`,(A,e)=>`Effect "${A}" missing uniform binding ${e}.`,(A,e)=>`Effect "${A}" missing texture binding ${e}.`,(A,e)=>`Effect "${A}" missing texture for sampler binding ${e}.`,(A,e,g)=>`writeUniformSlot: ${A} bytes exceeds uniform binding ${e} size ${g}.`,(A,e)=>`setUniformEffectUniforms: ${A} bytes exceeds uniform size ${e}.`,A=>`UniformEffectRenderTask "${A}" executed before record().`,()=>"Device-lost recovery capture requires an enabled recovery coordinator",()=>"WebGPU adapter not available during device recovery",A=>`WebGPU device recovery missing required features: ${A}`,()=>"forceWebGpuDeviceLossForTesting requires a device-lost recovery handler to be enabled first",()=>"WebGPU adapter not available",()=>"Babylon Lite: useFloatingOrigin requires useHighPrecisionMatrix on the engine.",()=>"renderFrame: surface belongs to a different engine.",()=>"Frame-bound post-submit work requires an active frame encoder.",()=>"GPU task timing could not instrument render passes on this command encoder.",()=>"GPU task timing could not instrument compute passes on this command encoder.",()=>"createMipMappedRenderTarget requires a color format and samples: 1.",()=>"Mipmapped render target has been disposed.",()=>"Mipmapped render target requires a single-sample, filterable, renderable color format.",()=>"Mipmapped render target dimensions must be positive integers.",()=>"Mipmapped render target dimensions exceed maxTextureDimension2D.",A=>`RenderTargetDescriptor.size.scale must be a positive finite number (got ${A}).`,()=>"WebGPU context not available",()=>"Babylon Lite: disposeSurface cannot dispose the engine's primary surface \u2014 use disposeEngine instead.",A=>`Flow Graph Editor: unsupported block class ${A}`,()=>"Flow Graph Editor: expected a serialized object",A=>`Flow Graph Editor: graph ${A} has no allBlocks array`,()=>"KHR_interactivity: duplicate type signatures",A=>`KHR_interactivity: unsupported type signature ${A}`,A=>`KHR_interactivity: node references missing declaration #${A}`,(A,e)=>`KHR_interactivity: variable ${A} references missing type #${e}`,(A,e,g)=>`KHR_interactivity: event ${A} value ${e} references missing type #${g}`,(A,e,g)=>`KHR_interactivity: ${A} node ${e} references invalid variable #${g}`,A=>`KHR_interactivity: variable/set node ${A} has invalid variable indices`,(A,e)=>`KHR_interactivity: variable/set node ${A} is missing input for variable #${e}`,(A,e)=>`KHR_interactivity: variable/set node ${A} input for variable #${e} has the wrong type`,A=>`KHR_interactivity: node ${A} is missing its pointer configuration`,(A,e)=>`KHR_interactivity: node ${A} is missing pointer parameter ${e}`,(A,e)=>`KHR_interactivity: node ${A} pointer parameter ${e} has the wrong type`,(A,e)=>`KHR_interactivity: ${A} node ${e} uses a reserved pointer parameter`,(A,e,g)=>`KHR_interactivity: ${A} node ${e} references invalid type #${g}`,(A,e)=>`KHR_interactivity: node ${A} references invalid event #${e}`,(A,e,g)=>`KHR_interactivity: ${A} node ${e} is missing required ${g} input`,(A,e)=>`KHR_interactivity: variable/interpolate node ${A} references invalid variable #${e}`,A=>`KHR_interactivity: variable/interpolate node ${A} can only use slerp with float4`,(A,e)=>`KHR_interactivity: pointer/interpolate node ${A} references invalid type #${e}`,(A,e,g)=>`KHR_interactivity: ${A} node ${e} cannot interpolate ${g}`,(A,e)=>`KHR_interactivity: node ${A} references missing producer node #${e}`,(A,e,g)=>`KHR_interactivity: node ${A} flow ${e} targets missing node #${g}`,A=>`invalid RFC 6901 escape in pointer segment ${A}`,A=>`literal pointer brackets must be doubled in ${A}`,()=>"JSON Pointer Templates must be absolute",A=>`duplicate pointer parameter ${A}`,A=>`ClearTextureTask "${A}": targetTexture or depthTexture is required; color target arrays must not be empty.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": color attachments must reference distinct textures.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": too many color attachments.`,A=>`ClearTextureTask "${A}": attachments must have matching dimensions and sample counts.`,A=>`ClearTextureTask "${A}": build the frame graph before execution.`,A=>`ClearTextureTask "${A}": targetTexture has no live color attachment.`,A=>`ClearTextureTask "${A}": depthTexture has no live depth/stencil attachment.`,A=>`CopyToTextureTask "${A}": either targetTexture or resolveTexture must be provided.`,A=>`CopyToTextureTask "${A}": sourceTexture cannot be the engine scRT because its GPU texture changes every frame.`,A=>`CopyToTextureTask "${A}": sourceTexture has no color texture. The source must be built before this task records.`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture requires a multisampled sourceTexture (got sampleCount=${e}).`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture must be single-sample (got sampleCount=${e}).`,(A,e,g,I,i)=>`CopyToTextureTask "${A}": sourceTexture (${e}x${g}) and resolveTexture (${I}x${i}) must have matching dimensions.`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture requires a multisampled targetTexture (got sampleCount=${e}).`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture must be single-sample (got sampleCount=${e}).`,(A,e,g)=>`CopyToTextureTask "${A}": resolveTexture format (${e}) must match targetTexture format (${g}).`,()=>"CopyToTextureTask: targetTexture has no color format.",A=>`DepthResolveTask "${A}": sourceTexture has no depth attachment.`,A=>`DepthResolveTask "${A}": sourceTexture must be multisampled (sampleCount > 1).`,A=>`DepthResolveTask "${A}": targetTexture has no depth format.`,()=>"FrameGraph target does not expose a frame graph.",A=>`addRenderPass("${A}"): no task is currently recording (called outside Task.record?)`,A=>`buildFrameGraphTask("${A}"): task is not registered in this graph.`,A=>`GenerateMipMapsTask "${A}": targetTexture is required.`,A=>`GenerateMipMapsTask "${A}": build the frame graph before execution.`,A=>`GenerateMipMapsTask "${A}": targetTexture changed or was disposed; rebuild the frame graph before execution.`,A=>`GenerateMipMapsTask "${A}": targetTexture cannot be a swapchain target.`,A=>`GenerateMipMapsTask "${A}": targetTexture must be a single-sample, filterable, renderable 2D color texture with sampling and render-attachment usage.`,A=>`GenerateMipMapsTask "${A}": targetTexture must have mipmaps allocated.`,A=>`Transparent geometry output cannot blend integer format "${A}".`,A=>`Transparent geometry output format "${A}" requires the float32-blendable WebGPU feature or a blendable format override.`,A=>`GeometryRendererTask: MESH_BLEND_TAG format must be r8uint, received ${A}.`,()=>"GeometryRendererTask: MESH_BLEND_TAG clearValue must be unsigned integer zero.",()=>"GeometryRendererTask: MESH_BLEND_TAG requires samples: 1.",()=>"GeometryRendererTask: transparent Node materials cannot write MESH_BLEND_TAG because their graph alpha is unavailable to the geometry terminal. Exclude transparent meshes or omit the tag attachment.",()=>"GeometryRendererTask: textureDescriptions must contain at least one entry.",()=>"GeometryRendererTask: too many color attachments.",A=>`GeometryRendererTask: unknown texture type ${A}.`,(A,e)=>`GeometryRendererTask: depthTexture sampleCount (${A}) must match samples (${e}).`,(A,e)=>`GeometryRendererTask: targetTexture sampleCount (${A}) must match samples (${e}).`,()=>"GeometryRendererTask: targetTexture must have a format.",()=>"GeometryRendererTask: MESH_BLEND_TAG is not enabled.",()=>"overdraw probe: this device has no timestamp-query feature",()=>"overdraw probe: tasks that load existing depth cannot be measured with a fresh-depth replay",()=>"overdraw probe: task render target has no size (has the task rendered yet?)",()=>"overdraw probe: task target has no color+depth signature to replicate",()=>"overdraw probe: task has no draw bindings (has the task rendered yet?)",()=>"overdraw probe: task scene bindings have not been recorded",()=>"overdraw probe: timestamp readback produced no usable samples",A=>`PostProcessTask "${A}": sourceTexture has no color texture. Render the source to an offscreen RenderTarget before post-processing.`,A=>`PostProcessTask "${A}": multisampled source textures are not supported. Use a sampleCount: 1 source RenderTarget.`,A=>`PostProcessTask "${A}": outputTexture must have a format.`,(A,e)=>`PostProcessTask "${A}": extra texture ${e} has no color texture.`,A=>`PostProcessTask "${A}": sourceTexture must have a format.`,()=>"enableRenderTaskMeshRefresh must be called before the render task is recorded.",()=>"enableRenderTaskMeshRefresh requires an explicit render task with autoMirror: false.",()=>"RenderTask has been disposed.",()=>"Material group has not completed its initial build in this scene.",()=>"RenderTask has been disposed.",()=>"buildClusteredLightGpuState: scene.camera is required",()=>"ClusteredLightContainer: light count cannot grow after GPU state creation.",A=>`setLightDiffuseColor: expected finite RGB components, got ${A}`,A=>`setLightIntensity: expected a finite intensity, got ${A}`,()=>"Device-lost Scene recovery requires environment loading after recovery was enabled",(A,e,g)=>`Device-lost Scene recovery could not refetch '${A}' (${e} ${g}).`,()=>"Procedural sky environment requires finite non-negative scattering, non-zero total scattering, a non-zero sun direction, and positive luminance.",()=>"Procedural sky environment has been disposed.",()=>"Procedural sky environment no longer owns the scene environment.",()=>"loadProceduralSkyEnvironment cannot load into a disposed scene.",()=>"loadProceduralSkyEnvironment requires a scene without an existing environment.",()=>"loadProceduralSkyEnvironment must run before the scene is registered.",()=>"A procedural sky environment is already loading for this scene.",()=>"Procedural sky environment initialization was cancelled: the scene was disposed, registered, or acquired another environment.",()=>"Procedural sky environment initialization was cancelled.",(A,e)=>`${A}: image ${e} not found`,(A,e)=>`${A}: bufferView ${e} not found`,(A,e,g)=>`${A}: failed to load image ${e} ${g}`,A=>`${A}: image has neither bufferView nor uri`,(A,e)=>`${A}: strided accessor uses unsupported component type: ${e}`,(A,e,g)=>`${A}: strided accessor ${e} uses unsupported component type: ${g}`,(A,e,g)=>`${A}: invalid accessor stride ${e} for accessor ${g}`,A=>`glTF camera ${A}: unsupported projection`,()=>"glTF camera nodes require non-zero uniform scale",A=>`EXT_mesh_gpu_instancing: accessor count mismatch on node ${A}`,A=>`EXT_meshopt_compression: compressed source buffer ${A} is not buffer 0 (unsupported)`,A=>`EXT_meshopt_compression: uncompressed bufferView in buffer ${A} is not buffer 0 (unsupported)`,A=>`glTF sparse: unsupported componentType ${A}`,A=>`glTF sparse: unsupported index componentType ${A}`,A=>`glTF sparse: unsupported value componentType ${A}`,()=>"glTF sparse: indices.componentType is required",(A,e)=>`glTF sparse: index ${A} out of range for accessor of count ${e}`,()=>"Not a valid GLB file",()=>"First GLB chunk is not JSON",()=>"Second GLB chunk is not BIN",(A,e)=>`Failed to load image: ${A} ${e}`,()=>"loadGltf: baseless input can't resolve relative URI; use self-contained GLB or URL with base.",A=>`Unsupported component type: ${A}`,()=>"Image has neither bufferView nor uri",(A,e)=>`Failed to load image: ${A} ${e}`,()=>"Image has neither bufferView nor uri",()=>"Invalid HDR: missing #? signature",A=>`Unsupported HDR format: ${A}`,A=>`Invalid HDR resolution: ${A}`,()=>"Invalid HDR: RLE scanline width does not match image",()=>"Invalid HDR: truncated RLE scanline",()=>"Invalid HDR: zero-length RLE packet",()=>"Invalid HDR: RLE run exceeds scanline",()=>"Invalid HDR: RLE literal exceeds scanline",()=>"Invalid HDR: truncated scanline",(A,e)=>`${A} source ${e}: expected five textures`,A=>`${A} resident environment exceeds admitted GPU capacity`,A=>`${A} active display exceeds admitted GPU capacity`,(A,e)=>`${A} source ${e}: GPU/CPU cache budget admission failed`,(A,e)=>`${A} metadata ${e}: only http and https URLs are supported`,A=>`${A} metadata: Fetch is required`,(A,e,g)=>`${A} metadata ${e}: HTTP ${g}`,(A,e)=>`${A} metadata ${e}: Content-Length exceeds maxCpuBytes admission`,(A,e)=>`${A} metadata ${e}: response has no body`,(A,e)=>`${A} metadata ${e}: streamed body exceeds maxCpuBytes admission`,(A,e,g)=>`${A} bootstrap coarse representation (${e} splats) exceeds maxSplats (${g})`,A=>`${A} attach: stream is disposed`,A=>`${A} attach: scene and stream use different engines`,A=>`${A} attach: stream is already attached to another scene`,A=>`${A} attach: attach before or during scene registration`,(A,e)=>`[GaussianSplatStream] GPU ${A} buffer size ${e} exceeds device limits`,()=>"[GaussianSplatStream] GPU budget/device limits cannot admit one canonical splat",()=>"[GaussianSplatStream] GPU budget cannot admit canonical stream state",()=>"[GaussianSplatStream] GPU upload requires exactly five source images",()=>"[GaussianSplatStream] GPU byte upload requires five exact RGBA8 images",()=>"[GaussianSplatStream] GPU state is disposed",()=>"[GaussianSplatStream] GPU interval is outside admitted source/canonical bounds",()=>"[GaussianSplatStream] GPU budget cannot admit pass-local projection and radix state",()=>"[GaussianSplatStream] GPU budget cannot protect submission-local gather parameters",()=>"[GaussianSplatStream] GPU budget cannot admit submission-local gather parameters",(A,e)=>`${A} transport ${e}: invalid Content-Length`,(A,e)=>`${A} transport ${e}: unsafe Content-Length`,(A,e)=>`${A} image ${e}: invalid WebP header`,(A,e)=>`${A} image ${e}: invalid lossless WebP header`,(A,e)=>`${A} image ${e}: unsupported WebP header`,A=>`${A} transport: Fetch and createImageBitmap are required`,A=>`${A} transport: reserveGpuBytes requires gpuLedger for reservation cleanup`,(A,e,g)=>`${A} ${e}: maxCpuBytes cannot admit ${g} bytes`,(A,e,g)=>`${A} ${e}: maxCpuBytes cannot admit ${g} bytes without blocking payloads retained by the same preparation`,(A,e)=>`${A} transport ${e}: response has no body`,(A,e)=>`${A} image ${e}: dimensions do not match the source`,A=>`${A} selection: invalid view-projection frustum`,A=>`${A} selection: viewProjectionMatrix must contain 16 values`,A=>`${A} selection: viewProjectionMatrix must be finite`,A=>`${A} selection: worldMatrix must contain 16 values`,A=>`${A} selection: world transform produced nonfinite bounds`,A=>`${A} selection: cameraPosition must be finite`,A=>`${A} selection: invalid planner parameters`,A=>`${A} selection: orthographic cameras are unsupported`,A=>`${A} selection: invalid planner parameters`,A=>`${A} bootstrap: manifest has no positive coarse source`,A=>`loadSOG: decoded WebP has zero dimensions (input size ${A})`,()=>"loadSOG: failed to acquire 2D context for WebP decode",()=>"loadSOG: means.mins/means.maxs must be arrays",()=>"loadSOG: SOG v2 missing scales codebook",()=>"loadSOG: scales.mins/maxs must be arrays for SOG v1",()=>"loadSOG: SOG v2 missing sh0 codebook",()=>"loadSOG: sh0.mins/maxs must be arrays for SOG v1",A=>`loadSOG: invalid quaternion mode ${A}`,()=>"loadSOG: SOG v2 missing shN codebook",(A,e)=>`loadSOG: HTTP ${A} for ${e}`,()=>"loadSOG: meta.json not found in archive",A=>`loadSOG: missing image '${A}' inside archive`,(A,e)=>`loadSplat: HTTP ${A} for ${e}`,A=>`loadSplat: failed to parse PLY at ${A} (unsupported property layout)`,()=>"loadSPZ: file too short to contain header",(A,e)=>`loadSPZ: unsupported SPZ stream (magic=0x${A} version=${e})`,(A,e)=>`loadSPZ: HTTP ${A} for ${e}`,()=>"Invalid compressed PLY: packed vertex properties require chunk metadata for every vertex",()=>"zip: EOCD record not found",()=>"zip: ZIP64 archives are not supported",A=>`zip: bad central directory signature at offset ${A}`,()=>"zip: encrypted entries are not supported",()=>"zip: ZIP64 archives are not supported",A=>`zip: bad local file header signature at offset ${A}`,(A,e)=>`zip: unsupported compression method ${A} for entry '${e}'`,(A,e,g)=>`zip: entry '${A}' decompressed size mismatch (got ${e}, expected ${g})`,A=>`Duplicate USD mesh ${A}`,()=>"Invalid USD analytic primitive",A=>`Missing USD material ${A}`,()=>"Invalid USD animation target, property, or value stride",()=>"Invalid USD animation samples",()=>"Invalid USD triangle indices",()=>"Non-finite USD positions",()=>"Non-finite USD vertex data",()=>"Invalid USD material subset index range",()=>"USD instance references a missing source",A=>`USD mesh ${A} cannot mix classic and thin instances`,()=>"USD command buffer must contain exactly one scene",()=>"Invalid USD stage metadata",A=>`Duplicate USD geometry ${A}`,A=>`Duplicate or reserved USD mesh ${A}`,A=>`Missing USD geometry ${A}`,()=>"USD mesh has no material subsets",()=>"Invalid USD material subset vertex range",A=>`Missing USD material ${A}`,(A,e)=>`Invalid USD ${A} texture output channel ${e}`,A=>`Duplicate USD material ${A}`,A=>`Non-finite USD material ${A}`,(A,e)=>`USD material ${A} has a channel without texture ${e}`,(A,e)=>`USD material ${A} references texture ${e} without a texture command`,A=>`Invalid or duplicate USD morph target ${A}`,A=>`USD morph target ${A} contains invalid vertex data`,A=>`USD morph targets reference missing mesh ${A}`,A=>`USD morph target vertex count does not match mesh ${A}`,A=>`Duplicate or reserved USD node ${A}`,()=>"Non-finite USD transform",()=>"Cyclic or missing USD parent node",()=>"Invalid USD command buffer",()=>"Unsupported USD command protocol version",()=>"Truncated USD command header",A=>`Invalid USD command ${A} payload`,()=>"Unexpected trailing USD commands",()=>"Invalid USD data range",A=>`Invalid or duplicate USD skeleton ${A}`,A=>`USD skeleton ${A} has an invalid parent or duplicate bone ID`,A=>`USD skeleton ${A} has a non-finite joint transform`,A=>`USD skeleton ${A} has a singular bind transform`,()=>"USD mesh references a missing skeleton",()=>"Missing or unsupported USD mesh skin",()=>"Invalid USD skin weights or joint indices",A=>`Duplicate USD texture ${A}`,A=>`Missing USD texture ${A}`,()=>"Unsupported USD texture encoding, wrap mode, UV set, or color space",()=>"Invalid USD texture transform",A=>`USD thin instances reference missing source ${A}`,A=>`USD mesh ${A} has duplicate or mixed instances`,A=>`USD thin instances for mesh ${A} contain a non-finite transform`,A=>`USD file path must be relative: ${A}`,A=>`Could not load USD: HTTP ${A}`,A=>`Duplicate USD virtual file: ${A}`,A=>`LineMaterial "${A}" requires thin-instance data`,()=>"createLineMaterial requires useThinInstances when useThinInstanceColors is enabled",(A,e)=>`NodeMaterial: cannot pick common numeric type from ${A} and ${e}`,A=>`NodeMaterial: AmbientOcclusionBlock "${A}" requires an ImageSourceBlock source`,()=>"BiPlanarBlock: texture projection is supported only in the fragment stage",A=>`NodeMaterial: ColorSplitterBlock (id=${A}) has no connected input`,A=>`NodeMaterial: ColorSplitterBlock has no output "${A}"`,A=>`NodeMaterial: unknown CurveBlock curveType ${A}`,A=>`NodeMaterial: CurveBlock does not support ${A}`,()=>"NodeMaterial: FragDepthBlock requires `depth` or both `worldPos` and `viewProjection` inputs",A=>`NodeMaterial: HeightToNormalBlock "${A}" requires worldTangent when generateInWorldSpace is false`,A=>`InputBlock: unknown mesh attribute "${A}"`,(A,e)=>`InputBlock: unsupported systemValue ${A} on block "${e}"`,A=>`LoopBlock "${A}": index can only be read while emitting the loop body`,A=>`LoopBlock "${A}": loopID can only be consumed by StorageReadBlock/StorageWriteBlock`,(A,e)=>`LoopBlock "${A}": unsupported output "${e}"`,A=>`NodeMaterial: MatrixSplitterBlock has no output "${A}"`,A=>`NodeMaterial: unsupported matrix block "${A}"`,()=>"NodeMaterial: NLerpBlock requires a vector left/right input; Babylon.js emits normalize(mix(...)) for this block",()=>"NodeMaterial: PBR-MR core emitter cannot emit optional PBR feature code",()=>"NodeMaterial: PBR-MR core helper cannot emit optional PBR feature code",A=>`NodeMaterial: RandomNumberBlock requires a vector seed so Babylon.js getRand(seed.xy) can be emitted; got ${A}`,A=>`ReflectionTextureBaseBlock "${A}" is an abstract compatibility block and cannot be emitted directly.`,A=>`ReflectionTextureBlock: coordinatesMode ${A} not supported (only EQUIRECTANGULAR_MODE=7)`,A=>`NodeMaterial: ReplaceColorBlock requires a vector/color value; got ${A}`,(A,e)=>`StorageReadBlock "${A}": unsupported output "${e}"`,A=>`StorageReadBlock "${A}": loopID input is not connected`,(A,e)=>`StorageReadBlock "${A}": loop ${e} is not active`,()=>"NodeMaterial: TBNBlock object output is not supported; use row0/row1/row2 outputs",A=>`NodeMaterial: TeleportOutBlock (id=${A}) has no entryPoint`,(A,e)=>`NodeMaterial: TeleportOutBlock (id=${A}) points to missing TeleportInBlock ${e}`,()=>"TriPlanarBlock: texture projection is supported only in the fragment stage",A=>`NodeMaterial: VectorSplitterBlock (id=${A}) has no connected input`,A=>`NodeMaterial: VectorSplitterBlock has no output "${A}"`,A=>`NodeMaterial: WaveBlock does not support ${A}`,A=>`NodeMaterial: unknown WaveBlock kind ${A}`,A=>`NodeMaterial: invalid block selection "${A}": use an exported block descriptor`,A=>`NodeMaterial: duplicate block selection "${A}"`,A=>`NodeMaterial: no emitter selected for block "${A}"`,(A,e,g)=>`NodeMaterial: cannot cast ${A} to ${e} for expression \`${g}\``,(A,e)=>`${A}: unsupported BJS connection point type 0x${e}`,(A,e,g)=>`NodeMaterial: block "${A}" (id=${e}) has no input "${g}"`,(A,e,g)=>`NodeMaterial: block "${A}" (id=${e}) input "${g}" is not connected`,(A,e,g)=>`NodeMaterial: dangling connection ${A}.${e} -> block ${g}`,A=>`NodeMaterial: no emitter loaded for block "${A}"`,()=>"NodeMaterial: only vertex->fragment varyings are supported",A=>`NodeMaterial: fragment root block ${A} not found`,A=>`NodeMaterial: no emitter for fragment root "${A}"`,A=>`NodeMaterial: vertex root block ${A} not found`,A=>`NodeMaterial: no emitter for vertex root "${A}"`,()=>"NodeMaterial: PBR/Reflection block requires scene environment but scene._envTextures is unset. Call loadEnvironment() before registerScene().",()=>"node-geometry view does not support scene group building",()=>"node-geometry rebuild requires task-owned resources",A=>`Transparent geometry output cannot blend integer format "${A}".`,A=>`Transparent geometry output format "${A}" requires the float32-blendable WebGPU feature or a blendable format override.`,()=>"NodeMaterial geometry view: graph has no GeometryTextureOutputBlock",()=>"NodeMaterial geometry view: morph / env / shadow inputs are not supported in the geometry pass",()=>"node-geometry: render target has no color attachments",(A,e)=>`NodeMaterial geometry view: texture binding "${A}" not set. Provide it via material.inputs["${e}"].texture before the first render.`,()=>"NodeMaterial geometry view: NORMALIZED_VIEW_DEPTH requested but no geometry-params UBO was provided by the task.",()=>"NodeMaterial geometry view: emitColor (real-color target) is not supported \u2014 omit targetTexture on the geometry task.",()=>"NodeMaterial: graph has no FragmentOutputBlock",()=>"NodeMaterial: advanced PBR-MR helper request must be emitted by the full PBR-MR block",()=>"NodeMaterial: invalid source \u2014 expected `.blocks` array",A=>`NodeMaterial: block missing numeric id (name=${A})`,(A,e)=>`NodeMaterial: cycle detected through block ${A} (${e})`,A=>`NodeMaterial: dangling reference to block ${A}`,A=>`NodeMaterial: helper key "${A}" registered with conflicting source bodies`,A=>`NodeMaterial: no advanced extension emitter registered for block "${A}"`,A=>`NodeMaterial: no compatibility extension emitter registered for block "${A}"`,A=>`NodeMaterial: no math extension emitter registered for block "${A}"`,A=>`NodeMaterial: no procedural extension emitter registered for block "${A}"`,(A,e)=>`NodeMaterial: texture binding "${A}" not set. Provide it via options.textures or material.inputs["${e}"].texture before the first render.`,A=>`NodeMaterial: material requires shadow generator #${A} but none was supplied to parseNodeMaterialFromSnippet({ shadowGenerators }).`,A=>`NodeMaterial: unsupported attribute "${A}"`,(A,e)=>`NodeMaterial: snippet fetch failed (${A}) for ${e}`,A=>`NodeMaterial: snippet "${A}" has no jsonPayload`,A=>`NodeMaterial: snippet "${A}" has no nodeMaterial`,(A,e)=>`[babylon-lite] ${A} must contain three finite${e} values`,A=>`[babylon-lite] ${A} must be finite and positive`,A=>`[babylon-lite] local probe ${A} influenceInnerRadius must be finite, non-negative, and no larger than influenceOuterRadius`,A=>`[babylon-lite] local probe ${A} inner influence box must be non-negative and contained by the outer influence box`,A=>`[babylon-lite] local probe ${A} angleRadians must be finite`,A=>`[babylon-lite] local probe ${A} debugColor must contain three finite values from 0 to 1`,()=>"[babylon-lite] local probe cubemap dimensions must differ only by power-of-two mip levels",()=>"[babylon-lite] local probe voxelGrid.cellSize must be finite and positive",()=>"[babylon-lite] local probe voxelGrid.maximum must be greater than minimum on every axis",()=>"[babylon-lite] local probe voxel grid dimensions are too large",()=>"[babylon-lite] local probe voxel grid dimensions are too large",(A,e,g,I,i)=>`[babylon-lite] local probe voxel (${A}, ${e}, ${g}) intersects ${I} probes, exceeding maxCandidates ${i}`,()=>"[babylon-lite] local probe cubemaps require COPY_SRC usage; call enablePbrLocalCubemap() before loading DDS or HDR probe environments, or create custom probe textures with COPY_SRC",()=>"[babylon-lite] local probe cubemaps must be square six-face textures with one shared format",()=>"[babylon-lite] local probe cubemaps have no common mip range",(A,e)=>`[babylon-lite] local probe set has ${A} probes, but this device supports at most ${e} cube-array probes`,(A,e)=>`[babylon-lite] local probe UBO requires ${A} bytes, but this device supports ${e}`,A=>`[babylon-lite] local probe voxel grid requires ${A} bytes, exceeding this device's storage-buffer limits`,A=>`[babylon-lite] local probe sets require 1..${A} probes`,()=>"Environment rotation: skybox direction declaration not found.",(A,e)=>`${A}: expected to rewrite 1 occurrence, rewrote ${e}`,A=>`local probe array _postCompose: expected to rewrite 1 voxel-grid binding declaration, rewrote ${A}`,A=>`local probe array _postCompose: expected to rewrite 1 cube-array binding declaration, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 clearcoat reflection direction, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 clearcoat radiance sample, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 sheen radiance sample, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 reflection direction, rewrote ${A}`,()=>"local cubemap _postCompose: expected at least 1 environment LOD scale rewrite",A=>`local cubemap _postCompose: expected to rewrite 1 base radiance sample, rewrote ${A}`,A=>`[babylon-lite] local cubemap could not replace the scene ${A} binding`,()=>"PBR transmission requires a frame-graph refraction texture.",()=>"composePbrGeometryShader: PBR fragment signature mismatch \u2014 _noColorOutput/_esmShadowOutput should be off",()=>"composePbrGeometryShader: alpha-block return statement not found \u2014 template changed?",()=>"pbr-geometry view does not support scene group building",()=>"pbr-geometry rebuild requires task-owned resources",()=>"buildPbrGeometryRenderable: scene has no PBR context. Ensure regular PBR meshes have been built before recording the geometry task.",()=>"pbr-geometry: render target has no color attachments",A=>`[babylon-lite] local cubemap maxCandidates is already ${A} and cannot be changed after initialization`,A=>`[babylon-lite] local cubemap maxCandidates must be an integer from 1 to ${A}`,()=>"PBR material plugin vertex signature is not registered.",()=>"PBR material plugin vertex uniforms require a material UBO.",A=>`Material plugin varying type "${A}" is unsupported; use a floating-point scalar or vector.`,()=>"Standard material plugin signature is not registered.",()=>"Standard material plugins require an owning scene.",()=>"Standard plugin material requires a scene mesh or a binding owner.",()=>"Standard material plugin signature is not registered.",()=>"setShadowCasterMaterial: the caster chain must not cycle back to the source material",()=>"Async ShaderMaterial pipeline preparation could not capture the synchronous descriptor.",()=>'enableShaderMaterialInstanceWorld requires the ShaderMaterial to declare the "world" system uniform.',A=>`ShaderMaterial: external texture "${A}" has no source. Call setShaderExternalTexture() before rendering.`,A=>`ShaderMaterial: external texture "${A}" is not ready.`,A=>`ShaderMaterial: external texture "${A}" was not declared.`,A=>`ShaderMaterial: external texture "${A}" was not declared.`,(A,e)=>`ShaderMaterial: ${A} name "${e}" is not a valid WGSL identifier.`,()=>"ShaderMaterial: vertexSource and fragmentSource must be non-empty WGSL strings.",()=>"ShaderMaterial: strip topologies are unsupported because indexed draws require a mesh-specific stripIndexFormat.",A=>`ShaderMaterial: unsupported attribute "${A}". Supported attributes: position, normal, uv, uv2, tangent, color, joints, weights, joints1, weights1.`,A=>`ShaderMaterial: duplicate attribute "${A}".`,()=>'ShaderMaterial: "position" attribute is required for mesh rendering.',A=>`ShaderMaterial: define "${A}" must be a boolean or number.`,()=>"ShaderMaterial: `transmissive` requires `needAlphaBlending` (the surface composites over the grabbed opaque scene color).",A=>`ShaderMaterial: custom uniform "${A}" must use an explicit typed declaration.`,(A,e)=>`ShaderMaterial: unsupported uniform type "${A}" for "${e}".`,(A,e)=>`ShaderMaterial: duplicate generated identifier "${A}" while adding ${e}.`,(A,e,g,I)=>`ShaderMaterial: uniform "${A}" of type ${e} expects ${g} value(s), got ${I}.`,A=>`ShaderMaterial: uniform "${A}" was not declared.`,(A,e,g,I)=>`ShaderMaterial: uniform "${A}" of type ${e} expects ${g} value(s), got ${I}.`,A=>`ShaderMaterial: uniform "${A}" was not declared.`,A=>`ShaderMaterial: sampler "${A}" was not declared.`,A=>`ShaderMaterial: sampler "${A}" expects a depth Texture2D.`,A=>`ShaderMaterial: sampler "${A}" cannot use a depth Texture2D.`,A=>`ShaderMaterial: sampler "${A}" was not declared.`,A=>`ShaderMaterial: storage buffer "${A}" was not declared.`,()=>"setShaderStorageBuffer requires a StorageBuffer created by createStorageBuffer; raw GPUBuffer is not supported.",A=>`ShaderMaterial: storage buffer "${A}" has been disposed.`,()=>"setShaderStorageBuffer requires a live StorageBuffer created by createStorageBuffer.",()=>"ShaderMaterial external textures require setShaderExternalTexture before pipeline preparation.",A=>`ShaderMaterial: sampler "${A}" has no Texture2D. Call setShaderTexture() before rendering.`,A=>`ShaderMaterial storage "${A}" is invalid.`,(A,e,g)=>`ShaderMaterial format "${A}" for "${e}" is incompatible with canonical geometry on mesh "${g}".`,(A,e,g)=>`ShaderMaterial format "${A}" for "${e}" does not fit the aligned vertex layout on mesh "${g}".`,()=>"Standard UV transform _bind requires the scene argument from the Standard bind-group builder",()=>"composeStandardGeometryShader: standard fragment signature mismatch \u2014 bypass active?",()=>"composeStandardGeometryShader: 'return color;' not found in composed fragment \u2014 template changed?",()=>"standard-geometry view does not support scene group building",()=>"standard-geometry rebuild requires task-owned resources",()=>"standard-geometry: skeletal velocity feature was not preloaded",()=>"standard-geometry: thin instances were not preloaded",()=>"standard-geometry: morph targets require the scene Standard morph context",()=>"standard-geometry: thin instances were not preloaded",()=>"standard-geometry: skeletal velocity requires a previous-bone texture",()=>"standard-geometry: render target has no color attachments",()=>"Standard material group has not completed its initial build in this scene.",()=>"Dashed lines require at least two points",()=>"createDashedLines produced no dash segments (degenerate points or dashNb)",()=>"updateDashedLines requires a mesh created by createDashedLines",A=>`Line system data requires finite ${A} components`,()=>"Line system data requires one color row per line",()=>"Line system data requires one color per point",()=>"createLineSystemData requires at least one point",()=>"createLineSystem requires material.useVertexColor to match the line color-buffer layout",()=>"updateLineSystem requires a mesh created by createLineSystem",()=>"updateLineSystem requires unchanged line and point counts",()=>"updateLineSystem requires unchanged line and point counts",()=>"updateLineSystem cannot add colors to a mesh created without vertex colors",A=>`createCsgFromMesh("${A}") requires CPU positions. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsgFromMesh("${A}") requires CPU indices. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsgFromMesh("${A}") requires CPU normals. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,(A,e)=>`createMeshesFromCsg("${A}") missing material for CSG material slot ${e}.`,()=>"CSG2 is not initialized. Call and await initializeCsg2Async() before using CSG2 operations.",A=>`${A} cannot use a disposed CSG2 solid.`,A=>`createCsg2FromMesh("${A}") requires CPU positions. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsg2FromMesh("${A}") requires CPU indices. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsg2FromMesh("${A}") requires CPU normals. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,(A,e)=>`createCsg2FromMesh("${A}") materialSlot must be an integer from 0 to ${e}.`,()=>"CSG2 operations require solids with the same vertex property layout.",(A,e)=>`createMeshesFromCsg2("${A}") received an unknown Manifold material original ID ${e}.`,A=>`Unable to build CSG2 mesh "${A}". Manifold has 0 vertices for this output.`,(A,e)=>`createMeshesFromCsg2("${A}") missing material for CSG2 material slot ${e}.`,()=>"enableThinInstanceWorldBounds requires mesh.thinInstances",()=>"createHierarchyInstancePool capacity must be a non-negative integer",()=>"createHierarchyInstancePool requires at least one mesh in the source hierarchy",A=>`createHierarchyInstancePool mesh "${A}" already has thin instances`,A=>`createHierarchyInstancePool requires an invertible world matrix for mesh "${A}"`,()=>"addHierarchyInstance exceeded pool capacity",()=>"setHierarchyInstanceCount count must be an integer within pool capacity",A=>`setHierarchyInstanceCount mesh "${A}" is missing thin instance data`,A=>`HierarchyInstancePool mesh "${A}" is missing thin instance data`,A=>`${A} index must reference an active hierarchy instance`,()=>"setMeshDrawRange requires live, owned, unshared, tightly-packed geometry",()=>"setMeshDrawRange requires undeformed uint32 geometry",()=>"setMeshDrawRange requires coherent retained CPU geometry",()=>"setMeshDrawRange requires coherent retained CPU geometry",()=>"setMeshDrawRange requires ranges within geometry capacity and WebGPU limits",()=>"setMeshDrawRange index must be relative to the selected vertex window",()=>"mesh geometry update requires valid ranges within the active geometry",()=>"updateMeshGeometryCapacity requires unshared, tightly-packed mesh geometry",()=>"updateMeshGeometryCapacity requires coherent triangle-list geometry with uint32 indices",()=>"updateMeshGeometryCapacity requires unchanged optional-attribute layout",A=>`mesh attribute updates require unshared, tightly-packed geometry; update the source StorageBuffer instead: ${A}`,()=>"mesh attribute update requires a valid tightly-packed vertex range",()=>"mesh attribute update requires a valid destination vertex range",()=>"updateMeshGeometry requires unshared, tightly-packed mesh geometry",()=>"updateMeshGeometry requires unchanged vertex/index counts; use resizeMeshGeometry for topology changes",()=>"updateMeshGeometry requires unchanged optional-attribute layout; use resizeMeshGeometry for layout changes",()=>"updateMeshGeometryCapacity requires reserveFactor >= 1",A=>`resizeMeshGeometry requires owned, tightly-packed geometry; recreate or update the source StorageBuffer instead: ${A}`,()=>"resizeSharedMeshGeometry requires at least one mesh",()=>"resizeSharedMeshGeometry requires meshes sharing one owned, tightly-packed geometry",()=>"resizeSharedMeshGeometry requires distinct, live meshes sharing one geometry",()=>"createMeshFromStorageBuffer: storage must be created with { vertex: true } so it carries GPUBufferUsage.VERTEX.",A=>`createMeshFromStorageBuffer: arrayStride must be a positive multiple of 4 within maxVertexBufferArrayStride, received ${A}.`,(A,e,g)=>`createMeshFromStorageBuffer: invalid vertex range (${A} vertices at baseVertex ${e}) for a ${g}-byte allocation.`,A=>`createMeshFromStorageBuffer: unsupported attribute offset "${A}".`,A=>`createMeshFromStorageBuffer: offset for "${A}" must be a non-negative integer smaller than arrayStride.`,()=>"createMeshFromStorageBuffer: indices must be a Uint16Array, Uint32Array, or index-capable StorageBuffer.",A=>`createMeshFromStorageBuffer: indexFormat must match the typed-array format "${A}".`,()=>"createMeshFromStorageBuffer: indices must be created with { index: true }.",()=>'createMeshFromStorageBuffer: a shared index allocation requires indexFormat "uint16" or "uint32".',()=>"createMeshFromStorageBuffer: indexCount must be a positive unsigned 32-bit integer.",(A,e)=>`createMeshFromStorageBuffer: indexCount ${A} exceeds the index source capacity of ${e}.`,(A,e,g)=>`createMeshFromStorageBuffer: indices[${A}] (${e}) must be less than vertexCount ${g}.`,()=>"setMeshIndexedIndirect: mesh has been disposed.",()=>"setMeshIndexedIndirect: only plain meshes without thin instances are supported.",()=>"setMeshIndexedIndirect: mesh must use a ShaderMaterial.",()=>"setMeshIndexedIndirect: mesh must have storage-backed geometry.",()=>"setMeshIndexedIndirect: storage-backed geometry must belong to the same engine and device; recreate its allocations and mesh.",()=>"setMeshIndexedIndirect: geometry changed; recreate or explicitly rebind the consumer.",()=>"setMeshIndexedIndirect: index allocation changed; explicitly rebind the consumer.",()=>"setMeshIndexedIndirect: mesh has been disposed.",()=>"setMeshIndexedIndirect: arguments must be a live StorageBuffer or null.",()=>"setMeshIndexedIndirect: cannot change a borrow while a frame encoder is active.",()=>"setMeshIndexedIndirect: arguments must be created with { indirect: true }.",()=>"setMeshIndexedIndirect: byteOffset must be a non-negative safe integer and multiple of 4.",(A,e)=>`setMeshIndexedIndirect: twenty-byte arguments at offset ${A} exceed the buffer's ${e}-byte capacity.`,()=>"setMeshIndexedIndirect: unbinding requires byteOffset zero.",()=>"setMeshIndexedIndirect: cannot change a borrow while a frame encoder is active.",()=>"setMeshIndexedIndirect: unbind arguments before replacing ShaderMaterial with another material family.",()=>"setMeshIndexedIndirect: unbind arguments before enabling thin instances.",()=>"getMeshIndexedDrawInfo: mesh has been disposed.",()=>"getMeshIndexedDrawInfo: only plain meshes without thin instances are supported.",()=>"Thin-instance LOD partners require an opaque, non-transmissive material",()=>"Thin-instance LOD partner requires the source draw to provide instance colors",()=>"setThinInstanceDrawCount requires a fully synchronized fixed-capacity pool",()=>"enableThinInstanceDynamicDrawCount requires mesh.thinInstances",()=>"enableThinInstanceGpuCulling requires mesh.thinInstances",()=>"setThinInstanceCullBoundsPad requires mesh.thinInstances",()=>"setThinInstanceLodPartner requires thinInstances on both meshes",()=>"setThinInstanceLodPartner requires two distinct meshes",()=>"setThinInstanceLodPartner does not support thin-instance data shared by mesh clones",()=>"setThinInstanceLodPartner fullMesh cannot already be an LOD partner",()=>"setThinInstanceLodPartner lodMesh cannot also own an LOD partner",()=>"setThinInstanceLodPartner lodMesh is already paired with another source mesh",()=>"setThinInstanceLodPartner requires source instance colors when the LOD partner uses instance colors",A=>`createNavMesh (tile cache) failed: ${A}`,A=>`createNavMesh (tiled) failed: ${A}`,A=>`createNavMesh failed: ${A}`,A=>`Mesh "${A}" missing CPU geometry for navmesh`,()=>"No navmesh generated. Call createNavMesh first.",()=>"Navmesh not ready. Call createNavMesh first.",()=>"Navmesh has no tile cache. Build with `maxObstacles > 0` to enable obstacles.",()=>"NodeParticle: BasicSpriteUpdateBlock requires SetupSpriteSheetBlock",()=>"NodeParticle: LocalPositionUpdated requires SystemBlock.isLocal",()=>"NodeParticle: LocalPositionUpdated read before local shape position creation",A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} changed value type`,()=>"NodeParticle: emitter provider must return a finite 16-element matrix",()=>"NodeParticle: emitter provider must return a finite 16-element matrix",(A,e)=>`NodeParticle: ParticleTeleportInBlock ${A} does not expose output "${e}"`,(A,e,g)=>`NodeParticle: ${A} ${e} does not expose output "${g}"`,A=>`NodeParticle: graph plumbing cycle ${A}`,(A,e,g)=>`NodeParticle: ${A} ${e} does not support ${g} connections`,A=>`NodeParticle: ParticleTeleportOutBlock ${A} has invalid entryPoint`,(A,e)=>`NodeParticle: ParticleTeleportOutBlock ${A} references missing entryPoint ${e}`,(A,e)=>`NodeParticle: ParticleTeleportOutBlock ${A} entryPoint ${e} is not ParticleTeleportInBlock`,A=>`NodeParticle: graph plumbing cycle ${A}`,A=>`NodeParticle: ParticleTeleportInBlock ${A} input is not connected`,(A,e)=>`NodeParticle: ${A} ${e} input is not connected`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} Particle scope requires particle-only evaluation`,()=>"NodeParticle: invalid source \u2014 expected a `blocks` array",A=>`NodeParticle: block missing numeric id (name=${A})`,()=>"NodeParticle: graph has no SystemBlock",A=>`NodeParticle: failed to load texture "${A}"`,()=>"NodeParticle: unable to decode texture content",()=>"BillboardSpriteSystem requires a depth-stencil render target.",()=>"createParticleBillboard: the particle system has no texture",A=>`syncParticleSprite2DBridgeWithBlendModes: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`syncParticleSprite2DBridgeWithBlendModes: originPx must be finite, got [${A}, ${e}]`,()=>"syncParticleSprite2DBridgeWithBlendModes: bridge-owned layers cannot use the Sprite2D Handle API",()=>"createParticleSprite2DBridge: the particle system has no texture",A=>`createParticleSprite2DBridge: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`createParticleSprite2DBridge: originPx must be finite, got [${A}, ${e}]`,()=>"syncParticleSprite2DBridge: the bridge-owned layer cannot use the Sprite2D Handle API",A=>`syncParticleSprite2DBridge: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`syncParticleSprite2DBridge: originPx must be finite, got [${A}, ${e}]`,()=>"createHeightFieldShape requires either a groundMesh or full explicit heightfield parameters.",()=>"createHeightFieldShape ground mesh has no vertex positions.",A=>`createHeightFieldShape requires a regular (N+1)\xD7(N+1) grid mesh (e.g. from createGroundFromHeightMap); got ${A} vertices, which is not the square of an integer \u2265 2.`,()=>"createHeightFieldShape ground mesh has zero extent in X or Z; cannot build a heightfield.",()=>"Failed to read physics body mass properties.",()=>"Failed to read physics body mass properties.",A=>`Unknown physics rotation axis "${A}".`,()=>"Thin-instance physics requires a nonsingular carrier world transform.",()=>"Thin-instance physics bodies do not support floating-origin worlds.",()=>"Thin-instance physics requires a non-empty matrix buffer before body creation.",()=>"Cannot create physics mesh shape from a singular root transform.",()=>"Cannot create physics mesh shape without vertex positions.",()=>"Cannot create physics mesh shape without triangle indices.",()=>"Physics mesh shapes require a mesh or transform hierarchy.",A=>`Unsupported shape type: ${A}`,()=>"Cannot add physics child shape from a singular parent transform.",()=>"createPhysicsAggregate supports only primitive physics shapes.",(A,e,g)=>`Default GPU picking cannot read "${A}" format "${e}" on mesh "${g}". Use compatible float32 data or exclude this mesh from picking.`,A=>`BloomPostProcessTask "${A}": sourceTexture must have a format.`,A=>`BloomPostProcessTask "${A}": sourceTexture must have a format.`,A=>`DepthOfFieldPostProcessTask "${A}": sourceTexture must have a format.`,A=>`MeshBlendingPostProcessTask "${A}": sourceTexture must have a color format.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} and outputTexture must not alias.`,A=>`MeshBlendingPostProcessTask "${A}": blended rgba32float output requires the float32-blendable WebGPU feature.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must be single-sample.`,(A,e,g)=>`MeshBlendingPostProcessTask "${A}": ${e} has unsupported format "${g}".`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must be a built 2D color render target.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must have the same physical dimensions as outputTexture.`,A=>`MeshBlendingPostProcessTask "${A}": camera projection matrix must be invertible.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": depth source has no depth attachment.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": depth source has no depth attachment.`,()=>"setRenderDrawIndirect: buffer must be a live allocation of the same engine created with indirect: true.",(A,e,g)=>`setRenderDrawIndirect: ${A} argument bytes at offset ${e} must fit the ${g}-byte buffer at a multiple of 4.`,A=>`RenderDrawTask "${A}" has been disposed.`,A=>`RenderDrawTask "${A}" has been disposed.`,A=>`RenderDrawTask "${A}" and its draw belong to different engines.`,A=>`RenderDrawTask "${A}" has been disposed.`,(A,e)=>`RenderDraw: ${A} must be an unsigned 32-bit integer, received ${e}.`,(A,e)=>`RenderDraw ${A}: ${e} buffer is disposed or belongs to a different engine.`,(A,e,g)=>`RenderDraw ${A}: ${e} buffer was not created with the ${g} usage.`,()=>"RenderDraw: binding set belongs to a different RenderShader.",(A,e,g)=>`RenderDraw "${A}": the shader declares ${e} vertex buffers, received ${g}.`,A=>`RenderDraw: binding "${A}" is not a dynamic buffer binding.`,(A,e)=>`RenderDraw: dynamic offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`RenderDraw: dynamic offset for "${A}" exceeds the bound buffer range.`,()=>"Alpha-to-coverage is not supported for NodeMaterial.",()=>"Uniform copies require 4-byte-aligned sizes and destination offsets.",A=>`createStorageBuffer: byte length must be a non-negative safe integer; received ${A}.`,(A,e)=>`createStorageBuffer: aligned byte length ${A} must be a safe integer within device maxBufferSize (${e}).`,()=>"StorageBuffer belongs to a previous device; recreate GPU-role allocations and rerun their producers after device loss.",()=>"StorageBuffer has been disposed.",()=>"StorageBuffer belongs to a different engine.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer has been disposed.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer belongs to a different engine.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer byteOffset must be a non-negative multiple of 4.",()=>"StorageBuffer update data must have a byte length that is a multiple of 4.",A=>`StorageBuffer update exceeds its ${A}-byte capacity.`,()=>"StorageBuffer is not a live registered allocation.",A=>`Mesh "${A}" cannot be added: it was disposed when it left its last scene. Create a new mesh instead.`,A=>`morph _postCompose: expected to rewrite 2 binding declarations, rewrote ${A}`,()=>"getCsmReceiverTexture requires a CSM shadow generator",()=>"Render-task transfers require live tasks in the same scene.",()=>"Deformable shadows require a fully initialized shadow generator",()=>"setShadowGeneratorEnabled requires a configured shadow generator.",A=>`Device-lost Scene recovery does not support shadow generator type "${A}"`,()=>"Device-lost Scene recovery could not find ESM shadow resources",()=>"Device-lost Scene recovery failed to create ESM shadow resources",()=>"AnimationController.tick requires an EngineContext for skeleton or morph animation",()=>"Cannot update disposed skeleton",()=>"Invalid bone matrices",()=>"createBillboardCustomShader: `fragment` must be a non-empty WGSL string.",()=>"BillboardSpriteSystem requires a depth-stencil render target.",()=>"addBillboardSprite: handle id space exhausted.",(A,e)=>`${A}: BillboardSpriteHandle ${e} has been removed.`,()=>"BillboardSpriteSystem: alphaCutoff must be a finite number.",()=>"BillboardSpriteSystem: opacity must be a finite number.",()=>"createAxisLockedBillboardSystem: axis components must be finite numbers.",()=>"createAxisLockedBillboardSystem: axis must be non-zero.",()=>"addBillboardSpriteIndex: props.position is required.",()=>"addBillboardSpriteIndex: props.sizeWorld is required.",(A,e)=>`updateBillboardSpriteIndex: index ${A} out of range [0, ${e})`,(A,e)=>`removeBillboardSpriteIndex: index ${A} out of range [0, ${e})`,(A,e)=>`setBillboardSpriteFrameIndex: index ${A} out of range [0, ${e})`,(A,e)=>`${A}: extra texture name "${e}" is not a valid WGSL identifier.`,(A,e,g,I)=>`${A}: frame ${e} has non-positive size ${g}x${I}.`,(A,e,g,I)=>`${A}: frame ${e} has negative sub-rect origin (srcX=${g}, srcY=${I}).`,(A,e,g,I)=>`${A}: frame ${e} sub-rect row extent (srcX + width) * 4 = ${g} exceeds srcStrideBytes ${I} (would spill into next row).`,(A,e,g,I)=>`${A}: frame ${e} width ${g} exceeds shelf max width ${I}.`,(A,e,g,I,i,C)=>`${A}: cannot fit frame ${e} (${g}x${I}) \u2014 atlas height capacity ${i} exhausted at y=${C}.`,()=>"createSpriteAtlasFromFrames: at least one frame is required, or pass options.capacityPx to create an empty atlas with reserved capacity for appendSpriteAtlasFrames.",(A,e)=>`createSpriteAtlasFromFrames: atlas dimensions must be >= 1 (got ${A}x${e}).`,(A,e,g,I)=>`createSpriteAtlasFromFrames: capacityPx ${A}x${e} too small for initial content ${g}x${I}.`,()=>"appendSpriteAtlasFrames: atlas was not built by createSpriteAtlasFromFrames (no packer state).",()=>"loadSpriteAtlas: metadataUrl unsupported.",()=>"loadSpriteAtlas: gridSize required.",(A,e)=>`resolveSpriteFrame: index ${A} out of range [0, ${e})`,()=>"addSprite2D: handle id space exhausted.",(A,e)=>`${A}: Sprite2DHandle ${e} has been removed.`,()=>"enableSprite2DInstanceParams: layer requires a customShader.",()=>"enableSprite2DInstanceParams: another instance extension is already installed.",()=>"setSprite2DInstanceParamsIndex: enableSprite2DInstanceParams must be called first.",(A,e)=>`setSprite2DInstanceParamsIndex: index ${A} out of range [0, ${e})`,()=>"setSprite2DInstanceParamsIndex: params must contain exactly four numbers.",()=>"setSprite2DInstanceParamsIndex: params must be finite Float32 values.",()=>'enableSprite2DYSort: only depth: "none" layers are supported.',()=>"enableSprite2DYSort: defaultBias must be finite.",()=>"setSprite2DYSortBias: Y-sort is not enabled for this layer.",(A,e)=>`setSprite2DYSortBias: index ${A} out of range [0, ${e})`,()=>"setSprite2DYSortBias: bias must be finite.",()=>"addSprite2DIndex: positionPx required.",(A,e)=>`updateSprite2DIndex: index ${A} out of range [0, ${e})`,(A,e)=>`removeSprite2DIndex: index ${A} out of range [0, ${e})`,(A,e)=>`setSprite2DFrameIndex: index ${A} out of range [0, ${e})`,()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"SpriteAnimationManager is already running autonomously.",()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"Sprite frame animation requires finite from/to frame indices.",()=>"Sprite frame animation requires finite from/to frame indices.",()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"SpriteAnimationManager is already running autonomously.",()=>"createSprite2DCustomShader: `fragment` must be a non-empty WGSL string.",()=>"Sprite pipeline: depth-enabled pipelines require a depth-stencil format.",()=>"Sprite pipeline: depth-enabled pipelines require a scene bind-group layout.",()=>'Depth-hosted sprites require depth != "none".',()=>"Depth-hosted Sprite2DLayer requires a depth-stencil render target.",()=>'SpriteRenderer requires depth: "none".',()=>"SpriteRenderer has been disposed.",A=>`TextData style palette cannot exceed ${A} entries.`,(A,e)=>`updateTextData ${A}: storage does not contain curveSet "${e}" \u2014 add it via updateGlyphStorage first.`,(A,e,g)=>`${A}: run index ${e} out of range (0..${g}).`,A=>`${A}: GlyphRun reference is not in this TextData.`,()=>"updateTextData addRun: GlyphRun reference is already in this TextData.",()=>"updateTextData removeRun: GlyphRun reference is not in this TextData.",()=>"updateTextData replaceRun: previous GlyphRun reference is not in this TextData.",()=>"updateTextData replaceRun: new GlyphRun reference is already in this TextData.",A=>`TextData style palette cannot exceed ${A} entries.`,()=>"Basis: no images in file",()=>"Basis: startTranscoding failed",A=>`Basis: transcoded size is 0 for mip ${A}`,A=>`Basis: transcodeImage failed for mip ${A}`,(A,e)=>`createDynamicTexture: width/height must be >= 1 (got ${A}x${e})`,()=>"createTexture2DFromExternalImage: texture creation did not produce GPU resources",()=>"createHtmlTexture: requires a DOM canvas rendering surface (HTML-in-Canvas is unavailable on OffscreenCanvas).",()=>"KTX: file too small",()=>"KTX: invalid magic",()=>"KTX: unsupported endianness",()=>"KTX: not a compressed texture (glType != 0)",()=>"KTX: not a compressed texture (glFormat != 0)",A=>`KTX: unknown glInternalFormat 0x${A}`,()=>"KTX: 3D textures not supported",()=>"KTX: texture arrays not supported",()=>"KTX: cubemaps not supported (use loadCubeTexture)",()=>"KTX: key/value data overflows buffer",A=>`KTX: truncated at mip ${A} size field`,A=>`KTX: mip ${A} data overflows buffer`,()=>"KTX: no mip levels found",A=>`KTX fetch failed: ${A}`,A=>`KTX2: ${A}`,()=>"KTX2: decoder produced no mipmaps",A=>`KTX2: decoder produced an empty mip ${A}`,A=>`KTX2: device does not support ${A}`,(A,e,g)=>`KTX2: uncompressed mip ${A} has ${e} bytes, expected ${g}`,A=>`KTX2: unsupported transcoded format 0x${A}`,(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,()=>"KTX2: RGBA decode size does not match image dimensions",A=>`KTX2: ${A}`,()=>"KTX2: decoder produced no mipmaps",(A,e)=>`KTX2: expected ${A} base-level layers but decoded ${e}`,(A,e,g,I)=>`KTX2: base-level layer ${A} is malformed (expected ${e}x${g}, ${I} bytes)`,(A,e)=>`createTexture2DFromPixels: width/height must be >= 1 (got ${A}x${e})`,(A,e,g,I)=>`createTexture2DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${g} RGBA, got ${I}`,(A,e)=>`createRenderTexture2D: width/height must be >= 1 (got ${A}x${e})`,(A,e)=>`updateTexture2DFromPixels: width/height must be >= 1 (got ${A}x${e})`,(A,e,g,I)=>`updateTexture2DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${g} RGBA, got ${I}`,(A,e,g)=>`createTexture3DFromPixels: width/height/depth must be >= 1 (got ${A}x${e}x${g})`,(A,e,g,I,i)=>`createTexture3DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${g}x${I} RGBA, got ${i}`,()=>"withSampledDepthTexture requires a single-sample depth attachment.",()=>"createSurfaceRenderTargetTexture: descriptor.size must be a SurfaceContext or { surface, scale }.",()=>"RenderTargetTexture has been disposed.",()=>"RenderTargetTexture cannot resize recursively from a resize callback.",()=>"RenderTargetTexture attachment configuration cannot change during resize.",()=>"RenderTargetTexture has been disposed.",()=>"RenderTargetTexture has been disposed.",()=>"Depth-only render-target textures require withSampledDepthTexture as the third argument.",()=>"createRenderTargetTexture: render target has no color or depth texture (no format / depthStencilFormat?).",()=>"createRenderTargetTexture: descriptor.size must be fixed { width, height } pixels, not a surface-backed size; use createSurfaceRenderTargetTexture for surface-resizing targets.",(A,e,g)=>`createTexture2DArray: width/height/layers must be >= 1 (got ${A}x${e}x${g})`,(A,e)=>`uploadImageToArrayLayer: layer must be an integer in [0, ${A}) (got ${e})`,(A,e)=>`loadImageToArrayLayer: fetch failed for ${A} (${e})`,(A,e)=>`createTexture2DArrayFromUrls: fetch failed for ${A} (${e})`,(A,e,g,I,i)=>`createTexture2DArrayFromUrls: all layers must share one size; layer 0 is ${A}x${e} but layer ${g} is ${I}x${i}`,A=>`Texture array pixel uploads require rgba8unorm or rgba8unorm-srgb, received ${A}.`,(A,e)=>`updateTexture2DArrayFromPixels: mipLevel must be an integer in [0, ${A}) (got ${e})`,(A,e,g,I,i,C)=>`updateTexture2DArrayFromPixels: data too short \u2014 need ${A} bytes for ${e}x${g}x${I} RGBA at mip ${i}, got ${C}`,()=>"KTX2: the decoder does not report layerCount; a decoder with 2D array support is required (see setKtx2DecoderUrl)",(A,e)=>`KTX2: decoder produced ${A} mips, which is not a whole number of ${e}-layer levels`,(A,e,g)=>`KTX2: expected layer ${A} at mip index ${e} but the decoder reported layer ${g}`,(A,e)=>`KTX2: layers of one mip level must share a size (level ${A}, layer ${e})`,(A,e)=>`KTX2: decoder reported invalid dimensions ${A}x${e}`,(A,e)=>`KTX2: decoder produced invalid base mip dimensions ${A}x${e}`,(A,e,g,I,i)=>`KTX2: mip ${A} has size ${e}x${g}, expected ${I}x${i}`,(A,e,g)=>`KTX2: texture dimensions ${A}x${e} exceed maxTextureDimension2D ${g}`,(A,e)=>`KTX2: array has ${A} layers, exceeding maxTextureArrayLayers ${e}`,(A,e,g,I)=>`KTX2: texture ${A}x${e} has ${g} mip levels, exceeding the maximum ${I}`,A=>`KTX2: device does not support ${A}`,(A,e,g,I)=>`KTX2: compressed dimensions ${A}x${e} are not aligned to ${g}x${I} blocks; texture-compression-unaligned is required`,(A,e,g,I)=>`KTX2: compressed mip ${A} layer ${e} has ${g} bytes, expected ${I}`,(A,e,g,I)=>`KTX2: uncompressed mip ${A} layer ${e} has ${g} bytes, expected ${I}`,A=>`KTX2: unsupported transcoded format 0x${A}`,()=>"KTX2: texture-array upload did not produce GPU resources",A=>`KTX2: GPU device was lost or replaced during texture-array upload${A}`,()=>"KTX2: at least one separate layer buffer is required",(A,e)=>`KTX2: separate layer ${A} reports layerCount ${e}; expected one 2D layer`,A=>`KTX2: separate layer ${A} has a different transcoded format`,(A,e,g,I,i)=>`KTX2: separate layer ${A} has size ${e}x${g}, expected ${I}x${i}`,(A,e,g)=>`KTX2: separate layer ${A} has ${e} mip levels, expected ${g}`,(A,e,g,I,i,C)=>`KTX2: separate layer ${A} mip ${e} has size ${g}x${I}, expected ${i}x${C}`,()=>"KTX2: at least one separate layer buffer is required",(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,()=>"KTX2: at least one separate layer URL is required",(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,(A,e,g,I)=>`updateTextureRegion: ${A} must be an integer in [${e}, ${g}], received ${I}.`,()=>"updateTextureRegion: the texture requires copy-destination usage and sampleCount 1.",A=>`updateTextureRegion: ${A} does not support CPU writes with the default copy aspect.`,(A,e)=>`updateTextureRegion: origin and extent must be multiples of the ${A}x${e} texel block.`,()=>"updateTextureRegion: depth/stencil copies must cover the full physical mip width and height.",(A,e,g,I,i)=>`updateTextureRegion: ${A} source bytes cannot hold ${e}\xD7${g}\xD7${I} texels at ${i} bytes per row.`,()=>"createTextureRenderTarget: the texture was not created with render-attachment usage.",A=>`createTextureRenderTarget: ${A} textures cannot be render targets.`,(A,e)=>`createTextureRenderTarget: layer must be an integer in [0, ${A}), received ${e}.`,(A,e)=>`createTextureRenderTarget: mipLevel must be an integer in [0, ${A}), received ${e}.`,()=>"Texture render target has been disposed.",()=>"CPU-only animation evaluation is unavailable for this animation controller",A=>`VAT prepared payload: ${A} must be a positive integer.`,A=>`VAT prepared payload: ${A} must be a record.`,(A,e)=>`VAT prepared payload: ${A} contains invalid bone index "${e}".`,(A,e)=>`VAT prepared payload: ${A}[${e}] has an invalid length.`,()=>"VAT prepared payload: data length must equal boneCount * frameCount * 16.",()=>"VAT prepared payload: clips must be a record.",A=>`VAT prepared payload: clip "${A}" is invalid.`,A=>`VAT preparation: mesh "${A}" has no skeleton to bake.`,(A,e)=>`VAT preparation: mesh "${A}" has no skeleton binding for clip "${e}".`,A=>`VAT preparation: mesh "${A}" has inconsistent bone counts.`,()=>"setVatInstanceStorage: mesh has no VAT data.",()=>"setVatInstanceStorage requires a live StorageBuffer from the same engine.",()=>"setVatTime: mesh has no VAT data.",()=>"attachVat: mesh has no skeleton (bake first, attach before clearing it).",()=>"controllerModels requires XR input tracking; do not pass input:false to enterXr.",()=>"handTracking requires XR input tracking; do not pass input:false to enterXr.",()=>"pointerSelection requires XR input tracking; do not pass input:false to enterXr.",()=>"WebXR is not available (navigator.xr missing).",()=>"WebGPU XR is not supported by this browser (XRGPUBinding missing).",()=>"teleportation requires XR input tracking; do not pass input:false to enterXr.",()=>"Compute binding declaration was not created by a supported resource helper.",(A,e)=>`ComputeBindingSet: resource "${A}" was not declared by ComputeShader "${e}".`,A=>`ComputeBindingSet: binding "${A}" has no resource.`,A=>`ComputeBindingSet for "${A}" has been disposed.`,A=>`ComputeBindingSet: binding "${A}" received the wrong buffer resource type.`,A=>`ComputeBindingSet: resource for "${A}" has been disposed or lost with its previous device; recreate it.`,A=>`ComputeBindingSet: resource for "${A}" belongs to a different engine.`,A=>`ComputeBindingSet: writable binding "${A}" received a read-only resource.`,(A,e)=>`ComputeBindingSet: offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`ComputeBindingSet: dynamic binding "${A}" requires size or a non-zero minBindingSize.`,A=>`ComputeBindingSet: size for "${A}" must be a positive multiple of 4.`,A=>`ComputeBindingSet: binding "${A}" must expose at least 4 bytes.`,(A,e,g)=>`ComputeBindingSet: binding "${A}" provides ${e} bytes but requires at least ${g} bytes.`,(A,e)=>`ComputeBindingSet: binding "${A}" exceeds this device's maximum binding size of ${e} bytes.`,(A,e)=>`ComputeBindingSet: binding "${A}" exceeds its ${e}-byte allocation.`,()=>"ComputeBindingSet contains a disposed or invalid buffer resource.",(A,e,g,I,i)=>`ComputeDispatch: ${A} workgroup dimension must be an integer in [0, ${e}], received ${g}x${I}x${i}.`,()=>"ComputeDispatch: binding set belongs to a different ComputeShader.",A=>`ComputeDispatch: binding "${A}" is not a dynamic buffer binding.`,(A,e)=>`ComputeDispatch: dynamic offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`ComputeDispatch: dynamic offset for "${A}" exceeds the bound buffer range.`,A=>`WebGPU adapter does not support required feature "${A}".`,A=>`ComputeDispatch: immediate data must initialize all ${A} bytes before dispatch.`,()=>"createComputeImmediateShader requires WGSL immediate_address_space support.",A=>`createComputeImmediateShader: immediateByteLength must be a positive multiple of 4 no larger than ${A}.`,()=>"setComputeDispatchImmediates requires a shader created with createComputeImmediateShader.",(A,e)=>`setComputeDispatchImmediates requires exactly ${A} bytes, received ${e}.`,()=>"ComputeDispatch: indirect buffer must be created with { indirect: true }.",()=>"ComputeDispatch: indirect byteOffset must be a non-negative multiple of 4.",(A,e)=>`ComputeDispatch: indirect arguments at ${A} exceed the buffer's ${e}-byte capacity.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" already has one-shot scheduling.`,A=>`Compute pipeline override "${A}" must have a non-empty name or decimal @id from 0 to 65535 with a finite value.`,A=>`Compute pipeline variant for "${A}" belongs to a lost or replaced GPU device; recreate it.`,()=>"Compute pipeline variants require explicit binding layouts.",A=>`ComputeBindingSet: sampler resource for "${A}" is invalid or belongs to a different engine.`,(A,e,g)=>`ComputeBindingSet: sampler "${A}" has type ${e}, expected ${g}.`,()=>"ComputeBindingSet contains an invalid sampler resource.",A=>`ComputeShader: ${A} must not be empty.`,(A,e)=>`ComputeShader: ${A} must be a non-negative integer, received ${e}.`,()=>"ComputeShader: computeSource must not be empty.",(A,e)=>`ComputeShader: group ${A} exceeds this device's maxBindGroups (${e}).`,(A,e)=>`ComputeShader: binding ${A} exceeds this device's maxBindingsPerBindGroup (${e}).`,A=>`ComputeShader: binding name "${A}" is declared more than once.`,(A,e)=>`ComputeShader: group ${A} binding ${e} is declared more than once.`,A=>`ComputeShader: minBindingSize for "${A}" must be a non-negative multiple of 4.`,A=>`ComputeShader: automatic layouts do not support dynamic offset binding "${A}".`,(A,e,g)=>`ComputeShader: ${A} ${e} exceed this device's limit of ${g}.`,A=>`ComputeShader "${A}" has been disposed.`,A=>`ComputeShader "${A}" belongs to a lost or replaced GPU device; recreate the compute graph.`,A=>`ComputeShader "${A}" pipeline preparation did not complete on its owning device.`,A=>`computeStorageBufferBinding: access must be "read" or "read-write", received "${A}".`,A=>`ComputeBindingSet: storage texture for "${A}" is invalid or belongs to a different engine.`,(A,e,g)=>`ComputeBindingSet: storage texture "${A}" has format ${e}, expected ${g}.`,(A,e,g)=>`ComputeBindingSet: storage texture "${A}" uses a ${e} view, expected ${g}.`,(A,e)=>`ComputeBindingSet: storage texture "${A}" was not validated for ${e} access.`,()=>"ComputeBindingSet contains an invalid storage texture resource.",A=>`computeStorageTextureBinding: format "${A}" is not supported.`,()=>"Compute storage texture mipmap task requires at least one resource.",()=>"Compute storage texture mipmap task requires same-engine sampled 2D filterable-float resources created with mipMaps: true; rgba8snorm also requires texture-formats-tier1.",A=>`Compute storage texture mipmap task "${A}" contains a disposed resource.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" and its dispatch belong to different engines.`,()=>"submitComputeTasks requires tasks from the same engine.",A=>`ComputeTask "${A}" must be recorded and active before direct submission.`,()=>"submitComputeTasks cannot run while a frame is being recorded.",A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeBindingSet: texture resource for "${A}" is invalid or belongs to a different engine.`,(A,e,g)=>`ComputeBindingSet: texture "${A}" has sample type ${e}, expected ${g}.`,A=>`ComputeBindingSet: texture "${A}" multisampling does not match its declaration.`,(A,e,g)=>`ComputeBindingSet: texture "${A}" uses a ${e} view, expected ${g}.`,()=>"ComputeBindingSet contains an invalid texture resource.",()=>"ComputeBindingSet contains a texture from a different engine.",()=>"computeTextureBinding: multisampled float textures require sampleType unfilterable-float.",()=>"createComputeTextureResource: stencil texture views are not currently supported.",()=>"createComputeTextureResource: only 2D texture views are currently supported.",(A,e)=>`createComputeTextureResource: declared sample type ${A} is incompatible with texture format ${e}.`,A=>`createComputeTextureViewResource: declared multisampled=${A} does not match the texture.`,A=>`createComputeTextureViewResource: multisampled textures require a 2d view, received ${A}.`,()=>"createComputeTextureResource: engine device changed during validation; retry with the recovered texture.",A=>`createComputeTextureResource: texture is incompatible with this engine: ${A}`,()=>"ComputeBindingSet contains an invalid texture resource.",A=>`ComputeTask "${A}" has been disposed.`,()=>"ComputeUniformArena: slotByteLength must be a positive safe integer and a multiple of 4.",()=>"ComputeUniformArena: slotCount must be a positive safe integer.",()=>"ComputeUniformArena: aligned stride and total byte length must be safe integers.",()=>"ComputeUniformArena has been disposed.",A=>`ComputeUniformArena: slot must be an integer in [0, ${A}].`,()=>"ComputeUniformArena: byteOffset must be a non-negative multiple of 4.",()=>"ComputeUniformArena: update data must have a byte length that is a multiple of 4.",A=>`ComputeUniformArena: update exceeds the slot's ${A}-byte capacity.`,A=>`createUniformBuffer: byte length must be a non-negative safe integer, received ${A}.`,(A,e)=>`createUniformBuffer: aligned byte length ${A} must be a safe integer within device maxBufferSize (${e}).`,()=>"UniformBuffer has been disposed.",()=>"UniformBuffer belongs to a different engine.",()=>"UniformBuffer is not a live registered allocation.",()=>"UniformBuffer byteOffset must be a non-negative multiple of 4.",()=>"UniformBuffer update data must have a byte length that is a multiple of 4.",A=>`UniformBuffer update exceeds its ${A}-byte capacity.`,()=>"UniformBuffer is not a live registered allocation.",()=>'createComputeUniformF16Writer requires createEngineWithFeatures(..., { requiredFeatures: ["shader-f16"] }).',A=>`ComputeUniformLayout: unsupported field type "${A}".`,()=>"ComputeUniformLayout requires at least one field.",()=>"ComputeUniformLayout: field name must not be empty.",A=>`ComputeUniformLayout: duplicate field "${A}".`,(A,e)=>`ComputeUniformWriter: layout requires ${A} bytes but arena slots contain ${e} bytes.`,()=>"ComputeUniformWriter: f16 fields require createComputeUniformF16Writer.",()=>"ComputeUniformWriter targets a disposed uniform arena.",A=>`ComputeUniformWriter: field "${A}" was not declared.`,(A,e)=>`${A}: field type ${e} is not supported by this setter.`,(A,e)=>`${A}: field type ${e} does not match this setter.`,()=>"ComputeUniformWriter: f16 writes require createComputeUniformF16Writer.",(A,e,g,I)=>`${A}: field "${e}" expects ${g} values, received ${I}.`,(A,e)=>`setComputeUniform: field "${A}" expects ${e} values, received 1.`,(A,e,g)=>`ComputeStorageTexture: ${A} must be a positive integer no larger than ${e}, received ${g}.`,()=>"ComputeStorageTexture: 1d textures require height=1 and depthOrArrayLayers=1.",()=>"ComputeStorageTexture: mipMaps is not supported for 1d textures.",()=>"ComputeStorageTexture: 2d textures require depthOrArrayLayers=1; use 2d-array for layers.",A=>`ComputeStorageTexture: unsupported access "${A}".`,()=>"ComputeStorageTexture: at least one access mode is required.",()=>"createComputeStorageTexture: engine device changed during validation; recreate the resource on the current device.",A=>`createComputeStorageTexture: unsupported format, dimension, or access combination: ${A}`,()=>"ComputeStorageTexture: format must be a GPU texture format string.",(A,e,g)=>`ComputeStorageTexture: ${A} (${e}) is incompatible with a ${g} sampler.`,A=>`ComputeStorageTexture2D: dimensions must be positive integers no larger than ${A}.`,A=>`ComputeStorageTexture2D: format "${A}" is not supported.`,()=>"ComputeStorageTexture: sampled outputs require validated sample metadata.",()=>"ComputeStorageTexture2D has been disposed.",()=>"ComputeStorageTexture2D is not a live registered allocation.",()=>"ComputeStorageTexture2D cannot be disposed while sampled facades are still owned.",A=>`Invalid ARIA attribute: ${A}`,(A,e)=>`Conflicting accessibility state: ${A} and ${e}.`,()=>"Accessibility tree is disposed.",()=>"Accessibility node does not belong to this tree.",()=>"Accessibility ordering requires a sibling in the same tree.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Scene accessibility is disposed.",()=>"Cannot create accessibility for a disposed scene.",()=>"The scene already has an accessibility projection.",()=>"A DOM canvas with a parent element is required when createSceneHtmlTwin is called without options.parent."];function MeA(A,e){const g=XvA[A];return g?g(...e):`Error #${A}`}rA();function $vA(){S3A(MeA)}function A8A(A){if(!(A instanceof Error))return String(A);const e=A.lite;if(!Array.isArray(e))return A.message;const g=/^#(\d+)$/.exec(A.message);return g?MeA(Number(g[1]),e):A.message}Ho();var e8A=(function(A){return A[A.Small=0]="Small",A[A.Medium=1]="Medium",A[A.Large=2]="Large",A[A.ExtraLarge=3]="ExtraLarge",A})({});function g8A(A,e){if(!Number.isInteger(A)||A<0||A>63)throw new RangeError("Mesh-blending group ID must be an integer between 0 and 63.");if(A===0)return 0;if(!Number.isInteger(e)||e<0||e>3)throw new RangeError("Mesh-blending radius class must be an integer between 0 and 3.");return e<<6|A}function D6(A){if(!Number.isInteger(A)||A<0||A>255)throw new RangeError("Mesh-blending tag must be an integer between 0 and 255.");if(A!==0&&(A&63)===0)throw new RangeError("A nonzero mesh-blending tag must contain a group ID between 1 and 63.");return A}function I8A(A){const e=D6(A);return{groupId:e&63,radiusClass:e>>6}}function XK(A,e){let g=A,I=e;const i={};return Object.defineProperties(i,{worldRadius:{enumerable:!0,get:()=>g,set:C=>{if(!Number.isFinite(C)||C<0)throw new RangeError("Mesh-blending world radii must be finite non-negative numbers.");g=C}},minimumProjectedRadius:{enumerable:!0,get:()=>I,set:C=>{if(!Number.isFinite(C)||C<0)throw new RangeError("Mesh-blending minimum projected radii must be finite non-negative numbers.");I=C}}}),i}function ReA(){return Object.freeze([XK(.06,1.5),XK(.1,3),XK(.2,3),XK(.3,5)])}function SeA(A){return D6(A.meshBlendingTag??0)}function $K(A,e){if(Array.isArray(e))for(const g of e)A._dependencies.add(g);else A._dependencies.add(e)}var t8A={r:.2,g:.2,b:.3,a:1};function i8A(A,e){const g={name:A,_parentTask:e,_dependencies:new Set,_renderTarget:null,_renderTargetDepth:null,_renderPassDescriptor:{colorAttachments:[]},_colorAttachment:null,_depthAttachment:null,clearColor:{...t8A},clear:!0,_executeFunc:null,_beforeExecute:null,_initialize(){const I=g._renderTarget;if(!I)throw new Error(`RenderPass "${g.name}": render target not set`);const i=I._colorView;let C=null;i&&(C={view:i,loadOp:g.clear?"clear":"load",storeOp:"store",clearValue:g.clearColor});const o=g._renderTargetDepth??I,r=o._descriptor.dFormat,B=o._depthView,n=r?r==="depth24plus-stencil8"||r==="depth32float-stencil8"||r==="stencil8":!1;let Q=null;B&&(Q={view:B,depthClearValue:o._descriptor.depthClearValue??0,depthLoadOp:"clear",depthStoreOp:"store",...n?{stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}:{}}),g._colorAttachment=C,g._depthAttachment=Q,g._renderPassDescriptor={label:g.name,colorAttachments:C?[C]:[],depthStencilAttachment:Q??void 0}},_execute(){const I=g._renderTarget;if(!I)return 0;g._beforeExecute?.();const i=g._parentTask.engine,C=g._colorAttachment;C&&(C.clearValue=g.clearColor,C.loadOp=g.clear?"clear":"load",C.view=I._colorView);const o=i._currentEncoder.beginRenderPass(g._renderPassDescriptor);let r=0;return g._executeFunc&&(r=g._executeFunc(o)),o.end(),r},_dispose(){g._renderTarget=null,g._renderTargetDepth=null,g._colorAttachment=null,g._depthAttachment=null,g._renderPassDescriptor={colorAttachments:[]},g._executeFunc=null,g._beforeExecute=null,g._dependencies.clear()}};return e._passes.push(g),g}rA(),jK();function NeA(A){return typeof A=="object"&&A!==null&&"_tasks"in A}function EF(A){if(NeA(A))return A;if("_frameGraph"in A&&NeA(A._frameGraph))return A._frameGraph;R(119)}function C8A(A,e){AeA(EF(A),e)}function o8A(A,e){const g=EF(A),I=g._tasks[0]?.name==="shadow"?1:0;g._tasks.splice(I,0,e)}function r8A(A,e,g){const I=EF(A),i=I._tasks.indexOf(g);i<0?I._tasks.push(e):I._tasks.splice(i,0,e)}function B8A(A,e,g){const I=EF(A),i=I._tasks.indexOf(g);i<0?I._tasks.push(e):I._tasks.splice(i+1,0,e)}function n8A(A,e){const g=EF(A)._currentProcessedTask;return g||R(120,e),i8A(e,g)}lt(),jK();function s8A(A,e){const g=A.engine,I=e?.update,i={_kind:"frame-graph-context",name:e?.name??"frame-graph",surface:A,frameGraph:XAA(g),clearColor:e?.clearColor??{r:0,g:0,b:0,a:1},_drawCallsPre:0,_disposed:!1,_update(){i._disposed||I?.(g._currentDelta)},_record(){return i._disposed?0:i.frameGraph.execute()},_resize(){i._disposed||i.frameGraph.build()}};return i}function Q8A(A){A._disposed||(A.frameGraph.build(),Ln(A.surface,A))}async function E8A(A){const e=A;e._disposed||(await Promise.all(A.frameGraph._tasks.map(g=>g._preload?.())),!e._disposed&&(A.frameGraph.build(),Ln(A.surface,A)))}function GeA(A){Zs(A.surface,A)}function a8A(A){const e=A;e._disposed||(GeA(A),A.frameGraph.dispose(),e._disposed=!0)}function ai(A){return HZ(A.texture,A)}var FC=b((()=>{Y3()}));te(),Gt(),FC(),m1();function meA(A,e){return Math.floor(Math.log2(Math.max(A,e)))+1}var c8A="@group(0)@binding(0)var src:texture_depth_2d;struct V{@builtin(position)p:vec4f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1));}@fragment fn fs(@builtin(position)fc:vec4f)->@location(0)f32{return textureLoad(src,vec2<i32>(fc.xy),0);}";function l8A(A){return`@group(0)@binding(0)var src:texture_2d<f32>;struct V{@builtin(position)p:vec4f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1));}@fragment fn fs(@builtin(position)fc:vec4f)->@location(0)f32{let c=vec2<i32>(fc.xy)*2;let sd=vec2<i32>(textureDimensions(src));let d=sd-vec2<i32>(1,1);let x1=min(c.x+1,d.x);let y1=min(c.y+1,d.y);let a=textureLoad(src,vec2<i32>(c.x,c.y),0).r;let b=textureLoad(src,vec2<i32>(x1,c.y),0).r;let e=textureLoad(src,vec2<i32>(c.x,y1),0).r;let f=textureLoad(src,vec2<i32>(x1,y1),0).r;var r=${A}(${A}(a,b),${A}(e,f));let dd=max(sd/vec2<i32>(2,2),vec2<i32>(1,1));let extraX=(sd.x&1)==1&&i32(fc.x)==dd.x-1;let extraY=(sd.y&1)==1&&i32(fc.y)==dd.y-1;if(extraX){let x2=min(c.x+2,d.x);r=${A}(r,${A}(textureLoad(src,vec2<i32>(x2,c.y),0).r,textureLoad(src,vec2<i32>(x2,y1),0).r));}if(extraY){let y2=min(c.y+2,d.y);r=${A}(r,${A}(textureLoad(src,vec2<i32>(c.x,y2),0).r,textureLoad(src,vec2<i32>(x1,y2),0).r));if(extraX){r=${A}(r,textureLoad(src,vec2<i32>(min(c.x+2,d.x),y2),0).r);}}return r;}`}function p8A(A,e){const g=A._device,I=e.reduce??"max",i=I1(A,{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}),C=g.createBindGroupLayout({entries:[{binding:0,visibility:MA.FRAGMENT,texture:{sampleType:"depth",viewDimension:"2d"}}]}),o=g.createBindGroupLayout({entries:[{binding:0,visibility:MA.FRAGMENT,texture:{sampleType:"unfilterable-float",viewDimension:"2d"}}]}),r=(w,M)=>g.createRenderPipeline({layout:g.createPipelineLayout({bindGroupLayouts:[M]}),vertex:{module:g.createShaderModule({code:w}),entryPoint:"vs"},fragment:{module:g.createShaderModule({code:w}),entryPoint:"fs",targets:[{format:"r32float"}]},primitive:{topology:"triangle-list"}}),B=r(c8A,C),n=r(l8A(I),o);let Q=Math.max(1,e.width|0),E=Math.max(1,e.height|0),a=meA(Q,E);function c(){return g.createTexture({label:"depth-pyramid",size:{width:Q,height:E},format:"r32float",usage:RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING,mipLevelCount:a})}function l(w){const M={texture:w,view:w.createView(),sampler:i,width:Q,height:E,_sampleType:"float"};return LI(M),M}let p=c(),D=l(p),u,_=[],d=null,y=null;function h(){u=p.createView({baseMipLevel:0,mipLevelCount:1}),_=[];for(let w=1;w<a;w++){const M=p.createView({baseMipLevel:w-1,mipLevelCount:1}),N=p.createView({baseMipLevel:w,mipLevelCount:1});_.push({dst:N,bindGroup:g.createBindGroup({layout:o,entries:[{binding:0,resource:M}]})})}d=null,y=null}return h(),{get texture(){return D},get mipCount(){return a},build(w,M){const N=M??g.createCommandEncoder();(d===null||y!==w)&&(d=g.createBindGroup({layout:C,entries:[{binding:0,resource:w.view}]}),y=w);const S=N.beginRenderPass({label:"depth-pyramid-copy",colorAttachments:[{view:u,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});S.setPipeline(B),S.setBindGroup(0,d),S.draw(3),S.end();for(const G of _){const m=N.beginRenderPass({label:"depth-pyramid-reduce",colorAttachments:[{view:G.dst,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});m.setPipeline(n),m.setBindGroup(0,G.bindGroup),m.draw(3),m.end()}M||g.queue.submit([N.finish()])},resize(w,M){const N=Math.max(1,w|0),S=Math.max(1,M|0);if(N===Q&&S===E)return;Q=N,E=S,a=meA(Q,E);const G=D;p=c(),D=l(p),h(),ai(G)},dispose(){ai(D)}}}function D8A(A,e,g){const{pyramid:I,source:i}=g;return{name:"depth-pyramid",engine:A,scene:e,_passes:[],record(){},execute(){const C=i();return C?(I.build(C,A._currentEncoder),I.mipCount):0},dispose(){I.dispose()}}}function FeA(A,e,g){let I=null;return{name:A.name??"image-processing",engine:e,scene:g,_passes:[],record(){beA(I),I=u8A(e,A.source)},execute(){if(!I)return 0;const i=g.imageProcessing,C=new oA([i.exposure,i.contrast,i.toneMappingEnabled===!0?1:0,0]);e._device.queue.writeBuffer(I.params,0,C);const o=e._currentEncoder.beginRenderPass({colorAttachments:[{view:e.scRT._colorView,loadOp:"clear",storeOp:"store",clearValue:g.clearColor}]});return o.setPipeline(I.pipeline),o.setBindGroup(0,I.bindGroup),o.draw(3),o.end(),1},dispose(){beA(I),I=null,this._passes.length=0}}}function u8A(A,e){const g=_8A(e);if(!g)throw new Error("Image processing source has no color texture");const I=A._device,i=(g.sampleCount??1)>1,C=I.createBuffer({size:16,usage:dA.UNIFORM|dA.COPY_DST}),o=I.createBindGroupLayout({entries:[{binding:0,visibility:MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:i?"unfilterable-float":"float",multisampled:i}}]}),r="struct P{e:f32,c:f32,t:f32,p:f32}@group(0)@binding(0)var<uniform>p:P;@vertex fn vs(@builtin(vertex_index)i:u32)->@builtin(position)vec4f{var a=array<vec2f,3>(vec2f(-1,-3),vec2f(3,1),vec2f(-1,1));return vec4f(a[i],0,1);}fn ip(r:vec4f)->vec4f{var c=r.rgb*p.e;if(p.t>0.5){c=1.0-exp2(-1.590579*c);}c=clamp(pow(max(c,vec3f(0)),vec3f(1/2.2)),vec3f(0),vec3f(1));let h=c*c*(3.0-2.0*c);if(p.c<1.0){c=mix(vec3f(0.5),c,p.c);}else{c=mix(c,h,p.c-1.0);}return vec4f(max(c,vec3f(0)),r.a);}",B=i?"@group(0)@binding(1)var s:texture_multisampled_2d<f32>;":"@group(0)@binding(1)var s:texture_2d<f32>;",n=i?"@fragment fn fs(@builtin(position)q:vec4f)->@location(0)vec4f{let d=textureDimensions(s);let px=clamp(vec2i(q.xy),vec2i(0),vec2i(d)-1);let n=textureNumSamples(s);var c=vec4f(0);for(var i=0u;i<n;i++){c+=ip(textureLoad(s,px,i));}return c/f32(n);}":"@fragment fn fs(@builtin(position)q:vec4f)->@location(0)vec4f{let d=textureDimensions(s);return ip(textureLoad(s,clamp(vec2i(q.xy),vec2i(0),vec2i(d)-1),0));}",Q=I.createShaderModule({code:`${r}${B}${n}`});return{pipeline:I.createRenderPipeline({layout:I.createPipelineLayout({bindGroupLayouts:[o]}),vertex:{module:Q,entryPoint:"vs"},fragment:{module:Q,entryPoint:"fs",targets:[{format:A.format}]},primitive:{topology:"triangle-list"}}),bindGroup:I.createBindGroup({layout:o,entries:[{binding:0,resource:{buffer:C}},{binding:1,resource:g.createView()}]}),params:C}}function _8A(A){const e=typeof A=="function"?A():A;return e?"_colorTexture"in e?e._colorTexture:e.texture:null}function beA(A){A?.params.destroy()}var keA=b((()=>{ZA(),te()}));keA();var Gi=128;function d8A(A,e,g){let I=Math.imul(A^g,73244475)^Math.imul(e+g,295559667);return I=Math.imul(I^I>>>16,73244475),I=Math.imul(I^I>>>16,73244475),((I^I>>>16)>>>0)/4294967296}function KeA(A,e,g){const i=new Float32Array(16384),C=new Float32Array(16384),o=new Array(16384);for(let r=0;r<Gi;r++)for(let B=0;B<Gi;B++){const n=r*Gi+B;i[n]=d8A(B,r,g),o[n]=n}for(let r=0;r<Gi;r++){const B=r-1&127,n=r+1&127;for(let Q=0;Q<Gi;Q++){const E=Q-1&127,a=Q+1&127,c=r*Gi+Q,l=(i[r*Gi+E]+i[r*Gi+a]+i[B*Gi+Q]+i[n*Gi+Q]+i[B*Gi+E]+i[B*Gi+a]+i[n*Gi+E]+i[n*Gi+a])*.125;C[c]=i[c]-l}}o.sort((r,B)=>C[r]-C[B]||r-B);for(let r=0;r<16384;r++)A[o[r]*2+e]=Math.floor(r*256/16384)}function f8A(){const A=new Uint8Array(32768);return KeA(A,0,1757159915),KeA(A,1,795749149),A}function y8A(A){e4=A}function A4(A,e=!1){const g=A._gpu;let I=0;return g.tangentBuffer&&(I|=1),A.vat?(I|=512,A.vat.joints1Buffer&&(I|=4)):A.skeleton&&(I|=2,A.skeleton.joints1Buffer&&(I|=4)),A.morphTargets&&(I|=8),A.thinInstances&&(I|=16,A.thinInstances.colors&&(I|=32)),g.colorBuffer&&(I|=64),g.uv2Buffer&&(I|=128),A._flatNormal&&(I|=UeA),e&&(I|=256),e4&&(I|=e4(A)),I}var UeA,e4,ci=b((()=>{UeA=1024,e4=null}));function h8A(A,e){const g=e.id,I=A.includedOnlyMeshIds;return I?.size?!!g&&I.has(g):!g||!A.excludedMeshIds?.has(g)}function rC(A,e,g){const I=g?new Ag(g.buffer,g.byteOffset,g.byteLength/4):null;let i=0,C=-1,o=0;for(const r of e){if(o>=Zg)break;r._writeLightUbo&&(h8A(r,A)&&(C=o,I&&(I[u6+i]=o),i++),o++)}if(I){I[16]=i;for(let r=i;r<Zg;r++)I[u6+r]=0}return i===1?C+1:-i}var u6,aF=b((()=>{ZA(),vt(),u6=20}));function w8A(A){tt=A}var lg,BC,veA,As,tt,xo=b((()=>{rA(),lg=(function(A){return A[A.IRRADIANCE=0]="IRRADIANCE",A[A.WORLD_POSITION=1]="WORLD_POSITION",A[A.LOCAL_POSITION=2]="LOCAL_POSITION",A[A.REFLECTIVITY=3]="REFLECTIVITY",A[A.VIEW_DEPTH=4]="VIEW_DEPTH",A[A.NORMALIZED_VIEW_DEPTH=5]="NORMALIZED_VIEW_DEPTH",A[A.SCREENSPACE_DEPTH=6]="SCREENSPACE_DEPTH",A[A.VIEW_NORMAL=7]="VIEW_NORMAL",A[A.WORLD_NORMAL=8]="WORLD_NORMAL",A[A.ALBEDO=9]="ALBEDO",A[A.LINEAR_VELOCITY=10]="LINEAR_VELOCITY",A[A.MESH_BLEND_TAG=11]="MESH_BLEND_TAG",A})({}),BC={r:0,g:0,b:0,a:0},veA={r:1,g:1,b:1,a:1},As=[{name:"Irradiance",defaultFormat:"rgba16float",clearValue:BC},{name:"WorldPosition",defaultFormat:"rgba16float",clearValue:BC},{name:"LocalPosition",defaultFormat:"rgba16float",clearValue:BC},{name:"Reflectivity",defaultFormat:"rgba8unorm",clearValue:BC},{name:"ViewDepth",defaultFormat:"r32float",clearValue:BC},{name:"NormalizedViewDepth",defaultFormat:"r16float",clearValue:veA},{name:"ScreenspaceDepth",defaultFormat:"r16float",clearValue:BC},{name:"ViewNormal",defaultFormat:"rgba16float",clearValue:BC},{name:"WorldNormal",defaultFormat:"rgba16float",clearValue:BC},{name:"Albedo",defaultFormat:"rgba8unorm",clearValue:BC},{name:"LinearVelocity",defaultFormat:"rgba16float",clearValue:BC},{name:"MeshBlendTag",defaultFormat:"r8uint",clearValue:BC,_validate:()=>{R(140)}}],tt=null}));function _6(A){const e=[];for(const g of[A.baseColorTexture,A.normalTexture,A.ormTexture,A.occlusionTexture,A.emissiveTexture,A.specGlossTexture])g&&e.push(g);for(const g of qr().values())g.textures?.(A,e);return e}var g4=b((()=>{lI()})),M8A=H({_computePbrMaterialFeatures:()=>d6});function d6(A){let e=(A.emissiveTexture?2:0)|(A.normalTexture?1:0)|(A.alphaBlend===!0||(A._alphaCutOff??0)<=0&&A.alpha<1?64:0)|(A.specGlossTexture?128:0)|(A.doubleSided?256:0);(A.occlusionStrength??1)>0&&(e|=u5),A.enableSpecularAA&&(e|=lK);let g=0;for(const I of qr().values())if(I.detect){const i=I.detect(A);e|=i.f,g|=i.f2}return A._uv2Mask&&(g|=dK),A.baseColorFactor&&(g|=fK),{features:e,features2:g}}var I4=b((()=>{lI()}));function R8A(A){cF=A}function S8A(A){t4=A}function N8A(A){y6=A}function LeA(A){i4!==A._device&&(lF.clear(),i4=A._device)}function G8A(){lF.clear(),i4=null}function m8A(A,e,g,I,i,C,o="",r=null){LeA(A);const B=r&&cF?cF(r):null,n=`${e}:${g}:${I}:${i}:${o}${B?B._key:""}`,Q=lF.get(n);if(Q)return Q;const E=A._device,a=E.createBindGroupLayout(C._meshBGLDescriptor);let c=null;C._shadowBGLDescriptor&&(c=E.createBindGroupLayout(C._shadowBGLDescriptor));const l={_features:e,_features2:g,_meshFeatures:I,_meshBGL:a,_shadowBGL:c,_composed:C,_pipelines:new Map};return B&&(l._stencil=B._desc),lF.set(n,l),l}function F8A(A,e,g,I){LeA(A);const i=Vn(),C=e._sampleCount>1&&!!i?.(I),o=`${Q1(e)}${C?":a2c":""}`,r=g._pipelines.get(o);if(r)return r;const B=A._device,{_features:n,_features2:Q,_composed:E}=g,a=(Q&sQ)!==0,c=!a&&(n&64)!==0,l=(n&256)!==0,p=n1(A),D=g._shadowBGL?[p,g._meshBGL,g._shadowBGL]:[p,g._meshBGL],u=i?g._a2cVertModule??=B.createShaderModule({code:E._vertexWGSL}):B.createShaderModule({code:E._vertexWGSL}),_=(Q&$m)!==0,d=!e._colorFormat&&!_?null:i?g._a2cFragModule??=B.createShaderModule({code:E._fragmentWGSL}):B.createShaderModule({code:E._fragmentWGSL}),y=_?null:{format:e._colorFormat,writeMask:yC.ALL};c&&y&&(y.blend={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}});const h=B.createRenderPipeline({layout:B.createPipelineLayout({bindGroupLayouts:D}),vertex:{module:u,entryPoint:"main",buffers:E._vertexBufferLayouts},...d?{fragment:{module:d,entryPoint:"main",targets:y?[y]:[]}}:{},...e._depthStencilFormat?{depthStencil:{format:e._depthStencilFormat,depthCompare:e._depthCompare??"greater-equal",depthWriteEnabled:_||a||!c,...cF&&g._stencil&&e._depthStencilFormat.includes("stencil")?g._stencil:{}}}:{},multisample:C?{count:e._sampleCount,alphaToCoverageEnabled:!0}:{count:e._sampleCount},primitive:{cullMode:l?"none":"back",...E._prim}});return g._pipelines.set(o,h),h}function f6(A,e,g,I,i,C,o,r,B){const n=A._device,Q=e._features,E=e._features2,a=e._meshFeatures,c=(Q&1)!==0&&(a&1)!==0,l=(Q&1)!==0&&(a&1)===0,p=c||l,D=(Q&2)!==0,u=(Q&128)!==0,_=(E&sQ)!==0,d=[];let y=0;const h=G=>{d.push({binding:y++,resource:G.view}),d.push({binding:y++,resource:G.sampler})},w={_engine:A,_features:Q,_features2:E,_meshFeatures:a,_material:C,_mesh:r,_env:o??y6?.(C)??null,_refractionTexture:B},M=D$(),N=g._fragmentKey?g._fragmentKey.split("|").filter(G=>G.length>0):[];d.push({binding:y++,resource:{buffer:I}}),d.push({binding:y++,resource:{buffer:i}});for(const G of M)G.phase==="vertex"&&G.bind&&(y=G.bind(w,d,y));h(C.baseColorTexture??t4?.(A)),p&&h(C.normalTexture),h(C.ormTexture??t4?.(A)),(E&2048)!==0&&(a&128)!==0&&C.occlusionTexture&&C.occlusionTexCoord===1&&h(C.occlusionTexture),D&&h(C.emissiveTexture),u&&h(C.specGlossTexture),_&&d.push({binding:y++,resource:{buffer:C._esmShadowParamsUBO}});const S=[];for(const G of N){const m=M.find(k=>k.id===G||G.startsWith(k.id+"-"));!m||m.phase==="vertex"||!m.bind||S.includes(m)||(S.push(m),y=m.bind(w,d,y))}return n.createBindGroup({layout:e._meshBGL,entries:d})}var cF,t4,y6,lF,i4,pF=b((()=>{te(),lI(),ci(),MI(),E1(),s1(),Wn(),cF=null,t4=null,y6=null,lF=new Map,i4=null}));function YeA(A,e){return A+e-1&~(e-1)}function b8A(A){const e=JeA[A];if(e)return e;const g=/^array<vec4<u32>,\s*(\d+)>$/.exec(A);if(g)return{align:16,size:Number(g[1])*16};throw new Error(`Unknown UBO field type: ${A}`)}function hQ(A){const e=new Map,g=[];let I=0;for(const i of A){const C=b8A(i._type);I=YeA(I,C.align),e.set(i._name,I),g.push(`${i._name}: ${i._type},`),I+=C.size}return{_totalBytes:YeA(I,16),_offsets:e,_structBody:g.join(`
1
+ var Zz=Object.defineProperty,b=(A,e,g)=>()=>{if(g)throw g[0];try{return A&&(e=A(A=0)),e}catch(I){throw g=[I],I}},H=(A,e)=>{let g={};for(var I in A)Zz(g,I,{get:A[I],enumerable:!0});return e||Zz(g,Symbol.toStringTag,{value:"Module"}),g};function S3A(A){BY=A}function R(A,...e){const g=new Error(BY?.(A,e)??`#${A}`);throw g.lite=e,g}var BY,rA=b((()=>{BY=null})),oA,Bi,Ag,$1,ni,E3,He,a3,Ao,Ai,ZA=b((()=>{oA=Float32Array,Bi=Float64Array,Ag=Uint32Array,$1=Int32Array,ni=Uint16Array,E3=Int16Array,He=Uint8Array,a3=Int8Array,Ao=Uint8ClampedArray,Ai=DataView}));function N3A(){return new oA(16)}function QI(){return(Xz??N3A)()}function nY(){return QI()}function G3A(A){Xz=A}var Xz,Ut=b((()=>{ZA()})),RA,dA,MA,yC,te=b((()=>{RA=globalThis.GPUTextureUsage,dA=globalThis.GPUBufferUsage,MA=globalThis.GPUShaderStage,yC=globalThis.GPUColorWrite}));function $z(A){const e=A.size;return"canvas"in e?e.canvas:e}function c3(A){return{_descriptor:A,_resolveSize:$z,_colorTexture:null,_colorView:null,_depthTexture:null,_depthView:null,_width:0,_height:0}}function Nt(A){const e=c3(A);return"surface"in A.size&&(hi(A),e._resolveSize=hi),e}function xI(A,e){if(A._eager){A._syncEager?.(e);return}eI(A);const g=A._descriptor,I=(A._resolveSize??$z)(g);A._width=I.width,A._height=I.height;const i=e._device;g.format&&(A._colorTexture=i.createTexture(sY(g,I,g.format,RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING|RA.COPY_SRC|RA.COPY_DST)),A._colorView=A._colorTexture.createView()),g.dFormat&&(A._depthTexture=i.createTexture(sY(g,I,g.dFormat,RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING)),A._depthView=A._depthTexture.createView())}function sY(A,e,g,I){return{label:A.lbl,size:e,format:g,sampleCount:A.samples,usage:I}}function eI(A){if(!A||A._eager&&!A._disposeAttachments)return;const e=A._colorTexture,g=A._depthTexture;if(A._colorTexture=A._depthTexture=null,A._colorView=A._depthView=null,A._width=A._height=0,A._disposeAttachments)A._disposeAttachments(e,g);else try{e?.destroy()}finally{A._ownsDepthTexture!==!1&&g?.destroy()}}function hi(A){const e=A.size;if("surface"in e){const g=e.scale;(!Number.isFinite(g)||g<=0)&&R(61,g);const I=e.surface.canvas;return{width:Math.floor(I.width*g)||1,height:Math.floor(I.height*g)||1}}return"canvas"in e?e.canvas:e}var MI=b((()=>{rA(),te()})),QY,EY,aY=b((()=>{QY="1.36.0",EY=`Babylon Lite v${QY}`}));function Mm(A){return"clientWidth"in A}function m3A(A){return A.endsWith("-srgb")?A:`${A}-srgb`}function F3A(A,e,g){const I=AZ(A,e,g);return A._surfaces.push(I),p3(I),l3(I),I}function AZ(A,e,g){const I=e.getContext("webgpu");I||R(62),Mm(e)&&e.setAttribute("data-engine",EY);const i=g?.format??navigator.gpu.getPreferredCanvasFormat(),C=g?.srgb?m3A(i):i,o=g?.alphaMode??"opaque";I.configure({device:A._device,format:i,alphaMode:o,viewFormats:[C]});const r=g?.msaaSamples===1?1:4,B=c3({lbl:"swapchain",format:C,samples:1,size:{width:0,height:0}});return B._eager=!0,{engine:A,canvas:e,format:C,msaaSamples:r,scRT:B,maxDevicePixelRatio:g?.maxDevicePixelRatio??1/0,_uniqueId:eZ++,_context:I,_configureFormat:i,_alphaMode:o,_renderingContexts:[]}}function l3(A){const e=A._context.getCurrentTexture(),g=A.scRT;g._colorTexture=e,g._colorView=e.createView({format:A.format}),g._width=e.width,g._height=e.height}function p3(A){const e=A.canvas;if(!Mm(e))return;const g=A._w??e.clientWidth,I=A._h??e.clientHeight;if(!(g>0&&I>0))return;const i=Math.min(globalThis.devicePixelRatio||1,A.maxDevicePixelRatio);cY(A,g*i|0,I*i|0)}function cY(A,e,g){const I=A.canvas,i=e|0,C=g|0;if(i>0&&C>0&&!(i===I.width&&C===I.height)){I.width=i,I.height=C,A.scRT._width=i,A.scRT._height=C;for(const o of A._renderingContexts)o._resize?.()}}function b3A(A){A===A.engine&&R(63),A._renderingContexts.length=0,A._ro?.disconnect(),A._context.unconfigure();const e=A.engine._surfaces,g=e.indexOf(A);g!==-1&&e.splice(g,1)}var eZ,zs=b((()=>{rA(),MI(),aY(),eZ=1})),k3A=H({MAT4_STORAGE_F64_BUILD_TAG:()=>lY,allocateF64Mat4:()=>gZ});function gZ(){return new Bi(16)}var lY,K3A=b((()=>{ZA(),lY="@@MAT4_STORAGE_F64@@",gZ[lY]=!0}));function IZ(A){if(!Number.isFinite(A)||A<1)throw new Error(`setMaxLights: expected positive integer, got ${A}`);Zg=A|0}var Zg,vt=b((()=>{Zg=16})),U3A=H({applyLightFoOffset:()=>L3A,getFloatingOriginOffset:()=>tZ,lightFoVersion:()=>v3A,wrapRenderableForFO:()=>Y3A});function tZ(A){const e=A.camera;if(!e)return{x:0,y:0,z:0};const g=e.worldMatrix;return{x:g[12],y:g[13],z:g[14]}}function v3A(A){const e=A.camera,g=e?e.worldMatrixVersion:-1,I=iZ??=new WeakMap;let i=I.get(A);return i?(i[0]!==e||i[1]!==g)&&(i[0]=e,i[1]=g,i[2]++):I.set(A,i=[e,g,0]),i[2]}function L3A(A,e){const g=e.camera?.worldMatrix;if(!g)return;const I=g[12],i=g[13],C=g[14];let o=0;for(const r of e.lights){if(o>=Zg)break;if(!r._writeLightUbo)continue;const B=4+o*16,n=A[B+3];if(n===0||n===2){const Q=r.worldMatrix;A[B]=Q[12]-I,A[B+1]=Q[13]-i,A[B+2]=Q[14]-C}o++}}function Y3A(A,e,g){let I=-1,i;return()=>{const C=e.camera,o=C?C.worldMatrixVersion:-1;(o!==I||C!==i)&&(g(),I=o,i=C),A()}}var iZ,CZ=b((()=>{vt(),iZ=null})),J3A=H({makePackMeshWorld:()=>H3A,packMat4IntoF32WithOffset:()=>pY});function pY(A,e,g,I,i,C,o){const r=e,B=I,n=g;A[n+0]=r[B+0],A[n+1]=r[B+1],A[n+2]=r[B+2],A[n+3]=r[B+3],A[n+4]=r[B+4],A[n+5]=r[B+5],A[n+6]=r[B+6],A[n+7]=r[B+7],A[n+8]=r[B+8],A[n+9]=r[B+9],A[n+10]=r[B+10],A[n+11]=r[B+11],A[n+12]=r[B+12]-i,A[n+13]=r[B+13]-C,A[n+14]=r[B+14]-o,A[n+15]=r[B+15]}function H3A(A){return(e,g,I,i)=>{const C=A.camera;if(!C){pY(e,g,I,i,0,0,0);return}const o=C.worldMatrix;pY(e,g,I,i,o[12],o[13],o[14])}}var x3A=b((()=>{})),T3A=H({createGpuFrameTimer:()=>q3A,destroyGpuFrameTimer:()=>V3A,gpuFrameTimerBegin:()=>P3A,gpuFrameTimerEnd:()=>O3A,gpuFrameTimerResolve:()=>j3A,gpuTimingSupportedFor:()=>oZ});function oZ(A){return A.features.has("timestamp-query")}function q3A(A){return oZ(A)?{device:A,markerPipeline:A.createComputePipeline({layout:"auto",compute:{module:A.createShaderModule({code:"@compute @workgroup_size(1) fn main() {}"}),entryPoint:"main"}}),querySet:A.createQuerySet({type:"timestamp",count:2}),resolveBuf:A.createBuffer({size:16,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),pool:[],lastMs:0,inFlight:0}:null}function P3A(A,e){const g=e.beginComputePass({timestampWrites:{querySet:A.querySet,beginningOfPassWriteIndex:0}});g.setPipeline(A.markerPipeline),g.dispatchWorkgroups(1),g.end()}function O3A(A,e){const g=e.beginComputePass({timestampWrites:{querySet:A.querySet,endOfPassWriteIndex:1}});g.setPipeline(A.markerPipeline),g.dispatchWorkgroups(1),g.end()}function j3A(A){if(A.inFlight>3)return;const e=A.device,g=A.pool.pop()??e.createBuffer({size:16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),I=e.createCommandEncoder();I.resolveQuerySet(A.querySet,0,2,A.resolveBuf,0),I.copyBufferToBuffer(A.resolveBuf,0,g,0,16),e.queue.submit([I.finish()]),A.inFlight++,g.mapAsync(GPUMapMode.READ).then(()=>{const i=new BigInt64Array(g.getMappedRange()),C=Number(i[1]-i[0])/1e6;C>=0&&C<5e3&&(A.lastMs=A.lastMs>0?A.lastMs*.8+C*.2:C),g.unmap(),A.pool.push(g),A.inFlight--},()=>{A.inFlight--})}function V3A(A){A.querySet.destroy(),A.resolveBuf.destroy();for(const e of A.pool)e.destroy();A.pool.length=0}var W3A=b((()=>{}));function Vi(){Yn=Yn+1|0}function z3A(A){return A._renderingContexts}function Z3A(A){if(!A||typeof A._kind!="string")throw new TypeError("Invalid RenderingContext: missing internal kind discriminator");return A._kind}function DY(A,e){return A._renderingContexts.indexOf(e)!==-1}function Ln(A,e){return A._renderingContexts.indexOf(e)!==-1?!1:(A._renderingContexts.push(e),!0)}function Zs(A,e){const g=A._renderingContexts,I=g.indexOf(e);return I===-1?!1:(g.splice(I,1),!0)}function X3A(A){const e=hC?.deviceFeatures;hC=A,hC.deviceFeatures=e}function rZ(){return hC?hC():{}}function BZ(A){return EZ.filter(e=>A.features.has(e))}function $3A(A){const e=hC??(()=>({}));e.deviceFeatures=A,hC=e}async function nZ(A,e){const g=await navigator.gpu.requestAdapter({powerPreference:"high-performance",...hC?hC():{}});g||R(50);const I=hC?.deviceFeatures?.(g,e)??BZ(g),i=await g.requestDevice({requiredFeatures:I,requiredLimits:e?.requiredLimits});console.log(`${EY} - WebGPU engine`);const C=!!e?.useHighPrecisionMatrix,o=!!e?.useFloatingOrigin;if(o&&!C&&R(51),C){const{allocateF64Mat4:c}=await Promise.resolve().then(()=>(K3A(),k3A));G3A(c)}let r,B,n,Q;if(o){const[{wrapRenderableForFO:c,lightFoVersion:l,applyLightFoOffset:p},{makePackMeshWorld:D}]=await Promise.all([Promise.resolve().then(()=>(CZ(),U3A)),Promise.resolve().then(()=>(x3A(),J3A))]);r=c,B=D,n=l,Q=p}const E={_device:i},a=[E];return Object.assign(E,{engine:E,surfaces:a,_surfaces:a,_device:i,_options:e,drawCallCount:0,gpuFrameTimeMs:0,useHighPrecisionMatrix:C,useFloatingOrigin:o,_animFrameId:0,_renderFn:null,_currentEncoder:void 0,_currentDelta:0,_cbs:[],_wrapRenderableForFO:r,_makePackMeshWorld:B,_lightFoVersion:n,_applyLightFoOffset:Q},AZ(E,A,e)),p3(E),l3(E),E}function uY(A){for(const e of A.surfaces)p3(e)}function AKA(A,e,g){cY(A,e,g)}function D3(A){const e=A.canvas;return{width:e.width,height:e.height}}function Rm(A){return new Promise(e=>{let g=!0,I=0;A._renderFn=i=>{const C=g?0:I>0?i-I:16.667;I=i,uY(A),sZ(A,C),g&&(g=!1,e()),A._renderFn&&(A._animFrameId=requestAnimationFrame(A._renderFn))},A._animFrameId=requestAnimationFrame(A._renderFn)})}function eKA(A){return A._device.queue.onSubmittedWorkDone()}function u3(A){A._animFrameId&&cancelAnimationFrame(A._animFrameId),A._animFrameId=0,A._renderFn=null,A._flushGpuRetirements?.(A)}function gKA(A,e,g=A.surfaces){if(g!==A.surfaces)for(let I=g.length;I--;)g[I].engine!==A&&R(52);sZ(A,e,g)}function sZ(A,e,g=A._surfaces){let I=0;for(let C=g.length;C--;)I+=g[C]._renderingContexts.length;if(!I)return A.drawCallCount=0,A._flushGpuRetirements?.(A);const i=A._device.createCommandEncoder({label:"frame"});A._currentEncoder=i,A._currentDelta=e;try{A._gpuTimerBegin?.(i),I=0;for(let o=0;o<g.length;o++){const r=g[o];r._capturePreFrame?.(r),l3(r);const B=r._renderingContexts;for(let n=0;n<B.length;n++){const Q=B[n];Q._update(),I+=Q._drawCallsPre+Q._record()}}const C=A._currentEncoder;for(let o=0;o<g.length;o++){const r=g[o];r._captureService?.(r,C)}A._gpuTimerEnd?.(C),A._cbs[0]=C.finish(),A._device.queue.submit(A._cbs),A._flushGpuRetirements?.(A),A.drawCallCount=I,A._gpuTimerResolve?.()}finally{A._currentEncoder=void 0}}function QZ(A){return A._device.features.has("timestamp-query")}function IKA(A,e){if(!e){A._gpuTimerWanted=!1,A.gpuFrameTimeMs=0,A._gpuTimerBegin=void 0,A._gpuTimerEnd=void 0,A._gpuTimerResolve=A._gpuTaskTimerResolve;return}QZ(A)&&(A._gpuTimerWanted=!0,Promise.resolve().then(()=>(W3A(),T3A)).then(({createGpuFrameTimer:g,gpuFrameTimerBegin:I,gpuFrameTimerEnd:i,gpuFrameTimerResolve:C})=>{A._gpuTimer===void 0&&(A._gpuTimer=g(A._device));const o=A._gpuTimer;o&&A._gpuTimerWanted&&(A._gpuTimerBegin=r=>I(o,r),A._gpuTimerEnd=r=>i(o,r),A._gpuTimerResolve=()=>{C(o),A.gpuFrameTimeMs=o.lastMs,A._gpuTaskTimerResolve?.()})}))}var Yn,hC,EZ,lt=b((()=>{rA(),Ut(),zs(),aY(),Yn=0,hC=null,EZ=["float32-filterable","texture-compression-astc","texture-compression-bc","texture-compression-etc2","texture-compression-unaligned","timestamp-query","primitive-index"]}));rA(),lt();var aZ=!1;function tKA(){aZ||(aZ=!0,$3A((A,e)=>{const g=BZ(A);for(const I of e?.requiredFeatures??[])A.features.has(I)||R(934,I),g.includes(I)||g.push(I);return g}))}function iKA(A,e){return tKA(),nZ(A,e)}function cZ(A){const e=A._gpuEvents,g=A._device;e._device!==g&&(e._device?.removeEventListener("uncapturederror",e._onError),e._device=g,g.addEventListener("uncapturederror",e._onError),g.lost.then(I=>{if(e._device===g)for(const i of e._lost)i(I)}))}function lZ(A){let e=A._gpuEvents;if(!e){const g=new Set;e=A._gpuEvents={_errors:g,_lost:new Set,_device:null,_onError:I=>{const i=I.error;for(const C of g)C(i)}},A._attachGpuEvents=cZ}return cZ(A),e}function CKA(A,e){const g=lZ(A);return g._errors.add(e),()=>{g._errors.delete(e)}}function oKA(A,e){const g=lZ(A);return g._lost.add(e),()=>{g._lost.delete(e)}}function pZ(A){return A._device.limits}function rKA(A,e){return A._device.features.has(e)}function _3(A){wC(A.splice(0))}function wC(A){for(const e of A)try{e()}catch(g){console.error("GPU resource retirement failed.",g)}}function et(A,e){A._flushGpuRetirements??=d3,(A._retirements??=[]).push(e)}function DZ(A,e){if(!e.length)return;const g=e.slice();et(A,()=>wC(g))}function d3(A){const e=A._retirements;if(!e)return;A._retirements=null;const g=A._retiring??=new Set;g.add(e),queueMicrotask(()=>{A._device.queue.onSubmittedWorkDone().then(()=>{g.delete(e),_3(e)}).catch(()=>{})})}async function BKA(A){await Promise.resolve();do{d3(A);const e=A._retiring,g=e?[...e]:[];await A._device.queue.onSubmittedWorkDone();for(const I of g)e.delete(I),_3(I)}while(A._retirements?.length||A._retiring?.size)}function uZ(A){const e=A._retirements,g=A._retiring;A._retirements=null,A._retiring=null,e&&_3(e),g?.forEach(_3)}var kI=b((()=>{}));lt(),kI();function nKA(A){uZ(A),u3(A);const e=A._surfaces;for(const g of e)g._renderingContexts.length=0,g._ro?.disconnect(),g._context.unconfigure();e.length=0;try{A._disposeManagedResources?.(),A._disposeStorageBuffers?.()}finally{A._device.destroy()}}function sKA(A){const e={useHighPrecisionMatrix:!1,useFloatingOrigin:!1,drawCallCount:0,gpuFrameTimeMs:0,_animFrameId:0,_renderFn:null,_currentDelta:0,_cbs:[],_renderingContexts:[]};e.engine=e;const g=[e];return e.surfaces=g,e._surfaces=g,e}function _Z(A,e,g){A._currentDelta=g,e._update()}function QKA(A,e,g,I=1e3/60){for(let i=0;i<g;i++)_Z(A,e,I)}function f3(A,e){e.hooks.size===0&&(A._gpuTaskTimerResolve===e.dispatch&&(A._gpuTaskTimerResolve=void 0),A._gpuTimerResolve===e.dispatch&&(A._gpuTimerResolve=void 0),h3?.get(A)===e&&h3.delete(A))}function y3(A,e,g,I){const i=e==="frame"?A._currentEncoder:null;e==="frame"&&!i&&R(53);const C=h3??=new WeakMap;let o=C.get(A);if(!o){const B=new Set,n=(E=A._currentEncoder,a=!0)=>{if(!(!E||o.lastDispatchedEncoder===E)){if(!a){for(const c of B)c.encoder===E&&(B.delete(c),c.cancel?.());f3(A,o);return}o.lastDispatchedEncoder=E;for(const c of B){if(c.encoder&&c.encoder!==E){B.delete(c),c.cancel?.();continue}c.encoder&&B.delete(c),c.run(E)}f3(A,o)}};o={hooks:B,dispatch:n,lastDispatchedEncoder:null},C.set(A,o);const Q=A._gpuTaskTimerResolve;A._gpuTaskTimerResolve=n,(!A._gpuTimerResolve||A._gpuTimerResolve===Q)&&(A._gpuTimerResolve=n)}const r={run:g,cancel:I,encoder:i};return o.hooks.add(r),i&&queueMicrotask(()=>{o.hooks.has(r)&&A._currentEncoder!==i&&(o.hooks.delete(r),I?.(),f3(A,o))}),()=>{o.hooks.delete(r)&&f3(A,o)}}var h3,_Y=b((()=>{rA(),h3=null})),EKA=H({createGpuTaskTimer:()=>aKA,installGpuTaskTimer:()=>cKA});function aKA(A){return A.features.has("timestamp-query")?{device:A,querySet:A.createQuerySet({type:"timestamp",count:128}),resolveBuffer:A.createBuffer({size:1024,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),readbackPool:[],pendingReadbacks:new Set,records:[],wrappedGraphs:[],patchedContextLists:[],patchedSurfaceLists:[],taskCapacity:MZ,currentEncoder:null,patchedEncoderMethods:null,activeTaskTiming:null,nextQueryIndex:0,nextTaskIndex:0,frameIndex:0,lastPublishedFrameIndex:0,droppedTaskCount:0,inFlight:0,skipFrame:!1,disposed:!1}:null}function cKA(A,e,g){lKA(A,e._surfaces);for(const C of e.surfaces)dZ(A,C);const i=y3(e,"persistent",C=>{A.currentEncoder===C&&hKA(A,g)});return()=>{DKA(A,i),RKA(A)}}function lKA(A,e){for(const I of A.patchedSurfaceLists)if(I.list===e)return;const g=e.push;e.push=(...I)=>{const i=g.apply(e,I);for(const C of I)dZ(A,C);return i},A.patchedSurfaceLists.push({list:e,push:g})}function dZ(A,e){const g=e._renderingContexts;pKA(A,g);for(const I of g){const i=yZ(I);i&&fZ(A,i)}}function pKA(A,e){for(const I of A.patchedContextLists)if(I.list===e)return;const g=e.push;e.push=(...I)=>{const i=g.apply(e,I);for(const C of I){const o=yZ(C);o&&fZ(A,o)}return i},A.patchedContextLists.push({list:e,push:g})}function fZ(A,e){for(const i of A.wrappedGraphs)if(i.graph===e)return;const g=e.execute,I=()=>_KA(A,e);e.execute=I,A.wrappedGraphs.push({graph:e,execute:g})}function DKA(A,e){for(const g of A.patchedSurfaceLists)g.list.push=g.push;A.patchedSurfaceLists.length=0;for(const g of A.patchedContextLists)g.list.push=g.push;A.patchedContextLists.length=0;for(const g of A.wrappedGraphs)g.graph.execute=g.execute;A.wrappedGraphs.length=0,dY(A),e()}function yZ(A){const e=A,g=e._frameGraph??e.frameGraph;return uKA(g)?g:null}function uKA(A){return typeof A=="object"&&A!==null&&"_tasks"in A&&"execute"in A}function _KA(A,e){let g=0;for(const I of e._tasks)I.executionEnabled!==!1&&(g+=dKA(A,I));return g}function dKA(A,e){const g=e.engine._currentEncoder;A.currentEncoder!==g&&fKA(A,g);const I=A.nextTaskIndex++;if(A.skipFrame)return hZ(e);const i={beginQueryIndex:-1,endQueryIndex:-1,passCount:0,conflicted:!1,dropped:!1};A.activeTaskTiming=i;try{const C=hZ(e);return i.passCount>0&&!i.conflicted&&!i.dropped&&A.records.push({index:I,name:e.name,beginQueryIndex:i.beginQueryIndex,endQueryIndex:i.endQueryIndex}),C}finally{A.activeTaskTiming=null}}function hZ(A){if(A.execute)return A.execute();let e=0;for(const g of A._passes)e+=g._execute();return e}function fKA(A,e){dY(A),A.currentEncoder=e,A.patchedEncoderMethods=yKA(A,e),A.records.length=0,A.nextQueryIndex=0,A.nextTaskIndex=0,A.droppedTaskCount=0,A.skipFrame=A.inFlight>hY}function yKA(A,e){const g=e.beginRenderPass.bind(e),I=e.beginComputePass.bind(e),i=Object.getOwnPropertyDescriptor(e,"beginRenderPass"),C=Object.getOwnPropertyDescriptor(e,"beginComputePass");return Reflect.set(e,"beginRenderPass",o=>g(wZ(A,o)),e)||R(54),Reflect.set(e,"beginComputePass",o=>I(wZ(A,o)),e)||(fY(e,"beginRenderPass",i),R(55)),{encoder:e,beginRenderPass:i,beginComputePass:C}}function wZ(A,e){const g=A.activeTaskTiming;if(!g||g.conflicted||g.dropped)return e;if(e?.timestampWrites!==void 0)return g.conflicted=!0,e;const I=A.taskCapacity*2;if(g.passCount===0)return A.nextQueryIndex+2>I?(g.dropped=!0,A.droppedTaskCount++,e):(g.beginQueryIndex=A.nextQueryIndex++,g.endQueryIndex=A.nextQueryIndex++,g.passCount++,{...e,timestampWrites:{querySet:A.querySet,beginningOfPassWriteIndex:g.beginQueryIndex,endOfPassWriteIndex:g.endQueryIndex}});if(A.nextQueryIndex>=I)return g.dropped=!0,A.droppedTaskCount++,e;g.endQueryIndex=A.nextQueryIndex++,g.passCount++;const i={querySet:A.querySet,endOfPassWriteIndex:g.endQueryIndex};return{...e,timestampWrites:i}}function dY(A){const e=A.patchedEncoderMethods;e&&(fY(e.encoder,"beginRenderPass",e.beginRenderPass),fY(e.encoder,"beginComputePass",e.beginComputePass)),A.currentEncoder=null,A.patchedEncoderMethods=null,A.activeTaskTiming=null}function fY(A,e,g){g?Object.defineProperty(A,e,g):Reflect.deleteProperty(A,e)}function hKA(A,e){if(A.disposed)return;A.frameIndex++;const g=A.records.slice(),I=g.length,i=A.nextQueryIndex,C=A.droppedTaskCount;if(A.records.length=0,A.nextQueryIndex=0,A.droppedTaskCount=0,dY(A),A.skipFrame||A.inFlight>hY)return;if(I===0){C>0&&yY(A,e,eo("available",!0,!0,A.frameIndex,[],C,0));return}const o=i*8,r=A.readbackPool.pop()??wKA(A),B=A.device.createCommandEncoder({label:"gpu-task-timing-resolve"});B.resolveQuerySet(A.querySet,0,i,A.resolveBuffer,0),B.copyBufferToBuffer(A.resolveBuffer,0,r,0,o),A.device.queue.submit([B.finish()]),A.inFlight++,A.pendingReadbacks.add(r),MKA(A,{buffer:r,byteLength:o,frameIndex:A.frameIndex,records:g,droppedTaskCount:C,publish:e})}function wKA(A){return A.device.createBuffer({size:A.taskCapacity*16,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}async function MKA(A,e){const g=e.buffer;try{if(await Promise.resolve(),await g.mapAsync(GPUMapMode.READ,0,e.byteLength),A.disposed)return;const I=new BigUint64Array(g.getMappedRange(0,e.byteLength)),i=[];let C=null,o=null;for(const B of e.records){const n=I[B.beginQueryIndex],Q=I[B.endQueryIndex];Q>=n&&(i.push({index:B.index,name:B.name,durationMs:Number(Q-n)/1e6}),C=C===null||n<C?n:C,o=o===null||Q>o?Q:o)}const r=C===null||o===null?0:Number(o-C)/1e6;g.unmap(),A.pendingReadbacks.delete(g),A.readbackPool.push(g),A.inFlight--,yY(A,e.publish,eo("available",!0,!0,e.frameIndex,i,e.droppedTaskCount,r))}catch(I){if(A.disposed)return;A.pendingReadbacks.delete(g),A.inFlight--,g.destroy(),yY(A,e.publish,eo("error",!0,!0,e.frameIndex,[],e.droppedTaskCount,0,SKA(I)))}}function yY(A,e,g){g.frameIndex>A.lastPublishedFrameIndex&&(A.lastPublishedFrameIndex=g.frameIndex,e(g))}function RKA(A){if(!A.disposed){A.disposed=!0,A.querySet.destroy(),A.resolveBuffer.destroy();for(const e of A.readbackPool)e.destroy();for(const e of A.pendingReadbacks)e.destroy();A.readbackPool.length=0,A.pendingReadbacks.clear(),A.inFlight=0}}function SKA(A){return A instanceof Error?A.message:String(A)}var MZ,hY,NKA=b((()=>{rA(),_Y(),GZ(),MZ=64,hY=3}));function mI(A,e,g,I,i,C){const o=g[I],r=g[I+1],B=g[I+2],n=g[I+3],Q=g[I+4],E=g[I+5],a=g[I+6],c=g[I+7],l=g[I+8],p=g[I+9],D=g[I+10],u=g[I+11],_=g[I+12],d=g[I+13],y=g[I+14],h=g[I+15];let w=i[C],M=i[C+1],N=i[C+2],S=i[C+3];A[e]=o*w+Q*M+l*N+_*S,A[e+1]=r*w+E*M+p*N+d*S,A[e+2]=B*w+a*M+D*N+y*S,A[e+3]=n*w+c*M+u*N+h*S,w=i[C+4],M=i[C+5],N=i[C+6],S=i[C+7],A[e+4]=o*w+Q*M+l*N+_*S,A[e+5]=r*w+E*M+p*N+d*S,A[e+6]=B*w+a*M+D*N+y*S,A[e+7]=n*w+c*M+u*N+h*S,w=i[C+8],M=i[C+9],N=i[C+10],S=i[C+11],A[e+8]=o*w+Q*M+l*N+_*S,A[e+9]=r*w+E*M+p*N+d*S,A[e+10]=B*w+a*M+D*N+y*S,A[e+11]=n*w+c*M+u*N+h*S,w=i[C+12],M=i[C+13],N=i[C+14],S=i[C+15],A[e+12]=o*w+Q*M+l*N+_*S,A[e+13]=r*w+E*M+p*N+d*S,A[e+14]=B*w+a*M+D*N+y*S,A[e+15]=n*w+c*M+u*N+h*S}var T1=b((()=>{}));function RZ(A,e,g,I,i){const C=1/Math.tan(e*.5),o=i-I;A[0]=C/g,A[5]=C,A[10]=-I/o,A[11]=1,A[14]=i*I/o}var SZ=b((()=>{}));function ei(A){const e=A.worldMatrixVersion;if(A._viewVer===e)return A._viewCache;const g=A._viewCache,I=A.worldMatrix,i=A._useFloatingOrigin,C=i?0:I[12],o=i?0:I[13],r=i?0:I[14];return g[0]=I[0],g[1]=I[4],g[2]=I[8],g[3]=0,g[4]=I[1],g[5]=I[5],g[6]=I[9],g[7]=0,g[8]=I[2],g[9]=I[6],g[10]=I[10],g[11]=0,g[12]=-(I[0]*C+I[1]*o+I[2]*r),g[13]=-(I[4]*C+I[5]*o+I[6]*r),g[14]=-(I[8]*C+I[9]*o+I[10]*r),g[15]=1,A._viewVer=e,g}function GKA(A){w3=A}function Wi(A){return(A._projFov!==A.fov||A._projNear!==A.nearPlane||A._projFar!==A.farPlane)&&(A._projFov=A.fov,A._projNear=A.nearPlane,A._projFar=A.farPlane,A._projRev=(A._projRev??0)+1),A.worldMatrixVersion+(A._projRev??0)}function IC(A,e){const g=Wi(A);if(A._projVer===g&&A._projAspect===e)return A._projCache;const I=A._projCache;return w3!==null&&A.ortho?w3(A,e,I):RZ(I,A.fov,e,A.nearPlane,A.farPlane),A._projVer=g,A._projAspect=e,I}function si(A,e){const g=Wi(A);if(A._vpVer===g&&A._vpAspect===e)return A._vpCache;const I=A._vpCache;return mI(I,0,IC(A,e),0,ei(A),0),A._vpVer=g,A._vpAspect=e,I}function Jn(A){const e=A.worldMatrix;return{x:e[12],y:e[13],z:e[14]}}function wi(A,e,g){const I=A?.viewport;return e/g*(I?I.width/I.height:1)}function NZ(A,e,g,I){const i=e?.viewport;if(!i)return;const C=Math.floor(i.x*g),o=Math.floor((1-i.y-i.height)*I),r=Math.ceil((i.x+i.width)*g)-C,B=Math.ceil((1-i.y)*I)-o;A.setViewport(C,o,r,B,0,1),A.setScissorRect(C,o,r,B)}var w3,FI=b((()=>{T1(),SZ(),w3=null})),mKA=H({_measureRenderTaskOverdrawCost:()=>FKA});async function FKA(A,e,g){const I=A._device;I.features.has("timestamp-query")||R(141);const i=g?.repeats??9;if(!Number.isInteger(i)||i<1)throw new RangeError("overdraw probe: repeats must be a positive integer");const C=e._config.rt,o=e._config.depth??C;(e._config.depth?e._config.depth._eager===!0:e._config.depthClear===!1)&&R(142);const r=C._width,B=C._height;(!r||!B)&&R(143);const n=C._descriptor.format??e._targetSignature._colorFormat,Q=e._targetSignature._depthStencilFormat,E=C._descriptor.samples??e._targetSignature._sampleCount??1;(!n||!Q?.startsWith("depth"))&&R(144);const a=[],c={index:0};for(const S of[e._opaqueBindings,e._directBindings,e._transparentBindings]){for(const G of S){const m=G.renderable.mesh;m&&m.visible===!1||a.push(G)}S!==e._transparentBindings&&(c.index=a.length)}a.length===0&&R(145);const l=e._sceneBG;l||R(146);const p=e._config.cam??e.scene.camera??null,D=(()=>{const S=a.slice(0,c.index);if(!p||S.length<=1)return a;const G=ei(p),m=K=>{const U=K.renderable._worldCenter??(()=>{const Y=K.renderable.mesh?.worldMatrix;return Y?[Y[12],Y[13],Y[14]]:null})();return U?U[0]*G[2]+U[1]*G[6]+U[2]*G[10]+G[14]:0},k=S.map(K=>({b:K,z:m(K)}));return k.sort((K,U)=>K.z-U.z),[...k.map(K=>K.b),...a.slice(c.index)]})(),u=I.createTexture({label:"overdraw-probe-color",size:{width:r,height:B},format:n,sampleCount:E,usage:GPUTextureUsage.RENDER_ATTACHMENT}),_=I.createTexture({label:"overdraw-probe-depth",size:{width:r,height:B},format:Q,sampleCount:E,usage:GPUTextureUsage.RENDER_ATTACHMENT}),d=Q==="depth24plus-stencil8"||Q==="depth32float-stencil8",y=o._descriptor.depthClearValue??0,h=I.createQuerySet({type:"timestamp",count:i*6}),w=I.createBuffer({label:"overdraw-probe-resolve",size:i*6*8,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),M=I.createBuffer({label:"overdraw-probe-read",size:i*6*8,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),N=(S,G)=>{const m=p?.viewport;if(m){const K=Math.floor(m.x*r),U=Math.floor((1-m.y-m.height)*B),Y=Math.ceil((m.x+m.width)*r)-K,x=Math.ceil((1-m.y)*B)-U;S.setViewport(K,U,Y,x,0,1),S.setScissorRect(K,U,Y,x)}S.setBindGroup(0,l);let k=null;for(const K of G)K.pipeline!==k&&(S.setPipeline(K.pipeline),k=K.pipeline),K.draw(S,A)};try{const S=u.createView(),G=_.createView();for(let X=0;X<i;X++){const Z=I.createCommandEncoder({label:"overdraw-probe"}),AA={view:G,depthClearValue:y,depthLoadOp:"clear",depthStoreOp:"store",...d?{stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}:{}},z={view:S,loadOp:"clear",storeOp:"discard",clearValue:{r:0,g:0,b:0,a:0}},IA=Z.beginRenderPass({label:"overdraw-probe-a",colorAttachments:[z],depthStencilAttachment:AA,timestampWrites:{querySet:h,beginningOfPassWriteIndex:X*6,endOfPassWriteIndex:X*6+1}});N(IA,a),IA.end();const sA=Z.beginRenderPass({label:"overdraw-probe-b",colorAttachments:[z],depthStencilAttachment:{view:G,depthLoadOp:"load",depthStoreOp:"discard",...d?{stencilLoadOp:"load",stencilStoreOp:"discard"}:{}},timestampWrites:{querySet:h,beginningOfPassWriteIndex:X*6+2,endOfPassWriteIndex:X*6+3}});N(sA,a),sA.end();const DA=Z.beginRenderPass({label:"overdraw-probe-c",colorAttachments:[z],depthStencilAttachment:{...AA,depthStoreOp:"discard",...d?{stencilStoreOp:"discard"}:{}},timestampWrites:{querySet:h,beginningOfPassWriteIndex:X*6+4,endOfPassWriteIndex:X*6+5}});N(DA,D),DA.end(),X===i-1&&(Z.resolveQuerySet(h,0,i*6,w,0),Z.copyBufferToBuffer(w,0,M,0,i*6*8)),I.queue.submit([Z.finish()])}await M.mapAsync(GPUMapMode.READ);const m=new BigUint64Array(M.getMappedRange()),k=[],K=[],U=[];for(let X=0;X<i;X++){const Z=Number(m[X*6+1]-m[X*6])/1e6,AA=Number(m[X*6+3]-m[X*6+2])/1e6,z=Number(m[X*6+5]-m[X*6+4])/1e6;Z>0&&Z<1e3&&k.push(Z),AA>0&&AA<1e3&&K.push(AA),z>0&&z<1e3&&U.push(z)}M.unmap(),(!k.length||!K.length||!U.length)&&R(147);const Y=X=>{const Z=X.slice().sort((AA,z)=>AA-z);return Z[Z.length>>1]},x=+Y(k).toFixed(3),q=+Y(K).toFixed(3),j=+Y(U).toFixed(3);return{width:r,height:B,sampleCount:E,bindings:a.length,msAsIs:x,msVisibleOnly:q,overdrawMs:+(x-q).toFixed(3),ratio:q>0?+(x/q).toFixed(3):0,msFrontToBack:j,sortGainMs:+(x-j).toFixed(3),repeats:i}}finally{h.destroy(),w.destroy(),M.destroy(),u.destroy(),_.destroy()}}var bKA=b((()=>{rA(),FI()}));function M3(A){return A._device.features.has("timestamp-query")}function R3(A){if(!M3(A))return eo("unsupported",!1,!1,0,[],0,0);const e=A._gpuTaskTimingResult;return e||(A._gpuTaskTimerWanted?eo("pending",!0,!0,0,[],0,0):eo("disabled",!0,!1,0,[],0,0))}async function kKA(A,e){if(!e){A._gpuTaskTimerEpoch=(A._gpuTaskTimerEpoch??0)+1,A._gpuTaskTimerWanted=!1,A._gpuTaskTimerDisable?.(),A._gpuTaskTimerDisable=void 0,A._gpuTaskTimer=void 0;const o=M3(A);return A._gpuTaskTimingResult=eo(o?"disabled":"unsupported",o,!1,0,[],0,0),A._gpuTaskTimingResult}if(!M3(A))return A._gpuTaskTimerWanted=!1,A._gpuTaskTimingResult=eo("unsupported",!1,!1,0,[],0,0),A._gpuTaskTimingResult;if(A._gpuTaskTimerWanted)return R3(A);const g=(A._gpuTaskTimerEpoch??0)+1;A._gpuTaskTimerEpoch=g,A._gpuTaskTimerWanted=!0,A._gpuTaskTimingResult=eo("pending",!0,!0,0,[],0,0);const{createGpuTaskTimer:I,installGpuTaskTimer:i}=await Promise.resolve().then(()=>(NKA(),EKA));if(!A._gpuTaskTimerWanted||A._gpuTaskTimerEpoch!==g)return R3(A);A._gpuTaskTimer===void 0&&(A._gpuTaskTimer=I(A._device));const C=A._gpuTaskTimer;return C?(A._gpuTaskTimerDisable=i(C,A,o=>{A._gpuTaskTimerWanted&&A._gpuTaskTimerEpoch===g&&(A._gpuTaskTimingResult=o)}),R3(A)):(A._gpuTaskTimerWanted=!1,A._gpuTaskTimingResult=eo("unsupported",!1,!1,0,[],0,0),A._gpuTaskTimingResult)}async function KKA(A,e,g){const{_measureRenderTaskOverdrawCost:I}=await Promise.resolve().then(()=>(bKA(),mKA));return I(A,e,g)}function eo(A,e,g,I,i,C,o,r){return{status:A,supported:e,enabled:g,frameIndex:I,tasks:i,totalDurationMs:o,droppedTaskCount:C,error:r}}var GZ=b((()=>{}));zs();function UKA(A){if(!Mm(A.canvas)||typeof ResizeObserver>"u")return()=>{};A._ro?.disconnect();const e=A._ro=new ResizeObserver(([g])=>{A._w=Math.round(g.contentRect.width),A._h=Math.round(g.contentRect.height)});return e.observe(A.canvas),()=>{e.disconnect(),A._ro===e&&(A._ro=void 0,A._w=A._h=void 0)}}var vKA=H({createCapturePreFrame:()=>TKA,createCaptureService:()=>xKA});function LKA(A){return Math.ceil(A*4/256)*256}function YKA(A){const e=A._captureQueue;!e||e.length===0||A._swapchainCopySrc||(A._swapchainCopySrc=!0,A._context.configure({device:A.engine._device,format:A._configureFormat,alphaMode:A._alphaMode,usage:RA.RENDER_ATTACHMENT|RA.COPY_SRC,viewFormats:[A.format]}))}function JKA(A,e){const g=A._captureQueue;if(!g||g.length===0||!A._swapchainCopySrc)return;A._captureQueue=void 0;const I=A.scRT._colorTexture;if(!I){const B=new Error("captureScreenshot: no swapchain texture available");for(const n of g)n.reject(B);return}const i=A.scRT._width,C=A.scRT._height,o=LKA(i),r=A.engine._device.createBuffer({label:"screenshot-readback",size:o*C,usage:dA.COPY_DST|dA.MAP_READ});e.copyTextureToBuffer({texture:I},{buffer:r,bytesPerRow:o,rowsPerImage:C},{width:i,height:C,depthOrArrayLayers:1}),HKA({buffer:r,width:i,height:C,bytesPerRow:o,bgra:A.format.startsWith("bgra"),reqs:g})}async function HKA(A){const{buffer:e,width:g,height:I,bytesPerRow:i,bgra:C,reqs:o}=A;try{await Promise.resolve(),await e.mapAsync(GPUMapMode.READ);const r=new Uint8Array(e.getMappedRange()),B=new Uint8ClampedArray(g*I*4);for(let Q=0;Q<I;Q++){const E=Q*i,a=Q*g*4;for(let c=0;c<g;c++){const l=E+c*4,p=a+c*4;C?(B[p]=r[l+2],B[p+1]=r[l+1],B[p+2]=r[l]):(B[p]=r[l],B[p+1]=r[l+1],B[p+2]=r[l+2]),B[p+3]=255}}e.unmap(),e.destroy();const n={width:g,height:I,data:B};for(const Q of o)Q.resolve(n)}catch(r){try{e.destroy()}catch{}for(const B of o)B.reject(r)}}function xKA(){return JKA}function TKA(){return YKA}var qKA=b((()=>{te()}));function PKA(A){const e=new Promise((g,I)=>{(A._captureQueue??=[]).push({resolve:g,reject:I})});return A._captureService||Promise.resolve().then(()=>(qKA(),vKA)).then(({createCaptureService:g,createCapturePreFrame:I})=>{A._captureService??=g(),A._capturePreFrame??=I()}),e}function Sm(A,e){return Math.ceil(A/e)*e}var Nm=b((()=>{}));function dg(A,e,g,I){const i=A._device.createBuffer({label:I,size:Sm(Math.max(e.byteLength,4),4),usage:g|dA.COPY_DST,mappedAtCreation:!0});return new He(i.getMappedRange()).set(new He(e.buffer,e.byteOffset,e.byteLength)),i.unmap(),i}var yt=b((()=>{ZA(),te(),Nm()})),OKA=H({getCpuStorageRecoveryLimits:()=>jKA,rebuildCpuStorageBuffers:()=>VKA});function jKA(A){for(const e of A._storageBuffers??[])if(e._data){const g=A._device.limits;return{maxBufferSize:g.maxBufferSize,maxStorageBufferBindingSize:g.maxStorageBufferBindingSize,maxStorageBuffersPerShaderStage:g.maxStorageBuffersPerShaderStage}}}function VKA(A){for(const e of A._storageBuffers??[])e._destroyed||(e._buffer=e._data?dg(A,e._data,dA.STORAGE,e._label):null)}var WKA=b((()=>{te(),yt()}));function I1(A,e={},g=""){const I=A._device,i=wY??=new WeakMap;let C=i.get(I);C||i.set(I,C=new Map);let o=g;for(const B in MY){const n=B;o+=`:${e[n]??MY[n]}`}let r=C.get(o);return r||C.set(o,r=I.createSampler(e)),r}function zKA(A){wY?.delete(A._device)}var wY,S3,N3,MY,m1=b((()=>{wY=null,S3="nearest",N3="clamp-to-edge",MY={minFilter:S3,magFilter:S3,mipmapFilter:S3,addressModeU:N3,addressModeV:N3,addressModeW:N3,maxAnisotropy:1}}));function go(A,e={}){const g=e.compare,I=e.lodMinClamp??0,i=e.lodMaxClamp??32;return I1(A,e,g!==void 0||I!==0||i!==32?`${g??""}:${I}:${i}`:"")}var Gm=b((()=>{m1()}));function G3(){return mZ??=new WeakMap}var mZ,RY=b((()=>{mZ=null}));function Mi(A){const e=G3();e.set(A,(e.get(A)??0)+1)}var Lr=b((()=>{RY()}));function LI(A){Mi(A.texture)}var Gt=b((()=>{Lr()}));function FZ(A){return G3().get(A.texture)===0}function m3(A){return G3().get(A.texture)??0}var SY=b((()=>{RY()}));function bZ(A){return I1(A,kZ)}function Qi(A){return I1(A,KZ)}function F3(A){return I1(A,UZ)}var kZ,KZ,UZ,F1=b((()=>{m1(),kZ={magFilter:"nearest",minFilter:"nearest"},KZ={magFilter:"linear",minFilter:"linear"},UZ={magFilter:"linear",minFilter:"linear",mipmapFilter:"linear"}})),Yr=H({generateMipmaps:()=>Xs,recordMipmaps:()=>b3});function ZKA(){$s?.clear(),$s=null,mm=null,k3=null,Fm=null,K3=null}function XKA(A){const e=A._device;e!==K3&&(ZKA(),K3=e),mm??=e.createShaderModule({code:vZ}),k3??=Qi(A),Fm??=e.createBindGroupLayout({entries:[{binding:0,visibility:MA.FRAGMENT,texture:{sampleType:"float"}},{binding:1,visibility:MA.FRAGMENT,sampler:{}}]})}function $KA(A,e){const g=A._device;XKA(A),$s??=new Map;let I=$s.get(e);return I||(I=g.createRenderPipeline({layout:g.createPipelineLayout({bindGroupLayouts:[Fm]}),vertex:{module:mm,entryPoint:"vs"},fragment:{module:mm,entryPoint:"fs",targets:[{format:e}]},primitive:{topology:"triangle-list"}}),$s.set(e,I)),I}function Xs(A,e,g){const I=A._device,i=I.createCommandEncoder();b3(A,e,i,g),I.queue.submit([i.finish()])}function b3(A,e,g,I){if(e.mipLevelCount<=1)return;const i=A._device,C=$KA(A,e.format),o=I!=null?{dimension:"2d",baseArrayLayer:I,arrayLayerCount:1}:{};for(let r=1;r<e.mipLevelCount;r++){const B=e.createView({baseMipLevel:r-1,mipLevelCount:1,...o}),n=e.createView({baseMipLevel:r,mipLevelCount:1,...o}),Q=i.createBindGroup({layout:Fm,entries:[{binding:0,resource:B},{binding:1,resource:k3}]}),E=g.beginRenderPass({colorAttachments:[{view:n,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});E.setPipeline(C),E.setBindGroup(0,Q),E.draw(3),E.end()}}var vZ,$s,mm,k3,Fm,K3,Ri=b((()=>{te(),F1(),vZ="@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var s:sampler;struct V{@builtin(position)p:vec4f,@location(0)u:vec2f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1),p*vec2f(.5,-.5)+.5);}@fragment fn fs(v:V)->@location(0)vec4f{return textureSample(t,s,v.u);}",$s=null,mm=null,k3=null,Fm=null,K3=null})),A4A=H({rebuildDynamicTexture2D:()=>e4A});async function e4A(A,e){const g=e._recoverySource;if(!g||g.kind!=="dynamic")return;const{width:I,height:i,format:C,levels:o,samplerDesc:r}=g,B=A._device.createTexture({size:{width:I,height:i},format:C,mipLevelCount:o,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});if(g.source)try{A._device.queue.copyExternalImageToTexture({source:g.source,flipY:g.flipY},{texture:B,premultipliedAlpha:g.premultipliedAlpha},[I,i]),o>1&&Xs(A,B)}catch{g.source=null}e.texture=B,e.view=B.createView(),e.sampler=go(A,r),e.width=I,e.height=i,LI(e)}var g4A=b((()=>{te(),Gt(),Gm(),Ri()})),NY=H({rebuildTexture2D:()=>I4A,settleRebuiltTextureOwnership:()=>t4A});async function I4A(A,e){const g=e._recoverySource;if(!g||FZ(e))return;U3??=new WeakMap;const I=U3.get(g);if(I?.device===A._device){I.tex!==e&&(await I.done,i4A(A,e,I.tex));return}const i=m3(e),C=C4A(A,e,g);if(U3.set(g,{device:A._device,tex:e,done:C}),await C,i>0){const o=A._deviceLostRecovery;o&&(o._pendingOwnership??=[]).push([e,i])}}function t4A(A){const e=A._pendingOwnership;if(A._pendingOwnership=void 0,!!e)for(const[g,I]of e)for(let i=m3(g);i<I;i++)LI(g)}function i4A(A,e,g){const I=LZ(A,e)??g.sampler;e.texture=g.texture,e.view=g.view,e.width=g.width,e.height=g.height,e.sampler=I}function LZ(A,e){const g=A._deviceLostRecovery?._samplerDescriptors,I=g?.get(e.sampler);if(!I)return;const i=go(A,I);return g.set(i,I),i}async function C4A(A,e,g){if(g.kind==="url"){const B=await o4A(A,g.url,g.opts);e.texture=B.texture,e.view=B.view,e.sampler=B.sampler,e.width=B.width,e.height=B.height,e._recoverySource=g;return}if(g.kind==="solid"){const B=A._device.createTexture({size:{width:1,height:1},format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST}),n=new He(g.rgba.map(Q=>Math.round(Q*255)));A._device.queue.writeTexture({texture:B},n,{bytesPerRow:4,rowsPerImage:1},{width:1,height:1}),e.texture=B,e.view=B.createView(),e.sampler=Qi(A),e.width=1,e.height=1;return}if(g.kind==="dynamic"){const{rebuildDynamicTexture2D:B}=await Promise.resolve().then(()=>(g4A(),A4A));await B(A,e);return}if(g.kind==="pixels"){const B=g.options,n=A._device.createTexture({size:{width:g.width,height:g.height},format:B.srgb?"rgba8unorm-srgb":"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST});A._device.queue.writeTexture({texture:n},g.data,{bytesPerRow:g.width*4,rowsPerImage:g.height},{width:g.width,height:g.height}),e.texture=n,e.view=n.createView(),e.sampler=go(A,{addressModeU:B.addressModeU??"clamp-to-edge",addressModeV:B.addressModeV??"clamp-to-edge",minFilter:B.minFilter??"nearest",magFilter:B.magFilter??"nearest"}),e.width=g.width,e.height=g.height;return}if(g.kind==="render"){const B=A._device.createTexture({size:{width:g.width,height:g.height},format:g.format,usage:RA.TEXTURE_BINDING|RA.RENDER_ATTACHMENT|RA.COPY_DST});e.texture=B,e.view=B.createView(),e.sampler=go(A,g.samplerDesc),e.width=g.width,e.height=g.height;return}if(g.kind==="external"){if(!g.bitmap)throw new Error("Cannot recover a released external-image texture");const B=A._device.createTexture({size:{width:g.width,height:g.height},format:g.format,mipLevelCount:g.levels,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});if(A._device.queue.copyExternalImageToTexture({source:g.bitmap,flipY:g.flipY},{texture:B,premultipliedAlpha:g.premultipliedAlpha},{width:g.width,height:g.height}),g.levels>1){const{generateMipmaps:n}=await Promise.resolve().then(()=>(Ri(),Yr));n(A,B)}e.texture=B,e.view=B.createView(),e.sampler=go(A,g.samplerDesc),e.width=g.width,e.height=g.height;return}const I=g.bitmap?.width??1,i=g.bitmap?.height??1,C=g.srgb?"rgba8unorm-srgb":"rgba8unorm",o=g.mipMaps?Math.floor(Math.log2(Math.max(I,i)))+1:1,r=A._device.createTexture({size:{width:I,height:i},format:C,mipLevelCount:o,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.COPY_SRC|RA.RENDER_ATTACHMENT});if(g.bitmap){if(A._device.queue.copyExternalImageToTexture({source:g.bitmap},{texture:r,premultipliedAlpha:!1},{width:I,height:i}),g.mipMaps&&o>1){const{generateMipmaps:B}=await Promise.resolve().then(()=>(Ri(),Yr));B(A,r)}}else A._device.queue.writeTexture({texture:r},g.fallback??new He([255,255,255,255]),{bytesPerRow:4},{width:1,height:1});e.texture=r,e.view=r.createView(),e.sampler=LZ(A,e)??go(A,{addressModeU:"repeat",addressModeV:"repeat",minFilter:"linear",magFilter:"linear",mipmapFilter:"linear",maxAnisotropy:4}),e.width=I,e.height=i}async function o4A(A,e,g){const I=g.mipMaps??!0,i=g.addressModeU??"repeat",C=g.addressModeV??"repeat",o=g.invertY??!0,r=g.srgb??!1,B=g.premultiplyAlpha??!1,n=r?"rgba8unorm-srgb":"rgba8unorm",Q=await(await fetch(e)).blob(),E=await createImageBitmap(Q,{premultiplyAlpha:B?"premultiply":"none",colorSpaceConversion:"none"}),a=E.width,c=E.height,l=I?Math.floor(Math.log2(Math.max(a,c)))+1:1,p=A._device.createTexture({size:{width:a,height:c},format:n,mipLevelCount:l,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});if(A._device.queue.copyExternalImageToTexture({source:E,flipY:o},{texture:p,premultipliedAlpha:B},{width:a,height:c}),E.close(),I&&l>1){const{generateMipmaps:y}=await Promise.resolve().then(()=>(Ri(),Yr));y(A,p)}const D=g.minFilter??"linear",u=g.magFilter??"linear",_=I?"linear":"nearest",d=go(A,{addressModeU:i,addressModeV:C,minFilter:D,magFilter:u,mipmapFilter:_,maxAnisotropy:D==="linear"&&u==="linear"&&_==="linear"?4:1});return{texture:p,view:p.createView(),sampler:d,width:a,height:c}}var U3,GY=b((()=>{ZA(),te(),Gm(),Gt(),SY(),F1(),U3=null})),r4A=H({runDeviceLostRecovery:()=>B4A});function YZ(){return Promise.resolve().then(()=>(WKA(),OKA))}async function B4A(A,e,g){const I=new Map;for(const Q of g)I.set(Q._kind,Q);const i=A._renderFn!==null;u3(A),s4A(A,I),uZ(A);const C=await Jr("requesting a replacement adapter",()=>navigator.gpu.requestAdapter({powerPreference:"high-performance",...rZ()}));C||R(47);const o=e._requiredFeatures.filter(Q=>!C.features.has(Q));o.length&&R(48,o.join(", "));const r=A._storageBuffers?.size?await YZ():void 0;A._device=await Jr("requesting a replacement device",()=>C.requestDevice({requiredFeatures:e._requiredFeatures,requiredLimits:{...A._options?.requiredLimits,...r?.getCpuStorageRecoveryLimits(A)}})),A._attachGpuEvents?.(A),await Jr("rebuilding engine storage buffers",async()=>{(r??(A._storageBuffers?.size?await YZ():void 0))?.rebuildCpuStorageBuffers(A)}),await Jr("reconfiguring rendering surfaces",()=>{for(const Q of A.surfaces){const E=Q._swapchainCopySrc?RA.RENDER_ATTACHMENT|RA.COPY_SRC:RA.RENDER_ATTACHMENT;Q._context.configure({device:A._device,format:Q._configureFormat,alphaMode:Q._alphaMode,usage:E,viewFormats:[Q.format]}),l3(Q)}}),await Jr("resizing rendering surfaces",()=>uY(A));const B=await n4A(A,e),n=Array.from(I.values()).sort((Q,E)=>(Q._recoverOrder??0)-(E._recoverOrder??0));try{for(const Q of n)await Jr(`running "${Q._kind}" recovery`,()=>Q._recover(A))}finally{B?.()}i&&await Jr("restarting rendering",()=>Rm(A))}async function n4A(A,e){const g=e._textures,I=[];for(const o of g){const r=o.deref();r?I.push(r):g.delete(o)}if(I.length===0)return;const{rebuildTexture2D:i,settleRebuiltTextureOwnership:C}=await Promise.resolve().then(()=>(GY(),NY));try{await Jr("rebuilding recoverable textures",async()=>{const o=(await Promise.allSettled(I.map(r=>i(A,r)))).find(r=>r.status==="rejected");if(o)throw o.reason})}catch(o){throw C(e),o}return()=>C(e)}function s4A(A,e){const g=new Set;for(const I of A.surfaces)for(const i of I._renderingContexts)e.has(i._kind)||g.add(i._kind);if(g.size)throw new Error(`Device-lost recovery cannot rebuild registered rendering contexts of kind: ${Array.from(g).sort().join(", ")}. Recovering around them would leave them bound to the lost device and crash the browser's renderer process on the next frame. Enable that kind's device-lost recovery before the device is lost, or unregister the context.`)}async function Jr(A,e){try{return await e()}catch(g){const I=g instanceof Error?g.message:String(g);throw new Error(`Device-lost recovery failed while ${A}: ${I}`,{cause:g})}}var Q4A=b((()=>{rA(),lt(),kI(),te(),zs()}));function E4A(A){return A._deviceLostRecovery??={_forceNextLoss:!1,_requiredFeatures:[],_armedDevice:null,_registrations:[],_samplerDescriptors:new WeakMap,_captureRefs:0,_meshCaptureRefs:0,_textures:new Set,_texturesPruneAt:64}}function v3(A,e){const g=E4A(A),I=g._registrations;I.length===0&&(g._requiredFeatures=Array.from(A._device.features)),I.some(C=>C._kind===e._kind)||e._enable?.(A),I.push(e),JZ(A,g);let i=!1;return{disable(){if(i)return;i=!0;const C=I.indexOf(e);C>=0&&I.splice(C,1),I.some(o=>o._kind===e._kind)||e._disable?.(A)}}}function a4A(A){const e=A._deviceLostRecovery;return!!e?._registrations.length&&(e._forceNextLoss=!0)}function JZ(A,e){const g=A._device;e._armedDevice===g||e._recovering||(e._armedDevice=g,g.lost.then(I=>{if(e._registrations.length===0||e._armedDevice!==g||I.reason==="destroyed"&&!e._forceNextLoss)return;e._forceNextLoss=!1,e._recovering=!0;const i=[...e._registrations];for(const C of i)C._onLost?.(I);Promise.resolve().then(()=>(Q4A(),r4A)).then(({runDeviceLostRecovery:C})=>C(A,e,i)).then(()=>{e._recovering=!1,JZ(A,e);for(const C of i)C._onRecovered?.()},C=>{e._recovering=!1;for(const o of i)o._onRecoveryFailed?.(C)})}))}rA();function c4A(A){a4A(A)||R(49),A._device.destroy()}function L3(A,e){const g={...A,...e};return mY?.(A,g),FY?.(A,g),g}function l4A(A){mY=A}function p4A(A){FY=A}function AQ(A,e,g={}){const I=A._device;bm||(bm=new WeakMap);let i=bm.get(I);i||(i=new Map,bm.set(I,i));const C=`${e}\0${g.mipMaps??!0}\0${g.addressModeU??"repeat"}\0${g.addressModeV??"repeat"}\0${g.minFilter??"linear"}\0${g.magFilter??"linear"}\0${g.invertY??!0}\0${g.srgb??!1}\0${g.premultiplyAlpha??!1}`,o=i.get(C);if(o)return o;const r=i,B=D4A(A,e,g);return r.set(C,B),B.catch(()=>r.delete(C)),B}async function D4A(A,e,g){const I=A._device,i=g.mipMaps??!0,C=g.addressModeU??"repeat",o=g.addressModeV??"repeat",r=g.invertY??!0,B=g.srgb??!1,n=g.premultiplyAlpha??!1,Q=B?"rgba8unorm-srgb":"rgba8unorm",E=await(await fetch(e)).blob(),a=await createImageBitmap(E,{premultiplyAlpha:n?"premultiply":"none",colorSpaceConversion:"none"}),c=a.width,l=a.height,p=i?Math.floor(Math.log2(Math.max(c,l)))+1:1,D=I.createTexture({size:{width:c,height:l},format:Q,mipLevelCount:p,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});if(I.queue.copyExternalImageToTexture({source:a,flipY:r},{texture:D,premultipliedAlpha:n},{width:c,height:l}),a.close(),i&&p>1){const{generateMipmaps:w}=await Promise.resolve().then(()=>(Ri(),Yr));w(A,D)}const u=g.minFilter??"linear",_=g.magFilter??"linear",d=i?"linear":"nearest",y=I1(A,{addressModeU:C,addressModeV:o,minFilter:u,magFilter:_,mipmapFilter:d,maxAnisotropy:u==="linear"&&_==="linear"&&d==="linear"?4:1}),h={texture:D,view:D.createView(),sampler:y,width:c,height:l};return A._dlr?.u(h,e,g),LI(h),h}var mY,FY,bm,MC=b((()=>{te(),Gt(),m1(),mY=null,FY=null,bm=null}));function u4A(A){bY=A}function HZ(A,e){const g=G3(),I=(g.get(A)??1)-1;return I<=0?(A.destroy(),e&&bY?.(e),g.set(A,0),!0):(g.set(A,I),!1)}var bY,Y3=b((()=>{RY(),bY=null}));rA(),MC(),Y3();var _4A=64,xZ=null;function TZ(A,e,g){e._recoverySource=g;const I=A._textures;if(I.size>=A._texturesPruneAt){for(const i of I)i.deref()||I.delete(i);A._texturesPruneAt=Math.max(_4A,I.size*2)}I.add(new WeakRef(e))}function qZ(A,e){const g=A._recoverySource;if(!g)return;const I=xZ?.get(g)?.deref();I&&TZ(I,e,g)}function d4A(A){const e=A._recoverySource;e?.kind==="external"&&(e.bitmap?.close(),e.bitmap=null)}function f4A(A){const e=A._deviceLostRecovery,g=new WeakRef(e),I=(i,C)=>{(xZ??=new WeakMap).set(C,g),TZ(e,i,C)};p4A(qZ),u4A(d4A),A._dlr={t:I,async x(i,C,o,r,B,n,Q,E,a){const c=await createImageBitmap(i,{premultiplyAlpha:E?"premultiply":"none",colorSpaceConversion:"none"});try{const l=await a(c);return I(l,{kind:"external",bitmap:c,width:C,height:o,format:r,levels:B,samplerDesc:n,flipY:Q,premultipliedAlpha:E}),l}catch(l){throw c.close(),l}},d:qZ,u(i,C,o){I(i,{kind:"url",url:C,opts:{...o}})},s(i,C,o,r,B){I(i,{kind:"solid",rgba:[C,o,r,B]})},b(i,C,o,r,B){I(i,{kind:"bitmap",bitmap:C,srgb:o,mipMaps:r,fallback:B})},p(i,C,o){I(i,{kind:"pixels",data:C.slice(0,i.width*i.height*4),width:i.width,height:i.height,options:{...o}})},r(i,C,o,r,B){I(i,{kind:"render",width:C,height:o,format:r,samplerDesc:B})},w(i,C,o,r,B,n,Q=0,E=B*4){const a=i._recoverySource;if(a?.kind!=="pixels")return;const c=new Uint8Array(C.buffer,C.byteOffset,C.byteLength),l=B*4;for(let p=0;p<n;p++){const D=Q+p*E,u=((r+p)*a.width+o)*4;a.data.set(c.subarray(D,D+l),u)}},m(i,C,o,r,B,n){A._deviceLostRecovery?._meshCaptureRefs&&(i._cpuUv2s=C??null,i._cpuTangents=o??null,i._cpuColors=r??null,i._cpuGpuIndices=B,i._cpuIndexFormat=n)},e(i,C,o){e._meshCaptureRefs&&(i._envRecoverySource={kind:"env",url:C,brdfUrl:o})},h(i,C,o){e._meshCaptureRefs&&(i._envRecoverySource={kind:"hdr",url:C,faceSize:o})}}}function PZ(A,e=!1){const g=A._deviceLostRecovery;g||R(46),g._captureRefs++,e&&g._meshCaptureRefs++,g._captureRefs===1&&f4A(A)}function OZ(A,e=!1){const g=A._deviceLostRecovery;!g||g._captureRefs===0||(g._captureRefs--,e&&g._meshCaptureRefs>0&&g._meshCaptureRefs--,g._captureRefs===0&&(A._dlr=void 0))}var Ei,Hr=b((()=>{Ei=class{_x;_y;_z;_onDirty;constructor(A,e,g,I){this._x=A,this._y=e,this._z=g,this._onDirty=I}get x(){return this._x}set x(A){this._x!==A&&(this._x=A,this._onDirty())}get y(){return this._y}set y(A){this._y!==A&&(this._y=A,this._onDirty())}get z(){return this._z}set z(A){this._z!==A&&(this._z=A,this._onDirty())}set(A,e,g){this._x=A,this._y=e,this._z=g,this._onDirty()}copyFrom(A){this.set(A.x,A.y,A.z)}toArray(A,e=0){A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z}}})),km,J3=b((()=>{km=class{_x;_y;_z;_w;_onDirty;_version=0;constructor(A,e,g,I,i){this._x=A,this._y=e,this._z=g,this._w=I,this._onDirty=i}get version(){return this._version}get x(){return this._x}set x(A){this._x!==A&&(this._x=A,this._version++,this._onDirty())}get y(){return this._y}set y(A){this._y!==A&&(this._y=A,this._version++,this._onDirty())}get z(){return this._z}set z(A){this._z!==A&&(this._z=A,this._version++,this._onDirty())}get w(){return this._w}set w(A){this._w!==A&&(this._w=A,this._version++,this._onDirty())}set(A,e,g,I){this._x=A,this._y=e,this._z=g,this._w=I,this._version++,this._onDirty()}copyFrom(A){this.set(A.x,A.y,A.z,A.w)}toArray(A,e=0){A[e]=this._x,A[e+1]=this._y,A[e+2]=this._z,A[e+3]=this._w}}}));function RC(A,e,g,I,i,C,o,r,B,n,Q,E){const a=C*C,c=o*o,l=r*r,p=C*o,D=C*r,u=o*r,_=B*C,d=B*o,y=B*r;A[e]=(1-2*(c+l))*n,A[e+1]=2*(p+y)*n,A[e+2]=2*(D-d)*n,A[e+3]=0,A[e+4]=2*(p-y)*Q,A[e+5]=(1-2*(a+l))*Q,A[e+6]=2*(u+_)*Q,A[e+7]=0,A[e+8]=2*(D+d)*E,A[e+9]=2*(u-_)*E,A[e+10]=(1-2*(a+c))*E,A[e+11]=0,A[e+12]=g,A[e+13]=I,A[e+14]=i,A[e+15]=1}var Io=b((()=>{}));function Km(A,e){A[KY]=e}function kY(A){return A===null?null:A[KY]??null}function Hn(A){kY(A)?._invalidate()}function y4A(A){kY(A)?.markLocalDirty()}function jZ(A,e,g){const I=QI();return VZ(I,A,e,g),I}function VZ(A,e,g,I){e.x===0&&e.y===0&&e.z===0&&g.x===0&&g.y===0&&g.z===0&&g.w===1&&I.x===1&&I.y===1&&I.z===1?(A.fill(0),A[0]=A[5]=A[10]=A[15]=1):RC(A,0,e.x,e.y,e.z,g.x,g.y,g.z,g.w,I.x,I.y,I.z)}function eQ(A){let e=0,g=-1,I=null,i=null;const C=QI();let o=null,r=null;const B=[];function n(){i=null,e++;for(const a of B)a._invalidate()}function Q(){const a=o.worldMatrixVersion;a!==g&&(g=a,n())}const E={get parent(){return o},set parent(a){a!==o&&(r!==null&&r._removeChild(E),o=a,r=kY(a),r!==null&&r._addChild(E),g=-1,n())},markLocalDirty(){I=null,n()},getWorldMatrix(){if(r===null&&o!==null&&Q(),i!==null)return i;const a=I??=A();if(o!==null){const c=o.worldMatrix;mI(C,0,c,0,a,0),i=C}else i=a;return i},getWorldMatrixVersion(){return r===null&&o!==null&&Q(),e},_invalidate:n,_addChild(a){B.push(a)},_removeChild(a){const c=B.indexOf(a);c>=0&&B.splice(c,1)}};return E}var KY,Lo=b((()=>{T1(),Ut(),Io(),KY=Symbol("wmState")}));function H3(A,e,g){const I=Math.cos(A*.5),i=Math.sin(A*.5),C=Math.cos(e*.5),o=Math.sin(e*.5),r=Math.cos(g*.5),B=Math.sin(g*.5);return[i*C*r+I*o*B,I*o*r-i*C*B,I*C*B+i*o*r,I*C*r-i*o*B]}function WZ(A,e,g,I){const i=2*(A*g+I*e),C=Math.asin(Math.max(-1,Math.min(1,i)));return[Math.atan2(-(2*(e*g-I*A)),1-2*(A*A+e*e)),C,Math.atan2(-(2*(A*e-I*g)),1-2*(e*e+g*g))]}var x3=b((()=>{}));function UY(A){let e=0,g=0,I=0,i=-1;const C=()=>{if(A.version!==i){const r=WZ(A.x,A.y,A.z,A.w);e=r[0],g=r[1],I=r[2],i=A.version}},o=(r,B,n)=>{e=r,g=B,I=n;const[Q,E,a,c]=H3(r,B,n);A.set(Q,E,a,c),i=A.version};return{get x(){return C(),e},set x(r){C(),o(r,g,I)},get y(){return C(),g},set y(r){C(),o(e,r,I)},get z(){return C(),I},set z(r){C(),o(e,g,r)},set:o}}function h4A(A,e=0,g=0,I=0,i=0,C=0,o=0,r=1,B=1,n=1,Q=1){return zZ(A,null,e,g,I,i,C,o,r,B,n,Q)}function xn(A,e,g,I,i){const C=zZ(A,e,g?.x,g?.y,g?.z,I?.x,I?.y,I?.z,I?.w,i?.x,i?.y,i?.z);return C._localMatrixLocked=g?void 0:!0,C}function zZ(A,e,g=0,I=0,i=0,C=0,o=0,r=0,B=1,n=1,Q=1,E=1){const a=T3({name:A,children:[]},g,I,i,C,o,r,B,n,Q,E);return e&&(a._localMatrix=e),a}function T3(A,e=0,g=0,I=0,i=0,C=0,o=0,r=1,B=1,n=1,Q=1){let E;const a=eQ(()=>_._localMatrix?_._localMatrix:(E??=QI(),VZ(E,l,p,u),E)),c=()=>{_._localMatrixLocked||(_._localMatrix=void 0,a.markLocalDirty())},l=new Ei(e,g,I,c),p=new km(i,C,o,r,c),D=UY(p),u=new Ei(B,n,Q,c),_={...A,position:l,rotationQuaternion:p,rotation:D,scaling:u,get parent(){return a.parent},set parent(d){a.parent=d},get worldMatrix(){return a.getWorldMatrix()},get worldMatrixVersion(){return a.getWorldMatrixVersion()}};return Km(_,a),_}var SC=b((()=>{Hr(),J3(),Lo(),x3(),Ut()}));function Tn(A,e=0,g=0,I=0,i=0,C=0,o=0,r=1,B=1,n=1){const[Q,E,a,c]=H3(i,C,o),l=T3({children:[],...A},e,g,I,Q,E,a,c,r,B,n);return Object.defineProperties(l,{worldMatrix:{enumerable:!1},worldMatrixVersion:{enumerable:!1}}),l}function q3(A,e,g,I,i,C,o,r){const B=A._device,n=dg(A,e,dA.VERTEX),Q=dg(A,g,dA.VERTEX),E=dg(A,I,dA.INDEX);let a;i&&i.length>0?a=dg(A,i,dA.VERTEX):(a=B.createBuffer({size:e.length/3*8,usage:dA.VERTEX,mappedAtCreation:!0}),a.unmap());let c=null;C&&C.length>0&&(c=dg(A,C,dA.VERTEX));const l=o&&o.length>0?dg(A,o,dA.VERTEX):null,p=r&&r.length>0?dg(A,r,dA.VERTEX):null;return{positionBuffer:n,normalBuffer:Q,uvBuffer:a,uv2Buffer:c,tangentBuffer:l,colorBuffer:p,hasUv:!!i&&i.length>0,hasUv2:!!C&&C.length>0,hasTangent:!!o&&o.length>0,hasColor:!!r&&r.length>0,indexBuffer:E,indexCount:I.length,indexFormat:"uint32"}}var xr=b((()=>{te(),yt(),SC(),x3()}));function ZZ(A,e){const g=A.indexCount;A._drawRangeSource=e,Object.defineProperty(A,"indexCount",{enumerable:!0,configurable:!0,get:()=>A._drawRangeSource?.indexCount??g})}var XZ=b((()=>{}));function Lt(A,e,g){return A._device.createBuffer({label:g,size:Sm(e,16),usage:dA.UNIFORM|dA.COPY_DST})}var b1=b((()=>{te(),Nm()}));function n1(A){const e=A._device,g=$Z??=new WeakMap;let I=g.get(e);return I||(I=e.createBindGroupLayout({label:"scene",entries:[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,buffer:{type:"uniform"}}]}),g.set(e,I)),I}function vY(A){const e=A._blend?{format:A._format,blend:A._blend}:{format:A._format};return{label:A._label,layout:A._engine._device.createPipelineLayout({bindGroupLayouts:A._bgls}),vertex:{module:A._vertModule,entryPoint:"main",buffers:A._vertexBuffers},fragment:{module:A._fragModule,entryPoint:"main",targets:[e]},depthStencil:{format:A._depthStencilFormat??"depth24plus-stencil8",depthCompare:A._depthCompare??"greater-equal",depthWriteEnabled:A._depthWriteEnabled??!0},multisample:{count:A._msaaSamples},primitive:{topology:"triangle-list",cullMode:A._cullMode??"back",frontFace:"ccw"}}}var $Z,s1=b((()=>{te(),MI(),$Z=null}));function wI(A,e,g){const I=A._device,i=Lt(A,e.byteLength,g);try{I.queue.writeBuffer(i,0,e.buffer,e.byteOffset,e.byteLength)}catch(C){throw i.destroy(),C}return i}var zI=b((()=>{b1()}));function LY(){return 16+Zg*16*4}function AX(A){let e=0;for(const g of A)e+=g._lightVersion??0;return e}function YY(A,e){A.fill(0);let g=0;const I=4;for(const i of e){if(g>=Zg)break;i._writeLightUbo&&(i._writeLightUbo(A,I+g*16),g++)}JY[0]=g,A[0]=eX[0]}function P3(A,e){let g=e._lightGpuState;const I=LY();if(g&&g._byteSize===I)return g;const i=!g;g?._buffer.destroy();const C=new oA(I/4);return YY(C,e.lights),A._applyLightFoOffset?.(C,e),g={_buffer:wI(A,C),_scratch:C,_version:AX(e.lights)+(A._lightFoVersion?.(e)??0),_listVersion:e._lightListVersion??0,_lightCount:e.lights.length,_byteSize:I},e._lightGpuState=g,i&&e._disposables.push(()=>{e._lightGpuState?._buffer.destroy(),e._lightGpuState=void 0}),g}function w4A(A,e){const g=P3(A,e),I=AX(e.lights)+(A._lightFoVersion?.(e)??0),i=e._lightListVersion??0;return(I!==g._version||i!==g._listVersion||e.lights.length!==g._lightCount)&&(g._version=I,g._listVersion=i,g._lightCount=e.lights.length,YY(g._scratch,e.lights),A._applyLightFoOffset?.(g._scratch,e),A._device.queue.writeBuffer(g._buffer,0,g._scratch)),g._buffer}function M4A(A,e,g){YY(e,g.lights),A._applyLightFoOffset?.(e,g)}var JY,eX,HY=b((()=>{ZA(),vt(),zI(),JY=new Ag(1),eX=new oA(JY.buffer)})),O3=b((()=>{}));function Si(A){return HZ(A)}var qn=b((()=>{Y3()}));function Yo(A,e){return Math.floor(Math.log2(Math.max(A,e)))+1}function R4A(A,e,g){return Math.max(1,Math.floor(Math.log2(Math.max(A,e))-g)+1)}var to=b((()=>{}));function gX(A){const e=new He(A);for(let l=0;l<8;l++)if(e[l]!==IX[l])throw new Error("Invalid .env file: bad magic");let g=8;for(;g<e.length&&e[g]!==0;)g++;const I=new TextDecoder().decode(e.subarray(8,g));g++;const i=g,C=JSON.parse(I),o=C.width,r=Yo(o,o),B=C.irradiance,n=new oA(27),Q=["x","y","z","xx","yy","zz","yz","zx","xy"];for(let l=0;l<9;l++){const p=B[Q[l]];n[l*3]=p[0],n[l*3+1]=p[1],n[l*3+2]=p[2]}const E=C.specular.mipmaps,a=C.imageType||"image/png",c=[];for(const l of E){const p=i+l.position,D=A.slice(p,p+l.length);c.push(new Blob([D],{type:a}))}return{faceBlobs:c,irradianceSH:n,width:o,mipCount:r}}var IX,tX=b((()=>{ZA(),to(),IX=new He([134,22,135,150,246,214,150,54])}));function iX(){return{minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}}function S4A(A,e,g,I){const i=g-I,C=g+I,o=e===0?"minX":e===1?"minY":"minZ",r=e===0?"maxX":e===1?"maxY":"maxZ";i<A[o]&&(A[o]=i),C>A[r]&&(A[r]=C)}function CX(A,e){const g=e.boundMin,I=e.boundMax;if(!g||!I)return;if(e._expandWorldBounds!==void 0){e._expandWorldBounds(A,e);return}const i=e.worldMatrix,C=[(g[0]+I[0])*.5,(g[1]+I[1])*.5,(g[2]+I[2])*.5],o=[(I[0]-g[0])*.5,(I[1]-g[1])*.5,(I[2]-g[2])*.5];for(let r=0;r<3;r++){let B=i[12+r],n=0;for(let Q=0;Q<3;Q++){const E=i[Q*4+r];B+=E*C[Q],n+=Math.abs(E)*o[Q]}S4A(A,r,B,n)}}var oX=b((()=>{})),rX=H({computeSceneSize:()=>BX});function BX(A,e){const g=iX();for(const u of A.meshes)CX(g,u);const I=g.minX,i=g.minY,C=g.minZ,o=g.maxX,r=g.maxY,B=g.maxZ;if(!isFinite(I))return{groundSize:15,skyboxSize:e??20,rootPosition:[0,0,0]};const n=o-I,Q=r-i,E=B-C,a=Math.sqrt(n*n+Q*Q+E*E);let c=15,l=e??20;const p=A.camera;p&&"upperRadiusLimit"in p&&p.upperRadiusLimit&&(c=p.upperRadiusLimit*2,l=c),a>c&&(c=a*2,l=c),c*=1.1,l*=1.5;const D=[I+n*.5,i-1e-5,C+E*.5];return{groundSize:c,skyboxSize:l,rootPosition:D}}var xY=b((()=>{oX()}));function N4A(A,e){const g=e.fog;g&&(A[80]=g.mode,A[81]=g.start,A[82]=g.end,A[83]=g.density,A[84]=g.color[0],A[85]=g.color[1],A[86]=g.color[2])}function G4A(A,e){const g=e.clipPlane;g&&(A[88]=g[0],A[89]=g[1],A[90]=g[2],A[91]=g[3])}function m4A(A,e){A[36]=e._environmentRotation??0;const g=e._envTextures?.sphericalHarmonics;g&&A.set(g,40)}function j3(A,e){const g=A._sceneUboContributors??=[];g.includes(e)||g.push(e)}function TY(A){for(const e of A._frameGraph._tasks)e._sceneUboCacheKey&&(e._sceneUboCacheKey.length=0)}function F4A(A,e){A.fog=e,j3(A,N4A)}function b4A(A,e){A.clipPlane=e,j3(A,G4A)}function Um(A){j3(A,m4A)}var Pn=b((()=>{})),V3=H({decodeBrdfPng:()=>k4A,uploadCubemapRGBD:()=>K4A});function nX(A,e){A!==PY&&(PY=A,OY=A.createShaderModule({code:EX}),W3=null,z3=null);const g=e?z3:W3;if(g)return g;const I=A.createComputePipeline({layout:"auto",compute:{module:OY,entryPoint:"main",constants:{[qY]:e?1:0}}});return e?z3=I:W3=I,I}function sX(A,e,g,I){return A.createBindGroup({layout:e.getBindGroupLayout(0),entries:[{binding:0,resource:g},{binding:1,resource:I}]})}function QX(A,e,g,I,i){const C=A.beginComputePass();C.setPipeline(e),C.setBindGroup(0,g),C.dispatchWorkgroups(Math.ceil(I/8),Math.ceil(i/8)),C.end()}function k4A(A,e){const g=A._device,I=nX(g,!1),i=e.width,C=e.height,o=g.createTexture({size:{width:i,height:C},format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});g.queue.copyExternalImageToTexture({source:e,flipY:!1},{texture:o,premultipliedAlpha:!1},{width:i,height:C});const r=g.createTexture({size:{width:i,height:C},format:"rgba16float",usage:RA.TEXTURE_BINDING|RA.STORAGE_BINDING}),B=sX(g,I,o.createView(),r.createView()),n=g.createCommandEncoder();return QX(n,I,B,i,C),g.queue.submit([n.finish()]),o.destroy(),r}function K4A(A,e,g,I){const i=A._device,C=nX(i,!0),o=i.createTexture({size:{width:g,height:g,depthOrArrayLayers:6},format:"rgba16float",mipLevelCount:I,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.COPY_SRC|RA.RENDER_ATTACHMENT,dimension:"2d"});for(let r=0;r<I;r++){const B=Math.max(1,g>>r),n=i.createTexture({size:{width:B,height:B},format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT}),Q=i.createTexture({size:{width:B,height:B},format:"rgba16float",usage:RA.STORAGE_BINDING|RA.COPY_SRC}),E=sX(i,C,n.createView(),Q.createView());for(let a=0;a<6;a++){const c=r*6+a;if(c>=e.length)break;i.queue.copyExternalImageToTexture({source:e[c],flipY:!1},{texture:n,premultipliedAlpha:!1},{width:B,height:B});const l=i.createCommandEncoder();QX(l,C,E,B,B),l.copyTextureToTexture({texture:Q},{texture:o,origin:{x:0,y:0,z:a},mipLevel:r},{width:B,height:B}),i.queue.submit([l.finish()])}n.destroy(),Q.destroy()}return o}var qY,EX,PY,OY,W3,z3,Z3=b((()=>{te(),qY=0,EX=`@id(${qY})override f:bool=false;@group(0)@binding(0)var t:texture_2d<f32>;@group(0)@binding(1)var o:texture_storage_2d<rgba16float,write>;@compute@workgroup_size(8,8)fn main(@builtin(global_invocation_id)g:vec3u){let d=textureDimensions(t);if(any(g.xy>=d)){return;}let c=textureLoad(t,vec2u(g.x,select(g.y,d.y-1u-g.y,f)),0);textureStore(o,g.xy,vec4f(pow(c.rgb,vec3f(2.2))/max(c.a,1.0/255.0),1));}`,PY=null,OY=null,W3=null,z3=null})),jY,aX=b((()=>{jY="struct e{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:e;struct d{@builtin(position) clipPos:vec4<f32>,@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@vertex fn main(@location(0) b:vec3<f32>)->d{var a:d;a.positionUVW=b;let c=(mesh.world*vec4<f32>(b,0.0)).xyz+scene.vEyePosition.xyz;a.positionW=c;a.clipPos=scene.viewProjection*vec4<f32>(c,1.0);return a;}"})),cX,U4A=b((()=>{cX="struct c{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32}@group(1) @binding(0) var<uniform> mesh:c;struct d{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:d)->@location(0) vec4<f32>{var a=vec4<f32>(mesh.skyOutputColor,1.0);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.positionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}"}));function Q1(A){return`${A._colorFormat??"-"}|${A._depthStencilFormat??"-"}|${A._depthCompare??""}|${A._sampleCount}`}var E1=b((()=>{})),lX,X3,VY,$3=b((()=>{lX="fn perturbNormal(vNormalW:vec3<f32>,positionW:vec3<f32>,uv:vec2<f32>,bumpScale:f32)->vec3<f32>{let normalSample=textureSample(bT,bS,uv).rgb*2.0-1.0;let N=normalize(vNormalW)*bumpScale;let dp1=dpdx(positionW);let dp2=-dpdy(positionW);let duv1=dpdx(uv);let duv2=-dpdy(uv);let dp2perp=cross(dp2,N);let dp1perp=cross(N,dp1);var tangent=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent=dp2perp*duv1.y+dp1perp*duv2.y;let det=max(dot(tangent,tangent),dot(bitangent,bitangent));let invmax=select(inverseSqrt(det),0.0,det==0.0);let cotangentFrame=mat3x3<f32>(tangent*invmax,bitangent*invmax,N);return normalize(cotangentFrame*normalSample);}",X3="fn dither(seed:vec2<f32>,varianceAmount:f32)->f32{let rand=fract(sin(dot(seed,vec2<f32>(12.9898,78.233)))*43758.5453);let normVariance=varianceAmount/255.0;return mix(-normVariance,normVariance,rand);}",VY="fn dither(a:vec2<f32>,b:f32)->f32{return 0.0;}"})),pX,v4A=b((()=>{pX="struct a{viewProjection:mat4x4<f32>,view:mat4x4<f32>,vEyePosition:vec4<f32>,envRotationY:f32,_envPad0:f32,_envPad1:f32,_envPad2:f32,vSphericalL00:vec4<f32>,vSphericalL1_1:vec4<f32>,vSphericalL10:vec4<f32>,vSphericalL11:vec4<f32>,vSphericalL2_2:vec4<f32>,vSphericalL2_1:vec4<f32>,vSphericalL20:vec4<f32>,vSphericalL21:vec4<f32>,vSphericalL22:vec4<f32>,vImageInfos:vec4<f32>,vFogInfos:vec4<f32>,vFogColor:vec4<f32>,clipPlane:vec4<f32>}@group(0) @binding(0) var<uniform> scene:a;"})),q1,tC=b((()=>{v4A(),O3(),q1=pX}));function vm(A,e,g){return A._device.createBindGroupLayout({label:e,entries:[{binding:0,visibility:g,buffer:{type:"uniform"}}]})}var Lm=b((()=>{})),DX=H({buildSolidSkyboxRenderable:()=>uX});function L4A(A,e){const g=new oA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),I=new ni([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return{posBuffer:dg(A,g,dA.VERTEX),idxBuffer:dg(A,I,dA.INDEX)}}function Y4A(){function A(e){const g=e._device;return gQ&&eK===g||(gQ=vm(e,"skybox-material",MA.VERTEX|MA.FRAGMENT)),gQ}return{getPipeline(e,g){const I=e._device;eK!==I&&(AK.clear(),gQ=null,eK=I);const i=Q1(g),C=AK.get(i);if(C)return C;const o=I.createShaderModule({code:q1+jY,label:"skybox-vert"}),r=I.createShaderModule({code:X3+cX,label:"skybox-frag"}),B=I.createRenderPipeline(vY({_label:"skybox-pipeline",_engine:e,_bgls:[n1(e),A(e)],_vertModule:o,_fragModule:r,_vertexBuffers:dX,_format:g._colorFormat,_depthStencilFormat:g._depthStencilFormat,_depthCompare:g._depthCompare,_msaaSamples:g._sampleCount,_depthWriteEnabled:!1}));return AK.set(i,B),B},createBindGroup(e,g,I){return e._device.createBindGroup({layout:A(e),entries:[{binding:0,resource:{buffer:g}}]})}}}function uX(A,e,g,I,i){const C=A.surface.engine,o=A.clearColor,r=L4A(C,g),B=Y4A(),n=J4A(C,I,i,[o.r,o.g,o.b]),Q=B.createBindGroup(C,n,e),E={order:0,isTransparent:!1,bind(a,c){return{renderable:E,pipeline:B.getPipeline(a,c),draw(l){return l.setBindGroup(1,Q),l.setVertexBuffer(0,r.posBuffer),l.setIndexBuffer(r.idxBuffer,"uint16"),l.drawIndexed(36),1}}}};return E._rebuild=()=>uX(A,e,g,I,i),E}function J4A(A,e,g,I){const i=new oA(_X/4);return i[0]=i[5]=i[10]=i[15]=1,i[12]=e[0],i[13]=e[1],i[14]=e[2],i[16]=g[0],i[17]=g[1],i[18]=g[2],i[20]=I[0],i[21]=I[1],i[22]=I[2],wI(A,i)}var _X,dX,AK,gQ,eK,fX=b((()=>{ZA(),te(),aX(),U4A(),s1(),E1(),$3(),tC(),yt(),zI(),Lm(),_X=96,dX=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],AK=new Map,gQ=null,eK=null})),yX,H4A=b((()=>{yX="struct g{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:g;struct h{@location(0) position:vec3<f32>,@location(1) normal:vec3<f32>,@location(2) uv:vec2<f32>}struct e{@builtin(position) clipPos:vec4<f32>,@location(0) vPositionW:vec3<f32>,@location(1) vNormalW:vec3<f32>,@location(2) vUV:vec2<f32>}@vertex fn main(c:h)->e{var a:e;let b=mesh.world;let d=b*vec4<f32>(c.position,1.0);a.vPositionW=d.xyz;a.clipPos=scene.viewProjection*d;let f=mat3x3<f32>(b[0].xyz,b[1].xyz,b[2].xyz);a.vNormalW=normalize(f*c.normal);a.vUV=c.uv;return a;}"})),hX,x4A=b((()=>{hX="struct o{world:mat4x4<f32>,primaryColor:vec3<f32>,alpha:f32,backgroundCenter:vec3<f32>,_pad:f32}@group(1) @binding(0) var<uniform> mesh:o;@group(1) @binding(1) var n:texture_2d<f32>;@group(1) @binding(2) var m:sampler;struct p{@location(0) vPositionW:vec3<f32>,@location(1) vNormalW:vec3<f32>,@location(2) vUV:vec2<f32>}@fragment fn main(b:p)->@location(0) vec4<f32>{let g=normalize(b.vNormalW);let c=textureSample(n,m,b.vUV);let h=c.rgb;let f=max(h,vec3<f32>(0.0));let i=mesh.primaryColor;let j=f*i;var e=mesh.alpha*c.a;let k=dot(g,normalize(scene.vEyePosition.xyz-mesh.backgroundCenter));const l:f32=0.1;let d=clamp(k/l,0.0,1.0);e*=d*d;var a=vec4<f32>(j,e);if (scene.vImageInfos.w>=0.0){a=applyImageProcessing(a);}a=vec4<f32>(a.rgb*a.a,a.a);a=vec4<f32>(a.rgb+vec3<f32>(dither(b.vPositionW.xy,0.5)),a.a);a=max(a,vec4<f32>(0.0));return a;}"})),wX=H({buildGroundRenderable:()=>MX});async function MX(A,e,g,I,i,C,o=!0){const r=T4A(o,q1+RX+(o?X3:VY)+hX),B=q4A(A,e),n=P4A(A,g,I),Q=(await O4A(A,i,C)).createView(),E=Qi(A),a=r.createBindGroup(A,n,Q,E),c={order:200,isTransparent:!0,bind(l,p){return{renderable:c,pipeline:r.getPipeline(l,p),draw(D){return D.setBindGroup(1,a),D.setVertexBuffer(0,B.posBuffer),D.setVertexBuffer(1,B.normBuffer),D.setVertexBuffer(2,B.uvBuffer),D.setIndexBuffer(B.idxBuffer,"uint16"),D.drawIndexed(6),1}}}};return c._rebuild=()=>MX(A,e,g,I,i,void 0,o),c}function T4A(A,e){function g(I){const i=I._device;return IQ&&Ym===i||(IQ=i.createBindGroupLayout({label:"ground-material",entries:[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d"}},{binding:2,visibility:MA.FRAGMENT,sampler:{type:"filtering"}}]}),Ym=i),IQ}return{getPipeline(I,i){const C=I._device;Ym!==C&&(gK.clear(),IQ=null,Ym=C);const o=`${+A}|${Q1(i)}`,r=gK.get(o);if(r)return r;const B=C.createShaderModule({code:q1+yX,label:"ground-vert"}),n=C.createShaderModule({code:e,label:"ground-frag"}),Q=C.createRenderPipeline({label:"ground-pipeline",layout:C.createPipelineLayout({bindGroupLayouts:[n1(I),g(I)]}),vertex:{module:B,entryPoint:"main",buffers:[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]},{arrayStride:12,attributes:[{shaderLocation:1,offset:0,format:"float32x3"}]},{arrayStride:8,attributes:[{shaderLocation:2,offset:0,format:"float32x2"}]}]},fragment:{module:n,entryPoint:"main",targets:[{format:i._colorFormat,blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},depthStencil:{format:i._depthStencilFormat??"depth24plus-stencil8",depthCompare:i._depthCompare??"greater-equal",depthWriteEnabled:!1},multisample:{count:i._sampleCount},primitive:{topology:"triangle-list",cullMode:"back",frontFace:"ccw"}});return gK.set(o,Q),Q},createBindGroup(I,i,C,o){return I._device.createBindGroup({layout:g(I),entries:[{binding:0,resource:{buffer:i}},{binding:1,resource:C},{binding:2,resource:o}]})}}}function q4A(A,e){const g=e/2,I=new oA([-g,-g,0,g,-g,0,g,g,0,-g,g,0]),i=new oA([0,0,1,0,0,1,0,0,1,0,0,1]),C=new oA([0,0,1,0,1,1,0,1]),o=new ni([0,2,1,0,3,2]);return{posBuffer:dg(A,I,dA.VERTEX),normBuffer:dg(A,i,dA.VERTEX),uvBuffer:dg(A,C,dA.VERTEX),idxBuffer:dg(A,o,dA.INDEX)}}function P4A(A,e,g){const I=new oA(SX/4),i=2220446049250313e-31;return I[0]=I[15]=1,I[5]=I[10]=i,I[6]=-1,I[9]=1,I[12]=e[0],I[13]=e[1],I[14]=e[2],I[16]=g[0],I[17]=g[1],I[18]=g[2],I[19]=.9,I[20]=0,I[21]=0,I[22]=0,wI(A,I)}async function O4A(A,e,g){const I=A._device;if(!e){const o=I.createTexture({size:[1,1],format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST});return I.queue.writeTexture({texture:o},new He([255,255,255,255]),{bytesPerRow:4},[1,1]),o}const i=g?await g:await fetch(e).then(o=>o.blob()).then(o=>createImageBitmap(o,{premultiplyAlpha:"none"})),C=I.createTexture({size:[i.width,i.height],format:"rgba8unorm",usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});return I.queue.copyExternalImageToTexture({source:i},{texture:C},[i.width,i.height]),i.close(),C}var RX,SX,gK,IQ,Ym,NX=b((()=>{ZA(),te(),F1(),zI(),s1(),E1(),H4A(),x4A(),yt(),tC(),$3(),RX="fn applyImageProcessing(result:vec4<f32>)->vec4<f32>{var rgb=result.rgb;rgb*=scene.vImageInfos.x;const tonemappingCalibration:f32=1.590579;rgb=1.0-exp2(-tonemappingCalibration*rgb);rgb=pow(rgb,vec3<f32>(1.0/2.2));rgb=clamp(rgb,vec3<f32>(0.0),vec3<f32>(1.0));let highContrast=rgb*rgb*(3.0-2.0*rgb);if(scene.vImageInfos.y<1.0){rgb=mix(vec3<f32>(0.5),rgb,scene.vImageInfos.y);}else{rgb=mix(rgb,highContrast,scene.vImageInfos.y-1.0);}rgb=max(rgb,vec3<f32>(0.0));return vec4<f32>(rgb,result.a);}",SX=96,gK=new Map,IQ=null,Ym=null}));function GX(A,e,g){function I(i){const C=i._device;xm!==C&&(Jm.clear(),Hm.clear(),xm=C);const o=Hm.get(A);if(o)return o;const r=C.createBindGroupLayout({label:`${A}-material`,entries:[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube"}},{binding:2,visibility:MA.FRAGMENT,sampler:{type:"filtering"}}]});return Hm.set(A,r),r}return{getPipeline(i,C){const o=i._device;xm!==o&&(Jm.clear(),Hm.clear(),xm=o);const r=`${g}|${Q1(C)}`,B=Jm.get(r);if(B)return B;const n=o.createShaderModule({code:e,label:`${A}-vert`}),Q=o.createShaderModule({code:g,label:`${A}-frag`}),E=o.createRenderPipeline(vY({_label:`${A}-pipeline`,_engine:i,_bgls:[n1(i),I(i)],_vertModule:n,_fragModule:Q,_vertexBuffers:mX,_format:C._colorFormat,_depthStencilFormat:C._depthStencilFormat,_depthCompare:C._depthCompare,_msaaSamples:C._sampleCount,_depthWriteEnabled:!1}));return Jm.set(r,E),E},createBindGroup(i,C,o,r){return i._device.createBindGroup({layout:I(i),entries:[{binding:0,resource:{buffer:C}},{binding:1,resource:o},{binding:2,resource:r}]})}}}var mX,Jm,Hm,xm,FX=b((()=>{te(),s1(),E1(),mX=[{arrayStride:12,attributes:[{shaderLocation:0,offset:0,format:"float32x3"}]}],Jm=new Map,Hm=new Map,xm=null})),bX,j4A=b((()=>{bX="struct e{world:mat4x4<f32>}@group(1) @binding(0) var<uniform> mesh:e;struct d{@builtin(position) clipPos:vec4<f32>,@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@vertex fn main(@location(0) b:vec3<f32>)->d{var a:d;a.positionUVW=b;let c=(mesh.world*vec4<f32>(b,1.0)).xyz;a.positionW=c;a.clipPos=scene.viewProjection*vec4<f32>(c,1.0);return a;}"})),V4A=b((()=>{})),W4A=H({buildDdsSkyboxRenderable:()=>WY});function z4A(A,e){const g=new oA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),I=new ni([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return[dg(A,g,dA.VERTEX),dg(A,I,dA.INDEX)]}async function WY(A,e,g,I,i,C=!0){const o=A.surface.engine,[r,B]=z4A(o,e),{cubeView:n,sampler:Q}=await X4A(o,i??KX),E=await A._environmentSkyboxShaderComposer?.("struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,exposureLinear:f32,contrast:f32,_pad1:f32,_pad2:f32,_pad3:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var c:texture_cube<f32>;@group(1) @binding(2) var d:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:h)->@location(0) vec4<f32>{var e=normalize(b.positionUVW);var a=textureSampleLevel(c,d,e,0.0).rgb;a*=mesh.primaryColor;if (scene.vImageInfos.w>=0.0){a*=mesh.exposureLinear;a=1.0-exp2(-1.590579*a);a=pow(a,vec3<f32>(1.0/2.2));a=saturate(a);let f=a*a*(3.0-2.0*a);a=mix(a,f,mesh.contrast-1.0);a=a+vec3<f32>(dither(b.positionW.xy,0.5));a=max(a,vec3<f32>(0.0));}return vec4<f32>(a,1.0);}","dds")??"struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,exposureLinear:f32,contrast:f32,_pad1:f32,_pad2:f32,_pad3:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var c:texture_cube<f32>;@group(1) @binding(2) var d:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(b:h)->@location(0) vec4<f32>{var e=normalize(b.positionUVW);var a=textureSampleLevel(c,d,e,0.0).rgb;a*=mesh.primaryColor;if (scene.vImageInfos.w>=0.0){a*=mesh.exposureLinear;a=1.0-exp2(-1.590579*a);a=pow(a,vec3<f32>(1.0/2.2));a=saturate(a);let f=a*a*(3.0-2.0*a);a=mix(a,f,mesh.contrast-1.0);a=a+vec3<f32>(dither(b.positionW.xy,0.5));a=max(a,vec3<f32>(0.0));}return vec4<f32>(a,1.0);}",a=q1+(C?X3:VY)+E,c=GX(C?"skybox-dds":"skybox-dds0",q1+bX,a),l=Z4A(o,g,I,A.imageProcessing.exposure,A.imageProcessing.contrast),p=c.createBindGroup(o,l,n,Q),D={order:0,isTransparent:!1,bind(u,_){return{renderable:D,pipeline:c.getPipeline(u,_),draw(d){return d.setBindGroup(1,p),d.setVertexBuffer(0,r),d.setIndexBuffer(B,"uint16"),d.drawIndexed(36),1}}}};return D._rebuild=()=>WY(A,e,g,I,i,C),D}function Z4A(A,e,g,I,i){const C=new oA(kX/4);return C[0]=C[5]=C[10]=C[15]=1,C[12]=e[0],C[13]=e[1],C[14]=e[2],C[16]=g[0],C[17]=g[1],C[18]=g[2],C[19]=I,C[20]=i,wI(A,C)}async function X4A(A,e){const g=A._device,I=await(await fetch(e)).arrayBuffer(),i=new $1(I,0,32),C=i[3],o=Math.max(i[7],1),r=i[21]===808540228?148:128,B=new He(I,r),n=g.createTexture({size:[C,C,6],format:"rgba16float",mipLevelCount:o,usage:RA.TEXTURE_BINDING|RA.COPY_DST|RA.RENDER_ATTACHMENT});let Q=0;for(let E=0;E<6;E++)for(let a=0;a<o;a++){const c=Math.max(C>>a,1);g.queue.writeTexture({texture:n,origin:{x:0,y:0,z:E},mipLevel:a},B.buffer,{offset:B.byteOffset+Q,bytesPerRow:c*8},{width:c,height:c}),Q+=c*c*8}return{cubeView:n.createView({dimension:"cube"}),sampler:I1(A,{magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",maxAnisotropy:4})}}var kX,KX,UX=b((()=>{ZA(),te(),m1(),yt(),zI(),$3(),tC(),FX(),j4A(),V4A(),kX=96,KX="https://assets.babylonjs.com/core/environments/backgroundSkybox.dds"})),$4A=b((()=>{})),vX=H({buildHdrSkyboxRenderable:()=>LX});function A9A(A,e){const g=new oA([-e,-e,-e,e,-e,-e,-e,e,-e,e,e,-e,-e,-e,e,e,-e,e,-e,e,e,e,e,e]),I=new ni([6,4,5,7,6,5,0,2,3,1,0,3,5,1,3,7,5,3,0,4,6,2,0,6,3,2,6,7,3,6,0,1,5,4,0,5]);return[dg(A,g,dA.VERTEX),dg(A,I,dA.INDEX)]}async function LX(A,e,g,I,i){const C=A.surface.engine,[o,r]=A9A(C,g),B=await A._environmentSkyboxShaderComposer?.("struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32,exposureLinear:f32,contrast:f32,_pad3:f32,_pad4:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var b:texture_cube<f32>;@group(1) @binding(2) var c:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(d:h)->@location(0) vec4<f32>{var e=normalize(d.positionUVW);var a=textureSampleLevel(b,c,e,0.0).rgb;a*=mesh.exposureLinear;a=pow(a,vec3<f32>(1.0/2.2));a=clamp(a,vec3<f32>(0.0),vec3<f32>(1.0));let f=a*a*(3.0-2.0*a);if (mesh.contrast<1.0){a=mix(vec3<f32>(0.5),a,mesh.contrast);} else{a=mix(a,f,mesh.contrast-1.0);}a=max(a,vec3<f32>(0.0));return vec4<f32>(a,1.0);}","hdr")??"struct g{world:mat4x4<f32>,primaryColor:vec3<f32>,_pad:f32,skyOutputColor:vec3<f32>,_pad2:f32,exposureLinear:f32,contrast:f32,_pad3:f32,_pad4:f32}@group(1) @binding(0) var<uniform> mesh:g;@group(1) @binding(1) var b:texture_cube<f32>;@group(1) @binding(2) var c:sampler;struct h{@location(0) positionUVW:vec3<f32>,@location(1) positionW:vec3<f32>}@fragment fn main(d:h)->@location(0) vec4<f32>{var e=normalize(d.positionUVW);var a=textureSampleLevel(b,c,e,0.0).rgb;a*=mesh.exposureLinear;a=pow(a,vec3<f32>(1.0/2.2));a=clamp(a,vec3<f32>(0.0),vec3<f32>(1.0));let f=a*a*(3.0-2.0*a);if (mesh.contrast<1.0){a=mix(vec3<f32>(0.5),a,mesh.contrast);} else{a=mix(a,f,mesh.contrast-1.0);}a=max(a,vec3<f32>(0.0));return vec4<f32>(a,1.0);}",n=GX("skybox-hdr",q1+jY,B),Q=e9A(C,I,i,A.clearColor,A.imageProcessing.exposure,A.imageProcessing.contrast),E=n.createBindGroup(C,Q,e.specularCubeView,e.cubeSampler),a={order:0,isTransparent:!1,bind(c,l){return{renderable:a,pipeline:n.getPipeline(c,l),draw(p){return p.setBindGroup(1,E),p.setVertexBuffer(0,o),p.setIndexBuffer(r,"uint16"),p.drawIndexed(36),1}}}};return a._rebuild=()=>LX(A,e,g,I,i),a}function e9A(A,e,g,I,i,C){const o=new oA(YX/4);return o[0]=o[5]=o[10]=o[15]=1,o[12]=e[0],o[13]=e[1],o[14]=e[2],o[16]=g[0],o[17]=g[1],o[18]=g[2],o[20]=I.r,o[21]=I.g,o[22]=I.b,o[24]=i,o[25]=C,wI(A,o)}var YX,JX=b((()=>{ZA(),te(),FX(),aX(),$4A(),tC(),yt(),zI(),YX=112}));async function g9A(A,e,g){const I=A.surface.engine,i=fetch(e).then(w=>w.arrayBuffer()),C=IK(g.brdfUrl),{faceBlobs:o,irradianceSH:r,width:B,mipCount:n}=gX(await i),Q=await Promise.all(o.map(w=>createImageBitmap(w,{premultiplyAlpha:"none",colorSpaceConversion:"none"}))),E=await Promise.resolve().then(()=>(Z3(),V3)),a=E.uploadCubemapRGBD(I,Q,B,n);for(const w of Q)w.close();const c=await C,l=E.decodeBrdfPng(I,c);c.close();const p=tQ(a,l,r,.8,I);A._envTextures=p,Um(A),Mi(a),Mi(l),A._disposables.push(()=>{Si(a),Si(l)}),A.imageProcessing.toneMappingEnabled=!0,A.imageProcessing.exposure=.8,A.imageProcessing.contrast=1.2;const D=g?.groundTextureUrl,u=D?fetch(D).then(w=>w.blob()).then(w=>createImageBitmap(w,{premultiplyAlpha:"none"})):void 0,_=g?.skyboxUrl,d=_!=null&&_.toLowerCase().endsWith(".dds"),y=_!=null&&(_===e||_.toLowerCase().endsWith(".env")),h={skipSkybox:d||y||g?.skipSkybox,skipGround:g?.skipGround};return I._dlr?.e(A,e,g.brdfUrl),A._deferredBuilders.push(async()=>{const w=A.environmentPrimaryColor??[.08697355964132344,.08697355964132344,.2122208331110881],{groundSize:M,skyboxSize:N,rootPosition:S}=BX(A,g?.skyboxSize),G=N/2;if(!h.skipSkybox){const m=await Promise.resolve().then(()=>(fX(),DX));A._renderables.push(m.buildSolidSkyboxRenderable(A,p,G,S,w))}if(!h.skipGround){const m=await Promise.resolve().then(()=>(NX(),wX));A._renderables.push(await m.buildGroundRenderable(I,M,S,w,D,u))}if(d){const m=await Promise.resolve().then(()=>(UX(),W4A));A._renderables.push(await m.buildDdsSkyboxRenderable(A,G,S,w,_))}if(y){const m=await Promise.resolve().then(()=>(JX(),vX));A._renderables.push(await m.buildHdrSkyboxRenderable(A,p,G,S,w))}}),p}function HX(A){const e=.3333338747897695,g=.33333298856284405,I=1.4999984284682104,i=3.999982863580422,C=1.3333326611423701,o=.6666653397393608,r=1.999991431790211,B=new oA(36);for(let n=0;n<3;n++){const Q=A[n],E=A[3+n],a=A[6+n],c=A[9+n],l=A[12+n],p=A[15+n],D=A[18+n],u=A[21+n],_=A[24+n];B[n]=(c+l)*e+p*g,B[4+n]=E*I,B[8+n]=a*I,B[12+n]=Q*I,B[16+n]=_*i,B[20+n]=D*i,B[24+n]=p*C-(c+l)*o,B[28+n]=u*i,B[32+n]=(c-l)*r}return B}var zY=b((()=>{ZA(),Lr(),qn(),Tm(),tX(),xY(),Pn()}));async function IK(A){const e=await fetch(A);if(e.ok)try{return await createImageBitmap(await e.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"})}catch{}throw new Error(`BRDF LUT '${A}' is not an image (${e.status} ${e.headers.get("content-type")??""}).`)}function tQ(A,e,g,I,i,C){return{specularCube:A,specularCubeView:A.createView({dimension:"cube"}),brdfLut:e,brdfLutView:e.createView(),cubeSampler:F3(i),brdfSampler:Qi(i),irradianceSH:g,sphericalHarmonics:C??HX(g),lodGenerationScale:I}}var Tm=b((()=>{zY(),F1()}));function xX(A){const e=1/Math.PI,g=new oA(27);for(let I=0;I<3;I++){const i=I*9,C=A[i],o=A[i+1],r=A[i+2],B=A[i+3],n=A[i+4],Q=A[i+5],E=A[i+6],a=A[i+7],c=A[i+8];g[0+I]=B*1.02333*e,g[3+I]=o*1.02333*e,g[6+I]=r*1.02333*e,g[9+I]=(C*.886227-E*.247708+c*.429043)*e,g[12+I]=(C*.886227-E*.247708-c*.429043)*e,g[15+I]=(C*.886227+E*.495417)*e,g[18+I]=Q*.858086*e,g[21+I]=a*.858086*e,g[24+I]=n*.858086*e}return g}var TX=b((()=>{ZA()})),I9A=H({computeSHFromEquirect:()=>OX,parseRGBE:()=>qX});function qX(A){const e=new He(A);let g=0;function I(){let E="";for(;g<e.length;){const a=e[g++];if(a===10)break;a!==13&&(E+=String.fromCharCode(a))}return E}I().startsWith("#?")||R(199);let i="";for(;g<e.length;){const E=I();if(E==="")break;E.startsWith("FORMAT=")&&(i=E.slice(7))}i&&i!=="32-bit_rle_rgbe"&&R(200,i);const C=I(),o=C.match(/-Y\s+(\d+)\s+\+X\s+(\d+)/);o||R(201,C);const r=parseInt(o[1],10),B=parseInt(o[2],10),n=new oA(B*r*3),Q=new He(B*4);for(let E=0;E<r;E++)g=t9A(e,g,B,n,E*B*3,Q);return{width:B,height:r,data:n}}function t9A(A,e,g,I,i,C){if(g>=8&&g<=32767&&A[e]===2&&A[e+1]===2&&(A[e+2]&128)===0){(A[e+2]<<8)+A[e+3]!==g&&R(202),e+=4;for(let o=0;o<4;o++){let r=o,B=0;for(;B<g;){e>=A.length&&R(203);const n=A[e++];if(n===0&&R(204),n>128){const Q=n-128;(Q>g-B||e>=A.length)&&R(205);const E=A[e++];for(let a=0;a<Q;a++)C[r]=E,r+=4;B+=Q}else{(n>g-B||e+n>A.length)&&R(206);for(let Q=0;Q<n;Q++)C[r]=A[e++],r+=4;B+=n}}}for(let o=0;o<g;o++)PX(C[o*4],C[o*4+1],C[o*4+2],C[o*4+3],I,i+o*3)}else{e+g*4>A.length&&R(207);for(let o=0;o<g;o++)PX(A[e],A[e+1],A[e+2],A[e+3],I,i+o*3),e+=4}return e}function PX(A,e,g,I,i,C){if(I===0)i[C]=i[C+1]=i[C+2]=0;else{const o=Math.pow(2,I-136);i[C]=A*o,i[C+1]=e*o,i[C+2]=g*o}}function OX(A,e,g){const I=.282094791773878,i=.48860251190292,C=1.092548430592079,o=.31539156525252,r=.54627421529604,B=new Bi(27);let n=0;for(let a=0;a<g;a++){const c=(a+.5)/g*Math.PI,l=Math.sin(c),p=Math.cos(c),D=l*(Math.PI/g)*(2*Math.PI/e);for(let u=0;u<e;u++){const _=(2*(u+.5)/e-1)*Math.PI,d=l*Math.sin(_),y=p,h=l*Math.cos(_),w=(a*e+u)*3;let M=A[w],N=A[w+1],S=A[w+2];const G=Math.max(M,N,S);if(G>4096){const K=4096/G;M*=K,N*=K,S*=K}const m=D;n+=m;const k=[I,i*y,i*h,i*d,C*d*y,C*y*h,o*(3*h*h-1),C*d*h,r*(d*d-y*y)];for(let K=0;K<9;K++){const U=k[K]*m;B[K]=B[K]+M*U,B[9+K]=B[9+K]+N*U,B[18+K]=B[18+K]+S*U}}}const Q=4*Math.PI/n;for(let a=0;a<27;a++)B[a]=B[a]*Q;const E=[1,2/3,2/3,2/3,.25,.25,.25,.25,.25];for(let a=0;a<3;a++)for(let c=0;c<9;c++)B[a*9+c]=B[a*9+c]*E[c];return xX(B)}var jX=b((()=>{rA(),ZA(),TX()})),VX,i9A=b((()=>{VX="struct t{faceSize:u32,equirectWidth:u32,equirectHeight:u32,_pad:u32}@group(0) @binding(0) var p:texture_2d<f32>;@group(0) @binding(1) var k:texture_storage_2d_array<rgba16float,write>;@group(0) @binding(2) var<uniform> params:t;const i=3.14159265359;const d=array<vec3<f32>,24>(vec3(1.0,-1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(1.0,-1.0,-1.0),vec3(-1.0,1.0,-1.0),vec3(1.0,1.0,-1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,1.0,-1.0));@compute @workgroup_size(8,8,1) fn main(@builtin(global_invocation_id) a:vec3u){let h=a.z;let c=params.faceSize;if (a.x>=c||a.y>=c||h>=6u){return;}let f=f32(a.x)/f32(c);let e=f32(a.y)/f32(c);let b=h*4u;let g=normalize(d[b]*(1.0-f)*(1.0-e)+d[b+1u]*f*(1.0-e)+d[b+2u]*(1.0-f)*e+d[b+3u]*f*e);let l=atan2(g.z,g.x);let m=acos(clamp(g.y,-1.0,1.0));let n=l/i*0.5+0.5;let o=m/i;let j=clamp(i32(round(n*f32(params.equirectWidth))),0,i32(params.equirectWidth)-1);let q=clamp(i32(round(o*f32(params.equirectHeight))),0,i32(params.equirectHeight)-1);let r=i32(params.equirectHeight)-q-1;let s=textureLoad(p,vec2<i32>(j,r),0);textureStore(k,vec2<i32>(a.xy),i32(h),vec4<f32>(s.rgb,1.0));}"})),WX,C9A=b((()=>{WX="struct ha{faceSize:u32,mipLevel:u32,totalMips:u32,srcSize:u32}@group(0) @binding(0) var x:texture_cube<f32>;@group(0) @binding(1) var F:sampler;@group(0) @binding(2) var z:texture_storage_2d_array<rgba16float,write>;@group(0) @binding(3) var<uniform> params:ha;const k=3.14159265359;const n=1024u;const g=array<vec3<f32>,24>(vec3(1.0,-1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(1.0,-1.0,-1.0),vec3(-1.0,1.0,-1.0),vec3(1.0,1.0,-1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,-1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(1.0,-1.0,-1.0),vec3(1.0,-1.0,1.0),vec3(1.0,1.0,-1.0),vec3(1.0,1.0,1.0),vec3(-1.0,-1.0,1.0),vec3(-1.0,-1.0,-1.0),vec3(-1.0,1.0,1.0),vec3(-1.0,1.0,-1.0));fn I(ca:u32,j:f32,d:f32)->vec3<f32>{let i=ca*4u;return normalize(g[i]*(1.0-j)*(1.0-d)+g[i+1u]*j*(1.0-d)+g[i+2u]*(1.0-j)*d+g[i+3u]*j*d);}fn J(ba:u32)->f32{var a=ba;a=(a<<16u)|(a>>16u);a=((a&0x55555555u)<<1u)|((a&0xAAAAAAAAu)>>1u);a=((a&0x33333333u)<<2u)|((a&0xCCCCCCCCu)>>2u);a=((a&0x0F0F0F0Fu)<<4u)|((a&0xF0F0F0F0u)>>4u);a=((a&0x00FF00FFu)<<8u)|((a&0xFF00FF00u)>>8u);return f32(a)*2.3283064365386963e-10;}fn K(aa:f32,C:f32,s:f32)->vec3<f32>{let Z=s*s;let u=2.0*k*aa;let o=sqrt((1.0-C)/(1.0+(Z-1.0)*C));let w=sqrt(1.0-o*o);return vec3<f32>(cos(u)*w,sin(u)*w,o);}fn L(y:f32,t:f32)->f32{let A=y*y*(t-1.0)+1.0;return t/(k*A*A);}fn H(Y:u32,M:f32,S:f32)->vec3<f32>{return I(Y,M,S);}@compute @workgroup_size(8,8,1) fn main(@builtin(global_invocation_id) c:vec3u){let f=c.z;let h=params.faceSize>>params.mipLevel;if (c.x>=h||c.y>=h||f>=6u){return;}let R=f32(c.x)/f32(h);let Q=f32(c.y)/f32(h);let b=normalize(H(f,R,Q));let q=pow(2.0,f32(params.mipLevel)/0.8)/f32(params.srcSize);if (params.mipLevel==0u){let O=textureSampleLevel(x,F,b,0.0);textureStore(z,vec2<i32>(c.xy),i32(f),vec4<f32>(O.rgb,1.0));return;}var X=select(vec3<f32>(1.0,0.0,0.0),vec3<f32>(0.0,0.0,1.0),abs(b.z)<0.999);let v=normalize(cross(X,b));let P=cross(b,v);var p=vec3<f32>(0.0);var m=0.0;let E=f32(params.srcSize);let T=4.0*k/(6.0*E*E);let U=f32(params.totalMips)-1.0;for(var e=0u;e<n;e++){let W=f32(e)/f32(n);let N=J(e);let r=K(W,N,q);let B=v*r.x+P*r.y+b*r.z;let D=max(dot(b,B),0.0);let G=2.0*D*B-b;let l=dot(b,G);if (l>0.0){let da=q*q;let ea=L(D,da)/4.0;let fa=1.0/(f32(n)*max(ea,0.0001));let ga=clamp(0.5*log2(fa/T)+1.0,0.0,U);let V=textureSampleLevel(x,F,G,ga);p+=V.rgb*l;m+=l;}}if (m>0.0){p/=m;}textureStore(z,vec2<i32>(c.xy),i32(f),vec4<f32>(p,1.0));}"})),ZY,zX=b((()=>{ZY="@group(0) @binding(0) var z:texture_storage_2d<rgba16float,write>;fn x(G:u32)->f32{var a=G;a=(a<<16u)|(a>>16u);a=((a&0x55555555u)<<1u)|((a&0xAAAAAAAAu)>>1u);a=((a&0x33333333u)<<2u)|((a&0xCCCCCCCCu)>>2u);a=((a&0x0F0F0F0Fu)<<4u)|((a&0xF0F0F0F0u)>>4u);a=((a&0x00FF00FFu)<<8u)|((a&0xFF00FF00u)>>8u);return f32(a)*2.3283064365386963e-10;}fn w(B:f32,u:f32,J:f32)->vec3f{let t=2.0*3.14159265359*B;let k=sqrt((1.0-u)/(1.0+(J-1.0)*u));let q=sqrt(1.0-k*k);return vec3f(cos(t)*q,sin(t)*q,k);}fn y(b:f32,n:f32)->vec2f{let o=vec3f(sqrt(1.0-b*b),0.0,b);let p=n*n;let e=p*p;var r=0.0;var l=0.0;let g=1024u;for(var f=0u;f<g;f++){let F=f32(f)/f32(g);let E=x(f);let j=w(F,E,e);let i=max(dot(o,j),0.0);let A=2.0*i*j-o;let d=max(A.z,0.0);let s=max(j.z,0.0);if (d>0.0&&s>0.0){let C=d*sqrt(b*b*(1.0-e)+e);let D=b*sqrt(d*d*(1.0-e)+e);let v=(0.5/max(C+D,1e-6))*d*(4.0*i/s);let m=pow(1.0-i,5.0);r+=(1.0-m)*v;l+=m*v;}}return vec2f(r/f32(g),l/f32(g));}@compute @workgroup_size(8,8) fn main(@builtin(global_invocation_id) c:vec3u){if (c.x>=256u||c.y>=256u){return;}let H=max((f32(c.x)+0.5)/256.0,0.001);let I=max((f32(c.y)+0.5)/256.0,0.04);let h=y(H,I);textureStore(z,vec2u(c.x,c.y),vec4f(h.y,h.x+h.y,0.0,1.0));}"})),o9A=H({HDR_LOD_GENERATION_SCALE:()=>XY,_enableHdrEnvironmentCopySource:()=>ZX,equirectToCubemapGPU:()=>XX,generateBrdfLut:()=>A$,prefilterCubemapGPU:()=>$X});function ZX(){$Y=RA.COPY_SRC}function XX(A,e,g){const I=A._device,i=I.createTexture({size:[e.width,e.height],format:"rgba32float",usage:RA.TEXTURE_BINDING|RA.COPY_DST});{const a=new oA(e.width*e.height*4);for(let c=0;c<e.width*e.height;c++)a[c*4]=e.data[c*3],a[c*4+1]=e.data[c*3+1],a[c*4+2]=e.data[c*3+2],a[c*4+3]=1;I.queue.writeTexture({texture:i},a.buffer,{bytesPerRow:e.width*16},{width:e.width,height:e.height})}const C=I.createTexture({size:[g,g,6],format:"rgba16float",usage:RA.TEXTURE_BINDING|RA.STORAGE_BINDING|RA.COPY_SRC,dimension:"2d"}),o=I.createShaderModule({code:VX}),r=I.createComputePipeline({layout:"auto",compute:{module:o,entryPoint:"main"}}),B=wI(A,new Ag([g,e.width,e.height,0])),n=I.createBindGroup({layout:r.getBindGroupLayout(0),entries:[{binding:0,resource:i.createView()},{binding:1,resource:C.createView()},{binding:2,resource:{buffer:B}}]}),Q=I.createCommandEncoder(),E=Q.beginComputePass();return E.setPipeline(r),E.setBindGroup(0,n),E.dispatchWorkgroups(Math.ceil(g/8),Math.ceil(g/8),6),E.end(),I.queue.submit([Q.finish()]),i.destroy(),B.destroy(),C}function $X(A,e,g,I){const i=A._device,C=i.createTexture({size:{width:g,height:g,depthOrArrayLayers:6},mipLevelCount:I,format:"rgba16float",usage:RA.TEXTURE_BINDING|RA.STORAGE_BINDING|RA.COPY_DST|$Y}),o=e.createView({dimension:"cube"}),r=Qi(A),B=i.createComputePipeline({layout:"auto",compute:{module:i.createShaderModule({code:WX}),entryPoint:"main"}}),n=Lt(A,16);{const Q=i.createCommandEncoder();Q.copyTextureToTexture({texture:e},{texture:C,mipLevel:0},{width:g,height:g,depthOrArrayLayers:6}),i.queue.submit([Q.finish()])}for(let Q=1;Q<I;Q++){const E=g>>Q;if(E<1)break;i.queue.writeBuffer(n,0,new Ag([g,Q,I,g]));const a=C.createView({baseMipLevel:Q,mipLevelCount:1}),c=i.createBindGroup({layout:B.getBindGroupLayout(0),entries:[{binding:0,resource:o},{binding:1,resource:r},{binding:2,resource:a},{binding:3,resource:{buffer:n}}]}),l=i.createCommandEncoder(),p=l.beginComputePass();p.setPipeline(B),p.setBindGroup(0,c),p.dispatchWorkgroups(Math.ceil(E/8),Math.ceil(E/8),6),p.end(),i.queue.submit([l.finish()])}return e.destroy(),n.destroy(),C}function A$(A){const e=A._device;(!qm||A5!==e)&&(qm=e.createComputePipeline({layout:"auto",compute:{module:e.createShaderModule({code:ZY}),entryPoint:"main"}}),A5=e);const g=256,I=e.createTexture({size:{width:g,height:g},format:"rgba16float",usage:RA.TEXTURE_BINDING|RA.STORAGE_BINDING}),i=e.createBindGroup({layout:qm.getBindGroupLayout(0),entries:[{binding:0,resource:I.createView()}]}),C=e.createCommandEncoder(),o=C.beginComputePass();return o.setPipeline(qm),o.setBindGroup(0,i),o.dispatchWorkgroups(Math.ceil(g/8),Math.ceil(g/8)),o.end(),e.queue.submit([C.finish()]),I}var XY,$Y,qm,A5,e5=b((()=>{ZA(),te(),F1(),zI(),b1(),i9A(),C9A(),zX(),XY=.8,$Y=0,qm=null,A5=null})),r9A=H({rebuildSceneEnvironment:()=>B9A});async function B9A(A,e){const g=e._envTextures;if(!g)return;const I=e._envRecoverySource;I||R(162);const i=g.sphericalHarmonics;e._envTextures=void 0;let C;if(I.kind==="env")C=await n9A(A,I,i);else{const B=await Promise.resolve().then(()=>(jX(),I9A)),n=await Promise.resolve().then(()=>(e5(),o9A)),Q=await e$(I.url),E=B.parseRGBE(Q),a=B.computeSHFromEquirect(E.data,E.width,E.height),c=n.equirectToCubemapGPU(A,E,I.faceSize);C=tQ(n.prefilterCubemapGPU(A,c,I.faceSize,Math.floor(Math.log2(I.faceSize))+1),n.generateBrdfLut(A),a,n.HDR_LOD_GENERATION_SCALE,A,i)}Object.assign(g,C);const{specularCube:o,brdfLut:r}=g;Mi(o),Mi(r),e._disposables.push(()=>{Si(o),Si(r)}),e._envTextures=g,e._envRecoverySource=I}async function n9A(A,e,g){const I=IK(e.brdfUrl);I.catch(()=>{});const{faceBlobs:i,irradianceSH:C,width:o,mipCount:r}=gX(await e$(e.url)),B=await Promise.all(i.map(c=>createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"}))),n=await Promise.resolve().then(()=>(Z3(),V3)),Q=n.uploadCubemapRGBD(A,B,o,r);for(const c of B)c.close();const E=await I,a=n.decodeBrdfPng(A,E);return E.close(),tQ(Q,a,C,.8,A,g)}async function e$(A){const e=await fetch(A);return e.ok||R(163,A,e.status,e.statusText),e.arrayBuffer()}var s9A=b((()=>{rA(),Lr(),qn(),Tm(),tX()}));function gt(A,e,g=0,I=0){const i=e;if(I===0&&i.length===16){A.set(i,g);return}const C=I,o=g;A[o+0]=i[C+0],A[o+1]=i[C+1],A[o+2]=i[C+2],A[o+3]=i[C+3],A[o+4]=i[C+4],A[o+5]=i[C+5],A[o+6]=i[C+6],A[o+7]=i[C+7],A[o+8]=i[C+8],A[o+9]=i[C+9],A[o+10]=i[C+10],A[o+11]=i[C+11],A[o+12]=i[C+12],A[o+13]=i[C+13],A[o+14]=i[C+14],A[o+15]=i[C+15]}var gi=b((()=>{}));function g5(A,e){gt(A,e._lightMatrix,0),A[16]=e._depthValues[0],A[17]=e._depthValues[1],A[18]=0,A[19]=0,A[20]=e._shadowsInfo[0],A[21]=e._shadowsInfo[1],A[22]=e._shadowsInfo[2],A[23]=e._shadowsInfo[3]}function g$(A,e,g,I,i,C){const o=Math.sqrt(A*A+e*e+g*g)||1,r=A/o,B=e/o,n=g/o;let Q=0,E=1,a=0;Math.abs(B)>.99&&(Q=0,E=0,a=1);let c=E*n-a*B,l=a*r-Q*n,p=Q*B-E*r;const D=Math.sqrt(c*c+l*l+p*p)||1;c/=D,l/=D,p/=D;const u=B*p-n*l,_=n*c-r*p,d=r*l-B*c;return new oA([c,u,r,0,l,_,B,0,p,d,n,0,-(c*I+l*i+p*C),-(u*I+_*i+d*C),-(r*I+B*i+n*C),1])}function I$(A,e){const g=new oA(16);for(let I=0;I<4;I++)for(let i=0;i<4;i++){let C=0;for(let o=0;o<4;o++)C+=A[I+o*4]*e[o+i*4];g[I+i*4]=C}return g}function t$(A,e,g,I,i=0,C=0,o=0){const r=A.worldMatrix,B=A.direction,n=g$(r[0]*B.x+r[4]*B.y+r[8]*B.z,r[1]*B.x+r[5]*B.y+r[9]*B.z,r[2]*B.x+r[6]*B.y+r[10]*B.z,r[12]-i,r[13]-C,r[14]-o);let Q=1/0,E=-1/0,a=1/0,c=-1/0;for(const u of e){const _=u.worldMatrix,d=u.boundMin??[-.5,-.5,-.5],y=u.boundMax??[.5,.5,.5];for(let h=0;h<8;h++){const w=h&1?y[0]:d[0],M=h&2?y[1]:d[1],N=h&4?y[2]:d[2],S=_[0]*w+_[4]*M+_[8]*N+_[12]-i,G=_[1]*w+_[5]*M+_[9]*N+_[13]-C,m=_[2]*w+_[6]*M+_[10]*N+_[14]-o,k=n[0]*S+n[4]*G+n[8]*m+n[12],K=n[1]*S+n[5]*G+n[9]*m+n[13];Q=Math.min(Q,k),E=Math.max(E,k),a=Math.min(a,K),c=Math.max(c,K)}}Number.isFinite(Q)||(Q=-1,E=1,a=-1,c=1);const l=(E-Q)*.1,p=(c-a)*.1;Q-=l,E+=l,a-=p,c+=p;const D=new oA(16);return D[0]=2/(E-Q),D[5]=2/(c-a),D[10]=1/(I-g),D[12]=-(E+Q)/(E-Q),D[13]=-(c+a)/(c-a),D[14]=-g/(I-g),D[15]=1,{_view:n,_viewProj:I$(D,n),_near:g,_far:I}}function Pm(A,e,g){const I=new oA(8);return I[0]=e,I[2]=g,I[4]=0,I[5]=1,wI(A,I)}function i$(A,e=null,g=A._depthTexture){const I=A._config._mapSize;return{_descriptor:{size:{width:I,height:I},format:e?"rgba16float":void 0,dFormat:"depth32float",depthClearValue:1,depthCompare:"less-equal",samples:1},_colorTexture:e,_colorView:e?.createView()??null,_depthTexture:g,_depthView:g.createView(),_width:I,_height:I,_eager:!0,_ownsDepthTexture:!1}}function I5(A,e,g,I){const i=new oA(24);return g5(i,{_lightMatrix:e,_depthValues:g,_shadowsInfo:I}),{ubo:wI(A,i),data:i}}function t5(A){let e=0;for(const g of A)e+=g.worldMatrixVersion+~~g.thinInstances?._version;return e}function tK(A){return{fov:1,nearPlane:1,farPlane:1,children:[],_viewCache:QI(),_projCache:QI(),_vpCache:QI(),get worldMatrix(){return A._light.worldMatrix},get worldMatrixVersion(){return this._shadowCameraVersion??A._light._lightVersion}}}function iK(A,e,g,I,i,C){A.nearPlane=g,A.farPlane=I,A._shadowCameraVersion=e,A._viewCache=i,A._viewVer=e,A._vpCache=C,A._vpVer=Wi(A),A._vpAspect=1}var Tr=b((()=>{ZA(),FI(),zI(),gi(),Ut()}));function C$(A,e,g,I,i){A.fill(0);const C=si(I,i),o=ei(I),r=I.worldMatrix;gt(A,C,0),gt(A,o,16),e.useFloatingOrigin?(A[32]=0,A[33]=0,A[34]=0):(A[32]=r[12],A[33]=r[13],A[34]=r[14]),A[87]=e.canvas.width;const B=g.imageProcessing;A[76]=B.exposure,A[77]=B.contrast,A[78]=g._envTextures?.lodGenerationScale??.8,A[79]=+B.toneMappingEnabled,A[37]=e.canvas.height}var o$=b((()=>{FI(),gi()}));function r$(A,e){return{_renderables:A,_opaqueBindings:[],_directBindings:[],_transparentBindings:[],_ob:[],_lastVersion:e}}function i5(A,e,g){A.clr??=!0;const I=A.rt._descriptor,i=A.depth?._descriptor,C={_colorFormat:I.format,_depthStencilFormat:i?.dFormat??I.dFormat,_depthCompare:I.depthCompare??i?.depthCompare,_sampleCount:I.samples},o={loadOp:"clear",storeOp:"store"},r={targetWidth:0,targetHeight:0},B={...r$([],-1),name:A.name,_config:A,_ownsTargets:!A.sharedRt,engine:e,scene:g,_passes:[],_renderPassDescriptor:{colorAttachments:[o]},_colorAttachment:o,_sceneUBO:Lt(e,368),_suData:new oA(92),_sceneUboCacheKey:[],_targetSignature:C,_updateContext:r,record(){if(B._disposed)throw new Error("RenderTask has been disposed.");B._recordExplicit?B._recordExplicit(B,!0):CK(B,A.autoMirror!==!1?g._renderables.slice():B._renderables,!0)},execute(){return l9A(B,e,C)},dispose(){if(B._disposed)return;B._disposed=!0;const n=B._pendingMeshes;n&&(n.length=0);for(const E of B._renderables)B._retireRenderable?.(B.engine,E);B._passes.length=B._opaqueBindings.length=B._directBindings.length=0,B._transparentBindings.length=B._renderables.length=B._ob.length=0,B._ownsTargets&&(eI(A.rt),eI(A.rst)),A.depth?._eager||eI(A.depth);const Q=B._sceneUBO;et(B.engine,()=>Q.destroy()),B._batchState?._release(B.engine),B._batchState=void 0}};return B}function B$(A,e){if(!A._renderables)return;A._removeMesh?.(e);let g=!1;for(let I=A._renderables.length-1;I>=0;I--)A._renderables[I].mesh===e&&(A._retireRenderable?.(A.engine,A._renderables[I]),A._renderables.splice(I,1),g=!0);for(const I of[A._opaqueBindings,A._directBindings,A._transparentBindings])for(let i=I.length-1;i>=0;i--)I[i].renderable.mesh===e&&(I.splice(i,1),g=!0);if(g){const I=A._batchState;A._batchState=I?._select([A._opaqueBindings,A._directBindings,A._transparentBindings]),I?._release(A.engine,[A._batchState]),A._ob.length=0,A._lastVersion=-1}}function Q9A(A,e){return e._sortDistance-A._sortDistance||A.renderable.order-e.renderable.order}function n$(A,e){return A.renderable.order-e.renderable.order}function E9A(A,e){const g=A._transparentBindings;if(g.length<=1||!e)return;const I=ei(e);for(const i of g){const C=i.renderable._worldCenter;i._sortDistance=C?C[0]*I[2]+C[1]*I[6]+C[2]*I[10]+I[14]:0}g.sort(Q9A)}function CK(A,e=A._renderables,g=!1,I=!0,i){const C=A._config,o=C.rt,r=A._batchState,B=r$(e,A.scene._renderableVersion);if(g){const a=(c,l)=>{c&&(l||A._ownsTargets||c._eager)&&xI(c,A.engine)};a(o),o._descriptor.samples>1&&a(C.rst),a(C.depth,!0)}const{_opaqueBindings:n,_directBindings:Q,_transparentBindings:E}=B;try{for(const a of e){const c=a.bind(A.engine,A._targetSignature);B._batchState=A._targetSignature._collectBatches?.(B._batchState,c),a.isTransparent||a._transmissive?E.push(c):a._direct?Q.push(c):n.push(c)}n.sort(n$),Q.sort(n$),g&&s$(A,A.engine,!1)}catch(a){throw B._batchState?._release(void 0,i??[r]),a}return g&&(a9A(A,o),A._updateContext.targetWidth=o._width,A._updateContext.targetHeight=o._height),I&&(Object.assign(A,B),r?._release(A.engine,[B._batchState])),B}function a9A(A,e){const g=A._config,I=A._colorAttachment;I.view=e._colorView,A._renderPassDescriptor.colorAttachments=e._colorView?[I]:[];const i=g.depth??e,C=i._depthView;let o;if(C){const r=i._descriptor,B=(g.depth?i._eager:g.depthClear===!1)?"load":"clear";o={view:C,depthClearValue:r.depthClearValue??0,depthLoadOp:B,depthStoreOp:"store"},r.dFormat?.includes("stencil")&&(o.stencilClearValue=0,o.stencilLoadOp=B,o.stencilStoreOp="store")}A._renderPassDescriptor.depthStencilAttachment=o}function c9A(A,e,g){const I=A.scene;A._config.autoMirror!==!1&&A._lastVersion!==I._renderableVersion&&CK(A,I._renderables.slice()),s$(A,e);const i=A._updateContext,C=A._config.cam??I.camera;g._colorFormat&&(A._config._skipClusteredLights||I._clusteredLightUpdater?.(C,i.targetWidth,i.targetHeight),w4A(e,I)),D9A(A,e,I,C),i._camera=C,A._batchState?._reset(),C5(A._opaqueBindings,i),C5(A._directBindings,i),C5(A._transparentBindings,i),A._batchState?._flush(e),E9A(A,C)}function l9A(A,e,g){if(A.enabled===!1)return 0;const I=A.scene;c9A(A,e,g);const i=A._colorAttachment,C=A._config;if(C.rt._colorView&&(C.rt===I.surface.scRT&&(i.view=C.rt._colorView),i.resolveTarget=C.rst?._colorView??void 0,i.clearValue=C.clrColor??I.clearColor,i.loadOp=C.clr?"clear":"load"),A._executeWithTransmission)return A._executeWithTransmission(g._sampleCount);const o=e._currentEncoder.beginRenderPass(A._renderPassDescriptor),r=p9A(A,o);return o.end(),r}function p9A(A,e){const g=A.engine,I=A._config,i=I.rt,C=A.scene,o=A._opaqueBindings,r=A._ob,B=A._sceneBG;if(NZ(e,I.cam??C.camera,i._width,i._height),e.setBindGroup(0,B),A._lastVis!==Yn||!r.length){const Q=i._descriptor,E=g._device.createRenderBundleEncoder({colorFormats:Q.format?[Q.format]:[],depthStencilFormat:A._targetSignature._depthStencilFormat,sampleCount:Q.samples});E.setBindGroup(0,B),iQ(E,o,g),r[0]=E.finish(),A._lastVis=Yn}let n=o.length;return e.executeBundles(r),e.setBindGroup(0,B),n+=iQ(e,A._directBindings,g),n+=iQ(e,A._transparentBindings,g),n}function s$(A,e,g=!0){const I=P3(e,A.scene)._buffer;if(I===A._lightsUBO)return;const i=e._device.createBindGroup({layout:n1(e),entries:[{binding:0,resource:{buffer:A._sceneUBO}},{binding:1,resource:{buffer:I}}]});A._lightsUBO=I,A._sceneBG=i,g&&(A._ob=[])}function D9A(A,e,g,I){if(!I)return;const i=I.viewport,C=A._config.rt,o=(A._config.cs?e.canvas.width/e.canvas.height:C._width/C._height)*(i?i.width/i.height:1),r=g.fog,B=g.imageProcessing,n=Wi(I),Q=g._envTextures,E=A._sceneUboCacheKey;if(E[0]===I&&E[1]===r&&E[2]===n&&E[3]===o&&E[4]===B.exposure&&E[5]===B.contrast&&E[6]===Q)return;E[0]=I,E[1]=r,E[2]=n,E[3]=o,E[4]=B.exposure,E[5]=B.contrast,E[6]=Q;const a=A._suData;C$(a,e,g,I,o);const c=g._sceneUboContributors;if(c)for(const l of c)l(a,g);e._device.queue.writeBuffer(A._sceneUBO,0,a)}function C5(A,e){for(const g of A)g.update?.(e)}function iQ(A,e,g){let I=null,i=0;for(const C of e){const o=C.renderable.mesh;o&&o.visible===!1||(C.pipeline!==I&&(A.setPipeline(C.pipeline),I=C.pipeline),i+=C.draw(A,g))}return i}var CQ=b((()=>{ZA(),lt(),kI(),MI(),FI(),s1(),o$(),b1(),O3(),HY()}));function o5(A,e){const g=A._groups.get(e);return g?g.r:e._sceneIndependentRebuild?e._rebuildSingle:void 0}var r5=b((()=>{}));function B5(A,e=[]){for(const{mesh:g,material:I}of A._pendingMeshes){if(!I)continue;const i={_lifetimeDisposers:[]},C=o5(A.scene,I._buildGroup);C||R(156),e.push(i);const o=C(A.scene,g,I,i);o._lifetimeDisposers=i._lifetimeDisposers,A._renderables.push(o)}return A._pendingMeshes.length=0,e}function u9A(A){const e=[],g={scene:A.scene,_renderables:A._renderables.slice(),_pendingMeshes:A._pendingMeshes.slice()},I=()=>{for(const i of e)wC(i._lifetimeDisposers);e.length=0};try{A._prepareTaskMeshes?.(g),B5(g,e)}catch(i){throw I(),i}return{renderables:g._renderables,dispose:I}}function Q$(A,e=!1){A._disposed&&R(157);const g=A._batchState,I=[],i=A._pendingMeshes.length>0,C=A._config.autoMirror!==!1,o={scene:A.scene,_renderables:C?i?[]:A.scene._renderables.slice():A._renderables.slice(),_pendingMeshes:A._pendingMeshes.slice()};let r;try{A._prepareTaskMeshes?.(o,!0),B5(o,I),r=CK(A,o._renderables,e,!1)}catch(B){for(const n of I)wC(n._lifetimeDisposers);throw B}i&&(A._config.autoMirror=!1),A._pendingMeshes=o._pendingMeshes,Object.assign(A,r),g?._release(A.engine,[r._batchState])}var E$=b((()=>{rA(),kI(),r5(),CQ()}));function oQ(A,e,g){return i5(A,e,g)}function Om(A,e,g){jm(A),A._addMesh(e,g)}function jm(A){A._addMesh||(A._pendingMeshes??=[],A._addMesh=d9A,A._recordExplicit=Q$,A._retireRenderable=_9A)}function _9A(A,e){e._lifetimeDisposers&&DZ(A,e._lifetimeDisposers)}function d9A(A,e){if(this._disposed)throw new Error("RenderTask has been disposed.");const g=e?.material??A.material;g&&(this._pendingMeshes.push({mesh:A,material:g}),this._sceneBG&&n5(this))}function f9A(A,e){const g=A._pendingMeshes;if(g)for(let I=g.length-1;I>=0;I--)g[I].mesh===e&&g.splice(I,1);B$(A,e)}function n5(A){Q$(A)}var rQ=b((()=>{kI(),CQ(),E$()})),a$,y9A=b((()=>{a$="struct c{@builtin(position) clipPos:vec4<f32>,@location(0) sampleCenter:vec2<f32>}@vertex fn main(@builtin(vertex_index) d:u32)->c{var e=array<vec2<f32>,3>(vec2<f32>(-1.0,-1.0),vec2<f32>(3.0,-1.0),vec2<f32>(-1.0,3.0));var a:c;let b=e[d];a.clipPos=vec4<f32>(b,0.0,1.0);a.sampleCenter=b*vec2<f32>(0.5,-0.5)+0.5;return a;}"}));function iC(A,e){const g=t1(A);return Object.create(g,{source:{value:g,enumerable:!0},_renderFeatures:{value:{features:e.features,features2:e.features2},writable:!0,enumerable:!0,configurable:!0}})}function oK(A){const e=A;return!!e.source&&!!e._renderFeatures}function t1(A){return oK(A)?A.source:A}var It=b((()=>{}));function h9A(A){Wm=A}function CC(A){(EK??=new Map).set(A._id,A),zm=null}function c$(){return EK??=new Map}function rK(){if(!zm){const A=EK;zm=A?Array.from(A.values()).sort((e,g)=>e._id.localeCompare(g._id)):[]}return zm}var BK,nK,s5,Q5,E5,On,a5,Vm,c5,BQ,l$,l5,p5,sK,D5,QK,Wm,EK,zm,aK,bI=b((()=>{BK=1024,nK=2048,s5=4096,Q5=8192,E5=16384,On=65536,a5=1<<17,Vm=1<<18,c5=1<<19,BQ=1<<20,l$=1<<21,l5=32768,p5=1<<22,sK=1<<24,D5=1<<26,QK=1<<27,Wm=null,EK=null,zm=null,aK=3456})),w9A=H({createStandardEsmShadowMaterialView:()=>M9A});function M9A(A,e){const g=iC(A,{features:(A._renderFeatures??{features:0}).features&~On|BQ});return Object.defineProperty(g,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(g,"_esmShadowDepthCode",{value:p$,enumerable:!1}),g}var p$,R9A=b((()=>{It(),bI(),p$="let depthMetricSM=(input.clipPos.z+shadowParams.depthValues.x)/shadowParams.depthValues.y+shadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,shadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),Zm,Xm,cK,u5,lK,pK,_5,DK,uK,d5,nQ,f5,_K,dK,fK,$m,sQ,Ii=b((()=>{Zm=1024,Xm=2048,cK=4096,u5=32768,lK=1<<17,pK=1<<21,_5=1<<22,DK=1<<25,uK=1<<26,d5=1<<27,nQ=1<<28,f5=1<<29,_K=1024,dK=2048,fK=4096,$m=32768,sQ=65536})),S9A=H({PBR2_ESM_SHADOW_OUTPUT:()=>sQ,PBR2_HAS_BASE_COLOR_FACTOR:()=>fK,PBR2_HAS_REFLECTANCE_FACTORS:()=>_K,PBR2_HAS_REFRACTION:()=>16,PBR2_HAS_UV2:()=>dK,PBR2_HAS_UV_TRANSFORM:()=>512,PBR2_NO_COLOR_OUTPUT:()=>$m,PBR_HAS_ALPHA_BLEND:()=>64,PBR_HAS_ALPHA_TEST:()=>8,PBR_HAS_ANISOTROPY:()=>uK,PBR_HAS_COTANGENT_NORMAL:()=>512,PBR_HAS_DOUBLE_SIDED:()=>256,PBR_HAS_EMISSIVE:()=>2,PBR_HAS_EMISSIVE_COLOR:()=>pK,PBR_HAS_ENV:()=>4,PBR_HAS_FOG:()=>32,PBR_HAS_GAMMA_ALBEDO:()=>DK,PBR_HAS_METALLIC_REFLECTANCE_MAP:()=>Zm,PBR_HAS_NORMAL_MAP:()=>1,PBR_HAS_OCCLUSION:()=>u5,PBR_HAS_REFLECTANCE_MAP:()=>Xm,PBR_HAS_SHEEN:()=>_5,PBR_HAS_SKYBOX:()=>f5,PBR_HAS_SPECULAR_AA:()=>lK,PBR_HAS_SPEC_GLOSS:()=>128,PBR_HAS_SUBSURFACE:()=>d5,PBR_HAS_THICKNESS_MAP:()=>nQ,PBR_HAS_TONEMAP:()=>16,PBR_HAS_USE_ALPHA_ONLY_MR:()=>cK,_getPbrExts:()=>qr,_getPbrExtsSorted:()=>D$,_getPbrSceneHooks:()=>u$,_registerPbrExt:()=>TI,_registerPbrSceneHook:()=>y5});function TI(A){(yK??=new Map).set(A.id,A),AF=null}function qr(){return yK??=new Map}function D$(){if(!AF){const A=yK;AF=A?Array.from(A.values()).sort((e,g)=>e.id.localeCompare(g.id)):[]}return AF}function y5(A){(h5??=new Set).add(A)}function u$(){return h5??[]}var yK,AF,h5,lI=b((()=>{Ii(),yK=null,AF=null,h5=null})),N9A=H({createPbrEsmShadowMaterialView:()=>G9A});function G9A(A,e){const g=A._renderFeatures??{features:0,features2:0},I=iC(A,{features:g.features&-65,features2:(g.features2??0)|sQ});return Object.defineProperty(I,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(I,"_esmShadowDepthCode",{value:_$,enumerable:!1}),I}var _$,m9A=b((()=>{It(),lI(),_$="let depthMetricSM=(input.clipPos.z+shadowParams.depthValues.x)/shadowParams.depthValues.y+shadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,shadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),hK=b((()=>{})),F9A=H({createNodeEsmShadowMaterialView:()=>b9A});function b9A(A,e){const g=iC(A,{features:(A._renderFeatures??{features:0}).features|2});return Object.defineProperty(g,"_esmShadowParamsUBO",{value:e,enumerable:!1}),Object.defineProperty(g,"_esmShadowDepthCode",{value:d$,enumerable:!1}),g}var d$,k9A=b((()=>{It(),hK(),d$="let depthMetricSM=(in.position.z+nmeShadowParams.depthValues.x)/nmeShadowParams.depthValues.y+nmeShadowParams.biasAndScale.x;let depthSM=clamp(exp(-min(87.0,nmeShadowParams.biasAndScale.z*depthMetricSM)),0.0,1.0);return vec4<f32>(depthSM,1.0,1.0,1.0);"})),K9A=H({createEsmDirectionalShadowGenerator:()=>M$,ensureEsmShadowTaskState:()=>h$,getEsmShadowTaskResources:()=>w5,setEsmShadowTaskResources:()=>f$});function f$(A,e){A._esmResources=e}function w5(A){return A._esmResources??null}async function U9A(A){const e=[];let g=!1,I=!1,i=!1;for(const C of A){const o=C.material?._buildGroup._materialFamily;g||=o==="standard",I||=o==="pbr",i||=o==="node"}g&&!M5&&e.push(Promise.resolve().then(()=>(R9A(),w9A)).then(C=>{M5=C.createStandardEsmShadowMaterialView})),I&&!R5&&e.push(Promise.resolve().then(()=>(m9A(),N9A)).then(C=>{R5=C.createPbrEsmShadowMaterialView})),i&&!S5&&e.push(Promise.resolve().then(()=>(k9A(),F9A)).then(C=>{S5=C.createNodeEsmShadowMaterialView})),await Promise.all(e)}function v9A(A){const e=Math.round(Math.max(A,1));for(const g of[e,e-1,e+1,e-2,e+2])if(g%2!==0&&Math.floor(g/2)%2===0&&g>0)return Math.max(g,3);return Math.max(e,3)}function L9A(A){const e=.3333333333333333;return Math.exp(-(A*A/(2*e*e)))/(Math.sqrt(2*Math.PI)*e)}function Y9A(A){const e=v9A(A),g=(e-1)/2,I=[],i=[];let C=0;for(let B=0;B<e;B++){const n=L9A(B/(e-1)*2-1);I[B]=B-g,i[B]=n,C+=n}for(let B=0;B<i.length;B++)i[B]=i[B]/C;const o=[],r=[];for(let B=0;B<=g;B+=2){const n=Math.min(B+1,Math.floor(g));if(B===n){o.push(I[B]),r.push(i[B]);continue}const Q=n===g,E=i[B]+i[n]*(Q?.5:1),a=I[B]+1/(1+i[B]/i[n]);a===0?(o.push(I[B],I[B+1]),r.push(i[B],i[B+1])):(o.push(a,-a),r.push(E,E))}return{offsets:o,weights:r}}function y$(A){let e=(Object.is(A,-0)?0:A).toPrecision(10);return/[.eE]/.test(e)||(e+=".0"),e}function J9A(A){const{offsets:e,weights:g}=Y9A(A),I=e.length;return`struct BlurParams{delta:vec2<f32>,_pad:vec2<f32>,};@group(0)@binding(0)var<uniform>params:BlurParams;@group(0)@binding(1)var srcTex:texture_2d<f32>;@group(0)@binding(2)var srcSampler:sampler;const OFFSETS=array<f32,${I}>(${e.map(y$).join(",")});const WEIGHTS=array<f32,${I}>(${g.map(y$).join(",")});@fragment fn main(@location(0)sampleCenter:vec2<f32>)->@location(0)vec4<f32>{var blend=vec4<f32>(0.0);for(var i=0u;i<${I}u;i=i+1u){blend+=textureSample(srcTex,srcSampler,sampleCenter+params.delta*OFFSETS[i])*WEIGHTS[i];}return blend;}`}function h$(A,e,g,I,i){const C=i;if(C){if(C._casterMeshes===I)return C;et(A,C._task.dispose)}const o=w5(g);if(!o)throw new Error("ShadowTask: missing ESM metadata.");const r=new Map,B=tK(g),n={_task:oQ({name:"esm",rt:i$(g,o._esmTexture,o._depthBuffer),clr:!0,clrColor:{r:0,g:0,b:0,a:0},cam:B,autoMirror:!1,_skipClusteredLights:!0},A,e),_camera:B,_lastCasterVersion:-1,_lastLightVersion:-1,_lastFoVersion:-1,_casterMeshes:I,_scene:e};for(const Q of I){const E=Q.material;E&&Om(n._task,Q,{material:T9A(E,r,g._shadowParamsUBO)})}return n}function H9A(A,e,g){const I=w5(e);if(!I)return 0;const i=g._casterMeshes,C=t5(i),o=e._light._lightVersion,r=A.useFloatingOrigin?g._scene.camera:null,B=r?r.worldMatrixVersion:0,n=r?r.worldMatrix[12]:0,Q=r?r.worldMatrix[13]:0,E=r?r.worldMatrix[14]:0;if(!e._config._forceRefreshEveryFrame&&C===g._lastCasterVersion&&o===g._lastLightVersion&&B===g._lastFoVersion&&r===g._lastFoCamera)return 0;const a=t$(e._light,i,e._config._orthoMinZ,e._config._orthoMaxZ,n,Q,E);q9A(e._lightMatrix,a._viewProj)&&(gt(e._lightMatrix,a._viewProj,0),e._version++,g5(I._shadowUboData,e),A._device.queue.writeBuffer(e._shadowUBO,0,I._shadowUboData)),x9A(g,a),g._lastCasterVersion=C,g._lastLightVersion=o,g._lastFoVersion=B,g._lastFoCamera=r;const c=g._task.execute?.()??0,l=A._currentEncoder;return w$(l,I._blurPipeline,I._blurTexH,I._blurHBG),w$(l,I._blurPipeline,e._depthTexture,I._blurVBG),c+2}function w$(A,e,g,I){const i=A.beginRenderPass({colorAttachments:[{view:g.createView(),loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});i.setPipeline(e),i.setBindGroup(0,I),i.draw(3),i.end()}function x9A(A,e){const g=A._camera;iK(g,g.worldMatrixVersion+1,e._near,e._far,e._view,e._viewProj)}function T9A(A,e,g){const I=e.get(A);if(I)return I;const i=A._buildGroup._materialFamily;let C;return i==="standard"?C=M5(A,g):i==="pbr"?C=R5(A,g):i==="node"&&(C=S5(A,g)),e.set(A,C),C}function q9A(A,e){for(let g=0;g<16;g++)if(A[g]!==e[g])return!0;return!1}function M$(A,e,g={}){const I=A._device,i=g.mapSize??1024,C=g.depthScale??50,o=g.bias??5e-5,r=g.blurKernel??1,B=g.blurScale??2,n=g.darkness??0,Q=g.frustumEdgeFalloff??0,E=g.orthoMinZ??1,a=g.orthoMaxZ??1e4,c=g.forceRefreshEveryFrame??!1,l=i/B,p={_mapSize:i,_bias:o,_orthoMinZ:E,_orthoMaxZ:a,_forceRefreshEveryFrame:c},D=Pm(A,o,C),u=I.createTexture({size:{width:i,height:i},format:"rgba16float",usage:RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING}),_=I.createTexture({size:{width:i,height:i},format:"depth32float",usage:RA.RENDER_ATTACHMENT}),d=I.createTexture({size:{width:l,height:l},format:"rgba16float",usage:RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING}),y=I.createTexture({size:{width:l,height:l},format:"rgba16float",usage:RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING}),h=I.createShaderModule({code:a$}),w=I.createShaderModule({code:J9A(r)}),M=I.createBindGroupLayout({entries:[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:MA.FRAGMENT,sampler:{type:"filtering"}}]}),N=I.createRenderPipeline({layout:I.createPipelineLayout({bindGroupLayouts:[M]}),vertex:{module:h,entryPoint:"main"},fragment:{module:w,entryPoint:"main",targets:[{format:"rgba16float"}]},primitive:{topology:"triangle-list",cullMode:"none"}}),S=Qi(A),G=wI(A,new oA([1/l,0,0,0])),m=I.createBindGroup({layout:M,entries:[{binding:0,resource:{buffer:G}},{binding:1,resource:u.createView()},{binding:2,resource:S}]}),k=wI(A,new oA([0,1/l,0,0])),K=I.createBindGroup({layout:M,entries:[{binding:0,resource:{buffer:k}},{binding:1,resource:d.createView()},{binding:2,resource:S}]}),U=new oA(16),Y=new oA([n,0,C,Q]),x=new oA([0,1]),{ubo:q,data:j}=I5(A,U,x,Y),X={_shadowType:"esm",_light:e,_depthTexture:y,_depthSampler:S,_lightMatrix:U,_shadowsInfo:Y,_depthValues:x,_shadowParamsUBO:D,_shadowUBO:q,_config:p,_version:0};return X._preloadShadowTask=U9A,X._ensureShadowTaskState=(Z,AA,z)=>{const IA=h$(Z,AA,X,z,X._shadowTaskState??null);return X._shadowTaskState=IA,IA},X._renderShadowMap=(Z,AA)=>H9A(Z,X,AA),f$(X,{_esmTexture:u,_depthBuffer:_,_blurTexH:d,_blurPipeline:N,_blurHBG:m,_blurVBG:K,_shadowUboData:j,_blurKernel:r,_blurScale:B}),X}var M5,R5,S5,R$=b((()=>{ZA(),kI(),te(),zI(),F1(),rQ(),Tr(),y9A(),gi()})),P9A=H({rebuildSceneShadowGenerators:()=>O9A});async function O9A(A,e){const g=new Set(e.shadowGenerators);for(const I of e.lights)I.shadowGenerator&&g.add(I.shadowGenerator);for(const I of g){if(I._shadowType!=="esm"&&I._shadowType!=="csm"&&R(721,I._shadowType),I._shadowTaskState?._task.dispose(),I._shadowTaskState=void 0,I._preloadPending=void 0,I._shadowType==="csm"){const B=A._device,n=I._config._mapSize;I._depthTexture=B.createTexture({size:{width:n,height:n,depthOrArrayLayers:I._csmCascadeCount},format:"depth32float",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|(I._csmCache?GPUTextureUsage.COPY_DST:0)}),I._depthSampler=B.createSampler({compare:"less",magFilter:"linear",minFilter:"linear"}),I._shadowParamsUBO=Pm(A,I._config._bias,1/n),I._shadowUBO=wI(A,new Float32Array(80));const Q=I._csmReceiverTexture;Q&&(Q.texture=I._depthTexture,Q.view=I._depthTexture.createView({dimension:"2d-array"}),Q.sampler=I._depthSampler,Q.width=n,Q.height=n,LI(Q)),I._version++;continue}const i=await Promise.resolve().then(()=>(R$(),K9A)),C=i.getEsmShadowTaskResources(I);C||R(722);const o=i.createEsmDirectionalShadowGenerator(A,I._light,{mapSize:I._config._mapSize,depthScale:I._shadowsInfo[2],bias:I._config._bias,blurKernel:C._blurKernel,blurScale:C._blurScale,darkness:I._shadowsInfo[0],frustumEdgeFalloff:I._shadowsInfo[3],orthoMinZ:I._config._orthoMinZ,orthoMaxZ:I._config._orthoMaxZ,forceRefreshEveryFrame:I._config._forceRefreshEveryFrame}),r=i.getEsmShadowTaskResources(o);r||R(723),I._depthTexture=o._depthTexture,I._depthSampler=o._depthSampler,I._lightMatrix=o._lightMatrix,I._shadowsInfo=o._shadowsInfo,I._depthValues=o._depthValues,I._shadowParamsUBO=o._shadowParamsUBO,I._shadowUBO=o._shadowUBO,I._version++,i.setEsmShadowTaskResources(I,r)}}var j9A=b((()=>{rA(),Gt(),zI(),Tr()})),N5=H({createSkeleton:()=>V9A});function V9A(A,e,g,I,i,C,o){const r=A._device,B=I*4,n=r.createTexture({size:[B,1],format:"rgba32float",usage:RA.TEXTURE_BINDING|RA.COPY_DST});r.queue.writeTexture({texture:n},i.buffer,{bytesPerRow:B*16},{width:B,height:1});const Q=new Ag(e.length);for(let p=0;p<e.length;p++)Q[p]=e[p];const E=dg(A,Q,dA.VERTEX),a=dg(A,g,dA.VERTEX);let c=null,l=null;if(C&&o){const p=new Ag(C.length);for(let D=0;D<C.length;D++)p[D]=C[D];c=dg(A,p,dA.VERTEX),l=dg(A,o,dA.VERTEX)}return{boneTexture:n,boneCount:I,jointsBuffer:E,weightsBuffer:a,joints:e,weights:g,boneMatrices:i,joints1Buffer:c,weights1Buffer:l,joints1:C??null,weights1:o??null,_skinBuffers:{jointsBuffer:E,weightsBuffer:a,joints1Buffer:c,weights1Buffer:l}}}var G5=b((()=>{ZA(),te(),yt()})),m5=H({MORPH_WEIGHTS_HEADER_BYTES:()=>16,createMorphTargets:()=>S$,setMorphTargetWeights:()=>N$});function S$(A,e,g,I){const i=e.length,C=new oA(i*g*wK);for(let a=0;a<i;a++){const c=e[a],l=a*g*wK;for(let p=0;p<g;p++){const D=l+p*wK;C[D]=c.positions[p*3],C[D+1]=c.positions[p*3+1],C[D+2]=c.positions[p*3+2],c.normals&&(C[D+3]=c.normals[p*3],C[D+4]=c.normals[p*3+1],C[D+5]=c.normals[p*3+2])}}const o=dg(A,C,dA.STORAGE),r=new ArrayBuffer(16+i*4),B=new Ag(r,0,2);B[0]=i,B[1]=g;const n=new oA(r,16,i);for(let a=0;a<i;a++)n[a]=I?.[a]??0;const Q=dg(A,new He(r),dA.STORAGE),E=new oA(i);return E.set(n),{deltasBuffer:o,count:i,weightsBuffer:Q,targets:e,weights:E}}function N$(A,e,g){if(e._disposed)throw new Error("Cannot update disposed morph targets");const I=Math.min(e.count,g.length);e.weights.fill(0);for(let i=0;i<I;i++)e.weights[i]=g[i]??0;A._device.queue.writeBuffer(e.weightsBuffer,16,e.weights)}var wK,MK=b((()=>{ZA(),te(),yt(),wK=6})),W9A=H({_rebuildMeshes:()=>m$,rebuildRegisteredScenes:()=>z9A,rebuildRenderables:()=>G$});async function z9A(A){A._pbrFallbackTex=void 0;for(const e of A.surfaces)for(const g of e._renderingContexts){if(g._kind!=="scene")continue;const I=g;!DY(e,I)||I._z||await Z9A(A,I)}}async function Z9A(A,e){if(e._envTextures){const{rebuildSceneEnvironment:I}=await Promise.resolve().then(()=>(s9A(),r9A));await QQ("rebuilding environment textures",()=>I(A,e))}if(await QQ("rebuilding material textures",()=>$9A(A,e)),await QQ("rebuilding meshes",()=>m$(A,e)),e._z)return;if(e.shadowGenerators.length>0||e.lights.some(I=>I.shadowGenerator)){const{rebuildSceneShadowGenerators:I}=await Promise.resolve().then(()=>(j9A(),P9A));await QQ("rebuilding shadows",()=>I(A,e))}if(e._z)return;const g=e._renderables.filter(I=>!!I._rebuild).map(I=>I._rebuild);e._renderables.length=e._uniformUpdaters.length=0,e._meshDisposables.clear(),e._lightGpuState&&(e._lightGpuState=void 0);for(const[I,i]of e._groups){const C=await QQ("rebuilding material groups",()=>I(e,i));if(e._z)return;i.r=e._runtimeBuilds?.base(I,C.rebuildSingle)??C.rebuildSingle,i.o=C.renderables,e._renderables.push(...C.renderables),C.updater&&e._uniformUpdaters.push(C.updater)}g.length>0&&e._renderables.push(...await QQ("rebuilding renderables",()=>G$(g))),e._renderables.sort((I,i)=>I.order-i.order),e._renderableVersion++,X9A(A,e),e._frameGraph.build()}async function G$(A){const e=[];for(const g of A)e.push(await g());return e}async function QQ(A,e){try{return await e()}catch(g){const I=g instanceof Error?g.message:String(g);throw new Error(`Device-lost Scene recovery failed while ${A}: ${I}`,{cause:g})}}function X9A(A,e){for(const g of e._frameGraph._tasks){if(!("_sceneUBO"in g&&"_targetSignature"in g&&"_opaqueBindings"in g))continue;const I=g;I._sceneUBO=Lt(A,368),I._lightsUBO=P3(A,e)._buffer,I._sceneBG=A._device.createBindGroup({layout:n1(A),entries:[{binding:0,resource:{buffer:I._sceneUBO}},{binding:1,resource:{buffer:I._lightsUBO}}]}),I._opaqueBindings.length=0,I._directBindings.length=0,I._transparentBindings.length=0,I._ob.length=0,I._lastVersion=-1,I._sceneUboCacheKey.length=0}}async function m$(A,e){let g=null,I=null;for(const i of e.meshes){if(i._cpuPositions&&i._cpuNormals&&i._cpuIndices){const C=i._gpu._recoverShared;i._gpu=C?C(A,i,F$):F$(A,i)}if(i.skeleton){g??=(await Promise.resolve().then(()=>(G5(),N5))).createSkeleton;const C=i.skeleton,o=g(A,C.joints,C.weights,C.boneCount,C.boneMatrices,C.joints1,C.weights1);Object.assign(C,o)}if(i.morphTargets){I??=(await Promise.resolve().then(()=>(MK(),m5))).createMorphTargets;const C=i.morphTargets,o=I(A,C.targets.map(r=>({positions:r.positions,normals:r.normals})),i._cpuPositions?i._cpuPositions.length/3:0,Array.from(C.weights));Object.assign(C,o)}}}function F$(A,e){const g=e._gpu,I=g._drawRangeSource;if(I){const Q=q3(A,I.positions,I.normals,I.indices,I.uvs,I.uvs2,I.tangents,I.colors);return ZZ(Q,{...I}),Q._firstIndex=g._firstIndex,Q._baseVertex=g._baseVertex,Q._vertexCapacity=I.positions.length/3,Q._indexCapacity=I.indices.length,Q}const i=e._cpuPositions,C=e._cpuNormals,o=e._cpuUvs,r=e._cpuGpuIndices??e._cpuIndices,B=A._device;let n;return o&&o.length>0?n=dg(A,o,dA.VERTEX):(n=B.createBuffer({size:i.length/3*8,usage:dA.VERTEX,mappedAtCreation:!0}),n.unmap()),{positionBuffer:dg(A,i,dA.VERTEX),normalBuffer:dg(A,C,dA.VERTEX),tangentBuffer:e._cpuTangents?.length?dg(A,e._cpuTangents,dA.VERTEX):null,uvBuffer:n,uv2Buffer:e._cpuUv2s?dg(A,e._cpuUv2s,dA.VERTEX):null,colorBuffer:e._cpuColors?dg(A,e._cpuColors,dA.VERTEX):null,hasUv:!!o&&o.length>0,hasUv2:!!e._cpuUv2s&&e._cpuUv2s.length>0,hasTangent:!!e._cpuTangents&&e._cpuTangents.length>0,hasColor:!!e._cpuColors&&e._cpuColors.length>0,indexBuffer:dg(A,r,dA.INDEX),indexCount:r.length,indexFormat:e._cpuIndexFormat??e._gpu.indexFormat}}async function $9A(A,e){const g=new Set,I=new WeakSet,i=[],C=r=>{if(!r||typeof r!="object")return;const B=r;if(B.texture&&B.view&&B.sampler&&typeof B.width=="number"&&typeof B.height=="number"){const n=B;g.has(n)||(g.add(n),i.push(n));return}if(!I.has(r)){I.add(r);for(const n of Object.values(B))C(n)}};for(const r of e.meshes)C(r.material);if(i.length===0)return;const{rebuildTexture2D:o}=await Promise.resolve().then(()=>(GY(),NY));await Promise.all(i.map(r=>o(A,r)))}var AUA=b((()=>{te(),lt(),xr(),XZ(),b1(),yt(),s1(),HY(),O3()}));function eUA(A,e={}){return v3(A,{_kind:"scene",_recoverOrder:100,_enable(g){PZ(g,!0)},_disable(g){OZ(g,!0)},async _recover(g){const{rebuildRegisteredScenes:I}=await Promise.resolve().then(()=>(AUA(),W9A));await I(g)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function gUA(A){F5=A}function zi(){return F5}function b$(A){b5=A}function Pr(){return b5}var F5,b5,NC=b((()=>{F5=null,b5=null}));function RK(A,e){const g=e.cellWidthPx,I=e.cellHeightPx,i=e.marginPx??0,C=e.spacingPx??0,o=e.columns??Math.max(1,Math.floor((A.width-i*2+C)/(g+C))),r=e.rows??Math.max(1,Math.floor((A.height-i*2+C)/(I+C))),B=e.pivot??[.5,.5],n=A.width,Q=A.height,E=[];for(let a=0;a<r;a++)for(let c=0;c<o;c++){const l=i+c*(g+C),p=i+a*(I+C);E.push({uvMin:[l/n,p/Q],uvMax:[(l+g)/n,(p+I)/Q],sourceSizePx:[g,I],pivot:[B[0],B[1]]})}return{texture:A,textureSizePx:[n,Q],frames:E,premultipliedAlpha:e.premultipliedAlpha??!1}}async function IUA(A,e,g={}){return g.metadataUrl!==void 0&&R(750),g.gridSize||R(751),RK(await AQ(A,e,{invertY:!1,addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",mipMaps:!1,minFilter:g.sampling==="nearest"?"nearest":"linear",magFilter:g.sampling==="nearest"?"nearest":"linear",premultiplyAlpha:g.premultiplyOnLoad??!1,...g.textureOptions}),{cellWidthPx:g.gridSize[0],cellHeightPx:g.gridSize[1],premultipliedAlpha:g.premultipliedAlpha??!1})}function eF(A,e){return(e<0||e>=A.frames.length)&&R(752,e,A.frames.length),e}function tUA(A){A.texture.texture.destroy()}var gF=b((()=>{rA(),MC()})),k5,K5,k$=b((()=>{k5={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},K5={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}})),K$,SK,U$,U5,v5,v$,L5=b((()=>{k$(),K$={_key:"opaque"},SK={_key:"alpha",_descriptor:k5},U$={_key:"premultiplied",_descriptor:K5,_premultipliedOpacity:!0},U5={_key:"additive",_descriptor:{color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}},v5={_key:"oneone",_descriptor:{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}},v$={_key:"multiply",_descriptor:{color:{srcFactor:"dst",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"dst-alpha",dstFactor:"zero",operation:"add"}}}}));function iUA(A){x5=A}function EQ(){return x5}function Y5(A,e={}){const g=e.depth??"none",I=e.blendMode??SK,i=Math.max(1,e.capacity??H$),C={positionPx:[e.view?.positionPx?.[0]??0,e.view?.positionPx?.[1]??0],zoom:e.view?.zoom??1,rotation:e.view?.rotation??0},o=g==="none"?13:14,r=o*4,B=new oA(i*o),n={_entityType:"sprite-2d-layer",atlas:A,depth:g,blendMode:I,opacity:e.opacity??1,visible:e.visible??!0,order:e.order??0,view:C,pivot:[e.pivot?.[0]??.5,e.pivot?.[1]??.5],layerZ:e.layerZ??.5,count:0,_capacity:i,_instanceFloatsPerSprite:o,_instanceStrideBytes:r,_instanceData:B,_savedSize:new oA(i*2),_version:0,_dirtyMin:0,_dirtyMax:0};return zi()?.initLayer(n,e),n}function CUA(A,e){const g=A.shaderParams??=[0,0,0,0];g[0]=e[0],g[1]=e[1],g[2]=e[2],g[3]=e[3]}function oUA(A,e){let g=A._capacity;for(;g<e;)g*=2;const I=new oA(g*A._instanceFloatsPerSprite);I.set(A._instanceData),A._instanceData=I;const i=new oA(g*2);i.set(A._savedSize),A._savedSize=i,A._capacity=g}function NK(A,e){A.count=e}function L$(A,e,g,I){const i=A._instanceData,C=e*A._instanceFloatsPerSprite,o=e*2,r=I===null,B=g.frame!==void 0?A.atlas.frames[eF(A.atlas,g.frame)]:null,n=g.positionPx?g.positionPx[0]:I[0],Q=g.positionPx?g.positionPx[1]:I[1];let E,a;g.sizePx?(E=g.sizePx[0],a=g.sizePx[1]):B?(E=B.sourceSizePx[0],a=B.sourceSizePx[1]):r?(E=0,a=0):(E=A._savedSize[o],a=A._savedSize[o+1]),A._savedSize[o]=E,A._savedSize[o+1]=a;let c;g.visible!==void 0?c=g.visible:r?c=!0:c=I[2]!==0||I[3]!==0;let l,p,D,u;B?(l=B.uvMin[0],p=B.uvMin[1],D=B.uvMax[0],u=B.uvMax[1]):r?(l=0,p=0,D=1,u=1):(l=I[4],p=I[5],D=I[6],u=I[7]);const _=l>D,d=p>u,y=!r&&I[4]>I[6],h=!r&&I[5]>I[7],w=g.flipX!==void 0?g.flipX===!0:y,M=g.flipY!==void 0?g.flipY===!0:h;if(_!==w){const m=l;l=D,D=m}if(d!==M){const m=p;p=u,u=m}const N=g.rotation??(I?I[8]:0),S=A.depth!=="none",G=S?g.z??(I?I[13]:A.layerZ):0;i[C+0]=n,i[C+1]=Q,i[C+2]=c?E:0,i[C+3]=c?a:0,i[C+4]=l,i[C+5]=p,i[C+6]=D,i[C+7]=u,i[C+8]=N,g.color?(i[C+9]=g.color[0],i[C+10]=g.color[1],i[C+11]=g.color[2],i[C+12]=g.color[3]):r&&(i[C+9]=1,i[C+10]=1,i[C+11]=1,i[C+12]=1),S&&(i[C+13]=G)}function IF(A,e,g){A._dirtyMin>=A._dirtyMax?(A._dirtyMin=e,A._dirtyMax=g):(e<A._dirtyMin&&(A._dirtyMin=e),g>A._dirtyMax&&(A._dirtyMax=g)),A._version=A._version+1|0,EQ()?.dirty(A,e,g)}function jn(A,e,g){IF(A,e,g)}function Y$(A,e){e.positionPx===void 0&&R(766);const g=A.count;return g>=A._capacity&&oUA(A,g+1),L$(A,g,e,null),A._vertexExtension?._initInstance(A._instanceData,g*A._instanceFloatsPerSprite),NK(A,A.count+1),EQ()?.add(A,g),IF(A,g,g+1),g}function J$(A,e,g){(e<0||e>=A.count)&&R(767,e,A.count);const I=e*A._instanceFloatsPerSprite;L$(A,e,g,A._instanceData.subarray(I,I+A._instanceFloatsPerSprite)),IF(A,e,e+1)}function J5(A,e){(e<0||e>=A.count)&&R(768,e,A.count);const g=A.count-1;A._handleHooks?.removeIndex(e,g),e!==g&&(A._instanceData.copyWithin(e*A._instanceFloatsPerSprite,g*A._instanceFloatsPerSprite,(g+1)*A._instanceFloatsPerSprite),A._savedSize.copyWithin(e*2,g*2,(g+1)*2)),A._savedSize[g*2]=0,A._savedSize[g*2+1]=0,NK(A,g),EQ()?.remove(A,e,g),IF(A,e,e+1)}function rUA(A){const e=A.count;A._dirtyMin=0,A._dirtyMax=0,A._handleHooks?.clear(),e!==0&&(A._savedSize.fill(0,0,e*2),NK(A,0),EQ()?.clear(A,e),A._version=A._version+1|0)}function H5(A,e,g){(e<0||e>=A.count)&&R(769,e,A.count);const I=eF(A.atlas,g),i=A.atlas.frames[I],C=e*A._instanceFloatsPerSprite,o=A._instanceData[C+4]>A._instanceData[C+6],r=A._instanceData[C+5]>A._instanceData[C+7];A._instanceData[C+4]=o?i.uvMax[0]:i.uvMin[0],A._instanceData[C+5]=r?i.uvMax[1]:i.uvMin[1],A._instanceData[C+6]=o?i.uvMin[0]:i.uvMax[0],A._instanceData[C+7]=r?i.uvMin[1]:i.uvMax[1],IF(A,e,e+1)}var x5,H$,GC=b((()=>{rA(),ZA(),gF(),NC(),L5(),x5=null,H$=16}));function BUA(A){q5=A}function T5(){return q5}var q5,x$=b((()=>{q5=null}));function nUA(A){P5=A}function Vn(){return P5}var P5,Wn=b((()=>{P5=null}));function sUA(A,e,g){return`${O5(A,e,g)} @fragment fn fs(in:O)->@location(0)vec4f{let s=textureSample(atlasTex,atlasSamp,in.uv);return s*in.tint*L.opacityMul;}`}function O5(A,e,g=!1,I){const i=`@group(${e})`,C=A?",@location(6)z:f32":"",o=g?",@location(7)o:vec2f":"",r=A?"1 - in.z":"0";return`struct Lr{viewPos:vec2f,viewScale:f32,viewRot:f32,screenSize:vec2f,pivot:vec2f,opacityMul:vec4f,aa:vec4f,};${i} @binding(0)var<uniform>L:Lr;${i} @binding(1)var atlasTex:texture_2d<f32>;${i} @binding(2)var atlasSamp:sampler;struct I{@builtin(vertex_index)vid:u32,@location(0)p:vec2f,@location(1)s:vec2f,@location(2)a:vec2f,@location(3)b:vec2f,@location(4)r:f32,@location(5)c:vec4f${C}${o}${I?._input??""}};struct O{@builtin(position)p:vec4f,@location(0)uv:vec2f,@location(1)tint:vec4f,${I?._output??""}};@vertex fn vs(in:I)->O{var q=array<vec2f,4>(vec2f(0,0),vec2f(1,0),vec2f(1,1),vec2f(0,1));let c=q[in.vid];let l=(c-L.pivot)*in.s;let cr=cos(in.r);let sr=sin(in.r);let r=vec2f(l.x*cr-l.y*sr,l.x*sr+l.y*cr);let p=in.p+r-L.viewPos;let lc=cos(L.viewRot);let ls=sin(L.viewRot);let v=vec2f(p.x*lc-p.y*ls,p.x*ls+p.y*lc)*L.viewScale;let n=vec2f(v.x/L.screenSize.x*2-1,1-v.y/L.screenSize.y*2);let uv=mix(in.a,in.b,c)${g?" + in.o":""};var out:O;out.p=vec4f(n,${r},1);out.uv=uv;out.tint=in.c;${I?._assignment??""} return out;}`}function T$(){return{_devices:new WeakMap}}function q$(A){A._devices=new WeakMap}function QUA(){return aQ??=T$(),mK++,aQ}function P$(){mK>0&&--mK===0&&aQ&&(q$(aQ),aQ=null)}function tF(A,e,g,I,i,C,o=!1,r,B,n,Q="greater-equal"){const E=EUA(A,e),a=aUA(C,r),c=Vn(),l=C&&o&&I>1&&!!n&&!!c?.(n),p=cUA(g,I,i,C,o,a,l,n,Q),D=E._pipelines.get(p);if(D)return D;const u=pUA(A,E,g,I,i,C,o,a,l,B,n,Q);return E._pipelines.set(p,u),u}function O$(A,e,g,I,i,C){const o=I.atlas.texture,r=[{binding:0,resource:{buffer:i}},{binding:1,resource:o.view},{binding:2,resource:o.sampler}];if(C)for(const B of zi().bindEntries(C,3))r.push(B);return A._device.createBindGroup({layout:e.getBindGroupLayout(g),entries:r})}function EUA(A,e){let g=e._devices.get(A._device);return g||(g={_shaderModules:new Map,_pipelines:new Map},e._devices.set(A._device,g)),g}function aUA(A,e){return A?(e||R(781),e):null}function cUA(A,e,g,I,i,C,o,r,B="greater-equal"){const n=r?zi()?.pipelineKeyPart(r)??"":"",Q=r?._uvScrollAttr?"1":"0",E=r?T5()?.pipelineKeyPart(r)??"0":"0";return`${A}:${e}:${g._key}:${I?1:0}:${i?1:0}:${C??"-"}:${I?B:"-"}:${o?"a":"n"}:cs${n}:uv${Q}:cg${E}`}function lUA(A,e,g,I){const i=I?zi()?.shaderModule(A,g,I):null;if(i)return i;const C=I?T5()?.shaderModule(A,g,I):null;if(C)return C;const o=I?._uvScrollAttr!=null,r=`${g?1:0}:${o?1:0}`;let B=e._shaderModules.get(r);return B||(B=A._device.createShaderModule({code:sUA(g,g?1:0,o)}),e._shaderModules.set(r,B)),B}function pUA(A,e,g,I,i,C,o,r,B,n,Q,E="greater-equal"){const a=A._device,c=[{binding:0,visibility:MA.VERTEX|MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:MA.FRAGMENT,sampler:{type:"filtering"}}],l=Q?zi()?.layoutEntries(Q,3):null;if(l)for(const w of l)c.push(w);const p=a.createBindGroupLayout({entries:c}),D=lUA(A,e,C,Q);C&&!n&&R(782);const u=C?[n,p]:[p],_=[{shaderLocation:0,offset:Z$,format:"float32x2"},{shaderLocation:1,offset:X$,format:"float32x2"},{shaderLocation:2,offset:$$,format:"float32x2"},{shaderLocation:3,offset:AAA,format:"float32x2"},{shaderLocation:4,offset:eAA,format:"float32"},{shaderLocation:5,offset:gAA,format:"float32x4"}];C&&_.push({shaderLocation:6,offset:IAA,format:"float32"}),Q?._uvScrollAttr&&_.push(Q._uvScrollAttr);const d=Q?zi()?.vertexAttribute(Q):null;d&&_.push(d);const y=Q?._instanceStrideBytes??(C?56:52),h={layout:a.createPipelineLayout({bindGroupLayouts:u}),vertex:{module:D,entryPoint:"vs",buffers:[{arrayStride:y,stepMode:"instance",attributes:_}]},fragment:{module:D,entryPoint:"fs",targets:[{format:g,blend:i._descriptor,writeMask:yC.ALL}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:B?{count:I,alphaToCoverageEnabled:!0}:{count:I}};return C&&(h.depthStencil={format:r,depthCompare:E,depthWriteEnabled:o}),a.createRenderPipeline(h)}function GK(A,e,g){return A.createBuffer({size:e._capacity*e._instanceStrideBytes,usage:dA.VERTEX|dA.COPY_DST,label:g})}function j$(A,e,g,I,i){const C=e._capacity*e._instanceStrideBytes;return g.size>=C?{buffer:g,capacity:I,reallocated:!1}:(g.destroy(),{buffer:GK(A,e,i),capacity:e._capacity,reallocated:!0})}function V$(A,e,g,I){const i=EQ()?.upload(A,e,g,I);if(i!==void 0)return i;if(I===e._version)return I;if(e.count===0)return e._dirtyMin=0,e._dirtyMax=0,e._version;let C,o;if(I===-1?(C=0,o=e.count):(C=e._dirtyMin,o=Math.min(e._dirtyMax,e.count)),o>C){const r=C*e._instanceStrideBytes,B=(o-C)*e._instanceStrideBytes;A.queue.writeBuffer(g,r,e._instanceData.buffer,e._instanceData.byteOffset+r,B)}return e._dirtyMin=0,e._dirtyMax=0,e._version}function W$(A,e,g,I){I[0]=A.view.positionPx[0],I[1]=A.view.positionPx[1],I[2]=A.view.zoom,I[3]=A.view.rotation,I[4]=e,I[5]=g,I[6]=A.pivot[0],I[7]=A.pivot[1];const i=A.opacity;A.blendMode._premultipliedOpacity?(I[8]=i,I[9]=i,I[10]=i,I[11]=i):(I[8]=1,I[9]=1,I[10]=1,I[11]=i),T5()?.writeUbo(A,I)}function z$(A,e,g,I,i){let C=!i;if(!C){for(let o=0;o<16;o++)if(I[o]!==g[o]){C=!0;break}}return C&&(A.queue.writeBuffer(e,0,g.buffer,g.byteOffset,64),I.set(g)),!0}var Z$,X$,$$,AAA,eAA,gAA,IAA,aQ,mK,FK,iF=b((()=>{rA(),ZA(),te(),GC(),NC(),x$(),Wn(),Z$=0,X$=8,$$=16,AAA=24,eAA=32,gAA=36,IAA=52,aQ=null,mK=0,FK=new ni([0,1,2,0,2,3])})),DUA=H({rebuildRegisteredSpriteRenderers:()=>uUA});async function uUA(A){const e=[],g=new Set;for(const I of A.surfaces)for(const i of I._renderingContexts){if(i._kind!=="sprite-renderer")continue;const C=i;e.push(C),C._target&&g.add(C._target);for(const o of C.layers){g.add(o.atlas.texture);for(const r of o.customShader?._extraTextures??[])g.add(r.texture)}}if(g.size>0){const{rebuildTexture2D:I}=await Promise.resolve().then(()=>(GY(),NY));await Promise.all(Array.from(g,i=>I(A,i)))}for(const I of e)_UA(I)}function _UA(A){const e=A._surface.engine,g=zi();A._indexBuffer=dg(e,FK,dA.INDEX),A._targetView=A._target?.view??null,A._visibleBundles.length=0;for(const I of A._layerGpu.values())I.instanceBuffer=GK(e._device,I.layer),I.instanceBufferCapacity=I.layer._capacity,I.uniformBuffer=Lt(e,64),I.bindGroup=null,I.uploadedVersion=-1,I.fx&&(g.disposeFx(I.fx),I.fx=g.createLayerFx(e,"sprite-layer-fx-ubo",I.layer)),I.pipeline=null,I.lastUbo.fill(0),I.uboUploaded=!1,I.renderBundle=null,I.bundleCount=-1;for(const I of A.layers)tF(e,A._pipelineCache,A._surface.format,1,I.blendMode,!1,!1,void 0,void 0,I)}var dUA=b((()=>{te(),b1(),yt(),NC(),iF()}));function fUA(A,e={}){return v3(A,{_kind:"sprite-renderer",_enable:PZ,_disable:OZ,async _recover(g){const{rebuildRegisteredSpriteRenderers:I}=await Promise.resolve().then(()=>(dUA(),DUA));await I(g)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function yUA(A){KK=A}function j5(A){return KK?._key(A)??A.curveSet}function hUA(A,e,g,I,i,C,o,r){const B=I._atlas._glyphSlots.get(i);if(!B)return!1;const n=B._index;if(n>Z5||r>Z5)return!1;const Q=g*3;return A[Q]=C,A[Q+1]=o,e[Q+2]=n|r<<16,!0}function tAA(A,e,g){const I=g*3;A[I]=0,A[I+1]=0,e[I+2]=_AA}function iAA(A,e){e>cQ&&R(787,cQ);const g=e*8;if(A._styles.length>=g)return;let I=Math.max(A._styles.length*2,8);for(;I<g;)I*=2;I=Math.min(I,cQ*8);const i=new Float32Array(I);i.set(A._styles),A._styles=i}function CF(A){const e=A.glyphs;let g=1;for(let I=0;I<e.length;I++)e[I].color!==void 0&&g++;return g}function CAA(A,e){for(let g=0;g<e.length;g++)A._freeStyleSlots.push(e[g])}function oAA(A,e,g){if(g?.length===e)return g;const I=A._freeStyleSlots,i=Math.max(0,e-I.length-(g?.length??0));iAA(A,A._styleCount+i),g&&CAA(A,g);const C=A._styleCount,o=new Array(e);for(let r=0;r<e;r++)o[r]=I.pop()??A._styleCount++;return A._styleCount!==C&&A._styleVersion++,o}function rAA(A,e,g,I,i){const C=e*8,o=A._styles,r=Math.fround(g[0]),B=Math.fround(g[1]),n=Math.fround(g[2]),Q=Math.fround(g[3]),E=Math.fround(I),a=Math.fround(i);o[C]===r&&o[C+1]===B&&o[C+2]===n&&o[C+3]===Q&&o[C+4]===E&&o[C+5]===a||(o[C]=r,o[C+1]=B,o[C+2]=n,o[C+3]=Q,o[C+4]=E,o[C+5]=a,A._styleVersion++)}function wUA(A,e){const g=e*3;if(A._instances.length>=g)return;let I=Math.max(A._instances.length*2,3);for(;I<g;)I*=2;const i=new Float32Array(I);i.set(A._instances.subarray(0,A._instanceCount*3)),A._instances=i,A._instancesU32=new Uint32Array(i.buffer),A._dirtyStart=0,A._dirtyEnd=A._instanceCount}function bK(A,e,g){g<=e||(A._dirtyStart===A._dirtyEnd?(A._dirtyStart=e,A._dirtyEnd=g):(e<A._dirtyStart&&(A._dirtyStart=e),g>A._dirtyEnd&&(A._dirtyEnd=g)),A._version++)}function MUA(A){return A._freeSlots.length>0?A._freeSlots.pop():-1}function BAA(A,e,g,I){for(const i of A._groups)if(i!==I&&i._slotStart>=e){i._slotStart+=g;for(let C=0;C<i._freeSlots.length;C++)i._freeSlots[C]=i._freeSlots[C]+g}for(const i of A._runRecords.values()){const C=i._slots;for(let o=0;o<C.length;o++)C[o]>=e&&(C[o]=C[o]+g)}A._layoutVersion++}function RUA(A,e,g){const I=e._slotStart+e._slotCount;if(g<=0)return I;wUA(A,A._instanceCount+g);const i=g*3,C=I*3,o=A._instanceCount*3;return o>C&&A._instances.copyWithin(C+i,C,o),BAA(A,I,g,e),A._instanceCount+=g,e._slotCount+=g,bK(A,I,A._instanceCount),I}function nAA(A,e,g){const I=new Array(g).fill(-1);let i=!0,C=-1,o=g;for(let r=0;r<g;r++){const B=MUA(e);if(B===-1){o=r;break}I[r]=B,i&&=B>=C,C=B}if(o<g){const r=RUA(A,e,g-o);i&&=r>=C;for(let B=o,n=r;B<g;B++)I[B]=n++}return i||I.sort(SUA),I}function SUA(A,e){return A-e}function sAA(A,e,g){let I=Number.POSITIVE_INFINITY,i=-1;for(const C of g)tAA(A._instances,A._instancesU32,C),e._freeSlots.push(C),C<I&&(I=C),C>i&&(i=C);i>=0&&bK(A,I,i+1)}function NUA(A,e){for(const g of A._groups)if(g._groupKey===e)return g}function kK(A,e,g){const I=A._curveSets.get(e);return I||R(788,g,e),I}function QAA(A,e,g,I){return{_curveSetId:A,_curveSet:e,_slotStart:g,_slotCount:0,_liveCount:0,_freeSlots:[],_bindGroup:null,_bindGroupVersion:-1,_groupKey:I}}function GUA(A,e,g){const I=NUA(A,g);if(I)return I;const i=QAA(e,kK(A._storage,e,"addRun"),A._instanceCount,g);return A._groups.push(i),i}function V5(A,e,g,I,i){const C=g.pixelsPerFontUnit,o=C!==0?1/C:0,r=KK?._param(g)??0,B=i[0];rAA(A,B,g.defaultColor??dAA,o,r);let n=0,Q=null,E=Number.POSITIVE_INFINITY,a=-1;for(let c=0;c<g.glyphs.length;c++){const l=g.glyphs[c],p=I[c];let D=B;const u=l.color;u!==void 0&&(D=i[++n],rAA(A,D,u,o,r)),hUA(A._instances,A._instancesU32,p,e._curveSet,l.glyphId,l.x,l.y,D)?Q!==null&&Q.push(p):(Q===null&&(Q=I.slice(0,c)),tAA(A._instances,A._instancesU32,p),e._freeSlots.push(p)),p<E&&(E=p),p>a&&(a=p)}return a>=0&&bK(A,E,a+1),Q??I}function EAA(A,e,g){let I=0,i=0;for(const E of e)I+=E.glyphs.length,i+=CF(E);iAA(A,i);const C=I*3;if(A._instances.length<C){let E=Math.max(A._instances.length*2,3);for(;E<C;)E*=2;A._instances=new Float32Array(E),A._instancesU32=new Uint32Array(A._instances.buffer)}const o=new Map;for(const E of A._groups)o.set(E._groupKey,E);A._storage=g;const r=new Map;for(const E of e){const a=j5(E);let c=r.get(a);c||(c=[],r.set(a,c)),c.push(E)}const B=[],n=new Map;let Q=0;A._styleCount=0,A._freeStyleSlots.length=0,A._styleVersion++;for(const[E,a]of r){const c=a[0].curveSet,l=kK(g,c,"reset"),p=o.get(E)??QAA(c,l,Q,E);p._curveSet!==l&&(p._curveSet=l,p._bindGroup=null,p._bindGroupVersion=-1),p._slotStart=Q,p._freeSlots=[];const D=B.length;let u=0;for(const _ of a){const d=new Array(_.glyphs.length).fill(-1);for(let M=0;M<_.glyphs.length;M++)d[M]=Q++;const y=CF(_),h=new Array(y);for(let M=0;M<y;M++)h[M]=A._styleCount++;const w=V5(A,p,_,d,h);u+=w.length,n.set(_,{_run:_,_groupIdx:D,_slots:w,_styleSlots:h})}p._slotCount=Q-p._slotStart,p._liveCount=u,B.push(p)}A._instanceCount=Q,A._groups=B,A._runs.length=0;for(const E of e)A._runs.push(E);A._runRecords=n,A._dirtyStart=0,A._dirtyEnd=Q,A._version++,A._layoutVersion++}function aAA(A,e){return typeof e=="number"?cAA(A,e,"updateTextData"):e}function cAA(A,e,g){if(typeof e=="number"){const I=A._runs[e];return I||R(789,g,e,A._runs.length-1),I}return A._runRecords.has(e)||R(790,g),e}function W5(A,e){return typeof e=="number"?e:A._runs.indexOf(e)}function lAA(A,e,g){A._runRecords.has(e)&&R(791);const I=g??A._runs.length;kK(A._storage,e.curveSet,"addRun");const i=oAA(A,CF(e)),C=GUA(A,e.curveSet,j5(e)),o=A._groups.indexOf(C),r=V5(A,C,e,nAA(A,C,e.glyphs.length),i);C._liveCount+=r.length,A._runRecords.set(e,{_run:e,_groupIdx:o,_slots:r,_styleSlots:i}),A._runs.splice(I,0,e)}function pAA(A,e){const g=aAA(A,e),I=A._runRecords.get(g);I||R(792);const i=A._groups[I._groupIdx];sAA(A,i,I._slots),i._liveCount-=I._slots.length,CAA(A,I._styleSlots),A._runRecords.delete(g);const C=W5(A,e);C>=0&&A._runs.splice(C,1),i._liveCount===0&&mUA(A,i)}function mUA(A,e){const g=A._groups.indexOf(e);if(g<0)return;const I=e._slotStart,i=e._slotCount;A._groups.splice(g,1);for(const C of A._runRecords.values())C._groupIdx>g&&C._groupIdx--;if(i>0){const C=i*3,o=(I+i)*3,r=A._instanceCount*3;r>o&&A._instances.copyWithin(o-C,o,r),BAA(A,I,-i),A._instanceCount-=i,bK(A,I,A._instanceCount)}}function FUA(A,e,g){const I=aAA(A,e),i=A._runRecords.get(I);i||R(793),I!==g&&A._runRecords.has(g)&&R(794);const C=A._groups[i._groupIdx];if(j5(g)===C._groupKey&&g.glyphs.length>0){const r=oAA(A,CF(g),i._styleSlots),B=i._slots.length;let n=i._slots;g.glyphs.length!==B&&(sAA(A,C,n),n=nAA(A,C,g.glyphs.length));const Q=V5(A,C,g,n,r);if(C._liveCount+=Q.length-B,I===g)i._slots=Q,i._styleSlots=r;else{A._runRecords.delete(I),A._runRecords.set(g,{_run:g,_groupIdx:i._groupIdx,_slots:Q,_styleSlots:r});const E=W5(A,e);E>=0&&(A._runs[E]=g)}return}const o=W5(A,e);kK(A._storage,g.curveSet,"replaceRun"),CF(g)>A._freeStyleSlots.length+i._styleSlots.length+cQ-A._styleCount&&R(795,cQ),pAA(A,o>=0?o:I),lAA(A,g,o>=0?o:void 0)}function DAA(A,e){const g=[],I=new Float32Array(3),i={runs:g,_runs:g,_groups:[],_runRecords:new Map,_instances:I,_instancesU32:new Uint32Array(I.buffer),_instanceCount:0,_styles:new Float32Array(8),_styleCount:0,_freeStyleSlots:[],_styleVersion:1,_storage:A,_version:1,_layoutVersion:0,_dirtyStart:0,_dirtyEnd:0};return e&&e.length>0&&EAA(i,e,A),i}function z5(A,e){switch(e.update){case"reset":EAA(A,e.runs??A._runs.slice(),e.storage??A._storage);return;case"addRun":lAA(A,e.run,e.insertBefore);return;case"removeRun":pAA(A,e.run);return;case"replaceRun":FUA(A,e.previous,e.run);return}}function uAA(A){for(const e of A._groups)e._bindGroup=null;A._groups=[],A._instanceCount=0,A._styleCount=0,A._freeStyleSlots.length=0,A._runs.length=0,A._runRecords.clear()}var _AA,Z5,cQ,dAA,KK,Or=b((()=>{rA(),_AA=4294967295,Z5=65534,cQ=65535,dAA=[1,1,1,1],KK=null}));function UK(A,e){return A.createBuffer({label:"text-styles",size:e*32,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})}function fAA(A,e,g){const I=Math.max(1,e._styleCount);let i=!1;if(I*32>g._styleBuf.size&&(g._styleBuf.destroy(),g._styleBuf=UK(A,e._styles.byteLength/32),g._uploadedStyleVersion=-1,i=!0),g._uploadedStyleVersion!==e._styleVersion){if(e._styleCount>0){const C=e._styles;A.queue.writeBuffer(g._styleBuf,0,C.buffer,C.byteOffset,e._styleCount*32)}g._uploadedStyleVersion=e._styleVersion}return i}var X5=b((()=>{Or()}));function yAA(A){const e=new Map;if(A)for(const[g,I]of A)e.set(g,MAA(I));return{_curveSets:e}}function hAA(A,e,g){let I=A._curveSets.get(e);I||(I=MAA(new Map),A._curveSets.set(e,I));for(const[i,C]of g)I._curves.has(i)||(I._curves.set(i,C),I._atlas._glyphSlots.set(i,SAA(I._atlas,C)))}function wAA(A){for(const e of A._curveSets.values()){const g=e._atlas._gpu;g&&(g._curveTex.destroy(),g._bandTex.destroy(),g._metaBuf.destroy(),e._atlas._gpu=null)}A._curveSets.clear()}function bUA(){return{_curveTexData:new Float32Array(lQ),_curveTexelsUsed:0,_bandTexData:new Float32Array(lQ),_bandTexelsUsed:0,_glyphSlots:new Map,_metaData:new Float32Array(192),_slotCount:0,_version:0,_gpu:null}}function MAA(A){const e=bUA();for(const[g,I]of A)e._glyphSlots.set(g,SAA(e,I));return{_curves:A,_atlas:e}}function RAA(A,e){const g=e*4;if(A.length>=g)return A;let I=Math.max(A.length*2,lQ);for(;I<g;)I*=2;I=Math.ceil(I/lQ)*lQ;const i=new Float32Array(I);return i.set(A),i}function SAA(A,e){const g=KUA(e),I=e.curves;let i=A._curveTexelsUsed;const C=new Array(I.length);for(let K=0;K<I.length;K++){const U=i/mC|0,Y=(i+1)/mC|0;U!==Y&&(i=Y*mC),C[K]=i,i+=2}const o=i;A._curveTexData=RAA(A._curveTexData,o);const r=A._curveTexData;for(let K=0;K<I.length;K++){const U=I[K],Y=C[K],x=Y*4;r[x]=U.p0x,r[x+1]=U.p0y,r[x+2]=U.p1x,r[x+3]=U.p1y;const q=(Y+1)*4;r[q]=U.p2x,r[q+1]=U.p2y}A._curveTexelsUsed=o;const B=g._hBandCount+g._vBandCount;let n=A._bandTexelsUsed;n%4096+B>4096&&(n=((n/mC|0)+1)*mC);const Q=n%mC,E=n/mC|0,a=[...g._hBands,...g._vBands];let c=B;const l=new Array(a.length);for(let K=0;K<a.length;K++)l[K]=c,c+=a[K]._curveIndices.length;const p=n+c;A._bandTexData=RAA(A._bandTexData,p);const D=A._bandTexData;for(let K=0;K<a.length;K++){const U=(n+K)*4;D[U]=a[K]._curveIndices.length,D[U+1]=l[K]}for(let K=0;K<a.length;K++){const U=a[K],Y=n+l[K];for(let x=0;x<U._curveIndices.length;x++){const q=C[U._curveIndices[x]],j=q%mC,X=q/mC|0,Z=(Y+x)*4;D[Z]=j,D[Z+1]=X}}A._bandTexelsUsed=p,A._version++;const{xMin:u,yMin:_,xMax:d,yMax:y}=e.bounds,h=d-u,w=y-_,M=h>0?g._vBandCount/h:0,N=w>0?g._hBandCount/w:0,S=A._slotCount++,G=A._slotCount*12;if(A._metaData.length<G){const K=new Float32Array(Math.max(A._metaData.length*2,G));K.set(A._metaData),A._metaData=K}const m=S*12,k=A._metaData;return k[m]=u,k[m+1]=_,k[m+2]=d,k[m+3]=y,k[m+4]=Q,k[m+5]=E,k[m+6]=g._vBandCount-1,k[m+7]=g._hBandCount-1,k[m+8]=M,k[m+9]=N,k[m+10]=-u*M,k[m+11]=-_*N,{_index:S}}function oF(A,e){const g=A[e];if(!g)throw new Error("buildGlyphBands: invalid curve index");return g}function kUA(A){const{curves:e,bounds:g}=A,I=Math.max(1,Math.min(8,Math.floor(e.length/2))),{xMin:i,yMin:C,xMax:o,yMax:r}=g,B=o-i,n=r-C,Q=n/I,E=B/I,a=[],c=[];for(let l=0;l<I;l++)a.push({_curveIndices:[]}),c.push({_curveIndices:[]});for(let l=0;l<e.length;l++){const p=oF(e,l),D=Math.min(p.p0y,p.p1y,p.p2y),u=Math.max(p.p0y,p.p1y,p.p2y),_=Math.min(p.p0x,p.p1x,p.p2x),d=Math.max(p.p0x,p.p1x,p.p2x);if(n>0)for(let y=0;y<I;y++){const h=C+y*Q,w=C+(y+1)*Q;u>=h&&D<=w&&a[y]._curveIndices.push(l)}if(B>0)for(let y=0;y<I;y++){const h=i+y*E,w=i+(y+1)*E;d>=h&&_<=w&&c[y]._curveIndices.push(l)}}for(const l of a)l._curveIndices.sort((p,D)=>{const u=oF(e,p),_=oF(e,D);return Math.max(_.p0x,_.p1x,_.p2x)-Math.max(u.p0x,u.p1x,u.p2x)});for(const l of c)l._curveIndices.sort((p,D)=>{const u=oF(e,p),_=oF(e,D);return Math.max(_.p0y,_.p1y,_.p2y)-Math.max(u.p0y,u.p1y,u.p2y)});return{_hBands:a,_vBands:c,_hBandCount:I,_vBandCount:I}}function KUA(A){return A._bands??=kUA(A)}var mC,lQ,$5=b((()=>{mC=4096,lQ=mC*4}));function pQ(A){let e=1;for(;e<A;)e<<=1;return e}function NAA(A,e){return A.createBuffer({label:"text-glyph-metadata",size:e*g6,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST})}function A6(A){return A<=0?1:Math.ceil(A/rF)}function vK(A,e,g){return A.createTexture({label:g,format:"rgba32float",size:{width:rF,height:e,depthOrArrayLayers:1},usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC})}function GAA(A,e,g,I){if(I===0)return;const i=A6(I);A.queue.writeTexture({texture:e},g.buffer,{offset:g.byteOffset,bytesPerRow:mAA,rowsPerImage:i},{width:rF,height:i,depthOrArrayLayers:1})}function e6(A,e){let g=e._gpu;const I=A6(e._curveTexelsUsed),i=A6(e._bandTexelsUsed),C=Math.max(1,e._slotCount);g&&g._device!==A&&(g._curveTex.destroy(),g._bandTex.destroy(),g._metaBuf.destroy(),g=null);let o=!1;if(g)I>g._curveTexRows&&(g._curveTex.destroy(),g._curveTexRows=pQ(I),g._curveTex=vK(A,g._curveTexRows,"text-slug-curves"),g._uploadedVersion=-1,o=!0),i>g._bandTexRows&&(g._bandTex.destroy(),g._bandTexRows=pQ(i),g._bandTex=vK(A,g._bandTexRows,"text-slug-bands"),g._uploadedVersion=-1,o=!0),C>g._metaCap&&(g._metaBuf.destroy(),g._metaCap=pQ(C),g._metaBuf=NAA(A,g._metaCap),g._uploadedVersion=-1,o=!0);else{const r=pQ(Math.max(1,I)),B=pQ(Math.max(1,i)),n=pQ(C);g={_device:A,_curveTex:vK(A,r,"text-slug-curves"),_bandTex:vK(A,B,"text-slug-bands"),_curveTexRows:r,_bandTexRows:B,_metaBuf:NAA(A,n),_metaCap:n,_uploadedVersion:-1},e._gpu=g,o=!0}if(g._uploadedVersion!==e._version){if(GAA(A,g._curveTex,e._curveTexData,e._curveTexelsUsed),GAA(A,g._bandTex,e._bandTexData,e._bandTexelsUsed),e._slotCount>0){const r=e._metaData;A.queue.writeBuffer(g._metaBuf,0,r.buffer,r.byteOffset,e._slotCount*g6)}g._uploadedVersion=e._version}return{_rebuilt:o,_gpu:g}}var rF,mAA,g6,I6=b((()=>{$5(),rF=4096,mAA=rF*4*4,g6=48})),UUA=H({rebuildRegisteredTextRenderers:()=>vUA});function vUA(A){for(const e of A.surfaces)for(const g of e._renderingContexts)g._kind==="text-renderer"&&LUA(g)}function LUA(A){const e=A._surface.engine,g=e._device;A._visibleBundles.length=0;for(const I of A._layerGpu.values())I._textU=Lt(e,FAA,"text-layer-ubo"),I._instanceBuf=g.createBuffer({label:"text-layer-instances",size:I._instanceCap*12,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),I._styleBuf=UK(g,I._styleBuf.size/32),I._uploadedStyleVersion=-1,I._pipeline=null,I._bindGroupCache.length=0,I._uploadedDataVersion=-1,I._uploadedViewportW=0,I._uploadedViewportH=0,I._lastMvpInputs.fill(0),I._mvpUploaded=!1,I._renderBundle=null,I._bundleLayoutVersion=-1,I._bundleDrawCalls=0;for(const I of A.layers)for(const i of I.data._groups)e6(g,i._curveSet._atlas);A._update()}var FAA,YUA=b((()=>{b1(),X5(),I6(),Or(),FAA=96}));function JUA(A,e={}){return v3(A,{_kind:"text-renderer",async _recover(g){const{rebuildRegisteredTextRenderers:I}=await Promise.resolve().then(()=>(YUA(),UUA));I(g)},_onLost:e.onLost,_onRecovered:e.onRecovered,_onRecoveryFailed:e.onRecoveryFailed})}function io(A){A._refCount=(A._refCount??1)+1}function oC(A){const e=A._refCount;return e===void 0||e<=1?!0:(A._refCount=e-1,!1)}var zn=b((()=>{})),bAA=H({rebuildScenePbrPipelines:()=>t6,rebuildSceneRenderables:()=>i6});async function t6(A,e=!1){await kAA(A,"pbr",e)}async function i6(A){await kAA(A,void 0,!1)}async function kAA(A,e,g){const I=A;if(!I._built&&!g)return;const i=I._lightListVersion??0,C=I.surface.engine,o=D=>{I._z?D.forEach(u=>u()):et(C,()=>D.forEach(u=>u()))};let r=!1,B=!1,n=!1,Q=!1;try{for(let D=1;;D++){if(e!==void 0){await E();break}if(c(I),await E(),!a(I))break;if(D>=UAA){I._rebuildHook=LK,Q=!0,B=!0;break}}n=!0}finally{if(r&&(I._renderables.sort(KAA),I._renderableVersion++,I._materialEpoch++,I._built&&I._frameGraph.build()),e===void 0&&n&&!B&&(I._lightListVersion??0)===i){const D=I._pendingTopologyRetirements?.splice(0);D?.length&&o(D),Q||(I._rebuildHook=void 0)}}async function E(){for(const[D,u]of I._groups){if(e!==void 0&&D._materialFamily!==e)continue;if(u.length===0){(u.o||u.r)&&(l(D,u),r=!0);continue}const _=I._runtimeBuilds;await _?.wait(u);let d=!1;const y=async()=>{const M=I._runtimeBuilds,N=[...u].filter(AA=>I.meshes.includes(AA)&&AA.material?._buildGroup===D);if(N.length===0){l(D,u);return}const S=!!u.r,G=I._disposables.length,m=new Map,k=new Map(N.map(AA=>[AA,AA.material]));for(const AA of N){const z=I._meshDisposables.get(AA);z&&(m.set(AA,z),I._meshDisposables.delete(AA),M?.holdPendingDisposers(AA,z))}let K,U;I._p=AA=>(U=AA,!0);try{K=await D(I,N)}catch(AA){U?.[1]();for(const z of N){const IA=m.get(z),sA=I._meshDisposables.get(z);if(sA&&sA!==IA)for(const EA of sA)EA();const DA=I.meshes.includes(z)&&z.material===k.get(z)&&z.material?._buildGroup===D&&u.includes(z);IA&&DA?I._meshDisposables.set(z,IA):(I._meshDisposables.delete(z),IA&&o(IA)),IA&&M?.releasePendingDisposers(z,IA)}throw AA}finally{delete I._p}if(I._z||_?._d()){U?.[1]();for(const z of N){const IA=I._meshDisposables.get(z),sA=m.get(z);if(IA&&IA!==sA)for(const DA of IA)DA();I._meshDisposables.delete(z)}for(const z of I._disposables.splice(0))z();const AA=[...m.values()].flat();o(AA);for(const[z,IA]of m)M?.releasePendingDisposers(z,IA);return}U?.[0](),D._rebuildSingle=K.rebuildSingle,u.r=I._runtimeBuilds?.base(D,K.rebuildSingle)??K.rebuildSingle,D._materialFamily==="pbr"&&K._G&&(u._w=null),S&&p(I,G);const Y=new Set(N.filter(AA=>I.meshes.includes(AA)&&AA.material===k.get(AA)&&AA.material?._buildGroup===D&&u.includes(AA)));if(Y.size!==N.length&&K.renderables.some(AA=>!AA.mesh)){for(const AA of N){const z=I._meshDisposables.get(AA),IA=m.get(AA);if(z&&z!==IA)for(const sA of z)sA();IA&&I.meshes.includes(AA)?I._meshDisposables.set(AA,IA):(I._meshDisposables.delete(AA),IA&&o(IA)),IA&&M?.releasePendingDisposers(AA,IA)}d=!0;return}const x=new Set;for(const AA of N){if(!Y.has(AA)){const z=m.get(AA),IA=I._meshDisposables.get(AA);if(IA&&IA!==z)for(const sA of IA)sA();z&&I.meshes.includes(AA)?(I._meshDisposables.set(AA,z),m.delete(AA),M?.releasePendingDisposers(AA,z)):I._meshDisposables.delete(AA);continue}x.add(AA.material),I._runtimeBuilds?.reset(AA)}for(const AA of x)AA._csmGen=(AA._csmGen??0)+1;const q=u.o,j=q?.length?new Set(q):null;for(let AA=I._renderables.length-1;AA>=0;AA--){const z=I._renderables[AA];(Y.has(z.mesh)||j?.has(z))&&I._renderables.splice(AA,1)}const X=K.renderables.filter(AA=>!AA.mesh||Y.has(AA.mesh));I._renderables.push(...X),u.o=X;const Z=[...m.values()].flat();o(Z);for(const[AA,z]of m)M?.releasePendingDisposers(AA,z)},{X:h}=await Promise.resolve().then(()=>(xK(),JK)),w=3;for(let M=1;;M++){if(d=!1,await h(I,D,y),I._z||_?._d()){B=!0;return}if(!d)break;if(M>=w){l(D,u),I._rebuildHook=LK,Q=!0,B=!0;break}}if(d){r=!0;continue}r=!0}}function a(D){for(const u of D.meshes){const _=u.material?._buildGroup;if(_&&!D._groups.get(_)?.includes(u))return!0}return!1}function c(D){const u=new Map;for(const _ of D.meshes){const d=_.material?._buildGroup;if(!d)continue;const y=u.get(d);y?y.push(_):u.set(d,[_])}for(const[_,d]of D._groups){const y=u.get(_)??[];(d.length!==y.length||y.some((h,w)=>d[w]!==h))&&(d.length=0,d.push(...y)),u.delete(_)}for(const[_,d]of u){const y=d;D._groups.set(_,y)}}function l(D,u){const _=u.o;if(_?.length){const d=new Set(_);for(let y=I._renderables.length-1;y>=0;y--)d.has(I._renderables[y])&&I._renderables.splice(y,1)}u.o=void 0,u.r=void 0,I._runtimeBuilds?.dropBase(D),I._rebuildHook=LK,Q=!0}function p(D,u){const _=new Set(D._disposables.slice(0,u));for(let d=D._disposables.length-1;d>=u;d--)_.has(D._disposables[d])&&D._disposables.splice(d,1)}}var KAA,UAA,LK,YK=b((()=>{kI(),KAA=(A,e)=>A.order-e.order,UAA=8,LK=A=>i6(A)})),JK=H({A:()=>LAA,B:()=>YAA,C:()=>HUA,X:()=>xUA});function vAA(A,e,g){A.pendingDisposers.set(e,g)}function C6(A,e,g){g&&A.pendingDisposers.get(e)===g&&A.pendingDisposers.delete(e)}function LAA(A,e,g,I){if(!e||g.material!==e)return I??Promise.resolve();const i=YAA(A,e._buildGroup,g);return I?Promise.all([I,i]).then(()=>{}):i}function HUA(A,e,g){let I=g;for(const i of e){const C=Array.isArray(i),o=C?i[0]:i;I=LAA(A,C?i[1]:o.material,o,I)}return(I??Promise.resolve()).catch(i=>{A._runtimeBuilds?._x(i)})}function YAA(A,e,g){if(A._z||!A.meshes.includes(g))return A._runtimeBuilds?.all().catch(()=>{})??Promise.resolve();TUA(A,e,g);const I=A._runtimeBuilds??JAA(A);return e._materialFamily==="pbr"&&(A._built||A._groups.get(e)?.r)?(I._n||(I._l=Promise.resolve(I._l).then(()=>Promise.resolve().then(()=>(YK(),bAA))).finally(()=>{I._n=void 0}).then(({rebuildScenePbrPipelines:i})=>A._z?void 0:i(A,!0)).catch(i=>{A._runtimeBuilds?._x(i)}),I._n=I.track(I._l)),I._n):I.queue(e,g).catch(()=>{})}function xUA(A,e,g){return A._z?Promise.resolve(void 0):(A._runtimeBuilds??JAA(A)).exclusive(e,g)}function JAA(A){const e={disposed:!1,error:null,active:new Set,chains:new WeakMap,generations:new WeakMap,installed:new WeakMap,installedMeshes:new Set,pendingDisposers:new WeakMap,tail:null},g=A,I={queue:(i,C)=>{const o=(e.generations.get(C)??0)+1,r=C.material;e.generations.set(C,o);const B=e.chains.get(C),n=[e.tail,Jo?.get(i)].filter(c=>!!c);let Q=()=>{};const E=new Promise(c=>{Q=c});e.tail=E,(Jo??=new WeakMap).set(i,E);const a=(B?B.catch(()=>{}):Promise.resolve()).then(()=>Promise.all(n)).then(()=>qUA(A,e,i,C,r,o)).catch(c=>{throw HK(A,e,i,C,r,o)&&(e.error=c instanceof Error?c:new Error("Runtime mesh build failed",{cause:c})),c}).finally(()=>{Q(),e.tail===E&&(e.tail=null),Jo?.get(i)===E&&Jo.delete(i)}).finally(()=>{e.chains.get(C)===a&&e.chains.delete(C)});return e.chains.set(C,a),I.track(a)},all:()=>Promise.all(e.active).then(()=>{}),track:i=>{const C=i.finally(()=>e.active.delete(C));return e.active.add(C),Promise.all(e.active).then(()=>{})},base:(i,C)=>{const o=jr?.get(i);return o&&o.bases.set(A,C),o?.dispatch??C},get w(){return!!e.tail},pendingDisposers:i=>e.pendingDisposers.get(i),holdPendingDisposers:(i,C)=>vAA(e,i,C),releasePendingDisposers:(i,C)=>C6(e,i,C),reset:i=>{xAA(A,e,i),g._pbrMeshGeomContexts?.delete(i)},remove:i=>{e.generations.set(i,(e.generations.get(i)??0)+1),e.chains.delete(i),HAA(A,e,i),g._pbrMeshGeomContexts?.delete(i)},dropBase:i=>{const C=jr?.get(i);C&&(C.bases.delete(A),C.scenes.delete(A))},wait:async i=>{const C=new Set;for(const o of i){const r=e.chains.get(o);r&&C.add(r)}await Promise.all(C)},_e:(i=!0)=>{if(e.error){const C=e.error;throw i&&(e.error=null),C}},_x:i=>{e.error=i instanceof Error?i:new Error("Runtime mesh build failed",{cause:i})},_d:()=>e.disposed,exclusive:(i,C)=>{const o=[];e.tail&&o.push(e.tail);const r=Jo?.get(i);r&&o.push(r);const B=Promise.all(o).then(C),n=B.then(()=>{},()=>{});return e.tail=n,(Jo??=new WeakMap).set(i,n),n.then(()=>{e.tail===n&&(e.tail=null),Jo?.get(i)===n&&Jo.delete(i)}),B}};return A._runtimeBuilds=I,(A._beforeRender??=[]).push(()=>{I._e()}),A._disposables.push(()=>{e.disposed=!0,e.active.clear();for(const i of e.installedMeshes)xAA(A,e,i);for(const i of A._groups.keys())jr?.get(i)?.bases.delete(A);A._runtimeBuilds=void 0,g._pbrMeshGeomContexts=void 0}),I}function TUA(A,e,g){for(const[i,C]of A._groups)if(i!==e){const o=C.indexOf(g);o>=0&&C.splice(o,1)}let I=A._groups.get(e);I||(I=[],A._groups.set(e,I)),I.includes(g)||I.push(g)}async function qUA(A,e,g,I,i,C){if(!HK(A,e,g,I,i,C))return;const o=A._meshDisposables.get(I);o&&(A._meshDisposables.delete(I),vAA(e,I,o));const r=g._rebuildSingle,B=jr?.get(g)?.bases.get(A)??A._groups.get(g)?.r,n=!!A._groups.get(g)?.r,Q=A._disposables.length,E=A,a=E._pbrGeomContext;let c,l;try{l=await g(A,[I]),c=E._pbrGeomContext}catch(u){if(TAA(A,e,I,o),qAA(A,e),!HK(A,e,g,I,i,C))return;throw u}finally{g._rebuildSingle=r,g._materialFamily==="pbr"&&n&&(E._pbrGeomContext=a)}if(!HK(A,e,g,I,i,C)){TAA(A,e,I,o),qAA(A,e);return}for(let u=A._renderables.length-1;u>=0;u--)A._renderables[u].mesh===I&&A._renderables.splice(u,1);if(o){for(const u of o){const _=A._disposables.indexOf(u);_>=0&&A._disposables.splice(_,1);const d=u.p;if(d){d._disposed=!0;const y=d._owner;if(y){const h=y.indexOf(d);h>=0&&y.splice(h,1),d._owner=void 0,y.length===0&&d._onOwnerEmpty?.()}else d._onOwnerEmpty?.();d._onOwnerEmpty&&(d._onOwnerEmpty=void 0)}}et(A.surface.engine,()=>{for(const u of o)u()})}C6(e,I,o),A._renderables.push(...l.renderables);const p=A._groups.get(g);p&&(p.o=[...(p.o??[]).filter(u=>u.mesh!==I),...l.renderables]),l.updater&&A._uniformUpdaters.push(l.updater),n&&OUA(A,Q),g._materialFamily==="pbr"&&n&&c&&(E._pbrMeshGeomContexts??=new WeakMap).set(I,c),PUA(A,e,g,I,l.rebuildSingle,n?B:l.rebuildSingle),I.material._csmGen=(I.material._csmGen??0)+1;const D=A._groups.get(g);D&&!n&&(D.r=l.rebuildSingle),A._renderables.sort(PAA),A._renderableVersion++,A._materialEpoch++}function PUA(A,e,g,I,i,C){let o=jr?.get(g);if(!o){const Q=new WeakMap,E=new WeakMap;o={bases:E,dispatch:(c,l,p,D)=>{const u=Q.get(c)?.get(l);if(u)return u(c,l,p,D);const _=E.get(c)??c._groups.get(g)?.r;if(_)return _(c,l,p,D);throw new Error("Material group has not completed its initial build")},scenes:Q},(jr??=new WeakMap).set(g,o)}let r=o.scenes.get(A);r||(r=new WeakMap,o.scenes.set(A,r)),r.set(I,i),o.bases.has(A)||o.bases.set(A,C??i);const B=A._groups.get(g);B&&(B.r=o.dispatch);let n=e.installed.get(I);n||(n=new Set,e.installed.set(I,n)),n.add(g),e.installedMeshes.add(I)}function HAA(A,e,g){const I=e.installed.get(g);if(I){for(const i of I)jr?.get(i)?.scenes.get(A)?.delete(g);e.installed.delete(g),e.installedMeshes.delete(g)}}function xAA(A,e,g){HAA(A,e,g)}function HK(A,e,g,I,i,C){return!e.disposed&&e.generations.get(I)===C&&A.meshes.includes(I)&&I.material===i&&i._buildGroup===g}function TAA(A,e,g,I){const i=A._meshDisposables.get(g);if(i&&i!==I){A._meshDisposables.delete(g);for(const C of i)C()}if(I)if(A.meshes.includes(g))A._meshDisposables.set(g,I);else if(e.disposed)for(const C of I)C();else et(A.surface.engine,()=>{for(const C of I)C()});C6(e,g,I)}function qAA(A,e){if(!e.disposed)return;const g=A._disposables.splice(0);for(const I of g)I()}function OUA(A,e){const g=new Set(A._disposables.slice(0,e));for(let I=A._disposables.length-1;I>=e;I--)g.has(A._disposables[I])&&A._disposables.splice(I,1)}var PAA,Jo,jr,xK=b((()=>{kI(),PAA=(A,e)=>A.order-e.order,Jo=null,jr=null}));function OAA(A,e,g,I=e.material){return Promise.resolve().then(()=>(xK(),JK)).then(i=>i.A(A,I,e,g)).catch(i=>console.error(i))}function TK(A,e,g){A._runtimeThinBuild=OAA,A.thinInstances?(A.thinInstances.matrices=e,A.thinInstances.count=g,A.thinInstances._capacity=g,A.thinInstances._version++,A.thinInstances._dirtyMin=0,A.thinInstances._dirtyMax=g):A.thinInstances={matrices:e,count:g,_capacity:g,_version:1,_gpuBuffer:null,_gpuVersion:0,_dirtyMin:0,_dirtyMax:g,_colorVersion:0,_colorDirtyMin:0,_colorDirtyMax:0,_colorGpuBuffer:null,_colorGpuBufferStorage:!1,_colorGpuVersion:0,_gpuCullingEnabled:!1}}function o6(A,e){const g=A.thinInstances;g&&(g.count=e,g._version++,g._dirtyMin=0,g._dirtyMax=e)}function jUA(A,e){const g=A.thinInstances;if(g){if(!Number.isInteger(e)||e<0||e>g._capacity)throw new RangeError(`Thin instance draw count ${e} must be an integer between 0 and capacity ${g._capacity}`);g.count!==e&&((!g._gpuBuffer||g._gpuVersion!==g._version||g.colors&&(!g._colorGpuBuffer||g._colorGpuVersion!==g._colorVersion))&&R(595),g.count=e,g._gpuVersion=++g._version)}}function VUA(A){const e=A.thinInstances;e||R(596),e._drawArgsBuffer||(e._drawArgsInstanceCount=-1)}function WUA(A,e){A._runtimeThinBuild=OAA;const g=A.thinInstances;if(!g){const C=new oA(256);return C.set(e,0),A.thinInstances={matrices:C,count:1,_capacity:16,_version:1,_gpuBuffer:null,_gpuVersion:0,_dirtyMin:0,_dirtyMax:1,_colorVersion:0,_colorDirtyMin:0,_colorDirtyMax:0,_colorGpuBuffer:null,_colorGpuBufferStorage:!1,_colorGpuVersion:0,_gpuCullingEnabled:!1},0}const I=g.count;if(I>=g._capacity){const i=g._capacity*2,C=new oA(i*16);C.set(g.matrices),g.matrices=C,g._capacity=i}return g.matrices.set(e,I*16),g.count++,g._version++,g._dirtyMin=0,g._dirtyMax=g.count,I}function zUA(A,e,g){const I=A.thinInstances;I.matrices.set(g,e*16),I._version++,I._dirtyMin=Math.min(I._dirtyMin,e),I._dirtyMax=Math.max(I._dirtyMax,e+1)}function ZUA(A,e){const g=A.thinInstances,I=g.count-1;e!==I&&g.matrices.copyWithin(e*16,I*16,I*16+16),g.count--,g._version++,g._dirtyMin=0,g._dirtyMax=g.count}function r6(A){const e=A.thinInstances;e._version++,e._dirtyMin=0,e._dirtyMax=e.count}function XUA(A,e){const g=A.thinInstances;g.colors=e,g._version++,g._colorVersion++,g._colorDirtyMin=0,g._colorDirtyMax=g.count}function $UA(A,e,g,I,i,C){const o=A.thinInstances,r=o.colors,B=e*4;r[B]=g,r[B+1]=I,r[B+2]=i,r[B+3]=C,o._version++,o._colorVersion++,o._colorDirtyMin=Math.min(o._colorDirtyMin,e),o._colorDirtyMax=Math.max(o._colorDirtyMax,e+1)}function AvA(A,e=!0){const g=A.thinInstances;g||R(597),g._gpuCullingEnabled!==e&&(g._gpuCullingEnabled=e,g._gpuVersion=-1,g._colorGpuVersion=-1)}function evA(A,e){const g=A.thinInstances;g||R(598),g._cullBoundsPad=e}function gvA(A,e,g){const I=A.thinInstances,i=e.thinInstances;if((!I||!i)&&R(599),A===e&&R(600),((I._refCount??1)>1||(i._refCount??1)>1)&&R(601),!Number.isFinite(g.distance)||g.distance<0)throw new RangeError("setThinInstanceLodPartner distance must be a finite non-negative number");const C=g.band??0;if(!Number.isFinite(C)||C<0)throw new RangeError("setThinInstanceLodPartner band must be a finite non-negative number");I._lodSource&&R(602),i._lodPartner&&R(603),i._lodSource&&i._lodSource!==A&&R(604),i.colors&&!I.colors&&R(605);const o=I._lodPartner;if(o&&o!==e){const B=o.thinInstances;B&&B._lodSource===A&&qK(B),o._clone=void 0,I._lodBuckets=null}I._lodPartner=e,I._lodDistance=g.distance,I._lodBand=C,i._lodSource=A,A._clone=e._clone="Cannot clone LOD-paired mesh";const r=I._lodBuckets??new WeakMap;I._lodBuckets=r,i._lodBuckets=r,i._gpuCullingEnabled||(i._lodAutoCull=!0,i._gpuCullingEnabled=!0,i._gpuVersion=-1,i._colorGpuVersion=-1)}function IvA(A){const e=A.thinInstances;if(!e?._lodPartner)return;const g=e._lodPartner,I=g.thinInstances;e._lodPartner=null,e._lodDistance=void 0,e._lodBand=void 0,e._lodBuckets=null,A._clone=void 0,g._clone=void 0,I&&I._lodSource===A&&qK(I)}function tvA(A){const e=A.thinInstances;if(!e)return;const g=e._lodSource,I=g?.thinInstances;g&&I?._lodPartner===A&&(I._lodPartner=null,I._lodDistance=void 0,I._lodBand=void 0,I._lodBuckets=null,g._clone=void 0),e._lodSource&&qK(e);const i=e._lodPartner,C=i?.thinInstances;e._lodPartner=null,e._lodDistance=void 0,e._lodBand=void 0,e._lodBuckets=null,A._clone=void 0,i&&C?._lodSource===A&&(i._clone=void 0,qK(C))}function qK(A){A._lodSource=null,A._lodBuckets=null,A._lodAutoCull&&(A._lodAutoCull=!1,A._gpuCullingEnabled=!1,A._gpuVersion=-1,A._colorGpuVersion=-1)}var DQ=b((()=>{rA(),ZA()}));function ivA(A){B6=A}function CvA(A){PK=A}function jAA(A){A.positionBuffer.destroy(),A.normalBuffer.destroy(),A.uvBuffer.destroy(),A.tangentBuffer?.destroy(),A.uv2Buffer?.destroy(),A.colorBuffer?.destroy()}function Zi(A){if(A._disposed)return;A._disposed=!0,B6?.(A);const e=A._gpu;oC(e)&&(PK?PK(e,jAA):(jAA(e),e.indexBuffer.destroy()),e._shaderColorFallback?.destroy());const g=A.thinInstances;g&&oC(g)&&(tvA(A),g._gpuBuffer?.destroy(),g._colorGpuBuffer?.destroy(),g._drawArgsBuffer?.destroy());const I=A.skeleton;I&&oC(I)&&(I._disposed=!0,I.boneTexture.destroy(),oC(I._skinBuffers)&&(I.jointsBuffer.destroy(),I.weightsBuffer.destroy(),I.joints1Buffer?.destroy(),I.weights1Buffer?.destroy()));const i=A.vat;i&&oC(i)&&(i.settingsBuffer.destroy(),i.instanceTexture?.destroy(),oC(i._textureResource)&&i._textureResource.texture.destroy(),oC(i._skinBuffers)&&(i.jointsBuffer.destroy(),i.weightsBuffer.destroy(),i.joints1Buffer?.destroy(),i.weights1Buffer?.destroy()));const C=A.morphTargets;C&&oC(C)&&(C._disposed=!0,C.deltasBuffer.destroy(),C.weightsBuffer.destroy())}var PK,B6,Co=b((()=>{zn(),DQ(),PK=null,B6=null}));function ovA(A){OK=A}function uQ(A,e){A._materialSwapQueue.includes(e)||A._materialSwapQueue.push(e)}function VAA(A){const e=_Q?.get(A);if(e)for(const g of e)uQ(g,A)}function rvA(A){return _Q?.get(A)}function BvA(A){let e=A.material;Object.defineProperty(A,"material",{get(){return e},set(g){if(g!==e){OK?.(A,g),e=g;const I=_Q?.get(A);if(I)for(const i of I)uQ(i,A),i._meshMaterialChange?.(A,g)}},configurable:!0,enumerable:!0})}function nvA(A,e){e._disposed&&R(715,e.name),OK?.(e,e.material);const g=_Q??=new WeakMap;let I=g.get(e);I||(g.set(e,I=new Set),BvA(e)),I.add(A)}function WAA(A,e){const g=_Q?.get(e);return g?(g.delete(A),g.size===0):!0}var _Q,OK,Zn=b((()=>{rA(),_Q=null,OK=null}));function n6(A){const e=A._materialSwapQueue;if(!e[0]||A._runtimeBuilds?.w)return;let g,I,i;const C=A._renderables;for(const r of e){const B=r.material;if(!B)continue;const n=r._runtimeThinBuild;if(n){I=n(A,r,I);continue}const Q=A._groups.get(B._buildGroup),E=Q?.r;if(!E){(i??=[]).push(r);continue}if(Q._w?.(r)){(i??=[]).push([r,B]);continue}const a=A._meshDisposables.get(r);a&&(A._meshDisposables.delete(r),et(A.surface.engine,()=>a.forEach(D=>D())));const c=Q.o;let l;for(let D=C.length;D--;)C[D].mesh===r&&(l=C.splice(D,1)[0]);B._csmGen=-~B._csmGen;const p=E(A,r);if(c){const D=c.indexOf(l);D<0?c.push(p):c[D]=p}g=C.push(p)}if(g&&(C.sort((r,B)=>r.order-B.order),A._renderableVersion++,A._materialEpoch++),e.length=0,!i)return I;const o=i;return Promise.resolve().then(()=>(xK(),JK)).then(({C:r})=>r(A,o,I),r=>{const B=A._runtimeBuilds;B?B._x(r):console.error(r)})}var zAA=b((()=>{kI()}));function svA(A){s6=A}function QvA(A,e,g){s6?.(A,e,g)}var s6,ZAA=b((()=>{s6=null}));function XAA(A){const e={_tasks:[],_currentProcessedTask:null,build(){for(let g=0;g<e._tasks.length;g++)$AA(e,e._tasks[g]);for(const g of e._tasks)for(const I of g._passes)I._initialize()},execute(){let g=0;for(const I of e._tasks)if(I.executionEnabled!==!1)if(I.execute)g+=I.execute();else for(const i of I._passes)g+=i._execute();return g},dispose(){for(const g of e._tasks)g.dispose();e._tasks.length=0,e._currentProcessedTask=null}};return e}function EvA(A,e){A._tasks.includes(e)||R(121,e.name),$AA(A,e);for(const g of e._passes)g._initialize()}function $AA(A,e){e._passes.length=0,A._currentProcessedTask=e;try{e.record()}finally{A._currentProcessedTask=null}}function AeA(A,e){A._tasks.push(e)}var jK=b((()=>{rA()})),eeA=H({configureSwapchainOverlayScene:()=>avA});function geA(A,e){for(const g of A._frameGraph._tasks)if(g?._config&&g._colorAttachment&&(g._config.rt===e.scRT||g._config.rst===e.scRT))return g}function avA(A,e){const g=A._renderingContexts[A._renderingContexts.length-1];if(!g?._frameGraph)return;const I=geA(e,A);if(!I)return;if(A.msaaSamples===1){I._config.clr=!1;return}const i=I.enabled;I._config.clr=!0,I.enabled=!1,e._beforeRender.unshift(()=>{const C=geA(g,A),o=C?._config.rst===A.scRT&&C._config.rt._colorView;I.enabled=o?i:!1,I._config.clr=!o,o&&(I._colorAttachment.view=o)})}var IeA=b((()=>{}));function cvA(){return VK??=new WeakMap,VK}function teA(A,e){cvA().set(A,e),WK&&WK(A,e).catch(g=>console.error(g))}function BF(A){return VK?.get(A)}function lvA(A,e){if(e!==1/0&&(!Number.isInteger(e)||e<0))throw new RangeError("setShadowCasterMaxCascade requires a non-negative integer or Infinity");A._shadowMaxCascade=e===1/0?void 0:e}function pvA(A){WK=A}var VK,WK,zK=b((()=>{VK=null,WK=null})),DvA=H({createShadowTask:()=>uvA});function uvA(A,e){const g=new Set;pvA(ieA);const I={name:"shadow",engine:A,scene:e,_passes:[],async _preload(){const i=[];for(const C of e.lights){const o=C.shadowGenerator,r=o?BF(o):null;o?._preloadShadowTask&&r&&i.push(ieA(o,r))}await Promise.all(i)},record(){I._passes.length=0;for(const i of e.lights){const C=i.shadowGenerator,o=C?BF(C):null;if(C?._ensureShadowTaskState&&o&&!C._preloadPending){g.add(C);const r=C._ensureShadowTaskState(A,e,o),B=e._renderableVersion;r._task.record(),r._recordedVersion=B}}},execute(){let i=0;for(const C of e.lights){const o=C.shadowGenerator,r=o?BF(o):null;if(o?._ensureShadowTaskState&&o._renderShadowMap&&r&&!o._preloadPending){g.add(o);const B=o._shadowTaskState??null,n=o._ensureShadowTaskState(A,e,r);if(n!==B||n._recordedVersion!==e._renderableVersion){const Q=e._renderableVersion;n._task.record(),n._recordedVersion=Q}i+=o._renderShadowMap(A,n)}}return i},dispose(){I._passes.length=0;for(const i of g){const C=i._shadowTaskState;C&&(C._task.dispose(),i._shadowTaskState=void 0)}g.clear()}};return I}async function ieA(A,e){A._preloadPending=e,await A._preloadShadowTask?.(e),A._preloadPending===e&&(A._preloadPending=void 0)}var _vA=b((()=>{zK()}));function dvA(A){Xn=A}function fvA(A){Q6=A}function CeA(A,e){const g=A.camera;g&&!g._useFloatingOrigin!=!e&&(g._useFloatingOrigin=e,g._viewVer=-1,g._projFov=void 0)}function oeA(A,e){const g=A.engine,I={_kind:"scene",surface:A,clearColor:{r:.2,g:.2,b:.3,a:1},camera:null,lights:[],meshes:[],animationGroups:[],fog:null,clipPlane:null,shadowGenerators:[],imageProcessing:{exposure:1,contrast:1,toneMappingEnabled:!1},_renderables:[],_prePasses:[],_pickSources:[],_uniformUpdaters:[],fixedDeltaMs:0,_beforeRender:[],_deferredBuilders:[],_groups:new Map,_disposables:[],_meshDisposables:new Map,_materialSwapQueue:[],_renderableVersion:0,_materialEpoch:0,_built:!1,_drawCallsPre:0,_update(){const C=I.fixedDeltaMs>0?I.fixedDeltaMs:g._currentDelta,o=g._currentEncoder;let r=0;CeA(I,g.useFloatingOrigin);for(const B of I._beforeRender)B(C);CeA(I,g.useFloatingOrigin),I._materialSwapQueue.length&&n6(I);for(const B of I._prePasses)r+=B.execute(o,g);for(const B of I._uniformUpdaters)B.update(g);I._drawCallsPre=r},_record(){return I._frameGraph.execute()},_resize(){I._frameGraph.build()}},i=XAA(g);if(I._frameGraph=i,e?.defaultRenderTask!==!1){const C=A.msaaSamples>1,o=C?c3({lbl:"scene-color",format:A.format,dFormat:"depth24plus-stencil8",samples:A.msaaSamples,size:A}):A.scRT,r=C?void 0:c3({lbl:"scene-depth",dFormat:"depth24plus-stencil8",samples:1,size:A});AeA(i,i5({name:"scene",rt:o,rst:C?A.scRT:void 0,depth:r},g,I))}return I._disposables.push(()=>i.dispose()),I}function dQ(A,e){A._beforeRender.unshift(e)}function yvA(){return Xn!==void 0}function hvA(A,e){Xn?.run(A,e)}function nF(A,e,g){Xn?.record(A,e,g)}function wvA(A){return A._frameGraph}function sF(A,e){const g=A;g._deferredBuilders.push(async()=>{const I=await e(g.surface.engine,g);g._renderables.push(...I.renderables),I.dispose&&g._disposables.push(I.dispose)})}function Pg(A,e){if(Xn&&A._sceneChanges&&A._sceneChanges.depth===0){Xn.run(A,()=>Pg(A,e));return}const g=A;if("entities"in e){const i=e;for(const C of i.entities)Pg(A,C);if(i.clearColor&&(g.clearColor=i.clearColor),i.camera&&!g.camera&&(g.camera=i.camera),i.animationGroups?.length){const C=g.surface.engine,o=i.animationGroups;g.animationGroups.push(...o);const r=B=>{for(const n of o)QvA(n,B,C)};i._beforeRenderHook=r,g._beforeRender.push(r)}i._sceneSetup?.(g,i),nF(g,e,"added");return}if("_gpu"in e&&"material"in e){const i=e;nvA(g,i),g.meshes.push(i),reA(g,i),g._meshMaterialChange?.(i,i.material)}else"lightType"in e?g.lights.push(e):"fov"in e&&(g.camera=e);nF(g,e,"added");const I=e.children;if(I?.length)for(const i of I)i.parent=e,Pg(A,i)}function reA(A,e){const g=e.material?._buildGroup;if(!g)return;let I=A._groups.get(g);I||(I=[],A._groups.set(g,I),A._built||A._deferredBuilders.push(async()=>{if(!I[0]){A._groups.delete(g);return}const i=await g(A,I);A._renderables.push(...i.renderables),I.o=i.renderables,i.updater&&A._uniformUpdaters.push(i.updater),I.r=i.rebuildSingle})),I.push(e),(A._built||I.r)&&uQ(A,e)}function BeA(A){const e=A;if(e._z)return;e._z=!0;const g=QF??=new WeakMap;g.set(e,()=>1),Zs(e.surface,e);const I=()=>{g.set(e,()=>{for(const i of e._meshDisposables.values())i.forEach(C=>C());return e._meshDisposables.clear(),e._disposables.splice(0).forEach(i=>i()),e._renderables.length=e._uniformUpdaters.length=0,1}),e._disposables.splice(0).forEach(i=>i());for(const i of e._meshDisposables.values())for(const C of i)C();e._meshDisposables.clear();for(const i of e.meshes)WAA(e,i)&&Zi(i);e._groups.clear(),e.meshes.length=0,e._renderables.length=0,e._prePasses.length=0,e._pickSources.length=0,e._uniformUpdaters.length=0,e._beforeRender.length=0,e._deferredBuilders.length=0,e._disposables.length=0,e._materialSwapQueue.length=0,e.lights.length=0,e.animationGroups.length=0,e.shadowGenerators.length=0,e.camera=null};Xn?.dispose(e),Q6?Q6(e,I):I()}async function neA(A){const e=A;for(!e._built&&e._materialSwapQueue.splice(0)[0]&&(e._groups.forEach(g=>g.length=0),e.meshes.forEach(g=>reA(e,g)));e._deferredBuilders.length;){const g=e._deferredBuilders.splice(0);await Promise.all(g.map(I=>I()))}await n6(e),QF?.get(e)?.()||(e._runtimeBuilds?._e(),e._renderableVersion++,e._built=!0),await e._rebuildHook?.(e)}function MvA(A){fQ=A}async function seA(A){const e=A,g=e.surface;DY(g,e)||(await neA(A),e._renderables.sort(E6),await Promise.all(e._frameGraph._tasks.map(I=>I._preload?.())),fQ&&await fQ(e),e._frameGraph.build(),g._renderingContexts[0]&&(await Promise.resolve().then(()=>(IeA(),eeA))).configureSwapchainOverlayScene(g,e),QF?.get(e)?.()||Ln(g,e))}async function RvA(A){const e=A,g=e.surface;DY(g,e)||(await neA(A),e._renderables.sort(E6),await SvA(g.engine,e),await Promise.all(e._frameGraph._tasks.map(I=>I._preload?.())),fQ&&await fQ(e),e._frameGraph.build(),g._renderingContexts[0]&&(await Promise.resolve().then(()=>(IeA(),eeA))).configureSwapchainOverlayScene(g,e),QF?.get(e)?.()||Ln(g,e))}async function SvA(A,e){if(e._frameGraph._tasks.some(I=>I.name==="shadow"))return;const{createShadowTask:g}=await Promise.resolve().then(()=>(_vA(),DvA));e._frameGraph._tasks.unshift(g(A,e))}function NvA(A){Zs(A.surface,A)}var QF,Xn,Q6,fQ,E6,ht=b((()=>{lt(),Co(),Zn(),zAA(),ZAA(),jK(),CQ(),MI(),QF=null,fQ=null,E6=(A,e)=>A.order-e.order}));CZ(),UX(),jX(),e5(),R$(),MK(),YK(),ht();var QeA=!1,EeA=!1;function aeA(A){if(A.length===1)throw A[0];if(A.length>1)throw new AggregateError(A)}function GvA(A,e){const g=A._sceneChanges;if(!g){e();return}g.depth++;let I=!1,i;try{e()}catch(o){I=!0,i=o}if(g.depth--,g.depth>0||g.dispatching){if(I)throw i;return}const C=I?[i]:[];g.dispatching=!0;try{for(;g.pending.length;){const o=g.pending.shift();for(const r of[...g.listeners])if(g.listeners.has(r))try{r(o)}catch(B){C.push(B)}}}finally{g.dispatching=!1,!g.listeners.size&&A._sceneChanges===g&&(A._sceneChanges=void 0)}aeA(C)}function mvA(A){const e=A._sceneChanges;e&&(e.listeners.clear(),e.pending.length=0,A._sceneChanges===e&&(A._sceneChanges=void 0))}function FvA(A,e){const g=[];for(const I of A._disposables.splice(0))try{I()}catch(i){g.push(i)}A._disposables.length=0;try{e()}catch(I){g.push(I)}aeA(g)}function ceA(){EeA||(EeA=!0,fvA(FvA))}function bvA(){QeA||(QeA=!0,ceA(),dvA({run:GvA,record:(A,e,g)=>{const I=A._sceneChanges;if(I){if(g==="added"){if(I.members.has(e))return;I.members.add(e)}else if(!I.members.delete(e))return;I.pending.push({type:g,entity:e})}},dispose:mvA}))}function kvA(A){const e=new WeakSet,g=I=>{if(!e.has(I)&&(e.add(I),"children"in I&&Array.isArray(I.children)))for(const i of I.children)typeof i=="object"&&i!==null&&(!("parent"in i)||i.parent===I)&&g(i)};for(const I of[...A.meshes,...A.lights,...A.shadowGenerators])g(I);return A.camera&&g(A.camera),e}function leA(A,e){if(A._z)throw new Error("Cannot observe a disposed scene.");bvA();const g=A._sceneChanges??={listeners:new Set,pending:[],members:kvA(A),depth:0,dispatching:!1},I=C=>e(C);g.listeners.add(I);let i=!0;return()=>{i&&(i=!1,g.listeners.delete(I),!g.listeners.size&&!g.depth&&!g.dispatching&&A._sceneChanges===g&&(A._sceneChanges=void 0))}}function peA(A,e){ceA();const g=A._disposables,I=()=>e();g.push(I);let i=!0;return()=>{if(!i)return;i=!1;const C=g.indexOf(I);C>=0&&g.splice(C,1)}}function a6(A,e,g,I){A[3]=0,A[7]=0,A[11]=0,A[12]=e.x,A[13]=e.y,A[14]=e.z,A[15]=1;let i=g.x-e.x,C=g.y-e.y,o=g.z-e.z;const r=Math.sqrt(i*i+C*C+o*o);let B=0,n=0,Q=0,E=0;if(r>=1e-10){const c=1/r;i*=c,C*=c,o*=c,B=I.y*o-I.z*C,n=I.z*i-I.x*o,Q=I.x*C-I.y*i,E=Math.sqrt(B*B+n*n+Q*Q)}if(E<1e-10){A[0]=1,A[1]=0,A[2]=0,A[4]=0,A[5]=1,A[6]=0,A[8]=0,A[9]=0,A[10]=1;return}const a=1/E;B*=a,n*=a,Q*=a,A[0]=B,A[1]=n,A[2]=Q,A[4]=C*Q-o*n,A[5]=o*B-i*Q,A[6]=i*n-C*B,A[8]=i,A[9]=C,A[10]=o}var c6=b((()=>{})),ZK,l6=b((()=>{ZK={x:0,y:1,z:0}}));c6(),l6(),Lo(),Hr(),Ut();function DeA(A,e,g,I){function i(){const E=Math.cos(Q.alpha),a=Math.sin(Q.alpha),c=Math.cos(Q.beta);let l=Math.sin(Q.beta);return l===0&&(l=1e-4),{x:Q.target.x+Q.radius*E*l,y:Q.target.y+Q.radius*c,z:Q.target.z+Q.radius*a*l}}const C=QI();function o(){return a6(C,i(),Q.target,ZK),C}const r=eQ(o),B=()=>r.markLocalDirty(),n={alpha:A,beta:e,radius:g},Q={alpha:0,beta:0,radius:0,target:new Ei(I.x,I.y,I.z,B),fov:.8,nearPlane:.1,farPlane:1e3,children:[],inertia:.9,panningInertia:.9,angularSensibility:1e3,panningSensibility:50,wheelPrecision:3,inertialAlphaOffset:0,inertialBetaOffset:0,inertialRadiusOffset:0,inertialPanningX:0,inertialPanningY:0,_viewCache:QI(),_projCache:QI(),_vpCache:QI(),get parent(){return r.parent},set parent(E){r.parent=E},get worldMatrix(){return r.getWorldMatrix()},get worldMatrixVersion(){return r.getWorldMatrixVersion()}};for(const E of["alpha","beta","radius"])Object.defineProperty(Q,E,{get:()=>n[E],set:a=>{n[E]!==a&&(n[E]=a,B(),Q._clampToLimits?.())},configurable:!0,enumerable:!0});return Km(Q,r),Q}function $n(A,e,g){return{x:A,y:e,z:g}}oX();function KvA(A){let e=1/0,g=1/0,I=1/0,i=-1/0,C=-1/0,o=-1/0;const r=iX();for(const l of A.meshes)l.visible!==!1&&CX(r,l);e=r.minX,g=r.minY,I=r.minZ,i=r.maxX,C=r.maxY,o=r.maxZ;const B=i-e,n=C-g,Q=o-I;let E=Math.sqrt(B*B+n*n+Q*Q)*1.5,a=$n(e+B*.5,g+n*.5,I+Q*.5);(!isFinite(E)||E===0)&&(E=1,a=$n(0,0,0));const c=DeA(-(Math.PI/2),Math.PI/2,E,a);return c.nearPlane=E*.01,c.farPlane=E*1e3,A.camera=c,c}function mt(A,e){if(yvA()&&A._sceneChanges&&A._sceneChanges.depth===0){hvA(A,()=>mt(A,e));return}if("entities"in e){const g=e;for(const o of g.entities)mt(A,o);g.camera&&A.camera===g.camera&&(A.camera=null);const I=g.animationGroups;if(I?.length)for(const o of I)yQ(A.animationGroups,o);const i=g._beforeRenderHook;i&&(yQ(A._beforeRender,i),g._beforeRenderHook=void 0);const C=g._sceneCleanups;if(C){const o=C.get(A);o&&(yQ(A._disposables,o),C.delete(A),A._z||o())}nF(A,e,"removed");return}if("_gpu"in e&&"material"in e){xvA(A,e),nF(A,e,"removed"),deA(A,e);return}if("lightType"in e){yQ(A.lights,e);const g=e.shadowGenerator;g?ueA(A,g):_eA(A)}else"fov"in e&&"nearPlane"in e?A.camera===e&&(A.camera=null):"_shadowType"in e&&"_light"in e&&ueA(A,e);HvA(e),nF(A,e,"removed"),deA(A,e)}function UvA(A,e){for(const g of e){yQ(A._disposables,g);const I=g.p;if(I){I._disposed=!0;const i=I._owner;if(i){const C=i.indexOf(I);C>=0&&i.splice(C,1),I._owner=void 0,i.length===0&&I._onOwnerEmpty?.()}else I._onOwnerEmpty?.();I._onOwnerEmpty&&(I._onOwnerEmpty=void 0)}}vvA(A,()=>{for(const g of e)g()})}function vvA(A,e){if(A._z){e();return}et(A.surface.engine,e)}function ueA(A,e){yQ(A.shadowGenerators,e);const g=e._light;g&&g.shadowGenerator===e&&(g.shadowGenerator=void 0),_eA(A);const I=e._shadowTaskState;I&&(e._shadowTaskState=void 0,LvA(A,()=>I._task.dispose()))}function LvA(A,e){A._pendingTopologyRetirements||(A._pendingTopologyRetirements=[],A._disposables.push(()=>YvA(A))),A._pendingTopologyRetirements.push(e)}function YvA(A){const e=A._pendingTopologyRetirements?.splice(0);if(!e?.length)return;const g=()=>{for(const i of e)try{i()}catch{}},I=A.surface.engine._device;I?I.queue.onSubmittedWorkDone().then(g,g):g()}function _eA(A){A._lightListVersion=(A._lightListVersion??0)+1,A._built&&(A._rebuildHook=JvA)}async function JvA(A){const{rebuildSceneRenderables:e}=await Promise.resolve().then(()=>(YK(),bAA));await e(A)}function yQ(A,e){const g=A.indexOf(e);g>=0&&A.splice(g,1)}function HvA(A){A&&typeof A=="object"&&"parent"in A&&(A.parent=null)}function deA(A,e){const g=e.children;if(g?.length)for(const I of[...g])mt(A,I)}function xvA(A,e){A._meshMaterialChange?.(e);for(const B of A._frameGraph._tasks)B._removeMesh?.(e);const g=A._meshDisposables.get(e);let I=!1;const i=[];g&&(I=!0,i.push(...g),A._meshDisposables.delete(e));const C=A.meshes.indexOf(e);C>=0&&(A.meshes.splice(C,1),I=!0);const o=A._renderables.findIndex(B=>B.mesh===e);o>=0&&(A._renderables.splice(o,1),I=!0),I&&A._renderableVersion++;for(const B of A._groups.values()){const n=B.indexOf(e);n>=0&&B.splice(n,1);const Q=B.o;if(Q)for(let E=Q.length;E--;)Q[E].mesh===e&&Q.splice(E,1)}const r=A._materialSwapQueue.indexOf(e);r>=0&&A._materialSwapQueue.splice(r,1),A._runtimeBuilds?.remove(e),e.parent=null;for(const B of A._frameGraph._tasks)"_renderables"in B&&B$(B,e);WAA(A,e)&&i.push(()=>Zi(e)),i.length&&UvA(A,i)}var Ni=b((()=>{ht(),Zn(),Co(),CQ(),kI()}));function YI(A,e){feA(A,e)&&Vi()}function feA(A,e){let g=A.visible!==e;A.visible=e;const I=A.children;for(let i=0;i<I.length;i++)feA(I[i],e)&&(g=!0);return g}var Ho=b((()=>{lt()})),TvA=H({_apply:()=>qvA}),yeA=/textureSampleLevel\(\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*([^,]+?)\s*,\s*0(?:\.0?)?\s*\)\.rgb/,qvA=(A,e)=>{const g=A.match(yeA),I=g?.[1],i=g?.[2],C=g?.[3];if(!I||!i||!C)throw new Error("Environment blur: skybox cubemap sample not found.");const o=`clamp(scene._envPad1*log2(f32(textureDimensions(${I}).x))*${e==="dds"?"0.8":"scene.vImageInfos.z+scene._envPad2"},0.0,f32(textureNumLevels(${I})-1))`;return A.replace(yeA,`textureSampleLevel(${I},${i},${C},0.0+(${o})).rgb`)};tC();function heA(A,e,g){const I=A._environmentSkyboxShaderPatchLoaders??=[];I[e]=g,A._environmentSkyboxShaderComposer??=async(i,C)=>{i=C==="hdr"?q1+i:i;for(const o of I.slice())o&&(i=(await o())._apply(i,C));return i}}Pn();var PvA=()=>TvA;function OvA(A,e){A[38]=e._environmentBlur??0,A[39]=e._envTextures?.lodGenerationOffset??0}function jvA(A,e){A._environmentBlur=e,heA(A,1,PvA),j3(A,OvA),TY(A)}var VvA=H({_apply:()=>weA}),p6,weA,WvA=b((()=>{rA(),p6=/var\s+([A-Za-z_]\w*)\s*=\s*normalize\(\w+\.positionUVW\)\s*;/,weA=A=>{const e=A.match(p6)?.[1];e||R(431);const g=`let _erc=cos(scene.envRotationY);let _ers=sin(scene.envRotationY);${e}=vec3f(${e}.x*_erc+${e}.z*_ers,${e}.y,-${e}.x*_ers+${e}.z*_erc);`;return A.replace(p6,`$&${g}`)}}));Pn();var zvA=()=>Promise.resolve().then(()=>(WvA(),VvA));function ZvA(A,e){Um(A),A._environmentRotation=e,heA(A,0,zvA),TY(A)}var XvA=[A=>`AnimationGroup "${A}" is already attached to another AnimationManager`,()=>"Animation task category is required.",()=>"AnimationTask is already attached to another AnimationManager",()=>"AnimationManager autonomous mode requires requestAnimationFrame",A=>`Animation weight fade duration must be a finite positive number, got ${A}`,A=>`Animation weight must be a finite number between 0 and 1, got ${A}`,A=>`Animation weight must be a finite number between 0 and 1, got ${A}`,()=>"createPropertyAnimationClip requires at least one track",()=>"Animation play range must have toTime greater than fromTime",A=>`Animation track "${A}" requires at least one key`,A=>`Animation track "${A}" requires a positive frameRate`,A=>`Animation track "${A}" key times must be monotonically increasing`,A=>`Animation track "${A}" requires at least one key`,A=>`Animation key for "${A}" must provide exactly one of time or frame`,A=>`Animation key for "${A}" must have a non-negative time`,(A,e)=>`Animation key for "${A}" expected ${e} values`,(A,e)=>`Animation key for "${A}" expected ${e} values`,A=>`Invalid animation property path "${A}"`,(A,e)=>`Animation property path "${A}" could not resolve "${e}"`,A=>`Animation property path "${A}" reached a non-object value`,(A,e)=>`Animation property path "${A}" could not resolve "${e}"`,(A,e)=>`Animation property path "${A}" has unsupported vector size ${e}`,(A,e)=>`Animation property path "${A}" could not resolve component "${e}"`,()=>"Additive animation reference must use either referenceFrame or referenceTime, not both",A=>`Additive animation reference time must be a finite non-negative number, got ${A}`,()=>"Weighted glTF animation requires an AnimationManager engine",()=>"Weighted glTF animation requires an AnimationManager engine",()=>"Weighted animation channels for the same property must use the same value size",()=>"Weighted animation channels for the same property must use the same mixing strategy",()=>"Audio engine media streams require a real-time AudioContext.",()=>"Unable to get a 2D context from the visualizer canvas.",()=>"Invalid splat voxel collision data.",(A,e)=>`Collision data: HTTP ${A} for ${e}`,()=>"Collision URL must be an HTTP(S) .voxel.json URL.",()=>"setEffectUniforms: wrapper has no uniform binding.",A=>`setEffectUniforms: unknown uniform binding "${A}".`,A=>`setEffectTexture: unknown texture binding "${A}".`,A=>`EffectRenderTask "${A}" executed before record().`,A=>`EffectRenderer "${A}" recorded before registerEffectRenderer().`,A=>`createEffectWrapper: duplicate binding ${A}.`,(A,e)=>`Effect "${A}" missing uniform binding ${e}.`,(A,e)=>`Effect "${A}" missing texture binding ${e}.`,(A,e)=>`Effect "${A}" missing texture for sampler binding ${e}.`,(A,e,g)=>`writeUniformSlot: ${A} bytes exceeds uniform binding ${e} size ${g}.`,(A,e)=>`setUniformEffectUniforms: ${A} bytes exceeds uniform size ${e}.`,A=>`UniformEffectRenderTask "${A}" executed before record().`,()=>"Device-lost recovery capture requires an enabled recovery coordinator",()=>"WebGPU adapter not available during device recovery",A=>`WebGPU device recovery missing required features: ${A}`,()=>"forceWebGpuDeviceLossForTesting requires a device-lost recovery handler to be enabled first",()=>"WebGPU adapter not available",()=>"Babylon Lite: useFloatingOrigin requires useHighPrecisionMatrix on the engine.",()=>"renderFrame: surface belongs to a different engine.",()=>"Frame-bound post-submit work requires an active frame encoder.",()=>"GPU task timing could not instrument render passes on this command encoder.",()=>"GPU task timing could not instrument compute passes on this command encoder.",()=>"createMipMappedRenderTarget requires a color format and samples: 1.",()=>"Mipmapped render target has been disposed.",()=>"Mipmapped render target requires a single-sample, filterable, renderable color format.",()=>"Mipmapped render target dimensions must be positive integers.",()=>"Mipmapped render target dimensions exceed maxTextureDimension2D.",A=>`RenderTargetDescriptor.size.scale must be a positive finite number (got ${A}).`,()=>"WebGPU context not available",()=>"Babylon Lite: disposeSurface cannot dispose the engine's primary surface \u2014 use disposeEngine instead.",A=>`Flow Graph Editor: unsupported block class ${A}`,()=>"Flow Graph Editor: expected a serialized object",A=>`Flow Graph Editor: graph ${A} has no allBlocks array`,()=>"KHR_interactivity: duplicate type signatures",A=>`KHR_interactivity: unsupported type signature ${A}`,A=>`KHR_interactivity: node references missing declaration #${A}`,(A,e)=>`KHR_interactivity: variable ${A} references missing type #${e}`,(A,e,g)=>`KHR_interactivity: event ${A} value ${e} references missing type #${g}`,(A,e,g)=>`KHR_interactivity: ${A} node ${e} references invalid variable #${g}`,A=>`KHR_interactivity: variable/set node ${A} has invalid variable indices`,(A,e)=>`KHR_interactivity: variable/set node ${A} is missing input for variable #${e}`,(A,e)=>`KHR_interactivity: variable/set node ${A} input for variable #${e} has the wrong type`,A=>`KHR_interactivity: node ${A} is missing its pointer configuration`,(A,e)=>`KHR_interactivity: node ${A} is missing pointer parameter ${e}`,(A,e)=>`KHR_interactivity: node ${A} pointer parameter ${e} has the wrong type`,(A,e)=>`KHR_interactivity: ${A} node ${e} uses a reserved pointer parameter`,(A,e,g)=>`KHR_interactivity: ${A} node ${e} references invalid type #${g}`,(A,e)=>`KHR_interactivity: node ${A} references invalid event #${e}`,(A,e,g)=>`KHR_interactivity: ${A} node ${e} is missing required ${g} input`,(A,e)=>`KHR_interactivity: variable/interpolate node ${A} references invalid variable #${e}`,A=>`KHR_interactivity: variable/interpolate node ${A} can only use slerp with float4`,(A,e)=>`KHR_interactivity: pointer/interpolate node ${A} references invalid type #${e}`,(A,e,g)=>`KHR_interactivity: ${A} node ${e} cannot interpolate ${g}`,(A,e)=>`KHR_interactivity: node ${A} references missing producer node #${e}`,(A,e,g)=>`KHR_interactivity: node ${A} flow ${e} targets missing node #${g}`,A=>`invalid RFC 6901 escape in pointer segment ${A}`,A=>`literal pointer brackets must be doubled in ${A}`,()=>"JSON Pointer Templates must be absolute",A=>`duplicate pointer parameter ${A}`,A=>`ClearTextureTask "${A}": targetTexture or depthTexture is required; color target arrays must not be empty.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": targetTexture must have a color attachment.`,A=>`ClearTextureTask "${A}": color attachments must reference distinct textures.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": depthTexture must have a depth/stencil attachment.`,A=>`ClearTextureTask "${A}": too many color attachments.`,A=>`ClearTextureTask "${A}": attachments must have matching dimensions and sample counts.`,A=>`ClearTextureTask "${A}": build the frame graph before execution.`,A=>`ClearTextureTask "${A}": targetTexture has no live color attachment.`,A=>`ClearTextureTask "${A}": depthTexture has no live depth/stencil attachment.`,A=>`CopyToTextureTask "${A}": either targetTexture or resolveTexture must be provided.`,A=>`CopyToTextureTask "${A}": sourceTexture cannot be the engine scRT because its GPU texture changes every frame.`,A=>`CopyToTextureTask "${A}": sourceTexture has no color texture. The source must be built before this task records.`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture requires a multisampled sourceTexture (got sampleCount=${e}).`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture must be single-sample (got sampleCount=${e}).`,(A,e,g,I,i)=>`CopyToTextureTask "${A}": sourceTexture (${e}x${g}) and resolveTexture (${I}x${i}) must have matching dimensions.`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture requires a multisampled targetTexture (got sampleCount=${e}).`,(A,e)=>`CopyToTextureTask "${A}": resolveTexture must be single-sample (got sampleCount=${e}).`,(A,e,g)=>`CopyToTextureTask "${A}": resolveTexture format (${e}) must match targetTexture format (${g}).`,()=>"CopyToTextureTask: targetTexture has no color format.",A=>`DepthResolveTask "${A}": sourceTexture has no depth attachment.`,A=>`DepthResolveTask "${A}": sourceTexture must be multisampled (sampleCount > 1).`,A=>`DepthResolveTask "${A}": targetTexture has no depth format.`,()=>"FrameGraph target does not expose a frame graph.",A=>`addRenderPass("${A}"): no task is currently recording (called outside Task.record?)`,A=>`buildFrameGraphTask("${A}"): task is not registered in this graph.`,A=>`GenerateMipMapsTask "${A}": targetTexture is required.`,A=>`GenerateMipMapsTask "${A}": build the frame graph before execution.`,A=>`GenerateMipMapsTask "${A}": targetTexture changed or was disposed; rebuild the frame graph before execution.`,A=>`GenerateMipMapsTask "${A}": targetTexture cannot be a swapchain target.`,A=>`GenerateMipMapsTask "${A}": targetTexture must be a single-sample, filterable, renderable 2D color texture with sampling and render-attachment usage.`,A=>`GenerateMipMapsTask "${A}": targetTexture must have mipmaps allocated.`,A=>`Transparent geometry output cannot blend integer format "${A}".`,A=>`Transparent geometry output format "${A}" requires the float32-blendable WebGPU feature or a blendable format override.`,A=>`GeometryRendererTask: MESH_BLEND_TAG format must be r8uint, received ${A}.`,()=>"GeometryRendererTask: MESH_BLEND_TAG clearValue must be unsigned integer zero.",()=>"GeometryRendererTask: MESH_BLEND_TAG requires samples: 1.",()=>"GeometryRendererTask: transparent Node materials cannot write MESH_BLEND_TAG because their graph alpha is unavailable to the geometry terminal. Exclude transparent meshes or omit the tag attachment.",()=>"GeometryRendererTask: textureDescriptions must contain at least one entry.",()=>"GeometryRendererTask: too many color attachments.",A=>`GeometryRendererTask: unknown texture type ${A}.`,(A,e)=>`GeometryRendererTask: depthTexture sampleCount (${A}) must match samples (${e}).`,(A,e)=>`GeometryRendererTask: targetTexture sampleCount (${A}) must match samples (${e}).`,()=>"GeometryRendererTask: targetTexture must have a format.",()=>"GeometryRendererTask: MESH_BLEND_TAG is not enabled.",()=>"overdraw probe: this device has no timestamp-query feature",()=>"overdraw probe: tasks that load existing depth cannot be measured with a fresh-depth replay",()=>"overdraw probe: task render target has no size (has the task rendered yet?)",()=>"overdraw probe: task target has no color+depth signature to replicate",()=>"overdraw probe: task has no draw bindings (has the task rendered yet?)",()=>"overdraw probe: task scene bindings have not been recorded",()=>"overdraw probe: timestamp readback produced no usable samples",A=>`PostProcessTask "${A}": sourceTexture has no color texture. Render the source to an offscreen RenderTarget before post-processing.`,A=>`PostProcessTask "${A}": multisampled source textures are not supported. Use a sampleCount: 1 source RenderTarget.`,A=>`PostProcessTask "${A}": outputTexture must have a format.`,(A,e)=>`PostProcessTask "${A}": extra texture ${e} has no color texture.`,A=>`PostProcessTask "${A}": sourceTexture must have a format.`,()=>"enableRenderTaskMeshRefresh must be called before the render task is recorded.",()=>"enableRenderTaskMeshRefresh requires an explicit render task with autoMirror: false.",()=>"RenderTask has been disposed.",()=>"Material group has not completed its initial build in this scene.",()=>"RenderTask has been disposed.",()=>"buildClusteredLightGpuState: scene.camera is required",()=>"ClusteredLightContainer: light count cannot grow after GPU state creation.",A=>`setLightDiffuseColor: expected finite RGB components, got ${A}`,A=>`setLightIntensity: expected a finite intensity, got ${A}`,()=>"Device-lost Scene recovery requires environment loading after recovery was enabled",(A,e,g)=>`Device-lost Scene recovery could not refetch '${A}' (${e} ${g}).`,()=>"Procedural sky environment requires finite non-negative scattering, non-zero total scattering, a non-zero sun direction, and positive luminance.",()=>"Procedural sky environment has been disposed.",()=>"Procedural sky environment no longer owns the scene environment.",()=>"loadProceduralSkyEnvironment cannot load into a disposed scene.",()=>"loadProceduralSkyEnvironment requires a scene without an existing environment.",()=>"loadProceduralSkyEnvironment must run before the scene is registered.",()=>"A procedural sky environment is already loading for this scene.",()=>"Procedural sky environment initialization was cancelled: the scene was disposed, registered, or acquired another environment.",()=>"Procedural sky environment initialization was cancelled.",(A,e)=>`${A}: image ${e} not found`,(A,e)=>`${A}: bufferView ${e} not found`,(A,e,g)=>`${A}: failed to load image ${e} ${g}`,A=>`${A}: image has neither bufferView nor uri`,(A,e)=>`${A}: strided accessor uses unsupported component type: ${e}`,(A,e,g)=>`${A}: strided accessor ${e} uses unsupported component type: ${g}`,(A,e,g)=>`${A}: invalid accessor stride ${e} for accessor ${g}`,A=>`glTF camera ${A}: unsupported projection`,()=>"glTF camera nodes require non-zero uniform scale",A=>`EXT_mesh_gpu_instancing: accessor count mismatch on node ${A}`,A=>`EXT_meshopt_compression: compressed source buffer ${A} is not buffer 0 (unsupported)`,A=>`EXT_meshopt_compression: uncompressed bufferView in buffer ${A} is not buffer 0 (unsupported)`,A=>`glTF sparse: unsupported componentType ${A}`,A=>`glTF sparse: unsupported index componentType ${A}`,A=>`glTF sparse: unsupported value componentType ${A}`,()=>"glTF sparse: indices.componentType is required",(A,e)=>`glTF sparse: index ${A} out of range for accessor of count ${e}`,()=>"Not a valid GLB file",()=>"First GLB chunk is not JSON",()=>"Second GLB chunk is not BIN",(A,e)=>`Failed to load image: ${A} ${e}`,()=>"loadGltf: baseless input can't resolve relative URI; use self-contained GLB or URL with base.",A=>`Unsupported component type: ${A}`,()=>"Image has neither bufferView nor uri",(A,e)=>`Failed to load image: ${A} ${e}`,()=>"Image has neither bufferView nor uri",()=>"Invalid HDR: missing #? signature",A=>`Unsupported HDR format: ${A}`,A=>`Invalid HDR resolution: ${A}`,()=>"Invalid HDR: RLE scanline width does not match image",()=>"Invalid HDR: truncated RLE scanline",()=>"Invalid HDR: zero-length RLE packet",()=>"Invalid HDR: RLE run exceeds scanline",()=>"Invalid HDR: RLE literal exceeds scanline",()=>"Invalid HDR: truncated scanline",(A,e)=>`${A} source ${e}: expected five textures`,A=>`${A} resident environment exceeds admitted GPU capacity`,A=>`${A} active display exceeds admitted GPU capacity`,(A,e)=>`${A} source ${e}: GPU/CPU cache budget admission failed`,(A,e)=>`${A} metadata ${e}: only http and https URLs are supported`,A=>`${A} metadata: Fetch is required`,(A,e,g)=>`${A} metadata ${e}: HTTP ${g}`,(A,e)=>`${A} metadata ${e}: Content-Length exceeds maxCpuBytes admission`,(A,e)=>`${A} metadata ${e}: response has no body`,(A,e)=>`${A} metadata ${e}: streamed body exceeds maxCpuBytes admission`,(A,e,g)=>`${A} bootstrap coarse representation (${e} splats) exceeds maxSplats (${g})`,A=>`${A} attach: stream is disposed`,A=>`${A} attach: scene and stream use different engines`,A=>`${A} attach: stream is already attached to another scene`,A=>`${A} attach: attach before or during scene registration`,(A,e)=>`[GaussianSplatStream] GPU ${A} buffer size ${e} exceeds device limits`,()=>"[GaussianSplatStream] GPU budget/device limits cannot admit one canonical splat",()=>"[GaussianSplatStream] GPU budget cannot admit canonical stream state",()=>"[GaussianSplatStream] GPU upload requires exactly five source images",()=>"[GaussianSplatStream] GPU byte upload requires five exact RGBA8 images",()=>"[GaussianSplatStream] GPU state is disposed",()=>"[GaussianSplatStream] GPU interval is outside admitted source/canonical bounds",()=>"[GaussianSplatStream] GPU budget cannot admit pass-local projection and radix state",()=>"[GaussianSplatStream] GPU budget cannot protect submission-local gather parameters",()=>"[GaussianSplatStream] GPU budget cannot admit submission-local gather parameters",(A,e)=>`${A} transport ${e}: invalid Content-Length`,(A,e)=>`${A} transport ${e}: unsafe Content-Length`,(A,e)=>`${A} image ${e}: invalid WebP header`,(A,e)=>`${A} image ${e}: invalid lossless WebP header`,(A,e)=>`${A} image ${e}: unsupported WebP header`,A=>`${A} transport: Fetch and createImageBitmap are required`,A=>`${A} transport: reserveGpuBytes requires gpuLedger for reservation cleanup`,(A,e,g)=>`${A} ${e}: maxCpuBytes cannot admit ${g} bytes`,(A,e,g)=>`${A} ${e}: maxCpuBytes cannot admit ${g} bytes without blocking payloads retained by the same preparation`,(A,e)=>`${A} transport ${e}: response has no body`,(A,e)=>`${A} image ${e}: dimensions do not match the source`,A=>`${A} selection: invalid view-projection frustum`,A=>`${A} selection: viewProjectionMatrix must contain 16 values`,A=>`${A} selection: viewProjectionMatrix must be finite`,A=>`${A} selection: worldMatrix must contain 16 values`,A=>`${A} selection: world transform produced nonfinite bounds`,A=>`${A} selection: cameraPosition must be finite`,A=>`${A} selection: invalid planner parameters`,A=>`${A} selection: orthographic cameras are unsupported`,A=>`${A} selection: invalid planner parameters`,A=>`${A} bootstrap: manifest has no positive coarse source`,A=>`loadSOG: decoded WebP has zero dimensions (input size ${A})`,()=>"loadSOG: failed to acquire 2D context for WebP decode",()=>"loadSOG: means.mins/means.maxs must be arrays",()=>"loadSOG: SOG v2 missing scales codebook",()=>"loadSOG: scales.mins/maxs must be arrays for SOG v1",()=>"loadSOG: SOG v2 missing sh0 codebook",()=>"loadSOG: sh0.mins/maxs must be arrays for SOG v1",A=>`loadSOG: invalid quaternion mode ${A}`,()=>"loadSOG: SOG v2 missing shN codebook",(A,e)=>`loadSOG: HTTP ${A} for ${e}`,()=>"loadSOG: meta.json not found in archive",A=>`loadSOG: missing image '${A}' inside archive`,(A,e)=>`loadSplat: HTTP ${A} for ${e}`,A=>`loadSplat: failed to parse PLY at ${A} (unsupported property layout)`,()=>"loadSPZ: file too short to contain header",(A,e)=>`loadSPZ: unsupported SPZ stream (magic=0x${A} version=${e})`,(A,e)=>`loadSPZ: HTTP ${A} for ${e}`,()=>"Invalid compressed PLY: packed vertex properties require chunk metadata for every vertex",()=>"zip: EOCD record not found",()=>"zip: ZIP64 archives are not supported",A=>`zip: bad central directory signature at offset ${A}`,()=>"zip: encrypted entries are not supported",()=>"zip: ZIP64 archives are not supported",A=>`zip: bad local file header signature at offset ${A}`,(A,e)=>`zip: unsupported compression method ${A} for entry '${e}'`,(A,e,g)=>`zip: entry '${A}' decompressed size mismatch (got ${e}, expected ${g})`,A=>`Duplicate USD mesh ${A}`,()=>"Invalid USD analytic primitive",A=>`Missing USD material ${A}`,()=>"Invalid USD animation target, property, or value stride",()=>"Invalid USD animation samples",()=>"Invalid USD triangle indices",()=>"Non-finite USD positions",()=>"Non-finite USD vertex data",()=>"Invalid USD material subset index range",()=>"USD instance references a missing source",A=>`USD mesh ${A} cannot mix classic and thin instances`,()=>"USD command buffer must contain exactly one scene",()=>"Invalid USD stage metadata",A=>`Duplicate USD geometry ${A}`,A=>`Duplicate or reserved USD mesh ${A}`,A=>`Missing USD geometry ${A}`,()=>"USD mesh has no material subsets",()=>"Invalid USD material subset vertex range",A=>`Missing USD material ${A}`,(A,e)=>`Invalid USD ${A} texture output channel ${e}`,A=>`Duplicate USD material ${A}`,A=>`Non-finite USD material ${A}`,(A,e)=>`USD material ${A} has a channel without texture ${e}`,(A,e)=>`USD material ${A} references texture ${e} without a texture command`,A=>`Invalid or duplicate USD morph target ${A}`,A=>`USD morph target ${A} contains invalid vertex data`,A=>`USD morph targets reference missing mesh ${A}`,A=>`USD morph target vertex count does not match mesh ${A}`,A=>`Duplicate or reserved USD node ${A}`,()=>"Non-finite USD transform",()=>"Cyclic or missing USD parent node",()=>"Invalid USD command buffer",()=>"Unsupported USD command protocol version",()=>"Truncated USD command header",A=>`Invalid USD command ${A} payload`,()=>"Unexpected trailing USD commands",()=>"Invalid USD data range",A=>`Invalid or duplicate USD skeleton ${A}`,A=>`USD skeleton ${A} has an invalid parent or duplicate bone ID`,A=>`USD skeleton ${A} has a non-finite joint transform`,A=>`USD skeleton ${A} has a singular bind transform`,()=>"USD mesh references a missing skeleton",()=>"Missing or unsupported USD mesh skin",()=>"Invalid USD skin weights or joint indices",A=>`Duplicate USD texture ${A}`,A=>`Missing USD texture ${A}`,()=>"Unsupported USD texture encoding, wrap mode, UV set, or color space",()=>"Invalid USD texture transform",A=>`USD thin instances reference missing source ${A}`,A=>`USD mesh ${A} has duplicate or mixed instances`,A=>`USD thin instances for mesh ${A} contain a non-finite transform`,A=>`USD file path must be relative: ${A}`,A=>`Could not load USD: HTTP ${A}`,A=>`Duplicate USD virtual file: ${A}`,A=>`LineMaterial "${A}" requires thin-instance data`,()=>"createLineMaterial requires useThinInstances when useThinInstanceColors is enabled",(A,e)=>`NodeMaterial: cannot pick common numeric type from ${A} and ${e}`,A=>`NodeMaterial: AmbientOcclusionBlock "${A}" requires an ImageSourceBlock source`,()=>"BiPlanarBlock: texture projection is supported only in the fragment stage",A=>`NodeMaterial: ColorSplitterBlock (id=${A}) has no connected input`,A=>`NodeMaterial: ColorSplitterBlock has no output "${A}"`,A=>`NodeMaterial: unknown CurveBlock curveType ${A}`,A=>`NodeMaterial: CurveBlock does not support ${A}`,()=>"NodeMaterial: FragDepthBlock requires `depth` or both `worldPos` and `viewProjection` inputs",A=>`NodeMaterial: HeightToNormalBlock "${A}" requires worldTangent when generateInWorldSpace is false`,A=>`InputBlock: unknown mesh attribute "${A}"`,(A,e)=>`InputBlock: unsupported systemValue ${A} on block "${e}"`,A=>`LoopBlock "${A}": index can only be read while emitting the loop body`,A=>`LoopBlock "${A}": loopID can only be consumed by StorageReadBlock/StorageWriteBlock`,(A,e)=>`LoopBlock "${A}": unsupported output "${e}"`,A=>`NodeMaterial: MatrixSplitterBlock has no output "${A}"`,A=>`NodeMaterial: unsupported matrix block "${A}"`,()=>"NodeMaterial: NLerpBlock requires a vector left/right input; Babylon.js emits normalize(mix(...)) for this block",()=>"NodeMaterial: PBR-MR core emitter cannot emit optional PBR feature code",()=>"NodeMaterial: PBR-MR core helper cannot emit optional PBR feature code",A=>`NodeMaterial: RandomNumberBlock requires a vector seed so Babylon.js getRand(seed.xy) can be emitted; got ${A}`,A=>`ReflectionTextureBaseBlock "${A}" is an abstract compatibility block and cannot be emitted directly.`,A=>`ReflectionTextureBlock: coordinatesMode ${A} not supported (only EQUIRECTANGULAR_MODE=7)`,A=>`NodeMaterial: ReplaceColorBlock requires a vector/color value; got ${A}`,(A,e)=>`StorageReadBlock "${A}": unsupported output "${e}"`,A=>`StorageReadBlock "${A}": loopID input is not connected`,(A,e)=>`StorageReadBlock "${A}": loop ${e} is not active`,()=>"NodeMaterial: TBNBlock object output is not supported; use row0/row1/row2 outputs",A=>`NodeMaterial: TeleportOutBlock (id=${A}) has no entryPoint`,(A,e)=>`NodeMaterial: TeleportOutBlock (id=${A}) points to missing TeleportInBlock ${e}`,()=>"TriPlanarBlock: texture projection is supported only in the fragment stage",A=>`NodeMaterial: VectorSplitterBlock (id=${A}) has no connected input`,A=>`NodeMaterial: VectorSplitterBlock has no output "${A}"`,A=>`NodeMaterial: WaveBlock does not support ${A}`,A=>`NodeMaterial: unknown WaveBlock kind ${A}`,A=>`NodeMaterial: invalid block selection "${A}": use an exported block descriptor`,A=>`NodeMaterial: duplicate block selection "${A}"`,A=>`NodeMaterial: no emitter selected for block "${A}"`,(A,e,g)=>`NodeMaterial: cannot cast ${A} to ${e} for expression \`${g}\``,(A,e)=>`${A}: unsupported BJS connection point type 0x${e}`,(A,e,g)=>`NodeMaterial: block "${A}" (id=${e}) has no input "${g}"`,(A,e,g)=>`NodeMaterial: block "${A}" (id=${e}) input "${g}" is not connected`,(A,e,g)=>`NodeMaterial: dangling connection ${A}.${e} -> block ${g}`,A=>`NodeMaterial: no emitter loaded for block "${A}"`,()=>"NodeMaterial: only vertex->fragment varyings are supported",A=>`NodeMaterial: fragment root block ${A} not found`,A=>`NodeMaterial: no emitter for fragment root "${A}"`,A=>`NodeMaterial: vertex root block ${A} not found`,A=>`NodeMaterial: no emitter for vertex root "${A}"`,()=>"NodeMaterial: PBR/Reflection block requires scene environment but scene._envTextures is unset. Call loadEnvironment() before registerScene().",()=>"node-geometry view does not support scene group building",()=>"node-geometry rebuild requires task-owned resources",A=>`Transparent geometry output cannot blend integer format "${A}".`,A=>`Transparent geometry output format "${A}" requires the float32-blendable WebGPU feature or a blendable format override.`,()=>"NodeMaterial geometry view: graph has no GeometryTextureOutputBlock",()=>"NodeMaterial geometry view: morph / env / shadow inputs are not supported in the geometry pass",()=>"node-geometry: render target has no color attachments",(A,e)=>`NodeMaterial geometry view: texture binding "${A}" not set. Provide it via material.inputs["${e}"].texture before the first render.`,()=>"NodeMaterial geometry view: NORMALIZED_VIEW_DEPTH requested but no geometry-params UBO was provided by the task.",()=>"NodeMaterial geometry view: emitColor (real-color target) is not supported \u2014 omit targetTexture on the geometry task.",()=>"NodeMaterial: graph has no FragmentOutputBlock",()=>"NodeMaterial: advanced PBR-MR helper request must be emitted by the full PBR-MR block",()=>"NodeMaterial: invalid source \u2014 expected `.blocks` array",A=>`NodeMaterial: block missing numeric id (name=${A})`,(A,e)=>`NodeMaterial: cycle detected through block ${A} (${e})`,A=>`NodeMaterial: dangling reference to block ${A}`,A=>`NodeMaterial: helper key "${A}" registered with conflicting source bodies`,A=>`NodeMaterial: no advanced extension emitter registered for block "${A}"`,A=>`NodeMaterial: no compatibility extension emitter registered for block "${A}"`,A=>`NodeMaterial: no math extension emitter registered for block "${A}"`,A=>`NodeMaterial: no procedural extension emitter registered for block "${A}"`,(A,e)=>`NodeMaterial: texture binding "${A}" not set. Provide it via options.textures or material.inputs["${e}"].texture before the first render.`,A=>`NodeMaterial: material requires shadow generator #${A} but none was supplied to parseNodeMaterialFromSnippet({ shadowGenerators }).`,A=>`NodeMaterial: unsupported attribute "${A}"`,(A,e)=>`NodeMaterial: snippet fetch failed (${A}) for ${e}`,A=>`NodeMaterial: snippet "${A}" has no jsonPayload`,A=>`NodeMaterial: snippet "${A}" has no nodeMaterial`,(A,e)=>`[babylon-lite] ${A} must contain three finite${e} values`,A=>`[babylon-lite] ${A} must be finite and positive`,A=>`[babylon-lite] local probe ${A} influenceInnerRadius must be finite, non-negative, and no larger than influenceOuterRadius`,A=>`[babylon-lite] local probe ${A} inner influence box must be non-negative and contained by the outer influence box`,A=>`[babylon-lite] local probe ${A} angleRadians must be finite`,A=>`[babylon-lite] local probe ${A} debugColor must contain three finite values from 0 to 1`,()=>"[babylon-lite] local probe cubemap dimensions must differ only by power-of-two mip levels",()=>"[babylon-lite] local probe voxelGrid.cellSize must be finite and positive",()=>"[babylon-lite] local probe voxelGrid.maximum must be greater than minimum on every axis",()=>"[babylon-lite] local probe voxel grid dimensions are too large",()=>"[babylon-lite] local probe voxel grid dimensions are too large",(A,e,g,I,i)=>`[babylon-lite] local probe voxel (${A}, ${e}, ${g}) intersects ${I} probes, exceeding maxCandidates ${i}`,()=>"[babylon-lite] local probe cubemaps require COPY_SRC usage; call enablePbrLocalCubemap() before loading DDS or HDR probe environments, or create custom probe textures with COPY_SRC",()=>"[babylon-lite] local probe cubemaps must be square six-face textures with one shared format",()=>"[babylon-lite] local probe cubemaps have no common mip range",(A,e)=>`[babylon-lite] local probe set has ${A} probes, but this device supports at most ${e} cube-array probes`,(A,e)=>`[babylon-lite] local probe UBO requires ${A} bytes, but this device supports ${e}`,A=>`[babylon-lite] local probe voxel grid requires ${A} bytes, exceeding this device's storage-buffer limits`,A=>`[babylon-lite] local probe sets require 1..${A} probes`,()=>"Environment rotation: skybox direction declaration not found.",(A,e)=>`${A}: expected to rewrite 1 occurrence, rewrote ${e}`,A=>`local probe array _postCompose: expected to rewrite 1 voxel-grid binding declaration, rewrote ${A}`,A=>`local probe array _postCompose: expected to rewrite 1 cube-array binding declaration, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 clearcoat reflection direction, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 clearcoat radiance sample, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 sheen radiance sample, rewrote ${A}`,A=>`local cubemap _postCompose: expected to rewrite 1 reflection direction, rewrote ${A}`,()=>"local cubemap _postCompose: expected at least 1 environment LOD scale rewrite",A=>`local cubemap _postCompose: expected to rewrite 1 base radiance sample, rewrote ${A}`,A=>`[babylon-lite] local cubemap could not replace the scene ${A} binding`,()=>"PBR transmission requires a frame-graph refraction texture.",()=>"composePbrGeometryShader: PBR fragment signature mismatch \u2014 _noColorOutput/_esmShadowOutput should be off",()=>"composePbrGeometryShader: alpha-block return statement not found \u2014 template changed?",()=>"pbr-geometry view does not support scene group building",()=>"pbr-geometry rebuild requires task-owned resources",()=>"buildPbrGeometryRenderable: scene has no PBR context. Ensure regular PBR meshes have been built before recording the geometry task.",()=>"pbr-geometry: render target has no color attachments",A=>`[babylon-lite] local cubemap maxCandidates is already ${A} and cannot be changed after initialization`,A=>`[babylon-lite] local cubemap maxCandidates must be an integer from 1 to ${A}`,()=>"PBR material plugin vertex signature is not registered.",()=>"PBR material plugin vertex uniforms require a material UBO.",A=>`Material plugin varying type "${A}" is unsupported; use a floating-point scalar or vector.`,()=>"Standard material plugin signature is not registered.",()=>"Standard material plugins require an owning scene.",()=>"Standard plugin material requires a scene mesh or a binding owner.",()=>"Standard material plugin signature is not registered.",()=>"setShadowCasterMaterial: the caster chain must not cycle back to the source material",()=>"Async ShaderMaterial pipeline preparation could not capture the synchronous descriptor.",()=>'enableShaderMaterialInstanceWorld requires the ShaderMaterial to declare the "world" system uniform.',A=>`ShaderMaterial: external texture "${A}" has no source. Call setShaderExternalTexture() before rendering.`,A=>`ShaderMaterial: external texture "${A}" is not ready.`,A=>`ShaderMaterial: external texture "${A}" was not declared.`,A=>`ShaderMaterial: external texture "${A}" was not declared.`,(A,e)=>`ShaderMaterial: ${A} name "${e}" is not a valid WGSL identifier.`,()=>"ShaderMaterial: vertexSource and fragmentSource must be non-empty WGSL strings.",()=>"ShaderMaterial: strip topologies are unsupported because indexed draws require a mesh-specific stripIndexFormat.",A=>`ShaderMaterial: unsupported attribute "${A}". Supported attributes: position, normal, uv, uv2, tangent, color, joints, weights, joints1, weights1.`,A=>`ShaderMaterial: duplicate attribute "${A}".`,()=>'ShaderMaterial: "position" attribute is required for mesh rendering.',A=>`ShaderMaterial: define "${A}" must be a boolean or number.`,()=>"ShaderMaterial: `transmissive` requires `needAlphaBlending` (the surface composites over the grabbed opaque scene color).",A=>`ShaderMaterial: custom uniform "${A}" must use an explicit typed declaration.`,(A,e)=>`ShaderMaterial: unsupported uniform type "${A}" for "${e}".`,(A,e)=>`ShaderMaterial: duplicate generated identifier "${A}" while adding ${e}.`,(A,e,g,I)=>`ShaderMaterial: uniform "${A}" of type ${e} expects ${g} value(s), got ${I}.`,A=>`ShaderMaterial: uniform "${A}" was not declared.`,(A,e,g,I)=>`ShaderMaterial: uniform "${A}" of type ${e} expects ${g} value(s), got ${I}.`,A=>`ShaderMaterial: uniform "${A}" was not declared.`,A=>`ShaderMaterial: sampler "${A}" was not declared.`,A=>`ShaderMaterial: sampler "${A}" expects a depth Texture2D.`,A=>`ShaderMaterial: sampler "${A}" cannot use a depth Texture2D.`,A=>`ShaderMaterial: sampler "${A}" was not declared.`,A=>`ShaderMaterial: storage buffer "${A}" was not declared.`,()=>"setShaderStorageBuffer requires a StorageBuffer created by createStorageBuffer; raw GPUBuffer is not supported.",A=>`ShaderMaterial: storage buffer "${A}" has been disposed.`,()=>"setShaderStorageBuffer requires a live StorageBuffer created by createStorageBuffer.",()=>"ShaderMaterial external textures require setShaderExternalTexture before pipeline preparation.",A=>`ShaderMaterial: sampler "${A}" has no Texture2D. Call setShaderTexture() before rendering.`,A=>`ShaderMaterial storage "${A}" is invalid.`,(A,e,g)=>`ShaderMaterial format "${A}" for "${e}" is incompatible with canonical geometry on mesh "${g}".`,(A,e,g)=>`ShaderMaterial format "${A}" for "${e}" does not fit the aligned vertex layout on mesh "${g}".`,()=>"Standard UV transform _bind requires the scene argument from the Standard bind-group builder",()=>"composeStandardGeometryShader: standard fragment signature mismatch \u2014 bypass active?",()=>"composeStandardGeometryShader: 'return color;' not found in composed fragment \u2014 template changed?",()=>"standard-geometry view does not support scene group building",()=>"standard-geometry rebuild requires task-owned resources",()=>"standard-geometry: skeletal velocity feature was not preloaded",()=>"standard-geometry: thin instances were not preloaded",()=>"standard-geometry: morph targets require the scene Standard morph context",()=>"standard-geometry: thin instances were not preloaded",()=>"standard-geometry: skeletal velocity requires a previous-bone texture",()=>"standard-geometry: render target has no color attachments",()=>"Standard material group has not completed its initial build in this scene.",()=>"Dashed lines require at least two points",()=>"createDashedLines produced no dash segments (degenerate points or dashNb)",()=>"updateDashedLines requires a mesh created by createDashedLines",A=>`Line system data requires finite ${A} components`,()=>"Line system data requires one color row per line",()=>"Line system data requires one color per point",()=>"createLineSystemData requires at least one point",()=>"createLineSystem requires material.useVertexColor to match the line color-buffer layout",()=>"updateLineSystem requires a mesh created by createLineSystem",()=>"updateLineSystem requires unchanged line and point counts",()=>"updateLineSystem requires unchanged line and point counts",()=>"updateLineSystem cannot add colors to a mesh created without vertex colors",A=>`createCsgFromMesh("${A}") requires CPU positions. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsgFromMesh("${A}") requires CPU indices. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsgFromMesh("${A}") requires CPU normals. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,(A,e)=>`createMeshesFromCsg("${A}") missing material for CSG material slot ${e}.`,()=>"CSG2 is not initialized. Call and await initializeCsg2Async() before using CSG2 operations.",A=>`${A} cannot use a disposed CSG2 solid.`,A=>`createCsg2FromMesh("${A}") requires CPU positions. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsg2FromMesh("${A}") requires CPU indices. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,A=>`createCsg2FromMesh("${A}") requires CPU normals. Use a Babylon Lite mesh factory or loader that retains CPU geometry.`,(A,e)=>`createCsg2FromMesh("${A}") materialSlot must be an integer from 0 to ${e}.`,()=>"CSG2 operations require solids with the same vertex property layout.",(A,e)=>`createMeshesFromCsg2("${A}") received an unknown Manifold material original ID ${e}.`,A=>`Unable to build CSG2 mesh "${A}". Manifold has 0 vertices for this output.`,(A,e)=>`createMeshesFromCsg2("${A}") missing material for CSG2 material slot ${e}.`,()=>"enableThinInstanceWorldBounds requires mesh.thinInstances",()=>"createHierarchyInstancePool capacity must be a non-negative integer",()=>"createHierarchyInstancePool requires at least one mesh in the source hierarchy",A=>`createHierarchyInstancePool mesh "${A}" already has thin instances`,A=>`createHierarchyInstancePool requires an invertible world matrix for mesh "${A}"`,()=>"addHierarchyInstance exceeded pool capacity",()=>"setHierarchyInstanceCount count must be an integer within pool capacity",A=>`setHierarchyInstanceCount mesh "${A}" is missing thin instance data`,A=>`HierarchyInstancePool mesh "${A}" is missing thin instance data`,A=>`${A} index must reference an active hierarchy instance`,()=>"setMeshDrawRange requires live, owned, unshared, tightly-packed geometry",()=>"setMeshDrawRange requires undeformed uint32 geometry",()=>"setMeshDrawRange requires coherent retained CPU geometry",()=>"setMeshDrawRange requires coherent retained CPU geometry",()=>"setMeshDrawRange requires ranges within geometry capacity and WebGPU limits",()=>"setMeshDrawRange index must be relative to the selected vertex window",()=>"mesh geometry update requires valid ranges within the active geometry",()=>"updateMeshGeometryCapacity requires unshared, tightly-packed mesh geometry",()=>"updateMeshGeometryCapacity requires coherent triangle-list geometry with uint32 indices",()=>"updateMeshGeometryCapacity requires unchanged optional-attribute layout",A=>`mesh attribute updates require unshared, tightly-packed geometry; update the source StorageBuffer instead: ${A}`,()=>"mesh attribute update requires a valid tightly-packed vertex range",()=>"mesh attribute update requires a valid destination vertex range",()=>"updateMeshGeometry requires unshared, tightly-packed mesh geometry",()=>"updateMeshGeometry requires unchanged vertex/index counts; use resizeMeshGeometry for topology changes",()=>"updateMeshGeometry requires unchanged optional-attribute layout; use resizeMeshGeometry for layout changes",()=>"updateMeshGeometryCapacity requires reserveFactor >= 1",A=>`resizeMeshGeometry requires owned, tightly-packed geometry; recreate or update the source StorageBuffer instead: ${A}`,()=>"resizeSharedMeshGeometry requires at least one mesh",()=>"resizeSharedMeshGeometry requires meshes sharing one owned, tightly-packed geometry",()=>"resizeSharedMeshGeometry requires distinct, live meshes sharing one geometry",()=>"createMeshFromStorageBuffer: storage must be created with { vertex: true } so it carries GPUBufferUsage.VERTEX.",A=>`createMeshFromStorageBuffer: arrayStride must be a positive multiple of 4 within maxVertexBufferArrayStride, received ${A}.`,(A,e,g)=>`createMeshFromStorageBuffer: invalid vertex range (${A} vertices at baseVertex ${e}) for a ${g}-byte allocation.`,A=>`createMeshFromStorageBuffer: unsupported attribute offset "${A}".`,A=>`createMeshFromStorageBuffer: offset for "${A}" must be a non-negative integer smaller than arrayStride.`,()=>"createMeshFromStorageBuffer: indices must be a Uint16Array, Uint32Array, or index-capable StorageBuffer.",A=>`createMeshFromStorageBuffer: indexFormat must match the typed-array format "${A}".`,()=>"createMeshFromStorageBuffer: indices must be created with { index: true }.",()=>'createMeshFromStorageBuffer: a shared index allocation requires indexFormat "uint16" or "uint32".',()=>"createMeshFromStorageBuffer: indexCount must be a positive unsigned 32-bit integer.",(A,e)=>`createMeshFromStorageBuffer: indexCount ${A} exceeds the index source capacity of ${e}.`,(A,e,g)=>`createMeshFromStorageBuffer: indices[${A}] (${e}) must be less than vertexCount ${g}.`,()=>"setMeshIndexedIndirect: mesh has been disposed.",()=>"setMeshIndexedIndirect: only plain meshes without thin instances are supported.",()=>"setMeshIndexedIndirect: mesh must use a ShaderMaterial.",()=>"setMeshIndexedIndirect: mesh must have storage-backed geometry.",()=>"setMeshIndexedIndirect: storage-backed geometry must belong to the same engine and device; recreate its allocations and mesh.",()=>"setMeshIndexedIndirect: geometry changed; recreate or explicitly rebind the consumer.",()=>"setMeshIndexedIndirect: index allocation changed; explicitly rebind the consumer.",()=>"setMeshIndexedIndirect: mesh has been disposed.",()=>"setMeshIndexedIndirect: arguments must be a live StorageBuffer or null.",()=>"setMeshIndexedIndirect: cannot change a borrow while a frame encoder is active.",()=>"setMeshIndexedIndirect: arguments must be created with { indirect: true }.",()=>"setMeshIndexedIndirect: byteOffset must be a non-negative safe integer and multiple of 4.",(A,e)=>`setMeshIndexedIndirect: twenty-byte arguments at offset ${A} exceed the buffer's ${e}-byte capacity.`,()=>"setMeshIndexedIndirect: unbinding requires byteOffset zero.",()=>"setMeshIndexedIndirect: cannot change a borrow while a frame encoder is active.",()=>"setMeshIndexedIndirect: unbind arguments before replacing ShaderMaterial with another material family.",()=>"setMeshIndexedIndirect: unbind arguments before enabling thin instances.",()=>"getMeshIndexedDrawInfo: mesh has been disposed.",()=>"getMeshIndexedDrawInfo: only plain meshes without thin instances are supported.",()=>"Thin-instance LOD partners require an opaque, non-transmissive material",()=>"Thin-instance LOD partner requires the source draw to provide instance colors",()=>"setThinInstanceDrawCount requires a fully synchronized fixed-capacity pool",()=>"enableThinInstanceDynamicDrawCount requires mesh.thinInstances",()=>"enableThinInstanceGpuCulling requires mesh.thinInstances",()=>"setThinInstanceCullBoundsPad requires mesh.thinInstances",()=>"setThinInstanceLodPartner requires thinInstances on both meshes",()=>"setThinInstanceLodPartner requires two distinct meshes",()=>"setThinInstanceLodPartner does not support thin-instance data shared by mesh clones",()=>"setThinInstanceLodPartner fullMesh cannot already be an LOD partner",()=>"setThinInstanceLodPartner lodMesh cannot also own an LOD partner",()=>"setThinInstanceLodPartner lodMesh is already paired with another source mesh",()=>"setThinInstanceLodPartner requires source instance colors when the LOD partner uses instance colors",A=>`createNavMesh (tile cache) failed: ${A}`,A=>`createNavMesh (tiled) failed: ${A}`,A=>`createNavMesh failed: ${A}`,A=>`Mesh "${A}" missing CPU geometry for navmesh`,()=>"No navmesh generated. Call createNavMesh first.",()=>"Navmesh not ready. Call createNavMesh first.",()=>"Navmesh has no tile cache. Build with `maxObstacles > 0` to enable obstacles.",()=>"NodeParticle: BasicSpriteUpdateBlock requires SetupSpriteSheetBlock",()=>"NodeParticle: LocalPositionUpdated requires SystemBlock.isLocal",()=>"NodeParticle: LocalPositionUpdated read before local shape position creation",A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} received an unsupported value`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} changed value type`,()=>"NodeParticle: emitter provider must return a finite 16-element matrix",()=>"NodeParticle: emitter provider must return a finite 16-element matrix",(A,e)=>`NodeParticle: ParticleTeleportInBlock ${A} does not expose output "${e}"`,(A,e,g)=>`NodeParticle: ${A} ${e} does not expose output "${g}"`,A=>`NodeParticle: graph plumbing cycle ${A}`,(A,e,g)=>`NodeParticle: ${A} ${e} does not support ${g} connections`,A=>`NodeParticle: ParticleTeleportOutBlock ${A} has invalid entryPoint`,(A,e)=>`NodeParticle: ParticleTeleportOutBlock ${A} references missing entryPoint ${e}`,(A,e)=>`NodeParticle: ParticleTeleportOutBlock ${A} entryPoint ${e} is not ParticleTeleportInBlock`,A=>`NodeParticle: graph plumbing cycle ${A}`,A=>`NodeParticle: ParticleTeleportInBlock ${A} input is not connected`,(A,e)=>`NodeParticle: ${A} ${e} input is not connected`,A=>`NodeParticle: ParticleLocalVariableBlock ${A} Particle scope requires particle-only evaluation`,()=>"NodeParticle: invalid source \u2014 expected a `blocks` array",A=>`NodeParticle: block missing numeric id (name=${A})`,()=>"NodeParticle: graph has no SystemBlock",A=>`NodeParticle: failed to load texture "${A}"`,()=>"NodeParticle: unable to decode texture content",()=>"BillboardSpriteSystem requires a depth-stencil render target.",()=>"createParticleBillboard: the particle system has no texture",A=>`syncParticleSprite2DBridgeWithBlendModes: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`syncParticleSprite2DBridgeWithBlendModes: originPx must be finite, got [${A}, ${e}]`,()=>"syncParticleSprite2DBridgeWithBlendModes: bridge-owned layers cannot use the Sprite2D Handle API",()=>"createParticleSprite2DBridge: the particle system has no texture",A=>`createParticleSprite2DBridge: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`createParticleSprite2DBridge: originPx must be finite, got [${A}, ${e}]`,()=>"syncParticleSprite2DBridge: the bridge-owned layer cannot use the Sprite2D Handle API",A=>`syncParticleSprite2DBridge: pixelsPerUnit must be a positive finite number, got ${A}`,(A,e)=>`syncParticleSprite2DBridge: originPx must be finite, got [${A}, ${e}]`,()=>"createHeightFieldShape requires either a groundMesh or full explicit heightfield parameters.",()=>"createHeightFieldShape ground mesh has no vertex positions.",A=>`createHeightFieldShape requires a regular (N+1)\xD7(N+1) grid mesh (e.g. from createGroundFromHeightMap); got ${A} vertices, which is not the square of an integer \u2265 2.`,()=>"createHeightFieldShape ground mesh has zero extent in X or Z; cannot build a heightfield.",()=>"Failed to read physics body mass properties.",()=>"Failed to read physics body mass properties.",A=>`Unknown physics rotation axis "${A}".`,()=>"Thin-instance physics requires a nonsingular carrier world transform.",()=>"Thin-instance physics bodies do not support floating-origin worlds.",()=>"Thin-instance physics requires a non-empty matrix buffer before body creation.",()=>"Cannot create physics mesh shape from a singular root transform.",()=>"Cannot create physics mesh shape without vertex positions.",()=>"Cannot create physics mesh shape without triangle indices.",()=>"Physics mesh shapes require a mesh or transform hierarchy.",A=>`Unsupported shape type: ${A}`,()=>"Cannot add physics child shape from a singular parent transform.",()=>"createPhysicsAggregate supports only primitive physics shapes.",(A,e,g)=>`Default GPU picking cannot read "${A}" format "${e}" on mesh "${g}". Use compatible float32 data or exclude this mesh from picking.`,A=>`BloomPostProcessTask "${A}": sourceTexture must have a format.`,A=>`BloomPostProcessTask "${A}": sourceTexture must have a format.`,A=>`DepthOfFieldPostProcessTask "${A}": sourceTexture must have a format.`,A=>`MeshBlendingPostProcessTask "${A}": sourceTexture must have a color format.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} and outputTexture must not alias.`,A=>`MeshBlendingPostProcessTask "${A}": blended rgba32float output requires the float32-blendable WebGPU feature.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must be single-sample.`,(A,e,g)=>`MeshBlendingPostProcessTask "${A}": ${e} has unsupported format "${g}".`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must be a built 2D color render target.`,(A,e)=>`MeshBlendingPostProcessTask "${A}": ${e} must have the same physical dimensions as outputTexture.`,A=>`MeshBlendingPostProcessTask "${A}": camera projection matrix must be invertible.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceContactShadowsPostProcessTask "${A}": depth source has no depth attachment.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": sourceTexture must be single-sample.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": depthTexture must be single-sample.`,A=>`ScreenSpaceGlobalIlluminationPostProcessTask "${A}": depth source has no depth attachment.`,()=>"setRenderDrawIndirect: buffer must be a live allocation of the same engine created with indirect: true.",(A,e,g)=>`setRenderDrawIndirect: ${A} argument bytes at offset ${e} must fit the ${g}-byte buffer at a multiple of 4.`,A=>`RenderDrawTask "${A}" has been disposed.`,A=>`RenderDrawTask "${A}" has been disposed.`,A=>`RenderDrawTask "${A}" and its draw belong to different engines.`,A=>`RenderDrawTask "${A}" has been disposed.`,(A,e)=>`RenderDraw: ${A} must be an unsigned 32-bit integer, received ${e}.`,(A,e)=>`RenderDraw ${A}: ${e} buffer is disposed or belongs to a different engine.`,(A,e,g)=>`RenderDraw ${A}: ${e} buffer was not created with the ${g} usage.`,()=>"RenderDraw: binding set belongs to a different RenderShader.",(A,e,g)=>`RenderDraw "${A}": the shader declares ${e} vertex buffers, received ${g}.`,A=>`RenderDraw: binding "${A}" is not a dynamic buffer binding.`,(A,e)=>`RenderDraw: dynamic offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`RenderDraw: dynamic offset for "${A}" exceeds the bound buffer range.`,()=>"Alpha-to-coverage is not supported for NodeMaterial.",()=>"Uniform copies require 4-byte-aligned sizes and destination offsets.",A=>`createStorageBuffer: byte length must be a non-negative safe integer; received ${A}.`,(A,e)=>`createStorageBuffer: aligned byte length ${A} must be a safe integer within device maxBufferSize (${e}).`,()=>"StorageBuffer belongs to a previous device; recreate GPU-role allocations and rerun their producers after device loss.",()=>"StorageBuffer has been disposed.",()=>"StorageBuffer belongs to a different engine.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer has been disposed.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer belongs to a different engine.",()=>"StorageBuffer is not a live registered allocation.",()=>"StorageBuffer byteOffset must be a non-negative multiple of 4.",()=>"StorageBuffer update data must have a byte length that is a multiple of 4.",A=>`StorageBuffer update exceeds its ${A}-byte capacity.`,()=>"StorageBuffer is not a live registered allocation.",A=>`Mesh "${A}" cannot be added: it was disposed when it left its last scene. Create a new mesh instead.`,A=>`morph _postCompose: expected to rewrite 2 binding declarations, rewrote ${A}`,()=>"getCsmReceiverTexture requires a CSM shadow generator",()=>"Render-task transfers require live tasks in the same scene.",()=>"Deformable shadows require a fully initialized shadow generator",()=>"setShadowGeneratorEnabled requires a configured shadow generator.",A=>`Device-lost Scene recovery does not support shadow generator type "${A}"`,()=>"Device-lost Scene recovery could not find ESM shadow resources",()=>"Device-lost Scene recovery failed to create ESM shadow resources",()=>"AnimationController.tick requires an EngineContext for skeleton or morph animation",()=>"Cannot update disposed skeleton",()=>"Invalid bone matrices",()=>"createBillboardCustomShader: `fragment` must be a non-empty WGSL string.",()=>"BillboardSpriteSystem requires a depth-stencil render target.",()=>"addBillboardSprite: handle id space exhausted.",(A,e)=>`${A}: BillboardSpriteHandle ${e} has been removed.`,()=>"BillboardSpriteSystem: alphaCutoff must be a finite number.",()=>"BillboardSpriteSystem: opacity must be a finite number.",()=>"createAxisLockedBillboardSystem: axis components must be finite numbers.",()=>"createAxisLockedBillboardSystem: axis must be non-zero.",()=>"addBillboardSpriteIndex: props.position is required.",()=>"addBillboardSpriteIndex: props.sizeWorld is required.",(A,e)=>`updateBillboardSpriteIndex: index ${A} out of range [0, ${e})`,(A,e)=>`removeBillboardSpriteIndex: index ${A} out of range [0, ${e})`,(A,e)=>`setBillboardSpriteFrameIndex: index ${A} out of range [0, ${e})`,(A,e)=>`${A}: extra texture name "${e}" is not a valid WGSL identifier.`,(A,e,g,I)=>`${A}: frame ${e} has non-positive size ${g}x${I}.`,(A,e,g,I)=>`${A}: frame ${e} has negative sub-rect origin (srcX=${g}, srcY=${I}).`,(A,e,g,I)=>`${A}: frame ${e} sub-rect row extent (srcX + width) * 4 = ${g} exceeds srcStrideBytes ${I} (would spill into next row).`,(A,e,g,I)=>`${A}: frame ${e} width ${g} exceeds shelf max width ${I}.`,(A,e,g,I,i,C)=>`${A}: cannot fit frame ${e} (${g}x${I}) \u2014 atlas height capacity ${i} exhausted at y=${C}.`,()=>"createSpriteAtlasFromFrames: at least one frame is required, or pass options.capacityPx to create an empty atlas with reserved capacity for appendSpriteAtlasFrames.",(A,e)=>`createSpriteAtlasFromFrames: atlas dimensions must be >= 1 (got ${A}x${e}).`,(A,e,g,I)=>`createSpriteAtlasFromFrames: capacityPx ${A}x${e} too small for initial content ${g}x${I}.`,()=>"appendSpriteAtlasFrames: atlas was not built by createSpriteAtlasFromFrames (no packer state).",()=>"loadSpriteAtlas: metadataUrl unsupported.",()=>"loadSpriteAtlas: gridSize required.",(A,e)=>`resolveSpriteFrame: index ${A} out of range [0, ${e})`,()=>"addSprite2D: handle id space exhausted.",(A,e)=>`${A}: Sprite2DHandle ${e} has been removed.`,()=>"enableSprite2DInstanceParams: layer requires a customShader.",()=>"enableSprite2DInstanceParams: another instance extension is already installed.",()=>"setSprite2DInstanceParamsIndex: enableSprite2DInstanceParams must be called first.",(A,e)=>`setSprite2DInstanceParamsIndex: index ${A} out of range [0, ${e})`,()=>"setSprite2DInstanceParamsIndex: params must contain exactly four numbers.",()=>"setSprite2DInstanceParamsIndex: params must be finite Float32 values.",()=>'enableSprite2DYSort: only depth: "none" layers are supported.',()=>"enableSprite2DYSort: defaultBias must be finite.",()=>"setSprite2DYSortBias: Y-sort is not enabled for this layer.",(A,e)=>`setSprite2DYSortBias: index ${A} out of range [0, ${e})`,()=>"setSprite2DYSortBias: bias must be finite.",()=>"addSprite2DIndex: positionPx required.",(A,e)=>`updateSprite2DIndex: index ${A} out of range [0, ${e})`,(A,e)=>`removeSprite2DIndex: index ${A} out of range [0, ${e})`,(A,e)=>`setSprite2DFrameIndex: index ${A} out of range [0, ${e})`,()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"SpriteAnimationManager is already running autonomously.",()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"Sprite frame animation requires finite from/to frame indices.",()=>"Sprite frame animation requires finite from/to frame indices.",()=>"SpriteAnimationManager is already attached to a render loop.",()=>"SpriteAnimationManager is already attached to an AnimationManager.",()=>"SpriteAnimationManager is already running autonomously.",()=>"createSprite2DCustomShader: `fragment` must be a non-empty WGSL string.",()=>"Sprite pipeline: depth-enabled pipelines require a depth-stencil format.",()=>"Sprite pipeline: depth-enabled pipelines require a scene bind-group layout.",()=>'Depth-hosted sprites require depth != "none".',()=>"Depth-hosted Sprite2DLayer requires a depth-stencil render target.",()=>'SpriteRenderer requires depth: "none".',()=>"SpriteRenderer has been disposed.",A=>`TextData style palette cannot exceed ${A} entries.`,(A,e)=>`updateTextData ${A}: storage does not contain curveSet "${e}" \u2014 add it via updateGlyphStorage first.`,(A,e,g)=>`${A}: run index ${e} out of range (0..${g}).`,A=>`${A}: GlyphRun reference is not in this TextData.`,()=>"updateTextData addRun: GlyphRun reference is already in this TextData.",()=>"updateTextData removeRun: GlyphRun reference is not in this TextData.",()=>"updateTextData replaceRun: previous GlyphRun reference is not in this TextData.",()=>"updateTextData replaceRun: new GlyphRun reference is already in this TextData.",A=>`TextData style palette cannot exceed ${A} entries.`,()=>"Basis: no images in file",()=>"Basis: startTranscoding failed",A=>`Basis: transcoded size is 0 for mip ${A}`,A=>`Basis: transcodeImage failed for mip ${A}`,(A,e)=>`createDynamicTexture: width/height must be >= 1 (got ${A}x${e})`,()=>"createTexture2DFromExternalImage: texture creation did not produce GPU resources",()=>"createHtmlTexture: requires a DOM canvas rendering surface (HTML-in-Canvas is unavailable on OffscreenCanvas).",()=>"KTX: file too small",()=>"KTX: invalid magic",()=>"KTX: unsupported endianness",()=>"KTX: not a compressed texture (glType != 0)",()=>"KTX: not a compressed texture (glFormat != 0)",A=>`KTX: unknown glInternalFormat 0x${A}`,()=>"KTX: 3D textures not supported",()=>"KTX: texture arrays not supported",()=>"KTX: cubemaps not supported (use loadCubeTexture)",()=>"KTX: key/value data overflows buffer",A=>`KTX: truncated at mip ${A} size field`,A=>`KTX: mip ${A} data overflows buffer`,()=>"KTX: no mip levels found",A=>`KTX fetch failed: ${A}`,A=>`KTX2: ${A}`,()=>"KTX2: decoder produced no mipmaps",A=>`KTX2: decoder produced an empty mip ${A}`,A=>`KTX2: device does not support ${A}`,(A,e,g)=>`KTX2: uncompressed mip ${A} has ${e} bytes, expected ${g}`,A=>`KTX2: unsupported transcoded format 0x${A}`,(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,()=>"KTX2: RGBA decode size does not match image dimensions",A=>`KTX2: ${A}`,()=>"KTX2: decoder produced no mipmaps",(A,e)=>`KTX2: expected ${A} base-level layers but decoded ${e}`,(A,e,g,I)=>`KTX2: base-level layer ${A} is malformed (expected ${e}x${g}, ${I} bytes)`,(A,e)=>`createTexture2DFromPixels: width/height must be >= 1 (got ${A}x${e})`,(A,e,g,I)=>`createTexture2DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${g} RGBA, got ${I}`,(A,e)=>`createRenderTexture2D: width/height must be >= 1 (got ${A}x${e})`,(A,e)=>`updateTexture2DFromPixels: width/height must be >= 1 (got ${A}x${e})`,(A,e,g,I)=>`updateTexture2DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${g} RGBA, got ${I}`,(A,e,g)=>`createTexture3DFromPixels: width/height/depth must be >= 1 (got ${A}x${e}x${g})`,(A,e,g,I,i)=>`createTexture3DFromPixels: data too short \u2014 need ${A} bytes for ${e}x${g}x${I} RGBA, got ${i}`,()=>"withSampledDepthTexture requires a single-sample depth attachment.",()=>"createSurfaceRenderTargetTexture: descriptor.size must be a SurfaceContext or { surface, scale }.",()=>"RenderTargetTexture has been disposed.",()=>"RenderTargetTexture cannot resize recursively from a resize callback.",()=>"RenderTargetTexture attachment configuration cannot change during resize.",()=>"RenderTargetTexture has been disposed.",()=>"RenderTargetTexture has been disposed.",()=>"Depth-only render-target textures require withSampledDepthTexture as the third argument.",()=>"createRenderTargetTexture: render target has no color or depth texture (no format / depthStencilFormat?).",()=>"createRenderTargetTexture: descriptor.size must be fixed { width, height } pixels, not a surface-backed size; use createSurfaceRenderTargetTexture for surface-resizing targets.",(A,e,g)=>`createTexture2DArray: width/height/layers must be >= 1 (got ${A}x${e}x${g})`,(A,e)=>`uploadImageToArrayLayer: layer must be an integer in [0, ${A}) (got ${e})`,(A,e)=>`loadImageToArrayLayer: fetch failed for ${A} (${e})`,(A,e)=>`createTexture2DArrayFromUrls: fetch failed for ${A} (${e})`,(A,e,g,I,i)=>`createTexture2DArrayFromUrls: all layers must share one size; layer 0 is ${A}x${e} but layer ${g} is ${I}x${i}`,A=>`Texture array pixel uploads require rgba8unorm or rgba8unorm-srgb, received ${A}.`,(A,e)=>`updateTexture2DArrayFromPixels: mipLevel must be an integer in [0, ${A}) (got ${e})`,(A,e,g,I,i,C)=>`updateTexture2DArrayFromPixels: data too short \u2014 need ${A} bytes for ${e}x${g}x${I} RGBA at mip ${i}, got ${C}`,()=>"KTX2: the decoder does not report layerCount; a decoder with 2D array support is required (see setKtx2DecoderUrl)",(A,e)=>`KTX2: decoder produced ${A} mips, which is not a whole number of ${e}-layer levels`,(A,e,g)=>`KTX2: expected layer ${A} at mip index ${e} but the decoder reported layer ${g}`,(A,e)=>`KTX2: layers of one mip level must share a size (level ${A}, layer ${e})`,(A,e)=>`KTX2: decoder reported invalid dimensions ${A}x${e}`,(A,e)=>`KTX2: decoder produced invalid base mip dimensions ${A}x${e}`,(A,e,g,I,i)=>`KTX2: mip ${A} has size ${e}x${g}, expected ${I}x${i}`,(A,e,g)=>`KTX2: texture dimensions ${A}x${e} exceed maxTextureDimension2D ${g}`,(A,e)=>`KTX2: array has ${A} layers, exceeding maxTextureArrayLayers ${e}`,(A,e,g,I)=>`KTX2: texture ${A}x${e} has ${g} mip levels, exceeding the maximum ${I}`,A=>`KTX2: device does not support ${A}`,(A,e,g,I)=>`KTX2: compressed dimensions ${A}x${e} are not aligned to ${g}x${I} blocks; texture-compression-unaligned is required`,(A,e,g,I)=>`KTX2: compressed mip ${A} layer ${e} has ${g} bytes, expected ${I}`,(A,e,g,I)=>`KTX2: uncompressed mip ${A} layer ${e} has ${g} bytes, expected ${I}`,A=>`KTX2: unsupported transcoded format 0x${A}`,()=>"KTX2: texture-array upload did not produce GPU resources",A=>`KTX2: GPU device was lost or replaced during texture-array upload${A}`,()=>"KTX2: at least one separate layer buffer is required",(A,e)=>`KTX2: separate layer ${A} reports layerCount ${e}; expected one 2D layer`,A=>`KTX2: separate layer ${A} has a different transcoded format`,(A,e,g,I,i)=>`KTX2: separate layer ${A} has size ${e}x${g}, expected ${I}x${i}`,(A,e,g)=>`KTX2: separate layer ${A} has ${e} mip levels, expected ${g}`,(A,e,g,I,i,C)=>`KTX2: separate layer ${A} mip ${e} has size ${g}x${I}, expected ${i}x${C}`,()=>"KTX2: at least one separate layer buffer is required",(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,()=>"KTX2: at least one separate layer URL is required",(A,e)=>`KTX2 fetch failed: ${A} for ${e}`,(A,e,g,I)=>`updateTextureRegion: ${A} must be an integer in [${e}, ${g}], received ${I}.`,()=>"updateTextureRegion: the texture requires copy-destination usage and sampleCount 1.",A=>`updateTextureRegion: ${A} does not support CPU writes with the default copy aspect.`,(A,e)=>`updateTextureRegion: origin and extent must be multiples of the ${A}x${e} texel block.`,()=>"updateTextureRegion: depth/stencil copies must cover the full physical mip width and height.",(A,e,g,I,i)=>`updateTextureRegion: ${A} source bytes cannot hold ${e}\xD7${g}\xD7${I} texels at ${i} bytes per row.`,()=>"createTextureRenderTarget: the texture was not created with render-attachment usage.",A=>`createTextureRenderTarget: ${A} textures cannot be render targets.`,(A,e)=>`createTextureRenderTarget: layer must be an integer in [0, ${A}), received ${e}.`,(A,e)=>`createTextureRenderTarget: mipLevel must be an integer in [0, ${A}), received ${e}.`,()=>"Texture render target has been disposed.",()=>"CPU-only animation evaluation is unavailable for this animation controller",A=>`VAT prepared payload: ${A} must be a positive integer.`,A=>`VAT prepared payload: ${A} must be a record.`,(A,e)=>`VAT prepared payload: ${A} contains invalid bone index "${e}".`,(A,e)=>`VAT prepared payload: ${A}[${e}] has an invalid length.`,()=>"VAT prepared payload: data length must equal boneCount * frameCount * 16.",()=>"VAT prepared payload: clips must be a record.",A=>`VAT prepared payload: clip "${A}" is invalid.`,A=>`VAT preparation: mesh "${A}" has no skeleton to bake.`,(A,e)=>`VAT preparation: mesh "${A}" has no skeleton binding for clip "${e}".`,A=>`VAT preparation: mesh "${A}" has inconsistent bone counts.`,()=>"setVatInstanceStorage: mesh has no VAT data.",()=>"setVatInstanceStorage requires a live StorageBuffer from the same engine.",()=>"setVatTime: mesh has no VAT data.",()=>"attachVat: mesh has no skeleton (bake first, attach before clearing it).",()=>"controllerModels requires XR input tracking; do not pass input:false to enterXr.",()=>"handTracking requires XR input tracking; do not pass input:false to enterXr.",()=>"pointerSelection requires XR input tracking; do not pass input:false to enterXr.",()=>"WebXR is not available (navigator.xr missing).",()=>"WebGPU XR is not supported by this browser (XRGPUBinding missing).",()=>"teleportation requires XR input tracking; do not pass input:false to enterXr.",()=>"Compute binding declaration was not created by a supported resource helper.",(A,e)=>`ComputeBindingSet: resource "${A}" was not declared by ComputeShader "${e}".`,A=>`ComputeBindingSet: binding "${A}" has no resource.`,A=>`ComputeBindingSet for "${A}" has been disposed.`,A=>`ComputeBindingSet: binding "${A}" received the wrong buffer resource type.`,A=>`ComputeBindingSet: resource for "${A}" has been disposed or lost with its previous device; recreate it.`,A=>`ComputeBindingSet: resource for "${A}" belongs to a different engine.`,A=>`ComputeBindingSet: writable binding "${A}" received a read-only resource.`,(A,e)=>`ComputeBindingSet: offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`ComputeBindingSet: dynamic binding "${A}" requires size or a non-zero minBindingSize.`,A=>`ComputeBindingSet: size for "${A}" must be a positive multiple of 4.`,A=>`ComputeBindingSet: binding "${A}" must expose at least 4 bytes.`,(A,e,g)=>`ComputeBindingSet: binding "${A}" provides ${e} bytes but requires at least ${g} bytes.`,(A,e)=>`ComputeBindingSet: binding "${A}" exceeds this device's maximum binding size of ${e} bytes.`,(A,e)=>`ComputeBindingSet: binding "${A}" exceeds its ${e}-byte allocation.`,()=>"ComputeBindingSet contains a disposed or invalid buffer resource.",(A,e,g,I,i)=>`ComputeDispatch: ${A} workgroup dimension must be an integer in [0, ${e}], received ${g}x${I}x${i}.`,()=>"ComputeDispatch: binding set belongs to a different ComputeShader.",A=>`ComputeDispatch: binding "${A}" is not a dynamic buffer binding.`,(A,e)=>`ComputeDispatch: dynamic offset for "${A}" must be a non-negative multiple of ${e}.`,A=>`ComputeDispatch: dynamic offset for "${A}" exceeds the bound buffer range.`,A=>`WebGPU adapter does not support required feature "${A}".`,A=>`ComputeDispatch: immediate data must initialize all ${A} bytes before dispatch.`,()=>"createComputeImmediateShader requires WGSL immediate_address_space support.",A=>`createComputeImmediateShader: immediateByteLength must be a positive multiple of 4 no larger than ${A}.`,()=>"setComputeDispatchImmediates requires a shader created with createComputeImmediateShader.",(A,e)=>`setComputeDispatchImmediates requires exactly ${A} bytes, received ${e}.`,()=>"ComputeDispatch: indirect buffer must be created with { indirect: true }.",()=>"ComputeDispatch: indirect byteOffset must be a non-negative multiple of 4.",(A,e)=>`ComputeDispatch: indirect arguments at ${A} exceed the buffer's ${e}-byte capacity.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" already has one-shot scheduling.`,A=>`Compute pipeline override "${A}" must have a non-empty name or decimal @id from 0 to 65535 with a finite value.`,A=>`Compute pipeline variant for "${A}" belongs to a lost or replaced GPU device; recreate it.`,()=>"Compute pipeline variants require explicit binding layouts.",A=>`ComputeBindingSet: sampler resource for "${A}" is invalid or belongs to a different engine.`,(A,e,g)=>`ComputeBindingSet: sampler "${A}" has type ${e}, expected ${g}.`,()=>"ComputeBindingSet contains an invalid sampler resource.",A=>`ComputeShader: ${A} must not be empty.`,(A,e)=>`ComputeShader: ${A} must be a non-negative integer, received ${e}.`,()=>"ComputeShader: computeSource must not be empty.",(A,e)=>`ComputeShader: group ${A} exceeds this device's maxBindGroups (${e}).`,(A,e)=>`ComputeShader: binding ${A} exceeds this device's maxBindingsPerBindGroup (${e}).`,A=>`ComputeShader: binding name "${A}" is declared more than once.`,(A,e)=>`ComputeShader: group ${A} binding ${e} is declared more than once.`,A=>`ComputeShader: minBindingSize for "${A}" must be a non-negative multiple of 4.`,A=>`ComputeShader: automatic layouts do not support dynamic offset binding "${A}".`,(A,e,g)=>`ComputeShader: ${A} ${e} exceed this device's limit of ${g}.`,A=>`ComputeShader "${A}" has been disposed.`,A=>`ComputeShader "${A}" belongs to a lost or replaced GPU device; recreate the compute graph.`,A=>`ComputeShader "${A}" pipeline preparation did not complete on its owning device.`,A=>`computeStorageBufferBinding: access must be "read" or "read-write", received "${A}".`,A=>`ComputeBindingSet: storage texture for "${A}" is invalid or belongs to a different engine.`,(A,e,g)=>`ComputeBindingSet: storage texture "${A}" has format ${e}, expected ${g}.`,(A,e,g)=>`ComputeBindingSet: storage texture "${A}" uses a ${e} view, expected ${g}.`,(A,e)=>`ComputeBindingSet: storage texture "${A}" was not validated for ${e} access.`,()=>"ComputeBindingSet contains an invalid storage texture resource.",A=>`computeStorageTextureBinding: format "${A}" is not supported.`,()=>"Compute storage texture mipmap task requires at least one resource.",()=>"Compute storage texture mipmap task requires same-engine sampled 2D filterable-float resources created with mipMaps: true; rgba8snorm also requires texture-formats-tier1.",A=>`Compute storage texture mipmap task "${A}" contains a disposed resource.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeTask "${A}" and its dispatch belong to different engines.`,()=>"submitComputeTasks requires tasks from the same engine.",A=>`ComputeTask "${A}" must be recorded and active before direct submission.`,()=>"submitComputeTasks cannot run while a frame is being recorded.",A=>`ComputeTask "${A}" has been disposed.`,A=>`ComputeBindingSet: texture resource for "${A}" is invalid or belongs to a different engine.`,(A,e,g)=>`ComputeBindingSet: texture "${A}" has sample type ${e}, expected ${g}.`,A=>`ComputeBindingSet: texture "${A}" multisampling does not match its declaration.`,(A,e,g)=>`ComputeBindingSet: texture "${A}" uses a ${e} view, expected ${g}.`,()=>"ComputeBindingSet contains an invalid texture resource.",()=>"ComputeBindingSet contains a texture from a different engine.",()=>"computeTextureBinding: multisampled float textures require sampleType unfilterable-float.",()=>"createComputeTextureResource: stencil texture views are not currently supported.",()=>"createComputeTextureResource: only 2D texture views are currently supported.",(A,e)=>`createComputeTextureResource: declared sample type ${A} is incompatible with texture format ${e}.`,A=>`createComputeTextureViewResource: declared multisampled=${A} does not match the texture.`,A=>`createComputeTextureViewResource: multisampled textures require a 2d view, received ${A}.`,()=>"createComputeTextureResource: engine device changed during validation; retry with the recovered texture.",A=>`createComputeTextureResource: texture is incompatible with this engine: ${A}`,()=>"ComputeBindingSet contains an invalid texture resource.",A=>`ComputeTask "${A}" has been disposed.`,()=>"ComputeUniformArena: slotByteLength must be a positive safe integer and a multiple of 4.",()=>"ComputeUniformArena: slotCount must be a positive safe integer.",()=>"ComputeUniformArena: aligned stride and total byte length must be safe integers.",()=>"ComputeUniformArena has been disposed.",A=>`ComputeUniformArena: slot must be an integer in [0, ${A}].`,()=>"ComputeUniformArena: byteOffset must be a non-negative multiple of 4.",()=>"ComputeUniformArena: update data must have a byte length that is a multiple of 4.",A=>`ComputeUniformArena: update exceeds the slot's ${A}-byte capacity.`,A=>`createUniformBuffer: byte length must be a non-negative safe integer, received ${A}.`,(A,e)=>`createUniformBuffer: aligned byte length ${A} must be a safe integer within device maxBufferSize (${e}).`,()=>"UniformBuffer has been disposed.",()=>"UniformBuffer belongs to a different engine.",()=>"UniformBuffer is not a live registered allocation.",()=>"UniformBuffer byteOffset must be a non-negative multiple of 4.",()=>"UniformBuffer update data must have a byte length that is a multiple of 4.",A=>`UniformBuffer update exceeds its ${A}-byte capacity.`,()=>"UniformBuffer is not a live registered allocation.",()=>'createComputeUniformF16Writer requires createEngineWithFeatures(..., { requiredFeatures: ["shader-f16"] }).',A=>`ComputeUniformLayout: unsupported field type "${A}".`,()=>"ComputeUniformLayout requires at least one field.",()=>"ComputeUniformLayout: field name must not be empty.",A=>`ComputeUniformLayout: duplicate field "${A}".`,(A,e)=>`ComputeUniformWriter: layout requires ${A} bytes but arena slots contain ${e} bytes.`,()=>"ComputeUniformWriter: f16 fields require createComputeUniformF16Writer.",()=>"ComputeUniformWriter targets a disposed uniform arena.",A=>`ComputeUniformWriter: field "${A}" was not declared.`,(A,e)=>`${A}: field type ${e} is not supported by this setter.`,(A,e)=>`${A}: field type ${e} does not match this setter.`,()=>"ComputeUniformWriter: f16 writes require createComputeUniformF16Writer.",(A,e,g,I)=>`${A}: field "${e}" expects ${g} values, received ${I}.`,(A,e)=>`setComputeUniform: field "${A}" expects ${e} values, received 1.`,(A,e,g)=>`ComputeStorageTexture: ${A} must be a positive integer no larger than ${e}, received ${g}.`,()=>"ComputeStorageTexture: 1d textures require height=1 and depthOrArrayLayers=1.",()=>"ComputeStorageTexture: mipMaps is not supported for 1d textures.",()=>"ComputeStorageTexture: 2d textures require depthOrArrayLayers=1; use 2d-array for layers.",A=>`ComputeStorageTexture: unsupported access "${A}".`,()=>"ComputeStorageTexture: at least one access mode is required.",()=>"createComputeStorageTexture: engine device changed during validation; recreate the resource on the current device.",A=>`createComputeStorageTexture: unsupported format, dimension, or access combination: ${A}`,()=>"ComputeStorageTexture: format must be a GPU texture format string.",(A,e,g)=>`ComputeStorageTexture: ${A} (${e}) is incompatible with a ${g} sampler.`,A=>`ComputeStorageTexture2D: dimensions must be positive integers no larger than ${A}.`,A=>`ComputeStorageTexture2D: format "${A}" is not supported.`,()=>"ComputeStorageTexture: sampled outputs require validated sample metadata.",()=>"ComputeStorageTexture2D has been disposed.",()=>"ComputeStorageTexture2D is not a live registered allocation.",()=>"ComputeStorageTexture2D cannot be disposed while sampled facades are still owned.",A=>`Invalid ARIA attribute: ${A}`,(A,e)=>`Conflicting accessibility state: ${A} and ${e}.`,()=>"Accessibility tree is disposed.",()=>"Accessibility node does not belong to this tree.",()=>"Accessibility ordering requires a sibling in the same tree.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Accessibility parent would create a cycle.",()=>"Scene accessibility is disposed.",()=>"Cannot create accessibility for a disposed scene.",()=>"The scene already has an accessibility projection.",()=>"A DOM canvas with a parent element is required when createSceneHtmlTwin is called without options.parent."];function MeA(A,e){const g=XvA[A];return g?g(...e):`Error #${A}`}rA();function $vA(){S3A(MeA)}function A8A(A){if(!(A instanceof Error))return String(A);const e=A.lite;if(!Array.isArray(e))return A.message;const g=/^#(\d+)$/.exec(A.message);return g?MeA(Number(g[1]),e):A.message}Ho();var e8A=(function(A){return A[A.Small=0]="Small",A[A.Medium=1]="Medium",A[A.Large=2]="Large",A[A.ExtraLarge=3]="ExtraLarge",A})({});function g8A(A,e){if(!Number.isInteger(A)||A<0||A>63)throw new RangeError("Mesh-blending group ID must be an integer between 0 and 63.");if(A===0)return 0;if(!Number.isInteger(e)||e<0||e>3)throw new RangeError("Mesh-blending radius class must be an integer between 0 and 3.");return e<<6|A}function D6(A){if(!Number.isInteger(A)||A<0||A>255)throw new RangeError("Mesh-blending tag must be an integer between 0 and 255.");if(A!==0&&(A&63)===0)throw new RangeError("A nonzero mesh-blending tag must contain a group ID between 1 and 63.");return A}function I8A(A){const e=D6(A);return{groupId:e&63,radiusClass:e>>6}}function XK(A,e){let g=A,I=e;const i={};return Object.defineProperties(i,{worldRadius:{enumerable:!0,get:()=>g,set:C=>{if(!Number.isFinite(C)||C<0)throw new RangeError("Mesh-blending world radii must be finite non-negative numbers.");g=C}},minimumProjectedRadius:{enumerable:!0,get:()=>I,set:C=>{if(!Number.isFinite(C)||C<0)throw new RangeError("Mesh-blending minimum projected radii must be finite non-negative numbers.");I=C}}}),i}function ReA(){return Object.freeze([XK(.06,1.5),XK(.1,3),XK(.2,3),XK(.3,5)])}function SeA(A){return D6(A.meshBlendingTag??0)}function $K(A,e){if(Array.isArray(e))for(const g of e)A._dependencies.add(g);else A._dependencies.add(e)}var t8A={r:.2,g:.2,b:.3,a:1};function i8A(A,e){const g={name:A,_parentTask:e,_dependencies:new Set,_renderTarget:null,_renderTargetDepth:null,_renderPassDescriptor:{colorAttachments:[]},_colorAttachment:null,_depthAttachment:null,clearColor:{...t8A},clear:!0,_executeFunc:null,_beforeExecute:null,_initialize(){const I=g._renderTarget;if(!I)throw new Error(`RenderPass "${g.name}": render target not set`);const i=I._colorView;let C=null;i&&(C={view:i,loadOp:g.clear?"clear":"load",storeOp:"store",clearValue:g.clearColor});const o=g._renderTargetDepth??I,r=o._descriptor.dFormat,B=o._depthView,n=r?r==="depth24plus-stencil8"||r==="depth32float-stencil8"||r==="stencil8":!1;let Q=null;B&&(Q={view:B,depthClearValue:o._descriptor.depthClearValue??0,depthLoadOp:"clear",depthStoreOp:"store",...n?{stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"}:{}}),g._colorAttachment=C,g._depthAttachment=Q,g._renderPassDescriptor={label:g.name,colorAttachments:C?[C]:[],depthStencilAttachment:Q??void 0}},_execute(){const I=g._renderTarget;if(!I)return 0;g._beforeExecute?.();const i=g._parentTask.engine,C=g._colorAttachment;C&&(C.clearValue=g.clearColor,C.loadOp=g.clear?"clear":"load",C.view=I._colorView);const o=i._currentEncoder.beginRenderPass(g._renderPassDescriptor);let r=0;return g._executeFunc&&(r=g._executeFunc(o)),o.end(),r},_dispose(){g._renderTarget=null,g._renderTargetDepth=null,g._colorAttachment=null,g._depthAttachment=null,g._renderPassDescriptor={colorAttachments:[]},g._executeFunc=null,g._beforeExecute=null,g._dependencies.clear()}};return e._passes.push(g),g}rA(),jK();function NeA(A){return typeof A=="object"&&A!==null&&"_tasks"in A}function EF(A){if(NeA(A))return A;if("_frameGraph"in A&&NeA(A._frameGraph))return A._frameGraph;R(119)}function C8A(A,e){AeA(EF(A),e)}function o8A(A,e){const g=EF(A),I=g._tasks[0]?.name==="shadow"?1:0;g._tasks.splice(I,0,e)}function r8A(A,e,g){const I=EF(A),i=I._tasks.indexOf(g);i<0?I._tasks.push(e):I._tasks.splice(i,0,e)}function B8A(A,e,g){const I=EF(A),i=I._tasks.indexOf(g);i<0?I._tasks.push(e):I._tasks.splice(i+1,0,e)}function n8A(A,e){const g=EF(A)._currentProcessedTask;return g||R(120,e),i8A(e,g)}lt(),jK();function s8A(A,e){const g=A.engine,I=e?.update,i={_kind:"frame-graph-context",name:e?.name??"frame-graph",surface:A,frameGraph:XAA(g),clearColor:e?.clearColor??{r:0,g:0,b:0,a:1},_drawCallsPre:0,_disposed:!1,_update(){i._disposed||I?.(g._currentDelta)},_record(){return i._disposed?0:i.frameGraph.execute()},_resize(){i._disposed||i.frameGraph.build()}};return i}function Q8A(A){A._disposed||(A.frameGraph.build(),Ln(A.surface,A))}async function E8A(A){const e=A;e._disposed||(await Promise.all(A.frameGraph._tasks.map(g=>g._preload?.())),!e._disposed&&(A.frameGraph.build(),Ln(A.surface,A)))}function GeA(A){Zs(A.surface,A)}function a8A(A){const e=A;e._disposed||(GeA(A),A.frameGraph.dispose(),e._disposed=!0)}function ai(A){return HZ(A.texture,A)}var FC=b((()=>{Y3()}));te(),Gt(),FC(),m1();function meA(A,e){return Math.floor(Math.log2(Math.max(A,e)))+1}var c8A="@group(0)@binding(0)var src:texture_depth_2d;struct V{@builtin(position)p:vec4f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1));}@fragment fn fs(@builtin(position)fc:vec4f)->@location(0)f32{return textureLoad(src,vec2<i32>(fc.xy),0);}";function l8A(A){return`@group(0)@binding(0)var src:texture_2d<f32>;struct V{@builtin(position)p:vec4f};@vertex fn vs(@builtin(vertex_index)i:u32)->V{let p=array<vec2f,3>(vec2f(-1,-1),vec2f(3,-1),vec2f(-1,3))[i];return V(vec4f(p,0,1));}@fragment fn fs(@builtin(position)fc:vec4f)->@location(0)f32{let c=vec2<i32>(fc.xy)*2;let sd=vec2<i32>(textureDimensions(src));let d=sd-vec2<i32>(1,1);let x1=min(c.x+1,d.x);let y1=min(c.y+1,d.y);let a=textureLoad(src,vec2<i32>(c.x,c.y),0).r;let b=textureLoad(src,vec2<i32>(x1,c.y),0).r;let e=textureLoad(src,vec2<i32>(c.x,y1),0).r;let f=textureLoad(src,vec2<i32>(x1,y1),0).r;var r=${A}(${A}(a,b),${A}(e,f));let dd=max(sd/vec2<i32>(2,2),vec2<i32>(1,1));let extraX=(sd.x&1)==1&&i32(fc.x)==dd.x-1;let extraY=(sd.y&1)==1&&i32(fc.y)==dd.y-1;if(extraX){let x2=min(c.x+2,d.x);r=${A}(r,${A}(textureLoad(src,vec2<i32>(x2,c.y),0).r,textureLoad(src,vec2<i32>(x2,y1),0).r));}if(extraY){let y2=min(c.y+2,d.y);r=${A}(r,${A}(textureLoad(src,vec2<i32>(c.x,y2),0).r,textureLoad(src,vec2<i32>(x1,y2),0).r));if(extraX){r=${A}(r,textureLoad(src,vec2<i32>(min(c.x+2,d.x),y2),0).r);}}return r;}`}function p8A(A,e){const g=A._device,I=e.reduce??"max",i=I1(A,{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}),C=g.createBindGroupLayout({entries:[{binding:0,visibility:MA.FRAGMENT,texture:{sampleType:"depth",viewDimension:"2d"}}]}),o=g.createBindGroupLayout({entries:[{binding:0,visibility:MA.FRAGMENT,texture:{sampleType:"unfilterable-float",viewDimension:"2d"}}]}),r=(w,M)=>g.createRenderPipeline({layout:g.createPipelineLayout({bindGroupLayouts:[M]}),vertex:{module:g.createShaderModule({code:w}),entryPoint:"vs"},fragment:{module:g.createShaderModule({code:w}),entryPoint:"fs",targets:[{format:"r32float"}]},primitive:{topology:"triangle-list"}}),B=r(c8A,C),n=r(l8A(I),o);let Q=Math.max(1,e.width|0),E=Math.max(1,e.height|0),a=meA(Q,E);function c(){return g.createTexture({label:"depth-pyramid",size:{width:Q,height:E},format:"r32float",usage:RA.RENDER_ATTACHMENT|RA.TEXTURE_BINDING,mipLevelCount:a})}function l(w){const M={texture:w,view:w.createView(),sampler:i,width:Q,height:E,_sampleType:"float"};return LI(M),M}let p=c(),D=l(p),u,_=[],d=null,y=null;function h(){u=p.createView({baseMipLevel:0,mipLevelCount:1}),_=[];for(let w=1;w<a;w++){const M=p.createView({baseMipLevel:w-1,mipLevelCount:1}),N=p.createView({baseMipLevel:w,mipLevelCount:1});_.push({dst:N,bindGroup:g.createBindGroup({layout:o,entries:[{binding:0,resource:M}]})})}d=null,y=null}return h(),{get texture(){return D},get mipCount(){return a},build(w,M){const N=M??g.createCommandEncoder();(d===null||y!==w)&&(d=g.createBindGroup({layout:C,entries:[{binding:0,resource:w.view}]}),y=w);const S=N.beginRenderPass({label:"depth-pyramid-copy",colorAttachments:[{view:u,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});S.setPipeline(B),S.setBindGroup(0,d),S.draw(3),S.end();for(const G of _){const m=N.beginRenderPass({label:"depth-pyramid-reduce",colorAttachments:[{view:G.dst,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});m.setPipeline(n),m.setBindGroup(0,G.bindGroup),m.draw(3),m.end()}M||g.queue.submit([N.finish()])},resize(w,M){const N=Math.max(1,w|0),S=Math.max(1,M|0);if(N===Q&&S===E)return;Q=N,E=S,a=meA(Q,E);const G=D;p=c(),D=l(p),h(),ai(G)},dispose(){ai(D)}}}function D8A(A,e,g){const{pyramid:I,source:i}=g;return{name:"depth-pyramid",engine:A,scene:e,_passes:[],record(){},execute(){const C=i();return C?(I.build(C,A._currentEncoder),I.mipCount):0},dispose(){I.dispose()}}}function FeA(A,e,g){let I=null;return{name:A.name??"image-processing",engine:e,scene:g,_passes:[],record(){beA(I),I=u8A(e,A.source)},execute(){if(!I)return 0;const i=g.imageProcessing,C=new oA([i.exposure,i.contrast,i.toneMappingEnabled===!0?1:0,0]);e._device.queue.writeBuffer(I.params,0,C);const o=e._currentEncoder.beginRenderPass({colorAttachments:[{view:e.scRT._colorView,loadOp:"clear",storeOp:"store",clearValue:g.clearColor}]});return o.setPipeline(I.pipeline),o.setBindGroup(0,I.bindGroup),o.draw(3),o.end(),1},dispose(){beA(I),I=null,this._passes.length=0}}}function u8A(A,e){const g=_8A(e);if(!g)throw new Error("Image processing source has no color texture");const I=A._device,i=(g.sampleCount??1)>1,C=I.createBuffer({size:16,usage:dA.UNIFORM|dA.COPY_DST}),o=I.createBindGroupLayout({entries:[{binding:0,visibility:MA.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:MA.FRAGMENT,texture:{sampleType:i?"unfilterable-float":"float",multisampled:i}}]}),r="struct P{e:f32,c:f32,t:f32,p:f32}@group(0)@binding(0)var<uniform>p:P;@vertex fn vs(@builtin(vertex_index)i:u32)->@builtin(position)vec4f{var a=array<vec2f,3>(vec2f(-1,-3),vec2f(3,1),vec2f(-1,1));return vec4f(a[i],0,1);}fn ip(r:vec4f)->vec4f{var c=r.rgb*p.e;if(p.t>0.5){c=1.0-exp2(-1.590579*c);}c=clamp(pow(max(c,vec3f(0)),vec3f(1/2.2)),vec3f(0),vec3f(1));let h=c*c*(3.0-2.0*c);if(p.c<1.0){c=mix(vec3f(0.5),c,p.c);}else{c=mix(c,h,p.c-1.0);}return vec4f(max(c,vec3f(0)),r.a);}",B=i?"@group(0)@binding(1)var s:texture_multisampled_2d<f32>;":"@group(0)@binding(1)var s:texture_2d<f32>;",n=i?"@fragment fn fs(@builtin(position)q:vec4f)->@location(0)vec4f{let d=textureDimensions(s);let px=clamp(vec2i(q.xy),vec2i(0),vec2i(d)-1);let n=textureNumSamples(s);var c=vec4f(0);for(var i=0u;i<n;i++){c+=ip(textureLoad(s,px,i));}return c/f32(n);}":"@fragment fn fs(@builtin(position)q:vec4f)->@location(0)vec4f{let d=textureDimensions(s);return ip(textureLoad(s,clamp(vec2i(q.xy),vec2i(0),vec2i(d)-1),0));}",Q=I.createShaderModule({code:`${r}${B}${n}`});return{pipeline:I.createRenderPipeline({layout:I.createPipelineLayout({bindGroupLayouts:[o]}),vertex:{module:Q,entryPoint:"vs"},fragment:{module:Q,entryPoint:"fs",targets:[{format:A.format}]},primitive:{topology:"triangle-list"}}),bindGroup:I.createBindGroup({layout:o,entries:[{binding:0,resource:{buffer:C}},{binding:1,resource:g.createView()}]}),params:C}}function _8A(A){const e=typeof A=="function"?A():A;return e?"_colorTexture"in e?e._colorTexture:e.texture:null}function beA(A){A?.params.destroy()}var keA=b((()=>{ZA(),te()}));keA();var Gi=128;function d8A(A,e,g){let I=Math.imul(A^g,73244475)^Math.imul(e+g,295559667);return I=Math.imul(I^I>>>16,73244475),I=Math.imul(I^I>>>16,73244475),((I^I>>>16)>>>0)/4294967296}function KeA(A,e,g){const i=new Float32Array(16384),C=new Float32Array(16384),o=new Array(16384);for(let r=0;r<Gi;r++)for(let B=0;B<Gi;B++){const n=r*Gi+B;i[n]=d8A(B,r,g),o[n]=n}for(let r=0;r<Gi;r++){const B=r-1&127,n=r+1&127;for(let Q=0;Q<Gi;Q++){const E=Q-1&127,a=Q+1&127,c=r*Gi+Q,l=(i[r*Gi+E]+i[r*Gi+a]+i[B*Gi+Q]+i[n*Gi+Q]+i[B*Gi+E]+i[B*Gi+a]+i[n*Gi+E]+i[n*Gi+a])*.125;C[c]=i[c]-l}}o.sort((r,B)=>C[r]-C[B]||r-B);for(let r=0;r<16384;r++)A[o[r]*2+e]=Math.floor(r*256/16384)}function f8A(){const A=new Uint8Array(32768);return KeA(A,0,1757159915),KeA(A,1,795749149),A}function y8A(A){e4=A}function A4(A,e=!1){const g=A._gpu;let I=0;return g.tangentBuffer&&(I|=1),A.vat?(I|=512,A.vat.joints1Buffer&&(I|=4)):A.skeleton&&(I|=2,A.skeleton.joints1Buffer&&(I|=4)),A.morphTargets&&(I|=8),A.thinInstances&&(I|=16,A.thinInstances.colors&&(I|=32)),g.colorBuffer&&(I|=64),g.uv2Buffer&&(I|=128),A._flatNormal&&(I|=UeA),e&&(I|=256),e4&&(I|=e4(A)),I}var UeA,e4,ci=b((()=>{UeA=1024,e4=null}));function h8A(A,e){const g=e.id,I=A.includedOnlyMeshIds;return I?.size?!!g&&I.has(g):!g||!A.excludedMeshIds?.has(g)}function rC(A,e,g){const I=g?new Ag(g.buffer,g.byteOffset,g.byteLength/4):null;let i=0,C=-1,o=0;for(const r of e){if(o>=Zg)break;r._writeLightUbo&&(h8A(r,A)&&(C=o,I&&(I[u6+i]=o),i++),o++)}if(I){I[16]=i;for(let r=i;r<Zg;r++)I[u6+r]=0}return i===1?C+1:-i}var u6,aF=b((()=>{ZA(),vt(),u6=20}));function w8A(A){tt=A}var lg,BC,veA,As,tt,xo=b((()=>{rA(),lg=(function(A){return A[A.IRRADIANCE=0]="IRRADIANCE",A[A.WORLD_POSITION=1]="WORLD_POSITION",A[A.LOCAL_POSITION=2]="LOCAL_POSITION",A[A.REFLECTIVITY=3]="REFLECTIVITY",A[A.VIEW_DEPTH=4]="VIEW_DEPTH",A[A.NORMALIZED_VIEW_DEPTH=5]="NORMALIZED_VIEW_DEPTH",A[A.SCREENSPACE_DEPTH=6]="SCREENSPACE_DEPTH",A[A.VIEW_NORMAL=7]="VIEW_NORMAL",A[A.WORLD_NORMAL=8]="WORLD_NORMAL",A[A.ALBEDO=9]="ALBEDO",A[A.LINEAR_VELOCITY=10]="LINEAR_VELOCITY",A[A.MESH_BLEND_TAG=11]="MESH_BLEND_TAG",A})({}),BC={r:0,g:0,b:0,a:0},veA={r:1,g:1,b:1,a:1},As=[{name:"Irradiance",defaultFormat:"rgba16float",clearValue:BC},{name:"WorldPosition",defaultFormat:"rgba16float",clearValue:BC},{name:"LocalPosition",defaultFormat:"rgba16float",clearValue:BC},{name:"Reflectivity",defaultFormat:"rgba8unorm",clearValue:BC},{name:"ViewDepth",defaultFormat:"r32float",clearValue:BC},{name:"NormalizedViewDepth",defaultFormat:"r16float",clearValue:veA},{name:"ScreenspaceDepth",defaultFormat:"r16float",clearValue:BC},{name:"ViewNormal",defaultFormat:"rgba16float",clearValue:BC},{name:"WorldNormal",defaultFormat:"rgba16float",clearValue:BC},{name:"Albedo",defaultFormat:"rgba8unorm",clearValue:BC},{name:"LinearVelocity",defaultFormat:"rgba16float",clearValue:BC},{name:"MeshBlendTag",defaultFormat:"r8uint",clearValue:BC,_validate:()=>{R(140)}}],tt=null}));function _6(A){const e=[];for(const g of[A.baseColorTexture,A.normalTexture,A.ormTexture,A.occlusionTexture,A.emissiveTexture,A.specGlossTexture])g&&e.push(g);for(const g of qr().values())g.textures?.(A,e);return e}var g4=b((()=>{lI()})),M8A=H({_computePbrMaterialFeatures:()=>d6});function d6(A){let e=(A.emissiveTexture?2:0)|(A.normalTexture?1:0)|(A.alphaBlend===!0||(A._alphaCutOff??0)<=0&&A.alpha<1?64:0)|(A.specGlossTexture?128:0)|(A.doubleSided?256:0);(A.occlusionStrength??1)>0&&(e|=u5),A.enableSpecularAA&&(e|=lK);let g=0;for(const I of qr().values())if(I.detect){const i=I.detect(A);e|=i.f,g|=i.f2}return A._uv2Mask&&(g|=dK),A.baseColorFactor&&(g|=fK),{features:e,features2:g}}var I4=b((()=>{lI()}));function R8A(A){cF=A}function S8A(A){t4=A}function N8A(A){y6=A}function LeA(A){i4!==A._device&&(lF.clear(),i4=A._device)}function G8A(){lF.clear(),i4=null}function m8A(A,e,g,I,i,C,o="",r=null){LeA(A);const B=r&&cF?cF(r):null,n=`${e}:${g}:${I}:${i}:${o}${B?B._key:""}`,Q=lF.get(n);if(Q)return Q;const E=A._device,a=E.createBindGroupLayout(C._meshBGLDescriptor);let c=null;C._shadowBGLDescriptor&&(c=E.createBindGroupLayout(C._shadowBGLDescriptor));const l={_features:e,_features2:g,_meshFeatures:I,_meshBGL:a,_shadowBGL:c,_composed:C,_pipelines:new Map};return B&&(l._stencil=B._desc),lF.set(n,l),l}function F8A(A,e,g,I){LeA(A);const i=Vn(),C=e._sampleCount>1&&!!i?.(I),o=`${Q1(e)}${C?":a2c":""}`,r=g._pipelines.get(o);if(r)return r;const B=A._device,{_features:n,_features2:Q,_composed:E}=g,a=(Q&sQ)!==0,c=!a&&(n&64)!==0,l=(n&256)!==0,p=n1(A),D=g._shadowBGL?[p,g._meshBGL,g._shadowBGL]:[p,g._meshBGL],u=i?g._a2cVertModule??=B.createShaderModule({code:E._vertexWGSL}):B.createShaderModule({code:E._vertexWGSL}),_=(Q&$m)!==0,d=!e._colorFormat&&!_?null:i?g._a2cFragModule??=B.createShaderModule({code:E._fragmentWGSL}):B.createShaderModule({code:E._fragmentWGSL}),y=_?null:{format:e._colorFormat,writeMask:yC.ALL};c&&y&&(y.blend={color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}});const h=B.createRenderPipeline({layout:B.createPipelineLayout({bindGroupLayouts:D}),vertex:{module:u,entryPoint:"main",buffers:E._vertexBufferLayouts},...d?{fragment:{module:d,entryPoint:"main",targets:y?[y]:[]}}:{},...e._depthStencilFormat?{depthStencil:{format:e._depthStencilFormat,depthCompare:e._depthCompare??"greater-equal",depthWriteEnabled:_||a||!c,...cF&&g._stencil&&e._depthStencilFormat.includes("stencil")?g._stencil:{}}}:{},multisample:C?{count:e._sampleCount,alphaToCoverageEnabled:!0}:{count:e._sampleCount},primitive:{cullMode:l?"none":"back",...E._prim}});return g._pipelines.set(o,h),h}function f6(A,e,g,I,i,C,o,r,B){const n=A._device,Q=e._features,E=e._features2,a=e._meshFeatures,c=(Q&1)!==0&&(a&1)!==0,l=(Q&1)!==0&&(a&1)===0,p=c||l,D=(Q&2)!==0,u=(Q&128)!==0,_=(E&sQ)!==0,d=[];let y=0;const h=G=>{d.push({binding:y++,resource:G.view}),d.push({binding:y++,resource:G.sampler})},w={_engine:A,_features:Q,_features2:E,_meshFeatures:a,_material:C,_mesh:r,_env:o??y6?.(C)??null,_refractionTexture:B},M=D$(),N=g._fragmentKey?g._fragmentKey.split("|").filter(G=>G.length>0):[];d.push({binding:y++,resource:{buffer:I}}),d.push({binding:y++,resource:{buffer:i}});for(const G of M)G.phase==="vertex"&&G.bind&&(y=G.bind(w,d,y));h(C.baseColorTexture??t4?.(A)),p&&h(C.normalTexture),h(C.ormTexture??t4?.(A)),(E&2048)!==0&&(a&128)!==0&&C.occlusionTexture&&C.occlusionTexCoord===1&&h(C.occlusionTexture),D&&h(C.emissiveTexture),u&&h(C.specGlossTexture),_&&d.push({binding:y++,resource:{buffer:C._esmShadowParamsUBO}});const S=[];for(const G of N){const m=M.find(k=>k.id===G||G.startsWith(k.id+"-"));!m||m.phase==="vertex"||!m.bind||S.includes(m)||(S.push(m),y=m.bind(w,d,y))}return n.createBindGroup({layout:e._meshBGL,entries:d})}var cF,t4,y6,lF,i4,pF=b((()=>{te(),lI(),ci(),MI(),E1(),s1(),Wn(),cF=null,t4=null,y6=null,lF=new Map,i4=null}));function YeA(A,e){return A+e-1&~(e-1)}function b8A(A){const e=JeA[A];if(e)return e;const g=/^array<vec4<u32>,\s*(\d+)>$/.exec(A);if(g)return{align:16,size:Number(g[1])*16};throw new Error(`Unknown UBO field type: ${A}`)}function hQ(A){const e=new Map,g=[];let I=0;for(const i of A){const C=b8A(i._type);I=YeA(I,C.align),e.set(i._name,I),g.push(`${i._name}: ${i._type},`),I+=C.size}return{_totalBytes:YeA(I,16),_offsets:e,_structBody:g.join(`
2
2
  `)}}var JeA,C4=b((()=>{JeA={f32:{align:4,size:4},u32:{align:4,size:4},i32:{align:4,size:4},"vec2<f32>":{align:8,size:8},"vec3<f32>":{align:16,size:12},"vec4<f32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"mat4x4<f32>":{align:16,size:64}}}));function HeA(A,e,g){for(let I=0;I<e.length;I++)A=A.replace(e[I],g[I]);return A}function k8A(A){const e=new Map;for(const C of A){if(e.has(C._id))throw Error();e.set(C._id,{_fragment:C,_remaining:C._dependencies?.length??0,_dependents:[]})}for(const C of A)for(const o of C._dependencies??[]){const r=e.get(o);if(!r)throw Error();r._dependents.push(C._id)}const g=[];for(const[C,o]of e)o._remaining===0&&g.push(C);g.sort();const I=[];let i=0;for(;i<g.length;){const C=g[i++],o=e.get(C);I.push(o._fragment);for(const r of o._dependents){const B=e.get(r);if(--B._remaining===0){let n=i;for(;n<g.length&&g[n]<r;)n++;g.splice(n,0,r)}}}if(I.length!==A.length)throw Error();return I}function xeA(A,e){const g=new Set,I=[];for(const i of[A,e])for(const C of i)g.has(C._name)||(g.add(C._name),I.push(C));return I}function TeA(A,e,g){return A.replace(WeA,(I,i)=>{const C=[];for(const o of e){const r=o[g];r?.[i]&&C.push(r[i])}return C.join(`
3
3
  `)})}function qeA(A,e,g){const I=k8A(e),i=[],C=[],o=[],r=[],B=[];for(const Z of I){Z._vertexAttributes&&i.push(...Z._vertexAttributes),Z._varyings&&C.push(...Z._varyings),Z._helperFunctions&&o.push(Z._helperFunctions),Z._vertexHelperFunctions&&r.push(Z._vertexHelperFunctions);for(const AA of Z._vertexBuiltins??[])B.push(`@builtin(${AA._builtin})${AA._name}:${AA._type},`)}const n=xeA(A._baseVertexAttributes,i),Q=[],E=[],a=new Map;for(let Z=0;Z<n.length;Z++){const AA=n[Z],z=AA._stepMode!=="instance"?g?.[AA._name]:void 0;Q.push(`@location(${Z})${AA._name}:${AA._type},`);let IA=AA._bufferGroup?a.get(AA._bufferGroup):void 0;IA||(IA={arrayStride:z?._stride??AA._arrayStride,stepMode:AA._stepMode??"vertex",attributes:[]},AA._bufferGroup?a.set(AA._bufferGroup,IA):E.push(IA)),IA.attributes.push({shaderLocation:Z,offset:z?._offset??AA._offset??0,format:AA._gpuFormat})}for(const Z of a.values())E.push(Z);let c=n.length;for(const Z of I)if(Z._pipelineVertexBuffers){const AA=Z._pipelineVertexBuffers(c);E.push(...AA._buffers),c=AA._nextLoc}const l="@builtin(position)clipPos:vec4f,"+xeA(A._baseVaryings,C).map((Z,AA)=>`@location(${AA})${Z._name}:${Z._type},`).join(`
4
4
  `),p=!!(A._baseMaterialUboFields&&A._baseMaterialUboFields.length>0),D=[...A._baseMeshUboFields],u=p?[...A._baseMaterialUboFields]:[];for(const Z of I)Z._uboFields?.length&&(p?u:D).push(...Z._uboFields);const _=hQ(D),d=p?hQ(u):void 0,y=[{binding:0,visibility:3,buffer:{type:"uniform"}}];p&&y.push({binding:1,visibility:h6,buffer:{type:"uniform"}});const h=[],w=[],M=[];let N=p?2:1,S=0;function G(Z){const AA=Z._group==="shadow",z=AA?S++:N++,IA=AA?2:1,sA={binding:z,visibility:Z._visibility},DA=Z._type;let EA="",wA;switch(DA._kind){case"uniform-buffer":sA.buffer={type:"uniform"},EA="<uniform>",wA=`${Z._name}Uniforms`;break;case"texture":{const Qe=DA._textureType==="texture_depth_2d"?"depth":DA._textureType==="texture_2d<u32>"?"uint":"float";sA.texture={sampleType:DA._sampleType??Qe,viewDimension:DA._textureType.includes("array")?"2d-array":DA._textureType.includes("cube")?"cube":"2d"},wA=DA._textureType;break}case"sampler":sA.sampler={type:DA._samplerType==="sampler_comparison"?"comparison":DA._samplerType==="sampler_non_filtering"?"non-filtering":"filtering"},wA=DA._samplerType==="sampler_non_filtering"?"sampler":DA._samplerType;break;case"storage-texture":sA.storageTexture={access:DA._gpuAccess,format:DA._format},wA=`texture_storage_2d<${DA._format},${DA._access}>`}(AA?h:y).push(sA);const YA=`@group(${IA})@binding(${z})var${EA} ${Z._name}:${wA};`;Z._visibility&PeA&&w.push(YA),Z._visibility&h6&&M.push(YA)}for(const Z of A._baseVertexBindings??[])G(Z);for(const Z of I)for(const AA of Z._vertexBindings??[])G(AA);for(const Z of A._baseBindings??[])G(Z);for(const Z of VeA)for(const AA of I)for(const z of AA._bindings??[])(z._group??"mesh")===Z&&G(z);const m=I.map(Z=>Z._id).join("|"),k=Q.join(`