shaders 2.0.651 → 2.0.652
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/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +16 -9
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.js +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -426,7 +426,7 @@ struct ${t} {
|
|
|
426
426
|
${e}
|
|
427
427
|
};`}_getWGSLStructBinding(t,e,r,s=0,i=0){let n=t+"Struct";return`${this._getWGSLStruct(n,e)}
|
|
428
428
|
@binding( ${s} ) @group( ${i} )
|
|
429
|
-
var<${r}> ${t} : ${n};`}},t7=class{constructor(t){this.backend=t}getCurrentDepthStencilFormat(t){let e;return t.depthTexture===null?t.depth&&t.stencil?e=P.Depth24PlusStencil8:t.depth&&(e=P.Depth24Plus):e=this.getTextureFormatGPU(t.depthTexture),e}getTextureFormatGPU(t){return this.backend.get(t).format}getTextureSampleData(t){let e;if(t.isFramebufferTexture)e=1;else if(t.isDepthTexture&&!t.renderTarget){let i=this.backend.renderer,n=i.getRenderTarget();e=n?n.samples:i.samples}else t.renderTarget&&(e=t.renderTarget.samples);e||(e=1);let r=e>1&&t.renderTarget!==null&&t.isDepthTexture!==!0&&t.isFramebufferTexture!==!0;return{samples:e,primarySamples:r?1:e,isMSAA:r}}getCurrentColorFormat(t){let e;return e=t.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(t.textures[0]),e}getCurrentColorSpace(t){return t.textures===null?this.backend.renderer.outputColorSpace:t.textures[0].colorSpace}getPrimitiveTopology(t,e){if(t.isPoints)return Uu.PointList;if(t.isLineSegments||t.isMesh&&e.wireframe===!0)return Uu.LineList;if(t.isLine)return Uu.LineStrip;if(t.isMesh)return Uu.TriangleList}getSampleCount(t){let e=1;return t>1&&(e=2**Math.floor(Math.log2(t)),e===2&&(e=4)),e}getSampleCountRenderContext(t){return t.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(t.sampleCount)}getPreferredCanvasFormat(){let t=this.backend.parameters.outputType;if(t===void 0)return navigator.gpu.getPreferredCanvasFormat();if(t===ms)return P.BGRA8Unorm;if(t===Ss)return P.RGBA16Float;throw Error("Unsupported outputType")}};const r7=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),s7=new Map([[h2,["float16"]]]),i7=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);var n7=class{constructor(t){this.backend=t}createAttribute(t,e){let r=this._getBufferAttribute(t),s=this.backend,i=s.get(r),n=i.buffer;if(n===void 0){let a=s.device,o=r.array;if(t.normalized===!1){if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),e&GPUBufferUsage.INDEX))for(let u=0;u<o.length;u++)o[u]===65535&&(o[u]=4294967295)}if(r.array=o,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&r.itemSize===3){o=new o.constructor(r.count*4);for(let u=0;u<r.count;u++)o.set(r.array.subarray(u*3,u*3+3),u*4);r.itemSize=4,r.array=o,i._force3to4BytesAlignment=!0}let l=o.byteLength,h=l+(4-l%4)%4;n=a.createBuffer({label:r.name,size:h,usage:e,mappedAtCreation:!0}),new o.constructor(n.getMappedRange()).set(o),n.unmap(),i.buffer=n}}updateAttribute(t){let e=this._getBufferAttribute(t),r=this.backend,s=r.device,i=r.get(e),n=r.get(e).buffer,a=e.array;if(i._force3to4BytesAlignment===!0){a=new a.constructor(e.count*4);for(let h=0;h<e.count;h++)a.set(e.array.subarray(h*3,h*3+3),h*4);e.array=a}let o=this._isTypedArray(a),l=e.updateRanges;if(l.length===0)s.queue.writeBuffer(n,0,a,0);else{let h=o?1:a.BYTES_PER_ELEMENT;for(let u=0,c=l.length;u<c;u++){let d=l[u],p,m;if(i._force3to4BytesAlignment===!0){let g=Math.floor(d.start/3),b=Math.ceil(d.count/3);p=g*4*h,m=b*4*h}else p=d.start*h,m=d.count*h;let f=p*(o?a.BYTES_PER_ELEMENT:1);s.queue.writeBuffer(n,f,a,p,m)}e.clearUpdateRanges()}}createShaderVertexBuffers(t){let e=t.getAttributes(),r=new Map;for(let s=0;s<e.length;s++){let i=e[s],n=i.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(i),o=r.get(a);if(o===void 0){let u,c;i.isInterleavedBufferAttribute===!0?(u=i.data.stride*n,c=i.data.isInstancedInterleavedBuffer?um.Instance:um.Vertex):(u=i.itemSize*n,c=i.isInstancedBufferAttribute?um.Instance:um.Vertex),i.normalized===!1&&(i.array.constructor===Int16Array||i.array.constructor===Uint16Array)&&(u=4),o={arrayStride:u,attributes:[],stepMode:c},r.set(a,o)}let l=this._getVertexFormat(i),h=i.isInterleavedBufferAttribute===!0?i.offset*n:0;o.attributes.push({shaderLocation:s,offset:h,format:l})}return Array.from(r.values())}destroyAttribute(t){let e=this.backend;e.get(this._getBufferAttribute(t)).buffer.destroy(),e.delete(t)}async getArrayBufferAsync(t){let e=this.backend,r=e.device,s=e.get(this._getBufferAttribute(t)),i=s.buffer,n=i.size,a=r.createBuffer({label:`${t.name}_readback`,size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),o=r.createCommandEncoder({label:`readback_encoder_${t.name}`});o.copyBufferToBuffer(i,0,a,0,n);let l=o.finish();r.queue.submit([l]),await a.mapAsync(GPUMapMode.READ);let h=a.getMappedRange(),u=new t.array.constructor(h.slice(0));return a.unmap(),u.buffer}_getVertexFormat(t){let{itemSize:e,normalized:r}=t,s=t.array.constructor,i=t.constructor,n;if(e===1)n=i7.get(s);else{let a=s7.get(i)||r7.get(s),o=a[r?1:0];if(o){let l=s.BYTES_PER_ELEMENT*e,h=Math.floor((l+3)/4)*4,u=h/s.BYTES_PER_ELEMENT;if(u%1)throw Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${o}x${u}`}}return n||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),n}_isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}_getBufferAttribute(t){return t.isInterleavedBufferAttribute&&(t=t.data),t}},a7=class{constructor(t){this.backend=t,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(t){let e=this.backend,r=e.device,s=[],i=0;for(let n of t.bindings){let a={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let o={};n.isStorageBuffer&&(n.visibility&4&&(n.access===Qr.READ_WRITE||n.access===Qr.WRITE_ONLY)?o.type=HS.Storage:o.type=HS.ReadOnlyStorage),a.buffer=o}else if(n.isSampler){let o={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?e.compatibilityMode&&(o.type=qS.NonFiltering):o.type=qS.Comparison),a.sampler=o}else if(n.isSampledTexture&&n.texture.isVideoTexture)a.externalTexture={};else if(n.isSampledTexture&&n.store){let o={};o.format=this.backend.get(n.texture).texture.format;let l=n.access;l===Qr.READ_WRITE?o.access=Sx.ReadWrite:l===Qr.WRITE_ONLY?o.access=Sx.WriteOnly:o.access=Sx.ReadOnly,a.storageTexture=o}else if(n.isSampledTexture){let o={},{primarySamples:l}=e.utils.getTextureSampleData(n.texture);if(l>1&&(o.multisampled=!0,n.texture.isDepthTexture||(o.sampleType=$o.UnfilterableFloat)),n.texture.isDepthTexture)e.compatibilityMode&&n.texture.compareFunction===null?o.sampleType=$o.UnfilterableFloat:o.sampleType=$o.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let h=n.texture.type;h===ds?o.sampleType=$o.SInt:h===Yt?o.sampleType=$o.UInt:h===Hs&&(this.backend.hasFeature("float32-filterable")?o.sampleType=$o.Float:o.sampleType=$o.UnfilterableFloat)}n.isSampledCubeTexture?o.viewDimension=Br.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?o.viewDimension=Br.TwoDArray:n.isSampledTexture3D&&(o.viewDimension=Br.ThreeD),a.texture=o}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);s.push(a)}return r.createBindGroupLayout({entries:s})}createBindings(t,e,r,s=0){let{backend:i,bindGroupLayoutCache:n}=this,a=i.get(t),o=n.get(t.bindingsReference);o===void 0&&(o=this.createBindingsLayout(t),n.set(t.bindingsReference,o));let l;r>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(l=a.groups[r])),l===void 0&&(l=this.createBindGroup(t,o),r>0&&(a.groups[r]=l,a.versions[r]=s)),a.group=l,a.layout=o}updateBinding(t){let e=this.backend,r=e.device,s=t.buffer,i=e.get(t).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(t,e){let r=this.backend,s=r.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=t[0],a=s.createBuffer({label:"bindingCameraIndex_"+n,size:16,usage:i});s.queue.writeBuffer(a,0,t,0);let o=[{binding:0,resource:{buffer:a}}];return s.createBindGroup({label:"bindGroupCameraIndex_"+n,layout:e,entries:o})}createBindGroup(t,e){let r=this.backend,s=r.device,i=0,n=[];for(let a of t.bindings){if(a.isUniformBuffer){let o=r.get(a);if(o.buffer===void 0){let l=a.byteLength,h=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,u=s.createBuffer({label:"bindingBuffer_"+a.name,size:l,usage:h});o.buffer=u}n.push({binding:i,resource:{buffer:o.buffer}})}else if(a.isStorageBuffer){let o=r.get(a);if(o.buffer===void 0){let l=a.attribute;o.buffer=r.get(l).buffer}n.push({binding:i,resource:{buffer:o.buffer}})}else if(a.isSampler){let o=r.get(a.texture);n.push({binding:i,resource:o.sampler})}else if(a.isSampledTexture){let o=r.get(a.texture),l;if(o.externalTexture!==void 0)l=s.importExternalTexture({source:o.externalTexture});else{let h=a.store?1:o.texture.mipLevelCount,u=`view-${o.texture.width}-${o.texture.height}-${h}`;if(l=o[u],l===void 0){let c=B$.All,d;d=a.isSampledCubeTexture?Br.Cube:a.isSampledTexture3D?Br.ThreeD:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?Br.TwoDArray:Br.TwoD,l=o[u]=o.texture.createView({aspect:c,dimension:d,mipLevelCount:h})}}n.push({binding:i,resource:l})}i++}return s.createBindGroup({label:"bindGroup_"+t.name,layout:e,entries:n})}},o7=class{constructor(t){this.backend=t,this._activePipelines=new WeakMap}setPipeline(t,e){this._activePipelines.get(t)!==e&&(t.setPipeline(e),this._activePipelines.set(t,e))}_getSampleCount(t){return this.backend.utils.getSampleCountRenderContext(t)}createRenderPipeline(t,e){let{object:r,material:s,geometry:i,pipeline:n}=t,{vertexProgram:a,fragmentProgram:o}=n,l=this.backend,h=l.device,u=l.utils,c=l.get(n),d=[];for(let re of t.getBindings()){let te=l.get(re);d.push(te.layout)}let p=l.attributeUtils.createShaderVertexBuffers(t),m;s.blending!==Ph&&(s.blending!==oa||s.transparent!==!1)&&(m=this._getBlending(s));let f={};s.stencilWrite===!0&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});let g=this._getColorWriteMask(s),b=[];if(t.context.textures!==null){let re=t.context.textures;for(let te=0;te<re.length;te++){let oe=u.getTextureFormatGPU(re[te]);b.push({format:oe,blend:m,writeMask:g})}}else{let re=u.getCurrentColorFormat(t.context);b.push({format:re,blend:m,writeMask:g})}let v=l.get(a).module,w=l.get(o).module,T=this._getPrimitiveState(r,i,s),N=this._getDepthCompare(s),S=u.getCurrentDepthStencilFormat(t.context),_=this._getSampleCount(t.context),A={label:`renderPipeline_${s.name||s.type}_${s.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},w,{targets:b}),primitive:T,multisample:{count:_,alphaToCoverageEnabled:s.alphaToCoverage&&_>1},layout:h.createPipelineLayout({bindGroupLayouts:d})},D={},K=t.context.depth,J=t.context.stencil;if((K===!0||J===!0)&&(K===!0&&(D.format=S,D.depthWriteEnabled=s.depthWrite,D.depthCompare=N),J===!0&&(D.stencilFront=f,D.stencilBack={},D.stencilReadMask=s.stencilFuncMask,D.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&(D.depthBias=s.polygonOffsetUnits,D.depthBiasSlopeScale=s.polygonOffsetFactor,D.depthBiasClamp=0),A.depthStencil=D),e===null)c.pipeline=h.createRenderPipeline(A);else{let re=new Promise(te=>{h.createRenderPipelineAsync(A).then(oe=>{c.pipeline=oe,te()})});e.push(re)}}createBundleEncoder(t,e="renderBundleEncoder"){let r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(t),a=s.getCurrentColorFormat(t),o=this._getSampleCount(t),l={label:e,colorFormats:[a],depthStencilFormat:n,sampleCount:o};return i.createRenderBundleEncoder(l)}createComputePipeline(t,e){let r=this.backend,s=r.device,i=r.get(t.computeProgram).module,n=r.get(t),a=[];for(let o of e){let l=r.get(o);a.push(l.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(t){let e,r,s=t.blending,i=t.blendSrc,n=t.blendDst,a=t.blendEquation;if(s===Wc){let o=t.blendSrcAlpha===null?i:t.blendSrcAlpha,l=t.blendDstAlpha===null?n:t.blendDstAlpha,h=t.blendEquationAlpha===null?a:t.blendEquationAlpha;e={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(h)}}else{let o=t.premultipliedAlpha,l=(h,u,c,d)=>{e={srcFactor:h,dstFactor:u,operation:Do.Add},r={srcFactor:c,dstFactor:d,operation:Do.Add}};if(o)switch(s){case oa:l(ze.One,ze.OneMinusSrcAlpha,ze.One,ze.OneMinusSrcAlpha);break;case Mf:l(ze.One,ze.One,ze.One,ze.One);break;case _f:l(ze.Zero,ze.OneMinusSrc,ze.Zero,ze.One);break;case Nf:l(ze.Zero,ze.Src,ze.Zero,ze.SrcAlpha);break}else switch(s){case oa:l(ze.SrcAlpha,ze.OneMinusSrcAlpha,ze.One,ze.OneMinusSrcAlpha);break;case Mf:l(ze.SrcAlpha,ze.One,ze.SrcAlpha,ze.One);break;case _f:l(ze.Zero,ze.OneMinusSrc,ze.Zero,ze.One);break;case Nf:l(ze.Zero,ze.Src,ze.Zero,ze.Src);break}}if(e!==void 0&&r!==void 0)return{color:e,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(t){let e;switch(t){case Ja:e=ze.Zero;break;case EN:e=ze.One;break;case PN:e=ze.Src;break;case FN:e=ze.OneMinusSrc;break;case Af:e=ze.SrcAlpha;break;case Cf:e=ze.OneMinusSrcAlpha;break;case zN:e=ze.Dst;break;case BN:e=ze.OneMinusDst;break;case LN:e=ze.DstAlpha;break;case IN:e=ze.OneMinusDstAlpha;break;case VN:e=ze.SrcAlphaSaturated;break;case oU:e=ze.Constant;break;case lU:e=ze.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",t)}return e}_getStencilCompare(t){let e,r=t.stencilFunc;switch(r){case Dz:e=kr.Never;break;case D0:e=kr.Always;break;case $z:e=kr.Less;break;case jz:e=kr.LessEqual;break;case Gz:e=kr.Equal;break;case qz:e=kr.GreaterEqual;break;case Wz:e=kr.Greater;break;case Hz:e=kr.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return e}_getStencilOperation(t){let e;switch(t){case Zo:e=Ua.Keep;break;case Iz:e=Ua.Zero;break;case zz:e=Ua.Replace;break;case Uz:e=Ua.Invert;break;case Bz:e=Ua.IncrementClamp;break;case Vz:e=Ua.DecrementClamp;break;case Oz:e=Ua.IncrementWrap;break;case kz:e=Ua.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",e)}return e}_getBlendOperation(t){let e;switch(t){case Hi:e=Do.Add;break;case CN:e=Do.Subtract;break;case RN:e=Do.ReverseSubtract;break;case yz:e=Do.Min;break;case xz:e=Do.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",t)}return e}_getPrimitiveState(t,e,r){let s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(t,r),e.index!==null&&t.isLine===!0&&t.isLineSegments!==!0&&(s.stripIndexFormat=e.index.array instanceof Uint16Array?Oh.Uint16:Oh.Uint32),r.side){case aa:s.frontFace=vx.CCW,s.cullMode=Tx.Back;break;case gs:s.frontFace=vx.CCW,s.cullMode=Tx.Front;break;case Hu:s.frontFace=vx.CCW,s.cullMode=Tx.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side);break}return s}_getColorWriteMask(t){return t.colorWrite===!0?WS.All:WS.None}_getDepthCompare(t){let e;if(t.depthTest===!1)e=kr.Always;else{let r=t.depthFunc;switch(r){case ON:e=kr.Never;break;case kN:e=kr.Always;break;case UN:e=kr.Less;break;case Rf:e=kr.LessEqual;break;case DN:e=kr.Equal;break;case $N:e=kr.GreaterEqual;break;case GN:e=kr.Greater;break;case jN:e=kr.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return e}},l7=class extends g3{constructor(t,e,r=2048){super(r),this.device=t,this.type=e,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${e}`});let s=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${e}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${e}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(t){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ba(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let e=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(t.id,e),e}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let t=new Map(this.queryOffsets),e=this.currentQueryIndex,r=e*8;this.currentQueryIndex=0,this.queryOffsets.clear();let s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,e,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);let i=s.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a=0;for(let[,o]of t){let l=n[o],h=n[o+1],u=Number(h-l)/1e6;a+=u}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(t){return console.error("Error resolving queries:",t),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(t){console.error("Error waiting for pending resolve:",t)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(t){console.error("Error unmapping buffer:",t)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},u7=class extends f3{constructor(t={}){super(t),this.isWebGPUBackend=!0,this.parameters.alpha=t.alpha===void 0?!0:t.alpha,this.parameters.compatibilityMode=t.compatibilityMode===void 0?!1:t.compatibilityMode,this.parameters.requiredLimits=t.requiredLimits===void 0?{}:t.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new t7(this),this.attributeUtils=new n7(this),this.bindingUtils=new a7(this),this.pipelineUtils=new o7(this),this.textureUtils=new W$(this),this.occludedResolveCache=new Map}async init(t){await super.init(t);let e=this.parameters,r;if(e.device===void 0){let n={powerPreference:e.powerPreference,featureLevel:e.compatibilityMode?"compatibility":void 0},a=typeof navigator<"u"?await navigator.gpu.requestAdapter(n):null;if(a===null)throw Error("WebGPUBackend: Unable to create WebGPU adapter.");let o=Object.values(cb),l=[];for(let u of o)a.features.has(u)&&l.push(u);let h={requiredFeatures:l,requiredLimits:e.requiredLimits};r=await a.requestDevice(h)}else r=e.device;r.lost.then(n=>{let a={api:"WebGPU",message:n.message||"Unknown reason",reason:n.reason||null,originalEvent:n};t.onDeviceLost(a)});let s=e.context===void 0?t.domElement.getContext("webgpu"):e.context;this.device=r,this.context=s;let i=e.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(cb.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return Mn}async getArrayBufferAsync(t){return await this.attributeUtils.getArrayBufferAsync(t)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let t=this.defaultRenderPassdescriptor;if(t===null){let r=this.renderer;t={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(t.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(r.depth,r.stencil).createView()});let s=t.colorAttachments[0];this.renderer.samples>0?s.view=this.colorBuffer.createView():s.resolveTarget=void 0,this.defaultRenderPassdescriptor=t}let e=t.colorAttachments[0];return this.renderer.samples>0?e.resolveTarget=this.context.getCurrentTexture().createView():e.view=this.context.getCurrentTexture().createView(),t}_isRenderCameraDepthArray(t){return t.depthTexture&&t.depthTexture.image.depth>1&&t.camera.isArrayCamera}_getRenderPassDescriptor(t,e={}){let r=t.renderTarget,s=this.get(r),i=s.descriptors;if(i===void 0||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==t.activeMipmapLevel||s.activeCubeFace!==t.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;let l=()=>{r.removeEventListener("dispose",l),this.delete(r)};r.hasEventListener("dispose",l)===!1&&r.addEventListener("dispose",l)}let n=t.getCacheKey(),a=i[n];if(a===void 0){let l=t.textures,h=[],u,c=this._isRenderCameraDepthArray(t);for(let d=0;d<l.length;d++){let p=this.get(l[d]),m={label:`colorAttachment_${d}`,baseMipLevel:t.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:t.activeCubeFace,arrayLayerCount:1,dimension:Br.TwoD};if(r.isRenderTarget3D)u=t.activeCubeFace,m.baseArrayLayer=0,m.dimension=Br.ThreeD,m.depthOrArrayLayers=l[d].image.depth;else if(r.isRenderTarget&&l[d].image.depth>1)if(c===!0){let f=t.camera.cameras;for(let g=0;g<f.length;g++){let b={...m,baseArrayLayer:g,arrayLayerCount:1,dimension:Br.TwoD},v=p.texture.createView(b);h.push({view:v,resolveTarget:void 0,depthSlice:void 0})}}else m.dimension=Br.TwoDArray,m.depthOrArrayLayers=l[d].image.depth;if(c!==!0){let f=p.texture.createView(m),g,b;p.msaaTexture===void 0?(g=f,b=void 0):(g=p.msaaTexture.createView(),b=f),h.push({view:g,resolveTarget:b,depthSlice:u})}}if(a={textureViews:h},t.depth){let d=this.get(t.depthTexture),p={};t.depthTexture.isArrayTexture&&(p.dimension=Br.TwoD,p.arrayLayerCount=1,p.baseArrayLayer=t.activeCubeFace),a.depthStencilView=d.texture.createView(p)}i[n]=a,s.width=r.width,s.height=r.height,s.samples=r.samples,s.activeMipmapLevel=t.activeMipmapLevel,s.activeCubeFace=t.activeCubeFace,s.dimensions=r.dimensions}let o={colorAttachments:[]};for(let l=0;l<a.textureViews.length;l++){let h=a.textureViews[l],u={r:0,g:0,b:0,a:1};l===0&&e.clearValue&&(u=e.clearValue),o.colorAttachments.push({view:h.view,depthSlice:h.depthSlice,resolveTarget:h.resolveTarget,loadOp:e.loadOp||tt.Load,storeOp:e.storeOp||cs.Store,clearValue:u})}return a.depthStencilView&&(o.depthStencilAttachment={view:a.depthStencilView}),o}beginRender(t){let e=this.get(t),r=this.device,s=t.occlusionQueryCount,i;s>0&&(e.currentOcclusionQuerySet&&e.currentOcclusionQuerySet.destroy(),e.currentOcclusionQueryBuffer&&e.currentOcclusionQueryBuffer.destroy(),e.currentOcclusionQuerySet=e.occlusionQuerySet,e.currentOcclusionQueryBuffer=e.occlusionQueryBuffer,e.currentOcclusionQueryObjects=e.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${t.id}`}),e.occlusionQuerySet=i,e.occlusionQueryIndex=0,e.occlusionQueryObjects=Array(s),e.lastOcclusionObject=null);let n;n=t.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(t,{loadOp:tt.Load}),this.initTimestampQuery(t,n),n.occlusionQuerySet=i;let a=n.depthStencilAttachment;if(t.textures!==null){let l=n.colorAttachments;for(let h=0;h<l.length;h++){let u=l[h];t.clearColor?(u.clearValue=h===0?t.clearColorValue:{r:0,g:0,b:0,a:1},u.loadOp=tt.Clear):u.loadOp=tt.Load,u.storeOp=cs.Store}}else{let l=n.colorAttachments[0];t.clearColor?(l.clearValue=t.clearColorValue,l.loadOp=tt.Clear):l.loadOp=tt.Load,l.storeOp=cs.Store}t.depth&&(t.clearDepth?(a.depthClearValue=t.clearDepthValue,a.depthLoadOp=tt.Clear):a.depthLoadOp=tt.Load,a.depthStoreOp=cs.Store),t.stencil&&(t.clearStencil?(a.stencilClearValue=t.clearStencilValue,a.stencilLoadOp=tt.Clear):a.stencilLoadOp=tt.Load,a.stencilStoreOp=cs.Store);let o=r.createCommandEncoder({label:"renderContext_"+t.id});if(this._isRenderCameraDepthArray(t)===!0){let l=t.camera.cameras;!e.layerDescriptors||e.layerDescriptors.length!==l.length?this._createDepthLayerDescriptors(t,e,n,l):this._updateDepthLayerDescriptors(t,e,l),e.bundleEncoders=[],e.bundleSets=[];for(let h=0;h<l.length;h++){let u=this.pipelineUtils.createBundleEncoder(t,"renderBundleArrayCamera_"+h),c={attributes:{},bindingGroups:[],pipeline:null,index:null};e.bundleEncoders.push(u),e.bundleSets.push(c)}e.currentPass=null}else{let l=o.beginRenderPass(n);if(e.currentPass=l,t.viewport&&this.updateViewport(t),t.scissor){let{x:h,y:u,width:c,height:d}=t.scissorValue;l.setScissorRect(h,u,c,d)}}e.descriptor=n,e.encoder=o,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.renderBundles=[]}_createDepthLayerDescriptors(t,e,r,s){let i=r.depthStencilAttachment;e.layerDescriptors=[];let n=this.get(t.depthTexture);n.viewCache||(n.viewCache=[]);for(let a=0;a<s.length;a++){let o={...r,colorAttachments:[{...r.colorAttachments[0],view:r.colorAttachments[a].view}]};if(r.depthStencilAttachment){let l=a;n.viewCache[l]||(n.viewCache[l]=n.texture.createView({dimension:Br.TwoD,baseArrayLayer:a,arrayLayerCount:1})),o.depthStencilAttachment={view:n.viewCache[l],depthLoadOp:i.depthLoadOp||tt.Clear,depthStoreOp:i.depthStoreOp||cs.Store,depthClearValue:i.depthClearValue||1},t.stencil&&(o.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,o.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,o.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else o.depthStencilAttachment={...i};e.layerDescriptors.push(o)}}_updateDepthLayerDescriptors(t,e,r){for(let s=0;s<r.length;s++){let i=e.layerDescriptors[s];if(i.depthStencilAttachment){let n=i.depthStencilAttachment;t.depth&&(t.clearDepth?(n.depthClearValue=t.clearDepthValue,n.depthLoadOp=tt.Clear):n.depthLoadOp=tt.Load),t.stencil&&(t.clearStencil?(n.stencilClearValue=t.clearStencilValue,n.stencilLoadOp=tt.Clear):n.stencilLoadOp=tt.Load)}}}finishRender(t){let e=this.get(t),r=t.occlusionQueryCount;e.renderBundles.length>0&&e.currentPass.executeBundles(e.renderBundles),r>e.occlusionQueryIndex&&e.currentPass.endOcclusionQuery();let s=e.encoder;if(this._isRenderCameraDepthArray(t)===!0){let i=[];for(let n=0;n<e.bundleEncoders.length;n++){let a=e.bundleEncoders[n];i.push(a.finish())}for(let n=0;n<e.layerDescriptors.length;n++)if(n<i.length){let a=e.layerDescriptors[n],o=s.beginRenderPass(a);if(t.viewport){let{x:l,y:h,width:u,height:c,minDepth:d,maxDepth:p}=t.viewportValue;o.setViewport(l,h,u,c,d,p)}if(t.scissor){let{x:l,y:h,width:u,height:c}=t.scissorValue;o.setScissorRect(l,h,u,c)}o.executeBundles([i[n]]),o.end()}}else e.currentPass&&e.currentPass.end();if(r>0){let i=r*8,n=this.occludedResolveCache.get(i);n===void 0&&(n=this.device.createBuffer({size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(i,n));let a=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});e.encoder.resolveQuerySet(e.occlusionQuerySet,0,r,n,0),e.encoder.copyBufferToBuffer(n,0,a,0,i),e.occlusionQueryBuffer=a,this.resolveOccludedAsync(t)}if(this.device.queue.submit([e.encoder.finish()]),t.textures!==null){let i=t.textures;for(let n=0;n<i.length;n++){let a=i[n];a.generateMipmaps===!0&&this.textureUtils.generateMipmaps(a)}}}isOccluded(t,e){let r=this.get(t);return r.occluded&&r.occluded.has(e)}async resolveOccludedAsync(t){let e=this.get(t),{currentOcclusionQueryBuffer:r,currentOcclusionQueryObjects:s}=e;if(r&&s){let i=new WeakSet;e.currentOcclusionQueryObjects=null,e.currentOcclusionQueryBuffer=null,await r.mapAsync(GPUMapMode.READ);let n=r.getMappedRange(),a=new BigUint64Array(n);for(let o=0;o<s.length;o++)a[o]===BigInt(0)&&i.add(s[o]);r.destroy(),e.occluded=i}}updateViewport(t){let{currentPass:e}=this.get(t),{x:r,y:s,width:i,height:n,minDepth:a,maxDepth:o}=t.viewportValue;e.setViewport(r,s,i,n,a,o)}getClearColor(){let t=super.getClearColor();return this.renderer.alpha===!0&&(t.r*=t.a,t.g*=t.a,t.b*=t.a),t}clear(t,e,r,s=null){let i=this.device,n=this.renderer,a=[],o,l,h,u;if(t){let p=this.getClearColor();l={r:p.r,g:p.g,b:p.b,a:p.a}}if(s===null){h=n.depth,u=n.stencil;let p=this._getDefaultRenderPassDescriptor();if(t){a=p.colorAttachments;let m=a[0];m.clearValue=l,m.loadOp=tt.Clear,m.storeOp=cs.Store}(h||u)&&(o=p.depthStencilAttachment)}else{h=s.depth,u=s.stencil;let p={loadOp:t?tt.Clear:tt.Load,clearValue:t?l:void 0};h&&(p.depthLoadOp=e?tt.Clear:tt.Load,p.depthClearValue=e?n.getClearDepth():void 0,p.depthStoreOp=cs.Store),u&&(p.stencilLoadOp=r?tt.Clear:tt.Load,p.stencilClearValue=r?n.getClearStencil():void 0,p.stencilStoreOp=cs.Store);let m=this._getRenderPassDescriptor(s,p);a=m.colorAttachments,o=m.depthStencilAttachment}h&&o&&o.depthLoadOp===void 0&&(e?(o.depthLoadOp=tt.Clear,o.depthClearValue=n.getClearDepth(),o.depthStoreOp=cs.Store):(o.depthLoadOp=tt.Load,o.depthStoreOp=cs.Store)),u&&o&&o.stencilLoadOp===void 0&&(r?(o.stencilLoadOp=tt.Clear,o.stencilClearValue=n.getClearStencil(),o.stencilStoreOp=cs.Store):(o.stencilLoadOp=tt.Load,o.stencilStoreOp=cs.Store));let c=i.createCommandEncoder({label:"clear"});c.beginRenderPass({colorAttachments:a,depthStencilAttachment:o}).end(),i.queue.submit([c.finish()])}beginCompute(t){let e=this.get(t),r={label:"computeGroup_"+t.id};this.initTimestampQuery(t,r),e.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+t.id}),e.passEncoderGPU=e.cmdEncoderGPU.beginComputePass(r)}compute(t,e,r,s){let{passEncoderGPU:i}=this.get(t),n=this.get(s).pipeline;this.pipelineUtils.setPipeline(i,n);for(let h=0,u=r.length;h<u;h++){let c=r[h],d=this.get(c);i.setBindGroup(h,d.group)}let a=this.device.limits.maxComputeWorkgroupsPerDimension,o=this.get(e);o.dispatchSize===void 0&&(o.dispatchSize={x:0,y:1,z:1});let{dispatchSize:l}=o;e.dispatchCount>a?(l.x=Math.min(e.dispatchCount,a),l.y=Math.ceil(e.dispatchCount/a)):l.x=e.dispatchCount,i.dispatchWorkgroups(l.x,l.y,l.z)}finishCompute(t){let e=this.get(t);e.passEncoderGPU.end(),this.device.queue.submit([e.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(t,e){let{object:r,material:s,context:i,pipeline:n}=t,a=t.getBindings(),o=this.get(i),l=this.get(n).pipeline,h=t.getIndex(),u=h!==null,c=t.getDrawParameters();if(c===null)return;let d=(m,f)=>{this.pipelineUtils.setPipeline(m,l),f.pipeline=l;let g=f.bindingGroups;for(let v=0,w=a.length;v<w;v++){let T=a[v],N=this.get(T);g[T.index]!==T.id&&(m.setBindGroup(T.index,N.group),g[T.index]=T.id)}if(u===!0&&f.index!==h){let v=this.get(h).buffer,w=h.array instanceof Uint16Array?Oh.Uint16:Oh.Uint32;m.setIndexBuffer(v,w),f.index=h}let b=t.getVertexBuffers();for(let v=0,w=b.length;v<w;v++){let T=b[v];if(f.attributes[v]!==T){let N=this.get(T).buffer;m.setVertexBuffer(v,N),f.attributes[v]=T}}i.stencil===!0&&s.stencilWrite===!0&&o.currentStencilRef!==s.stencilRef&&(m.setStencilReference(s.stencilRef),o.currentStencilRef=s.stencilRef)},p=(m,f)=>{if(d(m,f),r.isBatchedMesh===!0){let g=r._multiDrawStarts,b=r._multiDrawCounts,v=r._multiDrawCount,w=r._multiDrawInstances;w!==null&&ba("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let T=0;T<v;T++){let N=w?w[T]:1,S=N>1?0:T;u===!0?m.drawIndexed(b[T],N,g[T]/h.array.BYTES_PER_ELEMENT,0,S):m.draw(b[T],N,g[T],S),e.update(r,b[T],N)}}else if(u===!0){let{vertexCount:g,instanceCount:b,firstVertex:v}=c,w=t.getIndirect();if(w!==null){let T=this.get(w).buffer;m.drawIndexedIndirect(T,0)}else m.drawIndexed(g,b,v,0,0);e.update(r,g,b)}else{let{vertexCount:g,instanceCount:b,firstVertex:v}=c,w=t.getIndirect();if(w!==null){let T=this.get(w).buffer;m.drawIndirect(T,0)}else m.draw(g,b,v,0);e.update(r,g,b)}};if(t.camera.isArrayCamera&&t.camera.cameras.length>0){let m=this.get(t.camera),f=t.camera.cameras,g=t.getBindingGroup("cameraIndex");if(m.indexesGPU===void 0||m.indexesGPU.length!==f.length){let v=this.get(g),w=[],T=new Uint32Array([0,0,0,0]);for(let N=0,S=f.length;N<S;N++){T[0]=N;let _=this.bindingUtils.createBindGroupIndex(T,v.layout);w.push(_)}m.indexesGPU=w}let b=this.renderer.getPixelRatio();for(let v=0,w=f.length;v<w;v++){let T=f[v];if(r.layers.test(T.layers)){let N=T.viewport,S=o.currentPass,_=o.currentSets;if(o.bundleEncoders){let A=o.bundleEncoders[v],D=o.bundleSets[v];S=A,_=D}N&&S.setViewport(Math.floor(N.x*b),Math.floor(N.y*b),Math.floor(N.width*b),Math.floor(N.height*b),i.viewportValue.minDepth,i.viewportValue.maxDepth),g&&m.indexesGPU&&(S.setBindGroup(g.index,m.indexesGPU[v]),_.bindingGroups[g.index]=g.id),p(S,_)}}}else if(o.currentPass){if(o.occlusionQuerySet!==void 0){let m=o.lastOcclusionObject;m!==r&&(m!==null&&m.occlusionTest===!0&&(o.currentPass.endOcclusionQuery(),o.occlusionQueryIndex++),r.occlusionTest===!0&&(o.currentPass.beginOcclusionQuery(o.occlusionQueryIndex),o.occlusionQueryObjects[o.occlusionQueryIndex]=r),o.lastOcclusionObject=r)}p(o.currentPass,o.currentSets)}}needsRenderUpdate(t){let e=this.get(t),{object:r,material:s}=t,i=this.utils,n=i.getSampleCountRenderContext(t.context),a=i.getCurrentColorSpace(t.context),o=i.getCurrentColorFormat(t.context),l=i.getCurrentDepthStencilFormat(t.context),h=i.getPrimitiveTopology(r,s),u=!1;return(e.material!==s||e.materialVersion!==s.version||e.transparent!==s.transparent||e.blending!==s.blending||e.premultipliedAlpha!==s.premultipliedAlpha||e.blendSrc!==s.blendSrc||e.blendDst!==s.blendDst||e.blendEquation!==s.blendEquation||e.blendSrcAlpha!==s.blendSrcAlpha||e.blendDstAlpha!==s.blendDstAlpha||e.blendEquationAlpha!==s.blendEquationAlpha||e.colorWrite!==s.colorWrite||e.depthWrite!==s.depthWrite||e.depthTest!==s.depthTest||e.depthFunc!==s.depthFunc||e.stencilWrite!==s.stencilWrite||e.stencilFunc!==s.stencilFunc||e.stencilFail!==s.stencilFail||e.stencilZFail!==s.stencilZFail||e.stencilZPass!==s.stencilZPass||e.stencilFuncMask!==s.stencilFuncMask||e.stencilWriteMask!==s.stencilWriteMask||e.side!==s.side||e.alphaToCoverage!==s.alphaToCoverage||e.sampleCount!==n||e.colorSpace!==a||e.colorFormat!==o||e.depthStencilFormat!==l||e.primitiveTopology!==h||e.clippingContextCacheKey!==t.clippingContextCacheKey)&&(e.material=s,e.materialVersion=s.version,e.transparent=s.transparent,e.blending=s.blending,e.premultipliedAlpha=s.premultipliedAlpha,e.blendSrc=s.blendSrc,e.blendDst=s.blendDst,e.blendEquation=s.blendEquation,e.blendSrcAlpha=s.blendSrcAlpha,e.blendDstAlpha=s.blendDstAlpha,e.blendEquationAlpha=s.blendEquationAlpha,e.colorWrite=s.colorWrite,e.depthWrite=s.depthWrite,e.depthTest=s.depthTest,e.depthFunc=s.depthFunc,e.stencilWrite=s.stencilWrite,e.stencilFunc=s.stencilFunc,e.stencilFail=s.stencilFail,e.stencilZFail=s.stencilZFail,e.stencilZPass=s.stencilZPass,e.stencilFuncMask=s.stencilFuncMask,e.stencilWriteMask=s.stencilWriteMask,e.side=s.side,e.alphaToCoverage=s.alphaToCoverage,e.sampleCount=n,e.colorSpace=a,e.colorFormat=o,e.depthStencilFormat=l,e.primitiveTopology=h,e.clippingContextCacheKey=t.clippingContextCacheKey,u=!0),u}getRenderCacheKey(t){let{object:e,material:r}=t,s=this.utils,i=t.context;return[r.transparent,r.blending,r.premultipliedAlpha,r.blendSrc,r.blendDst,r.blendEquation,r.blendSrcAlpha,r.blendDstAlpha,r.blendEquationAlpha,r.colorWrite,r.depthWrite,r.depthTest,r.depthFunc,r.stencilWrite,r.stencilFunc,r.stencilFail,r.stencilZFail,r.stencilZPass,r.stencilFuncMask,r.stencilWriteMask,r.side,s.getSampleCountRenderContext(i),s.getCurrentColorSpace(i),s.getCurrentColorFormat(i),s.getCurrentDepthStencilFormat(i),s.getPrimitiveTopology(e,r),t.getGeometryCacheKey(),t.clippingContextCacheKey].join()}createSampler(t){this.textureUtils.createSampler(t)}destroySampler(t){this.textureUtils.destroySampler(t)}createDefaultTexture(t){this.textureUtils.createDefaultTexture(t)}createTexture(t,e){this.textureUtils.createTexture(t,e)}updateTexture(t,e){this.textureUtils.updateTexture(t,e)}generateMipmaps(t){this.textureUtils.generateMipmaps(t)}destroyTexture(t){this.textureUtils.destroyTexture(t)}async copyTextureToBuffer(t,e,r,s,i,n){return this.textureUtils.copyTextureToBuffer(t,e,r,s,i,n)}initTimestampQuery(t,e){if(!this.trackTimestamp)return;let r=t.isComputeNode?"compute":"render";this.timestampQueryPool[r]||(this.timestampQueryPool[r]=new l7(this.device,r,2048));let s=this.timestampQueryPool[r],i=s.allocateQueriesForContext(t);e.timestampWrites={querySet:s.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(t,e){return new e7(t,e)}createProgram(t){let e=this.get(t);e.module={module:this.device.createShaderModule({code:t.code,label:t.stage+(t.name===""?"":`_${t.name}`)}),entryPoint:"main"}}destroyProgram(t){this.delete(t)}createRenderPipeline(t,e){this.pipelineUtils.createRenderPipeline(t,e)}createComputePipeline(t,e){this.pipelineUtils.createComputePipeline(t,e)}beginBundle(t){let e=this.get(t);e._currentPass=e.currentPass,e._currentSets=e.currentSets,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.currentPass=this.pipelineUtils.createBundleEncoder(t)}finishBundle(t,e){let r=this.get(t),s=r.currentPass,i=s.finish();this.get(e).bundleGPU=i,r.currentSets=r._currentSets,r.currentPass=r._currentPass}addBundle(t,e){this.get(t).renderBundles.push(this.get(e).bundleGPU)}createBindings(t,e,r,s){this.bindingUtils.createBindings(t,e,r,s)}updateBindings(t,e,r,s){this.bindingUtils.createBindings(t,e,r,s)}updateBinding(t){this.bindingUtils.updateBinding(t)}createIndexAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(t){this.attributeUtils.updateAttribute(t)}destroyAttribute(t){this.attributeUtils.destroyAttribute(t)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(t){return this.device.features.has(t)}copyTextureToTexture(t,e,r=null,s=null,i=0,n=0){let a=0,o=0,l=0,h=0,u=0,c=0,d=t.image.width,p=t.image.height,m=1;r!==null&&(r.isBox3===!0?(h=r.min.x,u=r.min.y,c=r.min.z,d=r.max.x-r.min.x,p=r.max.y-r.min.y,m=r.max.z-r.min.z):(h=r.min.x,u=r.min.y,d=r.max.x-r.min.x,p=r.max.y-r.min.y,m=1)),s!==null&&(a=s.x,o=s.y,l=s.z||0);let f=this.device.createCommandEncoder({label:"copyTextureToTexture_"+t.id+"_"+e.id}),g=this.get(t).texture,b=this.get(e).texture;f.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:h,y:u,z:c}},{texture:b,mipLevel:n,origin:{x:a,y:o,z:l}},[d,p,m]),this.device.queue.submit([f.finish()]),n===0&&e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}copyFramebufferToTexture(t,e,r){let s=this.get(e),i=null;i=e.renderTarget?t.isDepthTexture?this.get(e.depthTexture).texture:this.get(e.textures[0]).texture:t.isDepthTexture?this.textureUtils.getDepthBuffer(e.depth,e.stencil):this.context.getCurrentTexture();let n=this.get(t).texture;if(i.format!==n.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",i.format,n.format);return}let a;if(s.currentPass?(s.currentPass.end(),a=s.encoder):a=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+t.id}),a.copyTextureToTexture({texture:i,origin:[r.x,r.y,0]},{texture:n},[r.z,r.w]),s.currentPass){let{descriptor:o}=s;for(let l=0;l<o.colorAttachments.length;l++)o.colorAttachments[l].loadOp=tt.Load;if(e.depth&&(o.depthStencilAttachment.depthLoadOp=tt.Load),e.stencil&&(o.depthStencilAttachment.stencilLoadOp=tt.Load),s.currentPass=a.beginRenderPass(o),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.viewport&&this.updateViewport(e),e.scissor){let{x:l,y:h,width:u,height:c}=e.scissorValue;s.currentPass.setScissorRect(l,h,u,c)}}else this.device.queue.submit([a.finish()]);t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}},h7=class extends f1{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n),this.iesMap=null}copy(t,e){return super.copy(t,e),this.iesMap=t.iesMap,this}},c7=class extends f1{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n),this.aspect=null}copy(t,e){return super.copy(t,e),this.aspect=t.aspect,this}},d7=class extends l3{constructor(){super(),this.addMaterial(rk,"MeshPhongMaterial"),this.addMaterial(QR,"MeshStandardMaterial"),this.addMaterial(Dk,"MeshPhysicalMaterial"),this.addMaterial(Wk,"MeshToonMaterial"),this.addMaterial(VR,"MeshBasicMaterial"),this.addMaterial(ek,"MeshLambertMaterial"),this.addMaterial(j4,"MeshNormalMaterial"),this.addMaterial(Xk,"MeshMatcapMaterial"),this.addMaterial(V4,"LineBasicMaterial"),this.addMaterial(k4,"LineDashedMaterial"),this.addMaterial(Qk,"PointsMaterial"),this.addMaterial(eE,"SpriteMaterial"),this.addMaterial(tU,"ShadowMaterial"),this.addLight(t8,iV),this.addLight($9,aV),this.addLight(G9,lV),this.addLight(Ev,f1),this.addLight(q9,oV),this.addLight(X9,tV),this.addLight(Y9,hV),this.addLight(j9,h7),this.addLight(H9,c7),this.addToneMapping(SE,Tz),this.addToneMapping(ME,wz),this.addToneMapping(_E,Sz),this.addToneMapping(NE,Mz),this.addToneMapping(AE,_z),this.addToneMapping(CE,Nz)}},KS=class extends m${constructor(t={}){let e;t.forceWebGL?e=jS:(e=u7,t.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new jS(t)));let r=new e(t);super(r,t),this.library=new d7,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},_t={};cz(_t,{BRDF_GGX:()=>p7,BRDF_Lambert:()=>m7,BasicShadowFilter:()=>f7,Break:()=>g7,Const:()=>wj,Continue:()=>y7,DFGApprox:()=>x7,D_GGX:()=>b7,Discard:()=>v7,EPSILON:()=>T7,F_Schlick:()=>w7,Fn:()=>S7,INFINITY:()=>M7,If:()=>_7,Loop:()=>A7,NodeAccess:()=>P7,NodeShaderStage:()=>C7,NodeType:()=>R7,NodeUpdateType:()=>E7,PCFShadowFilter:()=>F7,PCFSoftShadowFilter:()=>L7,PI:()=>I7,PI2:()=>z7,Return:()=>B7,Schlick_to_F0:()=>V7,ScriptableNodeResources:()=>O7,ShaderNode:()=>k7,Switch:()=>N7,TBNViewMatrix:()=>U7,VSMShadowFilter:()=>D7,V_GGX_SmithCorrelated:()=>$7,Var:()=>CJ,abs:()=>G7,acesFilmicToneMapping:()=>j7,acos:()=>W7,add:()=>pb,addNodeElement:()=>H7,agxToneMapping:()=>q7,all:()=>X7,alphaT:()=>Y7,and:()=>Z7,anisotropy:()=>J7,anisotropyB:()=>Q7,anisotropyT:()=>K7,any:()=>eG,append:()=>tG,array:()=>rG,arrayBuffer:()=>sG,asin:()=>iG,assign:()=>nG,atan:()=>aG,atan2:()=>oG,atomicAdd:()=>lG,atomicAnd:()=>uG,atomicFunc:()=>hG,atomicLoad:()=>yG,atomicMax:()=>cG,atomicMin:()=>dG,atomicOr:()=>pG,atomicStore:()=>mG,atomicSub:()=>fG,atomicXor:()=>gG,attenuationColor:()=>xG,attenuationDistance:()=>bG,attribute:()=>vG,attributeArray:()=>TG,backgroundBlurriness:()=>wG,backgroundIntensity:()=>SG,backgroundRotation:()=>MG,batch:()=>_G,billboarding:()=>NG,bitAnd:()=>AG,bitNot:()=>CG,bitOr:()=>RG,bitXor:()=>EG,bitangentGeometry:()=>PG,bitangentLocal:()=>FG,bitangentView:()=>LG,bitangentWorld:()=>IG,bitcast:()=>zG,blendBurn:()=>BG,blendColor:()=>VG,blendDodge:()=>OG,blendOverlay:()=>kG,blendScreen:()=>UG,blur:()=>DG,bool:()=>$G,buffer:()=>GG,bufferAttribute:()=>jG,bumpMap:()=>WG,burn:()=>HG,bvec2:()=>qG,bvec3:()=>XG,bvec4:()=>YG,bypass:()=>ZG,cache:()=>JG,call:()=>QG,cameraFar:()=>KG,cameraIndex:()=>ej,cameraNear:()=>tj,cameraNormalMatrix:()=>rj,cameraPosition:()=>sj,cameraProjectionMatrix:()=>ij,cameraProjectionMatrixInverse:()=>nj,cameraViewMatrix:()=>aj,cameraWorldMatrix:()=>oj,cbrt:()=>lj,cdl:()=>uj,ceil:()=>hj,checker:()=>cj,cineonToneMapping:()=>dj,clamp:()=>x3,clearcoat:()=>pj,clearcoatRoughness:()=>mj,code:()=>fj,color:()=>gj,colorSpaceToWorking:()=>yj,colorToDirection:()=>xj,compute:()=>bj,computeSkinning:()=>vj,cond:()=>Tj,context:()=>Sj,convert:()=>Mj,convertColorSpace:()=>_j,convertToTexture:()=>Nj,cos:()=>ff,cross:()=>Aj,cubeTexture:()=>Cj,dFdx:()=>Rj,dFdy:()=>Ej,dashSize:()=>Pj,debug:()=>Fj,decrement:()=>Lj,decrementBefore:()=>Ij,defaultBuildStages:()=>zj,defaultShaderStages:()=>Bj,defined:()=>Vj,degrees:()=>Oj,deltaTime:()=>kj,densityFog:()=>Uj,densityFogFactor:()=>Dj,depth:()=>$j,depthPass:()=>Gj,difference:()=>jj,diffuseColor:()=>Wj,directPointLight:()=>Hj,directionToColor:()=>qj,dispersion:()=>Xj,distance:()=>Yj,div:()=>Zj,dodge:()=>Jj,dot:()=>wd,drawIndex:()=>Qj,dynamicBufferAttribute:()=>Kj,element:()=>eW,emissive:()=>tW,equal:()=>rW,equals:()=>sW,equirectUV:()=>iW,exp:()=>nW,exp2:()=>aW,expression:()=>oW,faceDirection:()=>lW,faceForward:()=>uW,faceforward:()=>hW,float:()=>mb,floor:()=>cW,fog:()=>dW,fract:()=>fb,frameGroup:()=>pW,frameId:()=>mW,frontFacing:()=>fW,fwidth:()=>b3,gain:()=>gW,gapSize:()=>yW,getConstNodeType:()=>xW,getCurrentStack:()=>bW,getDirection:()=>vW,getDistanceAttenuation:()=>TW,getGeometryRoughness:()=>wW,getNormalFromDepth:()=>SW,getParallaxCorrectNormal:()=>MW,getRoughness:()=>_W,getScreenPosition:()=>NW,getShIrradianceAt:()=>AW,getShadowMaterial:()=>EW,getShadowRenderObjectFunction:()=>PW,getTextureIndex:()=>CW,getViewPosition:()=>RW,globalId:()=>SH,glsl:()=>FW,glslFn:()=>LW,grayscale:()=>IW,greaterThan:()=>zW,greaterThanEqual:()=>BW,hash:()=>VW,highpModelNormalViewMatrix:()=>OW,highpModelViewMatrix:()=>kW,hue:()=>UW,increment:()=>DW,incrementBefore:()=>$W,instance:()=>GW,instanceIndex:()=>jW,instancedArray:()=>WW,instancedBufferAttribute:()=>HW,instancedDynamicBufferAttribute:()=>qW,instancedMesh:()=>XW,int:()=>YW,inverseSqrt:()=>ZW,inversesqrt:()=>JW,invocationLocalIndex:()=>QW,invocationSubgroupIndex:()=>KW,ior:()=>eH,iridescence:()=>tH,iridescenceIOR:()=>rH,iridescenceThickness:()=>sH,ivec2:()=>iH,ivec3:()=>nH,ivec4:()=>aH,js:()=>oH,label:()=>lH,length:()=>uH,lengthSq:()=>hH,lessThan:()=>cH,lessThanEqual:()=>dH,lightPosition:()=>pH,lightProjectionUV:()=>xY,lightShadowMatrix:()=>mH,lightTargetDirection:()=>fH,lightTargetPosition:()=>gH,lightViewPosition:()=>yH,lightingContext:()=>xH,lights:()=>bH,linearDepth:()=>vH,linearToneMapping:()=>TH,localId:()=>wH,log:()=>MH,log2:()=>_H,logarithmicDepthToViewZ:()=>NH,loop:()=>AH,luminance:()=>CH,mat2:()=>EH,mat3:()=>PH,mat4:()=>FH,matcapUV:()=>LH,materialAO:()=>IH,materialAlphaTest:()=>zH,materialAnisotropy:()=>BH,materialAnisotropyVector:()=>VH,materialAttenuationColor:()=>OH,materialAttenuationDistance:()=>kH,materialClearcoat:()=>UH,materialClearcoatNormal:()=>DH,materialClearcoatRoughness:()=>$H,materialColor:()=>GH,materialDispersion:()=>jH,materialEmissive:()=>WH,materialIOR:()=>HH,materialIridescence:()=>qH,materialIridescenceIOR:()=>XH,materialIridescenceThickness:()=>YH,materialLightMap:()=>ZH,materialLineDashOffset:()=>JH,materialLineDashSize:()=>QH,materialLineGapSize:()=>KH,materialLineScale:()=>eq,materialLineWidth:()=>tq,materialMetalness:()=>rq,materialNormal:()=>sq,materialOpacity:()=>iq,materialPointSize:()=>nq,materialReference:()=>aq,materialReflectivity:()=>oq,materialRefractionRatio:()=>lq,materialRotation:()=>uq,materialRoughness:()=>hq,materialSheen:()=>cq,materialSheenRoughness:()=>dq,materialShininess:()=>pq,materialSpecular:()=>mq,materialSpecularColor:()=>fq,materialSpecularIntensity:()=>gq,materialSpecularStrength:()=>yq,materialThickness:()=>xq,materialTransmission:()=>bq,max:()=>v3,maxMipLevel:()=>vq,mediumpModelViewMatrix:()=>RH,metalness:()=>Tq,min:()=>wq,mix:()=>ml,mixElement:()=>Sq,mod:()=>Mq,modInt:()=>_q,modelDirection:()=>Nq,modelNormalMatrix:()=>Aq,modelPosition:()=>Cq,modelRadius:()=>Rq,modelScale:()=>Eq,modelViewMatrix:()=>Pq,modelViewPosition:()=>Fq,modelViewProjection:()=>Lq,modelWorldMatrix:()=>Iq,modelWorldMatrixInverse:()=>zq,morphReference:()=>Bq,mrt:()=>Vq,mul:()=>qs,mx_aastep:()=>Oq,mx_cell_noise_float:()=>kq,mx_contrast:()=>Uq,mx_fractal_noise_float:()=>Dq,mx_fractal_noise_vec2:()=>$q,mx_fractal_noise_vec3:()=>Gq,mx_fractal_noise_vec4:()=>jq,mx_hsvtorgb:()=>Wq,mx_noise_float:()=>Hq,mx_noise_vec3:()=>qq,mx_noise_vec4:()=>Xq,mx_ramplr:()=>Yq,mx_ramptb:()=>Zq,mx_rgbtohsv:()=>Jq,mx_safepower:()=>Qq,mx_splitlr:()=>Kq,mx_splittb:()=>eX,mx_srgb_texture_to_lin_rec709:()=>tX,mx_transform_uv:()=>rX,mx_worley_noise_float:()=>sX,mx_worley_noise_vec2:()=>iX,mx_worley_noise_vec3:()=>nX,namespace:()=>aX,negate:()=>oX,neutralToneMapping:()=>lX,nodeArray:()=>uX,nodeImmutable:()=>hX,nodeObject:()=>cX,nodeObjects:()=>dX,nodeProxy:()=>pX,normalFlat:()=>mX,normalGeometry:()=>fX,normalLocal:()=>gX,normalMap:()=>yX,normalView:()=>xX,normalWorld:()=>bX,normalize:()=>vX,not:()=>TX,notEqual:()=>wX,numWorkgroups:()=>SX,objectDirection:()=>MX,objectGroup:()=>_X,objectPosition:()=>NX,objectRadius:()=>AX,objectScale:()=>CX,objectViewPosition:()=>RX,objectWorldMatrix:()=>EX,oneMinus:()=>PX,or:()=>FX,orthographicDepthToViewZ:()=>LX,oscSawtooth:()=>IX,oscSine:()=>zX,oscSquare:()=>BX,oscTriangle:()=>VX,output:()=>OX,outputStruct:()=>kX,overlay:()=>UX,overloadingFn:()=>DX,parabola:()=>$X,parallaxDirection:()=>GX,parallaxUV:()=>jX,parameter:()=>WX,pass:()=>HX,passTexture:()=>qX,pcurve:()=>XX,perspectiveDepthToViewZ:()=>YX,pmremTexture:()=>ZX,pointShadow:()=>rZ,pointUV:()=>JX,pointWidth:()=>QX,positionGeometry:()=>KX,positionLocal:()=>eY,positionPrevious:()=>tY,positionView:()=>rY,positionViewDirection:()=>sY,positionWorld:()=>iY,positionWorldDirection:()=>nY,posterize:()=>aY,pow:()=>T3,pow2:()=>oY,pow3:()=>lY,pow4:()=>uY,premult:()=>hY,property:()=>cY,radians:()=>dY,rand:()=>pY,range:()=>mY,rangeFog:()=>fY,rangeFogFactor:()=>gY,reciprocal:()=>yY,reference:()=>bY,referenceBuffer:()=>vY,reflect:()=>TY,reflectVector:()=>wY,reflectView:()=>SY,reflector:()=>MY,refract:()=>_Y,refractVector:()=>NY,refractView:()=>AY,reinhardToneMapping:()=>CY,remainder:()=>RY,remap:()=>EY,remapClamp:()=>PY,renderGroup:()=>FY,renderOutput:()=>LY,rendererReference:()=>IY,rotate:()=>zY,rotateUV:()=>BY,roughness:()=>VY,round:()=>OY,rtt:()=>kY,sRGBTransferEOTF:()=>UY,sRGBTransferOETF:()=>DY,sampler:()=>$Y,samplerComparison:()=>GY,saturate:()=>jY,saturation:()=>WY,screen:()=>HY,screenCoordinate:()=>qY,screenSize:()=>XY,screenUV:()=>YY,scriptable:()=>ZY,scriptableValue:()=>JY,select:()=>QY,setCurrentStack:()=>KY,shaderStages:()=>eZ,shadow:()=>tZ,shadowPositionWorld:()=>sZ,shapeCircle:()=>nZ,sharedUniformGroup:()=>iZ,sheen:()=>aZ,sheenRoughness:()=>oZ,shiftLeft:()=>lZ,shiftRight:()=>uZ,shininess:()=>hZ,sign:()=>cZ,sin:()=>no,sinc:()=>dZ,skinning:()=>pZ,smoothstep:()=>gb,smoothstepElement:()=>mZ,specularColor:()=>fZ,specularF90:()=>gZ,spherizeUV:()=>yZ,split:()=>xZ,spritesheetUV:()=>bZ,sqrt:()=>vZ,stack:()=>TZ,step:()=>wZ,storage:()=>SZ,storageBarrier:()=>MZ,storageObject:()=>_Z,storageTexture:()=>NZ,string:()=>AZ,struct:()=>CZ,sub:()=>Sd,subgroupIndex:()=>RZ,subgroupSize:()=>EZ,tan:()=>PZ,tangentGeometry:()=>FZ,tangentLocal:()=>LZ,tangentView:()=>IZ,tangentWorld:()=>zZ,temp:()=>BZ,texture:()=>VZ,texture3D:()=>OZ,textureBarrier:()=>kZ,textureBicubic:()=>UZ,textureCubeUV:()=>DZ,textureLoad:()=>$Z,textureSize:()=>GZ,textureStore:()=>jZ,thickness:()=>WZ,time:()=>Lv,timerDelta:()=>HZ,timerGlobal:()=>qZ,timerLocal:()=>XZ,toneMapping:()=>YZ,toneMappingExposure:()=>ZZ,toonOutlinePass:()=>JZ,transformDirection:()=>QZ,transformNormal:()=>KZ,transformNormalToView:()=>eJ,transformedBentNormalView:()=>tJ,transformedBitangentView:()=>rJ,transformedBitangentWorld:()=>sJ,transformedClearcoatNormalView:()=>iJ,transformedNormalView:()=>nJ,transformedNormalWorld:()=>aJ,transformedTangentView:()=>oJ,transformedTangentWorld:()=>lJ,transmission:()=>uJ,transpose:()=>hJ,triNoise3D:()=>cJ,triplanarTexture:()=>dJ,triplanarTextures:()=>pJ,trunc:()=>mJ,tslFn:()=>fJ,uint:()=>gJ,uniform:()=>yJ,uniformArray:()=>bJ,uniformCubeTexture:()=>xJ,uniformGroup:()=>vJ,uniformTexture:()=>TJ,uniforms:()=>wJ,unpremult:()=>SJ,userData:()=>MJ,uv:()=>Iv,uvec2:()=>_J,uvec3:()=>NJ,uvec4:()=>AJ,varying:()=>RJ,varyingProperty:()=>EJ,vec2:()=>zv,vec3:()=>Bv,vec4:()=>Ur,vectorComponents:()=>PJ,velocity:()=>FJ,vertexColor:()=>LJ,vertexIndex:()=>IJ,vibrance:()=>zJ,viewZToLogarithmicDepth:()=>BJ,viewZToOrthographicDepth:()=>VJ,viewZToPerspectiveDepth:()=>OJ,viewport:()=>kJ,viewportBottomLeft:()=>UJ,viewportCoordinate:()=>DJ,viewportDepthTexture:()=>$J,viewportLinearDepth:()=>GJ,viewportMipTexture:()=>jJ,viewportResolution:()=>WJ,viewportSafeUV:()=>HJ,viewportSharedTexture:()=>qJ,viewportSize:()=>XJ,viewportTexture:()=>YJ,viewportTopLeft:()=>ZJ,viewportUV:()=>JJ,wgsl:()=>QJ,wgslFn:()=>KJ,workgroupArray:()=>eQ,workgroupBarrier:()=>tQ,workgroupId:()=>rQ,workingToColorSpace:()=>sQ,xor:()=>iQ});const p7=y.BRDF_GGX,m7=y.BRDF_Lambert,f7=y.BasicShadowFilter,g7=y.Break,y7=y.Continue,x7=y.DFGApprox,b7=y.D_GGX,v7=y.Discard,T7=y.EPSILON,w7=y.F_Schlick,S7=y.Fn,M7=y.INFINITY,_7=y.If,N7=y.Switch,A7=y.Loop,C7=y.NodeShaderStage,R7=y.NodeType,E7=y.NodeUpdateType,P7=y.NodeAccess,F7=y.PCFShadowFilter,L7=y.PCFSoftShadowFilter,I7=y.PI,z7=y.PI2,B7=y.Return,V7=y.Schlick_to_F0,O7=y.ScriptableNodeResources,k7=y.ShaderNode,U7=y.TBNViewMatrix,D7=y.VSMShadowFilter,$7=y.V_GGX_SmithCorrelated,G7=y.abs,j7=y.acesFilmicToneMapping,W7=y.acos,pb=y.add,H7=y.addNodeElement,q7=y.agxToneMapping,X7=y.all,Y7=y.alphaT,Z7=y.and,J7=y.anisotropy,Q7=y.anisotropyB,K7=y.anisotropyT,eG=y.any,tG=y.append,rG=y.array,sG=y.arrayBuffer,iG=y.asin,nG=y.assign,aG=y.atan,oG=y.atan2,lG=y.atomicAdd,uG=y.atomicAnd,hG=y.atomicFunc,cG=y.atomicMax,dG=y.atomicMin,pG=y.atomicOr,mG=y.atomicStore,fG=y.atomicSub,gG=y.atomicXor,yG=y.atomicLoad,xG=y.attenuationColor,bG=y.attenuationDistance,vG=y.attribute,TG=y.attributeArray,wG=y.backgroundBlurriness,SG=y.backgroundIntensity,MG=y.backgroundRotation,_G=y.batch,NG=y.billboarding,AG=y.bitAnd,CG=y.bitNot,RG=y.bitOr,EG=y.bitXor,PG=y.bitangentGeometry,FG=y.bitangentLocal,LG=y.bitangentView,IG=y.bitangentWorld,zG=y.bitcast,BG=y.blendBurn,VG=y.blendColor,OG=y.blendDodge,kG=y.blendOverlay,UG=y.blendScreen,DG=y.blur,$G=y.bool,GG=y.buffer,jG=y.bufferAttribute,WG=y.bumpMap,HG=y.burn,qG=y.bvec2,XG=y.bvec3,YG=y.bvec4,ZG=y.bypass,JG=y.cache,QG=y.call,KG=y.cameraFar,ej=y.cameraIndex,tj=y.cameraNear,rj=y.cameraNormalMatrix,sj=y.cameraPosition,ij=y.cameraProjectionMatrix,nj=y.cameraProjectionMatrixInverse,aj=y.cameraViewMatrix,oj=y.cameraWorldMatrix,lj=y.cbrt,uj=y.cdl,hj=y.ceil,cj=y.checker,dj=y.cineonToneMapping,x3=y.clamp,pj=y.clearcoat,mj=y.clearcoatRoughness,fj=y.code,gj=y.color,yj=y.colorSpaceToWorking,xj=y.colorToDirection,bj=y.compute,vj=y.computeSkinning,Tj=y.cond,wj=y.Const,Sj=y.context,Mj=y.convert,_j=y.convertColorSpace,Nj=y.convertToTexture,ff=y.cos,Aj=y.cross,Cj=y.cubeTexture,Rj=y.dFdx,Ej=y.dFdy,Pj=y.dashSize,Fj=y.debug,Lj=y.decrement,Ij=y.decrementBefore,zj=y.defaultBuildStages,Bj=y.defaultShaderStages,Vj=y.defined,Oj=y.degrees,kj=y.deltaTime,Uj=y.densityFog,Dj=y.densityFogFactor,$j=y.depth,Gj=y.depthPass,jj=y.difference,Wj=y.diffuseColor,Hj=y.directPointLight,qj=y.directionToColor,Xj=y.dispersion,Yj=y.distance,Zj=y.div,Jj=y.dodge,wd=y.dot,Qj=y.drawIndex,Kj=y.dynamicBufferAttribute,eW=y.element,tW=y.emissive,rW=y.equal,sW=y.equals,iW=y.equirectUV,nW=y.exp,aW=y.exp2,oW=y.expression,lW=y.faceDirection,uW=y.faceForward,hW=y.faceforward,mb=y.float,cW=y.floor,dW=y.fog,fb=y.fract,pW=y.frameGroup,mW=y.frameId,fW=y.frontFacing,b3=y.fwidth,gW=y.gain,yW=y.gapSize,xW=y.getConstNodeType,bW=y.getCurrentStack,vW=y.getDirection,TW=y.getDistanceAttenuation,wW=y.getGeometryRoughness,SW=y.getNormalFromDepth,MW=y.getParallaxCorrectNormal,_W=y.getRoughness,NW=y.getScreenPosition,AW=y.getShIrradianceAt,CW=y.getTextureIndex,RW=y.getViewPosition,EW=y.getShadowMaterial,PW=y.getShadowRenderObjectFunction,FW=y.glsl,LW=y.glslFn,IW=y.grayscale,zW=y.greaterThan,BW=y.greaterThanEqual,VW=y.hash,OW=y.highpModelNormalViewMatrix,kW=y.highpModelViewMatrix,UW=y.hue,DW=y.increment,$W=y.incrementBefore,GW=y.instance,jW=y.instanceIndex,WW=y.instancedArray,HW=y.instancedBufferAttribute,qW=y.instancedDynamicBufferAttribute,XW=y.instancedMesh,YW=y.int,ZW=y.inverseSqrt,JW=y.inversesqrt,QW=y.invocationLocalIndex,KW=y.invocationSubgroupIndex,eH=y.ior,tH=y.iridescence,rH=y.iridescenceIOR,sH=y.iridescenceThickness,iH=y.ivec2,nH=y.ivec3,aH=y.ivec4,oH=y.js,lH=y.label,uH=y.length,hH=y.lengthSq,cH=y.lessThan,dH=y.lessThanEqual,pH=y.lightPosition,mH=y.lightShadowMatrix,fH=y.lightTargetDirection,gH=y.lightTargetPosition,yH=y.lightViewPosition,xH=y.lightingContext,bH=y.lights,vH=y.linearDepth,TH=y.linearToneMapping,wH=y.localId,SH=y.globalId,MH=y.log,_H=y.log2,NH=y.logarithmicDepthToViewZ,AH=y.loop,CH=y.luminance,RH=y.mediumpModelViewMatrix,EH=y.mat2,PH=y.mat3,FH=y.mat4,LH=y.matcapUV,IH=y.materialAO,zH=y.materialAlphaTest,BH=y.materialAnisotropy,VH=y.materialAnisotropyVector,OH=y.materialAttenuationColor,kH=y.materialAttenuationDistance,UH=y.materialClearcoat,DH=y.materialClearcoatNormal,$H=y.materialClearcoatRoughness,GH=y.materialColor,jH=y.materialDispersion,WH=y.materialEmissive,HH=y.materialIOR,qH=y.materialIridescence,XH=y.materialIridescenceIOR,YH=y.materialIridescenceThickness,ZH=y.materialLightMap,JH=y.materialLineDashOffset,QH=y.materialLineDashSize,KH=y.materialLineGapSize,eq=y.materialLineScale,tq=y.materialLineWidth,rq=y.materialMetalness,sq=y.materialNormal,iq=y.materialOpacity,nq=y.materialPointSize,aq=y.materialReference,oq=y.materialReflectivity,lq=y.materialRefractionRatio,uq=y.materialRotation,hq=y.materialRoughness,cq=y.materialSheen,dq=y.materialSheenRoughness,pq=y.materialShininess,mq=y.materialSpecular,fq=y.materialSpecularColor,gq=y.materialSpecularIntensity,yq=y.materialSpecularStrength,xq=y.materialThickness,bq=y.materialTransmission,v3=y.max,vq=y.maxMipLevel,Tq=y.metalness,wq=y.min,ml=y.mix,Sq=y.mixElement,Mq=y.mod,_q=y.modInt,Nq=y.modelDirection,Aq=y.modelNormalMatrix,Cq=y.modelPosition,Rq=y.modelRadius,Eq=y.modelScale,Pq=y.modelViewMatrix,Fq=y.modelViewPosition,Lq=y.modelViewProjection,Iq=y.modelWorldMatrix,zq=y.modelWorldMatrixInverse,Bq=y.morphReference,Vq=y.mrt,qs=y.mul,Oq=y.mx_aastep,kq=y.mx_cell_noise_float,Uq=y.mx_contrast,Dq=y.mx_fractal_noise_float,$q=y.mx_fractal_noise_vec2,Gq=y.mx_fractal_noise_vec3,jq=y.mx_fractal_noise_vec4,Wq=y.mx_hsvtorgb,Hq=y.mx_noise_float,qq=y.mx_noise_vec3,Xq=y.mx_noise_vec4,Yq=y.mx_ramplr,Zq=y.mx_ramptb,Jq=y.mx_rgbtohsv,Qq=y.mx_safepower,Kq=y.mx_splitlr,eX=y.mx_splittb,tX=y.mx_srgb_texture_to_lin_rec709,rX=y.mx_transform_uv,sX=y.mx_worley_noise_float,iX=y.mx_worley_noise_vec2,nX=y.mx_worley_noise_vec3,aX=y.namespace,oX=y.negate,lX=y.neutralToneMapping,uX=y.nodeArray,hX=y.nodeImmutable,cX=y.nodeObject,dX=y.nodeObjects,pX=y.nodeProxy,mX=y.normalFlat,fX=y.normalGeometry,gX=y.normalLocal,yX=y.normalMap,xX=y.normalView,bX=y.normalWorld,vX=y.normalize,TX=y.not,wX=y.notEqual,SX=y.numWorkgroups,MX=y.objectDirection,_X=y.objectGroup,NX=y.objectPosition,AX=y.objectRadius,CX=y.objectScale,RX=y.objectViewPosition,EX=y.objectWorldMatrix,PX=y.oneMinus,FX=y.or,LX=y.orthographicDepthToViewZ,IX=y.oscSawtooth,zX=y.oscSine,BX=y.oscSquare,VX=y.oscTriangle,OX=y.output,kX=y.outputStruct,UX=y.overlay,DX=y.overloadingFn,$X=y.parabola,GX=y.parallaxDirection,jX=y.parallaxUV,WX=y.parameter,HX=y.pass,qX=y.passTexture,XX=y.pcurve,YX=y.perspectiveDepthToViewZ,ZX=y.pmremTexture,JX=y.pointUV,QX=y.pointWidth,KX=y.positionGeometry,eY=y.positionLocal,tY=y.positionPrevious,rY=y.positionView,sY=y.positionViewDirection,iY=y.positionWorld,nY=y.positionWorldDirection,aY=y.posterize,T3=y.pow,oY=y.pow2,lY=y.pow3,uY=y.pow4,hY=y.premult,cY=y.property,dY=y.radians,pY=y.rand,mY=y.range,fY=y.rangeFog,gY=y.rangeFogFactor,yY=y.reciprocal,xY=y.lightProjectionUV,bY=y.reference,vY=y.referenceBuffer,TY=y.reflect,wY=y.reflectVector,SY=y.reflectView,MY=y.reflector,_Y=y.refract,NY=y.refractVector,AY=y.refractView,CY=y.reinhardToneMapping,RY=y.remainder,EY=y.remap,PY=y.remapClamp,FY=y.renderGroup,LY=y.renderOutput,IY=y.rendererReference,zY=y.rotate,BY=y.rotateUV,VY=y.roughness,OY=y.round,kY=y.rtt,UY=y.sRGBTransferEOTF,DY=y.sRGBTransferOETF,$Y=y.sampler,GY=y.samplerComparison,jY=y.saturate,WY=y.saturation,HY=y.screen,qY=y.screenCoordinate,XY=y.screenSize,YY=y.screenUV,ZY=y.scriptable,JY=y.scriptableValue,QY=y.select,KY=y.setCurrentStack,eZ=y.shaderStages,tZ=y.shadow,rZ=y.pointShadow,sZ=y.shadowPositionWorld,iZ=y.sharedUniformGroup,nZ=y.shapeCircle,aZ=y.sheen,oZ=y.sheenRoughness,lZ=y.shiftLeft,uZ=y.shiftRight,hZ=y.shininess,cZ=y.sign,no=y.sin,dZ=y.sinc,pZ=y.skinning,gb=y.smoothstep,mZ=y.smoothstepElement,fZ=y.specularColor,gZ=y.specularF90,yZ=y.spherizeUV,xZ=y.split,bZ=y.spritesheetUV,vZ=y.sqrt,TZ=y.stack,wZ=y.step,SZ=y.storage,MZ=y.storageBarrier,_Z=y.storageObject,NZ=y.storageTexture,AZ=y.string,CZ=y.struct,Sd=y.sub,RZ=y.subgroupIndex,EZ=y.subgroupSize,PZ=y.tan,FZ=y.tangentGeometry,LZ=y.tangentLocal,IZ=y.tangentView,zZ=y.tangentWorld,BZ=y.temp,VZ=y.texture,OZ=y.texture3D,kZ=y.textureBarrier,UZ=y.textureBicubic,DZ=y.textureCubeUV,$Z=y.textureLoad,GZ=y.textureSize,jZ=y.textureStore,WZ=y.thickness,Lv=y.time,HZ=y.timerDelta,qZ=y.timerGlobal,XZ=y.timerLocal,YZ=y.toneMapping,ZZ=y.toneMappingExposure,JZ=y.toonOutlinePass,QZ=y.transformDirection,KZ=y.transformNormal,eJ=y.transformNormalToView,tJ=y.transformedBentNormalView,rJ=y.transformedBitangentView,sJ=y.transformedBitangentWorld,iJ=y.transformedClearcoatNormalView,nJ=y.transformedNormalView,aJ=y.transformedNormalWorld,oJ=y.transformedTangentView,lJ=y.transformedTangentWorld,uJ=y.transmission,hJ=y.transpose,cJ=y.triNoise3D,dJ=y.triplanarTexture,pJ=y.triplanarTextures,mJ=y.trunc,fJ=y.tslFn,gJ=y.uint,yJ=y.uniform,xJ=y.uniformCubeTexture,bJ=y.uniformArray,vJ=y.uniformGroup,TJ=y.uniformTexture,wJ=y.uniforms,SJ=y.unpremult,MJ=y.userData,Iv=y.uv,_J=y.uvec2,NJ=y.uvec3,AJ=y.uvec4,CJ=y.Var,RJ=y.varying,EJ=y.varyingProperty,zv=y.vec2,Bv=y.vec3,Ur=y.vec4,PJ=y.vectorComponents,FJ=y.velocity,LJ=y.vertexColor,IJ=y.vertexIndex,zJ=y.vibrance,BJ=y.viewZToLogarithmicDepth,VJ=y.viewZToOrthographicDepth,OJ=y.viewZToPerspectiveDepth,kJ=y.viewport,UJ=y.viewportBottomLeft,DJ=y.viewportCoordinate,$J=y.viewportDepthTexture,GJ=y.viewportLinearDepth,jJ=y.viewportMipTexture,WJ=y.viewportResolution,HJ=y.viewportSafeUV,qJ=y.viewportSharedTexture,XJ=y.viewportSize,YJ=y.viewportTexture,ZJ=y.viewportTopLeft,JJ=y.viewportUV,QJ=y.wgsl,KJ=y.wgslFn,eQ=y.workgroupArray,tQ=y.workgroupBarrier,rQ=y.workgroupId,sQ=y.workingToColorSpace,iQ=y.xor;function nQ(t,e,r=1){let s=t.rgb,i=e.rgb,n=qs(s,i),a=qs(e.a,r),o=ml(s,n,a),l=v3(t.a,qs(e.a,r));return Ur(o,l)}function aQ(t,e,r=1){let s=qs(e.a,r),i=pb(s,qs(t.a,Sd(1,s))),n=pb(qs(e.rgb,s),qs(t.rgb,qs(t.a,Sd(1,s))));return Ur(n,i)}const eM={normal:aQ,multiply:nQ};function au(t,e,r="normal",s=1){return(eM[r]||eM.normal)(t,e,s)}function oQ(t,e){let r=qs(t.a,e.a);return Ur(t.rgb,r)}function lQ(t,e){let r=Sd(1,e.a),s=qs(t.a,r);return Ur(t.rgb,s)}function uQ(t,e){let r=Bv(.2126,.7152,.0722),s=wd(e.rgb,r),i=qs(t.a,s);return Ur(t.rgb,i)}function hQ(t,e){let r=Bv(.2126,.7152,.0722),s=wd(e.rgb,r),i=Sd(1,s),n=qs(t.a,i);return Ur(t.rgb,n)}const tM={alpha:oQ,alphaInverted:lQ,luminance:uQ,luminanceInverted:hQ};function cQ(t,e,r="alpha"){return(tM[r]||tM.alpha)(t,e)}const rM={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};let sM=!1;const dQ=()=>{try{if(rM!==void 0){let{MODE:t,DEV:e}=rM;return e||t==="development"}if(typeof window<"u"&&window.location){let t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t.endsWith(".local")||t.includes("dev.")||t.startsWith("dev-")}return!1}catch{return!1}};function pQ(){let t=`renderer_${Math.random().toString(36).substring(2,11)}`,e=null,r,s,i,n,a,o={nodes:new Map,rootId:null,idToNodeId:new Map},l=null,h=null,u=null,c=!1,d=!1,p=!1,m=null,f=!1,g=!0,b=0,v=0,w=0,T=0,N=8,S=.5,_=.5,A=!1,D=!1,K=!1,J=[],re=!1,te=[],oe=!1,ae=()=>{var le;return(le=window).matchMedia?.call(le,"(prefers-reduced-motion: reduce)").matches??!1},ge=(le,pe)=>{if(le===b&&pe===v)return;let ye=performance.now();if(ye-w<N)return;b=le,v=pe,w=ye,r.setSize(le,pe,!1);let Re=le/pe,bt=2,or=bt*Re;s.left=-or/2,s.right=or/2,s.top=bt/2,s.bottom=-2/2,s.updateProjectionMatrix(),n.scale.set(or,bt,1),o.rootId&&p&&me(),qt().catch(console.warn)},fe=le=>{if(!r||!s||!n)return;let pe=le[0];if(!pe)return;let{width:ye,height:Re}=pe.contentRect,bt=Math.round(ye),or=Math.round(Re);ge(bt,or)},ve=le=>{let pe=le[0];pe&&(f=pe.isIntersecting,f?(a&&c&&o.rootId&&me(),g&&br()):Pi())},me=()=>{if(!o.rootId||!a||D)return;if(o.nodes.get(o.rootId)){D=!0;try{let pe=ft(o.rootId);pe&&a&&(a.fragmentNode=pe,a.needsUpdate=!0)}catch(pe){console.error("Error composing shader tree:",pe)}finally{D=!1}f&&qt().catch(console.warn)}},he=le=>{let pe=[];return o.nodes.forEach(ye=>{ye.parentId===le&&pe.push(ye)}),pe},Te=le=>{for(let[pe,ye]of o.nodes.entries())if(ye.metadata.id===le)return pe;return null},Ge=(le,pe,ye,Re)=>{if(!pe.metadata.mask?.source)return le;let bt=pe.metadata.mask.source,or=Te(bt);if(!or)return le;if(Re.has(or))return console.error("Uh oh, looks like you've got a circular dependency in your shader masks."),le;let Lo=new Set(Re);Lo.add(ye);let os=ft(or,Lo),kl=pe.metadata.mask.type||"alpha";return cQ(le,os,kl)},He=le=>{let pe=o.nodes.get(le);if(!pe||!pe.metadata.id)return!1;let ye=pe.metadata.id;for(let Re of o.nodes.values())if(Re.metadata.mask?.source===ye)return!0;return!1},ft=(le,pe=new Set)=>{let ye=o.nodes.get(le);if(!ye)return Ur(0,0,0,0);let Re=os=>{ye.cleanupCallbacks.push(os)},bt=os=>{ye.beforeRenderCallbacks.push(os)},or=os=>{ye.afterRenderCallbacks.push(os)},Lo=he(le);if(Lo.length===0){let os=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:void 0,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(os,ye,le,pe)}else{let os=[...Lo].sort((Li,rc)=>Li.metadata.renderOrder-rc.metadata.renderOrder);if(ye.parentId===null){let Li;for(let vr of os){if((vr.metadata.opacity??(He(vr.id)?0:1))===0&&!He(vr.id))continue;let _p=ft(vr.id,pe),Dn;Dn=vr.metadata.opacity===void 0?He(vr.id)?0:1:vr.metadata.opacity,Li=Li===void 0?Dn===1?au(Ur(1,1,1,0),_p,"normal",1):au(Ur(1,1,1,0),_p,vr.metadata.blendMode,Dn):au(Li,_p,vr.metadata.blendMode,Dn)}let rc=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:Li,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(rc,ye,le,pe)}else{let Li;for(let vr of os){let Mp=ft(vr.id,pe);if((vr.metadata.opacity??(He(vr.id)?0:1))===0&&!He(vr.id))continue;let Dn;Dn=vr.metadata.opacity===void 0?He(vr.id)?0:1:vr.metadata.opacity,Li=Li===void 0?Dn===1?au(Ur(1,1,1,0),Mp,"normal",1):au(Ur(1,1,1,0),Mp,vr.metadata.blendMode,Dn):au(Li,Mp,vr.metadata.blendMode,Dn)}let rc=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:Li,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(rc,ye,le,pe)}}},ht=(le,pe,ye,Re,bt={})=>{let or=0;if(ye!==null){let os=Array.from(o.nodes.values()).filter(kl=>kl.parentId===ye);os.length>0&&(or=Math.max(...os.map(kl=>kl.metadata.renderOrder))+1)}let Lo={id:le,fragmentNodeFunc:pe,parentId:ye,metadata:{blendMode:Re?.blendMode||"normal",opacity:Re?.opacity,id:Re?.id,mask:Re?.mask,renderOrder:Re?.renderOrder===void 0?or:Re?.renderOrder},uniforms:bt,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};o.nodes.set(le,Lo),ye===null&&(o.rootId=le),a&&c&&(J.includes(le)||J.push(le),re||(re=!0,queueMicrotask(()=>{re=!1,J=[],me()})))},Ft=(le,pe,ye)=>{let Re=o.nodes.get(le);if(!Re||!Re.uniforms){console.warn(`Node or uniforms not found for ID: ${le}`);return}let bt=Re.uniforms[pe];if(!bt||!bt.uniform){console.warn(`Uniform ${pe} not found in node: ${le}`);return}bt.uniform.value=ye,f&&qt()},ri=(le,pe)=>{let ye=o.nodes.get(le);if(!ye)return;let Re=!1;pe.blendMode!==void 0&&ye.metadata.blendMode!==pe.blendMode&&(ye.metadata.blendMode=pe.blendMode,Re=!0),pe.opacity!==void 0&&ye.metadata.opacity!==pe.opacity&&(ye.metadata.opacity=pe.opacity,Re=!0),pe.renderOrder!==void 0&&ye.metadata.renderOrder!==pe.renderOrder&&(ye.metadata.renderOrder=pe.renderOrder,Re=!0),pe.id!==void 0&&ye.metadata.id!==pe.id&&(ye.metadata.id=pe.id,Re=!0),pe.mask!==void 0&&(ye.metadata.mask?.source!==pe.mask?.source||ye.metadata.mask?.type!==pe.mask?.type)&&(ye.metadata.mask=pe.mask,Re=!0),Re&&a&&c?(te.includes(le)||te.push(le),oe||(oe=!0,queueMicrotask(()=>{oe=!1,te=[],me()}))):f&&qt()},ar=le=>{if(!o.nodes.has(le))return;let pe=o.nodes.get(le);if(pe&&pe.cleanupCallbacks.length>0)for(let Re of pe.cleanupCallbacks)try{Re()}catch(bt){console.error(`Error executing cleanup callback for node ${le}:`,bt)}let ye=he(le);for(let Re of ye)ar(Re.id);o.rootId===le&&(o.rootId=null),o.nodes.delete(le),a&&c&&me()},et=le=>{let pe={deltaTime:le,pointer:{x:S,y:_},pointerActive:A,dimensions:{width:b,height:v}};for(let ye of o.nodes.values())if(ye.beforeRenderCallbacks.length>0)for(let Re of ye.beforeRenderCallbacks)try{Re(pe)}catch(bt){console.error(`Error executing before render callback for node ${ye.id}:`,bt)}},Wr=le=>{let pe={deltaTime:le,pointer:{x:S,y:_},pointerActive:A,dimensions:{width:b,height:v}};for(let ye of o.nodes.values())if(ye.afterRenderCallbacks.length>0)for(let Re of ye.afterRenderCallbacks)try{Re(pe)}catch(bt){console.error(`Error executing after render callback for node ${ye.id}:`,bt)}},qt=async()=>{if(!c||!r||!i||!s||!a)return;let le=performance.now(),pe=T>0?(le-T)/1e3:.016,ye=Math.min(pe,.1);T=le,et(ye);try{if(D)return;r instanceof KS?await r.renderAsync(i,s).then(()=>{c&&Wr(ye)}).catch(Re=>{console.error("WebGPU render error:",Re)}):(r.render(i,s),Wr(ye))}catch(Re){console.error("Render frame error:",Re)}},br=()=>{if(l||!g||!f)return;let le=()=>{l=requestAnimationFrame(le),qt().catch(console.warn)};le()},Pi=()=>{l&&(cancelAnimationFrame(l),l=null)},ns=le=>{if(!e){console.log(`[${t}] No canvas element in updatePointerCoords`);return}let pe,ye;if("touches"in le){if(le.touches.length===0)return;pe=le.touches[0].clientX,ye=le.touches[0].clientY}else pe=le.clientX,ye=le.clientY;let Re=e.getBoundingClientRect(),bt=(pe-Re.left)/Re.width,or=(ye-Re.top)/Re.height;S=bt,_=or},as=le=>{ns(le)},Fi=le=>{ns(le)},vp=()=>{A=!1,qt().catch(console.warn)},Tp=()=>{A=!1,qt().catch(console.warn)},wp=()=>{A=!0,qt().catch(console.warn)},Sp=()=>{A=!0,qt().catch(console.warn)};return{initialize:async({canvas:le})=>{if(c||d)return;d=!0,m=new AbortController;let pe=m;try{if(e=le,i=new xg,i.background=null,s=new bg(-1,1,1,-1,.1,10),s.position.z=1,s.lookAt(0,0,0),K||(window.addEventListener("mousemove",as),window.addEventListener("touchmove",Fi),window.addEventListener("mouseup",vp),window.addEventListener("touchend",Tp),le.addEventListener("mousedown",wp),le.addEventListener("touchstart",Sp),K=!0,console.log(`[${t}] Added event listeners`)),pe.signal.aborted)return;try{if(r=new KS({canvas:le,antialias:!0,alpha:!0,depth:!1,powerPreference:"high-performance"}),await r.init(),pe.signal.aborted){r&&typeof r.dispose=="function"&&r.dispose();return}}catch(or){if(pe.signal.aborted)return;console.error("[Shaders] WebGPU initialization error:",or);return}if(pe.signal.aborted){r&&typeof r.dispose=="function"&&r.dispose();return}r.setPixelRatio(Math.min(window.devicePixelRatio,2)),r.outputColorSpace=ws,a=new VR({transparent:!0}),a.fragmentNode=Ur(0,0,0,0);let ye=new T2(2,2);n=new Nn(ye,a),i.add(n),h=new ResizeObserver(fe),h.observe(le),u=new IntersectionObserver(ve,{threshold:0}),u.observe(le),g=!ae();let{width:Re,height:bt}=le.getBoundingClientRect();ge(Math.round(Re),Math.round(bt)),p=!0,await qt(),g&&f&&br(),pe.signal.aborted||(c=!0)}catch(ye){console.error("[Shaders] Initialization error:",ye)}finally{d=!1,m===pe&&(m=null)}},cleanup:()=>{if(console.log(`[${t}] Cleanup called`),m&&m.abort(),h&&(h.disconnect(),h=null),u&&(u.disconnect(),u=null),K&&(console.log(`[${t}] Removing event listeners`),e&&(e.removeEventListener("mousedown",wp),e.removeEventListener("touchstart",Sp)),window&&(window.removeEventListener("mousemove",as),window.removeEventListener("touchmove",Fi),window.removeEventListener("mouseup",vp),window.removeEventListener("touchend",Tp)),K=!1),Pi(),o.nodes.clear(),o.rootId=null,o.idToNodeId.clear(),J=[],re=!1,te=[],oe=!1,n&&(i&&i.remove(n),n.geometry&&typeof n.geometry.dispose=="function"&&n.geometry.dispose(),n.material instanceof bs&&typeof n.material.dispose=="function"&&n.material.dispose()),r&&typeof r.dispose=="function")try{r.dispose()}catch(le){console.warn("Error disposing renderer:",le)}e=null,r=null,s=null,i=null,n=null,a=null,c=!1,d=!1,p=!1,m=null,b=0,v=0,f=!1,g=!0,S=.5,_=.5,A=!1},registerNode:ht,removeNode:ar,updateUniformValue:Ft,updateNodeMetadata:ri,showLicenseWarning:()=>{!dQ()||sM||(console.warn("Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production."),sM=!0)}}}const{uniform:mQ}=_t;function Bt(t,e,r){let s={};return Object.entries(t.props).forEach(([i,n])=>{let a=e[i],o=a;n.transform&&(o=n.transform(a)),s[i]={uniform:mQ(o).label(`${i}_${r}`),transform:n.transform||void 0}}),s}const{vec2:Qme,fract:Kme,sin:efe,dot:tfe}=_t,{vec2:rfe}=_t;/**
|
|
429
|
+
var<${r}> ${t} : ${n};`}},t7=class{constructor(t){this.backend=t}getCurrentDepthStencilFormat(t){let e;return t.depthTexture===null?t.depth&&t.stencil?e=P.Depth24PlusStencil8:t.depth&&(e=P.Depth24Plus):e=this.getTextureFormatGPU(t.depthTexture),e}getTextureFormatGPU(t){return this.backend.get(t).format}getTextureSampleData(t){let e;if(t.isFramebufferTexture)e=1;else if(t.isDepthTexture&&!t.renderTarget){let i=this.backend.renderer,n=i.getRenderTarget();e=n?n.samples:i.samples}else t.renderTarget&&(e=t.renderTarget.samples);e||(e=1);let r=e>1&&t.renderTarget!==null&&t.isDepthTexture!==!0&&t.isFramebufferTexture!==!0;return{samples:e,primarySamples:r?1:e,isMSAA:r}}getCurrentColorFormat(t){let e;return e=t.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(t.textures[0]),e}getCurrentColorSpace(t){return t.textures===null?this.backend.renderer.outputColorSpace:t.textures[0].colorSpace}getPrimitiveTopology(t,e){if(t.isPoints)return Uu.PointList;if(t.isLineSegments||t.isMesh&&e.wireframe===!0)return Uu.LineList;if(t.isLine)return Uu.LineStrip;if(t.isMesh)return Uu.TriangleList}getSampleCount(t){let e=1;return t>1&&(e=2**Math.floor(Math.log2(t)),e===2&&(e=4)),e}getSampleCountRenderContext(t){return t.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(t.sampleCount)}getPreferredCanvasFormat(){let t=this.backend.parameters.outputType;if(t===void 0)return navigator.gpu.getPreferredCanvasFormat();if(t===ms)return P.BGRA8Unorm;if(t===Ss)return P.RGBA16Float;throw Error("Unsupported outputType")}};const r7=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),s7=new Map([[h2,["float16"]]]),i7=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);var n7=class{constructor(t){this.backend=t}createAttribute(t,e){let r=this._getBufferAttribute(t),s=this.backend,i=s.get(r),n=i.buffer;if(n===void 0){let a=s.device,o=r.array;if(t.normalized===!1){if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),e&GPUBufferUsage.INDEX))for(let u=0;u<o.length;u++)o[u]===65535&&(o[u]=4294967295)}if(r.array=o,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&r.itemSize===3){o=new o.constructor(r.count*4);for(let u=0;u<r.count;u++)o.set(r.array.subarray(u*3,u*3+3),u*4);r.itemSize=4,r.array=o,i._force3to4BytesAlignment=!0}let l=o.byteLength,h=l+(4-l%4)%4;n=a.createBuffer({label:r.name,size:h,usage:e,mappedAtCreation:!0}),new o.constructor(n.getMappedRange()).set(o),n.unmap(),i.buffer=n}}updateAttribute(t){let e=this._getBufferAttribute(t),r=this.backend,s=r.device,i=r.get(e),n=r.get(e).buffer,a=e.array;if(i._force3to4BytesAlignment===!0){a=new a.constructor(e.count*4);for(let h=0;h<e.count;h++)a.set(e.array.subarray(h*3,h*3+3),h*4);e.array=a}let o=this._isTypedArray(a),l=e.updateRanges;if(l.length===0)s.queue.writeBuffer(n,0,a,0);else{let h=o?1:a.BYTES_PER_ELEMENT;for(let u=0,c=l.length;u<c;u++){let d=l[u],p,m;if(i._force3to4BytesAlignment===!0){let g=Math.floor(d.start/3),b=Math.ceil(d.count/3);p=g*4*h,m=b*4*h}else p=d.start*h,m=d.count*h;let f=p*(o?a.BYTES_PER_ELEMENT:1);s.queue.writeBuffer(n,f,a,p,m)}e.clearUpdateRanges()}}createShaderVertexBuffers(t){let e=t.getAttributes(),r=new Map;for(let s=0;s<e.length;s++){let i=e[s],n=i.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(i),o=r.get(a);if(o===void 0){let u,c;i.isInterleavedBufferAttribute===!0?(u=i.data.stride*n,c=i.data.isInstancedInterleavedBuffer?um.Instance:um.Vertex):(u=i.itemSize*n,c=i.isInstancedBufferAttribute?um.Instance:um.Vertex),i.normalized===!1&&(i.array.constructor===Int16Array||i.array.constructor===Uint16Array)&&(u=4),o={arrayStride:u,attributes:[],stepMode:c},r.set(a,o)}let l=this._getVertexFormat(i),h=i.isInterleavedBufferAttribute===!0?i.offset*n:0;o.attributes.push({shaderLocation:s,offset:h,format:l})}return Array.from(r.values())}destroyAttribute(t){let e=this.backend;e.get(this._getBufferAttribute(t)).buffer.destroy(),e.delete(t)}async getArrayBufferAsync(t){let e=this.backend,r=e.device,s=e.get(this._getBufferAttribute(t)),i=s.buffer,n=i.size,a=r.createBuffer({label:`${t.name}_readback`,size:n,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),o=r.createCommandEncoder({label:`readback_encoder_${t.name}`});o.copyBufferToBuffer(i,0,a,0,n);let l=o.finish();r.queue.submit([l]),await a.mapAsync(GPUMapMode.READ);let h=a.getMappedRange(),u=new t.array.constructor(h.slice(0));return a.unmap(),u.buffer}_getVertexFormat(t){let{itemSize:e,normalized:r}=t,s=t.array.constructor,i=t.constructor,n;if(e===1)n=i7.get(s);else{let a=s7.get(i)||r7.get(s),o=a[r?1:0];if(o){let l=s.BYTES_PER_ELEMENT*e,h=Math.floor((l+3)/4)*4,u=h/s.BYTES_PER_ELEMENT;if(u%1)throw Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");n=`${o}x${u}`}}return n||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),n}_isTypedArray(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}_getBufferAttribute(t){return t.isInterleavedBufferAttribute&&(t=t.data),t}},a7=class{constructor(t){this.backend=t,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(t){let e=this.backend,r=e.device,s=[],i=0;for(let n of t.bindings){let a={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let o={};n.isStorageBuffer&&(n.visibility&4&&(n.access===Qr.READ_WRITE||n.access===Qr.WRITE_ONLY)?o.type=HS.Storage:o.type=HS.ReadOnlyStorage),a.buffer=o}else if(n.isSampler){let o={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?e.compatibilityMode&&(o.type=qS.NonFiltering):o.type=qS.Comparison),a.sampler=o}else if(n.isSampledTexture&&n.texture.isVideoTexture)a.externalTexture={};else if(n.isSampledTexture&&n.store){let o={};o.format=this.backend.get(n.texture).texture.format;let l=n.access;l===Qr.READ_WRITE?o.access=Sx.ReadWrite:l===Qr.WRITE_ONLY?o.access=Sx.WriteOnly:o.access=Sx.ReadOnly,a.storageTexture=o}else if(n.isSampledTexture){let o={},{primarySamples:l}=e.utils.getTextureSampleData(n.texture);if(l>1&&(o.multisampled=!0,n.texture.isDepthTexture||(o.sampleType=$o.UnfilterableFloat)),n.texture.isDepthTexture)e.compatibilityMode&&n.texture.compareFunction===null?o.sampleType=$o.UnfilterableFloat:o.sampleType=$o.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let h=n.texture.type;h===ds?o.sampleType=$o.SInt:h===Yt?o.sampleType=$o.UInt:h===Hs&&(this.backend.hasFeature("float32-filterable")?o.sampleType=$o.Float:o.sampleType=$o.UnfilterableFloat)}n.isSampledCubeTexture?o.viewDimension=Br.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?o.viewDimension=Br.TwoDArray:n.isSampledTexture3D&&(o.viewDimension=Br.ThreeD),a.texture=o}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);s.push(a)}return r.createBindGroupLayout({entries:s})}createBindings(t,e,r,s=0){let{backend:i,bindGroupLayoutCache:n}=this,a=i.get(t),o=n.get(t.bindingsReference);o===void 0&&(o=this.createBindingsLayout(t),n.set(t.bindingsReference,o));let l;r>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[r]===s&&(l=a.groups[r])),l===void 0&&(l=this.createBindGroup(t,o),r>0&&(a.groups[r]=l,a.versions[r]=s)),a.group=l,a.layout=o}updateBinding(t){let e=this.backend,r=e.device,s=t.buffer,i=e.get(t).buffer;r.queue.writeBuffer(i,0,s,0)}createBindGroupIndex(t,e){let r=this.backend,s=r.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,n=t[0],a=s.createBuffer({label:"bindingCameraIndex_"+n,size:16,usage:i});s.queue.writeBuffer(a,0,t,0);let o=[{binding:0,resource:{buffer:a}}];return s.createBindGroup({label:"bindGroupCameraIndex_"+n,layout:e,entries:o})}createBindGroup(t,e){let r=this.backend,s=r.device,i=0,n=[];for(let a of t.bindings){if(a.isUniformBuffer){let o=r.get(a);if(o.buffer===void 0){let l=a.byteLength,h=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,u=s.createBuffer({label:"bindingBuffer_"+a.name,size:l,usage:h});o.buffer=u}n.push({binding:i,resource:{buffer:o.buffer}})}else if(a.isStorageBuffer){let o=r.get(a);if(o.buffer===void 0){let l=a.attribute;o.buffer=r.get(l).buffer}n.push({binding:i,resource:{buffer:o.buffer}})}else if(a.isSampler){let o=r.get(a.texture);n.push({binding:i,resource:o.sampler})}else if(a.isSampledTexture){let o=r.get(a.texture),l;if(o.externalTexture!==void 0)l=s.importExternalTexture({source:o.externalTexture});else{let h=a.store?1:o.texture.mipLevelCount,u=`view-${o.texture.width}-${o.texture.height}-${h}`;if(l=o[u],l===void 0){let c=B$.All,d;d=a.isSampledCubeTexture?Br.Cube:a.isSampledTexture3D?Br.ThreeD:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?Br.TwoDArray:Br.TwoD,l=o[u]=o.texture.createView({aspect:c,dimension:d,mipLevelCount:h})}}n.push({binding:i,resource:l})}i++}return s.createBindGroup({label:"bindGroup_"+t.name,layout:e,entries:n})}},o7=class{constructor(t){this.backend=t,this._activePipelines=new WeakMap}setPipeline(t,e){this._activePipelines.get(t)!==e&&(t.setPipeline(e),this._activePipelines.set(t,e))}_getSampleCount(t){return this.backend.utils.getSampleCountRenderContext(t)}createRenderPipeline(t,e){let{object:r,material:s,geometry:i,pipeline:n}=t,{vertexProgram:a,fragmentProgram:o}=n,l=this.backend,h=l.device,u=l.utils,c=l.get(n),d=[];for(let re of t.getBindings()){let te=l.get(re);d.push(te.layout)}let p=l.attributeUtils.createShaderVertexBuffers(t),m;s.blending!==Ph&&(s.blending!==oa||s.transparent!==!1)&&(m=this._getBlending(s));let f={};s.stencilWrite===!0&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});let g=this._getColorWriteMask(s),b=[];if(t.context.textures!==null){let re=t.context.textures;for(let te=0;te<re.length;te++){let oe=u.getTextureFormatGPU(re[te]);b.push({format:oe,blend:m,writeMask:g})}}else{let re=u.getCurrentColorFormat(t.context);b.push({format:re,blend:m,writeMask:g})}let v=l.get(a).module,w=l.get(o).module,T=this._getPrimitiveState(r,i,s),N=this._getDepthCompare(s),S=u.getCurrentDepthStencilFormat(t.context),_=this._getSampleCount(t.context),A={label:`renderPipeline_${s.name||s.type}_${s.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},w,{targets:b}),primitive:T,multisample:{count:_,alphaToCoverageEnabled:s.alphaToCoverage&&_>1},layout:h.createPipelineLayout({bindGroupLayouts:d})},D={},K=t.context.depth,J=t.context.stencil;if((K===!0||J===!0)&&(K===!0&&(D.format=S,D.depthWriteEnabled=s.depthWrite,D.depthCompare=N),J===!0&&(D.stencilFront=f,D.stencilBack={},D.stencilReadMask=s.stencilFuncMask,D.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&(D.depthBias=s.polygonOffsetUnits,D.depthBiasSlopeScale=s.polygonOffsetFactor,D.depthBiasClamp=0),A.depthStencil=D),e===null)c.pipeline=h.createRenderPipeline(A);else{let re=new Promise(te=>{h.createRenderPipelineAsync(A).then(oe=>{c.pipeline=oe,te()})});e.push(re)}}createBundleEncoder(t,e="renderBundleEncoder"){let r=this.backend,{utils:s,device:i}=r,n=s.getCurrentDepthStencilFormat(t),a=s.getCurrentColorFormat(t),o=this._getSampleCount(t),l={label:e,colorFormats:[a],depthStencilFormat:n,sampleCount:o};return i.createRenderBundleEncoder(l)}createComputePipeline(t,e){let r=this.backend,s=r.device,i=r.get(t.computeProgram).module,n=r.get(t),a=[];for(let o of e){let l=r.get(o);a.push(l.layout)}n.pipeline=s.createComputePipeline({compute:i,layout:s.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(t){let e,r,s=t.blending,i=t.blendSrc,n=t.blendDst,a=t.blendEquation;if(s===Wc){let o=t.blendSrcAlpha===null?i:t.blendSrcAlpha,l=t.blendDstAlpha===null?n:t.blendDstAlpha,h=t.blendEquationAlpha===null?a:t.blendEquationAlpha;e={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(l),operation:this._getBlendOperation(h)}}else{let o=t.premultipliedAlpha,l=(h,u,c,d)=>{e={srcFactor:h,dstFactor:u,operation:Do.Add},r={srcFactor:c,dstFactor:d,operation:Do.Add}};if(o)switch(s){case oa:l(ze.One,ze.OneMinusSrcAlpha,ze.One,ze.OneMinusSrcAlpha);break;case Mf:l(ze.One,ze.One,ze.One,ze.One);break;case _f:l(ze.Zero,ze.OneMinusSrc,ze.Zero,ze.One);break;case Nf:l(ze.Zero,ze.Src,ze.Zero,ze.SrcAlpha);break}else switch(s){case oa:l(ze.SrcAlpha,ze.OneMinusSrcAlpha,ze.One,ze.OneMinusSrcAlpha);break;case Mf:l(ze.SrcAlpha,ze.One,ze.SrcAlpha,ze.One);break;case _f:l(ze.Zero,ze.OneMinusSrc,ze.Zero,ze.One);break;case Nf:l(ze.Zero,ze.Src,ze.Zero,ze.Src);break}}if(e!==void 0&&r!==void 0)return{color:e,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(t){let e;switch(t){case Ja:e=ze.Zero;break;case EN:e=ze.One;break;case PN:e=ze.Src;break;case FN:e=ze.OneMinusSrc;break;case Af:e=ze.SrcAlpha;break;case Cf:e=ze.OneMinusSrcAlpha;break;case zN:e=ze.Dst;break;case BN:e=ze.OneMinusDst;break;case LN:e=ze.DstAlpha;break;case IN:e=ze.OneMinusDstAlpha;break;case VN:e=ze.SrcAlphaSaturated;break;case oU:e=ze.Constant;break;case lU:e=ze.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",t)}return e}_getStencilCompare(t){let e,r=t.stencilFunc;switch(r){case Dz:e=kr.Never;break;case D0:e=kr.Always;break;case $z:e=kr.Less;break;case jz:e=kr.LessEqual;break;case Gz:e=kr.Equal;break;case qz:e=kr.GreaterEqual;break;case Wz:e=kr.Greater;break;case Hz:e=kr.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return e}_getStencilOperation(t){let e;switch(t){case Zo:e=Ua.Keep;break;case Iz:e=Ua.Zero;break;case zz:e=Ua.Replace;break;case Uz:e=Ua.Invert;break;case Bz:e=Ua.IncrementClamp;break;case Vz:e=Ua.DecrementClamp;break;case Oz:e=Ua.IncrementWrap;break;case kz:e=Ua.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",e)}return e}_getBlendOperation(t){let e;switch(t){case Hi:e=Do.Add;break;case CN:e=Do.Subtract;break;case RN:e=Do.ReverseSubtract;break;case yz:e=Do.Min;break;case xz:e=Do.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",t)}return e}_getPrimitiveState(t,e,r){let s={},i=this.backend.utils;switch(s.topology=i.getPrimitiveTopology(t,r),e.index!==null&&t.isLine===!0&&t.isLineSegments!==!0&&(s.stripIndexFormat=e.index.array instanceof Uint16Array?Oh.Uint16:Oh.Uint32),r.side){case aa:s.frontFace=vx.CCW,s.cullMode=Tx.Back;break;case gs:s.frontFace=vx.CCW,s.cullMode=Tx.Front;break;case Hu:s.frontFace=vx.CCW,s.cullMode=Tx.None;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side);break}return s}_getColorWriteMask(t){return t.colorWrite===!0?WS.All:WS.None}_getDepthCompare(t){let e;if(t.depthTest===!1)e=kr.Always;else{let r=t.depthFunc;switch(r){case ON:e=kr.Never;break;case kN:e=kr.Always;break;case UN:e=kr.Less;break;case Rf:e=kr.LessEqual;break;case DN:e=kr.Equal;break;case $N:e=kr.GreaterEqual;break;case GN:e=kr.Greater;break;case jN:e=kr.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return e}},l7=class extends g3{constructor(t,e,r=2048){super(r),this.device=t,this.type=e,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${e}`});let s=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${e}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${e}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(t){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ba(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let e=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(t.id,e),e}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;let t=new Map(this.queryOffsets),e=this.currentQueryIndex,r=e*8;this.currentQueryIndex=0,this.queryOffsets.clear();let s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,e,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);let i=s.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;let n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a=0;for(let[,o]of t){let l=n[o],h=n[o+1],u=Number(h-l)/1e6;a+=u}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(t){return console.error("Error resolving queries:",t),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(t){console.error("Error waiting for pending resolve:",t)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(t){console.error("Error unmapping buffer:",t)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}},u7=class extends f3{constructor(t={}){super(t),this.isWebGPUBackend=!0,this.parameters.alpha=t.alpha===void 0?!0:t.alpha,this.parameters.compatibilityMode=t.compatibilityMode===void 0?!1:t.compatibilityMode,this.parameters.requiredLimits=t.requiredLimits===void 0?{}:t.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new t7(this),this.attributeUtils=new n7(this),this.bindingUtils=new a7(this),this.pipelineUtils=new o7(this),this.textureUtils=new W$(this),this.occludedResolveCache=new Map}async init(t){await super.init(t);let e=this.parameters,r;if(e.device===void 0){let n={powerPreference:e.powerPreference,featureLevel:e.compatibilityMode?"compatibility":void 0},a=typeof navigator<"u"?await navigator.gpu.requestAdapter(n):null;if(a===null)throw Error("WebGPUBackend: Unable to create WebGPU adapter.");let o=Object.values(cb),l=[];for(let u of o)a.features.has(u)&&l.push(u);let h={requiredFeatures:l,requiredLimits:e.requiredLimits};r=await a.requestDevice(h)}else r=e.device;r.lost.then(n=>{let a={api:"WebGPU",message:n.message||"Unknown reason",reason:n.reason||null,originalEvent:n};t.onDeviceLost(a)});let s=e.context===void 0?t.domElement.getContext("webgpu"):e.context;this.device=r,this.context=s;let i=e.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(cb.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:i}),this.updateSize()}get coordinateSystem(){return Mn}async getArrayBufferAsync(t){return await this.attributeUtils.getArrayBufferAsync(t)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let t=this.defaultRenderPassdescriptor;if(t===null){let r=this.renderer;t={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(t.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(r.depth,r.stencil).createView()});let s=t.colorAttachments[0];this.renderer.samples>0?s.view=this.colorBuffer.createView():s.resolveTarget=void 0,this.defaultRenderPassdescriptor=t}let e=t.colorAttachments[0];return this.renderer.samples>0?e.resolveTarget=this.context.getCurrentTexture().createView():e.view=this.context.getCurrentTexture().createView(),t}_isRenderCameraDepthArray(t){return t.depthTexture&&t.depthTexture.image.depth>1&&t.camera.isArrayCamera}_getRenderPassDescriptor(t,e={}){let r=t.renderTarget,s=this.get(r),i=s.descriptors;if(i===void 0||s.width!==r.width||s.height!==r.height||s.dimensions!==r.dimensions||s.activeMipmapLevel!==t.activeMipmapLevel||s.activeCubeFace!==t.activeCubeFace||s.samples!==r.samples){i={},s.descriptors=i;let l=()=>{r.removeEventListener("dispose",l),this.delete(r)};r.hasEventListener("dispose",l)===!1&&r.addEventListener("dispose",l)}let n=t.getCacheKey(),a=i[n];if(a===void 0){let l=t.textures,h=[],u,c=this._isRenderCameraDepthArray(t);for(let d=0;d<l.length;d++){let p=this.get(l[d]),m={label:`colorAttachment_${d}`,baseMipLevel:t.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:t.activeCubeFace,arrayLayerCount:1,dimension:Br.TwoD};if(r.isRenderTarget3D)u=t.activeCubeFace,m.baseArrayLayer=0,m.dimension=Br.ThreeD,m.depthOrArrayLayers=l[d].image.depth;else if(r.isRenderTarget&&l[d].image.depth>1)if(c===!0){let f=t.camera.cameras;for(let g=0;g<f.length;g++){let b={...m,baseArrayLayer:g,arrayLayerCount:1,dimension:Br.TwoD},v=p.texture.createView(b);h.push({view:v,resolveTarget:void 0,depthSlice:void 0})}}else m.dimension=Br.TwoDArray,m.depthOrArrayLayers=l[d].image.depth;if(c!==!0){let f=p.texture.createView(m),g,b;p.msaaTexture===void 0?(g=f,b=void 0):(g=p.msaaTexture.createView(),b=f),h.push({view:g,resolveTarget:b,depthSlice:u})}}if(a={textureViews:h},t.depth){let d=this.get(t.depthTexture),p={};t.depthTexture.isArrayTexture&&(p.dimension=Br.TwoD,p.arrayLayerCount=1,p.baseArrayLayer=t.activeCubeFace),a.depthStencilView=d.texture.createView(p)}i[n]=a,s.width=r.width,s.height=r.height,s.samples=r.samples,s.activeMipmapLevel=t.activeMipmapLevel,s.activeCubeFace=t.activeCubeFace,s.dimensions=r.dimensions}let o={colorAttachments:[]};for(let l=0;l<a.textureViews.length;l++){let h=a.textureViews[l],u={r:0,g:0,b:0,a:1};l===0&&e.clearValue&&(u=e.clearValue),o.colorAttachments.push({view:h.view,depthSlice:h.depthSlice,resolveTarget:h.resolveTarget,loadOp:e.loadOp||tt.Load,storeOp:e.storeOp||cs.Store,clearValue:u})}return a.depthStencilView&&(o.depthStencilAttachment={view:a.depthStencilView}),o}beginRender(t){let e=this.get(t),r=this.device,s=t.occlusionQueryCount,i;s>0&&(e.currentOcclusionQuerySet&&e.currentOcclusionQuerySet.destroy(),e.currentOcclusionQueryBuffer&&e.currentOcclusionQueryBuffer.destroy(),e.currentOcclusionQuerySet=e.occlusionQuerySet,e.currentOcclusionQueryBuffer=e.occlusionQueryBuffer,e.currentOcclusionQueryObjects=e.occlusionQueryObjects,i=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${t.id}`}),e.occlusionQuerySet=i,e.occlusionQueryIndex=0,e.occlusionQueryObjects=Array(s),e.lastOcclusionObject=null);let n;n=t.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(t,{loadOp:tt.Load}),this.initTimestampQuery(t,n),n.occlusionQuerySet=i;let a=n.depthStencilAttachment;if(t.textures!==null){let l=n.colorAttachments;for(let h=0;h<l.length;h++){let u=l[h];t.clearColor?(u.clearValue=h===0?t.clearColorValue:{r:0,g:0,b:0,a:1},u.loadOp=tt.Clear):u.loadOp=tt.Load,u.storeOp=cs.Store}}else{let l=n.colorAttachments[0];t.clearColor?(l.clearValue=t.clearColorValue,l.loadOp=tt.Clear):l.loadOp=tt.Load,l.storeOp=cs.Store}t.depth&&(t.clearDepth?(a.depthClearValue=t.clearDepthValue,a.depthLoadOp=tt.Clear):a.depthLoadOp=tt.Load,a.depthStoreOp=cs.Store),t.stencil&&(t.clearStencil?(a.stencilClearValue=t.clearStencilValue,a.stencilLoadOp=tt.Clear):a.stencilLoadOp=tt.Load,a.stencilStoreOp=cs.Store);let o=r.createCommandEncoder({label:"renderContext_"+t.id});if(this._isRenderCameraDepthArray(t)===!0){let l=t.camera.cameras;!e.layerDescriptors||e.layerDescriptors.length!==l.length?this._createDepthLayerDescriptors(t,e,n,l):this._updateDepthLayerDescriptors(t,e,l),e.bundleEncoders=[],e.bundleSets=[];for(let h=0;h<l.length;h++){let u=this.pipelineUtils.createBundleEncoder(t,"renderBundleArrayCamera_"+h),c={attributes:{},bindingGroups:[],pipeline:null,index:null};e.bundleEncoders.push(u),e.bundleSets.push(c)}e.currentPass=null}else{let l=o.beginRenderPass(n);if(e.currentPass=l,t.viewport&&this.updateViewport(t),t.scissor){let{x:h,y:u,width:c,height:d}=t.scissorValue;l.setScissorRect(h,u,c,d)}}e.descriptor=n,e.encoder=o,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.renderBundles=[]}_createDepthLayerDescriptors(t,e,r,s){let i=r.depthStencilAttachment;e.layerDescriptors=[];let n=this.get(t.depthTexture);n.viewCache||(n.viewCache=[]);for(let a=0;a<s.length;a++){let o={...r,colorAttachments:[{...r.colorAttachments[0],view:r.colorAttachments[a].view}]};if(r.depthStencilAttachment){let l=a;n.viewCache[l]||(n.viewCache[l]=n.texture.createView({dimension:Br.TwoD,baseArrayLayer:a,arrayLayerCount:1})),o.depthStencilAttachment={view:n.viewCache[l],depthLoadOp:i.depthLoadOp||tt.Clear,depthStoreOp:i.depthStoreOp||cs.Store,depthClearValue:i.depthClearValue||1},t.stencil&&(o.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,o.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,o.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else o.depthStencilAttachment={...i};e.layerDescriptors.push(o)}}_updateDepthLayerDescriptors(t,e,r){for(let s=0;s<r.length;s++){let i=e.layerDescriptors[s];if(i.depthStencilAttachment){let n=i.depthStencilAttachment;t.depth&&(t.clearDepth?(n.depthClearValue=t.clearDepthValue,n.depthLoadOp=tt.Clear):n.depthLoadOp=tt.Load),t.stencil&&(t.clearStencil?(n.stencilClearValue=t.clearStencilValue,n.stencilLoadOp=tt.Clear):n.stencilLoadOp=tt.Load)}}}finishRender(t){let e=this.get(t),r=t.occlusionQueryCount;e.renderBundles.length>0&&e.currentPass.executeBundles(e.renderBundles),r>e.occlusionQueryIndex&&e.currentPass.endOcclusionQuery();let s=e.encoder;if(this._isRenderCameraDepthArray(t)===!0){let i=[];for(let n=0;n<e.bundleEncoders.length;n++){let a=e.bundleEncoders[n];i.push(a.finish())}for(let n=0;n<e.layerDescriptors.length;n++)if(n<i.length){let a=e.layerDescriptors[n],o=s.beginRenderPass(a);if(t.viewport){let{x:l,y:h,width:u,height:c,minDepth:d,maxDepth:p}=t.viewportValue;o.setViewport(l,h,u,c,d,p)}if(t.scissor){let{x:l,y:h,width:u,height:c}=t.scissorValue;o.setScissorRect(l,h,u,c)}o.executeBundles([i[n]]),o.end()}}else e.currentPass&&e.currentPass.end();if(r>0){let i=r*8,n=this.occludedResolveCache.get(i);n===void 0&&(n=this.device.createBuffer({size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(i,n));let a=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});e.encoder.resolveQuerySet(e.occlusionQuerySet,0,r,n,0),e.encoder.copyBufferToBuffer(n,0,a,0,i),e.occlusionQueryBuffer=a,this.resolveOccludedAsync(t)}if(this.device.queue.submit([e.encoder.finish()]),t.textures!==null){let i=t.textures;for(let n=0;n<i.length;n++){let a=i[n];a.generateMipmaps===!0&&this.textureUtils.generateMipmaps(a)}}}isOccluded(t,e){let r=this.get(t);return r.occluded&&r.occluded.has(e)}async resolveOccludedAsync(t){let e=this.get(t),{currentOcclusionQueryBuffer:r,currentOcclusionQueryObjects:s}=e;if(r&&s){let i=new WeakSet;e.currentOcclusionQueryObjects=null,e.currentOcclusionQueryBuffer=null,await r.mapAsync(GPUMapMode.READ);let n=r.getMappedRange(),a=new BigUint64Array(n);for(let o=0;o<s.length;o++)a[o]===BigInt(0)&&i.add(s[o]);r.destroy(),e.occluded=i}}updateViewport(t){let{currentPass:e}=this.get(t),{x:r,y:s,width:i,height:n,minDepth:a,maxDepth:o}=t.viewportValue;e.setViewport(r,s,i,n,a,o)}getClearColor(){let t=super.getClearColor();return this.renderer.alpha===!0&&(t.r*=t.a,t.g*=t.a,t.b*=t.a),t}clear(t,e,r,s=null){let i=this.device,n=this.renderer,a=[],o,l,h,u;if(t){let p=this.getClearColor();l={r:p.r,g:p.g,b:p.b,a:p.a}}if(s===null){h=n.depth,u=n.stencil;let p=this._getDefaultRenderPassDescriptor();if(t){a=p.colorAttachments;let m=a[0];m.clearValue=l,m.loadOp=tt.Clear,m.storeOp=cs.Store}(h||u)&&(o=p.depthStencilAttachment)}else{h=s.depth,u=s.stencil;let p={loadOp:t?tt.Clear:tt.Load,clearValue:t?l:void 0};h&&(p.depthLoadOp=e?tt.Clear:tt.Load,p.depthClearValue=e?n.getClearDepth():void 0,p.depthStoreOp=cs.Store),u&&(p.stencilLoadOp=r?tt.Clear:tt.Load,p.stencilClearValue=r?n.getClearStencil():void 0,p.stencilStoreOp=cs.Store);let m=this._getRenderPassDescriptor(s,p);a=m.colorAttachments,o=m.depthStencilAttachment}h&&o&&o.depthLoadOp===void 0&&(e?(o.depthLoadOp=tt.Clear,o.depthClearValue=n.getClearDepth(),o.depthStoreOp=cs.Store):(o.depthLoadOp=tt.Load,o.depthStoreOp=cs.Store)),u&&o&&o.stencilLoadOp===void 0&&(r?(o.stencilLoadOp=tt.Clear,o.stencilClearValue=n.getClearStencil(),o.stencilStoreOp=cs.Store):(o.stencilLoadOp=tt.Load,o.stencilStoreOp=cs.Store));let c=i.createCommandEncoder({label:"clear"});c.beginRenderPass({colorAttachments:a,depthStencilAttachment:o}).end(),i.queue.submit([c.finish()])}beginCompute(t){let e=this.get(t),r={label:"computeGroup_"+t.id};this.initTimestampQuery(t,r),e.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+t.id}),e.passEncoderGPU=e.cmdEncoderGPU.beginComputePass(r)}compute(t,e,r,s){let{passEncoderGPU:i}=this.get(t),n=this.get(s).pipeline;this.pipelineUtils.setPipeline(i,n);for(let h=0,u=r.length;h<u;h++){let c=r[h],d=this.get(c);i.setBindGroup(h,d.group)}let a=this.device.limits.maxComputeWorkgroupsPerDimension,o=this.get(e);o.dispatchSize===void 0&&(o.dispatchSize={x:0,y:1,z:1});let{dispatchSize:l}=o;e.dispatchCount>a?(l.x=Math.min(e.dispatchCount,a),l.y=Math.ceil(e.dispatchCount/a)):l.x=e.dispatchCount,i.dispatchWorkgroups(l.x,l.y,l.z)}finishCompute(t){let e=this.get(t);e.passEncoderGPU.end(),this.device.queue.submit([e.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(t,e){let{object:r,material:s,context:i,pipeline:n}=t,a=t.getBindings(),o=this.get(i),l=this.get(n).pipeline,h=t.getIndex(),u=h!==null,c=t.getDrawParameters();if(c===null)return;let d=(m,f)=>{this.pipelineUtils.setPipeline(m,l),f.pipeline=l;let g=f.bindingGroups;for(let v=0,w=a.length;v<w;v++){let T=a[v],N=this.get(T);g[T.index]!==T.id&&(m.setBindGroup(T.index,N.group),g[T.index]=T.id)}if(u===!0&&f.index!==h){let v=this.get(h).buffer,w=h.array instanceof Uint16Array?Oh.Uint16:Oh.Uint32;m.setIndexBuffer(v,w),f.index=h}let b=t.getVertexBuffers();for(let v=0,w=b.length;v<w;v++){let T=b[v];if(f.attributes[v]!==T){let N=this.get(T).buffer;m.setVertexBuffer(v,N),f.attributes[v]=T}}i.stencil===!0&&s.stencilWrite===!0&&o.currentStencilRef!==s.stencilRef&&(m.setStencilReference(s.stencilRef),o.currentStencilRef=s.stencilRef)},p=(m,f)=>{if(d(m,f),r.isBatchedMesh===!0){let g=r._multiDrawStarts,b=r._multiDrawCounts,v=r._multiDrawCount,w=r._multiDrawInstances;w!==null&&ba("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let T=0;T<v;T++){let N=w?w[T]:1,S=N>1?0:T;u===!0?m.drawIndexed(b[T],N,g[T]/h.array.BYTES_PER_ELEMENT,0,S):m.draw(b[T],N,g[T],S),e.update(r,b[T],N)}}else if(u===!0){let{vertexCount:g,instanceCount:b,firstVertex:v}=c,w=t.getIndirect();if(w!==null){let T=this.get(w).buffer;m.drawIndexedIndirect(T,0)}else m.drawIndexed(g,b,v,0,0);e.update(r,g,b)}else{let{vertexCount:g,instanceCount:b,firstVertex:v}=c,w=t.getIndirect();if(w!==null){let T=this.get(w).buffer;m.drawIndirect(T,0)}else m.draw(g,b,v,0);e.update(r,g,b)}};if(t.camera.isArrayCamera&&t.camera.cameras.length>0){let m=this.get(t.camera),f=t.camera.cameras,g=t.getBindingGroup("cameraIndex");if(m.indexesGPU===void 0||m.indexesGPU.length!==f.length){let v=this.get(g),w=[],T=new Uint32Array([0,0,0,0]);for(let N=0,S=f.length;N<S;N++){T[0]=N;let _=this.bindingUtils.createBindGroupIndex(T,v.layout);w.push(_)}m.indexesGPU=w}let b=this.renderer.getPixelRatio();for(let v=0,w=f.length;v<w;v++){let T=f[v];if(r.layers.test(T.layers)){let N=T.viewport,S=o.currentPass,_=o.currentSets;if(o.bundleEncoders){let A=o.bundleEncoders[v],D=o.bundleSets[v];S=A,_=D}N&&S.setViewport(Math.floor(N.x*b),Math.floor(N.y*b),Math.floor(N.width*b),Math.floor(N.height*b),i.viewportValue.minDepth,i.viewportValue.maxDepth),g&&m.indexesGPU&&(S.setBindGroup(g.index,m.indexesGPU[v]),_.bindingGroups[g.index]=g.id),p(S,_)}}}else if(o.currentPass){if(o.occlusionQuerySet!==void 0){let m=o.lastOcclusionObject;m!==r&&(m!==null&&m.occlusionTest===!0&&(o.currentPass.endOcclusionQuery(),o.occlusionQueryIndex++),r.occlusionTest===!0&&(o.currentPass.beginOcclusionQuery(o.occlusionQueryIndex),o.occlusionQueryObjects[o.occlusionQueryIndex]=r),o.lastOcclusionObject=r)}p(o.currentPass,o.currentSets)}}needsRenderUpdate(t){let e=this.get(t),{object:r,material:s}=t,i=this.utils,n=i.getSampleCountRenderContext(t.context),a=i.getCurrentColorSpace(t.context),o=i.getCurrentColorFormat(t.context),l=i.getCurrentDepthStencilFormat(t.context),h=i.getPrimitiveTopology(r,s),u=!1;return(e.material!==s||e.materialVersion!==s.version||e.transparent!==s.transparent||e.blending!==s.blending||e.premultipliedAlpha!==s.premultipliedAlpha||e.blendSrc!==s.blendSrc||e.blendDst!==s.blendDst||e.blendEquation!==s.blendEquation||e.blendSrcAlpha!==s.blendSrcAlpha||e.blendDstAlpha!==s.blendDstAlpha||e.blendEquationAlpha!==s.blendEquationAlpha||e.colorWrite!==s.colorWrite||e.depthWrite!==s.depthWrite||e.depthTest!==s.depthTest||e.depthFunc!==s.depthFunc||e.stencilWrite!==s.stencilWrite||e.stencilFunc!==s.stencilFunc||e.stencilFail!==s.stencilFail||e.stencilZFail!==s.stencilZFail||e.stencilZPass!==s.stencilZPass||e.stencilFuncMask!==s.stencilFuncMask||e.stencilWriteMask!==s.stencilWriteMask||e.side!==s.side||e.alphaToCoverage!==s.alphaToCoverage||e.sampleCount!==n||e.colorSpace!==a||e.colorFormat!==o||e.depthStencilFormat!==l||e.primitiveTopology!==h||e.clippingContextCacheKey!==t.clippingContextCacheKey)&&(e.material=s,e.materialVersion=s.version,e.transparent=s.transparent,e.blending=s.blending,e.premultipliedAlpha=s.premultipliedAlpha,e.blendSrc=s.blendSrc,e.blendDst=s.blendDst,e.blendEquation=s.blendEquation,e.blendSrcAlpha=s.blendSrcAlpha,e.blendDstAlpha=s.blendDstAlpha,e.blendEquationAlpha=s.blendEquationAlpha,e.colorWrite=s.colorWrite,e.depthWrite=s.depthWrite,e.depthTest=s.depthTest,e.depthFunc=s.depthFunc,e.stencilWrite=s.stencilWrite,e.stencilFunc=s.stencilFunc,e.stencilFail=s.stencilFail,e.stencilZFail=s.stencilZFail,e.stencilZPass=s.stencilZPass,e.stencilFuncMask=s.stencilFuncMask,e.stencilWriteMask=s.stencilWriteMask,e.side=s.side,e.alphaToCoverage=s.alphaToCoverage,e.sampleCount=n,e.colorSpace=a,e.colorFormat=o,e.depthStencilFormat=l,e.primitiveTopology=h,e.clippingContextCacheKey=t.clippingContextCacheKey,u=!0),u}getRenderCacheKey(t){let{object:e,material:r}=t,s=this.utils,i=t.context;return[r.transparent,r.blending,r.premultipliedAlpha,r.blendSrc,r.blendDst,r.blendEquation,r.blendSrcAlpha,r.blendDstAlpha,r.blendEquationAlpha,r.colorWrite,r.depthWrite,r.depthTest,r.depthFunc,r.stencilWrite,r.stencilFunc,r.stencilFail,r.stencilZFail,r.stencilZPass,r.stencilFuncMask,r.stencilWriteMask,r.side,s.getSampleCountRenderContext(i),s.getCurrentColorSpace(i),s.getCurrentColorFormat(i),s.getCurrentDepthStencilFormat(i),s.getPrimitiveTopology(e,r),t.getGeometryCacheKey(),t.clippingContextCacheKey].join()}createSampler(t){this.textureUtils.createSampler(t)}destroySampler(t){this.textureUtils.destroySampler(t)}createDefaultTexture(t){this.textureUtils.createDefaultTexture(t)}createTexture(t,e){this.textureUtils.createTexture(t,e)}updateTexture(t,e){this.textureUtils.updateTexture(t,e)}generateMipmaps(t){this.textureUtils.generateMipmaps(t)}destroyTexture(t){this.textureUtils.destroyTexture(t)}async copyTextureToBuffer(t,e,r,s,i,n){return this.textureUtils.copyTextureToBuffer(t,e,r,s,i,n)}initTimestampQuery(t,e){if(!this.trackTimestamp)return;let r=t.isComputeNode?"compute":"render";this.timestampQueryPool[r]||(this.timestampQueryPool[r]=new l7(this.device,r,2048));let s=this.timestampQueryPool[r],i=s.allocateQueriesForContext(t);e.timestampWrites={querySet:s.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(t,e){return new e7(t,e)}createProgram(t){let e=this.get(t);e.module={module:this.device.createShaderModule({code:t.code,label:t.stage+(t.name===""?"":`_${t.name}`)}),entryPoint:"main"}}destroyProgram(t){this.delete(t)}createRenderPipeline(t,e){this.pipelineUtils.createRenderPipeline(t,e)}createComputePipeline(t,e){this.pipelineUtils.createComputePipeline(t,e)}beginBundle(t){let e=this.get(t);e._currentPass=e.currentPass,e._currentSets=e.currentSets,e.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.currentPass=this.pipelineUtils.createBundleEncoder(t)}finishBundle(t,e){let r=this.get(t),s=r.currentPass,i=s.finish();this.get(e).bundleGPU=i,r.currentSets=r._currentSets,r.currentPass=r._currentPass}addBundle(t,e){this.get(t).renderBundles.push(this.get(e).bundleGPU)}createBindings(t,e,r,s){this.bindingUtils.createBindings(t,e,r,s)}updateBindings(t,e,r,s){this.bindingUtils.createBindings(t,e,r,s)}updateBinding(t){this.bindingUtils.updateBinding(t)}createIndexAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(t){this.attributeUtils.createAttribute(t,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(t){this.attributeUtils.updateAttribute(t)}destroyAttribute(t){this.attributeUtils.destroyAttribute(t)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(t){return this.device.features.has(t)}copyTextureToTexture(t,e,r=null,s=null,i=0,n=0){let a=0,o=0,l=0,h=0,u=0,c=0,d=t.image.width,p=t.image.height,m=1;r!==null&&(r.isBox3===!0?(h=r.min.x,u=r.min.y,c=r.min.z,d=r.max.x-r.min.x,p=r.max.y-r.min.y,m=r.max.z-r.min.z):(h=r.min.x,u=r.min.y,d=r.max.x-r.min.x,p=r.max.y-r.min.y,m=1)),s!==null&&(a=s.x,o=s.y,l=s.z||0);let f=this.device.createCommandEncoder({label:"copyTextureToTexture_"+t.id+"_"+e.id}),g=this.get(t).texture,b=this.get(e).texture;f.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:h,y:u,z:c}},{texture:b,mipLevel:n,origin:{x:a,y:o,z:l}},[d,p,m]),this.device.queue.submit([f.finish()]),n===0&&e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}copyFramebufferToTexture(t,e,r){let s=this.get(e),i=null;i=e.renderTarget?t.isDepthTexture?this.get(e.depthTexture).texture:this.get(e.textures[0]).texture:t.isDepthTexture?this.textureUtils.getDepthBuffer(e.depth,e.stencil):this.context.getCurrentTexture();let n=this.get(t).texture;if(i.format!==n.format){console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",i.format,n.format);return}let a;if(s.currentPass?(s.currentPass.end(),a=s.encoder):a=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+t.id}),a.copyTextureToTexture({texture:i,origin:[r.x,r.y,0]},{texture:n},[r.z,r.w]),s.currentPass){let{descriptor:o}=s;for(let l=0;l<o.colorAttachments.length;l++)o.colorAttachments[l].loadOp=tt.Load;if(e.depth&&(o.depthStencilAttachment.depthLoadOp=tt.Load),e.stencil&&(o.depthStencilAttachment.stencilLoadOp=tt.Load),s.currentPass=a.beginRenderPass(o),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},e.viewport&&this.updateViewport(e),e.scissor){let{x:l,y:h,width:u,height:c}=e.scissorValue;s.currentPass.setScissorRect(l,h,u,c)}}else this.device.queue.submit([a.finish()]);t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}},h7=class extends f1{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n),this.iesMap=null}copy(t,e){return super.copy(t,e),this.iesMap=t.iesMap,this}},c7=class extends f1{constructor(t,e,r,s,i,n){super(t,e,r,s,i,n),this.aspect=null}copy(t,e){return super.copy(t,e),this.aspect=t.aspect,this}},d7=class extends l3{constructor(){super(),this.addMaterial(rk,"MeshPhongMaterial"),this.addMaterial(QR,"MeshStandardMaterial"),this.addMaterial(Dk,"MeshPhysicalMaterial"),this.addMaterial(Wk,"MeshToonMaterial"),this.addMaterial(VR,"MeshBasicMaterial"),this.addMaterial(ek,"MeshLambertMaterial"),this.addMaterial(j4,"MeshNormalMaterial"),this.addMaterial(Xk,"MeshMatcapMaterial"),this.addMaterial(V4,"LineBasicMaterial"),this.addMaterial(k4,"LineDashedMaterial"),this.addMaterial(Qk,"PointsMaterial"),this.addMaterial(eE,"SpriteMaterial"),this.addMaterial(tU,"ShadowMaterial"),this.addLight(t8,iV),this.addLight($9,aV),this.addLight(G9,lV),this.addLight(Ev,f1),this.addLight(q9,oV),this.addLight(X9,tV),this.addLight(Y9,hV),this.addLight(j9,h7),this.addLight(H9,c7),this.addToneMapping(SE,Tz),this.addToneMapping(ME,wz),this.addToneMapping(_E,Sz),this.addToneMapping(NE,Mz),this.addToneMapping(AE,_z),this.addToneMapping(CE,Nz)}},KS=class extends m${constructor(t={}){let e;t.forceWebGL?e=jS:(e=u7,t.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new jS(t)));let r=new e(t);super(r,t),this.library=new d7,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}},_t={};cz(_t,{BRDF_GGX:()=>p7,BRDF_Lambert:()=>m7,BasicShadowFilter:()=>f7,Break:()=>g7,Const:()=>wj,Continue:()=>y7,DFGApprox:()=>x7,D_GGX:()=>b7,Discard:()=>v7,EPSILON:()=>T7,F_Schlick:()=>w7,Fn:()=>S7,INFINITY:()=>M7,If:()=>_7,Loop:()=>A7,NodeAccess:()=>P7,NodeShaderStage:()=>C7,NodeType:()=>R7,NodeUpdateType:()=>E7,PCFShadowFilter:()=>F7,PCFSoftShadowFilter:()=>L7,PI:()=>I7,PI2:()=>z7,Return:()=>B7,Schlick_to_F0:()=>V7,ScriptableNodeResources:()=>O7,ShaderNode:()=>k7,Switch:()=>N7,TBNViewMatrix:()=>U7,VSMShadowFilter:()=>D7,V_GGX_SmithCorrelated:()=>$7,Var:()=>CJ,abs:()=>G7,acesFilmicToneMapping:()=>j7,acos:()=>W7,add:()=>pb,addNodeElement:()=>H7,agxToneMapping:()=>q7,all:()=>X7,alphaT:()=>Y7,and:()=>Z7,anisotropy:()=>J7,anisotropyB:()=>Q7,anisotropyT:()=>K7,any:()=>eG,append:()=>tG,array:()=>rG,arrayBuffer:()=>sG,asin:()=>iG,assign:()=>nG,atan:()=>aG,atan2:()=>oG,atomicAdd:()=>lG,atomicAnd:()=>uG,atomicFunc:()=>hG,atomicLoad:()=>yG,atomicMax:()=>cG,atomicMin:()=>dG,atomicOr:()=>pG,atomicStore:()=>mG,atomicSub:()=>fG,atomicXor:()=>gG,attenuationColor:()=>xG,attenuationDistance:()=>bG,attribute:()=>vG,attributeArray:()=>TG,backgroundBlurriness:()=>wG,backgroundIntensity:()=>SG,backgroundRotation:()=>MG,batch:()=>_G,billboarding:()=>NG,bitAnd:()=>AG,bitNot:()=>CG,bitOr:()=>RG,bitXor:()=>EG,bitangentGeometry:()=>PG,bitangentLocal:()=>FG,bitangentView:()=>LG,bitangentWorld:()=>IG,bitcast:()=>zG,blendBurn:()=>BG,blendColor:()=>VG,blendDodge:()=>OG,blendOverlay:()=>kG,blendScreen:()=>UG,blur:()=>DG,bool:()=>$G,buffer:()=>GG,bufferAttribute:()=>jG,bumpMap:()=>WG,burn:()=>HG,bvec2:()=>qG,bvec3:()=>XG,bvec4:()=>YG,bypass:()=>ZG,cache:()=>JG,call:()=>QG,cameraFar:()=>KG,cameraIndex:()=>ej,cameraNear:()=>tj,cameraNormalMatrix:()=>rj,cameraPosition:()=>sj,cameraProjectionMatrix:()=>ij,cameraProjectionMatrixInverse:()=>nj,cameraViewMatrix:()=>aj,cameraWorldMatrix:()=>oj,cbrt:()=>lj,cdl:()=>uj,ceil:()=>hj,checker:()=>cj,cineonToneMapping:()=>dj,clamp:()=>x3,clearcoat:()=>pj,clearcoatRoughness:()=>mj,code:()=>fj,color:()=>gj,colorSpaceToWorking:()=>yj,colorToDirection:()=>xj,compute:()=>bj,computeSkinning:()=>vj,cond:()=>Tj,context:()=>Sj,convert:()=>Mj,convertColorSpace:()=>_j,convertToTexture:()=>Nj,cos:()=>ff,cross:()=>Aj,cubeTexture:()=>Cj,dFdx:()=>Rj,dFdy:()=>Ej,dashSize:()=>Pj,debug:()=>Fj,decrement:()=>Lj,decrementBefore:()=>Ij,defaultBuildStages:()=>zj,defaultShaderStages:()=>Bj,defined:()=>Vj,degrees:()=>Oj,deltaTime:()=>kj,densityFog:()=>Uj,densityFogFactor:()=>Dj,depth:()=>$j,depthPass:()=>Gj,difference:()=>jj,diffuseColor:()=>Wj,directPointLight:()=>Hj,directionToColor:()=>qj,dispersion:()=>Xj,distance:()=>Yj,div:()=>Zj,dodge:()=>Jj,dot:()=>wd,drawIndex:()=>Qj,dynamicBufferAttribute:()=>Kj,element:()=>eW,emissive:()=>tW,equal:()=>rW,equals:()=>sW,equirectUV:()=>iW,exp:()=>nW,exp2:()=>aW,expression:()=>oW,faceDirection:()=>lW,faceForward:()=>uW,faceforward:()=>hW,float:()=>mb,floor:()=>cW,fog:()=>dW,fract:()=>fb,frameGroup:()=>pW,frameId:()=>mW,frontFacing:()=>fW,fwidth:()=>b3,gain:()=>gW,gapSize:()=>yW,getConstNodeType:()=>xW,getCurrentStack:()=>bW,getDirection:()=>vW,getDistanceAttenuation:()=>TW,getGeometryRoughness:()=>wW,getNormalFromDepth:()=>SW,getParallaxCorrectNormal:()=>MW,getRoughness:()=>_W,getScreenPosition:()=>NW,getShIrradianceAt:()=>AW,getShadowMaterial:()=>EW,getShadowRenderObjectFunction:()=>PW,getTextureIndex:()=>CW,getViewPosition:()=>RW,globalId:()=>SH,glsl:()=>FW,glslFn:()=>LW,grayscale:()=>IW,greaterThan:()=>zW,greaterThanEqual:()=>BW,hash:()=>VW,highpModelNormalViewMatrix:()=>OW,highpModelViewMatrix:()=>kW,hue:()=>UW,increment:()=>DW,incrementBefore:()=>$W,instance:()=>GW,instanceIndex:()=>jW,instancedArray:()=>WW,instancedBufferAttribute:()=>HW,instancedDynamicBufferAttribute:()=>qW,instancedMesh:()=>XW,int:()=>YW,inverseSqrt:()=>ZW,inversesqrt:()=>JW,invocationLocalIndex:()=>QW,invocationSubgroupIndex:()=>KW,ior:()=>eH,iridescence:()=>tH,iridescenceIOR:()=>rH,iridescenceThickness:()=>sH,ivec2:()=>iH,ivec3:()=>nH,ivec4:()=>aH,js:()=>oH,label:()=>lH,length:()=>uH,lengthSq:()=>hH,lessThan:()=>cH,lessThanEqual:()=>dH,lightPosition:()=>pH,lightProjectionUV:()=>xY,lightShadowMatrix:()=>mH,lightTargetDirection:()=>fH,lightTargetPosition:()=>gH,lightViewPosition:()=>yH,lightingContext:()=>xH,lights:()=>bH,linearDepth:()=>vH,linearToneMapping:()=>TH,localId:()=>wH,log:()=>MH,log2:()=>_H,logarithmicDepthToViewZ:()=>NH,loop:()=>AH,luminance:()=>CH,mat2:()=>EH,mat3:()=>PH,mat4:()=>FH,matcapUV:()=>LH,materialAO:()=>IH,materialAlphaTest:()=>zH,materialAnisotropy:()=>BH,materialAnisotropyVector:()=>VH,materialAttenuationColor:()=>OH,materialAttenuationDistance:()=>kH,materialClearcoat:()=>UH,materialClearcoatNormal:()=>DH,materialClearcoatRoughness:()=>$H,materialColor:()=>GH,materialDispersion:()=>jH,materialEmissive:()=>WH,materialIOR:()=>HH,materialIridescence:()=>qH,materialIridescenceIOR:()=>XH,materialIridescenceThickness:()=>YH,materialLightMap:()=>ZH,materialLineDashOffset:()=>JH,materialLineDashSize:()=>QH,materialLineGapSize:()=>KH,materialLineScale:()=>eq,materialLineWidth:()=>tq,materialMetalness:()=>rq,materialNormal:()=>sq,materialOpacity:()=>iq,materialPointSize:()=>nq,materialReference:()=>aq,materialReflectivity:()=>oq,materialRefractionRatio:()=>lq,materialRotation:()=>uq,materialRoughness:()=>hq,materialSheen:()=>cq,materialSheenRoughness:()=>dq,materialShininess:()=>pq,materialSpecular:()=>mq,materialSpecularColor:()=>fq,materialSpecularIntensity:()=>gq,materialSpecularStrength:()=>yq,materialThickness:()=>xq,materialTransmission:()=>bq,max:()=>v3,maxMipLevel:()=>vq,mediumpModelViewMatrix:()=>RH,metalness:()=>Tq,min:()=>wq,mix:()=>ml,mixElement:()=>Sq,mod:()=>Mq,modInt:()=>_q,modelDirection:()=>Nq,modelNormalMatrix:()=>Aq,modelPosition:()=>Cq,modelRadius:()=>Rq,modelScale:()=>Eq,modelViewMatrix:()=>Pq,modelViewPosition:()=>Fq,modelViewProjection:()=>Lq,modelWorldMatrix:()=>Iq,modelWorldMatrixInverse:()=>zq,morphReference:()=>Bq,mrt:()=>Vq,mul:()=>qs,mx_aastep:()=>Oq,mx_cell_noise_float:()=>kq,mx_contrast:()=>Uq,mx_fractal_noise_float:()=>Dq,mx_fractal_noise_vec2:()=>$q,mx_fractal_noise_vec3:()=>Gq,mx_fractal_noise_vec4:()=>jq,mx_hsvtorgb:()=>Wq,mx_noise_float:()=>Hq,mx_noise_vec3:()=>qq,mx_noise_vec4:()=>Xq,mx_ramplr:()=>Yq,mx_ramptb:()=>Zq,mx_rgbtohsv:()=>Jq,mx_safepower:()=>Qq,mx_splitlr:()=>Kq,mx_splittb:()=>eX,mx_srgb_texture_to_lin_rec709:()=>tX,mx_transform_uv:()=>rX,mx_worley_noise_float:()=>sX,mx_worley_noise_vec2:()=>iX,mx_worley_noise_vec3:()=>nX,namespace:()=>aX,negate:()=>oX,neutralToneMapping:()=>lX,nodeArray:()=>uX,nodeImmutable:()=>hX,nodeObject:()=>cX,nodeObjects:()=>dX,nodeProxy:()=>pX,normalFlat:()=>mX,normalGeometry:()=>fX,normalLocal:()=>gX,normalMap:()=>yX,normalView:()=>xX,normalWorld:()=>bX,normalize:()=>vX,not:()=>TX,notEqual:()=>wX,numWorkgroups:()=>SX,objectDirection:()=>MX,objectGroup:()=>_X,objectPosition:()=>NX,objectRadius:()=>AX,objectScale:()=>CX,objectViewPosition:()=>RX,objectWorldMatrix:()=>EX,oneMinus:()=>PX,or:()=>FX,orthographicDepthToViewZ:()=>LX,oscSawtooth:()=>IX,oscSine:()=>zX,oscSquare:()=>BX,oscTriangle:()=>VX,output:()=>OX,outputStruct:()=>kX,overlay:()=>UX,overloadingFn:()=>DX,parabola:()=>$X,parallaxDirection:()=>GX,parallaxUV:()=>jX,parameter:()=>WX,pass:()=>HX,passTexture:()=>qX,pcurve:()=>XX,perspectiveDepthToViewZ:()=>YX,pmremTexture:()=>ZX,pointShadow:()=>rZ,pointUV:()=>JX,pointWidth:()=>QX,positionGeometry:()=>KX,positionLocal:()=>eY,positionPrevious:()=>tY,positionView:()=>rY,positionViewDirection:()=>sY,positionWorld:()=>iY,positionWorldDirection:()=>nY,posterize:()=>aY,pow:()=>T3,pow2:()=>oY,pow3:()=>lY,pow4:()=>uY,premult:()=>hY,property:()=>cY,radians:()=>dY,rand:()=>pY,range:()=>mY,rangeFog:()=>fY,rangeFogFactor:()=>gY,reciprocal:()=>yY,reference:()=>bY,referenceBuffer:()=>vY,reflect:()=>TY,reflectVector:()=>wY,reflectView:()=>SY,reflector:()=>MY,refract:()=>_Y,refractVector:()=>NY,refractView:()=>AY,reinhardToneMapping:()=>CY,remainder:()=>RY,remap:()=>EY,remapClamp:()=>PY,renderGroup:()=>FY,renderOutput:()=>LY,rendererReference:()=>IY,rotate:()=>zY,rotateUV:()=>BY,roughness:()=>VY,round:()=>OY,rtt:()=>kY,sRGBTransferEOTF:()=>UY,sRGBTransferOETF:()=>DY,sampler:()=>$Y,samplerComparison:()=>GY,saturate:()=>jY,saturation:()=>WY,screen:()=>HY,screenCoordinate:()=>qY,screenSize:()=>XY,screenUV:()=>YY,scriptable:()=>ZY,scriptableValue:()=>JY,select:()=>QY,setCurrentStack:()=>KY,shaderStages:()=>eZ,shadow:()=>tZ,shadowPositionWorld:()=>sZ,shapeCircle:()=>nZ,sharedUniformGroup:()=>iZ,sheen:()=>aZ,sheenRoughness:()=>oZ,shiftLeft:()=>lZ,shiftRight:()=>uZ,shininess:()=>hZ,sign:()=>cZ,sin:()=>no,sinc:()=>dZ,skinning:()=>pZ,smoothstep:()=>gb,smoothstepElement:()=>mZ,specularColor:()=>fZ,specularF90:()=>gZ,spherizeUV:()=>yZ,split:()=>xZ,spritesheetUV:()=>bZ,sqrt:()=>vZ,stack:()=>TZ,step:()=>wZ,storage:()=>SZ,storageBarrier:()=>MZ,storageObject:()=>_Z,storageTexture:()=>NZ,string:()=>AZ,struct:()=>CZ,sub:()=>Sd,subgroupIndex:()=>RZ,subgroupSize:()=>EZ,tan:()=>PZ,tangentGeometry:()=>FZ,tangentLocal:()=>LZ,tangentView:()=>IZ,tangentWorld:()=>zZ,temp:()=>BZ,texture:()=>VZ,texture3D:()=>OZ,textureBarrier:()=>kZ,textureBicubic:()=>UZ,textureCubeUV:()=>DZ,textureLoad:()=>$Z,textureSize:()=>GZ,textureStore:()=>jZ,thickness:()=>WZ,time:()=>Lv,timerDelta:()=>HZ,timerGlobal:()=>qZ,timerLocal:()=>XZ,toneMapping:()=>YZ,toneMappingExposure:()=>ZZ,toonOutlinePass:()=>JZ,transformDirection:()=>QZ,transformNormal:()=>KZ,transformNormalToView:()=>eJ,transformedBentNormalView:()=>tJ,transformedBitangentView:()=>rJ,transformedBitangentWorld:()=>sJ,transformedClearcoatNormalView:()=>iJ,transformedNormalView:()=>nJ,transformedNormalWorld:()=>aJ,transformedTangentView:()=>oJ,transformedTangentWorld:()=>lJ,transmission:()=>uJ,transpose:()=>hJ,triNoise3D:()=>cJ,triplanarTexture:()=>dJ,triplanarTextures:()=>pJ,trunc:()=>mJ,tslFn:()=>fJ,uint:()=>gJ,uniform:()=>yJ,uniformArray:()=>bJ,uniformCubeTexture:()=>xJ,uniformGroup:()=>vJ,uniformTexture:()=>TJ,uniforms:()=>wJ,unpremult:()=>SJ,userData:()=>MJ,uv:()=>Iv,uvec2:()=>_J,uvec3:()=>NJ,uvec4:()=>AJ,varying:()=>RJ,varyingProperty:()=>EJ,vec2:()=>zv,vec3:()=>Bv,vec4:()=>Ur,vectorComponents:()=>PJ,velocity:()=>FJ,vertexColor:()=>LJ,vertexIndex:()=>IJ,vibrance:()=>zJ,viewZToLogarithmicDepth:()=>BJ,viewZToOrthographicDepth:()=>VJ,viewZToPerspectiveDepth:()=>OJ,viewport:()=>kJ,viewportBottomLeft:()=>UJ,viewportCoordinate:()=>DJ,viewportDepthTexture:()=>$J,viewportLinearDepth:()=>GJ,viewportMipTexture:()=>jJ,viewportResolution:()=>WJ,viewportSafeUV:()=>HJ,viewportSharedTexture:()=>qJ,viewportSize:()=>XJ,viewportTexture:()=>YJ,viewportTopLeft:()=>ZJ,viewportUV:()=>JJ,wgsl:()=>QJ,wgslFn:()=>KJ,workgroupArray:()=>eQ,workgroupBarrier:()=>tQ,workgroupId:()=>rQ,workingToColorSpace:()=>sQ,xor:()=>iQ});const p7=y.BRDF_GGX,m7=y.BRDF_Lambert,f7=y.BasicShadowFilter,g7=y.Break,y7=y.Continue,x7=y.DFGApprox,b7=y.D_GGX,v7=y.Discard,T7=y.EPSILON,w7=y.F_Schlick,S7=y.Fn,M7=y.INFINITY,_7=y.If,N7=y.Switch,A7=y.Loop,C7=y.NodeShaderStage,R7=y.NodeType,E7=y.NodeUpdateType,P7=y.NodeAccess,F7=y.PCFShadowFilter,L7=y.PCFSoftShadowFilter,I7=y.PI,z7=y.PI2,B7=y.Return,V7=y.Schlick_to_F0,O7=y.ScriptableNodeResources,k7=y.ShaderNode,U7=y.TBNViewMatrix,D7=y.VSMShadowFilter,$7=y.V_GGX_SmithCorrelated,G7=y.abs,j7=y.acesFilmicToneMapping,W7=y.acos,pb=y.add,H7=y.addNodeElement,q7=y.agxToneMapping,X7=y.all,Y7=y.alphaT,Z7=y.and,J7=y.anisotropy,Q7=y.anisotropyB,K7=y.anisotropyT,eG=y.any,tG=y.append,rG=y.array,sG=y.arrayBuffer,iG=y.asin,nG=y.assign,aG=y.atan,oG=y.atan2,lG=y.atomicAdd,uG=y.atomicAnd,hG=y.atomicFunc,cG=y.atomicMax,dG=y.atomicMin,pG=y.atomicOr,mG=y.atomicStore,fG=y.atomicSub,gG=y.atomicXor,yG=y.atomicLoad,xG=y.attenuationColor,bG=y.attenuationDistance,vG=y.attribute,TG=y.attributeArray,wG=y.backgroundBlurriness,SG=y.backgroundIntensity,MG=y.backgroundRotation,_G=y.batch,NG=y.billboarding,AG=y.bitAnd,CG=y.bitNot,RG=y.bitOr,EG=y.bitXor,PG=y.bitangentGeometry,FG=y.bitangentLocal,LG=y.bitangentView,IG=y.bitangentWorld,zG=y.bitcast,BG=y.blendBurn,VG=y.blendColor,OG=y.blendDodge,kG=y.blendOverlay,UG=y.blendScreen,DG=y.blur,$G=y.bool,GG=y.buffer,jG=y.bufferAttribute,WG=y.bumpMap,HG=y.burn,qG=y.bvec2,XG=y.bvec3,YG=y.bvec4,ZG=y.bypass,JG=y.cache,QG=y.call,KG=y.cameraFar,ej=y.cameraIndex,tj=y.cameraNear,rj=y.cameraNormalMatrix,sj=y.cameraPosition,ij=y.cameraProjectionMatrix,nj=y.cameraProjectionMatrixInverse,aj=y.cameraViewMatrix,oj=y.cameraWorldMatrix,lj=y.cbrt,uj=y.cdl,hj=y.ceil,cj=y.checker,dj=y.cineonToneMapping,x3=y.clamp,pj=y.clearcoat,mj=y.clearcoatRoughness,fj=y.code,gj=y.color,yj=y.colorSpaceToWorking,xj=y.colorToDirection,bj=y.compute,vj=y.computeSkinning,Tj=y.cond,wj=y.Const,Sj=y.context,Mj=y.convert,_j=y.convertColorSpace,Nj=y.convertToTexture,ff=y.cos,Aj=y.cross,Cj=y.cubeTexture,Rj=y.dFdx,Ej=y.dFdy,Pj=y.dashSize,Fj=y.debug,Lj=y.decrement,Ij=y.decrementBefore,zj=y.defaultBuildStages,Bj=y.defaultShaderStages,Vj=y.defined,Oj=y.degrees,kj=y.deltaTime,Uj=y.densityFog,Dj=y.densityFogFactor,$j=y.depth,Gj=y.depthPass,jj=y.difference,Wj=y.diffuseColor,Hj=y.directPointLight,qj=y.directionToColor,Xj=y.dispersion,Yj=y.distance,Zj=y.div,Jj=y.dodge,wd=y.dot,Qj=y.drawIndex,Kj=y.dynamicBufferAttribute,eW=y.element,tW=y.emissive,rW=y.equal,sW=y.equals,iW=y.equirectUV,nW=y.exp,aW=y.exp2,oW=y.expression,lW=y.faceDirection,uW=y.faceForward,hW=y.faceforward,mb=y.float,cW=y.floor,dW=y.fog,fb=y.fract,pW=y.frameGroup,mW=y.frameId,fW=y.frontFacing,b3=y.fwidth,gW=y.gain,yW=y.gapSize,xW=y.getConstNodeType,bW=y.getCurrentStack,vW=y.getDirection,TW=y.getDistanceAttenuation,wW=y.getGeometryRoughness,SW=y.getNormalFromDepth,MW=y.getParallaxCorrectNormal,_W=y.getRoughness,NW=y.getScreenPosition,AW=y.getShIrradianceAt,CW=y.getTextureIndex,RW=y.getViewPosition,EW=y.getShadowMaterial,PW=y.getShadowRenderObjectFunction,FW=y.glsl,LW=y.glslFn,IW=y.grayscale,zW=y.greaterThan,BW=y.greaterThanEqual,VW=y.hash,OW=y.highpModelNormalViewMatrix,kW=y.highpModelViewMatrix,UW=y.hue,DW=y.increment,$W=y.incrementBefore,GW=y.instance,jW=y.instanceIndex,WW=y.instancedArray,HW=y.instancedBufferAttribute,qW=y.instancedDynamicBufferAttribute,XW=y.instancedMesh,YW=y.int,ZW=y.inverseSqrt,JW=y.inversesqrt,QW=y.invocationLocalIndex,KW=y.invocationSubgroupIndex,eH=y.ior,tH=y.iridescence,rH=y.iridescenceIOR,sH=y.iridescenceThickness,iH=y.ivec2,nH=y.ivec3,aH=y.ivec4,oH=y.js,lH=y.label,uH=y.length,hH=y.lengthSq,cH=y.lessThan,dH=y.lessThanEqual,pH=y.lightPosition,mH=y.lightShadowMatrix,fH=y.lightTargetDirection,gH=y.lightTargetPosition,yH=y.lightViewPosition,xH=y.lightingContext,bH=y.lights,vH=y.linearDepth,TH=y.linearToneMapping,wH=y.localId,SH=y.globalId,MH=y.log,_H=y.log2,NH=y.logarithmicDepthToViewZ,AH=y.loop,CH=y.luminance,RH=y.mediumpModelViewMatrix,EH=y.mat2,PH=y.mat3,FH=y.mat4,LH=y.matcapUV,IH=y.materialAO,zH=y.materialAlphaTest,BH=y.materialAnisotropy,VH=y.materialAnisotropyVector,OH=y.materialAttenuationColor,kH=y.materialAttenuationDistance,UH=y.materialClearcoat,DH=y.materialClearcoatNormal,$H=y.materialClearcoatRoughness,GH=y.materialColor,jH=y.materialDispersion,WH=y.materialEmissive,HH=y.materialIOR,qH=y.materialIridescence,XH=y.materialIridescenceIOR,YH=y.materialIridescenceThickness,ZH=y.materialLightMap,JH=y.materialLineDashOffset,QH=y.materialLineDashSize,KH=y.materialLineGapSize,eq=y.materialLineScale,tq=y.materialLineWidth,rq=y.materialMetalness,sq=y.materialNormal,iq=y.materialOpacity,nq=y.materialPointSize,aq=y.materialReference,oq=y.materialReflectivity,lq=y.materialRefractionRatio,uq=y.materialRotation,hq=y.materialRoughness,cq=y.materialSheen,dq=y.materialSheenRoughness,pq=y.materialShininess,mq=y.materialSpecular,fq=y.materialSpecularColor,gq=y.materialSpecularIntensity,yq=y.materialSpecularStrength,xq=y.materialThickness,bq=y.materialTransmission,v3=y.max,vq=y.maxMipLevel,Tq=y.metalness,wq=y.min,ml=y.mix,Sq=y.mixElement,Mq=y.mod,_q=y.modInt,Nq=y.modelDirection,Aq=y.modelNormalMatrix,Cq=y.modelPosition,Rq=y.modelRadius,Eq=y.modelScale,Pq=y.modelViewMatrix,Fq=y.modelViewPosition,Lq=y.modelViewProjection,Iq=y.modelWorldMatrix,zq=y.modelWorldMatrixInverse,Bq=y.morphReference,Vq=y.mrt,qs=y.mul,Oq=y.mx_aastep,kq=y.mx_cell_noise_float,Uq=y.mx_contrast,Dq=y.mx_fractal_noise_float,$q=y.mx_fractal_noise_vec2,Gq=y.mx_fractal_noise_vec3,jq=y.mx_fractal_noise_vec4,Wq=y.mx_hsvtorgb,Hq=y.mx_noise_float,qq=y.mx_noise_vec3,Xq=y.mx_noise_vec4,Yq=y.mx_ramplr,Zq=y.mx_ramptb,Jq=y.mx_rgbtohsv,Qq=y.mx_safepower,Kq=y.mx_splitlr,eX=y.mx_splittb,tX=y.mx_srgb_texture_to_lin_rec709,rX=y.mx_transform_uv,sX=y.mx_worley_noise_float,iX=y.mx_worley_noise_vec2,nX=y.mx_worley_noise_vec3,aX=y.namespace,oX=y.negate,lX=y.neutralToneMapping,uX=y.nodeArray,hX=y.nodeImmutable,cX=y.nodeObject,dX=y.nodeObjects,pX=y.nodeProxy,mX=y.normalFlat,fX=y.normalGeometry,gX=y.normalLocal,yX=y.normalMap,xX=y.normalView,bX=y.normalWorld,vX=y.normalize,TX=y.not,wX=y.notEqual,SX=y.numWorkgroups,MX=y.objectDirection,_X=y.objectGroup,NX=y.objectPosition,AX=y.objectRadius,CX=y.objectScale,RX=y.objectViewPosition,EX=y.objectWorldMatrix,PX=y.oneMinus,FX=y.or,LX=y.orthographicDepthToViewZ,IX=y.oscSawtooth,zX=y.oscSine,BX=y.oscSquare,VX=y.oscTriangle,OX=y.output,kX=y.outputStruct,UX=y.overlay,DX=y.overloadingFn,$X=y.parabola,GX=y.parallaxDirection,jX=y.parallaxUV,WX=y.parameter,HX=y.pass,qX=y.passTexture,XX=y.pcurve,YX=y.perspectiveDepthToViewZ,ZX=y.pmremTexture,JX=y.pointUV,QX=y.pointWidth,KX=y.positionGeometry,eY=y.positionLocal,tY=y.positionPrevious,rY=y.positionView,sY=y.positionViewDirection,iY=y.positionWorld,nY=y.positionWorldDirection,aY=y.posterize,T3=y.pow,oY=y.pow2,lY=y.pow3,uY=y.pow4,hY=y.premult,cY=y.property,dY=y.radians,pY=y.rand,mY=y.range,fY=y.rangeFog,gY=y.rangeFogFactor,yY=y.reciprocal,xY=y.lightProjectionUV,bY=y.reference,vY=y.referenceBuffer,TY=y.reflect,wY=y.reflectVector,SY=y.reflectView,MY=y.reflector,_Y=y.refract,NY=y.refractVector,AY=y.refractView,CY=y.reinhardToneMapping,RY=y.remainder,EY=y.remap,PY=y.remapClamp,FY=y.renderGroup,LY=y.renderOutput,IY=y.rendererReference,zY=y.rotate,BY=y.rotateUV,VY=y.roughness,OY=y.round,kY=y.rtt,UY=y.sRGBTransferEOTF,DY=y.sRGBTransferOETF,$Y=y.sampler,GY=y.samplerComparison,jY=y.saturate,WY=y.saturation,HY=y.screen,qY=y.screenCoordinate,XY=y.screenSize,YY=y.screenUV,ZY=y.scriptable,JY=y.scriptableValue,QY=y.select,KY=y.setCurrentStack,eZ=y.shaderStages,tZ=y.shadow,rZ=y.pointShadow,sZ=y.shadowPositionWorld,iZ=y.sharedUniformGroup,nZ=y.shapeCircle,aZ=y.sheen,oZ=y.sheenRoughness,lZ=y.shiftLeft,uZ=y.shiftRight,hZ=y.shininess,cZ=y.sign,no=y.sin,dZ=y.sinc,pZ=y.skinning,gb=y.smoothstep,mZ=y.smoothstepElement,fZ=y.specularColor,gZ=y.specularF90,yZ=y.spherizeUV,xZ=y.split,bZ=y.spritesheetUV,vZ=y.sqrt,TZ=y.stack,wZ=y.step,SZ=y.storage,MZ=y.storageBarrier,_Z=y.storageObject,NZ=y.storageTexture,AZ=y.string,CZ=y.struct,Sd=y.sub,RZ=y.subgroupIndex,EZ=y.subgroupSize,PZ=y.tan,FZ=y.tangentGeometry,LZ=y.tangentLocal,IZ=y.tangentView,zZ=y.tangentWorld,BZ=y.temp,VZ=y.texture,OZ=y.texture3D,kZ=y.textureBarrier,UZ=y.textureBicubic,DZ=y.textureCubeUV,$Z=y.textureLoad,GZ=y.textureSize,jZ=y.textureStore,WZ=y.thickness,Lv=y.time,HZ=y.timerDelta,qZ=y.timerGlobal,XZ=y.timerLocal,YZ=y.toneMapping,ZZ=y.toneMappingExposure,JZ=y.toonOutlinePass,QZ=y.transformDirection,KZ=y.transformNormal,eJ=y.transformNormalToView,tJ=y.transformedBentNormalView,rJ=y.transformedBitangentView,sJ=y.transformedBitangentWorld,iJ=y.transformedClearcoatNormalView,nJ=y.transformedNormalView,aJ=y.transformedNormalWorld,oJ=y.transformedTangentView,lJ=y.transformedTangentWorld,uJ=y.transmission,hJ=y.transpose,cJ=y.triNoise3D,dJ=y.triplanarTexture,pJ=y.triplanarTextures,mJ=y.trunc,fJ=y.tslFn,gJ=y.uint,yJ=y.uniform,xJ=y.uniformCubeTexture,bJ=y.uniformArray,vJ=y.uniformGroup,TJ=y.uniformTexture,wJ=y.uniforms,SJ=y.unpremult,MJ=y.userData,Iv=y.uv,_J=y.uvec2,NJ=y.uvec3,AJ=y.uvec4,CJ=y.Var,RJ=y.varying,EJ=y.varyingProperty,zv=y.vec2,Bv=y.vec3,Ur=y.vec4,PJ=y.vectorComponents,FJ=y.velocity,LJ=y.vertexColor,IJ=y.vertexIndex,zJ=y.vibrance,BJ=y.viewZToLogarithmicDepth,VJ=y.viewZToOrthographicDepth,OJ=y.viewZToPerspectiveDepth,kJ=y.viewport,UJ=y.viewportBottomLeft,DJ=y.viewportCoordinate,$J=y.viewportDepthTexture,GJ=y.viewportLinearDepth,jJ=y.viewportMipTexture,WJ=y.viewportResolution,HJ=y.viewportSafeUV,qJ=y.viewportSharedTexture,XJ=y.viewportSize,YJ=y.viewportTexture,ZJ=y.viewportTopLeft,JJ=y.viewportUV,QJ=y.wgsl,KJ=y.wgslFn,eQ=y.workgroupArray,tQ=y.workgroupBarrier,rQ=y.workgroupId,sQ=y.workingToColorSpace,iQ=y.xor;function nQ(t,e,r=1){let s=t.rgb,i=e.rgb,n=qs(s,i),a=qs(e.a,r),o=ml(s,n,a),l=v3(t.a,qs(e.a,r));return Ur(o,l)}function aQ(t,e,r=1){let s=qs(e.a,r),i=pb(s,qs(t.a,Sd(1,s))),n=pb(qs(e.rgb,s),qs(t.rgb,qs(t.a,Sd(1,s))));return Ur(n,i)}const eM={normal:aQ,multiply:nQ};function au(t,e,r="normal",s=1){return(eM[r]||eM.normal)(t,e,s)}function oQ(t,e){let r=qs(t.a,e.a);return Ur(t.rgb,r)}function lQ(t,e){let r=Sd(1,e.a),s=qs(t.a,r);return Ur(t.rgb,s)}function uQ(t,e){let r=Bv(.2126,.7152,.0722),s=wd(e.rgb,r),i=qs(t.a,s);return Ur(t.rgb,i)}function hQ(t,e){let r=Bv(.2126,.7152,.0722),s=wd(e.rgb,r),i=Sd(1,s),n=qs(t.a,i);return Ur(t.rgb,n)}const tM={alpha:oQ,alphaInverted:lQ,luminance:uQ,luminanceInverted:hQ};function cQ(t,e,r="alpha"){return(tM[r]||tM.alpha)(t,e)}const rM={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};let sM=!1;const dQ=()=>{try{if(rM!==void 0){let{MODE:t,DEV:e}=rM;return e||t==="development"}if(typeof window<"u"&&window.location){let t=window.location.hostname;return t==="localhost"||t==="127.0.0.1"||t.endsWith(".local")||t.includes("dev.")||t.startsWith("dev-")}return!1}catch{return!1}};function pQ(){let t=`renderer_${Math.random().toString(36).substring(2,11)}`,e=null,r,s,i,n,a,o={nodes:new Map,rootId:null,idToNodeId:new Map},l=null,h=null,u=null,c=!1,d=!1,p=!1,m=null,f=!1,g=!0,b=0,v=0,w=0,T=0,N=8,S=.5,_=.5,A=!1,D=!1,K=!1,J=[],re=!1,te=[],oe=!1,ae=()=>{var le;return(le=window).matchMedia?.call(le,"(prefers-reduced-motion: reduce)").matches??!1},ge=(le,pe)=>{if(le===b&&pe===v)return;let ye=performance.now();if(ye-w<N)return;b=le,v=pe,w=ye,r.setSize(le,pe,!1);let Re=le/pe,bt=2,or=bt*Re;s.left=-or/2,s.right=or/2,s.top=bt/2,s.bottom=-2/2,s.updateProjectionMatrix(),n.scale.set(or,bt,1),o.rootId&&p&&me(),qt().catch(console.warn)},fe=le=>{if(!r||!s||!n)return;let pe=le[0];if(!pe)return;let{width:ye,height:Re}=pe.contentRect,bt=Math.round(ye),or=Math.round(Re);ge(bt,or)},ve=le=>{let pe=le[0];pe&&(f=pe.isIntersecting,f?(a&&c&&o.rootId&&me(),g&&br()):Pi())},me=()=>{if(!o.rootId||!a||D)return;if(o.nodes.get(o.rootId)){D=!0;try{let pe=ft(o.rootId);pe&&a&&(a.fragmentNode=pe,a.needsUpdate=!0)}catch(pe){console.error("Error composing shader tree:",pe)}finally{D=!1}f&&qt().catch(console.warn)}},he=le=>{let pe=[];return o.nodes.forEach(ye=>{ye.parentId===le&&pe.push(ye)}),pe},Te=le=>{for(let[pe,ye]of o.nodes.entries())if(ye.metadata.id===le)return pe;return null},Ge=(le,pe,ye,Re)=>{if(!pe.metadata.mask?.source)return le;let bt=pe.metadata.mask.source,or=Te(bt);if(!or)return le;if(Re.has(or))return console.error("Uh oh, looks like you've got a circular dependency in your shader masks."),le;let Lo=new Set(Re);Lo.add(ye);let os=ft(or,Lo),kl=pe.metadata.mask.type||"alpha";return cQ(le,os,kl)},He=le=>{let pe=o.nodes.get(le);if(!pe||!pe.metadata.id)return!1;let ye=pe.metadata.id;for(let Re of o.nodes.values())if(Re.metadata.mask?.source===ye)return!0;return!1},ft=(le,pe=new Set)=>{let ye=o.nodes.get(le);if(!ye)return Ur(0,0,0,0);let Re=os=>{ye.cleanupCallbacks.push(os)},bt=os=>{ye.beforeRenderCallbacks.push(os)},or=os=>{ye.afterRenderCallbacks.push(os)},Lo=he(le);if(Lo.length===0){let os=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:void 0,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(os,ye,le,pe)}else{let os=[...Lo].sort((Li,rc)=>Li.metadata.renderOrder-rc.metadata.renderOrder);if(ye.parentId===null){let Li;for(let vr of os){if((vr.metadata.opacity??(He(vr.id)?0:1))===0&&!He(vr.id))continue;let _p=ft(vr.id,pe),Dn;Dn=vr.metadata.opacity===void 0?He(vr.id)?0:1:vr.metadata.opacity,Li=Li===void 0?Dn===1?au(Ur(1,1,1,0),_p,"normal",1):au(Ur(1,1,1,0),_p,vr.metadata.blendMode,Dn):au(Li,_p,vr.metadata.blendMode,Dn)}let rc=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:Li,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(rc,ye,le,pe)}else{let Li;for(let vr of os){let Mp=ft(vr.id,pe);if((vr.metadata.opacity??(He(vr.id)?0:1))===0&&!He(vr.id))continue;let Dn;Dn=vr.metadata.opacity===void 0?He(vr.id)?0:1:vr.metadata.opacity,Li=Li===void 0?Dn===1?au(Ur(1,1,1,0),Mp,"normal",1):au(Ur(1,1,1,0),Mp,vr.metadata.blendMode,Dn):au(Li,Mp,vr.metadata.blendMode,Dn)}let rc=ye.fragmentNodeFunc({uniforms:ye.uniforms??{},childNode:Li,onCleanup:Re,onBeforeRender:bt,onAfterRender:or,canvas:e});return Ge(rc,ye,le,pe)}}},ht=(le,pe,ye,Re,bt={})=>{let or=0;if(ye!==null){let os=Array.from(o.nodes.values()).filter(kl=>kl.parentId===ye);os.length>0&&(or=Math.max(...os.map(kl=>kl.metadata.renderOrder))+1)}let Lo={id:le,fragmentNodeFunc:pe,parentId:ye,metadata:{blendMode:Re?.blendMode||"normal",opacity:Re?.opacity,id:Re?.id,mask:Re?.mask,renderOrder:Re?.renderOrder===void 0?or:Re?.renderOrder},uniforms:bt,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};o.nodes.set(le,Lo),ye===null&&(o.rootId=le),a&&c&&(J.includes(le)||J.push(le),re||(re=!0,queueMicrotask(()=>{re=!1,J=[],me()})))},Ft=(le,pe,ye)=>{let Re=o.nodes.get(le);if(!Re||!Re.uniforms){console.warn(`Node or uniforms not found for ID: ${le}`);return}let bt=Re.uniforms[pe];if(!bt||!bt.uniform){console.warn(`Uniform ${pe} not found in node: ${le}`);return}bt.uniform.value=ye,f&&qt()},ri=(le,pe)=>{let ye=o.nodes.get(le);if(!ye)return;let Re=!1;pe.blendMode!==void 0&&ye.metadata.blendMode!==pe.blendMode&&(ye.metadata.blendMode=pe.blendMode,Re=!0),pe.opacity!==void 0&&ye.metadata.opacity!==pe.opacity&&(ye.metadata.opacity=pe.opacity,Re=!0),pe.renderOrder!==void 0&&ye.metadata.renderOrder!==pe.renderOrder&&(ye.metadata.renderOrder=pe.renderOrder,Re=!0),pe.id!==void 0&&ye.metadata.id!==pe.id&&(ye.metadata.id=pe.id,Re=!0),pe.mask!==void 0&&(ye.metadata.mask?.source!==pe.mask?.source||ye.metadata.mask?.type!==pe.mask?.type)&&(ye.metadata.mask=pe.mask,Re=!0),Re&&a&&c?(te.includes(le)||te.push(le),oe||(oe=!0,queueMicrotask(()=>{oe=!1,te=[],me()}))):f&&qt()},ar=le=>{if(!o.nodes.has(le))return;let pe=o.nodes.get(le);if(pe&&pe.cleanupCallbacks.length>0)for(let Re of pe.cleanupCallbacks)try{Re()}catch(bt){console.error(`Error executing cleanup callback for node ${le}:`,bt)}let ye=he(le);for(let Re of ye)ar(Re.id);o.rootId===le&&(o.rootId=null),o.nodes.delete(le),a&&c&&me()},et=le=>{let pe={deltaTime:le,pointer:{x:S,y:_},pointerActive:A,dimensions:{width:b,height:v}};for(let ye of o.nodes.values())if(ye.beforeRenderCallbacks.length>0)for(let Re of ye.beforeRenderCallbacks)try{Re(pe)}catch(bt){console.error(`Error executing before render callback for node ${ye.id}:`,bt)}},Wr=le=>{let pe={deltaTime:le,pointer:{x:S,y:_},pointerActive:A,dimensions:{width:b,height:v}};for(let ye of o.nodes.values())if(ye.afterRenderCallbacks.length>0)for(let Re of ye.afterRenderCallbacks)try{Re(pe)}catch(bt){console.error(`Error executing after render callback for node ${ye.id}:`,bt)}},qt=async()=>{if(!c||!r||!i||!s||!a)return;let le=performance.now(),pe=T>0?(le-T)/1e3:.016,ye=Math.min(pe,.1);T=le,et(ye);try{if(D)return;r instanceof KS?await r.renderAsync(i,s).then(()=>{c&&Wr(ye)}).catch(Re=>{console.error("WebGPU render error:",Re)}):(r.render(i,s),Wr(ye))}catch(Re){console.error("Render frame error:",Re)}},br=()=>{if(l||!g||!f)return;let le=()=>{l=requestAnimationFrame(le),qt().catch(console.warn)};le()},Pi=()=>{l&&(cancelAnimationFrame(l),l=null)},ns=le=>{if(!e){console.log(`[${t}] No canvas element in updatePointerCoords`);return}let pe,ye;if("touches"in le){if(le.touches.length===0)return;pe=le.touches[0].clientX,ye=le.touches[0].clientY}else pe=le.clientX,ye=le.clientY;let Re=e.getBoundingClientRect(),bt=(pe-Re.left)/Re.width,or=(ye-Re.top)/Re.height;S=bt,_=or},as=le=>{ns(le)},Fi=le=>{ns(le)},vp=()=>{A=!1,qt().catch(console.warn)},Tp=()=>{A=!1,qt().catch(console.warn)},wp=()=>{A=!0,qt().catch(console.warn)},Sp=()=>{A=!0,qt().catch(console.warn)};return{initialize:async({canvas:le})=>{if(c||d)return;d=!0,m=new AbortController;let pe=m;try{if(e=le,i=new xg,i.background=null,s=new bg(-1,1,1,-1,.1,10),s.position.z=1,s.lookAt(0,0,0),K||(window.addEventListener("mousemove",as),window.addEventListener("touchmove",Fi),window.addEventListener("mouseup",vp),window.addEventListener("touchend",Tp),le.addEventListener("mousedown",wp),le.addEventListener("touchstart",Sp),K=!0,console.log(`[${t}] Added event listeners`)),pe.signal.aborted)return;try{if(r=new KS({canvas:le,antialias:!0,alpha:!0,depth:!1,powerPreference:"high-performance"}),await r.init(),pe.signal.aborted)return}catch(or){if(pe.signal.aborted)return;console.error("[Shaders] WebGPU initialization error:",or);return}if(pe.signal.aborted)return;r.setPixelRatio(Math.min(window.devicePixelRatio,2)),r.outputColorSpace=ws,a=new VR({transparent:!0}),a.fragmentNode=Ur(0,0,0,0);let ye=new T2(2,2);n=new Nn(ye,a),i.add(n),h=new ResizeObserver(fe),h.observe(le),u=new IntersectionObserver(ve,{threshold:0}),u.observe(le),g=!ae();let{width:Re,height:bt}=le.getBoundingClientRect();ge(Math.round(Re),Math.round(bt)),p=!0,await qt(),g&&f&&br(),pe.signal.aborted||(c=!0)}catch(ye){console.error("[Shaders] Initialization error:",ye)}finally{d=!1,m===pe&&(m=null)}},cleanup:()=>{if(console.log(`[${t}] Cleanup called`),m&&m.abort(),h&&(h.disconnect(),h=null),u&&(u.disconnect(),u=null),K&&(console.log(`[${t}] Removing event listeners`),e&&(e.removeEventListener("mousedown",wp),e.removeEventListener("touchstart",Sp)),window&&(window.removeEventListener("mousemove",as),window.removeEventListener("touchmove",Fi),window.removeEventListener("mouseup",vp),window.removeEventListener("touchend",Tp)),K=!1),Pi(),o.nodes.clear(),o.rootId=null,o.idToNodeId.clear(),J=[],re=!1,te=[],oe=!1,n){i&&i.remove(n);try{n.geometry&&typeof n.geometry.dispose=="function"&&n.geometry.dispose()}catch(le){console.warn("Error disposing geometry:",le)}try{n.material instanceof bs&&typeof n.material.dispose=="function"&&n.material.dispose()}catch(le){console.warn("Error disposing material:",le)}}if(r&&typeof r.dispose=="function")try{r.dispose()}catch(le){console.warn("Error disposing renderer:",le)}e=null,r=null,s=null,i=null,n=null,a=null,c=!1,d=!1,p=!1,m=null,b=0,v=0,f=!1,g=!0,S=.5,_=.5,A=!1},registerNode:ht,removeNode:ar,updateUniformValue:Ft,updateNodeMetadata:ri,showLicenseWarning:()=>{!dQ()||sM||(console.warn("Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production."),sM=!0)}}}const{uniform:mQ}=_t;function Bt(t,e,r){let s={};return Object.entries(t.props).forEach(([i,n])=>{let a=e[i],o=a;n.transform&&(o=n.transform(a)),s[i]={uniform:mQ(o).label(`${i}_${r}`),transform:n.transform||void 0}}),s}const{vec2:Qme,fract:Kme,sin:efe,dot:tfe}=_t,{vec2:rfe}=_t;/**
|
|
430
430
|
* @license
|
|
431
431
|
* Copyright 2010-2025 Three.js Authors
|
|
432
432
|
* SPDX-License-Identifier: MIT
|