shaders 2.0.0-alpha.11 → 2.0.0-alpha.13
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/components/MouseDistortion.d.ts +22 -0
- package/dist/react/components/MouseDistortion.d.ts.map +1 -0
- package/dist/react/index.cjs +23 -23
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5457 -5571
- package/dist/react/index.js.map +1 -1
- package/dist/react/utils/generatePresetCode.d.ts.map +1 -1
- package/dist/svelte/index.d.ts +0 -1
- package/dist/svelte/index.js +0 -1
- package/dist/svelte/utils/generatePresetCode.js +0 -1
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +10 -10
- package/dist/vue/utils/generatePresetCode.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/vue/index.js
CHANGED
|
@@ -393,7 +393,7 @@ struct ${e} {
|
|
|
393
393
|
${t}
|
|
394
394
|
};`}_getWGSLStructBinding(e,t,n,r=0,i=0){let a=e+`Struct`,o=this._getWGSLStruct(a,t);return`${o}
|
|
395
395
|
@binding( ${r} ) @group( ${i} )
|
|
396
|
-
var<${n}> ${e} : ${a};`}},oj=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture===null?e.depth&&e.stencil?t=L.Depth24PlusStencil8:e.depth&&(t=L.Depth24Plus):t=this.getTextureFormatGPU(e.depthTexture),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,r=n?1:t;return{samples:t,primarySamples:r,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return uA.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return uA.LineList;if(e.isLine)return uA.LineStrip;if(e.isMesh)return uA.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=2**Math.floor(Math.log2(e)),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===st)return L.BGRA8Unorm;if(e===mt)return L.RGBA16Float;throw Error(`Unsupported outputType`)}};const sj=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),cj=new Map([[ja,[`float16`]]]),lj=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var uj=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}if(n.array=s,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){s=new s.constructor(n.count*4);for(let e=0;e<n.count;e++)s.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=s,i._force3to4BytesAlignment=!0}let c=s.byteLength,l=c+(4-c%4)%4;a=o.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array;if(i._force3to4BytesAlignment===!0){o=new o.constructor(t.count*4);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*3,e*3+3),e*4);t.array=o}let s=this._isTypedArray(o),c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=s?1:o.BYTES_PER_ELEMENT;for(let t=0,n=c.length;t<n;t++){let n=c[t],l,u;if(i._force3to4BytesAlignment===!0){let t=Math.floor(n.start/3),r=Math.ceil(n.count/3);l=t*4*e,u=r*4*e}else l=n.start*e,u=n.count*e;let d=l*(s?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,d,o,l,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?AA.Instance:AA.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?AA.Instance:AA.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend,n=t.get(this._getBufferAttribute(e));n.buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,n=t.device,r=t.get(this._getBufferAttribute(e)),i=r.buffer,a=i.size,o=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),s=n.createCommandEncoder({label:`readback_encoder_${e.name}`});s.copyBufferToBuffer(i,0,o,0,a);let c=s.finish();n.queue.submit([c]),await o.mapAsync(GPUMapMode.READ);let l=o.getMappedRange(),u=new e.array.constructor(l.slice(0));return o.unmap(),u.buffer}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=lj.get(r);else{let e=cj.get(i)||sj.get(r),o=e[n?1:0];if(o){let e=r.BYTES_PER_ELEMENT*t,n=Math.floor((e+3)/4)*4,i=n/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${o}x${i}`}}return a||console.error(`THREE.WebGPUAttributeUtils: Vertex format not supported yet.`),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},dj=class{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){let t=this.backend,n=t.device,r=[],i=0;for(let n of e.bindings){let e={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let t={};n.isStorageBuffer&&(n.visibility&4&&(n.access===_c.READ_WRITE||n.access===_c.WRITE_ONLY)?t.type=CA.Storage:t.type=CA.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=TA.NonFiltering):r.type=TA.Comparison),e.sampler=r}else if(n.isSampledTexture&&n.texture.isVideoTexture)e.externalTexture={};else if(n.isSampledTexture&&n.store){let t={};t.format=this.backend.get(n.texture).texture.format;let r=n.access;r===_c.READ_WRITE?t.access=wA.ReadWrite:r===_c.WRITE_ONLY?t.access=wA.WriteOnly:t.access=wA.ReadOnly,e.storageTexture=t}else if(n.isSampledTexture){let r={},{primarySamples:i}=t.utils.getTextureSampleData(n.texture);if(i>1&&(r.multisampled=!0,n.texture.isDepthTexture||(r.sampleType=EA.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=EA.UnfilterableFloat:r.sampleType=EA.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=EA.SInt:e===ft?r.sampleType=EA.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=EA.Float:r.sampleType=EA.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=OA.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=OA.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=OA.ThreeD),e.texture=r}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);r.push(e)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){let{backend:i,bindGroupLayoutCache:a}=this,o=i.get(e),s=a.get(e.bindingsReference);s===void 0&&(s=this.createBindingsLayout(e),a.set(e.bindingsReference,s));let c;n>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(c=o.groups[n])),c===void 0&&(c=this.createBindGroup(e,s),n>0&&(o.groups[n]=c,o.versions[n]=r)),o.group=c,o.layout=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer;n.queue.writeBuffer(i,0,r,0)}createBindGroupIndex(e,t){let n=this.backend,r=n.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],o=r.createBuffer({label:`bindingCameraIndex_`+a,size:16,usage:i});r.queue.writeBuffer(o,0,e,0);let s=[{binding:0,resource:{buffer:o}}];return r.createBindGroup({label:`bindGroupCameraIndex_`+a,layout:t,entries:s})}createBindGroup(e,t){let n=this.backend,r=n.device,i=0,a=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);if(e.buffer===void 0){let n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=r.createBuffer({label:`bindingBuffer_`+t.name,size:n,usage:i});e.buffer=a}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t);if(e.buffer===void 0){let r=t.attribute;e.buffer=n.get(r).buffer}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){let e=n.get(t.texture);a.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){let e=n.get(t.texture),o;if(e.externalTexture!==void 0)o=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=`view-${e.texture.width}-${e.texture.height}-${n}`;if(o=e[r],o===void 0){let i=kA.All,a;a=t.isSampledCubeTexture?OA.Cube:t.isSampledTexture3D?OA.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?OA.TwoDArray:OA.TwoD,o=e[r]=e.texture.createView({aspect:i,dimension:a,mipLevelCount:n})}}a.push({binding:i,resource:o})}i++}return r.createBindGroup({label:`bindGroup_`+e.name,layout:t,entries:a})}},fj=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){let n=this._activePipelines.get(e);n!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let e=c.get(t);f.push(e.layout)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==ae&&(r.blending!==oe||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures;for(let e=0;e<t.length;e++){let n=u.getTextureFormatGPU(t[e]);_.push({format:n,blend:m,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),ee=this._getSampleCount(e.context),te={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},y,{targets:_}),primitive:b,multisample:{count:ee,alphaToCoverageEnabled:r.alphaToCoverage&&ee>1},layout:l.createPipelineLayout({bindGroupLayouts:f})},ne={},re=e.context.depth,ie=e.context.stencil;if((re===!0||ie===!0)&&(re===!0&&(ne.format=S,ne.depthWriteEnabled=r.depthWrite,ne.depthCompare=x),ie===!0&&(ne.stencilFront=h,ne.stencilBack={},ne.stencilReadMask=r.stencilFuncMask,ne.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(ne.depthBias=r.polygonOffsetUnits,ne.depthBiasSlopeScale=r.polygonOffsetFactor,ne.depthBiasClamp=0),te.depthStencil=ne),t===null)d.pipeline=l.createRenderPipeline(te);else{let e=new Promise(e=>{l.createRenderPipelineAsync(te).then(t=>{d.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let n=this.backend,{utils:r,device:i}=n,a=r.getCurrentDepthStencilFormat(e),o=r.getCurrentColorFormat(e),s=this._getSampleCount(e),c={label:t,colorFormats:[o],depthStencilFormat:a,sampleCount:s};return i.createRenderBundleEncoder(c)}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let t=n.get(e);o.push(t.layout)}a.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===ue){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:bA.Add},n={srcFactor:i,dstFactor:a,operation:bA.Add}};if(i)switch(r){case oe:a(yA.One,yA.OneMinusSrcAlpha,yA.One,yA.OneMinusSrcAlpha);break;case se:a(yA.One,yA.One,yA.One,yA.One);break;case ce:a(yA.Zero,yA.OneMinusSrc,yA.Zero,yA.One);break;case le:a(yA.Zero,yA.Src,yA.Zero,yA.SrcAlpha);break}else switch(r){case oe:a(yA.SrcAlpha,yA.OneMinusSrcAlpha,yA.One,yA.OneMinusSrcAlpha);break;case se:a(yA.SrcAlpha,yA.One,yA.SrcAlpha,yA.One);break;case ce:a(yA.Zero,yA.OneMinusSrc,yA.Zero,yA.One);break;case le:a(yA.Zero,yA.Src,yA.Zero,yA.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error(`THREE.WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case ge:t=yA.Zero;break;case _e:t=yA.One;break;case ve:t=yA.Src;break;case ye:t=yA.OneMinusSrc;break;case be:t=yA.SrcAlpha;break;case xe:t=yA.OneMinusSrcAlpha;break;case we:t=yA.Dst;break;case Te:t=yA.OneMinusDst;break;case Se:t=yA.DstAlpha;break;case Ce:t=yA.OneMinusDstAlpha;break;case Ee:t=yA.SrcAlphaSaturated;break;case Gb:t=yA.Constant;break;case Kb:t=yA.OneMinusConstant;break;default:console.error(`THREE.WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case On:t=dA.Never;break;case Fn:t=dA.Always;break;case kn:t=dA.Less;break;case jn:t=dA.LessEqual;break;case An:t=dA.Equal;break;case Pn:t=dA.GreaterEqual;break;case Mn:t=dA.Greater;break;case Nn:t=dA.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case xn:t=SA.Keep;break;case bn:t=SA.Zero;break;case Sn:t=SA.Replace;break;case Dn:t=SA.Invert;break;case Cn:t=SA.IncrementClamp;break;case wn:t=SA.DecrementClamp;break;case Tn:t=SA.IncrementWrap;break;case En:t=SA.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=bA.Add;break;case fe:t=bA.Subtract;break;case pe:t=bA.ReverseSubtract;break;case me:t=bA.Min;break;case he:t=bA.Max;break;default:console.error(`THREE.WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={},i=this.backend.utils;switch(r.topology=i.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?gA.Uint16:gA.Uint32),n.side){case ne:r.frontFace=mA.CCW,r.cullMode=hA.Back;break;case re:r.frontFace=mA.CCW,r.cullMode=hA.Front;break;case ie:r.frontFace=mA.CCW,r.cullMode=hA.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?xA.All:xA.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=dA.Always;else{let n=e.depthFunc;switch(n){case De:t=dA.Never;break;case Oe:t=dA.Always;break;case ke:t=dA.Less;break;case Ae:t=dA.LessEqual;break;case je:t=dA.Equal;break;case Me:t=dA.GreaterEqual;break;case Ne:t=dA.Greater;break;case Pe:t=dA.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},pj=class extends oA{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:`timestamp`,count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Mr(`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 t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{let e=await this.pendingResolve;return e}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o=0;for(let[,t]of e){let e=a[t],n=a[t+1],r=Number(n-e)/1e6;o+=r}return this.resultBuffer.unmap(),this.lastValue=o,o}catch(e){return console.error(`Error resolving queries:`,e),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(e){console.error(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){console.error(`Error unmapping buffer:`,e)}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}}},mj=class extends Hk{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new oj(this),this.attributeUtils=new uj(this),this.bindingUtils=new dj(this),this.pipelineUtils=new fj(this),this.textureUtils=new BA(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?`compatibility`:void 0},r=typeof navigator<`u`?await navigator.gpu.requestAdapter(e):null;if(r===null)throw Error(`WebGPUBackend: Unable to create WebGPU adapter.`);let i=Object.values(jA),a=[];for(let e of i)r.features.has(e)&&a.push(e);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await r.requestDevice(o)}else n=t.device;n.lost.then(t=>{let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)});let r=t.context===void 0?e.domElement.getContext(`webgpu`):t.context;this.device=n,this.context=r;let i=t.alpha?`premultiplied`:`opaque`;this.trackTimestamp=this.trackTimestamp&&this.hasFeature(jA.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 qn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){let t=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});let n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}let t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=r.descriptors;if(i===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==e.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples){i={},r.descriptors=i;let e=()=>{n.removeEventListener(`dispose`,e),this.delete(n)};n.hasEventListener(`dispose`,e)===!1&&n.addEventListener(`dispose`,e)}let a=e.getCacheKey(),o=i[a];if(o===void 0){let t=e.textures,s=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let i=this.get(t[r]),a={label:`colorAttachment_${r}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:OA.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=OA.ThreeD,a.depthOrArrayLayers=t[r].image.depth;else if(n.isRenderTarget&&t[r].image.depth>1)if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...a,baseArrayLayer:e,arrayLayerCount:1,dimension:OA.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=OA.TwoDArray,a.depthOrArrayLayers=t[r].image.depth;if(l!==!0){let e=i.texture.createView(a),t,n;i.msaaTexture===void 0?(t=e,n=void 0):(t=i.msaaTexture.createView(),n=e),s.push({view:t,resolveTarget:n,depthSlice:c})}}if(o={textureViews:s},e.depth){let t=this.get(e.depthTexture),n={};e.depthTexture.isArrayTexture&&(n.dimension=OA.TwoD,n.arrayLayerCount=1,n.baseArrayLayer=e.activeCubeFace),o.depthStencilView=t.texture.createView(n)}i[a]=o,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace,r.dimensions=n.dimensions}let s={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){let n=o.textureViews[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),s.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||pA.Load,storeOp:t.storeOp||fA.Store,clearValue:r})}return o.depthStencilView&&(s.depthStencilAttachment={view:o.depthStencilView}),s}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:`occlusion`,count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:pA.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(r.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},r.loadOp=pA.Clear):r.loadOp=pA.Load,r.storeOp=fA.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=pA.Clear):t.loadOp=pA.Load,t.storeOp=fA.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=pA.Clear):o.depthLoadOp=pA.Load,o.depthStoreOp=fA.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=pA.Clear):o.stencilLoadOp=pA.Load,o.stencilStoreOp=fA.Store);let s=n.createCommandEncoder({label:`renderContext_`+e.id});if(this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createDepthLayerDescriptors(e,t,a,n):this._updateDepthLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(n),t.bundleSets.push(i)}t.currentPass=null}else{let n=s.beginRenderPass(a);if(t.currentPass=n,e.viewport&&this.updateViewport(e),e.scissor){let{x:t,y:r,width:i,height:a}=e.scissorValue;n.setScissorRect(t,r,i,a)}}t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[o].view}]};if(n.depthStencilAttachment){let t=o;a.viewCache[t]||(a.viewCache[t]=a.texture.createView({dimension:OA.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||pA.Clear,depthStoreOp:i.depthStoreOp||fA.Store,depthClearValue:i.depthClearValue||1},e.stencil&&(r.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,r.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,r.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else r.depthStencilAttachment={...i};t.layerDescriptors.push(r)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=pA.Clear):t.depthLoadOp=pA.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=pA.Clear):t.stencilLoadOp=pA.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));let a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l,u;if(e){let e=this.getClearColor();c={r:e.r,g:e.g,b:e.b,a:e.a}}if(r===null){l=a.depth,u=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=c,e.loadOp=pA.Clear,e.storeOp=fA.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?pA.Clear:pA.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?pA.Clear:pA.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=fA.Store),u&&(i.stencilLoadOp=n?pA.Clear:pA.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=fA.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=pA.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=fA.Store):(s.depthLoadOp=pA.Load,s.depthStoreOp=fA.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=pA.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=fA.Store):(s.stencilLoadOp=pA.Load,s.stencilStoreOp=fA.Store));let d=i.createCommandEncoder({label:`clear`}),f=d.beginRenderPass({colorAttachments:o,depthStencilAttachment:s});f.end(),i.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),n={label:`computeGroup_`+e.id};this.initTimestampQuery(e,n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:`computeGroup_`+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r){let{passEncoderGPU:i}=this.get(e),a=this.get(r).pipeline;this.pipelineUtils.setPipeline(i,a);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);i.setBindGroup(e,r.group)}let o=this.device.limits.maxComputeWorkgroupsPerDimension,s=this.get(t);s.dispatchSize===void 0&&(s.dispatchSize={x:0,y:1,z:1});let{dispatchSize:c}=s;t.dispatchCount>o?(c.x=Math.min(t.dispatchCount,o),c.y=Math.ceil(t.dispatchCount/o)):c.x=t.dispatchCount,i.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){let{object:n,material:r,context:i,pipeline:a}=e,o=e.getBindings(),s=this.get(i),c=this.get(a).pipeline,l=e.getIndex(),u=l!==null,d=e.getDrawParameters();if(d===null)return;let f=(t,n)=>{this.pipelineUtils.setPipeline(t,c),n.pipeline=c;let a=n.bindingGroups;for(let e=0,n=o.length;e<n;e++){let n=o[e],r=this.get(n);a[n.index]!==n.id&&(t.setBindGroup(n.index,r.group),a[n.index]=n.id)}if(u===!0&&n.index!==l){let e=this.get(l).buffer,r=l.array instanceof Uint16Array?gA.Uint16:gA.Uint32;t.setIndexBuffer(e,r),n.index=l}let d=e.getVertexBuffers();for(let e=0,r=d.length;e<r;e++){let r=d[e];if(n.attributes[e]!==r){let i=this.get(r).buffer;t.setVertexBuffer(e,i),n.attributes[e]=r}}i.stencil===!0&&r.stencilWrite===!0&&s.currentStencilRef!==r.stencilRef&&(t.setStencilReference(r.stencilRef),s.currentStencilRef=r.stencilRef)},p=(r,i)=>{if(f(r,i),n.isBatchedMesh===!0){let e=n._multiDrawStarts,i=n._multiDrawCounts,a=n._multiDrawCount,o=n._multiDrawInstances;o!==null&&Mr(`THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`);for(let s=0;s<a;s++){let a=o?o[s]:1,c=a>1?0:s;u===!0?r.drawIndexed(i[s],a,e[s]/l.array.BYTES_PER_ELEMENT,0,c):r.draw(i[s],a,e[s],c),t.update(n,i[s],a)}}else if(u===!0){let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndexedIndirect(e,0)}else r.drawIndexed(i,a,o,0,0);t.update(n,i,a)}else{let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndirect(e,0)}else r.draw(i,a,o,0);t.update(n,i,a)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),r=e.camera.cameras,a=e.getBindingGroup(`cameraIndex`);if(t.indexesGPU===void 0||t.indexesGPU.length!==r.length){let e=this.get(a),n=[],i=new Uint32Array([0,0,0,0]);for(let t=0,a=r.length;t<a;t++){i[0]=t;let r=this.bindingUtils.createBindGroupIndex(i,e.layout);n.push(r)}t.indexesGPU=n}let o=this.renderer.getPixelRatio();for(let e=0,c=r.length;e<c;e++){let c=r[e];if(n.layers.test(c.layers)){let n=c.viewport,r=s.currentPass,l=s.currentSets;if(s.bundleEncoders){let t=s.bundleEncoders[e],n=s.bundleSets[e];r=t,l=n}n&&r.setViewport(Math.floor(n.x*o),Math.floor(n.y*o),Math.floor(n.width*o),Math.floor(n.height*o),i.viewportValue.minDepth,i.viewportValue.maxDepth),a&&t.indexesGPU&&(r.setBindGroup(a.index,t.indexesGPU[e]),l.bindingGroups[a.index]=a.id),p(r,l)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let e=s.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),n.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=n),s.lastOcclusionObject=n)}p(s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;let n=e.isComputeNode?`compute`:`render`;this.timestampQueryPool[n]||(this.timestampQueryPool[n]=new pj(this.device,n,2048));let r=this.timestampQueryPool[n],i=r.allocateQueriesForContext(e);t.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(e,t){return new aj(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===``?``:`_${e.name}`)}),entryPoint:`main`}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass,i=r.finish();this.get(t).bundleGPU=i,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){let n=this.get(e);n.renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0);let h=this.device.createCommandEncoder({label:`copyTextureToTexture_`+e.id+`_`+t.id}),g=this.get(e).texture,_=this.get(t).texture;h.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:l,y:u,z:d}},{texture:_,mipLevel:a,origin:{x:o,y:s,z:c}},[f,p,m]),this.device.queue.submit([h.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){console.error(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):o=this.device.createCommandEncoder({label:`copyFramebufferToTexture_`+e.id}),o.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=pA.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=pA.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=pA.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){let{x:e,y:n,width:i,height:a}=t.scissorValue;r.currentPass.setScissorRect(e,n,i,a)}}else this.device.queue.submit([o.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}},hj=class extends Es{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},gj=class extends Es{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},_j=class extends qO{constructor(){super(),this.addMaterial(yv,`MeshPhongMaterial`),this.addMaterial(hb,`MeshStandardMaterial`),this.addMaterial(_b,`MeshPhysicalMaterial`),this.addMaterial(xb,`MeshToonMaterial`),this.addMaterial(lv,`MeshBasicMaterial`),this.addMaterial(_v,`MeshLambertMaterial`),this.addMaterial(J_,`MeshNormalMaterial`),this.addMaterial(Tb,`MeshMatcapMaterial`),this.addMaterial(z_,`LineBasicMaterial`),this.addMaterial(V_,`LineDashedMaterial`),this.addMaterial(jb,`PointsMaterial`),this.addMaterial(kb,`SpriteMaterial`),this.addMaterial(Pb,`ShadowMaterial`),this.addLight(qT,js),this.addLight(vO,Ps),this.addLight(SO,Is),this.addLight(CO,Es),this.addLight(DO,Fs),this.addLight(OO,bs),this.addLight(kO,Rs),this.addLight(wO,hj),this.addLight(EO,gj),this.addToneMapping(LC,ze),this.addToneMapping(RC,Be),this.addToneMapping(zC,Ve),this.addToneMapping(VC,He),this.addToneMapping(GC,Ue),this.addToneMapping(KC,We)}},vj=class extends gk{constructor(e={}){let t;e.forceWebGL?t=lA:(t=mj,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new lA(e)));let n=new t(e);super(n,e),this.library=new _j,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},yj={};_(yj,{BRDF_GGX:()=>bj,BRDF_Lambert:()=>xj,BasicShadowFilter:()=>Sj,Break:()=>Cj,Const:()=>gte,Continue:()=>wj,DFGApprox:()=>Tj,D_GGX:()=>Ej,Discard:()=>Dj,EPSILON:()=>Oj,F_Schlick:()=>kj,Fn:()=>Aj,INFINITY:()=>jj,If:()=>Mj,Loop:()=>Pj,NodeAccess:()=>Rj,NodeShaderStage:()=>Fj,NodeType:()=>Ij,NodeUpdateType:()=>Lj,PCFShadowFilter:()=>zj,PCFSoftShadowFilter:()=>Bj,PI:()=>Vj,PI2:()=>Hj,Return:()=>Uj,Schlick_to_F0:()=>Wj,ScriptableNodeResources:()=>Gj,ShaderNode:()=>Kj,Switch:()=>Nj,TBNViewMatrix:()=>qj,VSMShadowFilter:()=>Jj,V_GGX_SmithCorrelated:()=>Yj,Var:()=>sF,abs:()=>Xj,acesFilmicToneMapping:()=>Zj,acos:()=>Qj,add:()=>$j,addNodeElement:()=>eM,agxToneMapping:()=>tM,all:()=>nM,alphaT:()=>rM,and:()=>iM,anisotropy:()=>aM,anisotropyB:()=>oM,anisotropyT:()=>sM,any:()=>cM,append:()=>lM,array:()=>uM,arrayBuffer:()=>dM,asin:()=>fM,assign:()=>pM,atan:()=>mM,atan2:()=>hM,atomicAdd:()=>gM,atomicAnd:()=>_M,atomicFunc:()=>vM,atomicLoad:()=>TM,atomicMax:()=>yM,atomicMin:()=>bM,atomicOr:()=>xM,atomicStore:()=>SM,atomicSub:()=>CM,atomicXor:()=>wM,attenuationColor:()=>EM,attenuationDistance:()=>DM,attribute:()=>OM,attributeArray:()=>hee,backgroundBlurriness:()=>gee,backgroundIntensity:()=>_ee,backgroundRotation:()=>vee,batch:()=>yee,billboarding:()=>bee,bitAnd:()=>xee,bitNot:()=>See,bitOr:()=>Cee,bitXor:()=>wee,bitangentGeometry:()=>Tee,bitangentLocal:()=>Eee,bitangentView:()=>Dee,bitangentWorld:()=>Oee,bitcast:()=>kee,blendBurn:()=>Aee,blendColor:()=>jee,blendDodge:()=>Mee,blendOverlay:()=>Nee,blendScreen:()=>Pee,blur:()=>Fee,bool:()=>Iee,buffer:()=>Lee,bufferAttribute:()=>Ree,bumpMap:()=>zee,burn:()=>Bee,bvec2:()=>Vee,bvec3:()=>Hee,bvec4:()=>Uee,bypass:()=>Wee,cache:()=>Gee,call:()=>Kee,cameraFar:()=>qee,cameraIndex:()=>Jee,cameraNear:()=>Yee,cameraNormalMatrix:()=>Xee,cameraPosition:()=>Zee,cameraProjectionMatrix:()=>Qee,cameraProjectionMatrixInverse:()=>$ee,cameraViewMatrix:()=>ete,cameraWorldMatrix:()=>tte,cbrt:()=>nte,cdl:()=>rte,ceil:()=>ite,checker:()=>ate,cineonToneMapping:()=>ote,clamp:()=>kM,clearcoat:()=>ste,clearcoatRoughness:()=>cte,code:()=>lte,color:()=>ute,colorSpaceToWorking:()=>dte,colorToDirection:()=>fte,compute:()=>pte,computeSkinning:()=>mte,cond:()=>hte,context:()=>_te,convert:()=>vte,convertColorSpace:()=>yte,convertToTexture:()=>bte,cos:()=>AM,cross:()=>xte,cubeTexture:()=>Ste,dFdx:()=>Cte,dFdy:()=>wte,dashSize:()=>Tte,debug:()=>Ete,decrement:()=>Dte,decrementBefore:()=>Ote,defaultBuildStages:()=>kte,defaultShaderStages:()=>Ate,defined:()=>jte,degrees:()=>Mte,deltaTime:()=>Nte,densityFog:()=>Pte,densityFogFactor:()=>Fte,depth:()=>Ite,depthPass:()=>Lte,difference:()=>Rte,diffuseColor:()=>zte,directPointLight:()=>Bte,directionToColor:()=>Vte,dispersion:()=>Hte,distance:()=>Ute,div:()=>Wte,dodge:()=>Gte,dot:()=>jM,drawIndex:()=>Kte,dynamicBufferAttribute:()=>qte,element:()=>Jte,emissive:()=>Yte,equal:()=>Xte,equals:()=>Zte,equirectUV:()=>Qte,exp:()=>$te,exp2:()=>ene,expression:()=>tne,faceDirection:()=>nne,faceForward:()=>rne,faceforward:()=>ine,float:()=>MM,floor:()=>NM,fog:()=>ane,fract:()=>PM,frameGroup:()=>one,frameId:()=>sne,frontFacing:()=>cne,fwidth:()=>lne,gain:()=>une,gapSize:()=>dne,getConstNodeType:()=>fne,getCurrentStack:()=>pne,getDirection:()=>mne,getDistanceAttenuation:()=>hne,getGeometryRoughness:()=>gne,getNormalFromDepth:()=>_ne,getParallaxCorrectNormal:()=>vne,getRoughness:()=>yne,getScreenPosition:()=>bne,getShIrradianceAt:()=>xne,getShadowMaterial:()=>wne,getShadowRenderObjectFunction:()=>Tne,getTextureIndex:()=>Sne,getViewPosition:()=>Cne,globalId:()=>gre,glsl:()=>Ene,glslFn:()=>Dne,grayscale:()=>One,greaterThan:()=>kne,greaterThanEqual:()=>Ane,hash:()=>jne,highpModelNormalViewMatrix:()=>Mne,highpModelViewMatrix:()=>Nne,hue:()=>Pne,increment:()=>Fne,incrementBefore:()=>Ine,instance:()=>Lne,instanceIndex:()=>Rne,instancedArray:()=>zne,instancedBufferAttribute:()=>Bne,instancedDynamicBufferAttribute:()=>Vne,instancedMesh:()=>Hne,int:()=>Une,inverseSqrt:()=>Wne,inversesqrt:()=>Gne,invocationLocalIndex:()=>Kne,invocationSubgroupIndex:()=>qne,ior:()=>Jne,iridescence:()=>Yne,iridescenceIOR:()=>Xne,iridescenceThickness:()=>Zne,ivec2:()=>Qne,ivec3:()=>$ne,ivec4:()=>ere,js:()=>tre,label:()=>nre,length:()=>FM,lengthSq:()=>rre,lessThan:()=>ire,lessThanEqual:()=>are,lightPosition:()=>ore,lightProjectionUV:()=>KM,lightShadowMatrix:()=>sre,lightTargetDirection:()=>cre,lightTargetPosition:()=>lre,lightViewPosition:()=>ure,lightingContext:()=>dre,lights:()=>fre,linearDepth:()=>pre,linearToneMapping:()=>mre,localId:()=>hre,log:()=>_re,log2:()=>vre,logarithmicDepthToViewZ:()=>yre,loop:()=>bre,luminance:()=>xre,mat2:()=>Cre,mat3:()=>wre,mat4:()=>Tre,matcapUV:()=>Ere,materialAO:()=>Dre,materialAlphaTest:()=>Ore,materialAnisotropy:()=>kre,materialAnisotropyVector:()=>Are,materialAttenuationColor:()=>jre,materialAttenuationDistance:()=>Mre,materialClearcoat:()=>Nre,materialClearcoatNormal:()=>Pre,materialClearcoatRoughness:()=>Fre,materialColor:()=>Ire,materialDispersion:()=>Lre,materialEmissive:()=>Rre,materialIOR:()=>zre,materialIridescence:()=>Bre,materialIridescenceIOR:()=>Vre,materialIridescenceThickness:()=>Hre,materialLightMap:()=>Ure,materialLineDashOffset:()=>Wre,materialLineDashSize:()=>Gre,materialLineGapSize:()=>Kre,materialLineScale:()=>qre,materialLineWidth:()=>Jre,materialMetalness:()=>Yre,materialNormal:()=>Xre,materialOpacity:()=>Zre,materialPointSize:()=>Qre,materialReference:()=>$re,materialReflectivity:()=>eie,materialRefractionRatio:()=>tie,materialRotation:()=>nie,materialRoughness:()=>rie,materialSheen:()=>iie,materialSheenRoughness:()=>aie,materialShininess:()=>oie,materialSpecular:()=>sie,materialSpecularColor:()=>cie,materialSpecularIntensity:()=>lie,materialSpecularStrength:()=>uie,materialThickness:()=>die,materialTransmission:()=>fie,max:()=>IM,maxMipLevel:()=>pie,mediumpModelViewMatrix:()=>Sre,metalness:()=>mie,min:()=>hie,mix:()=>LM,mixElement:()=>gie,mod:()=>_ie,modInt:()=>vie,modelDirection:()=>yie,modelNormalMatrix:()=>bie,modelPosition:()=>xie,modelRadius:()=>Sie,modelScale:()=>Cie,modelViewMatrix:()=>wie,modelViewPosition:()=>Tie,modelViewProjection:()=>Eie,modelWorldMatrix:()=>Die,modelWorldMatrixInverse:()=>Oie,morphReference:()=>kie,mrt:()=>Aie,mul:()=>RM,mx_aastep:()=>jie,mx_cell_noise_float:()=>Mie,mx_contrast:()=>Nie,mx_fractal_noise_float:()=>Pie,mx_fractal_noise_vec2:()=>Fie,mx_fractal_noise_vec3:()=>Iie,mx_fractal_noise_vec4:()=>Lie,mx_hsvtorgb:()=>Rie,mx_noise_float:()=>zie,mx_noise_vec3:()=>Bie,mx_noise_vec4:()=>Vie,mx_ramplr:()=>Hie,mx_ramptb:()=>Uie,mx_rgbtohsv:()=>Wie,mx_safepower:()=>Gie,mx_splitlr:()=>Kie,mx_splittb:()=>qie,mx_srgb_texture_to_lin_rec709:()=>Jie,mx_transform_uv:()=>Yie,mx_worley_noise_float:()=>Xie,mx_worley_noise_vec2:()=>Zie,mx_worley_noise_vec3:()=>Qie,namespace:()=>$ie,negate:()=>eae,neutralToneMapping:()=>tae,nodeArray:()=>nae,nodeImmutable:()=>rae,nodeObject:()=>iae,nodeObjects:()=>aae,nodeProxy:()=>oae,normalFlat:()=>sae,normalGeometry:()=>cae,normalLocal:()=>lae,normalMap:()=>uae,normalView:()=>dae,normalWorld:()=>fae,normalize:()=>pae,not:()=>mae,notEqual:()=>hae,numWorkgroups:()=>gae,objectDirection:()=>_ae,objectGroup:()=>vae,objectPosition:()=>yae,objectRadius:()=>bae,objectScale:()=>xae,objectViewPosition:()=>Sae,objectWorldMatrix:()=>Cae,oneMinus:()=>wae,or:()=>Tae,orthographicDepthToViewZ:()=>Eae,oscSawtooth:()=>Dae,oscSine:()=>Oae,oscSquare:()=>kae,oscTriangle:()=>Aae,output:()=>jae,outputStruct:()=>Mae,overlay:()=>Nae,overloadingFn:()=>Pae,parabola:()=>Fae,parallaxDirection:()=>Iae,parallaxUV:()=>Lae,parameter:()=>Rae,pass:()=>zae,passTexture:()=>Bae,pcurve:()=>Vae,perspectiveDepthToViewZ:()=>Hae,pmremTexture:()=>Uae,pointShadow:()=>AN,pointUV:()=>Wae,pointWidth:()=>Gae,positionGeometry:()=>Kae,positionLocal:()=>qae,positionPrevious:()=>Jae,positionView:()=>Yae,positionViewDirection:()=>Xae,positionWorld:()=>Zae,positionWorldDirection:()=>Qae,posterize:()=>$ae,pow:()=>zM,pow2:()=>eoe,pow3:()=>toe,pow4:()=>noe,premult:()=>roe,property:()=>ioe,radians:()=>BM,rand:()=>VM,range:()=>HM,rangeFog:()=>UM,rangeFogFactor:()=>WM,reciprocal:()=>GM,reference:()=>qM,referenceBuffer:()=>JM,reflect:()=>YM,reflectVector:()=>XM,reflectView:()=>ZM,reflector:()=>QM,refract:()=>$M,refractVector:()=>eN,refractView:()=>tN,reinhardToneMapping:()=>nN,remainder:()=>rN,remap:()=>iN,remapClamp:()=>aN,renderGroup:()=>oN,renderOutput:()=>sN,rendererReference:()=>cN,rotate:()=>lN,rotateUV:()=>uN,roughness:()=>dN,round:()=>fN,rtt:()=>pN,sRGBTransferEOTF:()=>mN,sRGBTransferOETF:()=>hN,sampler:()=>gN,samplerComparison:()=>_N,saturate:()=>vN,saturation:()=>yN,screen:()=>bN,screenCoordinate:()=>xN,screenSize:()=>SN,screenUV:()=>CN,scriptable:()=>wN,scriptableValue:()=>TN,select:()=>EN,setCurrentStack:()=>DN,shaderStages:()=>ON,shadow:()=>kN,shadowPositionWorld:()=>jN,shapeCircle:()=>NN,sharedUniformGroup:()=>MN,sheen:()=>PN,sheenRoughness:()=>FN,shiftLeft:()=>IN,shiftRight:()=>LN,shininess:()=>RN,sign:()=>zN,sin:()=>BN,sinc:()=>VN,skinning:()=>HN,smoothstep:()=>UN,smoothstepElement:()=>WN,specularColor:()=>GN,specularF90:()=>KN,spherizeUV:()=>qN,split:()=>JN,spritesheetUV:()=>YN,sqrt:()=>XN,stack:()=>ZN,step:()=>QN,storage:()=>$N,storageBarrier:()=>eP,storageObject:()=>tP,storageTexture:()=>nP,string:()=>rP,struct:()=>iP,sub:()=>aP,subgroupIndex:()=>oP,subgroupSize:()=>sP,tan:()=>cP,tangentGeometry:()=>lP,tangentLocal:()=>uP,tangentView:()=>dP,tangentWorld:()=>fP,temp:()=>pP,texture:()=>mP,texture3D:()=>hP,textureBarrier:()=>gP,textureBicubic:()=>_P,textureCubeUV:()=>vP,textureLoad:()=>yP,textureSize:()=>bP,textureStore:()=>xP,thickness:()=>SP,time:()=>CP,timerDelta:()=>wP,timerGlobal:()=>TP,timerLocal:()=>EP,toneMapping:()=>DP,toneMappingExposure:()=>OP,toonOutlinePass:()=>kP,transformDirection:()=>AP,transformNormal:()=>jP,transformNormalToView:()=>MP,transformedBentNormalView:()=>NP,transformedBitangentView:()=>PP,transformedBitangentWorld:()=>FP,transformedClearcoatNormalView:()=>IP,transformedNormalView:()=>LP,transformedNormalWorld:()=>RP,transformedTangentView:()=>zP,transformedTangentWorld:()=>BP,transmission:()=>VP,transpose:()=>HP,triNoise3D:()=>UP,triplanarTexture:()=>WP,triplanarTextures:()=>GP,trunc:()=>KP,tslFn:()=>qP,uint:()=>JP,uniform:()=>YP,uniformArray:()=>ZP,uniformCubeTexture:()=>XP,uniformGroup:()=>QP,uniformTexture:()=>$P,uniforms:()=>eF,unpremult:()=>tF,userData:()=>nF,uv:()=>rF,uvec2:()=>iF,uvec3:()=>aF,uvec4:()=>oF,varying:()=>cF,varyingProperty:()=>lF,vec2:()=>uF,vec3:()=>dF,vec4:()=>fF,vectorComponents:()=>pF,velocity:()=>mF,vertexColor:()=>hF,vertexIndex:()=>gF,vibrance:()=>_F,viewZToLogarithmicDepth:()=>vF,viewZToOrthographicDepth:()=>yF,viewZToPerspectiveDepth:()=>bF,viewport:()=>xF,viewportBottomLeft:()=>SF,viewportCoordinate:()=>CF,viewportDepthTexture:()=>wF,viewportLinearDepth:()=>TF,viewportMipTexture:()=>EF,viewportResolution:()=>DF,viewportSafeUV:()=>OF,viewportSharedTexture:()=>kF,viewportSize:()=>AF,viewportTexture:()=>jF,viewportTopLeft:()=>MF,viewportUV:()=>NF,wgsl:()=>PF,wgslFn:()=>FF,workgroupArray:()=>IF,workgroupBarrier:()=>LF,workgroupId:()=>RF,workingToColorSpace:()=>zF,xor:()=>BF});const bj=I.BRDF_GGX,xj=I.BRDF_Lambert,Sj=I.BasicShadowFilter,Cj=I.Break,wj=I.Continue,Tj=I.DFGApprox,Ej=I.D_GGX,Dj=I.Discard,Oj=I.EPSILON,kj=I.F_Schlick,Aj=I.Fn,jj=I.INFINITY,Mj=I.If,Nj=I.Switch,Pj=I.Loop,Fj=I.NodeShaderStage,Ij=I.NodeType,Lj=I.NodeUpdateType,Rj=I.NodeAccess,zj=I.PCFShadowFilter,Bj=I.PCFSoftShadowFilter,Vj=I.PI,Hj=I.PI2,Uj=I.Return,Wj=I.Schlick_to_F0,Gj=I.ScriptableNodeResources,Kj=I.ShaderNode,qj=I.TBNViewMatrix,Jj=I.VSMShadowFilter,Yj=I.V_GGX_SmithCorrelated,Xj=I.abs,Zj=I.acesFilmicToneMapping,Qj=I.acos,$j=I.add,eM=I.addNodeElement,tM=I.agxToneMapping,nM=I.all,rM=I.alphaT,iM=I.and,aM=I.anisotropy,oM=I.anisotropyB,sM=I.anisotropyT,cM=I.any,lM=I.append,uM=I.array,dM=I.arrayBuffer,fM=I.asin,pM=I.assign,mM=I.atan,hM=I.atan2,gM=I.atomicAdd,_M=I.atomicAnd,vM=I.atomicFunc,yM=I.atomicMax,bM=I.atomicMin,xM=I.atomicOr,SM=I.atomicStore,CM=I.atomicSub,wM=I.atomicXor,TM=I.atomicLoad,EM=I.attenuationColor,DM=I.attenuationDistance,OM=I.attribute,hee=I.attributeArray,gee=I.backgroundBlurriness,_ee=I.backgroundIntensity,vee=I.backgroundRotation,yee=I.batch,bee=I.billboarding,xee=I.bitAnd,See=I.bitNot,Cee=I.bitOr,wee=I.bitXor,Tee=I.bitangentGeometry,Eee=I.bitangentLocal,Dee=I.bitangentView,Oee=I.bitangentWorld,kee=I.bitcast,Aee=I.blendBurn,jee=I.blendColor,Mee=I.blendDodge,Nee=I.blendOverlay,Pee=I.blendScreen,Fee=I.blur,Iee=I.bool,Lee=I.buffer,Ree=I.bufferAttribute,zee=I.bumpMap,Bee=I.burn,Vee=I.bvec2,Hee=I.bvec3,Uee=I.bvec4,Wee=I.bypass,Gee=I.cache,Kee=I.call,qee=I.cameraFar,Jee=I.cameraIndex,Yee=I.cameraNear,Xee=I.cameraNormalMatrix,Zee=I.cameraPosition,Qee=I.cameraProjectionMatrix,$ee=I.cameraProjectionMatrixInverse,ete=I.cameraViewMatrix,tte=I.cameraWorldMatrix,nte=I.cbrt,rte=I.cdl,ite=I.ceil,ate=I.checker,ote=I.cineonToneMapping,kM=I.clamp,ste=I.clearcoat,cte=I.clearcoatRoughness,lte=I.code,ute=I.color,dte=I.colorSpaceToWorking,fte=I.colorToDirection,pte=I.compute,mte=I.computeSkinning,hte=I.cond,gte=I.Const,_te=I.context,vte=I.convert,yte=I.convertColorSpace,bte=I.convertToTexture,AM=I.cos,xte=I.cross,Ste=I.cubeTexture,Cte=I.dFdx,wte=I.dFdy,Tte=I.dashSize,Ete=I.debug,Dte=I.decrement,Ote=I.decrementBefore,kte=I.defaultBuildStages,Ate=I.defaultShaderStages,jte=I.defined,Mte=I.degrees,Nte=I.deltaTime,Pte=I.densityFog,Fte=I.densityFogFactor,Ite=I.depth,Lte=I.depthPass,Rte=I.difference,zte=I.diffuseColor,Bte=I.directPointLight,Vte=I.directionToColor,Hte=I.dispersion,Ute=I.distance,Wte=I.div,Gte=I.dodge,jM=I.dot,Kte=I.drawIndex,qte=I.dynamicBufferAttribute,Jte=I.element,Yte=I.emissive,Xte=I.equal,Zte=I.equals,Qte=I.equirectUV,$te=I.exp,ene=I.exp2,tne=I.expression,nne=I.faceDirection,rne=I.faceForward,ine=I.faceforward,MM=I.float,NM=I.floor,ane=I.fog,PM=I.fract,one=I.frameGroup,sne=I.frameId,cne=I.frontFacing,lne=I.fwidth,une=I.gain,dne=I.gapSize,fne=I.getConstNodeType,pne=I.getCurrentStack,mne=I.getDirection,hne=I.getDistanceAttenuation,gne=I.getGeometryRoughness,_ne=I.getNormalFromDepth,vne=I.getParallaxCorrectNormal,yne=I.getRoughness,bne=I.getScreenPosition,xne=I.getShIrradianceAt,Sne=I.getTextureIndex,Cne=I.getViewPosition,wne=I.getShadowMaterial,Tne=I.getShadowRenderObjectFunction,Ene=I.glsl,Dne=I.glslFn,One=I.grayscale,kne=I.greaterThan,Ane=I.greaterThanEqual,jne=I.hash,Mne=I.highpModelNormalViewMatrix,Nne=I.highpModelViewMatrix,Pne=I.hue,Fne=I.increment,Ine=I.incrementBefore,Lne=I.instance,Rne=I.instanceIndex,zne=I.instancedArray,Bne=I.instancedBufferAttribute,Vne=I.instancedDynamicBufferAttribute,Hne=I.instancedMesh,Une=I.int,Wne=I.inverseSqrt,Gne=I.inversesqrt,Kne=I.invocationLocalIndex,qne=I.invocationSubgroupIndex,Jne=I.ior,Yne=I.iridescence,Xne=I.iridescenceIOR,Zne=I.iridescenceThickness,Qne=I.ivec2,$ne=I.ivec3,ere=I.ivec4,tre=I.js,nre=I.label,FM=I.length,rre=I.lengthSq,ire=I.lessThan,are=I.lessThanEqual,ore=I.lightPosition,sre=I.lightShadowMatrix,cre=I.lightTargetDirection,lre=I.lightTargetPosition,ure=I.lightViewPosition,dre=I.lightingContext,fre=I.lights,pre=I.linearDepth,mre=I.linearToneMapping,hre=I.localId,gre=I.globalId,_re=I.log,vre=I.log2,yre=I.logarithmicDepthToViewZ,bre=I.loop,xre=I.luminance,Sre=I.mediumpModelViewMatrix,Cre=I.mat2,wre=I.mat3,Tre=I.mat4,Ere=I.matcapUV,Dre=I.materialAO,Ore=I.materialAlphaTest,kre=I.materialAnisotropy,Are=I.materialAnisotropyVector,jre=I.materialAttenuationColor,Mre=I.materialAttenuationDistance,Nre=I.materialClearcoat,Pre=I.materialClearcoatNormal,Fre=I.materialClearcoatRoughness,Ire=I.materialColor,Lre=I.materialDispersion,Rre=I.materialEmissive,zre=I.materialIOR,Bre=I.materialIridescence,Vre=I.materialIridescenceIOR,Hre=I.materialIridescenceThickness,Ure=I.materialLightMap,Wre=I.materialLineDashOffset,Gre=I.materialLineDashSize,Kre=I.materialLineGapSize,qre=I.materialLineScale,Jre=I.materialLineWidth,Yre=I.materialMetalness,Xre=I.materialNormal,Zre=I.materialOpacity,Qre=I.materialPointSize,$re=I.materialReference,eie=I.materialReflectivity,tie=I.materialRefractionRatio,nie=I.materialRotation,rie=I.materialRoughness,iie=I.materialSheen,aie=I.materialSheenRoughness,oie=I.materialShininess,sie=I.materialSpecular,cie=I.materialSpecularColor,lie=I.materialSpecularIntensity,uie=I.materialSpecularStrength,die=I.materialThickness,fie=I.materialTransmission,IM=I.max,pie=I.maxMipLevel,mie=I.metalness,hie=I.min,LM=I.mix,gie=I.mixElement,_ie=I.mod,vie=I.modInt,yie=I.modelDirection,bie=I.modelNormalMatrix,xie=I.modelPosition,Sie=I.modelRadius,Cie=I.modelScale,wie=I.modelViewMatrix,Tie=I.modelViewPosition,Eie=I.modelViewProjection,Die=I.modelWorldMatrix,Oie=I.modelWorldMatrixInverse,kie=I.morphReference,Aie=I.mrt,RM=I.mul,jie=I.mx_aastep,Mie=I.mx_cell_noise_float,Nie=I.mx_contrast,Pie=I.mx_fractal_noise_float,Fie=I.mx_fractal_noise_vec2,Iie=I.mx_fractal_noise_vec3,Lie=I.mx_fractal_noise_vec4,Rie=I.mx_hsvtorgb,zie=I.mx_noise_float,Bie=I.mx_noise_vec3,Vie=I.mx_noise_vec4,Hie=I.mx_ramplr,Uie=I.mx_ramptb,Wie=I.mx_rgbtohsv,Gie=I.mx_safepower,Kie=I.mx_splitlr,qie=I.mx_splittb,Jie=I.mx_srgb_texture_to_lin_rec709,Yie=I.mx_transform_uv,Xie=I.mx_worley_noise_float,Zie=I.mx_worley_noise_vec2,Qie=I.mx_worley_noise_vec3,$ie=I.namespace,eae=I.negate,tae=I.neutralToneMapping,nae=I.nodeArray,rae=I.nodeImmutable,iae=I.nodeObject,aae=I.nodeObjects,oae=I.nodeProxy,sae=I.normalFlat,cae=I.normalGeometry,lae=I.normalLocal,uae=I.normalMap,dae=I.normalView,fae=I.normalWorld,pae=I.normalize,mae=I.not,hae=I.notEqual,gae=I.numWorkgroups,_ae=I.objectDirection,vae=I.objectGroup,yae=I.objectPosition,bae=I.objectRadius,xae=I.objectScale,Sae=I.objectViewPosition,Cae=I.objectWorldMatrix,wae=I.oneMinus,Tae=I.or,Eae=I.orthographicDepthToViewZ,Dae=I.oscSawtooth,Oae=I.oscSine,kae=I.oscSquare,Aae=I.oscTriangle,jae=I.output,Mae=I.outputStruct,Nae=I.overlay,Pae=I.overloadingFn,Fae=I.parabola,Iae=I.parallaxDirection,Lae=I.parallaxUV,Rae=I.parameter,zae=I.pass,Bae=I.passTexture,Vae=I.pcurve,Hae=I.perspectiveDepthToViewZ,Uae=I.pmremTexture,Wae=I.pointUV,Gae=I.pointWidth,Kae=I.positionGeometry,qae=I.positionLocal,Jae=I.positionPrevious,Yae=I.positionView,Xae=I.positionViewDirection,Zae=I.positionWorld,Qae=I.positionWorldDirection,$ae=I.posterize,zM=I.pow,eoe=I.pow2,toe=I.pow3,noe=I.pow4,roe=I.premult,ioe=I.property,BM=I.radians,VM=I.rand,HM=I.range,UM=I.rangeFog,WM=I.rangeFogFactor,GM=I.reciprocal,KM=I.lightProjectionUV,qM=I.reference,JM=I.referenceBuffer,YM=I.reflect,XM=I.reflectVector,ZM=I.reflectView,QM=I.reflector,$M=I.refract,eN=I.refractVector,tN=I.refractView,nN=I.reinhardToneMapping,rN=I.remainder,iN=I.remap,aN=I.remapClamp,oN=I.renderGroup,sN=I.renderOutput,cN=I.rendererReference,lN=I.rotate,uN=I.rotateUV,dN=I.roughness,fN=I.round,pN=I.rtt,mN=I.sRGBTransferEOTF,hN=I.sRGBTransferOETF,gN=I.sampler,_N=I.samplerComparison,vN=I.saturate,yN=I.saturation,bN=I.screen,xN=I.screenCoordinate,SN=I.screenSize,CN=I.screenUV,wN=I.scriptable,TN=I.scriptableValue,EN=I.select,DN=I.setCurrentStack,ON=I.shaderStages,kN=I.shadow,AN=I.pointShadow,jN=I.shadowPositionWorld,MN=I.sharedUniformGroup,NN=I.shapeCircle,PN=I.sheen,FN=I.sheenRoughness,IN=I.shiftLeft,LN=I.shiftRight,RN=I.shininess,zN=I.sign,BN=I.sin,VN=I.sinc,HN=I.skinning,UN=I.smoothstep,WN=I.smoothstepElement,GN=I.specularColor,KN=I.specularF90,qN=I.spherizeUV,JN=I.split,YN=I.spritesheetUV,XN=I.sqrt,ZN=I.stack,QN=I.step,$N=I.storage,eP=I.storageBarrier,tP=I.storageObject,nP=I.storageTexture,rP=I.string,iP=I.struct,aP=I.sub,oP=I.subgroupIndex,sP=I.subgroupSize,cP=I.tan,lP=I.tangentGeometry,uP=I.tangentLocal,dP=I.tangentView,fP=I.tangentWorld,pP=I.temp,mP=I.texture,hP=I.texture3D,gP=I.textureBarrier,_P=I.textureBicubic,vP=I.textureCubeUV,yP=I.textureLoad,bP=I.textureSize,xP=I.textureStore,SP=I.thickness,CP=I.time,wP=I.timerDelta,TP=I.timerGlobal,EP=I.timerLocal,DP=I.toneMapping,OP=I.toneMappingExposure,kP=I.toonOutlinePass,AP=I.transformDirection,jP=I.transformNormal,MP=I.transformNormalToView,NP=I.transformedBentNormalView,PP=I.transformedBitangentView,FP=I.transformedBitangentWorld,IP=I.transformedClearcoatNormalView,LP=I.transformedNormalView,RP=I.transformedNormalWorld,zP=I.transformedTangentView,BP=I.transformedTangentWorld,VP=I.transmission,HP=I.transpose,UP=I.triNoise3D,WP=I.triplanarTexture,GP=I.triplanarTextures,KP=I.trunc,qP=I.tslFn,JP=I.uint,YP=I.uniform,XP=I.uniformCubeTexture,ZP=I.uniformArray,QP=I.uniformGroup,$P=I.uniformTexture,eF=I.uniforms,tF=I.unpremult,nF=I.userData,rF=I.uv,iF=I.uvec2,aF=I.uvec3,oF=I.uvec4,sF=I.Var,cF=I.varying,lF=I.varyingProperty,uF=I.vec2,dF=I.vec3,fF=I.vec4,pF=I.vectorComponents,mF=I.velocity,hF=I.vertexColor,gF=I.vertexIndex,_F=I.vibrance,vF=I.viewZToLogarithmicDepth,yF=I.viewZToOrthographicDepth,bF=I.viewZToPerspectiveDepth,xF=I.viewport,SF=I.viewportBottomLeft,CF=I.viewportCoordinate,wF=I.viewportDepthTexture,TF=I.viewportLinearDepth,EF=I.viewportMipTexture,DF=I.viewportResolution,OF=I.viewportSafeUV,kF=I.viewportSharedTexture,AF=I.viewportSize,jF=I.viewportTexture,MF=I.viewportTopLeft,NF=I.viewportUV,PF=I.wgsl,FF=I.wgslFn,IF=I.workgroupArray,LF=I.workgroupBarrier,RF=I.workgroupId,zF=I.workingToColorSpace,BF=I.xor;function VF(e,t,n=1){let r=e.rgb,i=t.rgb,a=RM(r,i),o=RM(t.a,n),s=LM(r,a,o),c=IM(e.a,RM(t.a,n));return fF(s,c)}function HF(e,t,n=1){let r=RM(t.a,n),i=$j(r,RM(e.a,aP(1,r))),a=$j(RM(t.rgb,r),RM(e.rgb,RM(e.a,aP(1,r))));return fF(a,i)}const UF={normal:HF,multiply:VF};function WF(e,t,n=`normal`,r=1){let i=UF[n]||UF.normal;return i(e,t,r)}function GF(e,t){let n=RM(e.a,t.a);return fF(e.rgb,n)}function KF(e,t){let n=aP(1,t.a),r=RM(e.a,n);return fF(e.rgb,r)}function qF(e,t){let n=dF(.2126,.7152,.0722),r=jM(t.rgb,n),i=RM(e.a,r);return fF(e.rgb,i)}function JF(e,t){let n=dF(.2126,.7152,.0722),r=jM(t.rgb,n),i=aP(1,r),a=RM(e.a,i);return fF(e.rgb,a)}const YF={alpha:GF,alphaInverted:KF,luminance:qF,luminanceInverted:JF};function XF(e,t,n=`alpha`){let r=YF[n]||YF.alpha;return r(e,t)}const ZF={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let QF=null,$F=!1;const eI=()=>{try{if(ZF!==void 0){let{MODE:e,DEV:t}=ZF;return t||e===`development`}if(typeof window<`u`&&window.location){let e=window.location.hostname;return e===`localhost`||e===`127.0.0.1`||e.endsWith(`.local`)||e.includes(`dev.`)||e.startsWith(`dev-`)}return!1}catch{return!1}};function tI(){let e,t,n,r,i,a={nodes:new Map,rootId:null,idToNodeId:new Map},o=null,s=null,c=null,l=!1,u=!1,d=null,f=!1,p=!0,m=0,h=0,g=0,_=0,v=8,y=.5,b=.5,x=!1,S=!1,ee=()=>{var e,t,n;return(e=t=(n=window).matchMedia)?.call(n,`(prefers-reduced-motion: reduce)`).matches??!1},te=(n,i)=>{if(n===m&&i===h)return;let o=performance.now();if(o-g<v)return;m=n,h=i,g=o,e.setSize(n,i,!1);let s=n/i,c=2,l=c*s;t.left=-l/2,t.right=l/2,t.top=c/2,t.bottom=-c/2,t.updateProjectionMatrix(),r.scale.set(l,c,1),a.rootId&&ie(),ge().catch(console.warn)},ne=n=>{if(!e||!t||!r)return;let i=n[0];if(!i)return;let{width:a,height:o}=i.contentRect,s=Math.round(a),c=Math.round(o);te(s,c)},re=e=>{let t=e[0];t&&(f=t.isIntersecting,f&&p?_e():ve())},ie=()=>{if(!a.rootId||!i||S)return;let e=a.nodes.get(a.rootId);if(e){S=!0;try{let e=le(a.rootId);e&&i&&(i.fragmentNode=e,i.needsUpdate=!0)}catch(e){console.error(`Error composing shader tree:`,e)}finally{S=!1}f&&ge()}},ae=e=>{let t=[];return a.nodes.forEach(n=>{n.parentId===e&&t.push(n)}),t},oe=e=>{for(let[t,n]of a.nodes.entries())if(n.metadata.id===e)return t;return null},se=(e,t,n,r)=>{var i,a;if(!(i=a=t.metadata.mask)?.source)return e;let o=t.metadata.mask.source,s=oe(o);if(!s)return e;if(r.has(s))return console.error(`Uh oh, looks like you've got a circular dependency in your shader masks.`),e;let c=new Set(r);c.add(n);let l=le(s,c),u=t.metadata.mask.type||`alpha`;return XF(e,l,u)},ce=e=>{var t,n;let r=a.nodes.get(e);if(!r||!r.metadata.id)return!1;let i=r.metadata.id;for(let e of a.nodes.values())if((t=n=e.metadata.mask)?.source===i)return!0;return!1},le=(e,t=new Set)=>{let n=a.nodes.get(e);if(!n)return fF(0,0,0,0);let r=e=>{n.cleanupCallbacks.push(e)},i=e=>{n.beforeRenderCallbacks.push(e)},o=e=>{n.afterRenderCallbacks.push(e)},s=ae(e);if(s.length===0){let a=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:void 0,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:QF});return se(a,n,e,t)}else{let a=[...s].sort((e,t)=>e.metadata.renderOrder-t.metadata.renderOrder),c=n.parentId===null;if(c){let s;for(let e of a){if(e.metadata.opacity===0&&!ce(e.id))continue;let n=le(e.id,t),r=ce(e.id)?0:e.metadata.opacity;s=s===void 0?n:WF(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:QF});return se(c,n,e,t)}else{let s;for(let e of a){let n=le(e.id,t);if(e.metadata.opacity===0&&!ce(e.id))continue;let r=ce(e.id)?0:e.metadata.opacity;s=s===void 0?n:WF(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:QF});return se(c,n,e,t)}}},ue=(e,t,n,r,o={})=>{let s=0;if(n!==null){let e=Array.from(a.nodes.values()).filter(e=>e.parentId===n);e.length>0&&(s=Math.max(...e.map(e=>e.metadata.renderOrder))+1)}let c={id:e,fragmentNodeFunc:t,parentId:n,metadata:{blendMode:r?.blendMode||`normal`,opacity:r?.opacity===void 0?1:r?.opacity,id:r?.id,mask:r?.mask,renderOrder:r?.renderOrder===void 0?s:r?.renderOrder},uniforms:o,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};a.nodes.set(e,c),n===null&&(a.rootId=e),i&&l&&ie()},de=(e,t,n)=>{let r=a.nodes.get(e);if(!r||!r.uniforms){console.warn(`Node or uniforms not found for ID: ${e}`);return}let i=r.uniforms[t];if(!i||!i.uniform){console.warn(`Uniform ${t} not found in node: ${e}`);return}i.uniform.value=n,f&&ge()},fe=(e,t)=>{var n,r,o,s,c,u,d,p;let m=a.nodes.get(e);if(!m)return;let h=!1;t.blendMode!==void 0&&m.metadata.blendMode!==t.blendMode&&(m.metadata.blendMode=t.blendMode,h=!0),t.opacity!==void 0&&m.metadata.opacity!==t.opacity&&(m.metadata.opacity=t.opacity,h=!0),t.renderOrder!==void 0&&m.metadata.renderOrder!==t.renderOrder&&(m.metadata.renderOrder=t.renderOrder,h=!0),t.id!==void 0&&m.metadata.id!==t.id&&(m.metadata.id=t.id,h=!0),t.mask!==void 0&&((n=c=m.metadata.mask)?.source!==(r=u=t.mask)?.source||(o=d=m.metadata.mask)?.type!==(s=p=t.mask)?.type)&&(m.metadata.mask=t.mask,h=!0),h&&i&&l?ie():f&&ge()},pe=e=>{if(!a.nodes.has(e))return;let t=a.nodes.get(e);if(t&&t.cleanupCallbacks.length>0)for(let n of t.cleanupCallbacks)try{n()}catch(t){console.error(`Error executing cleanup callback for node ${e}:`,t)}let n=ae(e);for(let e of n)pe(e.id);a.rootId===e&&(a.rootId=null),a.nodes.delete(e),i&&l&&ie()},me=e=>{let t={deltaTime:e,pointer:{x:y,y:b},pointerActive:x,dimensions:{width:m,height:h}};for(let e of a.nodes.values())if(e.beforeRenderCallbacks.length>0)for(let n of e.beforeRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing before render callback for node ${e.id}:`,t)}},he=e=>{let t={deltaTime:e,pointer:{x:y,y:b},pointerActive:x,dimensions:{width:m,height:h}};for(let e of a.nodes.values())if(e.afterRenderCallbacks.length>0)for(let n of e.afterRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing after render callback for node ${e.id}:`,t)}},ge=async()=>{if(!l||!e||!n||!t||!i)return;let r=performance.now(),a=_>0?(r-_)/1e3:.016,o=Math.min(a,.1);_=r,me(o);try{if(S)return;e instanceof vj?await e.renderAsync(n,t).then(()=>{l&&he(o)}).catch(e=>{console.error(`WebGPU render error:`,e)}):(e.render(n,t),he(o))}catch(e){console.error(`Render frame error:`,e)}},_e=()=>{if(o||!p||!f)return;let e=()=>{o=requestAnimationFrame(e),ge()};e()},ve=()=>{o&&(cancelAnimationFrame(o),o=null)},ye=e=>{if(!QF)return;let t,n;if(`touches`in e){if(e.touches.length===0)return;t=e.touches[0].clientX,n=e.touches[0].clientY}else t=e.clientX,n=e.clientY;let r=QF.getBoundingClientRect(),i=(t-r.left)/r.width,a=(n-r.top)/r.height;y=Math.max(0,Math.min(1,i)),b=Math.max(0,Math.min(1,a))},be=async({canvas:o})=>{if(l||u)return;u=!0,d=new AbortController;let m=d;try{if(QF=o,n=new xo,n.background=null,t=new Ms(-1,1,1,-1,.1,10),t.position.z=1,t.lookAt(0,0,0),o.addEventListener(`mousemove`,ye),o.addEventListener(`touchmove`,ye),o.addEventListener(`mousedown`,()=>{x=!0,ge()}),o.addEventListener(`touchstart`,()=>{x=!0,ge()}),window.addEventListener(`mouseup`,()=>{x=!1,ge()}),window.addEventListener(`touchend`,()=>{x=!1,ge()}),m.signal.aborted)return;try{if(e=new vj({canvas:o,antialias:!0,alpha:!0,depth:!1,powerPreference:`high-performance`}),await e.init(),m.signal.aborted){e.dispose();return}}catch(e){if(m.signal.aborted)return;console.error(`[Shaders] WebGPU initialization error:`,e);return}if(m.signal.aborted){e&&e.dispose();return}e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.outputColorSpace=gn,i=new lv({transparent:!0}),a.nodes.size===0?i.fragmentNode=fF(0,0,0,0):ie();let u=new Uo(2,2);r=new Qa(u,i),n.add(r),s=new ResizeObserver(ne),s.observe(o),c=new IntersectionObserver(re,{threshold:0}),c.observe(o),p=!ee();let{width:d,height:h}=o.getBoundingClientRect();te(Math.round(d),Math.round(h)),await ge(),p&&f&&_e(),m.signal.aborted||(l=!0)}catch(e){console.error(`[Shaders] Initialization error:`,e)}finally{u=!1,d===m&&(d=null)}},xe=()=>{!eI()||$F||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),$F=!0)},Se=()=>{if(d&&d.abort(),s&&(s.disconnect(),s=null),c&&(c.disconnect(),c=null),QF&&(QF.removeEventListener(`mousemove`,ye),QF.removeEventListener(`touchmove`,ye),QF.removeEventListener(`mousedown`,()=>{x=!0}),QF.removeEventListener(`touchstart`,()=>{x=!0})),window&&(window.removeEventListener(`mouseup`,()=>{x=!1}),window.removeEventListener(`touchend`,()=>{x=!1})),ve(),a.nodes.clear(),a.rootId=null,a.idToNodeId.clear(),r&&(n&&n.remove(r),r.geometry&&r.geometry.dispose(),r.material instanceof ya&&r.material.dispose()),e)try{e.dispose()}catch(e){console.warn(`Error disposing renderer:`,e)}QF=null,e=null,t=null,n=null,r=null,i=null,l=!1,u=!1,d=null,m=0,h=0,f=!1,p=!0,y=.5,b=.5,x=!1};return{initialize:be,cleanup:Se,registerNode:ue,removeNode:pe,updateUniformValue:de,updateNodeMetadata:fe,showLicenseWarning:xe}}const{uniform:nI}=yj;function rI(e,t,n){let r={};return Object.entries(e.props).forEach(([e,i])=>{let a=t[e],o=a;i.transform&&(o=i.transform(a)),r[e]={uniform:nI(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:iI,fract:aI,sin:oI,dot:sI}=yj,aoe=e=>aI(oI(sI(e,iI(12.12345,78.12345))).mul(40000.12345)),ooe=(e=.03)=>t=>aoe(t).mul(e).mul(.10012345),{vec2:cI}=yj,soe=(e=cI(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=yj,c=r*1.618033988749895,l=r*2.718281828459045,u=(Math.sin(r)+2)*5,d=(Math.cos(r)+2)*5,f=i(a(e.x.mul(n).mul(u).add(s.mul(.1)).add(c)),o(e.y.mul(n).mul(u).add(s.mul(.1)).add(l))),p=i(a(e.y.mul(n).mul(d).add(s.mul(.05)).add(l)),o(e.x.mul(n).mul(d).add(s.mul(.05)).add(c))),m=f.add(p).mul(t);return e.add(m)},coe=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=yj,c=a(a(e.r,e.g),e.b),l=o(n,n+r,c).mul(i).mul(1),u=e.rgb.add(t.rgb.mul(l));return s(u,e.a)},loe=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=yj,c=s(),l=c.x.sub(.5).sub(a(r)).mul(2),u=c.y.sub(.5).add(a(i)).mul(2),d=l.mul(l).add(u.mul(u)).sqrt();return a(1).sub(o(a(1).sub(a(t)),a(1).sub(a(t)).add(a(n)),d.mul(a(1).add(a(n)))))};var lI=function(exports){"use strict";function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({}),uI,dI;function fI(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>{let n=0;if(!Array.isArray(e)){for(let r of t)n+=e*r;return n}for(let r=0;r<e.length;r++)n+=e[r]*(t[r]||0);return n}));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}function pI(e){return mI(e)===`string`}function mI(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function hI(e,{precision:t,unit:n}){return gI(e)?`none`:vI(e,t)+(n??``)}function gI(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function _I(e){return gI(e)?0:e}function vI(e,t){if(e===0)return 0;let n=~~e,r=0;n&&t&&(r=~~Math.log10(Math.abs(n))+1);let i=10**(t-r);return Math.floor(e*i+.5)/i}const yI={deg:1,grad:.9,rad:180/Math.PI,turn:360};function bI(e){if(!e)return;e=e.trim();let t=/^([a-z]+)\((.+?)\)$/i,n=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,a=e.match(t);if(a){let e=[];return a[2].replace(i,(t,i)=>{let a=i.match(r),o=i;if(a){let e=a[0],t=o.slice(0,-e.length);e===`%`?(o=new Number(t/100),o.type=`<percentage>`):(o=new Number(t*yI[e]),o.type=`<angle>`,o.unit=e)}else n.test(o)?(o=new Number(o),o.type=`<number>`):o===`none`&&(o=new Number(NaN),o.none=!0);t.startsWith(`/`)&&(o=o instanceof Number?o:new Number(o),o.alpha=!0),typeof o==`object`&&o instanceof Number&&(o.raw=i),e.push(o)}),{name:a[1].toLowerCase(),rawName:a[1],rawArgs:a[2],args:e}}}function xI(e){return e[e.length-1]}function SI(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function CI(e,t,n){return(n-e)/(t-e)}function wI(e,t,n){return SI(t[0],t[1],CI(e[0],e[1],n))}function TI(e){return e.map(e=>e.split(`|`).map(e=>{e=e.trim();let t=e.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))}function EI(e,t,n){return Math.max(Math.min(n,t),e)}function DI(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function OI(e,t){return DI(Math.abs(e)**t,e)}function kI(e,t){return t===0?0:e/t}function AI(e,t,n=0,r=e.length){for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}var jI=Object.freeze({__proto__:null,bisectLeft:AI,clamp:EI,copySign:DI,interpolate:SI,interpolateInv:CI,isNone:gI,isString:pI,last:xI,mapRange:wI,multiplyMatrices:fI,parseCoordGrammar:TI,parseFunction:bI,serializeNumber:hI,skipNone:_I,spow:OI,toPrecision:vI,type:mI,zdiv:kI}),MI=class{add(e,t,n){if(typeof arguments[0]!=`string`){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?`unshift`:`push`](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}};const NI=new MI;var PI={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((uI=globalThis)==null||(uI=uI.process)==null||(uI=uI.env)==null||(uI=uI.NODE_ENV)==null?void 0:uI.toLowerCase())!==`test`,warn:function(e){var t,n;this.verbose&&((t=globalThis)==null||(t=t.console)==null||(n=t.warn)==null||n.call(t,e))}};const FI={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function II(e){return Array.isArray(e)?e:FI[e]}function LI(e,t,n,r={}){if(e=II(e),t=II(t),!e||!t)throw TypeError(`Missing white point to convert ${e?``:`from`}${!e&&!t?`/`:``}${t?``:`to`}`);if(e===t)return n;let i={W1:e,W2:t,XYZ:n,options:r};if(NI.run(`chromatic-adaptation-start`,i),i.M||(i.W1===FI.D65&&i.W2===FI.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===FI.D50&&i.W2===FI.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),NI.run(`chromatic-adaptation-end`,i),i.M)return fI(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const RI=new Set([`<number>`,`<percentage>`,`<angle>`]);function zI(e,t,n,r){let i=Object.entries(e.coords).map(([e,i],a)=>{let o=t.coordGrammar[a],s=r[a],c=s?.type,l;if(l=s.none?o.find(e=>RI.has(e)):o.find(e=>e==c),!l){let t=i.name||e;throw TypeError(`${c??s.raw} not allowed for ${t} in ${n}()`)}let u=l.range;c===`<percentage>`&&(u||=[0,1]);let d=i.range||i.refRange;return u&&d&&(r[a]=wI(u,d,r[a])),l});return i}function BI(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(NI.run(`parse-start`,i),i.color)return i.color;if(i.parsed=bI(i.str),i.parsed){let e=i.parsed.name;if(e===`color`){let e=i.parsed.args.shift(),n=e.startsWith(`--`)?e.substring(2):`--${e}`,r=[e,n],c=i.parsed.rawArgs.indexOf(`/`)>0?i.parsed.args.pop():1;for(let n of UI.all){let s=n.getFormat(`color`);if(s){var a,o;if(r.includes(s.id)||(a=o=s.ids)?.filter(e=>r.includes(e)).length){let r=Object.keys(n.coords).map((e,t)=>i.parsed.args[t]||0),a;return s.coordGrammar&&(a=zI(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&PI.warn(`${n.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith(`--`)&&!s.id.startsWith(`--`)&&PI.warn(`${n.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:n.id,coords:r,alpha:c}}}}let l=``,u=e in UI.registry?e:n;if(u in UI.registry){var s;let e=(s=UI.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;e&&(l=`Did you mean color(${e})?`)}throw TypeError(`Cannot parse color(${e}). `+(l||`Missing a plugin?`))}else for(let n of UI.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||xI(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=zI(n,r,e,o)),t&&Object.assign(t,{formatId:r.name,types:s}),{spaceId:n.id,coords:o,alpha:a}}}}else for(let e of UI.all)for(let n in e.formats){let r=e.formats[n];if(r.type!==`custom`||r.test&&!r.test(i.str))continue;let a=r.parse(i.str);if(a)return a.alpha??=1,t&&(t.formatId=n),a}throw TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function VI(e){if(Array.isArray(e))return e.map(VI);if(!e)throw TypeError(`Empty color reference`);pI(e)&&(e=BI(e));let t=e.space||e.spaceId;return t instanceof UI||(e.space=UI.get(t)),e.alpha===void 0&&(e.alpha=1),e}const HI=75e-6;var UI=(dI=class e{constructor(t){var n,r;this.id=t.id,this.name=t.name,this.base=t.base?e.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let i=t.coords??this.base.coords;for(let e in i)`name`in i[e]||(i[e].name=e);this.coords=i;let a=t.white??this.base.white??`D65`;for(let e in this.white=II(a),this.formats=t.formats??{},this.formats){let t=this.formats[e];t.type||=`function`,t.name||=e}(n=r=this.formats.color)?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace=t.gamutSpace===`self`?this:e.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=t.referred,Object.defineProperty(this,`path`,{value:WI(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),NI.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=HI}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let n=Object.values(this.coords);return e.every((e,r)=>{let i=n[r];if(i.type!==`angle`&&i.range){if(Number.isNaN(e))return!0;let[n,r]=i.range;return(n===void 0||e>=n-t)&&(r===void 0||e<=r+t)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!(`range`in e))}get cssId(){var e;return((e=this.formats)==null||(e=e.color)==null?void 0:e.id)||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type===`angle`)return!0;return!1}getFormat(e){if(typeof e==`object`)return e=GI(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=GI(t,this),t):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(t,n){if(arguments.length===1){let e=VI(t);[t,n]=[e.space,e.coords]}if(t=e.get(t),this.equals(t))return n;n=n.map(e=>Number.isNaN(e)?0:e);let r=this.path,i=t.path,a,o;for(let e=0;e<r.length&&r[e].equals(i[e]);e++)a=r[e],o=e;if(!a)throw Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let e=r.length-1;e>o;e--)n=r[e].toBase(n);for(let e=o+1;e<i.length;e++)n=i[e].fromBase(n);return n}from(t,n){if(arguments.length===1){let e=VI(t);[t,n]=[e.space,e.coords]}return t=e.get(t),t.to(this,n)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let n=this.coords[t],r=n.range||n.refRange;e.push(r?.min??0)}return e}static get all(){return[...new Set(Object.values(e.registry))]}static register(e,t){if(arguments.length===1&&(t=arguments[0],e=t.id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,arguments.length===1&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(t,...n){if(!t||t instanceof e)return t;let r=mI(t);if(r===`string`){let n=e.registry[t.toLowerCase()];if(!n)throw TypeError(`No color space found with id = "${t}"`);return n}if(n.length)return e.get(...n);throw TypeError(`${t} is not a valid color space`)}static resolveCoord(t,n){let r=mI(t),i,a;if(r===`string`?t.includes(`.`)?[i,a]=t.split(`.`):[i,a]=[,t]:Array.isArray(t)?[i,a]=t:(i=t.space,a=t.coordId),i=e.get(i),i||=n,!i)throw TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(r=mI(a),r===`number`||r===`string`&&a>=0){let e=Object.entries(i.coords)[a];if(e)return{space:i,id:e[0],index:a,...e[1]}}i=e.get(i);let o=a.toLowerCase(),s=0;for(let e in i.coords){var c,l;let t=i.coords[e];if(e.toLowerCase()===o||(c=l=t.name)?.toLowerCase()===o)return{space:i,id:e,index:s,...t};s++}throw TypeError(`No "${a}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(`, `)}`)}},lI.defineProperty(dI,`registry`,{}),lI.defineProperty(dI,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),dI);function WI(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function GI(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=TI(e.coords);let n=Object.entries(t).map(([t,n],r)=>{let i=e.coordGrammar[r][0],a=n.range||n.refRange,o=i.range,s=``;return i==`<percentage>`?(o=[0,100],s=`%`):i==`<angle>`&&(s=`deg`),{fromRange:a,toRange:o,suffix:s}});e.serializeCoords=(e,t)=>e.map((e,r)=>{let{fromRange:i,toRange:a,suffix:o}=n[r];return i&&a&&(e=wI(i,a,e)),e=hI(e,{precision:t,unit:o}),e})}return e}var KI=new UI({id:`xyz-d65`,name:`XYZ D65`,coords:{x:{name:`X`},y:{name:`Y`},z:{name:`Z`}},white:`D65`,formats:{color:{ids:[`xyz-d65`,`xyz`]}},aliases:[`xyz`]}),qI=class extends UI{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=KI,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=fI(e.toXYZ_M,t);return this.white!==this.base.white&&(n=LI(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=LI(this.base.white,this.white,t),fI(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function JI(e,t){return e=VI(e),!t||e.space.equals(t)?e.coords.slice():(t=UI.get(t),t.from(e))}function YI(e,t){e=VI(e);let{space:n,index:r}=UI.resolveCoord(t,e.space),i=JI(e,n);return i[r]}function XI(e,t,n){return e=VI(e),t=UI.get(t),e.coords=t.to(e.space,n),e}XI.returns=`color`;function ZI(e,t,n){if(e=VI(e),arguments.length===2&&mI(arguments[1])===`object`){let t=arguments[1];for(let n in t)ZI(e,n,t[n])}else{typeof n==`function`&&(n=n(YI(e,t)));let{space:r,index:i}=UI.resolveCoord(t,e.space),a=JI(e,r);a[i]=n,XI(e,r,a)}return e}ZI.returns=`color`;var QI=new UI({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:KI,fromBase:e=>LI(KI.white,`D50`,e),toBase:e=>LI(`D50`,KI.white,e)});const $I=216/24389,eL=24/116,tL=24389/27;let nL=FI.D50;var rL=new UI({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:nL,base:QI,fromBase(e){let t=e.map((e,t)=>e/nL[t]),n=t.map(e=>e>$I?Math.cbrt(e):(tL*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>eL?t[0]**3:(116*t[0]-16)/tL,e[0]>8?((e[0]+16)/116)**3:e[0]/tL,t[2]>eL?t[2]**3:(116*t[2]-16)/tL];return n.map((e,t)=>e*nL[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function iL(e){return(e%360+360)%360}function aL(e,t){if(e===`raw`)return t;let[n,r]=t.map(iL),i=r-n;return e===`increasing`?i<0&&(r+=360):e===`decreasing`?i>0&&(n+=360):e===`longer`?-180<i&&i<180&&(i>0?n+=360:r+=360):e===`shorter`&&(i>180?n+=360:i<-180&&(r+=360)),[n,r]}var oL=new UI({id:`lch`,name:`LCH`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,150],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:rL,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),iL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{lch:{coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const sL=25**7,cL=Math.PI,lL=180/cL,uL=cL/180;function dL(e){let t=e*e,n=t*t*t*e;return n}function fL(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=VI([e,t]);let[a,o,s]=rL.from(e),c=oL.from(rL,[a,o,s])[1],[l,u,d]=rL.from(t),f=oL.from(rL,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=dL(p),h=.5*(1-Math.sqrt(m/(m+sL))),g=(1+h)*o,_=(1+h)*u,v=Math.sqrt(g**2+s**2),y=Math.sqrt(_**2+d**2),b=g===0&&s===0?0:Math.atan2(s,g),x=_===0&&d===0?0:Math.atan2(d,_);b<0&&(b+=2*cL),x<0&&(x+=2*cL),b*=lL,x*=lL;let S=l-a,ee=y-v,te=x-b,ne=b+x,re=Math.abs(te),ie;v*y===0?ie=0:re<=180?ie=te:te>180?ie=te-360:te<-180?ie=te+360:PI.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*uL/2),oe=(a+l)/2,se=(v+y)/2,ce=dL(se),le;le=v*y===0?ne:re<=180?ne/2:ne<360?(ne+360)/2:(ne-360)/2;let ue=(oe-50)**2,de=1+.015*ue/Math.sqrt(20+ue),fe=1+.045*se,pe=1;pe-=.17*Math.cos((le-30)*uL),pe+=.24*Math.cos(2*le*uL),pe+=.32*Math.cos((3*le+6)*uL),pe-=.2*Math.cos((4*le-63)*uL);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+sL)),_e=-1*Math.sin(2*he*uL)*ge,ve=(S/(n*de))**2;return ve+=(ee/(r*fe))**2,ve+=(ae/(i*me))**2,ve+=_e*(ee/(r*fe))*(ae/(i*me)),Math.sqrt(ve)}const pL=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],mL=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],hL=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],gL=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var _L=new UI({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:KI,fromBase(e){let t=fI(pL,e),n=t.map(e=>Math.cbrt(e));return fI(hL,n)},toBase(e){let t=fI(gL,e),n=t.map(e=>e**3);return fI(mL,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function vL(e,t){[e,t]=VI([e,t]);let[n,r,i]=_L.from(e),[a,o,s]=_L.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const yL=75e-6;function bL(e,t,{epsilon:n=yL}={}){e=VI(e),t||=e.space,t=UI.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function xL(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function SL(e,t,n=`lab`){n=UI.get(n);let r=n.from(e),i=n.from(t);return Math.sqrt(r.reduce((e,t,n)=>{let r=i[n];return isNaN(t)||isNaN(r)?e:e+(r-t)**2},0))}function CL(e,t){return SL(e,t,`lab`)}const wL=Math.PI,TL=wL/180;function EL(e,t,{l:n=2,c:r=1}={}){[e,t]=VI([e,t]);let[i,a,o]=rL.from(e),[,s,c]=oL.from(rL,[i,a,o]),[l,u,d]=rL.from(t),f=oL.from(rL,[l,u,d])[1];s<0&&(s=0),f<0&&(f=0);let p=i-l,m=s-f,h=a-u,g=o-d,_=h**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let y=.0638*s/(1+.0131*s)+.638,b;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*TL)):.36+Math.abs(.4*Math.cos((c+35)*TL));let x=s**4,S=Math.sqrt(x/(x+1900)),ee=y*(S*b+1-S),te=(p/(n*v))**2;return te+=(m/(r*y))**2,te+=_/ee**2,Math.sqrt(te)}const DL=203;var OL=new UI({id:`xyz-abs-d65`,cssId:`--xyz-abs-d65`,name:`Absolute XYZ D65`,coords:{x:{refRange:[0,9504.7],name:`Xa`},y:{refRange:[0,1e4],name:`Ya`},z:{refRange:[0,10888.3],name:`Za`}},base:KI,fromBase(e){return e.map(e=>Math.max(e*DL,0))},toBase(e){return e.map(e=>Math.max(e/DL,0))}});const kL=1.15,AL=.66,jL=2610/2**14,ML=2**14/2610,NL=3424/2**12,PL=2413/2**7,FL=2392/2**7,IL=1.7*2523/2**5,LL=2**5/(1.7*2523),RL=-.56,zL=16295499532821565e-27,BL=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],VL=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],HL=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],UL=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var WL=new UI({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:OL,fromBase(e){let[t,n,r]=e,i=kL*t-(kL-1)*r,a=AL*n-(AL-1)*t,o=fI(BL,[i,a,r]),s=o.map(function(e){let t=NL+PL*(e/1e4)**jL,n=1+FL*(e/1e4)**jL;return(t/n)**IL}),[c,l,u]=fI(HL,s),d=(1+RL)*c/(1+RL*c)-zL;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+zL)/(1+RL-RL*(t+zL)),a=fI(UL,[i,n,r]),o=a.map(function(e){let t=NL-e**LL,n=FL*e**LL-PL,r=1e4*(t/n)**ML;return r}),[s,c,l]=fI(VL,o),u=(s+(kL-1)*l)/kL,d=(c+(AL-1)*u)/AL;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),GL=new UI({id:`jzczhz`,name:`JzCzHz`,coords:{jz:{refRange:[0,1],name:`Jz`},cz:{refRange:[0,1],name:`Chroma`},hz:{refRange:[0,360],type:`angle`,name:`Hue`}},base:WL,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),iL(i)]},toBase(e){return[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]}});function KL(e,t){[e,t]=VI([e,t]);let[n,r,i]=GL.from(e),[a,o,s]=GL.from(t),c=n-a,l=r-o;Number.isNaN(i)&&Number.isNaN(s)?(i=0,s=0):Number.isNaN(i)?i=s:Number.isNaN(s)&&(s=i);let u=i-s,d=2*Math.sqrt(r*o)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(c**2+l**2+d**2)}const qL=3424/4096,JL=2413/128,YL=2392/128,XL=2610/16384,ZL=2523/32,QL=16384/2610,$L=32/2523,eR=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],tR=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],nR=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],rR=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var iR=new UI({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:OL,fromBase(e){let t=fI(eR,e);return aR(t)},toBase(e){let t=oR(e);return fI(rR,t)}});function aR(e){let t=e.map(function(e){let t=qL+JL*(e/1e4)**XL,n=1+YL*(e/1e4)**XL;return(t/n)**ZL});return fI(tR,t)}function oR(e){let t=fI(nR,e),n=t.map(function(e){let t=Math.max(e**$L-qL,0),n=JL-YL*e**$L;return 1e4*(t/n)**QL});return n}function sR(e,t){[e,t]=VI([e,t]);let[n,r,i]=iR.from(e),[a,o,s]=iR.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const cR=FI.D65,lR=.42,uR=1/lR,dR=2*Math.PI,fR=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],pR=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],mR=[[460,451,288],[460,-891,-261],[460,-220,-6300]],hR={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},gR={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},_R=180/Math.PI,vR=Math.PI/180;function yR(e,t){let n=e.map(e=>{let n=OI(t*Math.abs(e)*.01,lR);return 400*DI(n,e)/(n+27.13)});return n}function bR(e,t){let n=100/t*27.13**uR;return e.map(e=>{let t=Math.abs(e);return DI(n*OI(t/(400-t),uR),e)})}function xR(e){let t=iL(e);t<=gR.h[0]&&(t+=360);let n=AI(gR.h,t)-1,[r,i]=gR.h.slice(n,n+2),[a,o]=gR.e.slice(n,n+2),s=gR.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function SR(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=gR.h.slice(n,n+2),[a,o]=gR.e.slice(n,n+2);return iL((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function CR(e,t,n,r,i){let a={};a.discounting=i,a.refWhite=e,a.surround=r;let o=e.map(e=>e*100);a.la=t,a.yb=n;let s=o[1],c=fI(fR,o);r=hR[a.surround];let l=r[0];a.c=r[1],a.nc=r[2];let u=1/(5*a.la+1),d=u**4;a.fl=d*a.la+.1*(1-d)*(1-d)*Math.cbrt(5*a.la),a.flRoot=a.fl**.25,a.n=a.yb/s,a.z=1.48+Math.sqrt(a.n),a.nbb=.725*a.n**-.2,a.ncb=a.nbb;let f=i?1:Math.max(Math.min(l*(1-1/3.6*Math.exp((-a.la-42)/92)),1),0);a.dRgb=c.map(e=>SI(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=yR(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const wR=CR(cR,64/Math.PI*.2,20,`average`,!1);function TR(e,t){if(!(e.J!==void 0^e.Q!==void 0))throw Error(`Conversion requires one and only one: 'J' or 'Q'`);if(!(e.C!==void 0^e.M!==void 0^e.s!==void 0))throw Error(`Conversion requires one and only one: 'C', 'M' or 's'`);if(!(e.h!==void 0^e.H!==void 0))throw Error(`Conversion requires one and only one: 'h' or 'H'`);if(e.J===0||e.Q===0)return[0,0,0];let n=0;n=e.h===void 0?SR(e.H)*vR:iL(e.h)*vR;let r=Math.cos(n),i=Math.sin(n),a=0;e.J===void 0?e.Q!==void 0&&(a=.25*t.c*e.Q/((t.aW+4)*t.flRoot)):a=OI(e.J,1/2)*.1;let o=0;e.C===void 0?e.M===void 0?e.s!==void 0&&(o=4e-4*e.s**2*(t.aW+4)/t.c):o=e.M/t.flRoot/a:o=e.C/a;let s=OI(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*OI(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*kI(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=bR(fI(mR,[d,p,m]).map(e=>e*1/1403),t.fl);return fI(pR,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function ER(e,t){let n=e.map(e=>e*100),r=yR(fI(fR,n).map((e,n)=>e*t.dRgb[n]),t.fl),i=r[0]+(-12*r[1]+r[2])/11,a=(r[0]+r[1]-2*r[2])/9,o=(Math.atan2(a,i)%dR+dR)%dR,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*kI(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=OI(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=OI(u/t.aW,.5*t.c*t.z),f=100*OI(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=iL(o*_R),_=xR(g),v=50*OI(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var DR=new UI({id:`cam16-jmh`,cssId:`--cam16-jmh`,name:`CAM16-JMh`,coords:{j:{refRange:[0,100],name:`J`},m:{refRange:[0,105],name:`Colorfulness`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:KI,fromBase(e){let t=ER(e,wR);return[t.J,t.M,t.h]},toBase(e){return TR({J:e[0],M:e[1],h:e[2]},wR)}});const OR=FI.D65,kR=216/24389,AR=24389/27;function jR(e){let t=e>kR?Math.cbrt(e):(AR*e+16)/116;return 116*t-16}function MR(e){return e>8?((e+16)/116)**3:e/AR}function NR(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=MR(i);o=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let c=2e-12,l=15,u=0,d=1/0;for(;u<=l;){a=TR({J:o,C:r,h:n},t);let e=Math.abs(a[1]-s);if(e<d){if(e<=c)return a;d=e}o-=(a[1]-s)*o/(2*a[1]),u+=1}return TR({J:o,C:r,h:n},t)}function PR(e,t){let n=jR(e[1]);if(n===0)return[0,0,0];let r=ER(e,FR);return[iL(r.h),r.C,n]}const FR=CR(OR,200/Math.PI*MR(50),MR(50)*100,`average`,!1);var IR=new UI({id:`hct`,name:`HCT`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},c:{refRange:[0,145],name:`Colorfulness`},t:{refRange:[0,100],name:`Tone`}},base:KI,fromBase(e){return PR(e)},toBase(e){return NR(e,FR)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const LR=Math.PI/180,RR=[1,.007,.0228];function zR(e){e[1]<0&&(e=IR.fromBase(IR.toBase(e)));let t=Math.log(Math.max(1+RR[2]*e[1]*FR.flRoot,1))/RR[2],n=e[0]*LR,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function BR(e,t){[e,t]=VI([e,t]);let[n,r,i]=zR(IR.from(e)),[a,o,s]=zR(IR.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var VR={deltaE76:CL,deltaECMC:EL,deltaE2000:fL,deltaEJz:KL,deltaEITP:sR,deltaEOK:vL,deltaEHCT:BR};function HR(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const UR={hct:{method:`hct.c`,jnd:2,deltaEMethod:`hct`,blackWhiteClamp:{}},"hct-tonal":{method:`hct.c`,jnd:0,deltaEMethod:`hct`,blackWhiteClamp:{channel:`hct.t`,min:0,max:100}}};function WR(e,{method:t=PI.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=VI(e),pI(arguments[1])?n=arguments[1]:n||=e.space,n=UI.get(n),bL(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=KR(e,{space:n});else{if(t!==`clip`&&!bL(e,n)){Object.prototype.hasOwnProperty.call(UR,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=UR[t]);let s=fL;if(r!==``){for(let e in VR)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=VR[e];break}}let c=WR(qR(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=UI.resolveCoord(a.channel),n=YI(qR(e,t.space),t.id);if(gI(n)&&(n=0),n>=a.max)return qR({space:`xyz-d65`,coords:FI.D65},e.space);if(n<=a.min)return qR({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=UI.resolveCoord(t),c=r.space,l=r.id,u=qR(e,c);u.coords.forEach((e,t)=>{gI(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=HR(i),m=f,h=YI(u,l);for(;h-m>p;){let e=xL(u);e=WR(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=YI(u,l):h=YI(u,l),ZI(u,l,(m+h)/2)}o=qR(u,n)}else o=c}else o=qR(e,n);if(t===`clip`||!bL(o,n,{epsilon:0})){let e=Object.values(n.coords).map(e=>e.range||[]);o.coords=o.coords.map((t,n)=>{let[r,i]=e[n];return r!==void 0&&(t=Math.max(r,t)),i!==void 0&&(t=Math.min(t,i)),t})}}return n!==e.space&&(o=qR(o,e.space)),e.coords=o.coords,e}WR.returns=`color`;const GR={WHITE:{space:_L,coords:[1,0,0]},BLACK:{space:_L,coords:[0,0,0]}};function KR(e,{space:t}={}){let n=.02,r=1e-4;e=VI(e),t||=e.space,t=UI.get(t);let i=UI.get(`oklch`);if(t.isUnbounded)return qR(e,t);let a=qR(e,i),o=a.coords[0];if(o>=1){let n=qR(GR.WHITE,t);return n.alpha=e.alpha,qR(n,t)}if(o<=0){let n=qR(GR.BLACK,t);return n.alpha=e.alpha,qR(n,t)}if(bL(a,t,{epsilon:0}))return qR(a,t);function s(e){let n=qR(e,t),r=Object.values(t.coords);return n.coords=n.coords.map((e,t)=>{if(`range`in r[t]){let[n,i]=r[t].range;return EI(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=xL(a),f=s(d),p=vL(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&bL(d,t,{epsilon:0}))c=e;else if(f=s(d),p=vL(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function qR(e,t,{inGamut:n}={}){e=VI(e),t=UI.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=WR(i,n===!0?void 0:n)),i}qR.returns=`color`;function JR(e,{precision:t=PI.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=VI(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??UI.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!bL(e)&&(s=WR(xL(e),r===!0?void 0:r).coords),n.type===`custom`)if(i.precision=t,n.serialize)a=n.serialize(s,e.alpha,i);else throw TypeError(`format ${o} can only be used to parse colors, not for serialization`);else{let r=n.name||`color`;n.serializeCoords?s=n.serializeCoords(s,t):t!==null&&(s=s.map(e=>hI(e,{precision:t})));let i=[...s];if(r===`color`){var c,l;let t=n.id||(c=l=n.ids)?.[0]||e.space.id;i.unshift(t)}let o=e.alpha;t!==null&&(o=hI(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const YR=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],XR=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var ZR=new qI({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:YR,fromXYZ_M:XR});const QR=1.09929682680944,$R=.018053968510807;var ez=new qI({id:`rec2020`,name:`REC.2020`,base:ZR,toBase(e){return e.map(function(e){return e<$R*4.5?e/4.5:((e+QR-1)/QR)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=$R?QR*e**.45-(QR-1):4.5*e})}});const tz=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],nz=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var rz=new qI({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:tz,fromXYZ_M:nz});const iz=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],az=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var oz=new qI({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:iz,fromXYZ_M:az}),sz={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let cz=[,,,].fill(`<percentage> | <number>[0, 255]`),lz=[,,,].fill(`<number>[0, 255]`);var uz=new qI({id:`srgb`,name:`sRGB`,base:oz,fromBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}),toBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}),formats:{rgb:{coords:cz},rgb_number:{name:`rgb`,commas:!0,coords:lz,noAlpha:!0},color:{},rgba:{coords:cz,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:lz},hex:{type:`custom`,toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,`$&$&`));let t=[];return e.replace(/[a-f0-9]{2}/gi,e=>{t.push(parseInt(e,16)/255)}),{spaceId:`srgb`,coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:n=!0}={})=>{t<1&&e.push(t),e=e.map(e=>Math.round(e*255));let r=n&&e.every(e=>e%17==0),i=e.map(e=>r?(e/17).toString(16):e.toString(16).padStart(2,`0`)).join(``);return`#`+i}},keyword:{type:`custom`,test:e=>/^[a-z]+$/i.test(e),parse(e){e=e.toLowerCase();let t={spaceId:`srgb`,coords:null,alpha:1};if(e===`transparent`?(t.coords=sz.black,t.alpha=0):t.coords=sz[e],t.coords)return t}}}}),dz=new qI({id:`p3`,cssId:`display-p3`,name:`P3`,base:rz,fromBase:uz.fromBase,toBase:uz.toBase});PI.display_space=uz;let fz;if(typeof CSS<`u`&&CSS.supports)for(let e of[rL,ez,dz]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=JR(n);if(CSS.supports(`color`,r)){PI.display_space=e;break}}function pz(e,{space:t=PI.display_space,...n}={}){let r=JR(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!PI.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some(gI)||gI(e.alpha);if(a&&!(fz??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=xL(e),i.coords=i.coords.map(_I),i.alpha=_I(i.alpha),r=JR(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=qR(i,t),r=new String(JR(i,n)),r.color=i}return r}function mz(e,t){return e=VI(e),t=VI(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function hz(e){return YI(e,[KI,`y`])}function gz(e,t){ZI(e,[KI,`y`],t)}function _z(e){Object.defineProperty(e.prototype,`luminance`,{get(){return hz(this)},set(e){gz(this,e)}})}var vz=Object.freeze({__proto__:null,getLuminance:hz,register:_z,setLuminance:gz});function yz(e,t){e=VI(e),t=VI(t);let n=Math.max(hz(e),0),r=Math.max(hz(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const bz=.56,xz=.57,Sz=.62,Cz=.65,wz=.022,Tz=1.414,Ez=.1,Dz=5e-4,Oz=1.14,kz=.027,Az=1.14;function jz(e){return e>=wz?e:e+(wz-e)**Tz}function Mz(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function Nz(e,t){t=VI(t),e=VI(e);let n,r,i,a,o,s;t=qR(t,`srgb`),[a,o,s]=t.coords;let c=Mz(a)*.2126729+Mz(o)*.7151522+Mz(s)*.072175;e=qR(e,`srgb`),[a,o,s]=e.coords;let l=Mz(a)*.2126729+Mz(o)*.7151522+Mz(s)*.072175,u=jz(c),d=jz(l),f=d>u;return Math.abs(d-u)<Dz?r=0:f?(n=d**bz-u**xz,r=n*Oz):(n=d**Cz-u**Sz,r=n*Az),i=Math.abs(r)<Ez?0:r>0?r-kz:r+kz,i*100}function Pz(e,t){e=VI(e),t=VI(t);let n=Math.max(hz(e),0),r=Math.max(hz(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const Fz=5e4;function Iz(e,t){e=VI(e),t=VI(t);let n=Math.max(hz(e),0),r=Math.max(hz(t),0);return r>n&&([n,r]=[r,n]),r===0?Fz:(n-r)/r}function Lz(e,t){e=VI(e),t=VI(t);let n=YI(e,[rL,`l`]),r=YI(t,[rL,`l`]);return Math.abs(n-r)}const Rz=216/24389,zz=24/116,Bz=24389/27;let Vz=FI.D65;var Hz=new UI({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Vz,base:KI,fromBase(e){let t=e.map((e,t)=>e/Vz[t]),n=t.map(e=>e>Rz?Math.cbrt(e):(Bz*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>zz?t[0]**3:(116*t[0]-16)/Bz,e[0]>8?((e[0]+16)/116)**3:e[0]/Bz,t[2]>zz?t[2]**3:(116*t[2]-16)/Bz];return n.map((e,t)=>e*Vz[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const Uz=5**.5*.5+.5;function Wz(e,t){e=VI(e),t=VI(t);let n=YI(e,[Hz,`l`]),r=YI(t,[Hz,`l`]),i=Math.abs(n**+Uz-r**+Uz),a=i**(1/Uz)*Math.SQRT2-40;return a<7.5?0:a}var Gz=Object.freeze({__proto__:null,contrastAPCA:Nz,contrastDeltaPhi:Wz,contrastLstar:Lz,contrastMichelson:Pz,contrastWCAG21:yz,contrastWeber:Iz});function Kz(e,t,n={}){pI(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(Gz).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=VI(e),t=VI(t),Gz)if(`contrast`+r.toLowerCase()===n.toLowerCase())return Gz[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function qz(e){let[t,n,r]=JI(e,KI),i=t+15*n+3*r;return[4*t/i,9*n/i]}function Jz(e){let[t,n,r]=JI(e,KI),i=t+n+r;return[t/i,n/i]}function Yz(e){Object.defineProperty(e.prototype,`uv`,{get(){return qz(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return Jz(this)}})}var Xz=Object.freeze({__proto__:null,register:Yz,uv:qz,xy:Jz});function Zz(e,t,n={}){pI(n)&&(n={method:n});let{method:r=PI.deltaE,...i}=n;for(let n in VR)if(`deltae`+r.toLowerCase()===n.toLowerCase())return VR[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function Qz(e,t=.25){let n=UI.get(`oklch`,`lch`),r=[n,`l`];return ZI(e,r,e=>e*(1+t))}function $z(e,t=.25){let n=UI.get(`oklch`,`lch`),r=[n,`l`];return ZI(e,r,e=>e*(1-t))}var eB=Object.freeze({__proto__:null,darken:$z,lighten:Qz});function tB(e,t,n=.5,r={}){[e,t]=[VI(e),VI(t)],mI(n)===`object`&&([n,r]=[.5,n]);let i=rB(e,t,r);return i(n)}function nB(e,t,n={}){let r;iB(e)&&([r,n]=[e,t],[e,t]=r.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:a,steps:o=2,maxSteps:s=1e3,...c}=n;r||([e,t]=[VI(e),VI(t)],r=rB(e,t,c));let l=Zz(e,t),u=i>0?Math.max(o,Math.ceil(l/i)+1):o,d=[];if(s!==void 0&&(u=Math.min(u,s)),u===1)d=[{p:.5,color:r(.5)}];else{let e=1/(u-1);d=Array.from({length:u},(t,n)=>{let i=n*e;return{p:i,color:r(i)}})}if(i>0){let e=d.reduce((e,t,n)=>{if(n===0)return 0;let r=Zz(t.color,d[n-1].color,a);return Math.max(e,r)},0);for(;e>i;){e=0;for(let t=1;t<d.length&&d.length<s;t++){let n=d[t-1],i=d[t],a=(i.p+n.p)/2,o=r(a);e=Math.max(e,Zz(o,n.color),Zz(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function rB(e,t,n={}){if(iB(e)){let[n,r]=[e,t];return rB(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=VI(e),t=VI(t),e=xL(e),t=xL(t);let s={colors:[e,t],options:n};if(r=r?UI.get(r):UI.registry[PI.interpolationSpace]||e.space,i=i?UI.get(i):r,e=qR(e,r),t=qR(t,r),e=WR(e),t=WR(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[YI(e,a),YI(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=aL(i,[o,s]),ZI(e,a,o),ZI(t,a,s)}return o&&(e.coords=e.coords.map(t=>t*e.alpha),t.coords=t.coords.map(e=>e*t.alpha)),Object.assign(n=>{n=a?a(n):n;let s=e.coords.map((e,r)=>{let i=t.coords[r];return SI(e,i,n)}),c=SI(e.alpha,t.alpha,n),l={space:r,coords:s,alpha:c};return o&&(l.coords=l.coords.map(e=>e/c)),i!==r&&(l=qR(l,i)),l},{rangeArgs:s})}function iB(e){return mI(e)===`function`&&!!e.rangeArgs}PI.interpolationSpace=`lab`;function aB(e){e.defineFunction(`mix`,tB,{returns:`color`}),e.defineFunction(`range`,rB,{returns:`function<color>`}),e.defineFunction(`steps`,nB,{returns:`array<color>`})}var oB=Object.freeze({__proto__:null,isRange:iB,mix:tB,range:rB,register:aB,steps:nB}),sB=new UI({id:`hsl`,name:`HSL`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:uz,fromBase:e=>{let t=Math.max(...e),n=Math.min(...e),[r,i,a]=e,[o,s,c]=[NaN,0,(n+t)/2],l=t-n;if(l!==0){switch(s=c===0||c===1?0:(t-c)/Math.min(c,1-c),t){case r:o=(i-a)/l+(i<a?6:0);break;case i:o=(a-r)/l+2;break;case a:o=(r-i)/l+4}o*=60}return s<0&&(o+=180,s=Math.abs(s)),o>=360&&(o-=360),[o,s*100,c*100]},toBase:e=>{let[t,n,r]=e;t%=360,t<0&&(t+=360),n/=100,r/=100;function i(e){let i=(e+t/30)%12,a=n*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4)]},formats:{hsl:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`]},hsla:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`],commas:!0,lastAlpha:!0}}}),cB=new UI({id:`hsv`,name:`HSV`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},v:{range:[0,100],name:`Value`}},base:sB,fromBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r+n*Math.min(r,1-r);return[t,i===0?0:200*(1-r/i),100*i]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r*(1-n/2);return[t,i===0||i===1?0:(r-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:`--hsv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),lB=new UI({id:`hwb`,name:`HWB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},w:{range:[0,100],name:`Whiteness`},b:{range:[0,100],name:`Blackness`}},base:cB,fromBase(e){let[t,n,r]=e;return[t,r*(100-n)/100,100-r]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=n+r;if(i>=1){let e=n/i;return[t,0,e*100]}let a=1-r,o=a===0?0:1-n/a;return[t,o*100,a*100]},formats:{hwb:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const uB=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],dB=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var fB=new qI({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:uB,fromXYZ_M:dB}),pB=new qI({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:fB,toBase:e=>e.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:e=>e.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const mB=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],hB=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var gB=new qI({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:QI,toXYZ_M:mB,fromXYZ_M:hB});const _B=1/512,vB=16/512;var yB=new qI({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:gB,toBase(e){return e.map(e=>e<vB?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=_B?e**(1/1.8):16*e)}}),bB=new UI({id:`oklch`,name:`Oklch`,coords:{l:{refRange:[0,1],name:`Lightness`},c:{refRange:[0,.4],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},white:`D65`,base:_L,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),iL(i)]},toBase(e){let[t,n,r]=e,i,a;return isNaN(r)?(i=0,a=0):(i=n*Math.cos(r*Math.PI/180),a=n*Math.sin(r*Math.PI/180)),[t,i,a]},formats:{oklch:{coords:[`<percentage> | <number>`,`<number> | <percentage>[0,1]`,`<number> | <angle>`]}}});let xB=FI.D65;const SB=216/24389,CB=24389/27,[wB,TB]=qz({space:KI,coords:xB});var EB=new UI({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:xB,base:KI,fromBase(e){let t=[_I(e[0]),_I(e[1]),_I(e[2])],n=t[1],[r,i]=qz({space:KI,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=SB?CB*n:116*Math.cbrt(n)-16;return[a,13*a*(r-wB),13*a*(i-TB)]},toBase(e){let[t,n,r]=e;if(t===0||gI(t))return[0,0,0];n=_I(n),r=_I(r);let i=n/(13*t)+wB,a=r/(13*t)+TB,o=t<=8?t/CB:((t+16)/116)**3;return[o*(9*i/(4*a)),o,o*((12-3*i-20*a)/(4*a))]},formats:{color:{id:`--luv`,coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),DB=new UI({id:`lchuv`,name:`LChuv`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,220],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:EB,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),iL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{color:{id:`--lchuv`,coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const OB=216/24389,kB=24389/27,AB=az[0][0],jB=az[0][1],MB=az[0][2],NB=az[1][0],PB=az[1][1],FB=az[1][2],IB=az[2][0],LB=az[2][1],RB=az[2][2];function zB(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function BB(e){let t=(e+16)**3/1560896,n=t>OB?t:e/kB,r=n*(284517*AB-94839*MB),i=n*(838422*MB+769860*jB+731718*AB),a=n*(632260*MB-126452*jB),o=n*(284517*NB-94839*FB),s=n*(838422*FB+769860*PB+731718*NB),c=n*(632260*FB-126452*PB),l=n*(284517*IB-94839*RB),u=n*(838422*RB+769860*LB+731718*IB),d=n*(632260*RB-126452*LB);return{r0s:r/a,r0i:i*e/a,r1s:r/(a+126452),r1i:(i-769860)*e/(a+126452),g0s:o/c,g0i:s*e/c,g1s:o/(c+126452),g1i:(s-769860)*e/(c+126452),b0s:l/d,b0i:u*e/d,b1s:l/(d+126452),b1i:(u-769860)*e/(d+126452)}}function VB(e,t){let n=t/360*Math.PI*2,r=zB(e.r0s,e.r0i,n),i=zB(e.r1s,e.r1i,n),a=zB(e.g0s,e.g0i,n),o=zB(e.g1s,e.g1i,n),s=zB(e.b0s,e.b0i,n),c=zB(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var HB=new UI({id:`hsluv`,name:`HSLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:DB,gamutSpace:uz,fromBase(e){let[t,n,r]=[_I(e[0]),_I(e[1]),_I(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=BB(t),a=VB(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[_I(e[0]),_I(e[1]),_I(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=BB(r),a=VB(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});az[0][0],az[0][1],az[0][2],az[1][0],az[1][1],az[1][2],az[2][0],az[2][1],az[2][2];function UB(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function WB(e){let t=UB(e.r0s,e.r0i),n=UB(e.r1s,e.r1i),r=UB(e.g0s,e.g0i),i=UB(e.g1s,e.g1i),a=UB(e.b0s,e.b0i),o=UB(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var GB=new UI({id:`hpluv`,name:`HPLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:DB,gamutSpace:`self`,fromBase(e){let[t,n,r]=[_I(e[0]),_I(e[1]),_I(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=BB(t),r=WB(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[_I(e[0]),_I(e[1]),_I(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=BB(r),t=WB(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const KB=203,qB=2610/2**14,JB=2**14/2610,YB=2523/2**5,XB=2**5/2523,ZB=3424/2**12,QB=2413/2**7,$B=2392/2**7;var eV=new qI({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:ZR,toBase(e){return e.map(function(e){let t=(Math.max(e**XB-ZB,0)/(QB-$B*e**XB))**JB;return t*1e4/KB})},fromBase(e){return e.map(function(e){let t=Math.max(e*KB/1e4,0),n=ZB+QB*t**qB,r=1+$B*t**qB;return(n/r)**YB})}});const tV=.17883277,nV=.28466892,rV=.55991073,iV=3.7743;var aV=new qI({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:ZR,toBase(e){return e.map(function(e){return e<=.5?e**2/3*iV:(Math.exp((e-rV)/tV)+nV)/12*iV})},fromBase(e){return e.map(function(e){return e/=iV,e<=1/12?Math.sqrt(3*e):tV*Math.log(12*e-nV)+rV})}});const oV={};NI.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=cV(e.W1,e.W2,e.options.method))}),NI.add(`chromatic-adaptation-end`,e=>{e.M||=cV(e.W1,e.W2,e.options.method)});function sV({id:e,toCone_M:t,fromCone_M:n}){oV[e]=arguments[0]}function cV(e,t,n=`Bradford`){let r=oV[n],[i,a,o]=fI(r.toCone_M,e),[s,c,l]=fI(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=fI(u,r.toCone_M),f=fI(r.fromCone_M,d);return f}sV({id:`von Kries`,toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),sV({id:`Bradford`,toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),sV({id:`CAT02`,toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),sV({id:`CAT16`,toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(FI,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),FI.ACES=[.32168/.33767,1,.34065/.33767];const lV=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],uV=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var dV=new qI({id:`acescg`,cssId:`--acescg`,name:`ACEScg`,coords:{r:{range:[0,65504],name:`Red`},g:{range:[0,65504],name:`Green`},b:{range:[0,65504],name:`Blue`}},referred:`scene`,white:FI.ACES,toXYZ_M:lV,fromXYZ_M:uV});const fV=2**-16,pV=-.35828683,mV=(Math.log2(65504)+9.72)/17.52;var hV=new qI({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[pV,mV],name:`Red`},g:{range:[pV,mV],name:`Green`},b:{range:[pV,mV],name:`Blue`}},referred:`scene`,base:dV,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-fV)*2:e<mV?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(fV)+9.72)/17.52:e<fV?(Math.log2(fV+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),gV=Object.freeze({__proto__:null,A98RGB:pB,A98RGB_Linear:fB,ACEScc:hV,ACEScg:dV,CAM16_JMh:DR,HCT:IR,HPLuv:GB,HSL:sB,HSLuv:HB,HSV:cB,HWB:lB,ICTCP:iR,JzCzHz:GL,Jzazbz:WL,LCH:oL,LCHuv:DB,Lab:rL,Lab_D65:Hz,Luv:EB,OKLCH:bB,OKLab:_L,P3:dz,P3_Linear:rz,ProPhoto:yB,ProPhoto_Linear:gB,REC_2020:ez,REC_2020_Linear:ZR,REC_2100_HLG:aV,REC_2100_PQ:eV,XYZ_ABS_D65:OL,XYZ_D50:QI,XYZ_D65:KI,sRGB:uz,sRGB_Linear:oz}),_V=class e{constructor(...e){let t;e.length===1&&(t=VI(e[0]));let n,r,i;t?(n=t.space||t.spaceId,r=t.coords,i=t.alpha):[n,r,i]=e,Object.defineProperty(this,`space`,{value:UI.get(n),writable:!1,enumerable:!0,configurable:!0}),this.coords=r?r.slice():[0,0,0],this.alpha=i>1||i===void 0?1:i<0?0:i;for(let e=0;e<this.coords.length;e++)this.coords[e]===`NaN`&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new e(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...t){let n=pz(this,...t);return n.color=new e(n.color),n}static get(t,...n){return t instanceof e?t:new e(t,...n)}static defineFunction(t,n,r=n){let{instance:i=!0,returns:a}=r,o=function(...t){let r=n(...t);if(a===`color`)r=e.get(r);else if(a===`function<color>`){let t=r;r=function(...n){let r=t(...n);return e.get(r)},Object.assign(r,t)}else a===`array<color>`&&(r=r.map(t=>e.get(t)));return r};t in e||(e[t]=o),i&&(e.prototype[t]=function(...e){return o(this,...e)})}static defineFunctions(t){for(let n in t)e.defineFunction(n,t[n],t[n])}static extend(exports){if(exports.register)exports.register(e);else for(let n in exports)e.defineFunction(n,exports[n])}};_V.defineFunctions({get:YI,getAll:JI,set:ZI,setAll:XI,to:qR,equals:mz,inGamut:bL,toGamut:WR,distance:SL,toString:JR}),Object.assign(_V,{util:jI,hooks:NI,WHITES:FI,Space:UI,spaces:UI.registry,parse:BI,defaults:PI});for(let e of Object.keys(gV))UI.register(gV[e]);for(let e in UI.registry)vV(e,UI.registry[e]);NI.add(`colorspace-init-end`,e=>{var t,n;vV(e.id,e),(t=n=e.aliases)?.forEach(t=>{vV(t,e)})});function vV(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(_V.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return UI.resolveCoord([t,n]),!0}catch{}return Reflect.has(e,n)},get:(e,n,r)=>{if(n&&typeof n!=`symbol`&&!(n in e)){let{index:r}=UI.resolveCoord([t,n]);if(r>=0)return e[r]}return Reflect.get(e,n,r)},set:(n,r,i,a)=>{if(r&&typeof r!=`symbol`&&!(r in n)||r>=0){let{index:a}=UI.resolveCoord([t,r]);if(a>=0)return n[a]=i,this.setAll(e,n),!0}return Reflect.set(n,r,i,a)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}_V.extend(VR),_V.extend({deltaE:Zz}),Object.assign(_V,{deltaEMethods:VR}),_V.extend(eB),_V.extend({contrast:Kz}),_V.extend(Xz),_V.extend(vz),_V.extend(oB),_V.extend(Gz);const{vec2:yV,vec4:bV}=yj,xV=e=>{let t=new _V(e);return bV(...t.to(`p3-linear`).coords,t.alpha).value},SV=e=>{let t=.5,n=.5;if(typeof e==`string`){let r=e.toLowerCase().trim().split(/\s+/);r.includes(`left`)?t=0:r.includes(`right`)?t=1:(r.includes(`center`)||r.length===1&&(r[0]===`top`||r[0]===`bottom`))&&(t=.5),r.includes(`top`)?n=0:r.includes(`bottom`)?n=1:(r.includes(`center`)||r.length===1&&(r[0]===`left`||r[0]===`right`))&&(n=.5),r.length===1&&r[0]===`center`&&(t=.5,n=.5)}else typeof e==`object`&&e?(t=e.x,n=e.y):console.warn(`Invalid position value provided: ${e}. Defaulting to center.`);return yV(t,1-n).value},{vec2:CV,viewportSize:wV}=yj,TV=(e=CV(0))=>{let t=wV,n=t.x.div(t.y),r=e.x.mul(n);return CV(r,e.y)},EV={name:`Circle`,props:{color:{type:String,default:`#ffffff`,transform:xV,description:`The color of the circle`},backgroundColor:{type:String,default:`transparent`,transform:xV,description:`The background color`},radius:{type:Number,default:1,description:`The radius of the circle`},softness:{type:Number,default:0,description:`Edge softness (0 = sharp, 1 = soft)`},center:{type:Object,default:{x:.5,y:.5},transform:SV}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,uv:o}=yj,s=t(e.center.uniform.x.mul(.5).add(.25),e.center.uniform.y.mul(.5).add(.25)),c=TV(o()),l=TV(s),u=r(c.sub(l)),d=e.softness.uniform,f=e.radius.uniform.mul(.25),p=a(f,f.sub(d),u);return n(i(e.backgroundColor.uniform,e.color.uniform,p),1)}};var DV=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},backgroundColor:{},radius:{},softness:{},center:{}},{blendMode:`normal`,opacity:1,...Object.entries(EV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${EV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(EV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(EV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(EV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,EV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),OV=DV;const kV={name:`DotGrid`,props:{color:{type:String,default:`#ffffff`,description:`Dot color`,transform:xV},density:{type:Number,default:100,description:`Grid density (number of dots)`},dotSize:{type:Number,default:.2,description:`Size of each dot (0-1)`}},fragmentNode:({uniforms:e})=>{let t=rF(),n=e.density.uniform,r=e.dotSize.uniform,i=e.color.uniform,a=AF,o=a.x.div(a.y),s=uF(t.x.mul(o),t.y),c=s.mul(n),l=c.sub(NM(c)),u=FM(l.sub(.5)),d=MM(1).sub(UN(r.mul(.45),r.mul(.5),u)),f=dF(i).mul(d);return fF(f,d)}};var AV=r({__name:`DotGrid`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},density:{},dotSize:{}},{blendMode:`normal`,opacity:1,...Object.entries(kV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${kV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(kV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(kV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(kV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,kV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),jV=AV;const MV={name:`FilmGrain`,props:{intensity:{type:Number,default:.25,description:`Grain intensity (0-1)`},power:{type:Number,default:.645,description:`Controls blending based on brightness`},speed:{type:Number,default:.5,description:`Animation speed of grain noise`}},fragmentNode:({uniforms:e,childNode:t})=>{let n=t||fF(0,0,0,0),r=rF(),i=e=>PM(BN(jM(e,uF(12.9898,78.233))).mul(43758.5453)),a=e=>jM(e,fF(.299,.587,.114,0)),o=i(r).add(CP.mul(e.speed.uniform)),s=PM(BN(o.mul(43758.5453))),c=LM(MM(.5),MM(.75),s).mul(e.intensity.uniform),l=zM(a(n),e.power.uniform),u=n.mul(c),d=kM(l,0,1),f=LM(u,n,d);return fF(f.x,f.y,f.z,n.w)}};var NV=r({__name:`FilmGrain`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},power:{},speed:{}},{blendMode:`normal`,opacity:1,...Object.entries(MV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${MV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(MV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(MV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(MV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,MV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),PV=NV;const FV=new WeakMap,IV={name:`glassTiles`,props:{intensity:{type:Number,default:1,description:`The intensity of the glass tiles effect`},tileCount:{type:Number,default:100,description:`Number of tiles across the shortest dimension`}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,canvas:r})=>{let{vec2:i,vec4:a,floor:o,mul:s,div:c,sub:l,add:u,convertToTexture:d,uv:f,uniform:p}=yj;if(!t)return console.error(`You must pass a child component into the Glass Tiles shader.`),a(0);let m=d(t),h=p(1),g=()=>{r&&(h.value=r.clientWidth/r.clientHeight)};g();let _=FV.get(r);_||(_=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;m.setSize(n*i,r*i),g()}),_.observe(r),FV.set(r,_)),n(()=>{let e=FV.get(r);e&&(e.disconnect(),FV.delete(r))});let v=f(),y=e.intensity.uniform,b=e.tileCount.uniform,x=i(h.greaterThanEqual(1).select(s(b,h),b),h.lessThan(1).select(c(b,h),b)),S=c(o(s(v,x)),x),ee=l(v,S),te=i(.5,.5),ne=s(y,.025),re=c(ee,c(i(1),x)),ie=l(re,te),ae=s(ie,ne),oe=u(ee,ae),se=u(oe,S);return a(m.sample(se))}};var LV=r({__name:`GlassTiles`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},tileCount:{}},{blendMode:`normal`,opacity:1,...Object.entries(IV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${IV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(IV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(IV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(IV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,IV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),RV=LV;const zV={VERTEX:`vertex`,FRAGMENT:`fragment`},BV={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},VV=[`fragment`,`vertex`],uoe=[...VV,`compute`],HV=[`x`,`y`,`z`,`w`],UV=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let WV=1234567;const GV=Math.PI/180,KV=180/Math.PI;function qV(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=UV[e&255]+UV[e>>8&255]+UV[e>>16&255]+UV[e>>24&255]+`-`+UV[t&255]+UV[t>>8&255]+`-`+UV[t>>16&15|64]+UV[t>>24&255]+`-`+UV[n&63|128]+UV[n>>8&255]+`-`+UV[n>>16&255]+UV[n>>24&255]+UV[r&255]+UV[r>>8&255]+UV[r>>16&255]+UV[r>>24&255];return i.toLowerCase()}function JV(e,t,n){return Math.max(t,Math.min(n,e))}function YV(e,t){return(e%t+t)%t}function XV(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function ZV(e,t,n){return e===t?0:(n-e)/(t-e)}function QV(e,t,n){return(1-n)*e+n*t}function $V(e,t,n,r){return QV(e,t,1-Math.exp(-n*r))}function eH(e,t=1){return t-Math.abs(YV(e,t*2)-t)}function tH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function nH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function rH(e,t){return e+Math.floor(Math.random()*(t-e+1))}function iH(e,t){return e+Math.random()*(t-e)}function aH(e){return e*(.5-Math.random())}function oH(e){e!==void 0&&(WV=e);let t=WV+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function sH(e){return e*GV}function cH(e){return e*KV}function lH(e){return(e&e-1)==0&&e!==0}function uH(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function dH(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function fH(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function pH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function mH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const hH={DEG2RAD:GV,RAD2DEG:KV,generateUUID:qV,clamp:JV,euclideanModulo:YV,mapLinear:XV,inverseLerp:ZV,lerp:QV,damp:$V,pingpong:eH,smoothstep:tH,smootherstep:nH,randInt:rH,randFloat:iH,randFloatSpread:aH,seededRandom:oH,degToRad:sH,radToDeg:cH,isPowerOfTwo:lH,ceilPowerOfTwo:uH,floorPowerOfTwo:dH,setQuaternionFromProperEuler:fH,normalize:mH,denormalize:pH},gH=0,_H=1015,vH=``,yH=`srgb`,bH=`srgb-linear`,xH=`linear`,SH=`srgb`,CH=35044,wH=2e3,TH=2001;var EH=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(DH.makeScale(e,t)),this}rotate(e){return this.premultiply(DH.makeRotation(-e)),this}translate(e,t){return this.premultiply(DH.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const DH=new EH,OH={};function kH(e){e in OH||(OH[e]=!0,console.warn(e))}const AH=new EH().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),jH=new EH().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function MH(){let e={enabled:!0,workingColorSpace:bH,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===SH&&(e.r=PH(e.r),e.g=PH(e.g),e.b=PH(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===SH&&(e.r=FH(e.r),e.g=FH(e.g),e.b=FH(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===vH?xH:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return kH(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return kH(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[bH]:{primaries:t,whitePoint:r,transfer:xH,toXYZ:AH,fromXYZ:jH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:yH},outputColorSpaceConfig:{drawingBufferColorSpace:yH}},[yH]:{primaries:t,whitePoint:r,transfer:SH,toXYZ:AH,fromXYZ:jH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:yH}}}),e}const NH=MH();function PH(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function FH(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}const IH={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},LH={h:0,s:0,l:0},RH={h:0,s:0,l:0};function zH(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var BH=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=yH){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,NH.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=NH.workingColorSpace){return this.r=e,this.g=t,this.b=n,NH.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=NH.workingColorSpace){if(e=YV(e,1),t=JV(t,0,1),n=JV(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=zH(i,r,e+1/3),this.g=zH(i,r,e),this.b=zH(i,r,e-1/3)}return NH.colorSpaceToWorking(this,r),this}setStyle(e,t=yH){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=yH){let n=IH[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=PH(e.r),this.g=PH(e.g),this.b=PH(e.b),this}copyLinearToSRGB(e){return this.r=FH(e.r),this.g=FH(e.g),this.b=FH(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yH){return NH.workingToColorSpace(VH.copy(this),e),Math.round(JV(VH.r*255,0,255))*65536+Math.round(JV(VH.g*255,0,255))*256+Math.round(JV(VH.b*255,0,255))}getHexString(e=yH){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=NH.workingColorSpace){NH.workingToColorSpace(VH.copy(this),t);let n=VH.r,r=VH.g,i=VH.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=NH.workingColorSpace){return NH.workingToColorSpace(VH.copy(this),t),e.r=VH.r,e.g=VH.g,e.b=VH.b,e}getStyle(e=yH){NH.workingToColorSpace(VH.copy(this),e);let t=VH.r,n=VH.g,r=VH.b;return e===yH?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(LH),this.setHSL(LH.h+e,LH.s+t,LH.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(LH),e.getHSL(RH);let n=QV(LH.h,RH.h,t),r=QV(LH.s,RH.s,t),i=QV(LH.l,RH.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const VH=new BH;BH.NAMES=IH;var HH=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},UH=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(JV(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},WH=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(KH.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(KH.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=JV(this.x,e.x,t.x),this.y=JV(this.y,e.y,t.y),this.z=JV(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=JV(this.x,e,t),this.y=JV(this.y,e,t),this.z=JV(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(JV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return GH.copy(this).projectOnVector(e),this.sub(GH)}reflect(e){return this.sub(GH.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(JV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const GH=new WH,KH=new UH;var qH=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/JH.setFromMatrixColumn(e,0).length(),i=1/JH.setFromMatrixColumn(e,1).length(),a=1/JH.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(XH,e,ZH)}lookAt(e,t,n){let r=this.elements;return eU.subVectors(e,t),eU.lengthSq()===0&&(eU.z=1),eU.normalize(),QH.crossVectors(n,eU),QH.lengthSq()===0&&(Math.abs(n.z)===1?eU.x+=1e-4:eU.z+=1e-4,eU.normalize(),QH.crossVectors(n,eU)),QH.normalize(),$H.crossVectors(eU,QH),r[0]=QH.x,r[4]=$H.x,r[8]=eU.x,r[1]=QH.y,r[5]=$H.y,r[9]=eU.y,r[2]=QH.z,r[6]=$H.z,r[10]=eU.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=JH.set(r[0],r[1],r[2]).length(),a=JH.set(r[4],r[5],r[6]).length(),o=JH.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],YH.copy(this);let c=1/i,l=1/a,u=1/o;return YH.elements[0]*=c,YH.elements[1]*=c,YH.elements[2]*=c,YH.elements[4]*=l,YH.elements[5]*=l,YH.elements[6]*=l,YH.elements[8]*=u,YH.elements[9]*=u,YH.elements[10]*=u,t.setFromRotationMatrix(YH),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=wH){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===wH)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===TH)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=wH){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===wH)p=(a+i)*u,m=-2*u;else if(o===TH)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const JH=new WH,YH=new qH,XH=new WH(0,0,0),ZH=new WH(1,1,1),QH=new WH,$H=new WH,eU=new WH;var tU=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=JV(this.x,e.x,t.x),this.y=JV(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=JV(this.x,e,t),this.y=JV(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(JV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(JV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},nU=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=JV(this.x,e.x,t.x),this.y=JV(this.y,e.y,t.y),this.z=JV(this.z,e.z,t.z),this.w=JV(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=JV(this.x,e,t),this.y=JV(this.y,e,t),this.z=JV(this.z,e,t),this.w=JV(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(JV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};function rU(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const iU=(...e)=>rU(e);function aU(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of oU(e))n.push(rU(r.slice(0,-4)),i.getCacheKey(t));return rU(n)}function*oU(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}function sU(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function cU(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new BH(...t):n===`vec2`?new tU(...t):n===`vec3`?new WH(...t):n===`vec4`?new nU(...t):n===`mat2`?new HH(...t):n===`mat3`?new EH(...t):n===`mat4`?new qH(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?uU(t[0]):null}function lU(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function uU(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var dU=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const fU={analyze:`setup`,generate:`analyze`};let pU=0;var mU=class extends dU{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=BV.NONE,this.updateBeforeType=BV.NONE,this.updateAfterType=BV.NONE,this.uuid=hH.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:pU++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,BV.FRAME)}onRenderUpdate(e){return this.onUpdate(e,BV.RENDER)}onObjectUpdate(e){return this.onUpdate(e,BV.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of oU(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=iU(aU(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=fU[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return oU(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},hU=mU,gU=class extends hU{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},_U=gU,vU=class extends hU{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},yU=vU,bU=class extends hU{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},xU=bU,SU=class extends _U{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},CU=SU;const wU=HV.join(``);var TU=class extends hU{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(HV.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===wU.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},EU=TU,DU=class extends _U{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=HV[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},OU=DU,kU=class extends _U{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=HV[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},AU=kU,jU=class extends hU{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?sU(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=sU(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=lU(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?cU(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}},MU=jU;const NU=/float|u?int/;var PU=class extends MU{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return NU.test(n)&&NU.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},FU=PU,IU=class extends hU{static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}},LU=IU;let RU=null;const zU=new Map;function R(e,t){if(zU.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);zU.set(e,t)}const BU=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),VU=e=>BU(e).split(``).sort().join(``),HU={setup(e,t){let n=t.shift();return e(pW(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(RU.assign(n,...e),n);if(zU.has(t)){let r=zU.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&zU.has(t.slice(0,t.length-6))){let r=zU.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=BU(t),fW(new EU(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=VU(t.slice(3).toLowerCase()),n=>fW(new OU(e,t,fW(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=VU(t.slice(4).toLowerCase()),()=>fW(new AU(fW(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),fW(new EU(e,t));else if(/^\d+$/.test(t)===!0)return fW(new yU(n,new FU(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>fW(new LU(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},UU=new WeakMap,WU=new WeakMap,GU=function(e,t=null){let n=sU(e);if(n===`node`){let t=UU.get(e);return t===void 0&&(t=new Proxy(e,HU),UU.set(e,t),UU.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return fW(sW(e,t));else if(n===`shader`)return gW(e);return e},KU=function(e,t=null){for(let n in e)e[n]=fW(e[n],t);return e},qU=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=fW(e[r],t);return e},JU=function(e,t=null,n=null,r=null){let i=e=>fW(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...mW(l(t)))):n===null?a=(...n)=>i(new e(t,...mW(l(n)))):(n=fW(n),a=(...r)=>i(new e(t,...mW(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a};var YU=class extends hU{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=WU.get(e.constructor);r===void 0&&(r=new WeakMap,WU.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=fW(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=fW(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=fW(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},XU=class extends hU{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return pW(e),fW(new YU(this,e))}setup(){return this.call()}};const ZU=[!1,!0],QU=[0,1,2,3],$U=[-1,-2],eW=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],tW=new Map;for(let e of ZU)tW.set(e,new FU(e));const nW=new Map;for(let e of QU)nW.set(e,new FU(e,`uint`));const rW=new Map([...nW].map(e=>new FU(e.value,`int`)));for(let e of $U)rW.set(e,new FU(e,`int`));const iW=new Map([...rW].map(e=>new FU(e.value)));for(let e of eW)iW.set(e,new FU(e));for(let e of eW)iW.set(-e,new FU(-e));const aW={bool:tW,uint:nW,ints:rW,float:iW},oW=new Map([...tW,...iW]),sW=(e,t)=>oW.has(e)?oW.get(e):e.isNode===!0?e:new FU(e,t),cW=e=>{try{return e.getNodeType()}catch{return}},lW=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[cU(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return fW(t.get(n[0]));if(n.length===1){let t=sW(n[0],e);return cW(t)===e?fW(t):fW(new xU(t,e))}let r=n.map(e=>sW(e));return fW(new CU(r,e))}},uW=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function dW(e,t){return new Proxy(new XU(e,t),HU)}const fW=(e,t=null)=>GU(e,t),pW=(e,t=null)=>new KU(e,t),mW=(e,t=null)=>new qU(e,t),z=(...e)=>new JU(...e);let hW=0;const gW=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new dW(e,n),i=(...e)=>{let t;pW(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ hW++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i};function _W(e){return RU&&RU.add(e),e}R(`toStack`,_W);const vW=new lW(`color`),yW=new lW(`float`,aW.float),bW=new lW(`int`,aW.ints),xW=new lW(`uint`,aW.uint),SW=new lW(`bool`,aW.bool),CW=new lW(`vec2`),wW=new lW(`ivec2`),TW=new lW(`uvec2`),EW=new lW(`bvec2`),DW=new lW(`vec3`),OW=new lW(`ivec3`),kW=new lW(`uvec3`),AW=new lW(`bvec3`),jW=new lW(`vec4`),MW=new lW(`ivec4`),NW=new lW(`uvec4`),PW=new lW(`bvec4`),FW=new lW(`mat2`),IW=new lW(`mat3`),LW=new lW(`mat4`);R(`toColor`,vW),R(`toFloat`,yW),R(`toInt`,bW),R(`toUint`,xW),R(`toBool`,SW),R(`toVec2`,CW),R(`toIVec2`,wW),R(`toUVec2`,TW),R(`toBVec2`,EW),R(`toVec3`,DW),R(`toIVec3`,OW),R(`toUVec3`,kW),R(`toBVec3`,AW),R(`toVec4`,jW),R(`toIVec4`,MW),R(`toUVec4`,NW),R(`toBVec4`,PW),R(`toMat2`,FW),R(`toMat3`,IW),R(`toMat4`,LW);const RW=z(yU).setParameterLength(2),zW=(e,t)=>fW(new xU(fW(e),t));R(`element`,RW),R(`convert`,zW),R(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),_W(e)));const BW={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var VW=class e extends _U{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(BW[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===wH;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const HW=z(VW,`+`).setParameterLength(2,1/0).setName(`add`),UW=z(VW,`-`).setParameterLength(2,1/0).setName(`sub`),WW=z(VW,`*`).setParameterLength(2,1/0).setName(`mul`),GW=z(VW,`/`).setParameterLength(2,1/0).setName(`div`),KW=z(VW,`%`).setParameterLength(2).setName(`mod`),qW=z(VW,`==`).setParameterLength(2).setName(`equal`),JW=z(VW,`!=`).setParameterLength(2).setName(`notEqual`),YW=z(VW,`<`).setParameterLength(2).setName(`lessThan`),XW=z(VW,`>`).setParameterLength(2).setName(`greaterThan`),ZW=z(VW,`<=`).setParameterLength(2).setName(`lessThanEqual`),QW=z(VW,`>=`).setParameterLength(2).setName(`greaterThanEqual`),$W=z(VW,`&&`).setParameterLength(2,1/0).setName(`and`),eG=z(VW,`||`).setParameterLength(2,1/0).setName(`or`),tG=z(VW,`!`).setParameterLength(1).setName(`not`),nG=z(VW,`^^`).setParameterLength(2).setName(`xor`),rG=z(VW,`&`).setParameterLength(2).setName(`bitAnd`),iG=z(VW,`~`).setParameterLength(2).setName(`bitNot`),aG=z(VW,`|`).setParameterLength(2).setName(`bitOr`),oG=z(VW,`^`).setParameterLength(2).setName(`bitXor`),sG=z(VW,`<<`).setParameterLength(2).setName(`shiftLeft`),cG=z(VW,`>>`).setParameterLength(2).setName(`shiftRight`),lG=gW(([e])=>(e.addAssign(1),e)),uG=gW(([e])=>(e.subAssign(1),e)),dG=gW(([e])=>{let t=bW(e).toConst();return e.addAssign(1),t}),fG=gW(([e])=>{let t=bW(e).toConst();return e.subAssign(1),t});R(`add`,HW),R(`sub`,UW),R(`mul`,WW),R(`div`,GW),R(`mod`,KW),R(`equal`,qW),R(`notEqual`,JW),R(`lessThan`,YW),R(`greaterThan`,XW),R(`lessThanEqual`,ZW),R(`greaterThanEqual`,QW),R(`and`,$W),R(`or`,eG),R(`not`,tG),R(`xor`,nG),R(`bitAnd`,rG),R(`bitNot`,iG),R(`bitOr`,aG),R(`bitXor`,oG),R(`shiftLeft`,sG),R(`shiftRight`,cG),R(`incrementBefore`,lG),R(`decrementBefore`,uG),R(`increment`,dG),R(`decrement`,fG);const pG=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),KW(e,t)),mG=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),KW(bW(e),bW(t)));R(`remainder`,pG),R(`modInt`,mG);var B=class e extends _U{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=UW(1,n);else if(i===e.RECIPROCAL)a=GW(1,n);else if(i===e.DIFFERENCE)a=IG(UW(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=jW(DW(i),0):e=jW(DW(e),0);let o=WW(e,i).xyz;a=OG(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===wH&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===wH&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===TH&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};B.ALL=`all`,B.ANY=`any`,B.RADIANS=`radians`,B.DEGREES=`degrees`,B.EXP=`exp`,B.EXP2=`exp2`,B.LOG=`log`,B.LOG2=`log2`,B.SQRT=`sqrt`,B.INVERSE_SQRT=`inversesqrt`,B.FLOOR=`floor`,B.CEIL=`ceil`,B.NORMALIZE=`normalize`,B.FRACT=`fract`,B.SIN=`sin`,B.COS=`cos`,B.TAN=`tan`,B.ASIN=`asin`,B.ACOS=`acos`,B.ATAN=`atan`,B.ABS=`abs`,B.SIGN=`sign`,B.LENGTH=`length`,B.NEGATE=`negate`,B.ONE_MINUS=`oneMinus`,B.DFDX=`dFdx`,B.DFDY=`dFdy`,B.ROUND=`round`,B.RECIPROCAL=`reciprocal`,B.TRUNC=`trunc`,B.FWIDTH=`fwidth`,B.TRANSPOSE=`transpose`,B.BITCAST=`bitcast`,B.EQUALS=`equals`,B.MIN=`min`,B.MAX=`max`,B.STEP=`step`,B.REFLECT=`reflect`,B.DISTANCE=`distance`,B.DIFFERENCE=`difference`,B.DOT=`dot`,B.CROSS=`cross`,B.POW=`pow`,B.TRANSFORM_DIRECTION=`transformDirection`,B.MIX=`mix`,B.CLAMP=`clamp`,B.REFRACT=`refract`,B.SMOOTHSTEP=`smoothstep`,B.FACEFORWARD=`faceforward`;const hG=yW(Math.PI),doe=yW(Math.PI*2),gG=z(B,B.ALL).setParameterLength(1),_G=z(B,B.ANY).setParameterLength(1),vG=z(B,B.RADIANS).setParameterLength(1),yG=z(B,B.DEGREES).setParameterLength(1),bG=z(B,B.EXP).setParameterLength(1),xG=z(B,B.EXP2).setParameterLength(1),SG=z(B,B.LOG).setParameterLength(1),CG=z(B,B.LOG2).setParameterLength(1),wG=z(B,B.SQRT).setParameterLength(1),TG=z(B,B.INVERSE_SQRT).setParameterLength(1),EG=z(B,B.FLOOR).setParameterLength(1),DG=z(B,B.CEIL).setParameterLength(1),OG=z(B,B.NORMALIZE).setParameterLength(1),kG=z(B,B.FRACT).setParameterLength(1),AG=z(B,B.SIN).setParameterLength(1),jG=z(B,B.COS).setParameterLength(1),MG=z(B,B.TAN).setParameterLength(1),NG=z(B,B.ASIN).setParameterLength(1),PG=z(B,B.ACOS).setParameterLength(1),FG=z(B,B.ATAN).setParameterLength(1,2),IG=z(B,B.ABS).setParameterLength(1),LG=z(B,B.SIGN).setParameterLength(1),RG=z(B,B.LENGTH).setParameterLength(1),zG=z(B,B.NEGATE).setParameterLength(1),BG=z(B,B.ONE_MINUS).setParameterLength(1),VG=z(B,B.DFDX).setParameterLength(1),HG=z(B,B.DFDY).setParameterLength(1),UG=z(B,B.ROUND).setParameterLength(1),WG=z(B,B.RECIPROCAL).setParameterLength(1),GG=z(B,B.TRUNC).setParameterLength(1),KG=z(B,B.FWIDTH).setParameterLength(1),qG=z(B,B.TRANSPOSE).setParameterLength(1),JG=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),qW(e,t)),YG=z(B,B.MIN).setParameterLength(2,1/0),XG=z(B,B.MAX).setParameterLength(2,1/0),ZG=z(B,B.STEP).setParameterLength(2),QG=z(B,B.REFLECT).setParameterLength(2),$G=z(B,B.DISTANCE).setParameterLength(2),eK=z(B,B.DIFFERENCE).setParameterLength(2),tK=z(B,B.DOT).setParameterLength(2),nK=z(B,B.CROSS).setParameterLength(2),rK=z(B,B.POW).setParameterLength(2),iK=z(B,B.POW,2).setParameterLength(1),aK=z(B,B.POW,3).setParameterLength(1),oK=z(B,B.POW,4).setParameterLength(1),sK=z(B,B.TRANSFORM_DIRECTION).setParameterLength(2),cK=e=>WW(LG(e),rK(IG(e),1/3)),lK=e=>tK(e,e),uK=z(B,B.MIX).setParameterLength(3),dK=(e,t=0,n=1)=>fW(new B(B.CLAMP,fW(e),fW(t),fW(n))),fK=e=>dK(e),pK=z(B,B.REFRACT).setParameterLength(3),mK=z(B,B.SMOOTHSTEP).setParameterLength(3),hK=z(B,B.FACEFORWARD).setParameterLength(3),gK=gW(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=tK(e.xy,CW(t,n)),a=KW(i,hG);return kG(AG(a).mul(r))}),_K=(e,t,n)=>uK(t,n,e),vK=(e,t,n)=>mK(t,n,e),yK=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),FG(e,t));R(`all`,gG),R(`any`,_G),R(`equals`,JG),R(`radians`,vG),R(`degrees`,yG),R(`exp`,bG),R(`exp2`,xG),R(`log`,SG),R(`log2`,CG),R(`sqrt`,wG),R(`inverseSqrt`,TG),R(`floor`,EG),R(`ceil`,DG),R(`normalize`,OG),R(`fract`,kG),R(`sin`,AG),R(`cos`,jG),R(`tan`,MG),R(`asin`,NG),R(`acos`,PG),R(`atan`,FG),R(`abs`,IG),R(`sign`,LG),R(`length`,RG),R(`lengthSq`,lK),R(`negate`,zG),R(`oneMinus`,BG),R(`dFdx`,VG),R(`dFdy`,HG),R(`round`,UG),R(`reciprocal`,WG),R(`trunc`,GG),R(`fwidth`,KG),R(`atan2`,yK),R(`min`,YG),R(`max`,XG),R(`step`,ZG),R(`reflect`,QG),R(`distance`,$G),R(`dot`,tK),R(`cross`,nK),R(`pow`,rK),R(`pow2`,iK),R(`pow3`,aK),R(`pow4`,oK),R(`transformDirection`,sK),R(`mix`,_K),R(`clamp`,dK),R(`refract`,pK),R(`smoothstep`,vK),R(`faceForward`,hK),R(`difference`,eK),R(`saturate`,fK),R(`cbrt`,cK),R(`transpose`,qG),R(`rand`,gK);var bK=class extends _U{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const xK=(...e)=>{let t;if(e.length===1){let n=e[0];t=new bK(null,n.length,n)}else{let n=e[0],r=e[1];t=new bK(n,r)}return fW(t)};R(`toArray`,(e,t)=>xK(Array(t).fill(e)));var SK=class extends hU{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const CK=e=>new SK(e),wK=(e,t=0)=>new SK(e,!0,t),TK=wK(`render`),EK=CK(`object`);var DK=class extends MU{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=EK}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const OK=(e,t)=>{let n=uW(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return fW(new DK(r,n))};var kK=class extends hU{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const AK=(e,t)=>fW(new kK(e,t));var jK=class extends _U{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=HV.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const MK=z(jK).setParameterLength(2);R(`assign`,MK);var NK=class extends _U{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(yW(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(yW(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const PK=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?mW(t):pW(t[0]),fW(new NK(fW(e),t)));R(`call`,PK);var FK=class extends hU{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?AK(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
396
|
+
var<${n}> ${e} : ${a};`}},oj=class{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture===null?e.depth&&e.stencil?t=L.Depth24PlusStencil8:e.depth&&(t=L.Depth24Plus):t=this.getTextureFormatGPU(e.depthTexture),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,n=e.getRenderTarget();t=n?n.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);t||=1;let n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0,r=n?1:t;return{samples:t,primarySamples:r,isMSAA:n}}getCurrentColorFormat(e){let t;return t=e.textures===null?this.getPreferredCanvasFormat():this.getTextureFormatGPU(e.textures[0]),t}getCurrentColorSpace(e){return e.textures===null?this.backend.renderer.outputColorSpace:e.textures[0].colorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return uA.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return uA.LineList;if(e.isLine)return uA.LineStrip;if(e.isMesh)return uA.TriangleList}getSampleCount(e){let t=1;return e>1&&(t=2**Math.floor(Math.log2(e)),t===2&&(t=4)),t}getSampleCountRenderContext(e){return e.textures===null?this.getSampleCount(this.backend.renderer.samples):this.getSampleCount(e.sampleCount)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===st)return L.BGRA8Unorm;if(e===mt)return L.RGBA16Float;throw Error(`Unsupported outputType`)}};const sj=new Map([[Int8Array,[`sint8`,`snorm8`]],[Uint8Array,[`uint8`,`unorm8`]],[Int16Array,[`sint16`,`snorm16`]],[Uint16Array,[`uint16`,`unorm16`]],[Int32Array,[`sint32`,`snorm32`]],[Uint32Array,[`uint32`,`unorm32`]],[Float32Array,[`float32`]]]),cj=new Map([[ja,[`float16`]]]),lj=new Map([[Int32Array,`sint32`],[Int16Array,`sint32`],[Uint32Array,`uint32`],[Uint16Array,`uint32`],[Float32Array,`float32`]]);var uj=class{constructor(e){this.backend=e}createAttribute(e,t){let n=this._getBufferAttribute(e),r=this.backend,i=r.get(n),a=i.buffer;if(a===void 0){let o=r.device,s=n.array;if(e.normalized===!1){if(s.constructor===Int16Array||s.constructor===Int8Array)s=new Int32Array(s);else if((s.constructor===Uint16Array||s.constructor===Uint8Array)&&(s=new Uint32Array(s),t&GPUBufferUsage.INDEX))for(let e=0;e<s.length;e++)s[e]===65535&&(s[e]=4294967295)}if(n.array=s,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){s=new s.constructor(n.count*4);for(let e=0;e<n.count;e++)s.set(n.array.subarray(e*3,e*3+3),e*4);n.itemSize=4,n.array=s,i._force3to4BytesAlignment=!0}let c=s.byteLength,l=c+(4-c%4)%4;a=o.createBuffer({label:n.name,size:l,usage:t,mappedAtCreation:!0}),new s.constructor(a.getMappedRange()).set(s),a.unmap(),i.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),n=this.backend,r=n.device,i=n.get(t),a=n.get(t).buffer,o=t.array;if(i._force3to4BytesAlignment===!0){o=new o.constructor(t.count*4);for(let e=0;e<t.count;e++)o.set(t.array.subarray(e*3,e*3+3),e*4);t.array=o}let s=this._isTypedArray(o),c=t.updateRanges;if(c.length===0)r.queue.writeBuffer(a,0,o,0);else{let e=s?1:o.BYTES_PER_ELEMENT;for(let t=0,n=c.length;t<n;t++){let n=c[t],l,u;if(i._force3to4BytesAlignment===!0){let t=Math.floor(n.start/3),r=Math.ceil(n.count/3);l=t*4*e,u=r*4*e}else l=n.start*e,u=n.count*e;let d=l*(s?o.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,d,o,l,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),n=new Map;for(let e=0;e<t.length;e++){let r=t[e],i=r.array.BYTES_PER_ELEMENT,a=this._getBufferAttribute(r),o=n.get(a);if(o===void 0){let e,t;r.isInterleavedBufferAttribute===!0?(e=r.data.stride*i,t=r.data.isInstancedInterleavedBuffer?AA.Instance:AA.Vertex):(e=r.itemSize*i,t=r.isInstancedBufferAttribute?AA.Instance:AA.Vertex),r.normalized===!1&&(r.array.constructor===Int16Array||r.array.constructor===Uint16Array)&&(e=4),o={arrayStride:e,attributes:[],stepMode:t},n.set(a,o)}let s=this._getVertexFormat(r),c=r.isInterleavedBufferAttribute===!0?r.offset*i:0;o.attributes.push({shaderLocation:e,offset:c,format:s})}return Array.from(n.values())}destroyAttribute(e){let t=this.backend,n=t.get(this._getBufferAttribute(e));n.buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,n=t.device,r=t.get(this._getBufferAttribute(e)),i=r.buffer,a=i.size,o=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),s=n.createCommandEncoder({label:`readback_encoder_${e.name}`});s.copyBufferToBuffer(i,0,o,0,a);let c=s.finish();n.queue.submit([c]),await o.mapAsync(GPUMapMode.READ);let l=o.getMappedRange(),u=new e.array.constructor(l.slice(0));return o.unmap(),u.buffer}_getVertexFormat(e){let{itemSize:t,normalized:n}=e,r=e.array.constructor,i=e.constructor,a;if(t===1)a=lj.get(r);else{let e=cj.get(i)||sj.get(r),o=e[n?1:0];if(o){let e=r.BYTES_PER_ELEMENT*t,n=Math.floor((e+3)/4)*4,i=n/r.BYTES_PER_ELEMENT;if(i%1)throw Error(`THREE.WebGPUAttributeUtils: Bad vertex format item size.`);a=`${o}x${i}`}}return a||console.error(`THREE.WebGPUAttributeUtils: Vertex format not supported yet.`),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}},dj=class{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){let t=this.backend,n=t.device,r=[],i=0;for(let n of e.bindings){let e={binding:i++,visibility:n.visibility};if(n.isUniformBuffer||n.isStorageBuffer){let t={};n.isStorageBuffer&&(n.visibility&4&&(n.access===_c.READ_WRITE||n.access===_c.WRITE_ONLY)?t.type=CA.Storage:t.type=CA.ReadOnlyStorage),e.buffer=t}else if(n.isSampler){let r={};n.texture.isDepthTexture&&(n.texture.compareFunction===null?t.compatibilityMode&&(r.type=TA.NonFiltering):r.type=TA.Comparison),e.sampler=r}else if(n.isSampledTexture&&n.texture.isVideoTexture)e.externalTexture={};else if(n.isSampledTexture&&n.store){let t={};t.format=this.backend.get(n.texture).texture.format;let r=n.access;r===_c.READ_WRITE?t.access=wA.ReadWrite:r===_c.WRITE_ONLY?t.access=wA.WriteOnly:t.access=wA.ReadOnly,e.storageTexture=t}else if(n.isSampledTexture){let r={},{primarySamples:i}=t.utils.getTextureSampleData(n.texture);if(i>1&&(r.multisampled=!0,n.texture.isDepthTexture||(r.sampleType=EA.UnfilterableFloat)),n.texture.isDepthTexture)t.compatibilityMode&&n.texture.compareFunction===null?r.sampleType=EA.UnfilterableFloat:r.sampleType=EA.Depth;else if(n.texture.isDataTexture||n.texture.isDataArrayTexture||n.texture.isData3DTexture){let e=n.texture.type;e===dt?r.sampleType=EA.SInt:e===ft?r.sampleType=EA.UInt:e===pt&&(this.backend.hasFeature(`float32-filterable`)?r.sampleType=EA.Float:r.sampleType=EA.UnfilterableFloat)}n.isSampledCubeTexture?r.viewDimension=OA.Cube:n.texture.isArrayTexture||n.texture.isDataArrayTexture||n.texture.isCompressedArrayTexture?r.viewDimension=OA.TwoDArray:n.isSampledTexture3D&&(r.viewDimension=OA.ThreeD),e.texture=r}else console.error(`WebGPUBindingUtils: Unsupported binding "${n}".`);r.push(e)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){let{backend:i,bindGroupLayoutCache:a}=this,o=i.get(e),s=a.get(e.bindingsReference);s===void 0&&(s=this.createBindingsLayout(e),a.set(e.bindingsReference,s));let c;n>0&&(o.groups===void 0&&(o.groups=[],o.versions=[]),o.versions[n]===r&&(c=o.groups[n])),c===void 0&&(c=this.createBindGroup(e,s),n>0&&(o.groups[n]=c,o.versions[n]=r)),o.group=c,o.layout=s}updateBinding(e){let t=this.backend,n=t.device,r=e.buffer,i=t.get(e).buffer;n.queue.writeBuffer(i,0,r,0)}createBindGroupIndex(e,t){let n=this.backend,r=n.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],o=r.createBuffer({label:`bindingCameraIndex_`+a,size:16,usage:i});r.queue.writeBuffer(o,0,e,0);let s=[{binding:0,resource:{buffer:o}}];return r.createBindGroup({label:`bindGroupCameraIndex_`+a,layout:t,entries:s})}createBindGroup(e,t){let n=this.backend,r=n.device,i=0,a=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=n.get(t);if(e.buffer===void 0){let n=t.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=r.createBuffer({label:`bindingBuffer_`+t.name,size:n,usage:i});e.buffer=a}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=n.get(t);if(e.buffer===void 0){let r=t.attribute;e.buffer=n.get(r).buffer}a.push({binding:i,resource:{buffer:e.buffer}})}else if(t.isSampler){let e=n.get(t.texture);a.push({binding:i,resource:e.sampler})}else if(t.isSampledTexture){let e=n.get(t.texture),o;if(e.externalTexture!==void 0)o=r.importExternalTexture({source:e.externalTexture});else{let n=t.store?1:e.texture.mipLevelCount,r=`view-${e.texture.width}-${e.texture.height}-${n}`;if(o=e[r],o===void 0){let i=kA.All,a;a=t.isSampledCubeTexture?OA.Cube:t.isSampledTexture3D?OA.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?OA.TwoDArray:OA.TwoD,o=e[r]=e.texture.createView({aspect:i,dimension:a,mipLevelCount:n})}}a.push({binding:i,resource:o})}i++}return r.createBindGroup({label:`bindGroup_`+e.name,layout:t,entries:a})}},fj=class{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){let n=this._activePipelines.get(e);n!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let{object:n,material:r,geometry:i,pipeline:a}=e,{vertexProgram:o,fragmentProgram:s}=a,c=this.backend,l=c.device,u=c.utils,d=c.get(a),f=[];for(let t of e.getBindings()){let e=c.get(t);f.push(e.layout)}let p=c.attributeUtils.createShaderVertexBuffers(e),m;r.blending!==ae&&(r.blending!==oe||r.transparent!==!1)&&(m=this._getBlending(r));let h={};r.stencilWrite===!0&&(h={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});let g=this._getColorWriteMask(r),_=[];if(e.context.textures!==null){let t=e.context.textures;for(let e=0;e<t.length;e++){let n=u.getTextureFormatGPU(t[e]);_.push({format:n,blend:m,writeMask:g})}}else{let t=u.getCurrentColorFormat(e.context);_.push({format:t,blend:m,writeMask:g})}let v=c.get(o).module,y=c.get(s).module,b=this._getPrimitiveState(n,i,r),x=this._getDepthCompare(r),S=u.getCurrentDepthStencilFormat(e.context),ee=this._getSampleCount(e.context),te={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},v,{buffers:p}),fragment:Object.assign({},y,{targets:_}),primitive:b,multisample:{count:ee,alphaToCoverageEnabled:r.alphaToCoverage&&ee>1},layout:l.createPipelineLayout({bindGroupLayouts:f})},ne={},re=e.context.depth,ie=e.context.stencil;if((re===!0||ie===!0)&&(re===!0&&(ne.format=S,ne.depthWriteEnabled=r.depthWrite,ne.depthCompare=x),ie===!0&&(ne.stencilFront=h,ne.stencilBack={},ne.stencilReadMask=r.stencilFuncMask,ne.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(ne.depthBias=r.polygonOffsetUnits,ne.depthBiasSlopeScale=r.polygonOffsetFactor,ne.depthBiasClamp=0),te.depthStencil=ne),t===null)d.pipeline=l.createRenderPipeline(te);else{let e=new Promise(e=>{l.createRenderPipelineAsync(te).then(t=>{d.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t=`renderBundleEncoder`){let n=this.backend,{utils:r,device:i}=n,a=r.getCurrentDepthStencilFormat(e),o=r.getCurrentColorFormat(e),s=this._getSampleCount(e),c={label:t,colorFormats:[o],depthStencilFormat:a,sampleCount:s};return i.createRenderBundleEncoder(c)}createComputePipeline(e,t){let n=this.backend,r=n.device,i=n.get(e.computeProgram).module,a=n.get(e),o=[];for(let e of t){let t=n.get(e);o.push(t.layout)}a.pipeline=r.createComputePipeline({compute:i,layout:r.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,n,r=e.blending,i=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(r===ue){let r=e.blendSrcAlpha===null?i:e.blendSrcAlpha,s=e.blendDstAlpha===null?a:e.blendDstAlpha,c=e.blendEquationAlpha===null?o:e.blendEquationAlpha;t={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},n={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(s),operation:this._getBlendOperation(c)}}else{let i=e.premultipliedAlpha,a=(e,r,i,a)=>{t={srcFactor:e,dstFactor:r,operation:bA.Add},n={srcFactor:i,dstFactor:a,operation:bA.Add}};if(i)switch(r){case oe:a(yA.One,yA.OneMinusSrcAlpha,yA.One,yA.OneMinusSrcAlpha);break;case se:a(yA.One,yA.One,yA.One,yA.One);break;case ce:a(yA.Zero,yA.OneMinusSrc,yA.Zero,yA.One);break;case le:a(yA.Zero,yA.Src,yA.Zero,yA.SrcAlpha);break}else switch(r){case oe:a(yA.SrcAlpha,yA.OneMinusSrcAlpha,yA.One,yA.OneMinusSrcAlpha);break;case se:a(yA.SrcAlpha,yA.One,yA.SrcAlpha,yA.One);break;case ce:a(yA.Zero,yA.OneMinusSrc,yA.Zero,yA.One);break;case le:a(yA.Zero,yA.Src,yA.Zero,yA.Src);break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error(`THREE.WebGPURenderer: Invalid blending: `,r)}_getBlendFactor(e){let t;switch(e){case ge:t=yA.Zero;break;case _e:t=yA.One;break;case ve:t=yA.Src;break;case ye:t=yA.OneMinusSrc;break;case be:t=yA.SrcAlpha;break;case xe:t=yA.OneMinusSrcAlpha;break;case we:t=yA.Dst;break;case Te:t=yA.OneMinusDst;break;case Se:t=yA.DstAlpha;break;case Ce:t=yA.OneMinusDstAlpha;break;case Ee:t=yA.SrcAlphaSaturated;break;case Gb:t=yA.Constant;break;case Kb:t=yA.OneMinusConstant;break;default:console.error(`THREE.WebGPURenderer: Blend factor not supported.`,e)}return t}_getStencilCompare(e){let t,n=e.stencilFunc;switch(n){case On:t=dA.Never;break;case Fn:t=dA.Always;break;case kn:t=dA.Less;break;case jn:t=dA.LessEqual;break;case An:t=dA.Equal;break;case Pn:t=dA.GreaterEqual;break;case Mn:t=dA.Greater;break;case Nn:t=dA.NotEqual;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil function.`,n)}return t}_getStencilOperation(e){let t;switch(e){case xn:t=SA.Keep;break;case bn:t=SA.Zero;break;case Sn:t=SA.Replace;break;case Dn:t=SA.Invert;break;case Cn:t=SA.IncrementClamp;break;case wn:t=SA.DecrementClamp;break;case Tn:t=SA.IncrementWrap;break;case En:t=SA.DecrementWrap;break;default:console.error(`THREE.WebGPURenderer: Invalid stencil operation.`,t)}return t}_getBlendOperation(e){let t;switch(e){case de:t=bA.Add;break;case fe:t=bA.Subtract;break;case pe:t=bA.ReverseSubtract;break;case me:t=bA.Min;break;case he:t=bA.Max;break;default:console.error(`THREE.WebGPUPipelineUtils: Blend equation not supported.`,e)}return t}_getPrimitiveState(e,t,n){let r={},i=this.backend.utils;switch(r.topology=i.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?gA.Uint16:gA.Uint32),n.side){case ne:r.frontFace=mA.CCW,r.cullMode=hA.Back;break;case re:r.frontFace=mA.CCW,r.cullMode=hA.Front;break;case ie:r.frontFace=mA.CCW,r.cullMode=hA.None;break;default:console.error(`THREE.WebGPUPipelineUtils: Unknown material.side value.`,n.side);break}return r}_getColorWriteMask(e){return e.colorWrite===!0?xA.All:xA.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=dA.Always;else{let n=e.depthFunc;switch(n){case De:t=dA.Never;break;case Oe:t=dA.Always;break;case ke:t=dA.Less;break;case Ae:t=dA.LessEqual;break;case je:t=dA.Equal;break;case Me:t=dA.GreaterEqual;break;case Ne:t=dA.Greater;break;case Pe:t=dA.NotEqual;break;default:console.error(`THREE.WebGPUPipelineUtils: Invalid depth function.`,n)}}return t}},pj=class extends oA{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:`timestamp`,count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Mr(`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 t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e.id,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{let e=await this.pendingResolve;return e}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!==`unmapped`)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();let r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);let i=r.finish();if(this.device.queue.submit([i]),this.resultBuffer.mapState!==`unmapped`)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState===`mapped`&&this.resultBuffer.unmap(),this.lastValue;let a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),o=0;for(let[,t]of e){let e=a[t],n=a[t+1],r=Number(n-e)/1e6;o+=r}return this.resultBuffer.unmap(),this.lastValue=o,o}catch(e){return console.error(`Error resolving queries:`,e),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(e){console.error(`Error waiting for pending resolve:`,e)}if(this.resultBuffer&&this.resultBuffer.mapState===`mapped`)try{this.resultBuffer.unmap()}catch(e){console.error(`Error unmapping buffer:`,e)}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}}},mj=class extends Hk{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new oj(this),this.attributeUtils=new uj(this),this.bindingUtils=new dj(this),this.pipelineUtils=new fj(this),this.textureUtils=new BA(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);let t=this.parameters,n;if(t.device===void 0){let e={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?`compatibility`:void 0},r=typeof navigator<`u`?await navigator.gpu.requestAdapter(e):null;if(r===null)throw Error(`WebGPUBackend: Unable to create WebGPU adapter.`);let i=Object.values(jA),a=[];for(let e of i)r.features.has(e)&&a.push(e);let o={requiredFeatures:a,requiredLimits:t.requiredLimits};n=await r.requestDevice(o)}else n=t.device;n.lost.then(t=>{let n={api:`WebGPU`,message:t.message||`Unknown reason`,reason:t.reason||null,originalEvent:t};e.onDeviceLost(n)});let r=t.context===void 0?e.domElement.getContext(`webgpu`):t.context;this.device=n,this.context=r;let i=t.alpha?`premultiplied`:`opaque`;this.trackTimestamp=this.trackTimestamp&&this.hasFeature(jA.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 qn}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){let t=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});let n=e.colorAttachments[0];this.renderer.samples>0?n.view=this.colorBuffer.createView():n.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}let t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){let n=e.renderTarget,r=this.get(n),i=r.descriptors;if(i===void 0||r.width!==n.width||r.height!==n.height||r.dimensions!==n.dimensions||r.activeMipmapLevel!==e.activeMipmapLevel||r.activeCubeFace!==e.activeCubeFace||r.samples!==n.samples){i={},r.descriptors=i;let e=()=>{n.removeEventListener(`dispose`,e),this.delete(n)};n.hasEventListener(`dispose`,e)===!1&&n.addEventListener(`dispose`,e)}let a=e.getCacheKey(),o=i[a];if(o===void 0){let t=e.textures,s=[],c,l=this._isRenderCameraDepthArray(e);for(let r=0;r<t.length;r++){let i=this.get(t[r]),a={label:`colorAttachment_${r}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:OA.TwoD};if(n.isRenderTarget3D)c=e.activeCubeFace,a.baseArrayLayer=0,a.dimension=OA.ThreeD,a.depthOrArrayLayers=t[r].image.depth;else if(n.isRenderTarget&&t[r].image.depth>1)if(l===!0){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...a,baseArrayLayer:e,arrayLayerCount:1,dimension:OA.TwoD},n=i.texture.createView(t);s.push({view:n,resolveTarget:void 0,depthSlice:void 0})}}else a.dimension=OA.TwoDArray,a.depthOrArrayLayers=t[r].image.depth;if(l!==!0){let e=i.texture.createView(a),t,n;i.msaaTexture===void 0?(t=e,n=void 0):(t=i.msaaTexture.createView(),n=e),s.push({view:t,resolveTarget:n,depthSlice:c})}}if(o={textureViews:s},e.depth){let t=this.get(e.depthTexture),n={};e.depthTexture.isArrayTexture&&(n.dimension=OA.TwoD,n.arrayLayerCount=1,n.baseArrayLayer=e.activeCubeFace),o.depthStencilView=t.texture.createView(n)}i[a]=o,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace,r.dimensions=n.dimensions}let s={colorAttachments:[]};for(let e=0;e<o.textureViews.length;e++){let n=o.textureViews[e],r={r:0,g:0,b:0,a:1};e===0&&t.clearValue&&(r=t.clearValue),s.colorAttachments.push({view:n.view,depthSlice:n.depthSlice,resolveTarget:n.resolveTarget,loadOp:t.loadOp||pA.Load,storeOp:t.storeOp||fA.Store,clearValue:r})}return o.depthStencilView&&(s.depthStencilAttachment={view:o.depthStencilView}),s}beginRender(e){let t=this.get(e),n=this.device,r=e.occlusionQueryCount,i;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,i=n.createQuerySet({type:`occlusion`,count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=i,t.occlusionQueryIndex=0,t.occlusionQueryObjects=Array(r),t.lastOcclusionObject=null);let a;a=e.textures===null?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:pA.Load}),this.initTimestampQuery(e,a),a.occlusionQuerySet=i;let o=a.depthStencilAttachment;if(e.textures!==null){let t=a.colorAttachments;for(let n=0;n<t.length;n++){let r=t[n];e.clearColor?(r.clearValue=n===0?e.clearColorValue:{r:0,g:0,b:0,a:1},r.loadOp=pA.Clear):r.loadOp=pA.Load,r.storeOp=fA.Store}}else{let t=a.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=pA.Clear):t.loadOp=pA.Load,t.storeOp=fA.Store}e.depth&&(e.clearDepth?(o.depthClearValue=e.clearDepthValue,o.depthLoadOp=pA.Clear):o.depthLoadOp=pA.Load,o.depthStoreOp=fA.Store),e.stencil&&(e.clearStencil?(o.stencilClearValue=e.clearStencilValue,o.stencilLoadOp=pA.Clear):o.stencilLoadOp=pA.Load,o.stencilStoreOp=fA.Store);let s=n.createCommandEncoder({label:`renderContext_`+e.id});if(this._isRenderCameraDepthArray(e)===!0){let n=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==n.length?this._createDepthLayerDescriptors(e,t,a,n):this._updateDepthLayerDescriptors(e,t,n),t.bundleEncoders=[],t.bundleSets=[];for(let r=0;r<n.length;r++){let n=this.pipelineUtils.createBundleEncoder(e,`renderBundleArrayCamera_`+r),i={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(n),t.bundleSets.push(i)}t.currentPass=null}else{let n=s.beginRenderPass(a);if(t.currentPass=n,e.viewport&&this.updateViewport(e),e.scissor){let{x:t,y:r,width:i,height:a}=e.scissorValue;n.setScissorRect(t,r,i,a)}}t.descriptor=a,t.encoder=s,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){let i=n.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||=[];for(let o=0;o<r.length;o++){let r={...n,colorAttachments:[{...n.colorAttachments[0],view:n.colorAttachments[o].view}]};if(n.depthStencilAttachment){let t=o;a.viewCache[t]||(a.viewCache[t]=a.texture.createView({dimension:OA.TwoD,baseArrayLayer:o,arrayLayerCount:1})),r.depthStencilAttachment={view:a.viewCache[t],depthLoadOp:i.depthLoadOp||pA.Clear,depthStoreOp:i.depthStoreOp||fA.Store,depthClearValue:i.depthClearValue||1},e.stencil&&(r.depthStencilAttachment.stencilLoadOp=i.stencilLoadOp,r.depthStencilAttachment.stencilStoreOp=i.stencilStoreOp,r.depthStencilAttachment.stencilClearValue=i.stencilClearValue)}else r.depthStencilAttachment={...i};t.layerDescriptors.push(r)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){let n=t.layerDescriptors[r];if(n.depthStencilAttachment){let t=n.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=pA.Clear):t.depthLoadOp=pA.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=pA.Clear):t.stencilLoadOp=pA.Load)}}}finishRender(e){let t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){let n=[];for(let e=0;e<t.bundleEncoders.length;e++){let r=t.bundleEncoders[e];n.push(r.finish())}for(let i=0;i<t.layerDescriptors.length;i++)if(i<n.length){let a=t.layerDescriptors[i],o=r.beginRenderPass(a);if(e.viewport){let{x:t,y:n,width:r,height:i,minDepth:a,maxDepth:s}=e.viewportValue;o.setViewport(t,n,r,i,a,s)}if(e.scissor){let{x:t,y:n,width:r,height:i}=e.scissorValue;o.setScissorRect(t,n,r,i)}o.executeBundles([n[i]]),o.end()}}else t.currentPass&&t.currentPass.end();if(n>0){let r=n*8,i=this.occludedResolveCache.get(r);i===void 0&&(i=this.device.createBuffer({size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(r,i));let a=this.device.createBuffer({size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,i,0),t.encoder.copyBufferToBuffer(i,0,a,0,r),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){let t=e.textures;for(let e=0;e<t.length;e++){let n=t[e];n.generateMipmaps===!0&&this.textureUtils.generateMipmaps(n)}}}isOccluded(e,t){let n=this.get(e);return n.occluded&&n.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await n.mapAsync(GPUMapMode.READ);let i=n.getMappedRange(),a=new BigUint64Array(i);for(let t=0;t<r.length;t++)a[t]===BigInt(0)&&e.add(r[t]);n.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:n,y:r,width:i,height:a,minDepth:o,maxDepth:s}=e.viewportValue;t.setViewport(n,r,i,a,o,s)}getClearColor(){let e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,n,r=null){let i=this.device,a=this.renderer,o=[],s,c,l,u;if(e){let e=this.getClearColor();c={r:e.r,g:e.g,b:e.b,a:e.a}}if(r===null){l=a.depth,u=a.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){o=t.colorAttachments;let e=o[0];e.clearValue=c,e.loadOp=pA.Clear,e.storeOp=fA.Store}(l||u)&&(s=t.depthStencilAttachment)}else{l=r.depth,u=r.stencil;let i={loadOp:e?pA.Clear:pA.Load,clearValue:e?c:void 0};l&&(i.depthLoadOp=t?pA.Clear:pA.Load,i.depthClearValue=t?a.getClearDepth():void 0,i.depthStoreOp=fA.Store),u&&(i.stencilLoadOp=n?pA.Clear:pA.Load,i.stencilClearValue=n?a.getClearStencil():void 0,i.stencilStoreOp=fA.Store);let d=this._getRenderPassDescriptor(r,i);o=d.colorAttachments,s=d.depthStencilAttachment}l&&s&&s.depthLoadOp===void 0&&(t?(s.depthLoadOp=pA.Clear,s.depthClearValue=a.getClearDepth(),s.depthStoreOp=fA.Store):(s.depthLoadOp=pA.Load,s.depthStoreOp=fA.Store)),u&&s&&s.stencilLoadOp===void 0&&(n?(s.stencilLoadOp=pA.Clear,s.stencilClearValue=a.getClearStencil(),s.stencilStoreOp=fA.Store):(s.stencilLoadOp=pA.Load,s.stencilStoreOp=fA.Store));let d=i.createCommandEncoder({label:`clear`}),f=d.beginRenderPass({colorAttachments:o,depthStencilAttachment:s});f.end(),i.queue.submit([d.finish()])}beginCompute(e){let t=this.get(e),n={label:`computeGroup_`+e.id};this.initTimestampQuery(e,n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:`computeGroup_`+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r){let{passEncoderGPU:i}=this.get(e),a=this.get(r).pipeline;this.pipelineUtils.setPipeline(i,a);for(let e=0,t=n.length;e<t;e++){let t=n[e],r=this.get(t);i.setBindGroup(e,r.group)}let o=this.device.limits.maxComputeWorkgroupsPerDimension,s=this.get(t);s.dispatchSize===void 0&&(s.dispatchSize={x:0,y:1,z:1});let{dispatchSize:c}=s;t.dispatchCount>o?(c.x=Math.min(t.dispatchCount,o),c.y=Math.ceil(t.dispatchCount/o)):c.x=t.dispatchCount,i.dispatchWorkgroups(c.x,c.y,c.z)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}async waitForGPU(){await this.device.queue.onSubmittedWorkDone()}draw(e,t){let{object:n,material:r,context:i,pipeline:a}=e,o=e.getBindings(),s=this.get(i),c=this.get(a).pipeline,l=e.getIndex(),u=l!==null,d=e.getDrawParameters();if(d===null)return;let f=(t,n)=>{this.pipelineUtils.setPipeline(t,c),n.pipeline=c;let a=n.bindingGroups;for(let e=0,n=o.length;e<n;e++){let n=o[e],r=this.get(n);a[n.index]!==n.id&&(t.setBindGroup(n.index,r.group),a[n.index]=n.id)}if(u===!0&&n.index!==l){let e=this.get(l).buffer,r=l.array instanceof Uint16Array?gA.Uint16:gA.Uint32;t.setIndexBuffer(e,r),n.index=l}let d=e.getVertexBuffers();for(let e=0,r=d.length;e<r;e++){let r=d[e];if(n.attributes[e]!==r){let i=this.get(r).buffer;t.setVertexBuffer(e,i),n.attributes[e]=r}}i.stencil===!0&&r.stencilWrite===!0&&s.currentStencilRef!==r.stencilRef&&(t.setStencilReference(r.stencilRef),s.currentStencilRef=r.stencilRef)},p=(r,i)=>{if(f(r,i),n.isBatchedMesh===!0){let e=n._multiDrawStarts,i=n._multiDrawCounts,a=n._multiDrawCount,o=n._multiDrawInstances;o!==null&&Mr(`THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`);for(let s=0;s<a;s++){let a=o?o[s]:1,c=a>1?0:s;u===!0?r.drawIndexed(i[s],a,e[s]/l.array.BYTES_PER_ELEMENT,0,c):r.draw(i[s],a,e[s],c),t.update(n,i[s],a)}}else if(u===!0){let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndexedIndirect(e,0)}else r.drawIndexed(i,a,o,0,0);t.update(n,i,a)}else{let{vertexCount:i,instanceCount:a,firstVertex:o}=d,s=e.getIndirect();if(s!==null){let e=this.get(s).buffer;r.drawIndirect(e,0)}else r.draw(i,a,o,0);t.update(n,i,a)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),r=e.camera.cameras,a=e.getBindingGroup(`cameraIndex`);if(t.indexesGPU===void 0||t.indexesGPU.length!==r.length){let e=this.get(a),n=[],i=new Uint32Array([0,0,0,0]);for(let t=0,a=r.length;t<a;t++){i[0]=t;let r=this.bindingUtils.createBindGroupIndex(i,e.layout);n.push(r)}t.indexesGPU=n}let o=this.renderer.getPixelRatio();for(let e=0,c=r.length;e<c;e++){let c=r[e];if(n.layers.test(c.layers)){let n=c.viewport,r=s.currentPass,l=s.currentSets;if(s.bundleEncoders){let t=s.bundleEncoders[e],n=s.bundleSets[e];r=t,l=n}n&&r.setViewport(Math.floor(n.x*o),Math.floor(n.y*o),Math.floor(n.width*o),Math.floor(n.height*o),i.viewportValue.minDepth,i.viewportValue.maxDepth),a&&t.indexesGPU&&(r.setBindGroup(a.index,t.indexesGPU[e]),l.bindingGroups[a.index]=a.id),p(r,l)}}}else if(s.currentPass){if(s.occlusionQuerySet!==void 0){let e=s.lastOcclusionObject;e!==n&&(e!==null&&e.occlusionTest===!0&&(s.currentPass.endOcclusionQuery(),s.occlusionQueryIndex++),n.occlusionTest===!0&&(s.currentPass.beginOcclusionQuery(s.occlusionQueryIndex),s.occlusionQueryObjects[s.occlusionQueryIndex]=n),s.lastOcclusionObject=n)}p(s.currentPass,s.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:n,material:r}=e,i=this.utils,a=i.getSampleCountRenderContext(e.context),o=i.getCurrentColorSpace(e.context),s=i.getCurrentColorFormat(e.context),c=i.getCurrentDepthStencilFormat(e.context),l=i.getPrimitiveTopology(n,r),u=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==o||t.colorFormat!==s||t.depthStencilFormat!==c||t.primitiveTopology!==l||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=o,t.colorFormat=s,t.depthStencilFormat=c,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContextCacheKey,u=!0),u}getRenderCacheKey(e){let{object:t,material:n}=e,r=this.utils,i=e.context;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,r.getSampleCountRenderContext(i),r.getCurrentColorSpace(i),r.getCurrentColorFormat(i),r.getCurrentDepthStencilFormat(i),r.getPrimitiveTopology(t,n),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}async copyTextureToBuffer(e,t,n,r,i,a){return this.textureUtils.copyTextureToBuffer(e,t,n,r,i,a)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;let n=e.isComputeNode?`compute`:`render`;this.timestampQueryPool[n]||(this.timestampQueryPool[n]=new pj(this.device,n,2048));let r=this.timestampQueryPool[n],i=r.allocateQueriesForContext(e);t.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:i,endOfPassWriteIndex:i+1}}createNodeBuilder(e,t){return new aj(e,t)}createProgram(e){let t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name===``?``:`_${e.name}`)}),entryPoint:`main`}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){let t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){let n=this.get(e),r=n.currentPass,i=r.finish();this.get(t).bundleGPU=i,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){let n=this.get(e);n.renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,i=0,a=0){let o=0,s=0,c=0,l=0,u=0,d=0,f=e.image.width,p=e.image.height,m=1;n!==null&&(n.isBox3===!0?(l=n.min.x,u=n.min.y,d=n.min.z,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=n.max.z-n.min.z):(l=n.min.x,u=n.min.y,f=n.max.x-n.min.x,p=n.max.y-n.min.y,m=1)),r!==null&&(o=r.x,s=r.y,c=r.z||0);let h=this.device.createCommandEncoder({label:`copyTextureToTexture_`+e.id+`_`+t.id}),g=this.get(e).texture,_=this.get(t).texture;h.copyTextureToTexture({texture:g,mipLevel:i,origin:{x:l,y:u,z:d}},{texture:_,mipLevel:a,origin:{x:o,y:s,z:c}},[f,p,m]),this.device.queue.submit([h.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){let r=this.get(t),i=null;i=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();let a=this.get(e).texture;if(i.format!==a.format){console.error(`WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.`,i.format,a.format);return}let o;if(r.currentPass?(r.currentPass.end(),o=r.encoder):o=this.device.createCommandEncoder({label:`copyFramebufferToTexture_`+e.id}),o.copyTextureToTexture({texture:i,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),r.currentPass){let{descriptor:e}=r;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=pA.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=pA.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=pA.Load),r.currentPass=o.beginRenderPass(e),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){let{x:e,y:n,width:i,height:a}=t.scissorValue;r.currentPass.setScissorRect(e,n,i,a)}}else this.device.queue.submit([o.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}},hj=class extends Es{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}},gj=class extends Es{constructor(e,t,n,r,i,a){super(e,t,n,r,i,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}},_j=class extends qO{constructor(){super(),this.addMaterial(yv,`MeshPhongMaterial`),this.addMaterial(hb,`MeshStandardMaterial`),this.addMaterial(_b,`MeshPhysicalMaterial`),this.addMaterial(xb,`MeshToonMaterial`),this.addMaterial(lv,`MeshBasicMaterial`),this.addMaterial(_v,`MeshLambertMaterial`),this.addMaterial(J_,`MeshNormalMaterial`),this.addMaterial(Tb,`MeshMatcapMaterial`),this.addMaterial(z_,`LineBasicMaterial`),this.addMaterial(V_,`LineDashedMaterial`),this.addMaterial(jb,`PointsMaterial`),this.addMaterial(kb,`SpriteMaterial`),this.addMaterial(Pb,`ShadowMaterial`),this.addLight(qT,js),this.addLight(vO,Ps),this.addLight(SO,Is),this.addLight(CO,Es),this.addLight(DO,Fs),this.addLight(OO,bs),this.addLight(kO,Rs),this.addLight(wO,hj),this.addLight(EO,gj),this.addToneMapping(LC,ze),this.addToneMapping(RC,Be),this.addToneMapping(zC,Ve),this.addToneMapping(VC,He),this.addToneMapping(GC,Ue),this.addToneMapping(KC,We)}},vj=class extends gk{constructor(e={}){let t;e.forceWebGL?t=lA:(t=mj,e.getFallback=()=>(console.warn(`THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend.`),new lA(e)));let n=new t(e);super(n,e),this.library=new _j,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}},yj={};_(yj,{BRDF_GGX:()=>bj,BRDF_Lambert:()=>xj,BasicShadowFilter:()=>Sj,Break:()=>Cj,Const:()=>hte,Continue:()=>wj,DFGApprox:()=>Tj,D_GGX:()=>Ej,Discard:()=>Dj,EPSILON:()=>Oj,F_Schlick:()=>kj,Fn:()=>Aj,INFINITY:()=>jj,If:()=>Mj,Loop:()=>Pj,NodeAccess:()=>Rj,NodeShaderStage:()=>Fj,NodeType:()=>Ij,NodeUpdateType:()=>Lj,PCFShadowFilter:()=>zj,PCFSoftShadowFilter:()=>Bj,PI:()=>Vj,PI2:()=>Hj,Return:()=>Uj,Schlick_to_F0:()=>Wj,ScriptableNodeResources:()=>Gj,ShaderNode:()=>Kj,Switch:()=>Nj,TBNViewMatrix:()=>qj,VSMShadowFilter:()=>Jj,V_GGX_SmithCorrelated:()=>Yj,Var:()=>lF,abs:()=>Xj,acesFilmicToneMapping:()=>Zj,acos:()=>Qj,add:()=>$j,addNodeElement:()=>eM,agxToneMapping:()=>tM,all:()=>nM,alphaT:()=>rM,and:()=>iM,anisotropy:()=>aM,anisotropyB:()=>oM,anisotropyT:()=>sM,any:()=>cM,append:()=>lM,array:()=>uM,arrayBuffer:()=>dM,asin:()=>fM,assign:()=>pM,atan:()=>mM,atan2:()=>hM,atomicAdd:()=>gM,atomicAnd:()=>_M,atomicFunc:()=>vM,atomicLoad:()=>TM,atomicMax:()=>yM,atomicMin:()=>bM,atomicOr:()=>xM,atomicStore:()=>SM,atomicSub:()=>CM,atomicXor:()=>wM,attenuationColor:()=>EM,attenuationDistance:()=>DM,attribute:()=>OM,attributeArray:()=>kM,backgroundBlurriness:()=>hee,backgroundIntensity:()=>gee,backgroundRotation:()=>_ee,batch:()=>vee,billboarding:()=>yee,bitAnd:()=>bee,bitNot:()=>xee,bitOr:()=>See,bitXor:()=>Cee,bitangentGeometry:()=>wee,bitangentLocal:()=>Tee,bitangentView:()=>Eee,bitangentWorld:()=>Dee,bitcast:()=>Oee,blendBurn:()=>kee,blendColor:()=>Aee,blendDodge:()=>jee,blendOverlay:()=>Mee,blendScreen:()=>Nee,blur:()=>Pee,bool:()=>Fee,buffer:()=>Iee,bufferAttribute:()=>Lee,bumpMap:()=>Ree,burn:()=>zee,bvec2:()=>Bee,bvec3:()=>Vee,bvec4:()=>Hee,bypass:()=>Uee,cache:()=>Wee,call:()=>Gee,cameraFar:()=>Kee,cameraIndex:()=>qee,cameraNear:()=>Jee,cameraNormalMatrix:()=>Yee,cameraPosition:()=>Xee,cameraProjectionMatrix:()=>Zee,cameraProjectionMatrixInverse:()=>Qee,cameraViewMatrix:()=>$ee,cameraWorldMatrix:()=>ete,cbrt:()=>tte,cdl:()=>nte,ceil:()=>rte,checker:()=>ite,cineonToneMapping:()=>ate,clamp:()=>AM,clearcoat:()=>ote,clearcoatRoughness:()=>ste,code:()=>cte,color:()=>lte,colorSpaceToWorking:()=>ute,colorToDirection:()=>dte,compute:()=>fte,computeSkinning:()=>pte,cond:()=>mte,context:()=>gte,convert:()=>_te,convertColorSpace:()=>vte,convertToTexture:()=>yte,cos:()=>jM,cross:()=>bte,cubeTexture:()=>xte,dFdx:()=>Ste,dFdy:()=>Cte,dashSize:()=>wte,debug:()=>Tte,decrement:()=>Ete,decrementBefore:()=>Dte,defaultBuildStages:()=>Ote,defaultShaderStages:()=>kte,defined:()=>Ate,degrees:()=>jte,deltaTime:()=>Mte,densityFog:()=>Nte,densityFogFactor:()=>Pte,depth:()=>Fte,depthPass:()=>Ite,difference:()=>Lte,diffuseColor:()=>Rte,directPointLight:()=>zte,directionToColor:()=>Bte,dispersion:()=>Vte,distance:()=>Hte,div:()=>Ute,dodge:()=>Wte,dot:()=>MM,drawIndex:()=>Gte,dynamicBufferAttribute:()=>Kte,element:()=>qte,emissive:()=>Jte,equal:()=>Yte,equals:()=>Xte,equirectUV:()=>Zte,exp:()=>Qte,exp2:()=>$te,expression:()=>ene,faceDirection:()=>tne,faceForward:()=>nne,faceforward:()=>rne,float:()=>NM,floor:()=>PM,fog:()=>ine,fract:()=>FM,frameGroup:()=>ane,frameId:()=>one,frontFacing:()=>sne,fwidth:()=>cne,gain:()=>lne,gapSize:()=>une,getConstNodeType:()=>dne,getCurrentStack:()=>fne,getDirection:()=>pne,getDistanceAttenuation:()=>mne,getGeometryRoughness:()=>hne,getNormalFromDepth:()=>gne,getParallaxCorrectNormal:()=>_ne,getRoughness:()=>vne,getScreenPosition:()=>yne,getShIrradianceAt:()=>bne,getShadowMaterial:()=>Cne,getShadowRenderObjectFunction:()=>wne,getTextureIndex:()=>xne,getViewPosition:()=>Sne,globalId:()=>hre,glsl:()=>Tne,glslFn:()=>Ene,grayscale:()=>Dne,greaterThan:()=>One,greaterThanEqual:()=>kne,hash:()=>Ane,highpModelNormalViewMatrix:()=>jne,highpModelViewMatrix:()=>Mne,hue:()=>Nne,increment:()=>Pne,incrementBefore:()=>Fne,instance:()=>Ine,instanceIndex:()=>Lne,instancedArray:()=>Rne,instancedBufferAttribute:()=>zne,instancedDynamicBufferAttribute:()=>Bne,instancedMesh:()=>Vne,int:()=>Hne,inverseSqrt:()=>Une,inversesqrt:()=>Wne,invocationLocalIndex:()=>Gne,invocationSubgroupIndex:()=>Kne,ior:()=>qne,iridescence:()=>Jne,iridescenceIOR:()=>Yne,iridescenceThickness:()=>Xne,ivec2:()=>Zne,ivec3:()=>Qne,ivec4:()=>$ne,js:()=>ere,label:()=>tre,length:()=>IM,lengthSq:()=>nre,lessThan:()=>rre,lessThanEqual:()=>ire,lightPosition:()=>are,lightProjectionUV:()=>JM,lightShadowMatrix:()=>ore,lightTargetDirection:()=>sre,lightTargetPosition:()=>cre,lightViewPosition:()=>lre,lightingContext:()=>ure,lights:()=>dre,linearDepth:()=>fre,linearToneMapping:()=>pre,localId:()=>mre,log:()=>gre,log2:()=>_re,logarithmicDepthToViewZ:()=>vre,loop:()=>yre,luminance:()=>bre,mat2:()=>Sre,mat3:()=>Cre,mat4:()=>wre,matcapUV:()=>Tre,materialAO:()=>Ere,materialAlphaTest:()=>Dre,materialAnisotropy:()=>Ore,materialAnisotropyVector:()=>kre,materialAttenuationColor:()=>Are,materialAttenuationDistance:()=>jre,materialClearcoat:()=>Mre,materialClearcoatNormal:()=>Nre,materialClearcoatRoughness:()=>Pre,materialColor:()=>Fre,materialDispersion:()=>Ire,materialEmissive:()=>Lre,materialIOR:()=>Rre,materialIridescence:()=>zre,materialIridescenceIOR:()=>Bre,materialIridescenceThickness:()=>Vre,materialLightMap:()=>Hre,materialLineDashOffset:()=>Ure,materialLineDashSize:()=>Wre,materialLineGapSize:()=>Gre,materialLineScale:()=>Kre,materialLineWidth:()=>qre,materialMetalness:()=>Jre,materialNormal:()=>Yre,materialOpacity:()=>Xre,materialPointSize:()=>Zre,materialReference:()=>Qre,materialReflectivity:()=>$re,materialRefractionRatio:()=>eie,materialRotation:()=>tie,materialRoughness:()=>nie,materialSheen:()=>rie,materialSheenRoughness:()=>iie,materialShininess:()=>aie,materialSpecular:()=>oie,materialSpecularColor:()=>sie,materialSpecularIntensity:()=>cie,materialSpecularStrength:()=>lie,materialThickness:()=>uie,materialTransmission:()=>die,max:()=>LM,maxMipLevel:()=>fie,mediumpModelViewMatrix:()=>xre,metalness:()=>pie,min:()=>mie,mix:()=>RM,mixElement:()=>hie,mod:()=>gie,modInt:()=>_ie,modelDirection:()=>vie,modelNormalMatrix:()=>yie,modelPosition:()=>bie,modelRadius:()=>xie,modelScale:()=>Sie,modelViewMatrix:()=>Cie,modelViewPosition:()=>wie,modelViewProjection:()=>Tie,modelWorldMatrix:()=>Eie,modelWorldMatrixInverse:()=>Die,morphReference:()=>Oie,mrt:()=>kie,mul:()=>zM,mx_aastep:()=>Aie,mx_cell_noise_float:()=>jie,mx_contrast:()=>Mie,mx_fractal_noise_float:()=>Nie,mx_fractal_noise_vec2:()=>Pie,mx_fractal_noise_vec3:()=>Fie,mx_fractal_noise_vec4:()=>Iie,mx_hsvtorgb:()=>Lie,mx_noise_float:()=>Rie,mx_noise_vec3:()=>zie,mx_noise_vec4:()=>Bie,mx_ramplr:()=>Vie,mx_ramptb:()=>Hie,mx_rgbtohsv:()=>Uie,mx_safepower:()=>Wie,mx_splitlr:()=>Gie,mx_splittb:()=>Kie,mx_srgb_texture_to_lin_rec709:()=>qie,mx_transform_uv:()=>Jie,mx_worley_noise_float:()=>Yie,mx_worley_noise_vec2:()=>Xie,mx_worley_noise_vec3:()=>Zie,namespace:()=>Qie,negate:()=>$ie,neutralToneMapping:()=>eae,nodeArray:()=>tae,nodeImmutable:()=>nae,nodeObject:()=>rae,nodeObjects:()=>iae,nodeProxy:()=>aae,normalFlat:()=>oae,normalGeometry:()=>sae,normalLocal:()=>cae,normalMap:()=>lae,normalView:()=>uae,normalWorld:()=>dae,normalize:()=>fae,not:()=>pae,notEqual:()=>mae,numWorkgroups:()=>hae,objectDirection:()=>gae,objectGroup:()=>_ae,objectPosition:()=>vae,objectRadius:()=>yae,objectScale:()=>bae,objectViewPosition:()=>xae,objectWorldMatrix:()=>Sae,oneMinus:()=>Cae,or:()=>wae,orthographicDepthToViewZ:()=>Tae,oscSawtooth:()=>Eae,oscSine:()=>Dae,oscSquare:()=>Oae,oscTriangle:()=>kae,output:()=>Aae,outputStruct:()=>jae,overlay:()=>Mae,overloadingFn:()=>Nae,parabola:()=>Pae,parallaxDirection:()=>Fae,parallaxUV:()=>Iae,parameter:()=>Lae,pass:()=>Rae,passTexture:()=>zae,pcurve:()=>Bae,perspectiveDepthToViewZ:()=>Vae,pmremTexture:()=>Hae,pointShadow:()=>MN,pointUV:()=>Uae,pointWidth:()=>Wae,positionGeometry:()=>Gae,positionLocal:()=>Kae,positionPrevious:()=>qae,positionView:()=>Jae,positionViewDirection:()=>Yae,positionWorld:()=>Xae,positionWorldDirection:()=>Zae,posterize:()=>Qae,pow:()=>BM,pow2:()=>$ae,pow3:()=>eoe,pow4:()=>toe,premult:()=>noe,property:()=>VM,radians:()=>HM,rand:()=>UM,range:()=>WM,rangeFog:()=>GM,rangeFogFactor:()=>KM,reciprocal:()=>qM,reference:()=>YM,referenceBuffer:()=>XM,reflect:()=>ZM,reflectVector:()=>QM,reflectView:()=>$M,reflector:()=>eN,refract:()=>tN,refractVector:()=>nN,refractView:()=>rN,reinhardToneMapping:()=>iN,remainder:()=>aN,remap:()=>oN,remapClamp:()=>sN,renderGroup:()=>cN,renderOutput:()=>lN,rendererReference:()=>uN,rotate:()=>dN,rotateUV:()=>fN,roughness:()=>pN,round:()=>mN,rtt:()=>hN,sRGBTransferEOTF:()=>gN,sRGBTransferOETF:()=>_N,sampler:()=>vN,samplerComparison:()=>yN,saturate:()=>bN,saturation:()=>xN,screen:()=>SN,screenCoordinate:()=>CN,screenSize:()=>wN,screenUV:()=>TN,scriptable:()=>EN,scriptableValue:()=>DN,select:()=>ON,setCurrentStack:()=>kN,shaderStages:()=>AN,shadow:()=>jN,shadowPositionWorld:()=>NN,shapeCircle:()=>FN,sharedUniformGroup:()=>PN,sheen:()=>IN,sheenRoughness:()=>LN,shiftLeft:()=>RN,shiftRight:()=>zN,shininess:()=>BN,sign:()=>VN,sin:()=>HN,sinc:()=>UN,skinning:()=>WN,smoothstep:()=>GN,smoothstepElement:()=>KN,specularColor:()=>qN,specularF90:()=>JN,spherizeUV:()=>YN,split:()=>XN,spritesheetUV:()=>ZN,sqrt:()=>QN,stack:()=>$N,step:()=>eP,storage:()=>tP,storageBarrier:()=>nP,storageObject:()=>rP,storageTexture:()=>iP,string:()=>aP,struct:()=>oP,sub:()=>sP,subgroupIndex:()=>cP,subgroupSize:()=>lP,tan:()=>uP,tangentGeometry:()=>dP,tangentLocal:()=>fP,tangentView:()=>pP,tangentWorld:()=>mP,temp:()=>hP,texture:()=>gP,texture3D:()=>_P,textureBarrier:()=>vP,textureBicubic:()=>yP,textureCubeUV:()=>bP,textureLoad:()=>xP,textureSize:()=>SP,textureStore:()=>CP,thickness:()=>wP,time:()=>TP,timerDelta:()=>EP,timerGlobal:()=>DP,timerLocal:()=>OP,toneMapping:()=>kP,toneMappingExposure:()=>AP,toonOutlinePass:()=>jP,transformDirection:()=>MP,transformNormal:()=>NP,transformNormalToView:()=>PP,transformedBentNormalView:()=>FP,transformedBitangentView:()=>IP,transformedBitangentWorld:()=>LP,transformedClearcoatNormalView:()=>RP,transformedNormalView:()=>zP,transformedNormalWorld:()=>BP,transformedTangentView:()=>VP,transformedTangentWorld:()=>HP,transmission:()=>UP,transpose:()=>WP,triNoise3D:()=>GP,triplanarTexture:()=>KP,triplanarTextures:()=>qP,trunc:()=>JP,tslFn:()=>YP,uint:()=>XP,uniform:()=>ZP,uniformArray:()=>$P,uniformCubeTexture:()=>QP,uniformGroup:()=>eF,uniformTexture:()=>tF,uniforms:()=>nF,unpremult:()=>rF,userData:()=>iF,uv:()=>aF,uvec2:()=>oF,uvec3:()=>sF,uvec4:()=>cF,varying:()=>uF,varyingProperty:()=>dF,vec2:()=>fF,vec3:()=>pF,vec4:()=>mF,vectorComponents:()=>hF,velocity:()=>gF,vertexColor:()=>_F,vertexIndex:()=>vF,vibrance:()=>yF,viewZToLogarithmicDepth:()=>bF,viewZToOrthographicDepth:()=>xF,viewZToPerspectiveDepth:()=>SF,viewport:()=>CF,viewportBottomLeft:()=>wF,viewportCoordinate:()=>TF,viewportDepthTexture:()=>EF,viewportLinearDepth:()=>DF,viewportMipTexture:()=>OF,viewportResolution:()=>kF,viewportSafeUV:()=>AF,viewportSharedTexture:()=>jF,viewportSize:()=>MF,viewportTexture:()=>NF,viewportTopLeft:()=>PF,viewportUV:()=>FF,wgsl:()=>IF,wgslFn:()=>LF,workgroupArray:()=>RF,workgroupBarrier:()=>zF,workgroupId:()=>BF,workingToColorSpace:()=>VF,xor:()=>HF});const bj=I.BRDF_GGX,xj=I.BRDF_Lambert,Sj=I.BasicShadowFilter,Cj=I.Break,wj=I.Continue,Tj=I.DFGApprox,Ej=I.D_GGX,Dj=I.Discard,Oj=I.EPSILON,kj=I.F_Schlick,Aj=I.Fn,jj=I.INFINITY,Mj=I.If,Nj=I.Switch,Pj=I.Loop,Fj=I.NodeShaderStage,Ij=I.NodeType,Lj=I.NodeUpdateType,Rj=I.NodeAccess,zj=I.PCFShadowFilter,Bj=I.PCFSoftShadowFilter,Vj=I.PI,Hj=I.PI2,Uj=I.Return,Wj=I.Schlick_to_F0,Gj=I.ScriptableNodeResources,Kj=I.ShaderNode,qj=I.TBNViewMatrix,Jj=I.VSMShadowFilter,Yj=I.V_GGX_SmithCorrelated,Xj=I.abs,Zj=I.acesFilmicToneMapping,Qj=I.acos,$j=I.add,eM=I.addNodeElement,tM=I.agxToneMapping,nM=I.all,rM=I.alphaT,iM=I.and,aM=I.anisotropy,oM=I.anisotropyB,sM=I.anisotropyT,cM=I.any,lM=I.append,uM=I.array,dM=I.arrayBuffer,fM=I.asin,pM=I.assign,mM=I.atan,hM=I.atan2,gM=I.atomicAdd,_M=I.atomicAnd,vM=I.atomicFunc,yM=I.atomicMax,bM=I.atomicMin,xM=I.atomicOr,SM=I.atomicStore,CM=I.atomicSub,wM=I.atomicXor,TM=I.atomicLoad,EM=I.attenuationColor,DM=I.attenuationDistance,OM=I.attribute,kM=I.attributeArray,hee=I.backgroundBlurriness,gee=I.backgroundIntensity,_ee=I.backgroundRotation,vee=I.batch,yee=I.billboarding,bee=I.bitAnd,xee=I.bitNot,See=I.bitOr,Cee=I.bitXor,wee=I.bitangentGeometry,Tee=I.bitangentLocal,Eee=I.bitangentView,Dee=I.bitangentWorld,Oee=I.bitcast,kee=I.blendBurn,Aee=I.blendColor,jee=I.blendDodge,Mee=I.blendOverlay,Nee=I.blendScreen,Pee=I.blur,Fee=I.bool,Iee=I.buffer,Lee=I.bufferAttribute,Ree=I.bumpMap,zee=I.burn,Bee=I.bvec2,Vee=I.bvec3,Hee=I.bvec4,Uee=I.bypass,Wee=I.cache,Gee=I.call,Kee=I.cameraFar,qee=I.cameraIndex,Jee=I.cameraNear,Yee=I.cameraNormalMatrix,Xee=I.cameraPosition,Zee=I.cameraProjectionMatrix,Qee=I.cameraProjectionMatrixInverse,$ee=I.cameraViewMatrix,ete=I.cameraWorldMatrix,tte=I.cbrt,nte=I.cdl,rte=I.ceil,ite=I.checker,ate=I.cineonToneMapping,AM=I.clamp,ote=I.clearcoat,ste=I.clearcoatRoughness,cte=I.code,lte=I.color,ute=I.colorSpaceToWorking,dte=I.colorToDirection,fte=I.compute,pte=I.computeSkinning,mte=I.cond,hte=I.Const,gte=I.context,_te=I.convert,vte=I.convertColorSpace,yte=I.convertToTexture,jM=I.cos,bte=I.cross,xte=I.cubeTexture,Ste=I.dFdx,Cte=I.dFdy,wte=I.dashSize,Tte=I.debug,Ete=I.decrement,Dte=I.decrementBefore,Ote=I.defaultBuildStages,kte=I.defaultShaderStages,Ate=I.defined,jte=I.degrees,Mte=I.deltaTime,Nte=I.densityFog,Pte=I.densityFogFactor,Fte=I.depth,Ite=I.depthPass,Lte=I.difference,Rte=I.diffuseColor,zte=I.directPointLight,Bte=I.directionToColor,Vte=I.dispersion,Hte=I.distance,Ute=I.div,Wte=I.dodge,MM=I.dot,Gte=I.drawIndex,Kte=I.dynamicBufferAttribute,qte=I.element,Jte=I.emissive,Yte=I.equal,Xte=I.equals,Zte=I.equirectUV,Qte=I.exp,$te=I.exp2,ene=I.expression,tne=I.faceDirection,nne=I.faceForward,rne=I.faceforward,NM=I.float,PM=I.floor,ine=I.fog,FM=I.fract,ane=I.frameGroup,one=I.frameId,sne=I.frontFacing,cne=I.fwidth,lne=I.gain,une=I.gapSize,dne=I.getConstNodeType,fne=I.getCurrentStack,pne=I.getDirection,mne=I.getDistanceAttenuation,hne=I.getGeometryRoughness,gne=I.getNormalFromDepth,_ne=I.getParallaxCorrectNormal,vne=I.getRoughness,yne=I.getScreenPosition,bne=I.getShIrradianceAt,xne=I.getTextureIndex,Sne=I.getViewPosition,Cne=I.getShadowMaterial,wne=I.getShadowRenderObjectFunction,Tne=I.glsl,Ene=I.glslFn,Dne=I.grayscale,One=I.greaterThan,kne=I.greaterThanEqual,Ane=I.hash,jne=I.highpModelNormalViewMatrix,Mne=I.highpModelViewMatrix,Nne=I.hue,Pne=I.increment,Fne=I.incrementBefore,Ine=I.instance,Lne=I.instanceIndex,Rne=I.instancedArray,zne=I.instancedBufferAttribute,Bne=I.instancedDynamicBufferAttribute,Vne=I.instancedMesh,Hne=I.int,Une=I.inverseSqrt,Wne=I.inversesqrt,Gne=I.invocationLocalIndex,Kne=I.invocationSubgroupIndex,qne=I.ior,Jne=I.iridescence,Yne=I.iridescenceIOR,Xne=I.iridescenceThickness,Zne=I.ivec2,Qne=I.ivec3,$ne=I.ivec4,ere=I.js,tre=I.label,IM=I.length,nre=I.lengthSq,rre=I.lessThan,ire=I.lessThanEqual,are=I.lightPosition,ore=I.lightShadowMatrix,sre=I.lightTargetDirection,cre=I.lightTargetPosition,lre=I.lightViewPosition,ure=I.lightingContext,dre=I.lights,fre=I.linearDepth,pre=I.linearToneMapping,mre=I.localId,hre=I.globalId,gre=I.log,_re=I.log2,vre=I.logarithmicDepthToViewZ,yre=I.loop,bre=I.luminance,xre=I.mediumpModelViewMatrix,Sre=I.mat2,Cre=I.mat3,wre=I.mat4,Tre=I.matcapUV,Ere=I.materialAO,Dre=I.materialAlphaTest,Ore=I.materialAnisotropy,kre=I.materialAnisotropyVector,Are=I.materialAttenuationColor,jre=I.materialAttenuationDistance,Mre=I.materialClearcoat,Nre=I.materialClearcoatNormal,Pre=I.materialClearcoatRoughness,Fre=I.materialColor,Ire=I.materialDispersion,Lre=I.materialEmissive,Rre=I.materialIOR,zre=I.materialIridescence,Bre=I.materialIridescenceIOR,Vre=I.materialIridescenceThickness,Hre=I.materialLightMap,Ure=I.materialLineDashOffset,Wre=I.materialLineDashSize,Gre=I.materialLineGapSize,Kre=I.materialLineScale,qre=I.materialLineWidth,Jre=I.materialMetalness,Yre=I.materialNormal,Xre=I.materialOpacity,Zre=I.materialPointSize,Qre=I.materialReference,$re=I.materialReflectivity,eie=I.materialRefractionRatio,tie=I.materialRotation,nie=I.materialRoughness,rie=I.materialSheen,iie=I.materialSheenRoughness,aie=I.materialShininess,oie=I.materialSpecular,sie=I.materialSpecularColor,cie=I.materialSpecularIntensity,lie=I.materialSpecularStrength,uie=I.materialThickness,die=I.materialTransmission,LM=I.max,fie=I.maxMipLevel,pie=I.metalness,mie=I.min,RM=I.mix,hie=I.mixElement,gie=I.mod,_ie=I.modInt,vie=I.modelDirection,yie=I.modelNormalMatrix,bie=I.modelPosition,xie=I.modelRadius,Sie=I.modelScale,Cie=I.modelViewMatrix,wie=I.modelViewPosition,Tie=I.modelViewProjection,Eie=I.modelWorldMatrix,Die=I.modelWorldMatrixInverse,Oie=I.morphReference,kie=I.mrt,zM=I.mul,Aie=I.mx_aastep,jie=I.mx_cell_noise_float,Mie=I.mx_contrast,Nie=I.mx_fractal_noise_float,Pie=I.mx_fractal_noise_vec2,Fie=I.mx_fractal_noise_vec3,Iie=I.mx_fractal_noise_vec4,Lie=I.mx_hsvtorgb,Rie=I.mx_noise_float,zie=I.mx_noise_vec3,Bie=I.mx_noise_vec4,Vie=I.mx_ramplr,Hie=I.mx_ramptb,Uie=I.mx_rgbtohsv,Wie=I.mx_safepower,Gie=I.mx_splitlr,Kie=I.mx_splittb,qie=I.mx_srgb_texture_to_lin_rec709,Jie=I.mx_transform_uv,Yie=I.mx_worley_noise_float,Xie=I.mx_worley_noise_vec2,Zie=I.mx_worley_noise_vec3,Qie=I.namespace,$ie=I.negate,eae=I.neutralToneMapping,tae=I.nodeArray,nae=I.nodeImmutable,rae=I.nodeObject,iae=I.nodeObjects,aae=I.nodeProxy,oae=I.normalFlat,sae=I.normalGeometry,cae=I.normalLocal,lae=I.normalMap,uae=I.normalView,dae=I.normalWorld,fae=I.normalize,pae=I.not,mae=I.notEqual,hae=I.numWorkgroups,gae=I.objectDirection,_ae=I.objectGroup,vae=I.objectPosition,yae=I.objectRadius,bae=I.objectScale,xae=I.objectViewPosition,Sae=I.objectWorldMatrix,Cae=I.oneMinus,wae=I.or,Tae=I.orthographicDepthToViewZ,Eae=I.oscSawtooth,Dae=I.oscSine,Oae=I.oscSquare,kae=I.oscTriangle,Aae=I.output,jae=I.outputStruct,Mae=I.overlay,Nae=I.overloadingFn,Pae=I.parabola,Fae=I.parallaxDirection,Iae=I.parallaxUV,Lae=I.parameter,Rae=I.pass,zae=I.passTexture,Bae=I.pcurve,Vae=I.perspectiveDepthToViewZ,Hae=I.pmremTexture,Uae=I.pointUV,Wae=I.pointWidth,Gae=I.positionGeometry,Kae=I.positionLocal,qae=I.positionPrevious,Jae=I.positionView,Yae=I.positionViewDirection,Xae=I.positionWorld,Zae=I.positionWorldDirection,Qae=I.posterize,BM=I.pow,$ae=I.pow2,eoe=I.pow3,toe=I.pow4,noe=I.premult,VM=I.property,HM=I.radians,UM=I.rand,WM=I.range,GM=I.rangeFog,KM=I.rangeFogFactor,qM=I.reciprocal,JM=I.lightProjectionUV,YM=I.reference,XM=I.referenceBuffer,ZM=I.reflect,QM=I.reflectVector,$M=I.reflectView,eN=I.reflector,tN=I.refract,nN=I.refractVector,rN=I.refractView,iN=I.reinhardToneMapping,aN=I.remainder,oN=I.remap,sN=I.remapClamp,cN=I.renderGroup,lN=I.renderOutput,uN=I.rendererReference,dN=I.rotate,fN=I.rotateUV,pN=I.roughness,mN=I.round,hN=I.rtt,gN=I.sRGBTransferEOTF,_N=I.sRGBTransferOETF,vN=I.sampler,yN=I.samplerComparison,bN=I.saturate,xN=I.saturation,SN=I.screen,CN=I.screenCoordinate,wN=I.screenSize,TN=I.screenUV,EN=I.scriptable,DN=I.scriptableValue,ON=I.select,kN=I.setCurrentStack,AN=I.shaderStages,jN=I.shadow,MN=I.pointShadow,NN=I.shadowPositionWorld,PN=I.sharedUniformGroup,FN=I.shapeCircle,IN=I.sheen,LN=I.sheenRoughness,RN=I.shiftLeft,zN=I.shiftRight,BN=I.shininess,VN=I.sign,HN=I.sin,UN=I.sinc,WN=I.skinning,GN=I.smoothstep,KN=I.smoothstepElement,qN=I.specularColor,JN=I.specularF90,YN=I.spherizeUV,XN=I.split,ZN=I.spritesheetUV,QN=I.sqrt,$N=I.stack,eP=I.step,tP=I.storage,nP=I.storageBarrier,rP=I.storageObject,iP=I.storageTexture,aP=I.string,oP=I.struct,sP=I.sub,cP=I.subgroupIndex,lP=I.subgroupSize,uP=I.tan,dP=I.tangentGeometry,fP=I.tangentLocal,pP=I.tangentView,mP=I.tangentWorld,hP=I.temp,gP=I.texture,_P=I.texture3D,vP=I.textureBarrier,yP=I.textureBicubic,bP=I.textureCubeUV,xP=I.textureLoad,SP=I.textureSize,CP=I.textureStore,wP=I.thickness,TP=I.time,EP=I.timerDelta,DP=I.timerGlobal,OP=I.timerLocal,kP=I.toneMapping,AP=I.toneMappingExposure,jP=I.toonOutlinePass,MP=I.transformDirection,NP=I.transformNormal,PP=I.transformNormalToView,FP=I.transformedBentNormalView,IP=I.transformedBitangentView,LP=I.transformedBitangentWorld,RP=I.transformedClearcoatNormalView,zP=I.transformedNormalView,BP=I.transformedNormalWorld,VP=I.transformedTangentView,HP=I.transformedTangentWorld,UP=I.transmission,WP=I.transpose,GP=I.triNoise3D,KP=I.triplanarTexture,qP=I.triplanarTextures,JP=I.trunc,YP=I.tslFn,XP=I.uint,ZP=I.uniform,QP=I.uniformCubeTexture,$P=I.uniformArray,eF=I.uniformGroup,tF=I.uniformTexture,nF=I.uniforms,rF=I.unpremult,iF=I.userData,aF=I.uv,oF=I.uvec2,sF=I.uvec3,cF=I.uvec4,lF=I.Var,uF=I.varying,dF=I.varyingProperty,fF=I.vec2,pF=I.vec3,mF=I.vec4,hF=I.vectorComponents,gF=I.velocity,_F=I.vertexColor,vF=I.vertexIndex,yF=I.vibrance,bF=I.viewZToLogarithmicDepth,xF=I.viewZToOrthographicDepth,SF=I.viewZToPerspectiveDepth,CF=I.viewport,wF=I.viewportBottomLeft,TF=I.viewportCoordinate,EF=I.viewportDepthTexture,DF=I.viewportLinearDepth,OF=I.viewportMipTexture,kF=I.viewportResolution,AF=I.viewportSafeUV,jF=I.viewportSharedTexture,MF=I.viewportSize,NF=I.viewportTexture,PF=I.viewportTopLeft,FF=I.viewportUV,IF=I.wgsl,LF=I.wgslFn,RF=I.workgroupArray,zF=I.workgroupBarrier,BF=I.workgroupId,VF=I.workingToColorSpace,HF=I.xor;function UF(e,t,n=1){let r=e.rgb,i=t.rgb,a=zM(r,i),o=zM(t.a,n),s=RM(r,a,o),c=LM(e.a,zM(t.a,n));return mF(s,c)}function WF(e,t,n=1){let r=zM(t.a,n),i=$j(r,zM(e.a,sP(1,r))),a=$j(zM(t.rgb,r),zM(e.rgb,zM(e.a,sP(1,r))));return mF(a,i)}const GF={normal:WF,multiply:UF};function KF(e,t,n=`normal`,r=1){let i=GF[n]||GF.normal;return i(e,t,r)}function qF(e,t){let n=zM(e.a,t.a);return mF(e.rgb,n)}function JF(e,t){let n=sP(1,t.a),r=zM(e.a,n);return mF(e.rgb,r)}function YF(e,t){let n=pF(.2126,.7152,.0722),r=MM(t.rgb,n),i=zM(e.a,r);return mF(e.rgb,i)}function XF(e,t){let n=pF(.2126,.7152,.0722),r=MM(t.rgb,n),i=sP(1,r),a=zM(e.a,i);return mF(e.rgb,a)}const ZF={alpha:qF,alphaInverted:JF,luminance:YF,luminanceInverted:XF};function QF(e,t,n=`alpha`){let r=ZF[n]||ZF.alpha;return r(e,t)}const $F={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1};let eI=null,tI=!1;const nI=()=>{try{if($F!==void 0){let{MODE:e,DEV:t}=$F;return t||e===`development`}if(typeof window<`u`&&window.location){let e=window.location.hostname;return e===`localhost`||e===`127.0.0.1`||e.endsWith(`.local`)||e.includes(`dev.`)||e.startsWith(`dev-`)}return!1}catch{return!1}};function rI(){let e,t,n,r,i,a={nodes:new Map,rootId:null,idToNodeId:new Map},o=null,s=null,c=null,l=!1,u=!1,d=null,f=!1,p=!0,m=0,h=0,g=0,_=0,v=8,y=.5,b=.5,x=!1,S=!1,ee=()=>{var e,t,n;return(e=t=(n=window).matchMedia)?.call(n,`(prefers-reduced-motion: reduce)`).matches??!1},te=(n,i)=>{if(n===m&&i===h)return;let o=performance.now();if(o-g<v)return;m=n,h=i,g=o,e.setSize(n,i,!1);let s=n/i,c=2,l=c*s;t.left=-l/2,t.right=l/2,t.top=c/2,t.bottom=-c/2,t.updateProjectionMatrix(),r.scale.set(l,c,1),a.rootId&&ie(),ge().catch(console.warn)},ne=n=>{if(!e||!t||!r)return;let i=n[0];if(!i)return;let{width:a,height:o}=i.contentRect,s=Math.round(a),c=Math.round(o);te(s,c)},re=e=>{let t=e[0];t&&(f=t.isIntersecting,f&&p?_e():ve())},ie=()=>{if(!a.rootId||!i||S)return;let e=a.nodes.get(a.rootId);if(e){S=!0;try{let e=le(a.rootId);e&&i&&(i.fragmentNode=e,i.needsUpdate=!0)}catch(e){console.error(`Error composing shader tree:`,e)}finally{S=!1}f&&ge()}},ae=e=>{let t=[];return a.nodes.forEach(n=>{n.parentId===e&&t.push(n)}),t},oe=e=>{for(let[t,n]of a.nodes.entries())if(n.metadata.id===e)return t;return null},se=(e,t,n,r)=>{var i,a;if(!(i=a=t.metadata.mask)?.source)return e;let o=t.metadata.mask.source,s=oe(o);if(!s)return e;if(r.has(s))return console.error(`Uh oh, looks like you've got a circular dependency in your shader masks.`),e;let c=new Set(r);c.add(n);let l=le(s,c),u=t.metadata.mask.type||`alpha`;return QF(e,l,u)},ce=e=>{var t,n;let r=a.nodes.get(e);if(!r||!r.metadata.id)return!1;let i=r.metadata.id;for(let e of a.nodes.values())if((t=n=e.metadata.mask)?.source===i)return!0;return!1},le=(e,t=new Set)=>{let n=a.nodes.get(e);if(!n)return mF(0,0,0,0);let r=e=>{n.cleanupCallbacks.push(e)},i=e=>{n.beforeRenderCallbacks.push(e)},o=e=>{n.afterRenderCallbacks.push(e)},s=ae(e);if(s.length===0){let a=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:void 0,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:eI});return se(a,n,e,t)}else{let a=[...s].sort((e,t)=>e.metadata.renderOrder-t.metadata.renderOrder),c=n.parentId===null;if(c){let s;for(let e of a){if(e.metadata.opacity===0&&!ce(e.id))continue;let n=le(e.id,t),r=ce(e.id)?0:e.metadata.opacity;s=s===void 0?n:KF(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:eI});return se(c,n,e,t)}else{let s;for(let e of a){let n=le(e.id,t);if(e.metadata.opacity===0&&!ce(e.id))continue;let r=ce(e.id)?0:e.metadata.opacity;s=s===void 0?n:KF(s,n,e.metadata.blendMode,r)}let c=n.fragmentNodeFunc({uniforms:n.uniforms??{},childNode:s,onCleanup:r,onBeforeRender:i,onAfterRender:o,canvas:eI});return se(c,n,e,t)}}},ue=(e,t,n,r,o={})=>{let s=0;if(n!==null){let e=Array.from(a.nodes.values()).filter(e=>e.parentId===n);e.length>0&&(s=Math.max(...e.map(e=>e.metadata.renderOrder))+1)}let c={id:e,fragmentNodeFunc:t,parentId:n,metadata:{blendMode:r?.blendMode||`normal`,opacity:r?.opacity===void 0?1:r?.opacity,id:r?.id,mask:r?.mask,renderOrder:r?.renderOrder===void 0?s:r?.renderOrder},uniforms:o,cleanupCallbacks:[],beforeRenderCallbacks:[],afterRenderCallbacks:[]};a.nodes.set(e,c),n===null&&(a.rootId=e),i&&l&&ie()},de=(e,t,n)=>{let r=a.nodes.get(e);if(!r||!r.uniforms){console.warn(`Node or uniforms not found for ID: ${e}`);return}let i=r.uniforms[t];if(!i||!i.uniform){console.warn(`Uniform ${t} not found in node: ${e}`);return}i.uniform.value=n,f&&ge()},fe=(e,t)=>{var n,r,o,s,c,u,d,p;let m=a.nodes.get(e);if(!m)return;let h=!1;t.blendMode!==void 0&&m.metadata.blendMode!==t.blendMode&&(m.metadata.blendMode=t.blendMode,h=!0),t.opacity!==void 0&&m.metadata.opacity!==t.opacity&&(m.metadata.opacity=t.opacity,h=!0),t.renderOrder!==void 0&&m.metadata.renderOrder!==t.renderOrder&&(m.metadata.renderOrder=t.renderOrder,h=!0),t.id!==void 0&&m.metadata.id!==t.id&&(m.metadata.id=t.id,h=!0),t.mask!==void 0&&((n=c=m.metadata.mask)?.source!==(r=u=t.mask)?.source||(o=d=m.metadata.mask)?.type!==(s=p=t.mask)?.type)&&(m.metadata.mask=t.mask,h=!0),h&&i&&l?ie():f&&ge()},pe=e=>{if(!a.nodes.has(e))return;let t=a.nodes.get(e);if(t&&t.cleanupCallbacks.length>0)for(let n of t.cleanupCallbacks)try{n()}catch(t){console.error(`Error executing cleanup callback for node ${e}:`,t)}let n=ae(e);for(let e of n)pe(e.id);a.rootId===e&&(a.rootId=null),a.nodes.delete(e),i&&l&&ie()},me=e=>{let t={deltaTime:e,pointer:{x:y,y:b},pointerActive:x,dimensions:{width:m,height:h}};for(let e of a.nodes.values())if(e.beforeRenderCallbacks.length>0)for(let n of e.beforeRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing before render callback for node ${e.id}:`,t)}},he=e=>{let t={deltaTime:e,pointer:{x:y,y:b},pointerActive:x,dimensions:{width:m,height:h}};for(let e of a.nodes.values())if(e.afterRenderCallbacks.length>0)for(let n of e.afterRenderCallbacks)try{n(t)}catch(t){console.error(`Error executing after render callback for node ${e.id}:`,t)}},ge=async()=>{if(!l||!e||!n||!t||!i)return;let r=performance.now(),a=_>0?(r-_)/1e3:.016,o=Math.min(a,.1);_=r,me(o);try{if(S)return;e instanceof vj?await e.renderAsync(n,t).then(()=>{l&&he(o)}).catch(e=>{console.error(`WebGPU render error:`,e)}):(e.render(n,t),he(o))}catch(e){console.error(`Render frame error:`,e)}},_e=()=>{if(o||!p||!f)return;let e=()=>{o=requestAnimationFrame(e),ge()};e()},ve=()=>{o&&(cancelAnimationFrame(o),o=null)},ye=e=>{if(!eI)return;let t,n;if(`touches`in e){if(e.touches.length===0)return;t=e.touches[0].clientX,n=e.touches[0].clientY}else t=e.clientX,n=e.clientY;let r=eI.getBoundingClientRect(),i=(t-r.left)/r.width,a=(n-r.top)/r.height;y=Math.max(0,Math.min(1,i)),b=Math.max(0,Math.min(1,a))},be=async({canvas:o})=>{if(l||u)return;u=!0,d=new AbortController;let m=d;try{if(eI=o,n=new xo,n.background=null,t=new Ms(-1,1,1,-1,.1,10),t.position.z=1,t.lookAt(0,0,0),o.addEventListener(`mousemove`,ye),o.addEventListener(`touchmove`,ye),o.addEventListener(`mousedown`,()=>{x=!0,ge()}),o.addEventListener(`touchstart`,()=>{x=!0,ge()}),window.addEventListener(`mouseup`,()=>{x=!1,ge()}),window.addEventListener(`touchend`,()=>{x=!1,ge()}),m.signal.aborted)return;try{if(e=new vj({canvas:o,antialias:!0,alpha:!0,depth:!1,powerPreference:`high-performance`}),await e.init(),m.signal.aborted){e.dispose();return}}catch(e){if(m.signal.aborted)return;console.error(`[Shaders] WebGPU initialization error:`,e);return}if(m.signal.aborted){e&&e.dispose();return}e.setPixelRatio(Math.min(window.devicePixelRatio,2)),e.outputColorSpace=gn,i=new lv({transparent:!0}),a.nodes.size===0?i.fragmentNode=mF(0,0,0,0):ie();let u=new Uo(2,2);r=new Qa(u,i),n.add(r),s=new ResizeObserver(ne),s.observe(o),c=new IntersectionObserver(re,{threshold:0}),c.observe(o),p=!ee();let{width:d,height:h}=o.getBoundingClientRect();te(Math.round(d),Math.round(h)),await ge(),p&&f&&_e(),m.signal.aborted||(l=!0)}catch(e){console.error(`[Shaders] Initialization error:`,e)}finally{u=!1,d===m&&(d=null)}},xe=()=>{!nI()||tI||(console.warn(`Shaders is running in development mode. Please purchase a license at https://shaders.com to use it in production.`),tI=!0)},Se=()=>{if(d&&d.abort(),s&&(s.disconnect(),s=null),c&&(c.disconnect(),c=null),eI&&(eI.removeEventListener(`mousemove`,ye),eI.removeEventListener(`touchmove`,ye),eI.removeEventListener(`mousedown`,()=>{x=!0}),eI.removeEventListener(`touchstart`,()=>{x=!0})),window&&(window.removeEventListener(`mouseup`,()=>{x=!1}),window.removeEventListener(`touchend`,()=>{x=!1})),ve(),a.nodes.clear(),a.rootId=null,a.idToNodeId.clear(),r&&(n&&n.remove(r),r.geometry&&r.geometry.dispose(),r.material instanceof ya&&r.material.dispose()),e)try{e.dispose()}catch(e){console.warn(`Error disposing renderer:`,e)}eI=null,e=null,t=null,n=null,r=null,i=null,l=!1,u=!1,d=null,m=0,h=0,f=!1,p=!0,y=.5,b=.5,x=!1};return{initialize:be,cleanup:Se,registerNode:ue,removeNode:pe,updateUniformValue:de,updateNodeMetadata:fe,showLicenseWarning:xe}}const{uniform:iI}=yj;function aI(e,t,n){let r={};return Object.entries(e.props).forEach(([e,i])=>{let a=t[e],o=a;i.transform&&(o=i.transform(a)),r[e]={uniform:iI(o).label(`${e}_${n}`),transform:i.transform||void 0}}),r}const{vec2:oI,fract:sI,sin:cI,dot:roe}=yj,lI=e=>sI(cI(roe(e,oI(12.12345,78.12345))).mul(40000.12345)),ioe=(e=.03)=>t=>lI(t).mul(e).mul(.10012345),{vec2:uI}=yj,aoe=(e=uI(0),t=.02,n=1,r=1)=>{let{vec2:i,sin:a,cos:o,time:s}=yj,c=r*1.618033988749895,l=r*2.718281828459045,u=(Math.sin(r)+2)*5,d=(Math.cos(r)+2)*5,f=i(a(e.x.mul(n).mul(u).add(s.mul(.1)).add(c)),o(e.y.mul(n).mul(u).add(s.mul(.1)).add(l))),p=i(a(e.y.mul(n).mul(d).add(s.mul(.05)).add(l)),o(e.x.mul(n).mul(d).add(s.mul(.05)).add(c))),m=f.add(p).mul(t);return e.add(m)},ooe=(e,t,n=.6,r=.3,i=1)=>{let{max:a,smoothstep:o,vec4:s}=yj,c=a(a(e.r,e.g),e.b),l=o(n,n+r,c).mul(i).mul(1),u=e.rgb.add(t.rgb.mul(l));return s(u,e.a)},soe=(e={})=>{let{inset:t=.4,softness:n=.5,offsetX:r=0,offsetY:i=0}=e,{float:a,smoothstep:o,uv:s}=yj,c=s(),l=c.x.sub(.5).sub(a(r)).mul(2),u=c.y.sub(.5).add(a(i)).mul(2),d=l.mul(l).add(u.mul(u)).sqrt();return a(1).sub(o(a(1).sub(a(t)),a(1).sub(a(t)).add(a(n)),d.mul(a(1).add(a(n)))))};var dI=function(exports){"use strict";function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({}),fI,pI;function mI(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>{let n=0;if(!Array.isArray(e)){for(let r of t)n+=e*r;return n}for(let r=0;r<e.length;r++)n+=e[r]*(t[r]||0);return n}));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}function hI(e){return gI(e)===`string`}function gI(e){let t=Object.prototype.toString.call(e);return(t.match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function _I(e,{precision:t,unit:n}){return vI(e)?`none`:bI(e,t)+(n??``)}function vI(e){return Number.isNaN(e)||e instanceof Number&&e?.none}function yI(e){return vI(e)?0:e}function bI(e,t){if(e===0)return 0;let n=~~e,r=0;n&&t&&(r=~~Math.log10(Math.abs(n))+1);let i=10**(t-r);return Math.floor(e*i+.5)/i}const xI={deg:1,grad:.9,rad:180/Math.PI,turn:360};function SI(e){if(!e)return;e=e.trim();let t=/^([a-z]+)\((.+?)\)$/i,n=/^-?[\d.]+$/,r=/%|deg|g?rad|turn$/,i=/\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g,a=e.match(t);if(a){let e=[];return a[2].replace(i,(t,i)=>{let a=i.match(r),o=i;if(a){let e=a[0],t=o.slice(0,-e.length);e===`%`?(o=new Number(t/100),o.type=`<percentage>`):(o=new Number(t*xI[e]),o.type=`<angle>`,o.unit=e)}else n.test(o)?(o=new Number(o),o.type=`<number>`):o===`none`&&(o=new Number(NaN),o.none=!0);t.startsWith(`/`)&&(o=o instanceof Number?o:new Number(o),o.alpha=!0),typeof o==`object`&&o instanceof Number&&(o.raw=i),e.push(o)}),{name:a[1].toLowerCase(),rawName:a[1],rawArgs:a[2],args:e}}}function CI(e){return e[e.length-1]}function wI(e,t,n){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*n}function TI(e,t,n){return(n-e)/(t-e)}function EI(e,t,n){return wI(t[0],t[1],TI(e[0],e[1],n))}function DI(e){return e.map(e=>e.split(`|`).map(e=>{e=e.trim();let t=e.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);if(t){let e=new String(t[1]);return e.range=[+t[2],+t[3]],e}return e}))}function OI(e,t,n){return Math.max(Math.min(n,t),e)}function kI(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function AI(e,t){return kI(Math.abs(e)**t,e)}function jI(e,t){return t===0?0:e/t}function MI(e,t,n=0,r=e.length){for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}var NI=Object.freeze({__proto__:null,bisectLeft:MI,clamp:OI,copySign:kI,interpolate:wI,interpolateInv:TI,isNone:vI,isString:hI,last:CI,mapRange:EI,multiplyMatrices:mI,parseCoordGrammar:DI,parseFunction:SI,serializeNumber:_I,skipNone:yI,spow:AI,toPrecision:bI,type:gI,zdiv:jI}),PI=class{add(e,t,n){if(typeof arguments[0]!=`string`){for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1]);return}(Array.isArray(e)?e:[e]).forEach(function(e){this[e]=this[e]||[],t&&this[e][n?`unshift`:`push`](t)},this)}run(e,t){this[e]=this[e]||[],this[e].forEach(function(e){e.call(t&&t.context?t.context:t,t)})}};const FI=new PI;var II={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:((fI=globalThis)==null||(fI=fI.process)==null||(fI=fI.env)==null||(fI=fI.NODE_ENV)==null?void 0:fI.toLowerCase())!==`test`,warn:function(e){var t,n;this.verbose&&((t=globalThis)==null||(t=t.console)==null||(n=t.warn)==null||n.call(t,e))}};const LI={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function RI(e){return Array.isArray(e)?e:LI[e]}function zI(e,t,n,r={}){if(e=RI(e),t=RI(t),!e||!t)throw TypeError(`Missing white point to convert ${e?``:`from`}${!e&&!t?`/`:``}${t?``:`to`}`);if(e===t)return n;let i={W1:e,W2:t,XYZ:n,options:r};if(FI.run(`chromatic-adaptation-start`,i),i.M||(i.W1===LI.D65&&i.W2===LI.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===LI.D50&&i.W2===LI.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),FI.run(`chromatic-adaptation-end`,i),i.M)return mI(i.M,i.XYZ);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}const BI=new Set([`<number>`,`<percentage>`,`<angle>`]);function VI(e,t,n,r){let i=Object.entries(e.coords).map(([e,i],a)=>{let o=t.coordGrammar[a],s=r[a],c=s?.type,l;if(l=s.none?o.find(e=>BI.has(e)):o.find(e=>e==c),!l){let t=i.name||e;throw TypeError(`${c??s.raw} not allowed for ${t} in ${n}()`)}let u=l.range;c===`<percentage>`&&(u||=[0,1]);let d=i.range||i.refRange;return u&&d&&(r[a]=EI(u,d,r[a])),l});return i}function HI(e,{meta:t}={}){var n,r;let i={str:(n=r=String(e))?.trim()};if(FI.run(`parse-start`,i),i.color)return i.color;if(i.parsed=SI(i.str),i.parsed){let e=i.parsed.name;if(e===`color`){let e=i.parsed.args.shift(),n=e.startsWith(`--`)?e.substring(2):`--${e}`,r=[e,n],c=i.parsed.rawArgs.indexOf(`/`)>0?i.parsed.args.pop():1;for(let n of GI.all){let s=n.getFormat(`color`);if(s){var a,o;if(r.includes(s.id)||(a=o=s.ids)?.filter(e=>r.includes(e)).length){let r=Object.keys(n.coords).map((e,t)=>i.parsed.args[t]||0),a;return s.coordGrammar&&(a=VI(n,s,`color`,r)),t&&Object.assign(t,{formatId:`color`,types:a}),s.id.startsWith(`--`)&&!e.startsWith(`--`)&&II.warn(`${n.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${s.id}) instead of color(${e}).`),e.startsWith(`--`)&&!s.id.startsWith(`--`)&&II.warn(`${n.name} is a standard space and supported in the CSS spec. Use color(${s.id}) instead of prefixed color(${e}).`),{spaceId:n.id,coords:r,alpha:c}}}}let l=``,u=e in GI.registry?e:n;if(u in GI.registry){var s;let e=(s=GI.registry[u].formats)==null||(s=s.color)==null?void 0:s.id;e&&(l=`Did you mean color(${e})?`)}throw TypeError(`Cannot parse color(${e}). `+(l||`Missing a plugin?`))}else for(let n of GI.all){let r=n.getFormat(e);if(r&&r.type===`function`){let a=1;(r.lastAlpha||CI(i.parsed.args).alpha)&&(a=i.parsed.args.pop());let o=i.parsed.args,s;return r.coordGrammar&&(s=VI(n,r,e,o)),t&&Object.assign(t,{formatId:r.name,types:s}),{spaceId:n.id,coords:o,alpha:a}}}}else for(let e of GI.all)for(let n in e.formats){let r=e.formats[n];if(r.type!==`custom`||r.test&&!r.test(i.str))continue;let a=r.parse(i.str);if(a)return a.alpha??=1,t&&(t.formatId=n),a}throw TypeError(`Could not parse ${e} as a color. Missing a plugin?`)}function UI(e){if(Array.isArray(e))return e.map(UI);if(!e)throw TypeError(`Empty color reference`);hI(e)&&(e=HI(e));let t=e.space||e.spaceId;return t instanceof GI||(e.space=GI.get(t)),e.alpha===void 0&&(e.alpha=1),e}const WI=75e-6;var GI=(pI=class e{constructor(t){var n,r;this.id=t.id,this.name=t.name,this.base=t.base?e.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let i=t.coords??this.base.coords;for(let e in i)`name`in i[e]||(i[e].name=e);this.coords=i;let a=t.white??this.base.white??`D65`;for(let e in this.white=RI(a),this.formats=t.formats??{},this.formats){let t=this.formats[e];t.type||=`function`,t.name||=e}(n=r=this.formats.color)?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace=t.gamutSpace===`self`?this:e.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=t.referred,Object.defineProperty(this,`path`,{value:KI(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),FI.run(`colorspace-init-end`,this)}inGamut(e,{epsilon:t=WI}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let n=Object.values(this.coords);return e.every((e,r)=>{let i=n[r];if(i.type!==`angle`&&i.range){if(Number.isNaN(e))return!0;let[n,r]=i.range;return(n===void 0||e>=n-t)&&(r===void 0||e<=r+t)}return!0})}get isUnbounded(){return Object.values(this.coords).every(e=>!(`range`in e))}get cssId(){var e;return((e=this.formats)==null||(e=e.color)==null?void 0:e.id)||this.id}get isPolar(){for(let e in this.coords)if(this.coords[e].type===`angle`)return!0;return!1}getFormat(e){if(typeof e==`object`)return e=qI(e,this),e;let t;return t=e===`default`?Object.values(this.formats)[0]:this.formats[e],t?(t=qI(t,this),t):null}equals(e){return e?this===e||this.id===e||this.id===e.id:!1}to(t,n){if(arguments.length===1){let e=UI(t);[t,n]=[e.space,e.coords]}if(t=e.get(t),this.equals(t))return n;n=n.map(e=>Number.isNaN(e)?0:e);let r=this.path,i=t.path,a,o;for(let e=0;e<r.length&&r[e].equals(i[e]);e++)a=r[e],o=e;if(!a)throw Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let e=r.length-1;e>o;e--)n=r[e].toBase(n);for(let e=o+1;e<i.length;e++)n=i[e].fromBase(n);return n}from(t,n){if(arguments.length===1){let e=UI(t);[t,n]=[e.space,e.coords]}return t=e.get(t),t.to(this,n)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let n=this.coords[t],r=n.range||n.refRange;e.push(r?.min??0)}return e}static get all(){return[...new Set(Object.values(e.registry))]}static register(e,t){if(arguments.length===1&&(t=arguments[0],e=t.id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,arguments.length===1&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(t,...n){if(!t||t instanceof e)return t;let r=gI(t);if(r===`string`){let n=e.registry[t.toLowerCase()];if(!n)throw TypeError(`No color space found with id = "${t}"`);return n}if(n.length)return e.get(...n);throw TypeError(`${t} is not a valid color space`)}static resolveCoord(t,n){let r=gI(t),i,a;if(r===`string`?t.includes(`.`)?[i,a]=t.split(`.`):[i,a]=[,t]:Array.isArray(t)?[i,a]=t:(i=t.space,a=t.coordId),i=e.get(i),i||=n,!i)throw TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(r=gI(a),r===`number`||r===`string`&&a>=0){let e=Object.entries(i.coords)[a];if(e)return{space:i,id:e[0],index:a,...e[1]}}i=e.get(i);let o=a.toLowerCase(),s=0;for(let e in i.coords){var c,l;let t=i.coords[e];if(e.toLowerCase()===o||(c=l=t.name)?.toLowerCase()===o)return{space:i,id:e,index:s,...t};s++}throw TypeError(`No "${a}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(`, `)}`)}},dI.defineProperty(pI,`registry`,{}),dI.defineProperty(pI,`DEFAULT_FORMAT`,{type:`functions`,name:`color`}),pI);function KI(e){let t=[e];for(let n=e;n=n.base;)t.push(n);return t}function qI(e,{coords:t}={}){if(e.coords&&!e.coordGrammar){e.type||=`function`,e.name||=`color`,e.coordGrammar=DI(e.coords);let n=Object.entries(t).map(([t,n],r)=>{let i=e.coordGrammar[r][0],a=n.range||n.refRange,o=i.range,s=``;return i==`<percentage>`?(o=[0,100],s=`%`):i==`<angle>`&&(s=`deg`),{fromRange:a,toRange:o,suffix:s}});e.serializeCoords=(e,t)=>e.map((e,r)=>{let{fromRange:i,toRange:a,suffix:o}=n[r];return i&&a&&(e=EI(i,a,e)),e=_I(e,{precision:t,unit:o}),e})}return e}var JI=new GI({id:`xyz-d65`,name:`XYZ D65`,coords:{x:{name:`X`},y:{name:`Y`},z:{name:`Z`}},white:`D65`,formats:{color:{ids:[`xyz-d65`,`xyz`]}},aliases:[`xyz`]}),YI=class extends GI{constructor(e){e.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},e.base||=JI,e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let n=mI(e.toXYZ_M,t);return this.white!==this.base.white&&(n=zI(this.white,this.base.white,n)),n},e.fromBase??=t=>(t=zI(this.base.white,this.white,t),mI(e.fromXYZ_M,t))),e.referred??=`display`,super(e)}};function XI(e,t){return e=UI(e),!t||e.space.equals(t)?e.coords.slice():(t=GI.get(t),t.from(e))}function ZI(e,t){e=UI(e);let{space:n,index:r}=GI.resolveCoord(t,e.space),i=XI(e,n);return i[r]}function QI(e,t,n){return e=UI(e),t=GI.get(t),e.coords=t.to(e.space,n),e}QI.returns=`color`;function $I(e,t,n){if(e=UI(e),arguments.length===2&&gI(arguments[1])===`object`){let t=arguments[1];for(let n in t)$I(e,n,t[n])}else{typeof n==`function`&&(n=n(ZI(e,t)));let{space:r,index:i}=GI.resolveCoord(t,e.space),a=XI(e,r);a[i]=n,QI(e,r,a)}return e}$I.returns=`color`;var eL=new GI({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:JI,fromBase:e=>zI(JI.white,`D50`,e),toBase:e=>zI(`D50`,JI.white,e)});const tL=216/24389,nL=24/116,rL=24389/27;let iL=LI.D50;var aL=new GI({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:iL,base:eL,fromBase(e){let t=e.map((e,t)=>e/iL[t]),n=t.map(e=>e>tL?Math.cbrt(e):(rL*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>nL?t[0]**3:(116*t[0]-16)/rL,e[0]>8?((e[0]+16)/116)**3:e[0]/rL,t[2]>nL?t[2]**3:(116*t[2]-16)/rL];return n.map((e,t)=>e*iL[t])},formats:{lab:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function oL(e){return(e%360+360)%360}function sL(e,t){if(e===`raw`)return t;let[n,r]=t.map(oL),i=r-n;return e===`increasing`?i<0&&(r+=360):e===`decreasing`?i>0&&(n+=360):e===`longer`?-180<i&&i<180&&(i>0?n+=360:r+=360):e===`shorter`&&(i>180?n+=360:i<-180&&(r+=360)),[n,r]}var cL=new GI({id:`lch`,name:`LCH`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,150],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:aL,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),oL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{lch:{coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const lL=25**7,uL=Math.PI,dL=180/uL,fL=uL/180;function pL(e){let t=e*e,n=t*t*t*e;return n}function mL(e,t,{kL:n=1,kC:r=1,kH:i=1}={}){[e,t]=UI([e,t]);let[a,o,s]=aL.from(e),c=cL.from(aL,[a,o,s])[1],[l,u,d]=aL.from(t),f=cL.from(aL,[l,u,d])[1];c<0&&(c=0),f<0&&(f=0);let p=(c+f)/2,m=pL(p),h=.5*(1-Math.sqrt(m/(m+lL))),g=(1+h)*o,_=(1+h)*u,v=Math.sqrt(g**2+s**2),y=Math.sqrt(_**2+d**2),b=g===0&&s===0?0:Math.atan2(s,g),x=_===0&&d===0?0:Math.atan2(d,_);b<0&&(b+=2*uL),x<0&&(x+=2*uL),b*=dL,x*=dL;let S=l-a,ee=y-v,te=x-b,ne=b+x,re=Math.abs(te),ie;v*y===0?ie=0:re<=180?ie=te:te>180?ie=te-360:te<-180?ie=te+360:II.warn(`the unthinkable has happened`);let ae=2*Math.sqrt(y*v)*Math.sin(ie*fL/2),oe=(a+l)/2,se=(v+y)/2,ce=pL(se),le;le=v*y===0?ne:re<=180?ne/2:ne<360?(ne+360)/2:(ne-360)/2;let ue=(oe-50)**2,de=1+.015*ue/Math.sqrt(20+ue),fe=1+.045*se,pe=1;pe-=.17*Math.cos((le-30)*fL),pe+=.24*Math.cos(2*le*fL),pe+=.32*Math.cos((3*le+6)*fL),pe-=.2*Math.cos((4*le-63)*fL);let me=1+.015*se*pe,he=30*Math.exp(-1*((le-275)/25)**2),ge=2*Math.sqrt(ce/(ce+lL)),_e=-1*Math.sin(2*he*fL)*ge,ve=(S/(n*de))**2;return ve+=(ee/(r*fe))**2,ve+=(ae/(i*me))**2,ve+=_e*(ee/(r*fe))*(ae/(i*me)),Math.sqrt(ve)}const hL=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],gL=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],_L=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],vL=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var yL=new GI({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:JI,fromBase(e){let t=mI(hL,e),n=t.map(e=>Math.cbrt(e));return mI(_L,n)},toBase(e){let t=mI(vL,e),n=t.map(e=>e**3);return mI(gL,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});function bL(e,t){[e,t]=UI([e,t]);let[n,r,i]=yL.from(e),[a,o,s]=yL.from(t),c=n-a,l=r-o,u=i-s;return Math.sqrt(c**2+l**2+u**2)}const xL=75e-6;function SL(e,t,{epsilon:n=xL}={}){e=UI(e),t||=e.space,t=GI.get(t);let r=e.coords;return t!==e.space&&(r=t.from(e)),t.inGamut(r,{epsilon:n})}function CL(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}function wL(e,t,n=`lab`){n=GI.get(n);let r=n.from(e),i=n.from(t);return Math.sqrt(r.reduce((e,t,n)=>{let r=i[n];return isNaN(t)||isNaN(r)?e:e+(r-t)**2},0))}function TL(e,t){return wL(e,t,`lab`)}const EL=Math.PI,DL=EL/180;function OL(e,t,{l:n=2,c:r=1}={}){[e,t]=UI([e,t]);let[i,a,o]=aL.from(e),[,s,c]=cL.from(aL,[i,a,o]),[l,u,d]=aL.from(t),f=cL.from(aL,[l,u,d])[1];s<0&&(s=0),f<0&&(f=0);let p=i-l,m=s-f,h=a-u,g=o-d,_=h**2+g**2-m**2,v=.511;i>=16&&(v=.040975*i/(1+.01765*i));let y=.0638*s/(1+.0131*s)+.638,b;Number.isNaN(c)&&(c=0),b=c>=164&&c<=345?.56+Math.abs(.2*Math.cos((c+168)*DL)):.36+Math.abs(.4*Math.cos((c+35)*DL));let x=s**4,S=Math.sqrt(x/(x+1900)),ee=y*(S*b+1-S),te=(p/(n*v))**2;return te+=(m/(r*y))**2,te+=_/ee**2,Math.sqrt(te)}const kL=203;var AL=new GI({id:`xyz-abs-d65`,cssId:`--xyz-abs-d65`,name:`Absolute XYZ D65`,coords:{x:{refRange:[0,9504.7],name:`Xa`},y:{refRange:[0,1e4],name:`Ya`},z:{refRange:[0,10888.3],name:`Za`}},base:JI,fromBase(e){return e.map(e=>Math.max(e*kL,0))},toBase(e){return e.map(e=>Math.max(e/kL,0))}});const jL=1.15,ML=.66,NL=2610/2**14,PL=2**14/2610,FL=3424/2**12,IL=2413/2**7,LL=2392/2**7,RL=1.7*2523/2**5,zL=2**5/(1.7*2523),BL=-.56,VL=16295499532821565e-27,HL=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],UL=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],WL=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],GL=[[1,.1386050432715393,.05804731615611886],[.9999999999999999,-.1386050432715393,-.05804731615611886],[.9999999999999998,-.09601924202631895,-.8118918960560388]];var KL=new GI({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.5,.5]},bz:{refRange:[-.5,.5]}},base:AL,fromBase(e){let[t,n,r]=e,i=jL*t-(jL-1)*r,a=ML*n-(ML-1)*t,o=mI(HL,[i,a,r]),s=o.map(function(e){let t=FL+IL*(e/1e4)**NL,n=1+LL*(e/1e4)**NL;return(t/n)**RL}),[c,l,u]=mI(WL,s),d=(1+BL)*c/(1+BL*c)-VL;return[d,l,u]},toBase(e){let[t,n,r]=e,i=(t+VL)/(1+BL-BL*(t+VL)),a=mI(GL,[i,n,r]),o=a.map(function(e){let t=FL-e**zL,n=LL*e**zL-IL,r=1e4*(t/n)**PL;return r}),[s,c,l]=mI(UL,o),u=(s+(jL-1)*l)/jL,d=(c+(ML-1)*u)/ML;return[u,d,l]},formats:{color:{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),qL=new GI({id:`jzczhz`,name:`JzCzHz`,coords:{jz:{refRange:[0,1],name:`Jz`},cz:{refRange:[0,1],name:`Chroma`},hz:{refRange:[0,360],type:`angle`,name:`Hue`}},base:KL,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),oL(i)]},toBase(e){return[e[0],e[1]*Math.cos(e[2]*Math.PI/180),e[1]*Math.sin(e[2]*Math.PI/180)]}});function JL(e,t){[e,t]=UI([e,t]);let[n,r,i]=qL.from(e),[a,o,s]=qL.from(t),c=n-a,l=r-o;Number.isNaN(i)&&Number.isNaN(s)?(i=0,s=0):Number.isNaN(i)?i=s:Number.isNaN(s)&&(s=i);let u=i-s,d=2*Math.sqrt(r*o)*Math.sin(u/2*(Math.PI/180));return Math.sqrt(c**2+l**2+d**2)}const YL=3424/4096,XL=2413/128,ZL=2392/128,QL=2610/16384,$L=2523/32,eR=16384/2610,tR=32/2523,nR=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],rR=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],iR=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],aR=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var oR=new GI({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:AL,fromBase(e){let t=mI(nR,e);return sR(t)},toBase(e){let t=cR(e);return mI(aR,t)}});function sR(e){let t=e.map(function(e){let t=YL+XL*(e/1e4)**QL,n=1+ZL*(e/1e4)**QL;return(t/n)**$L});return mI(rR,t)}function cR(e){let t=mI(iR,e),n=t.map(function(e){let t=Math.max(e**tR-YL,0),n=XL-ZL*e**tR;return 1e4*(t/n)**eR});return n}function lR(e,t){[e,t]=UI([e,t]);let[n,r,i]=oR.from(e),[a,o,s]=oR.from(t);return 720*Math.sqrt((n-a)**2+.25*(r-o)**2+(i-s)**2)}const uR=LI.D65,dR=.42,fR=1/dR,pR=2*Math.PI,mR=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],hR=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],gR=[[460,451,288],[460,-891,-261],[460,-220,-6300]],_R={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},vR={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},yR=180/Math.PI,bR=Math.PI/180;function xR(e,t){let n=e.map(e=>{let n=AI(t*Math.abs(e)*.01,dR);return 400*kI(n,e)/(n+27.13)});return n}function SR(e,t){let n=100/t*27.13**fR;return e.map(e=>{let t=Math.abs(e);return kI(n*AI(t/(400-t),fR),e)})}function CR(e){let t=oL(e);t<=vR.h[0]&&(t+=360);let n=MI(vR.h,t)-1,[r,i]=vR.h.slice(n,n+2),[a,o]=vR.e.slice(n,n+2),s=vR.H[n],c=(t-r)/a;return s+100*c/(c+(i-t)/o)}function wR(e){let t=(e%400+400)%400,n=Math.floor(.01*t);t%=100;let[r,i]=vR.h.slice(n,n+2),[a,o]=vR.e.slice(n,n+2);return oL((t*(o*r-a*i)-100*r*o)/(t*(o-a)-100*o))}function TR(e,t,n,r,i){let a={};a.discounting=i,a.refWhite=e,a.surround=r;let o=e.map(e=>e*100);a.la=t,a.yb=n;let s=o[1],c=mI(mR,o);r=_R[a.surround];let l=r[0];a.c=r[1],a.nc=r[2];let u=1/(5*a.la+1),d=u**4;a.fl=d*a.la+.1*(1-d)*(1-d)*Math.cbrt(5*a.la),a.flRoot=a.fl**.25,a.n=a.yb/s,a.z=1.48+Math.sqrt(a.n),a.nbb=.725*a.n**-.2,a.ncb=a.nbb;let f=i?1:Math.max(Math.min(l*(1-1/3.6*Math.exp((-a.la-42)/92)),1),0);a.dRgb=c.map(e=>wI(1,s/e,f)),a.dRgbInv=a.dRgb.map(e=>1/e);let p=c.map((e,t)=>e*a.dRgb[t]),m=xR(p,a.fl);return a.aW=a.nbb*(2*m[0]+m[1]+.05*m[2]),a}const ER=TR(uR,64/Math.PI*.2,20,`average`,!1);function DR(e,t){if(!(e.J!==void 0^e.Q!==void 0))throw Error(`Conversion requires one and only one: 'J' or 'Q'`);if(!(e.C!==void 0^e.M!==void 0^e.s!==void 0))throw Error(`Conversion requires one and only one: 'C', 'M' or 's'`);if(!(e.h!==void 0^e.H!==void 0))throw Error(`Conversion requires one and only one: 'h' or 'H'`);if(e.J===0||e.Q===0)return[0,0,0];let n=0;n=e.h===void 0?wR(e.H)*bR:oL(e.h)*bR;let r=Math.cos(n),i=Math.sin(n),a=0;e.J===void 0?e.Q!==void 0&&(a=.25*t.c*e.Q/((t.aW+4)*t.flRoot)):a=AI(e.J,1/2)*.1;let o=0;e.C===void 0?e.M===void 0?e.s!==void 0&&(o=4e-4*e.s**2*(t.aW+4)/t.c):o=e.M/t.flRoot/a:o=e.C/a;let s=AI(o*(1.64-.29**t.n)**-.73,10/9),c=.25*(Math.cos(n+2)+3.8),l=t.aW*AI(a,2/t.c/t.z),u=5e4/13*t.nc*t.ncb*c,d=l/t.nbb,f=23*(d+.305)*jI(s,23*u+s*(11*r+108*i)),p=f*r,m=f*i,h=SR(mI(gR,[d,p,m]).map(e=>e*1/1403),t.fl);return mI(hR,h.map((e,n)=>e*t.dRgbInv[n])).map(e=>e/100)}function OR(e,t){let n=e.map(e=>e*100),r=xR(mI(mR,n).map((e,n)=>e*t.dRgb[n]),t.fl),i=r[0]+(-12*r[1]+r[2])/11,a=(r[0]+r[1]-2*r[2])/9,o=(Math.atan2(a,i)%pR+pR)%pR,s=.25*(Math.cos(o+2)+3.8),c=5e4/13*t.nc*t.ncb*jI(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),l=AI(c,.9)*(1.64-.29**t.n)**.73,u=t.nbb*(2*r[0]+r[1]+.05*r[2]),d=AI(u/t.aW,.5*t.c*t.z),f=100*AI(d,2),p=4/t.c*d*(t.aW+4)*t.flRoot,m=l*d,h=m*t.flRoot,g=oL(o*yR),_=CR(g),v=50*AI(t.c*l/(t.aW+4),1/2);return{J:f,C:m,h:g,s:v,Q:p,M:h,H:_}}var kR=new GI({id:`cam16-jmh`,cssId:`--cam16-jmh`,name:`CAM16-JMh`,coords:{j:{refRange:[0,100],name:`J`},m:{refRange:[0,105],name:`Colorfulness`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:JI,fromBase(e){let t=OR(e,ER);return[t.J,t.M,t.h]},toBase(e){return DR({J:e[0],M:e[1],h:e[2]},ER)}});const AR=LI.D65,jR=216/24389,MR=24389/27;function NR(e){let t=e>jR?Math.cbrt(e):(MR*e+16)/116;return 116*t-16}function PR(e){return e>8?((e+16)/116)**3:e/MR}function FR(e,t){let[n,r,i]=e,a=[],o=0;if(i===0)return[0,0,0];let s=PR(i);o=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let c=2e-12,l=15,u=0,d=1/0;for(;u<=l;){a=DR({J:o,C:r,h:n},t);let e=Math.abs(a[1]-s);if(e<d){if(e<=c)return a;d=e}o-=(a[1]-s)*o/(2*a[1]),u+=1}return DR({J:o,C:r,h:n},t)}function IR(e,t){let n=NR(e[1]);if(n===0)return[0,0,0];let r=OR(e,LR);return[oL(r.h),r.C,n]}const LR=TR(AR,200/Math.PI*PR(50),PR(50)*100,`average`,!1);var RR=new GI({id:`hct`,name:`HCT`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},c:{refRange:[0,145],name:`Colorfulness`},t:{refRange:[0,100],name:`Tone`}},base:JI,fromBase(e){return IR(e)},toBase(e){return FR(e,LR)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const zR=Math.PI/180,BR=[1,.007,.0228];function VR(e){e[1]<0&&(e=RR.fromBase(RR.toBase(e)));let t=Math.log(Math.max(1+BR[2]*e[1]*LR.flRoot,1))/BR[2],n=e[0]*zR,r=t*Math.cos(n),i=t*Math.sin(n);return[e[2],r,i]}function HR(e,t){[e,t]=UI([e,t]);let[n,r,i]=VR(RR.from(e)),[a,o,s]=VR(RR.from(t));return Math.sqrt((n-a)**2+(r-o)**2+(i-s)**2)}var UR={deltaE76:TL,deltaECMC:OL,deltaE2000:mL,deltaEJz:JL,deltaEITP:lR,deltaEOK:bL,deltaEHCT:HR};function WR(e){let t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat(`1e${t-2}`),1e-6)}const GR={hct:{method:`hct.c`,jnd:2,deltaEMethod:`hct`,blackWhiteClamp:{}},"hct-tonal":{method:`hct.c`,jnd:0,deltaEMethod:`hct`,blackWhiteClamp:{channel:`hct.t`,min:0,max:100}}};function KR(e,{method:t=II.gamut_mapping,space:n=void 0,deltaEMethod:r=``,jnd:i=2,blackWhiteClamp:a={}}={}){if(e=UI(e),hI(arguments[1])?n=arguments[1]:n||=e.space,n=GI.get(n),SL(e,n,{epsilon:0}))return e;let o;if(t===`css`)o=JR(e,{space:n});else{if(t!==`clip`&&!SL(e,n)){Object.prototype.hasOwnProperty.call(GR,t)&&({method:t,jnd:i,deltaEMethod:r,blackWhiteClamp:a}=GR[t]);let s=mL;if(r!==``){for(let e in UR)if(`deltae`+r.toLowerCase()===e.toLowerCase()){s=UR[e];break}}let c=KR(YR(e,n),{method:`clip`,space:n});if(s(e,c)>i){if(Object.keys(a).length===3){let t=GI.resolveCoord(a.channel),n=ZI(YR(e,t.space),t.id);if(vI(n)&&(n=0),n>=a.max)return YR({space:`xyz-d65`,coords:LI.D65},e.space);if(n<=a.min)return YR({space:`xyz-d65`,coords:[0,0,0]},e.space)}let r=GI.resolveCoord(t),c=r.space,l=r.id,u=YR(e,c);u.coords.forEach((e,t)=>{vI(e)&&(u.coords[t]=0)});let d=r.range||r.refRange,f=d[0],p=WR(i),m=f,h=ZI(u,l);for(;h-m>p;){let e=CL(u);e=KR(e,{space:n,method:`clip`});let t=s(u,e);t-i<p?m=ZI(u,l):h=ZI(u,l),$I(u,l,(m+h)/2)}o=YR(u,n)}else o=c}else o=YR(e,n);if(t===`clip`||!SL(o,n,{epsilon:0})){let e=Object.values(n.coords).map(e=>e.range||[]);o.coords=o.coords.map((t,n)=>{let[r,i]=e[n];return r!==void 0&&(t=Math.max(r,t)),i!==void 0&&(t=Math.min(t,i)),t})}}return n!==e.space&&(o=YR(o,e.space)),e.coords=o.coords,e}KR.returns=`color`;const qR={WHITE:{space:yL,coords:[1,0,0]},BLACK:{space:yL,coords:[0,0,0]}};function JR(e,{space:t}={}){let n=.02,r=1e-4;e=UI(e),t||=e.space,t=GI.get(t);let i=GI.get(`oklch`);if(t.isUnbounded)return YR(e,t);let a=YR(e,i),o=a.coords[0];if(o>=1){let n=YR(qR.WHITE,t);return n.alpha=e.alpha,YR(n,t)}if(o<=0){let n=YR(qR.BLACK,t);return n.alpha=e.alpha,YR(n,t)}if(SL(a,t,{epsilon:0}))return YR(a,t);function s(e){let n=YR(e,t),r=Object.values(t.coords);return n.coords=n.coords.map((e,t)=>{if(`range`in r[t]){let[n,i]=r[t].range;return OI(n,e,i)}return e}),n}let c=0,l=a.coords[1],u=!0,d=CL(a),f=s(d),p=bL(f,d);if(p<n)return f;for(;l-c>r;){let e=(c+l)/2;if(d.coords[1]=e,u&&SL(d,t,{epsilon:0}))c=e;else if(f=s(d),p=bL(f,d),p<n){if(n-p<r)break;u=!1,c=e}else l=e}return f}function YR(e,t,{inGamut:n}={}){e=UI(e),t=GI.get(t);let r=t.from(e),i={space:t,coords:r,alpha:e.alpha};return n&&(i=KR(i,n===!0?void 0:n)),i}YR.returns=`color`;function XR(e,{precision:t=II.precision,format:n=`default`,inGamut:r=!0,...i}={}){let a;e=UI(e);let o=n;n=e.space.getFormat(n)??e.space.getFormat(`default`)??GI.DEFAULT_FORMAT;let s=e.coords.slice();if(r||=n.toGamut,r&&!SL(e)&&(s=KR(CL(e),r===!0?void 0:r).coords),n.type===`custom`)if(i.precision=t,n.serialize)a=n.serialize(s,e.alpha,i);else throw TypeError(`format ${o} can only be used to parse colors, not for serialization`);else{let r=n.name||`color`;n.serializeCoords?s=n.serializeCoords(s,t):t!==null&&(s=s.map(e=>_I(e,{precision:t})));let i=[...s];if(r===`color`){var c,l;let t=n.id||(c=l=n.ids)?.[0]||e.space.id;i.unshift(t)}let o=e.alpha;t!==null&&(o=_I(o,{precision:t}));let u=e.alpha>=1||n.noAlpha?``:`${n.commas?`,`:` /`} ${o}`;a=`${r}(${i.join(n.commas?`, `:` `)}${u})`}return a}const ZR=[[.6369580483012914,.14461690358620832,.1688809751641721],[.2627002120112671,.6779980715188708,.05930171646986196],[0,.028072693049087428,1.060985057710791]],QR=[[1.716651187971268,-.355670783776392,-.25336628137366],[-.666684351832489,1.616481236634939,.0157685458139111],[.017639857445311,-.042770613257809,.942103121235474]];var $R=new YI({id:`rec2020-linear`,cssId:`--rec2020-linear`,name:`Linear REC.2020`,white:`D65`,toXYZ_M:ZR,fromXYZ_M:QR});const ez=1.09929682680944,tz=.018053968510807;var nz=new YI({id:`rec2020`,name:`REC.2020`,base:$R,toBase(e){return e.map(function(e){return e<tz*4.5?e/4.5:((e+ez-1)/ez)**(1/.45)})},fromBase(e){return e.map(function(e){return e>=tz?ez*e**.45-(ez-1):4.5*e})}});const rz=[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],iz=[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]];var az=new YI({id:`p3-linear`,cssId:`--display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:rz,fromXYZ_M:iz});const oz=[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],sz=[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]];var cz=new YI({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:oz,fromXYZ_M:sz}),lz={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let uz=[,,,].fill(`<percentage> | <number>[0, 255]`),dz=[,,,].fill(`<number>[0, 255]`);var fz=new YI({id:`srgb`,name:`sRGB`,base:cz,fromBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}),toBase:e=>e.map(e=>{let t=e<0?-1:1,n=e*t;return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}),formats:{rgb:{coords:uz},rgb_number:{name:`rgb`,commas:!0,coords:dz,noAlpha:!0},color:{},rgba:{coords:uz,commas:!0,lastAlpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:dz},hex:{type:`custom`,toGamut:!0,test:e=>/^#([a-f0-9]{3,4}){1,2}$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,`$&$&`));let t=[];return e.replace(/[a-f0-9]{2}/gi,e=>{t.push(parseInt(e,16)/255)}),{spaceId:`srgb`,coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:n=!0}={})=>{t<1&&e.push(t),e=e.map(e=>Math.round(e*255));let r=n&&e.every(e=>e%17==0),i=e.map(e=>r?(e/17).toString(16):e.toString(16).padStart(2,`0`)).join(``);return`#`+i}},keyword:{type:`custom`,test:e=>/^[a-z]+$/i.test(e),parse(e){e=e.toLowerCase();let t={spaceId:`srgb`,coords:null,alpha:1};if(e===`transparent`?(t.coords=lz.black,t.alpha=0):t.coords=lz[e],t.coords)return t}}}}),pz=new YI({id:`p3`,cssId:`display-p3`,name:`P3`,base:az,fromBase:fz.fromBase,toBase:fz.toBase});II.display_space=fz;let mz;if(typeof CSS<`u`&&CSS.supports)for(let e of[aL,nz,pz]){let t=e.getMinCoords(),n={space:e,coords:t,alpha:1},r=XR(n);if(CSS.supports(`color`,r)){II.display_space=e;break}}function hz(e,{space:t=II.display_space,...n}={}){let r=XR(e,n);if(typeof CSS>`u`||CSS.supports(`color`,r)||!II.display_space)r=new String(r),r.color=e;else{let i=e,a=e.coords.some(vI)||vI(e.alpha);if(a&&!(mz??=CSS.supports(`color`,`hsl(none 50% 50%)`))&&(i=CL(e),i.coords=i.coords.map(yI),i.alpha=yI(i.alpha),r=XR(i,n),CSS.supports(`color`,r)))return r=new String(r),r.color=i,r;i=YR(i,t),r=new String(XR(i,n)),r.color=i}return r}function gz(e,t){return e=UI(e),t=UI(t),e.space===t.space&&e.alpha===t.alpha&&e.coords.every((e,n)=>e===t.coords[n])}function _z(e){return ZI(e,[JI,`y`])}function vz(e,t){$I(e,[JI,`y`],t)}function yz(e){Object.defineProperty(e.prototype,`luminance`,{get(){return _z(this)},set(e){vz(this,e)}})}var bz=Object.freeze({__proto__:null,getLuminance:_z,register:yz,setLuminance:vz});function xz(e,t){e=UI(e),t=UI(t);let n=Math.max(_z(e),0),r=Math.max(_z(t),0);return r>n&&([n,r]=[r,n]),(n+.05)/(r+.05)}const Sz=.56,Cz=.57,wz=.62,Tz=.65,Ez=.022,Dz=1.414,Oz=.1,kz=5e-4,Az=1.14,jz=.027,Mz=1.14;function Nz(e){return e>=Ez?e:e+(Ez-e)**Dz}function Pz(e){let t=e<0?-1:1,n=Math.abs(e);return t*n**2.4}function Fz(e,t){t=UI(t),e=UI(e);let n,r,i,a,o,s;t=YR(t,`srgb`),[a,o,s]=t.coords;let c=Pz(a)*.2126729+Pz(o)*.7151522+Pz(s)*.072175;e=YR(e,`srgb`),[a,o,s]=e.coords;let l=Pz(a)*.2126729+Pz(o)*.7151522+Pz(s)*.072175,u=Nz(c),d=Nz(l),f=d>u;return Math.abs(d-u)<kz?r=0:f?(n=d**Sz-u**Cz,r=n*Az):(n=d**Tz-u**wz,r=n*Mz),i=Math.abs(r)<Oz?0:r>0?r-jz:r+jz,i*100}function Iz(e,t){e=UI(e),t=UI(t);let n=Math.max(_z(e),0),r=Math.max(_z(t),0);r>n&&([n,r]=[r,n]);let i=n+r;return i===0?0:(n-r)/i}const Lz=5e4;function Rz(e,t){e=UI(e),t=UI(t);let n=Math.max(_z(e),0),r=Math.max(_z(t),0);return r>n&&([n,r]=[r,n]),r===0?Lz:(n-r)/r}function zz(e,t){e=UI(e),t=UI(t);let n=ZI(e,[aL,`l`]),r=ZI(t,[aL,`l`]);return Math.abs(n-r)}const Bz=216/24389,Vz=24/116,Hz=24389/27;let Uz=LI.D65;var Wz=new GI({id:`lab-d65`,name:`Lab D65`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Uz,base:JI,fromBase(e){let t=e.map((e,t)=>e/Uz[t]),n=t.map(e=>e>Bz?Math.cbrt(e):(Hz*e+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(e){let t=[];t[1]=(e[0]+16)/116,t[0]=e[1]/500+t[1],t[2]=t[1]-e[2]/200;let n=[t[0]>Vz?t[0]**3:(116*t[0]-16)/Hz,e[0]>8?((e[0]+16)/116)**3:e[0]/Hz,t[2]>Vz?t[2]**3:(116*t[2]-16)/Hz];return n.map((e,t)=>e*Uz[t])},formats:{"lab-d65":{coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}});const Gz=5**.5*.5+.5;function Kz(e,t){e=UI(e),t=UI(t);let n=ZI(e,[Wz,`l`]),r=ZI(t,[Wz,`l`]),i=Math.abs(n**+Gz-r**+Gz),a=i**(1/Gz)*Math.SQRT2-40;return a<7.5?0:a}var qz=Object.freeze({__proto__:null,contrastAPCA:Fz,contrastDeltaPhi:Kz,contrastLstar:zz,contrastMichelson:Iz,contrastWCAG21:xz,contrastWeber:Rz});function Jz(e,t,n={}){hI(n)&&(n={algorithm:n});let{algorithm:r,...i}=n;if(!r){let e=Object.keys(qz).map(e=>e.replace(/^contrast/,``)).join(`, `);throw TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${e}`)}for(let n in e=UI(e),t=UI(t),qz)if(`contrast`+r.toLowerCase()===n.toLowerCase())return qz[n](e,t,i);throw TypeError(`Unknown contrast algorithm: ${r}`)}function Yz(e){let[t,n,r]=XI(e,JI),i=t+15*n+3*r;return[4*t/i,9*n/i]}function Xz(e){let[t,n,r]=XI(e,JI),i=t+n+r;return[t/i,n/i]}function Zz(e){Object.defineProperty(e.prototype,`uv`,{get(){return Yz(this)}}),Object.defineProperty(e.prototype,`xy`,{get(){return Xz(this)}})}var Qz=Object.freeze({__proto__:null,register:Zz,uv:Yz,xy:Xz});function $z(e,t,n={}){hI(n)&&(n={method:n});let{method:r=II.deltaE,...i}=n;for(let n in UR)if(`deltae`+r.toLowerCase()===n.toLowerCase())return UR[n](e,t,i);throw TypeError(`Unknown deltaE method: ${r}`)}function eB(e,t=.25){let n=GI.get(`oklch`,`lch`),r=[n,`l`];return $I(e,r,e=>e*(1+t))}function tB(e,t=.25){let n=GI.get(`oklch`,`lch`),r=[n,`l`];return $I(e,r,e=>e*(1-t))}var nB=Object.freeze({__proto__:null,darken:tB,lighten:eB});function rB(e,t,n=.5,r={}){[e,t]=[UI(e),UI(t)],gI(n)===`object`&&([n,r]=[.5,n]);let i=aB(e,t,r);return i(n)}function iB(e,t,n={}){let r;oB(e)&&([r,n]=[e,t],[e,t]=r.rangeArgs.colors);let{maxDeltaE:i,deltaEMethod:a,steps:o=2,maxSteps:s=1e3,...c}=n;r||([e,t]=[UI(e),UI(t)],r=aB(e,t,c));let l=$z(e,t),u=i>0?Math.max(o,Math.ceil(l/i)+1):o,d=[];if(s!==void 0&&(u=Math.min(u,s)),u===1)d=[{p:.5,color:r(.5)}];else{let e=1/(u-1);d=Array.from({length:u},(t,n)=>{let i=n*e;return{p:i,color:r(i)}})}if(i>0){let e=d.reduce((e,t,n)=>{if(n===0)return 0;let r=$z(t.color,d[n-1].color,a);return Math.max(e,r)},0);for(;e>i;){e=0;for(let t=1;t<d.length&&d.length<s;t++){let n=d[t-1],i=d[t],a=(i.p+n.p)/2,o=r(a);e=Math.max(e,$z(o,n.color),$z(o,i.color)),d.splice(t,0,{p:a,color:r(a)}),t++}}}return d=d.map(e=>e.color),d}function aB(e,t,n={}){if(oB(e)){let[n,r]=[e,t];return aB(...n.rangeArgs.colors,{...n.rangeArgs.options,...r})}let{space:r,outputSpace:i,progression:a,premultiplied:o}=n;e=UI(e),t=UI(t),e=CL(e),t=CL(t);let s={colors:[e,t],options:n};if(r=r?GI.get(r):GI.registry[II.interpolationSpace]||e.space,i=i?GI.get(i):r,e=YR(e,r),t=YR(t,r),e=KR(e),t=KR(t),r.coords.h&&r.coords.h.type===`angle`){let i=n.hue=n.hue||`shorter`,a=[r,`h`],[o,s]=[ZI(e,a),ZI(t,a)];isNaN(o)&&!isNaN(s)?o=s:isNaN(s)&&!isNaN(o)&&(s=o),[o,s]=sL(i,[o,s]),$I(e,a,o),$I(t,a,s)}return o&&(e.coords=e.coords.map(t=>t*e.alpha),t.coords=t.coords.map(e=>e*t.alpha)),Object.assign(n=>{n=a?a(n):n;let s=e.coords.map((e,r)=>{let i=t.coords[r];return wI(e,i,n)}),c=wI(e.alpha,t.alpha,n),l={space:r,coords:s,alpha:c};return o&&(l.coords=l.coords.map(e=>e/c)),i!==r&&(l=YR(l,i)),l},{rangeArgs:s})}function oB(e){return gI(e)===`function`&&!!e.rangeArgs}II.interpolationSpace=`lab`;function sB(e){e.defineFunction(`mix`,rB,{returns:`color`}),e.defineFunction(`range`,aB,{returns:`function<color>`}),e.defineFunction(`steps`,iB,{returns:`array<color>`})}var cB=Object.freeze({__proto__:null,isRange:oB,mix:rB,range:aB,register:sB,steps:iB}),lB=new GI({id:`hsl`,name:`HSL`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:fz,fromBase:e=>{let t=Math.max(...e),n=Math.min(...e),[r,i,a]=e,[o,s,c]=[NaN,0,(n+t)/2],l=t-n;if(l!==0){switch(s=c===0||c===1?0:(t-c)/Math.min(c,1-c),t){case r:o=(i-a)/l+(i<a?6:0);break;case i:o=(a-r)/l+2;break;case a:o=(r-i)/l+4}o*=60}return s<0&&(o+=180,s=Math.abs(s)),o>=360&&(o-=360),[o,s*100,c*100]},toBase:e=>{let[t,n,r]=e;t%=360,t<0&&(t+=360),n/=100,r/=100;function i(e){let i=(e+t/30)%12,a=n*Math.min(r,1-r);return r-a*Math.max(-1,Math.min(i-3,9-i,1))}return[i(0),i(8),i(4)]},formats:{hsl:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`]},hsla:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`],commas:!0,lastAlpha:!0}}}),uB=new GI({id:`hsv`,name:`HSV`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},v:{range:[0,100],name:`Value`}},base:lB,fromBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r+n*Math.min(r,1-r);return[t,i===0?0:200*(1-r/i),100*i]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=r*(1-n/2);return[t,i===0||i===1?0:(r-i)/Math.min(i,1-i)*100,i*100]},formats:{color:{id:`--hsv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),dB=new GI({id:`hwb`,name:`HWB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},w:{range:[0,100],name:`Whiteness`},b:{range:[0,100],name:`Blackness`}},base:uB,fromBase(e){let[t,n,r]=e;return[t,r*(100-n)/100,100-r]},toBase(e){let[t,n,r]=e;n/=100,r/=100;let i=n+r;if(i>=1){let e=n/i;return[t,0,e*100]}let a=1-r,o=a===0?0:1-n/a;return[t,o*100,a*100]},formats:{hwb:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const fB=[[.5766690429101305,.1855582379065463,.1882286462349947],[.29734497525053605,.6273635662554661,.07529145849399788],[.02703136138641234,.07068885253582723,.9913375368376388]],pB=[[2.0415879038107465,-.5650069742788596,-.34473135077832956],[-.9692436362808795,1.8759675015077202,.04155505740717557],[.013444280632031142,-.11836239223101838,1.0151749943912054]];var mB=new YI({id:`a98rgb-linear`,cssId:`--a98-rgb-linear`,name:`Linear Adobe® 98 RGB compatible`,white:`D65`,toXYZ_M:fB,fromXYZ_M:pB}),hB=new YI({id:`a98rgb`,cssId:`a98-rgb`,name:`Adobe® 98 RGB compatible`,base:mB,toBase:e=>e.map(e=>Math.abs(e)**(563/256)*Math.sign(e)),fromBase:e=>e.map(e=>Math.abs(e)**(256/563)*Math.sign(e))});const gB=[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],_B=[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]];var vB=new YI({id:`prophoto-linear`,cssId:`--prophoto-rgb-linear`,name:`Linear ProPhoto`,white:`D50`,base:eL,toXYZ_M:gB,fromXYZ_M:_B});const yB=1/512,bB=16/512;var xB=new YI({id:`prophoto`,cssId:`prophoto-rgb`,name:`ProPhoto`,base:vB,toBase(e){return e.map(e=>e<bB?e/16:e**1.8)},fromBase(e){return e.map(e=>e>=yB?e**(1/1.8):16*e)}}),SB=new GI({id:`oklch`,name:`Oklch`,coords:{l:{refRange:[0,1],name:`Lightness`},c:{refRange:[0,.4],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},white:`D65`,base:yL,fromBase(e){let[t,n,r]=e,i,a=2e-4;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),oL(i)]},toBase(e){let[t,n,r]=e,i,a;return isNaN(r)?(i=0,a=0):(i=n*Math.cos(r*Math.PI/180),a=n*Math.sin(r*Math.PI/180)),[t,i,a]},formats:{oklch:{coords:[`<percentage> | <number>`,`<number> | <percentage>[0,1]`,`<number> | <angle>`]}}});let CB=LI.D65;const wB=216/24389,TB=24389/27,[EB,DB]=Yz({space:JI,coords:CB});var OB=new GI({id:`luv`,name:`Luv`,coords:{l:{refRange:[0,100],name:`Lightness`},u:{refRange:[-215,215]},v:{refRange:[-215,215]}},white:CB,base:JI,fromBase(e){let t=[yI(e[0]),yI(e[1]),yI(e[2])],n=t[1],[r,i]=Yz({space:JI,coords:t});if(!Number.isFinite(r)||!Number.isFinite(i))return[0,0,0];let a=n<=wB?TB*n:116*Math.cbrt(n)-16;return[a,13*a*(r-EB),13*a*(i-DB)]},toBase(e){let[t,n,r]=e;if(t===0||vI(t))return[0,0,0];n=yI(n),r=yI(r);let i=n/(13*t)+EB,a=r/(13*t)+DB,o=t<=8?t/TB:((t+16)/116)**3;return[o*(9*i/(4*a)),o,o*((12-3*i-20*a)/(4*a))]},formats:{color:{id:`--luv`,coords:[`<number> | <percentage>`,`<number> | <percentage>[-1,1]`,`<number> | <percentage>[-1,1]`]}}}),kB=new GI({id:`lchuv`,name:`LChuv`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,220],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:OB,fromBase(e){let[t,n,r]=e,i,a=.02;return i=Math.abs(n)<a&&Math.abs(r)<a?NaN:Math.atan2(r,n)*180/Math.PI,[t,Math.sqrt(n**2+r**2),oL(i)]},toBase(e){let[t,n,r]=e;return n<0&&(n=0),isNaN(r)&&(r=0),[t,n*Math.cos(r*Math.PI/180),n*Math.sin(r*Math.PI/180)]},formats:{color:{id:`--lchuv`,coords:[`<number> | <percentage>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const AB=216/24389,jB=24389/27,MB=sz[0][0],NB=sz[0][1],PB=sz[0][2],FB=sz[1][0],IB=sz[1][1],LB=sz[1][2],RB=sz[2][0],zB=sz[2][1],BB=sz[2][2];function VB(e,t,n){let r=t/(Math.sin(n)-e*Math.cos(n));return r<0?1/0:r}function HB(e){let t=(e+16)**3/1560896,n=t>AB?t:e/jB,r=n*(284517*MB-94839*PB),i=n*(838422*PB+769860*NB+731718*MB),a=n*(632260*PB-126452*NB),o=n*(284517*FB-94839*LB),s=n*(838422*LB+769860*IB+731718*FB),c=n*(632260*LB-126452*IB),l=n*(284517*RB-94839*BB),u=n*(838422*BB+769860*zB+731718*RB),d=n*(632260*BB-126452*zB);return{r0s:r/a,r0i:i*e/a,r1s:r/(a+126452),r1i:(i-769860)*e/(a+126452),g0s:o/c,g0i:s*e/c,g1s:o/(c+126452),g1i:(s-769860)*e/(c+126452),b0s:l/d,b0i:u*e/d,b1s:l/(d+126452),b1i:(u-769860)*e/(d+126452)}}function UB(e,t){let n=t/360*Math.PI*2,r=VB(e.r0s,e.r0i,n),i=VB(e.r1s,e.r1i,n),a=VB(e.g0s,e.g0i,n),o=VB(e.g1s,e.g1i,n),s=VB(e.b0s,e.b0i,n),c=VB(e.b1s,e.b1i,n);return Math.min(r,i,a,o,s,c)}var WB=new GI({id:`hsluv`,name:`HSLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:kB,gamutSpace:fz,fromBase(e){let[t,n,r]=[yI(e[0]),yI(e[1]),yI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=HB(t),a=UB(e,r);i=n/a*100}return[r,i,t]},toBase(e){let[t,n,r]=[yI(e[0]),yI(e[1]),yI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=HB(r),a=UB(e,t);i=a/100*n}return[r,i,t]},formats:{color:{id:`--hsluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});sz[0][0],sz[0][1],sz[0][2],sz[1][0],sz[1][1],sz[1][2],sz[2][0],sz[2][1],sz[2][2];function GB(e,t){return Math.abs(t)/Math.sqrt(e**2+1)}function KB(e){let t=GB(e.r0s,e.r0i),n=GB(e.r1s,e.r1i),r=GB(e.g0s,e.g0i),i=GB(e.g1s,e.g1i),a=GB(e.b0s,e.b0i),o=GB(e.b1s,e.b1i);return Math.min(t,n,r,i,a,o)}var qB=new GI({id:`hpluv`,name:`HPLuv`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:kB,gamutSpace:`self`,fromBase(e){let[t,n,r]=[yI(e[0]),yI(e[1]),yI(e[2])],i;if(t>99.9999999)i=0,t=100;else if(t<1e-8)i=0,t=0;else{let e=HB(t),r=KB(e);i=n/r*100}return[r,i,t]},toBase(e){let[t,n,r]=[yI(e[0]),yI(e[1]),yI(e[2])],i;if(r>99.9999999)r=100,i=0;else if(r<1e-8)r=0,i=0;else{let e=HB(r),t=KB(e);i=t/100*n}return[r,i,t]},formats:{color:{id:`--hpluv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const JB=203,YB=2610/2**14,XB=2**14/2610,ZB=2523/2**5,QB=2**5/2523,$B=3424/2**12,eV=2413/2**7,tV=2392/2**7;var nV=new YI({id:`rec2100pq`,cssId:`rec2100-pq`,name:`REC.2100-PQ`,base:$R,toBase(e){return e.map(function(e){let t=(Math.max(e**QB-$B,0)/(eV-tV*e**QB))**XB;return t*1e4/JB})},fromBase(e){return e.map(function(e){let t=Math.max(e*JB/1e4,0),n=$B+eV*t**YB,r=1+tV*t**YB;return(n/r)**ZB})}});const rV=.17883277,iV=.28466892,aV=.55991073,oV=3.7743;var sV=new YI({id:`rec2100hlg`,cssId:`rec2100-hlg`,name:`REC.2100-HLG`,referred:`scene`,base:$R,toBase(e){return e.map(function(e){return e<=.5?e**2/3*oV:(Math.exp((e-aV)/rV)+iV)/12*oV})},fromBase(e){return e.map(function(e){return e/=oV,e<=1/12?Math.sqrt(3*e):rV*Math.log(12*e-iV)+aV})}});const cV={};FI.add(`chromatic-adaptation-start`,e=>{e.options.method&&(e.M=uV(e.W1,e.W2,e.options.method))}),FI.add(`chromatic-adaptation-end`,e=>{e.M||=uV(e.W1,e.W2,e.options.method)});function lV({id:e,toCone_M:t,fromCone_M:n}){cV[e]=arguments[0]}function uV(e,t,n=`Bradford`){let r=cV[n],[i,a,o]=mI(r.toCone_M,e),[s,c,l]=mI(r.toCone_M,t),u=[[s/i,0,0],[0,c/a,0],[0,0,l/o]],d=mI(u,r.toCone_M),f=mI(r.fromCone_M,d);return f}lV({id:`von Kries`,toCone_M:[[.40024,.7076,-.08081],[-.2263,1.16532,.0457],[0,0,.91822]],fromCone_M:[[1.8599363874558397,-1.1293816185800916,.21989740959619328],[.3611914362417676,.6388124632850422,-6370596838649899e-21],[0,0,1.0890636230968613]]}),lV({id:`Bradford`,toCone_M:[[.8951,.2664,-.1614],[-.7502,1.7135,.0367],[.0389,-.0685,1.0296]],fromCone_M:[[.9869929054667121,-.14705425642099013,.15996265166373122],[.4323052697233945,.5183602715367774,.049291228212855594],[-.00852866457517732,.04004282165408486,.96848669578755]]}),lV({id:`CAT02`,toCone_M:[[.7328,.4296,-.1624],[-.7036,1.6975,.0061],[.003,.0136,.9834]],fromCone_M:[[1.0961238208355142,-.27886900021828726,.18274517938277307],[.4543690419753592,.4735331543074117,.07209780371722911],[-.009627608738429355,-.00569803121611342,1.0153256399545427]]}),lV({id:`CAT16`,toCone_M:[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],fromCone_M:[[1.862067855087233,-1.0112546305316845,.14918677544445172],[.3875265432361372,.6214474419314753,-.008973985167612521],[-.01584149884933386,-.03412293802851557,1.0499644368778496]]}),Object.assign(LI,{A:[1.0985,1,.35585],C:[.98074,1,1.18232],D55:[.95682,1,.92149],D75:[.94972,1,1.22638],E:[1,1,1],F2:[.99186,1,.67393],F7:[.95041,1,1.08747],F11:[1.00962,1,.6435]}),LI.ACES=[.32168/.33767,1,.34065/.33767];const dV=[[.6624541811085053,.13400420645643313,.1561876870049078],[.27222871678091454,.6740817658111484,.05368951740793705],[-.005574649490394108,.004060733528982826,1.0103391003129971]],fV=[[1.6410233796943257,-.32480329418479,-.23642469523761225],[-.6636628587229829,1.6153315916573379,.016756347685530137],[.011721894328375376,-.008284441996237409,.9883948585390215]];var pV=new YI({id:`acescg`,cssId:`--acescg`,name:`ACEScg`,coords:{r:{range:[0,65504],name:`Red`},g:{range:[0,65504],name:`Green`},b:{range:[0,65504],name:`Blue`}},referred:`scene`,white:LI.ACES,toXYZ_M:dV,fromXYZ_M:fV});const mV=2**-16,hV=-.35828683,gV=(Math.log2(65504)+9.72)/17.52;var _V=new YI({id:`acescc`,cssId:`--acescc`,name:`ACEScc`,coords:{r:{range:[hV,gV],name:`Red`},g:{range:[hV,gV],name:`Green`},b:{range:[hV,gV],name:`Blue`}},referred:`scene`,base:pV,toBase(e){let t=-5.279999999999999/17.52;return e.map(function(e){return e<=t?(2**(e*17.52-9.72)-mV)*2:e<gV?2**(e*17.52-9.72):65504})},fromBase(e){return e.map(function(e){return e<=0?(Math.log2(mV)+9.72)/17.52:e<mV?(Math.log2(mV+e*.5)+9.72)/17.52:(Math.log2(e)+9.72)/17.52})}}),vV=Object.freeze({__proto__:null,A98RGB:hB,A98RGB_Linear:mB,ACEScc:_V,ACEScg:pV,CAM16_JMh:kR,HCT:RR,HPLuv:qB,HSL:lB,HSLuv:WB,HSV:uB,HWB:dB,ICTCP:oR,JzCzHz:qL,Jzazbz:KL,LCH:cL,LCHuv:kB,Lab:aL,Lab_D65:Wz,Luv:OB,OKLCH:SB,OKLab:yL,P3:pz,P3_Linear:az,ProPhoto:xB,ProPhoto_Linear:vB,REC_2020:nz,REC_2020_Linear:$R,REC_2100_HLG:sV,REC_2100_PQ:nV,XYZ_ABS_D65:AL,XYZ_D50:eL,XYZ_D65:JI,sRGB:fz,sRGB_Linear:cz}),yV=class e{constructor(...e){let t;e.length===1&&(t=UI(e[0]));let n,r,i;t?(n=t.space||t.spaceId,r=t.coords,i=t.alpha):[n,r,i]=e,Object.defineProperty(this,`space`,{value:GI.get(n),writable:!1,enumerable:!0,configurable:!0}),this.coords=r?r.slice():[0,0,0],this.alpha=i>1||i===void 0?1:i<0?0:i;for(let e=0;e<this.coords.length;e++)this.coords[e]===`NaN`&&(this.coords[e]=NaN);for(let e in this.space.coords)Object.defineProperty(this,e,{get:()=>this.get(e),set:t=>this.set(e,t)})}get spaceId(){return this.space.id}clone(){return new e(this.space,this.coords,this.alpha)}toJSON(){return{spaceId:this.spaceId,coords:this.coords,alpha:this.alpha}}display(...t){let n=hz(this,...t);return n.color=new e(n.color),n}static get(t,...n){return t instanceof e?t:new e(t,...n)}static defineFunction(t,n,r=n){let{instance:i=!0,returns:a}=r,o=function(...t){let r=n(...t);if(a===`color`)r=e.get(r);else if(a===`function<color>`){let t=r;r=function(...n){let r=t(...n);return e.get(r)},Object.assign(r,t)}else a===`array<color>`&&(r=r.map(t=>e.get(t)));return r};t in e||(e[t]=o),i&&(e.prototype[t]=function(...e){return o(this,...e)})}static defineFunctions(t){for(let n in t)e.defineFunction(n,t[n],t[n])}static extend(exports){if(exports.register)exports.register(e);else for(let n in exports)e.defineFunction(n,exports[n])}};yV.defineFunctions({get:ZI,getAll:XI,set:$I,setAll:QI,to:YR,equals:gz,inGamut:SL,toGamut:KR,distance:wL,toString:XR}),Object.assign(yV,{util:NI,hooks:FI,WHITES:LI,Space:GI,spaces:GI.registry,parse:HI,defaults:II});for(let e of Object.keys(vV))GI.register(vV[e]);for(let e in GI.registry)bV(e,GI.registry[e]);FI.add(`colorspace-init-end`,e=>{var t,n;bV(e.id,e),(t=n=e.aliases)?.forEach(t=>{bV(t,e)})});function bV(e,t){let n=e.replace(/-/g,`_`);Object.defineProperty(yV.prototype,n,{get(){let n=this.getAll(e);return typeof Proxy>`u`?n:new Proxy(n,{has:(e,n)=>{try{return GI.resolveCoord([t,n]),!0}catch{}return Reflect.has(e,n)},get:(e,n,r)=>{if(n&&typeof n!=`symbol`&&!(n in e)){let{index:r}=GI.resolveCoord([t,n]);if(r>=0)return e[r]}return Reflect.get(e,n,r)},set:(n,r,i,a)=>{if(r&&typeof r!=`symbol`&&!(r in n)||r>=0){let{index:a}=GI.resolveCoord([t,r]);if(a>=0)return n[a]=i,this.setAll(e,n),!0}return Reflect.set(n,r,i,a)}})},set(t){this.setAll(e,t)},configurable:!0,enumerable:!0})}yV.extend(UR),yV.extend({deltaE:$z}),Object.assign(yV,{deltaEMethods:UR}),yV.extend(nB),yV.extend({contrast:Jz}),yV.extend(Qz),yV.extend(bz),yV.extend(cB),yV.extend(qz);const{vec2:xV,vec4:SV}=yj,CV=e=>{let t=new yV(e);return SV(...t.to(`p3-linear`).coords,t.alpha).value},wV=e=>{let t=.5,n=.5;if(typeof e==`string`){let r=e.toLowerCase().trim().split(/\s+/);r.includes(`left`)?t=0:r.includes(`right`)?t=1:(r.includes(`center`)||r.length===1&&(r[0]===`top`||r[0]===`bottom`))&&(t=.5),r.includes(`top`)?n=0:r.includes(`bottom`)?n=1:(r.includes(`center`)||r.length===1&&(r[0]===`left`||r[0]===`right`))&&(n=.5),r.length===1&&r[0]===`center`&&(t=.5,n=.5)}else typeof e==`object`&&e?(t=e.x,n=e.y):console.warn(`Invalid position value provided: ${e}. Defaulting to center.`);return xV(t,1-n).value},{vec2:TV,viewportSize:EV}=yj,DV=(e=TV(0))=>{let t=EV,n=t.x.div(t.y),r=e.x.mul(n);return TV(r,e.y)},OV={name:`Circle`,props:{color:{type:String,default:`#ffffff`,transform:CV,description:`The color of the circle`},backgroundColor:{type:String,default:`transparent`,transform:CV,description:`The background color`},radius:{type:Number,default:1,description:`The radius of the circle`},softness:{type:Number,default:0,description:`Edge softness (0 = sharp, 1 = soft)`},center:{type:Object,default:{x:.5,y:.5},transform:wV}},fragmentNode:({uniforms:e})=>{let{vec2:t,vec4:n,length:r,mix:i,smoothstep:a,uv:o}=yj,s=t(e.center.uniform.x.mul(.5).add(.25),e.center.uniform.y.mul(.5).add(.25)),c=DV(o()),l=DV(s),u=r(c.sub(l)),d=e.softness.uniform,f=e.radius.uniform.mul(.25),p=a(f,f.sub(d),u);return n(i(e.backgroundColor.uniform,e.color.uniform,p),1)}};var kV=r({__name:`Circle`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},backgroundColor:{},radius:{},softness:{},center:{}},{blendMode:`normal`,opacity:1,...Object.entries(OV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${OV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(OV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(OV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(OV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,OV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),AV=kV;const jV={name:`DotGrid`,props:{color:{type:String,default:`#ffffff`,description:`Dot color`,transform:CV},density:{type:Number,default:100,description:`Grid density (number of dots)`},dotSize:{type:Number,default:.2,description:`Size of each dot (0-1)`}},fragmentNode:({uniforms:e})=>{let t=aF(),n=e.density.uniform,r=e.dotSize.uniform,i=e.color.uniform,a=MF,o=a.x.div(a.y),s=fF(t.x.mul(o),t.y),c=s.mul(n),l=c.sub(PM(c)),u=IM(l.sub(.5)),d=NM(1).sub(GN(r.mul(.45),r.mul(.5),u)),f=pF(i).mul(d);return mF(f,d)}};var MV=r({__name:`DotGrid`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{},density:{},dotSize:{}},{blendMode:`normal`,opacity:1,...Object.entries(jV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${jV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(jV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(jV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(jV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,jV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),NV=MV;const PV={name:`FilmGrain`,props:{intensity:{type:Number,default:.25,description:`Grain intensity (0-1)`},power:{type:Number,default:.645,description:`Controls blending based on brightness`},speed:{type:Number,default:.5,description:`Animation speed of grain noise`}},fragmentNode:({uniforms:e,childNode:t})=>{let n=t||mF(0,0,0,0),r=aF(),i=e=>FM(HN(MM(e,fF(12.9898,78.233))).mul(43758.5453)),a=e=>MM(e,mF(.299,.587,.114,0)),o=i(r).add(TP.mul(e.speed.uniform)),s=FM(HN(o.mul(43758.5453))),c=RM(NM(.5),NM(.75),s).mul(e.intensity.uniform),l=BM(a(n),e.power.uniform),u=n.mul(c),d=AM(l,0,1),f=RM(u,n,d);return mF(f.x,f.y,f.z,n.w)}};var FV=r({__name:`FilmGrain`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},power:{},speed:{}},{blendMode:`normal`,opacity:1,...Object.entries(PV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${PV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(PV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(PV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(PV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,PV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),IV=FV;const LV=new WeakMap,RV={name:`glassTiles`,props:{intensity:{type:Number,default:1,description:`The intensity of the glass tiles effect`},tileCount:{type:Number,default:100,description:`Number of tiles across the shortest dimension`}},fragmentNode:({uniforms:e,childNode:t,onCleanup:n,canvas:r})=>{let{vec2:i,vec4:a,floor:o,mul:s,div:c,sub:l,add:u,convertToTexture:d,uv:f,uniform:p}=yj;if(!t)return console.error(`You must pass a child component into the Glass Tiles shader.`),a(0);let m=d(t),h=p(1),g=()=>{r&&(h.value=r.clientWidth/r.clientHeight)};g();let _=LV.get(r);_||(_=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect,i=window.devicePixelRatio||1;m.setSize(n*i,r*i),g()}),_.observe(r),LV.set(r,_)),n(()=>{let e=LV.get(r);e&&(e.disconnect(),LV.delete(r))});let v=f(),y=e.intensity.uniform,b=e.tileCount.uniform,x=i(h.greaterThanEqual(1).select(s(b,h),b),h.lessThan(1).select(c(b,h),b)),S=c(o(s(v,x)),x),ee=l(v,S),te=i(.5,.5),ne=s(y,.025),re=c(ee,c(i(1),x)),ie=l(re,te),ae=s(ie,ne),oe=u(ee,ae),se=u(oe,S);return a(m.sample(se))}};var zV=r({__name:`GlassTiles`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{},tileCount:{}},{blendMode:`normal`,opacity:1,...Object.entries(RV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${RV.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(RV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(RV.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(RV,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,RV.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),BV=zV;const VV={VERTEX:`vertex`,FRAGMENT:`fragment`},HV={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},UV=[`fragment`,`vertex`],coe=[...UV,`compute`],WV=[`x`,`y`,`z`,`w`],GV=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let KV=1234567;const qV=Math.PI/180,JV=180/Math.PI;function YV(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=GV[e&255]+GV[e>>8&255]+GV[e>>16&255]+GV[e>>24&255]+`-`+GV[t&255]+GV[t>>8&255]+`-`+GV[t>>16&15|64]+GV[t>>24&255]+`-`+GV[n&63|128]+GV[n>>8&255]+`-`+GV[n>>16&255]+GV[n>>24&255]+GV[r&255]+GV[r>>8&255]+GV[r>>16&255]+GV[r>>24&255];return i.toLowerCase()}function XV(e,t,n){return Math.max(t,Math.min(n,e))}function ZV(e,t){return(e%t+t)%t}function QV(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function $V(e,t,n){return e===t?0:(n-e)/(t-e)}function eH(e,t,n){return(1-n)*e+n*t}function tH(e,t,n,r){return eH(e,t,1-Math.exp(-n*r))}function nH(e,t=1){return t-Math.abs(ZV(e,t*2)-t)}function rH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function iH(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function aH(e,t){return e+Math.floor(Math.random()*(t-e+1))}function oH(e,t){return e+Math.random()*(t-e)}function sH(e){return e*(.5-Math.random())}function cH(e){e!==void 0&&(KV=e);let t=KV+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function lH(e){return e*qV}function uH(e){return e*JV}function dH(e){return(e&e-1)==0&&e!==0}function fH(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function pH(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function mH(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function hH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function gH(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const _H={DEG2RAD:qV,RAD2DEG:JV,generateUUID:YV,clamp:XV,euclideanModulo:ZV,mapLinear:QV,inverseLerp:$V,lerp:eH,damp:tH,pingpong:nH,smoothstep:rH,smootherstep:iH,randInt:aH,randFloat:oH,randFloatSpread:sH,seededRandom:cH,degToRad:lH,radToDeg:uH,isPowerOfTwo:dH,ceilPowerOfTwo:fH,floorPowerOfTwo:pH,setQuaternionFromProperEuler:mH,normalize:gH,denormalize:hH},vH=0,yH=1015,bH=``,xH=`srgb`,SH=`srgb-linear`,CH=`linear`,wH=`srgb`,TH=35044,EH=2e3,DH=2001;var OH=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(kH.makeScale(e,t)),this}rotate(e){return this.premultiply(kH.makeRotation(-e)),this}translate(e,t){return this.premultiply(kH.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const kH=new OH,AH={};function jH(e){e in AH||(AH[e]=!0,console.warn(e))}const MH=new OH().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),NH=new OH().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function PH(){let e={enabled:!0,workingColorSpace:SH,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===wH&&(e.r=IH(e.r),e.g=IH(e.g),e.b=IH(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===wH&&(e.r=LH(e.r),e.g=LH(e.g),e.b=LH(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===bH?CH:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return jH(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return jH(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[SH]:{primaries:t,whitePoint:r,transfer:CH,toXYZ:MH,fromXYZ:NH,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:xH},outputColorSpaceConfig:{drawingBufferColorSpace:xH}},[xH]:{primaries:t,whitePoint:r,transfer:wH,toXYZ:MH,fromXYZ:NH,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:xH}}}),e}const FH=PH();function IH(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function LH(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}const RH={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},zH={h:0,s:0,l:0},BH={h:0,s:0,l:0};function VH(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var HH=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=xH){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,FH.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=FH.workingColorSpace){return this.r=e,this.g=t,this.b=n,FH.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=FH.workingColorSpace){if(e=ZV(e,1),t=XV(t,0,1),n=XV(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=VH(i,r,e+1/3),this.g=VH(i,r,e),this.b=VH(i,r,e-1/3)}return FH.colorSpaceToWorking(this,r),this}setStyle(e,t=xH){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=xH){let n=RH[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=IH(e.r),this.g=IH(e.g),this.b=IH(e.b),this}copyLinearToSRGB(e){return this.r=LH(e.r),this.g=LH(e.g),this.b=LH(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=xH){return FH.workingToColorSpace(UH.copy(this),e),Math.round(XV(UH.r*255,0,255))*65536+Math.round(XV(UH.g*255,0,255))*256+Math.round(XV(UH.b*255,0,255))}getHexString(e=xH){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=FH.workingColorSpace){FH.workingToColorSpace(UH.copy(this),t);let n=UH.r,r=UH.g,i=UH.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=FH.workingColorSpace){return FH.workingToColorSpace(UH.copy(this),t),e.r=UH.r,e.g=UH.g,e.b=UH.b,e}getStyle(e=xH){FH.workingToColorSpace(UH.copy(this),e);let t=UH.r,n=UH.g,r=UH.b;return e===xH?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(zH),this.setHSL(zH.h+e,zH.s+t,zH.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(zH),e.getHSL(BH);let n=eH(zH.h,BH.h,t),r=eH(zH.s,BH.s,t),i=eH(zH.l,BH.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const UH=new HH;HH.NAMES=RH;var WH=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}},GH=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(XV(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},KH=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(JH.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(JH.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=XV(this.x,e.x,t.x),this.y=XV(this.y,e.y,t.y),this.z=XV(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=XV(this.x,e,t),this.y=XV(this.y,e,t),this.z=XV(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(XV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return qH.copy(this).projectOnVector(e),this.sub(qH)}reflect(e){return this.sub(qH.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(XV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const qH=new KH,JH=new GH;var YH=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/XH.setFromMatrixColumn(e,0).length(),i=1/XH.setFromMatrixColumn(e,1).length(),a=1/XH.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(QH,e,$H)}lookAt(e,t,n){let r=this.elements;return nU.subVectors(e,t),nU.lengthSq()===0&&(nU.z=1),nU.normalize(),eU.crossVectors(n,nU),eU.lengthSq()===0&&(Math.abs(n.z)===1?nU.x+=1e-4:nU.z+=1e-4,nU.normalize(),eU.crossVectors(n,nU)),eU.normalize(),tU.crossVectors(nU,eU),r[0]=eU.x,r[4]=tU.x,r[8]=nU.x,r[1]=eU.y,r[5]=tU.y,r[9]=nU.y,r[2]=eU.z,r[6]=tU.z,r[10]=nU.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=XH.set(r[0],r[1],r[2]).length(),a=XH.set(r[4],r[5],r[6]).length(),o=XH.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],ZH.copy(this);let c=1/i,l=1/a,u=1/o;return ZH.elements[0]*=c,ZH.elements[1]*=c,ZH.elements[2]*=c,ZH.elements[4]*=l,ZH.elements[5]*=l,ZH.elements[6]*=l,ZH.elements[8]*=u,ZH.elements[9]*=u,ZH.elements[10]*=u,t.setFromRotationMatrix(ZH),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=EH){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===EH)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===DH)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=EH){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===EH)p=(a+i)*u,m=-2*u;else if(o===DH)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const XH=new KH,ZH=new YH,QH=new KH(0,0,0),$H=new KH(1,1,1),eU=new KH,tU=new KH,nU=new KH;var rU=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=XV(this.x,e.x,t.x),this.y=XV(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=XV(this.x,e,t),this.y=XV(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(XV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(XV(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},iU=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=XV(this.x,e.x,t.x),this.y=XV(this.y,e.y,t.y),this.z=XV(this.z,e.z,t.z),this.w=XV(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=XV(this.x,e,t),this.y=XV(this.y,e,t),this.z=XV(this.z,e,t),this.w=XV(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(XV(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};function aU(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const oU=(...e)=>aU(e);function sU(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of cU(e))n.push(aU(r.slice(0,-4)),i.getCacheKey(t));return aU(n)}function*cU(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}function lU(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function uU(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new HH(...t):n===`vec2`?new rU(...t):n===`vec3`?new KH(...t):n===`vec4`?new iU(...t):n===`mat2`?new WH(...t):n===`mat3`?new OH(...t):n===`mat4`?new YH(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?fU(t[0]):null}function dU(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function fU(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}var pU=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const mU={analyze:`setup`,generate:`analyze`};let hU=0;var gU=class extends pU{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=HV.NONE,this.updateBeforeType=HV.NONE,this.updateAfterType=HV.NONE,this.uuid=_H.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:hU++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,HV.FRAME)}onRenderUpdate(e){return this.onUpdate(e,HV.RENDER)}onObjectUpdate(e){return this.onUpdate(e,HV.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of cU(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=oU(sU(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=mU[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return cU(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},_U=gU,vU=class extends _U{static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},yU=vU,bU=class extends _U{static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},xU=bU,SU=class extends _U{static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},CU=SU,wU=class extends yU{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}},TU=wU;const EU=WV.join(``);var DU=class extends _U{static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(WV.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===EU.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},OU=DU,kU=class extends yU{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=WV[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},AU=kU,jU=class extends yU{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=WV[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},MU=jU,NU=class extends _U{static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?lU(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=lU(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=dU(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?uU(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}},PU=NU;const FU=/float|u?int/;var IU=class extends PU{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return FU.test(n)&&FU.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},LU=IU,RU=class extends _U{static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}},zU=RU;let BU=null;const VU=new Map;function R(e,t){if(VU.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);VU.set(e,t)}const HU=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),UU=e=>HU(e).split(``).sort().join(``),WU={setup(e,t){let n=t.shift();return e(hW(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(BU.assign(n,...e),n);if(VU.has(t)){let r=VU.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&VU.has(t.slice(0,t.length-6))){let r=VU.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=HU(t),mW(new OU(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=UU(t.slice(3).toLowerCase()),n=>mW(new AU(e,t,mW(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=UU(t.slice(4).toLowerCase()),()=>mW(new MU(mW(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),mW(new OU(e,t));else if(/^\d+$/.test(t)===!0)return mW(new xU(n,new LU(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>mW(new zU(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},GU=new WeakMap,KU=new WeakMap,qU=function(e,t=null){let n=lU(e);if(n===`node`){let t=GU.get(e);return t===void 0&&(t=new Proxy(e,WU),GU.set(e,t),GU.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return mW(lW(e,t));else if(n===`shader`)return vW(e);return e},JU=function(e,t=null){for(let n in e)e[n]=mW(e[n],t);return e},YU=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=mW(e[r],t);return e},XU=function(e,t=null,n=null,r=null){let i=e=>mW(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...gW(l(t)))):n===null?a=(...n)=>i(new e(t,...gW(l(n)))):(n=mW(n),a=(...r)=>i(new e(t,...gW(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a};var ZU=class extends _U{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=KU.get(e.constructor);r===void 0&&(r=new WeakMap,KU.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=mW(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=mW(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=mW(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},QU=class extends _U{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return hW(e),mW(new ZU(this,e))}setup(){return this.call()}};const $U=[!1,!0],eW=[0,1,2,3],tW=[-1,-2],nW=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],rW=new Map;for(let e of $U)rW.set(e,new LU(e));const iW=new Map;for(let e of eW)iW.set(e,new LU(e,`uint`));const aW=new Map([...iW].map(e=>new LU(e.value,`int`)));for(let e of tW)aW.set(e,new LU(e,`int`));const oW=new Map([...aW].map(e=>new LU(e.value)));for(let e of nW)oW.set(e,new LU(e));for(let e of nW)oW.set(-e,new LU(-e));const sW={bool:rW,uint:iW,ints:aW,float:oW},cW=new Map([...rW,...oW]),lW=(e,t)=>cW.has(e)?cW.get(e):e.isNode===!0?e:new LU(e,t),uW=e=>{try{return e.getNodeType()}catch{return}},dW=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[uU(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return mW(t.get(n[0]));if(n.length===1){let t=lW(n[0],e);return uW(t)===e?mW(t):mW(new CU(t,e))}let r=n.map(e=>lW(e));return mW(new TU(r,e))}},fW=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function pW(e,t){return new Proxy(new QU(e,t),WU)}const mW=(e,t=null)=>qU(e,t),hW=(e,t=null)=>new JU(e,t),gW=(e,t=null)=>new YU(e,t),z=(...e)=>new XU(...e);let _W=0;const vW=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new pW(e,n),i=(...e)=>{let t;hW(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ _W++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i};function yW(e){return BU&&BU.add(e),e}R(`toStack`,yW);const bW=new dW(`color`),xW=new dW(`float`,sW.float),SW=new dW(`int`,sW.ints),CW=new dW(`uint`,sW.uint),wW=new dW(`bool`,sW.bool),TW=new dW(`vec2`),EW=new dW(`ivec2`),DW=new dW(`uvec2`),OW=new dW(`bvec2`),kW=new dW(`vec3`),AW=new dW(`ivec3`),jW=new dW(`uvec3`),MW=new dW(`bvec3`),NW=new dW(`vec4`),PW=new dW(`ivec4`),FW=new dW(`uvec4`),IW=new dW(`bvec4`),LW=new dW(`mat2`),RW=new dW(`mat3`),zW=new dW(`mat4`);R(`toColor`,bW),R(`toFloat`,xW),R(`toInt`,SW),R(`toUint`,CW),R(`toBool`,wW),R(`toVec2`,TW),R(`toIVec2`,EW),R(`toUVec2`,DW),R(`toBVec2`,OW),R(`toVec3`,kW),R(`toIVec3`,AW),R(`toUVec3`,jW),R(`toBVec3`,MW),R(`toVec4`,NW),R(`toIVec4`,PW),R(`toUVec4`,FW),R(`toBVec4`,IW),R(`toMat2`,LW),R(`toMat3`,RW),R(`toMat4`,zW);const BW=z(xU).setParameterLength(2),VW=(e,t)=>mW(new CU(mW(e),t));R(`element`,BW),R(`convert`,VW),R(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),yW(e)));const HW={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var UW=class e extends yU{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(HW[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===EH;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const WW=z(UW,`+`).setParameterLength(2,1/0).setName(`add`),GW=z(UW,`-`).setParameterLength(2,1/0).setName(`sub`),KW=z(UW,`*`).setParameterLength(2,1/0).setName(`mul`),qW=z(UW,`/`).setParameterLength(2,1/0).setName(`div`),JW=z(UW,`%`).setParameterLength(2).setName(`mod`),YW=z(UW,`==`).setParameterLength(2).setName(`equal`),XW=z(UW,`!=`).setParameterLength(2).setName(`notEqual`),ZW=z(UW,`<`).setParameterLength(2).setName(`lessThan`),QW=z(UW,`>`).setParameterLength(2).setName(`greaterThan`),$W=z(UW,`<=`).setParameterLength(2).setName(`lessThanEqual`),eG=z(UW,`>=`).setParameterLength(2).setName(`greaterThanEqual`),tG=z(UW,`&&`).setParameterLength(2,1/0).setName(`and`),nG=z(UW,`||`).setParameterLength(2,1/0).setName(`or`),rG=z(UW,`!`).setParameterLength(1).setName(`not`),iG=z(UW,`^^`).setParameterLength(2).setName(`xor`),aG=z(UW,`&`).setParameterLength(2).setName(`bitAnd`),oG=z(UW,`~`).setParameterLength(2).setName(`bitNot`),sG=z(UW,`|`).setParameterLength(2).setName(`bitOr`),cG=z(UW,`^`).setParameterLength(2).setName(`bitXor`),lG=z(UW,`<<`).setParameterLength(2).setName(`shiftLeft`),uG=z(UW,`>>`).setParameterLength(2).setName(`shiftRight`),dG=vW(([e])=>(e.addAssign(1),e)),fG=vW(([e])=>(e.subAssign(1),e)),pG=vW(([e])=>{let t=SW(e).toConst();return e.addAssign(1),t}),mG=vW(([e])=>{let t=SW(e).toConst();return e.subAssign(1),t});R(`add`,WW),R(`sub`,GW),R(`mul`,KW),R(`div`,qW),R(`mod`,JW),R(`equal`,YW),R(`notEqual`,XW),R(`lessThan`,ZW),R(`greaterThan`,QW),R(`lessThanEqual`,$W),R(`greaterThanEqual`,eG),R(`and`,tG),R(`or`,nG),R(`not`,rG),R(`xor`,iG),R(`bitAnd`,aG),R(`bitNot`,oG),R(`bitOr`,sG),R(`bitXor`,cG),R(`shiftLeft`,lG),R(`shiftRight`,uG),R(`incrementBefore`,dG),R(`decrementBefore`,fG),R(`increment`,pG),R(`decrement`,mG);const hG=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),JW(e,t)),gG=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),JW(SW(e),SW(t)));R(`remainder`,hG),R(`modInt`,gG);var B=class e extends yU{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=GW(1,n);else if(i===e.RECIPROCAL)a=qW(1,n);else if(i===e.DIFFERENCE)a=RG(GW(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=NW(kW(i),0):e=NW(kW(e),0);let o=KW(e,i).xyz;a=AG(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===EH&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===EH&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===DH&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};B.ALL=`all`,B.ANY=`any`,B.RADIANS=`radians`,B.DEGREES=`degrees`,B.EXP=`exp`,B.EXP2=`exp2`,B.LOG=`log`,B.LOG2=`log2`,B.SQRT=`sqrt`,B.INVERSE_SQRT=`inversesqrt`,B.FLOOR=`floor`,B.CEIL=`ceil`,B.NORMALIZE=`normalize`,B.FRACT=`fract`,B.SIN=`sin`,B.COS=`cos`,B.TAN=`tan`,B.ASIN=`asin`,B.ACOS=`acos`,B.ATAN=`atan`,B.ABS=`abs`,B.SIGN=`sign`,B.LENGTH=`length`,B.NEGATE=`negate`,B.ONE_MINUS=`oneMinus`,B.DFDX=`dFdx`,B.DFDY=`dFdy`,B.ROUND=`round`,B.RECIPROCAL=`reciprocal`,B.TRUNC=`trunc`,B.FWIDTH=`fwidth`,B.TRANSPOSE=`transpose`,B.BITCAST=`bitcast`,B.EQUALS=`equals`,B.MIN=`min`,B.MAX=`max`,B.STEP=`step`,B.REFLECT=`reflect`,B.DISTANCE=`distance`,B.DIFFERENCE=`difference`,B.DOT=`dot`,B.CROSS=`cross`,B.POW=`pow`,B.TRANSFORM_DIRECTION=`transformDirection`,B.MIX=`mix`,B.CLAMP=`clamp`,B.REFRACT=`refract`,B.SMOOTHSTEP=`smoothstep`,B.FACEFORWARD=`faceforward`;const _G=xW(Math.PI),loe=xW(Math.PI*2),vG=z(B,B.ALL).setParameterLength(1),yG=z(B,B.ANY).setParameterLength(1),bG=z(B,B.RADIANS).setParameterLength(1),xG=z(B,B.DEGREES).setParameterLength(1),SG=z(B,B.EXP).setParameterLength(1),CG=z(B,B.EXP2).setParameterLength(1),wG=z(B,B.LOG).setParameterLength(1),TG=z(B,B.LOG2).setParameterLength(1),EG=z(B,B.SQRT).setParameterLength(1),DG=z(B,B.INVERSE_SQRT).setParameterLength(1),OG=z(B,B.FLOOR).setParameterLength(1),kG=z(B,B.CEIL).setParameterLength(1),AG=z(B,B.NORMALIZE).setParameterLength(1),jG=z(B,B.FRACT).setParameterLength(1),MG=z(B,B.SIN).setParameterLength(1),NG=z(B,B.COS).setParameterLength(1),PG=z(B,B.TAN).setParameterLength(1),FG=z(B,B.ASIN).setParameterLength(1),IG=z(B,B.ACOS).setParameterLength(1),LG=z(B,B.ATAN).setParameterLength(1,2),RG=z(B,B.ABS).setParameterLength(1),zG=z(B,B.SIGN).setParameterLength(1),BG=z(B,B.LENGTH).setParameterLength(1),VG=z(B,B.NEGATE).setParameterLength(1),HG=z(B,B.ONE_MINUS).setParameterLength(1),UG=z(B,B.DFDX).setParameterLength(1),WG=z(B,B.DFDY).setParameterLength(1),GG=z(B,B.ROUND).setParameterLength(1),KG=z(B,B.RECIPROCAL).setParameterLength(1),qG=z(B,B.TRUNC).setParameterLength(1),JG=z(B,B.FWIDTH).setParameterLength(1),YG=z(B,B.TRANSPOSE).setParameterLength(1),XG=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),YW(e,t)),ZG=z(B,B.MIN).setParameterLength(2,1/0),QG=z(B,B.MAX).setParameterLength(2,1/0),$G=z(B,B.STEP).setParameterLength(2),eK=z(B,B.REFLECT).setParameterLength(2),tK=z(B,B.DISTANCE).setParameterLength(2),nK=z(B,B.DIFFERENCE).setParameterLength(2),rK=z(B,B.DOT).setParameterLength(2),iK=z(B,B.CROSS).setParameterLength(2),aK=z(B,B.POW).setParameterLength(2),oK=z(B,B.POW,2).setParameterLength(1),sK=z(B,B.POW,3).setParameterLength(1),cK=z(B,B.POW,4).setParameterLength(1),lK=z(B,B.TRANSFORM_DIRECTION).setParameterLength(2),uK=e=>KW(zG(e),aK(RG(e),1/3)),dK=e=>rK(e,e),fK=z(B,B.MIX).setParameterLength(3),pK=(e,t=0,n=1)=>mW(new B(B.CLAMP,mW(e),mW(t),mW(n))),mK=e=>pK(e),hK=z(B,B.REFRACT).setParameterLength(3),gK=z(B,B.SMOOTHSTEP).setParameterLength(3),_K=z(B,B.FACEFORWARD).setParameterLength(3),vK=vW(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=rK(e.xy,TW(t,n)),a=JW(i,_G);return jG(MG(a).mul(r))}),yK=(e,t,n)=>fK(t,n,e),bK=(e,t,n)=>gK(t,n,e),xK=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),LG(e,t));R(`all`,vG),R(`any`,yG),R(`equals`,XG),R(`radians`,bG),R(`degrees`,xG),R(`exp`,SG),R(`exp2`,CG),R(`log`,wG),R(`log2`,TG),R(`sqrt`,EG),R(`inverseSqrt`,DG),R(`floor`,OG),R(`ceil`,kG),R(`normalize`,AG),R(`fract`,jG),R(`sin`,MG),R(`cos`,NG),R(`tan`,PG),R(`asin`,FG),R(`acos`,IG),R(`atan`,LG),R(`abs`,RG),R(`sign`,zG),R(`length`,BG),R(`lengthSq`,dK),R(`negate`,VG),R(`oneMinus`,HG),R(`dFdx`,UG),R(`dFdy`,WG),R(`round`,GG),R(`reciprocal`,KG),R(`trunc`,qG),R(`fwidth`,JG),R(`atan2`,xK),R(`min`,ZG),R(`max`,QG),R(`step`,$G),R(`reflect`,eK),R(`distance`,tK),R(`dot`,rK),R(`cross`,iK),R(`pow`,aK),R(`pow2`,oK),R(`pow3`,sK),R(`pow4`,cK),R(`transformDirection`,lK),R(`mix`,yK),R(`clamp`,pK),R(`refract`,hK),R(`smoothstep`,bK),R(`faceForward`,_K),R(`difference`,nK),R(`saturate`,mK),R(`cbrt`,uK),R(`transpose`,YG),R(`rand`,vK);var SK=class extends yU{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const CK=(...e)=>{let t;if(e.length===1){let n=e[0];t=new SK(null,n.length,n)}else{let n=e[0],r=e[1];t=new SK(n,r)}return mW(t)};R(`toArray`,(e,t)=>CK(Array(t).fill(e)));var wK=class extends _U{static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const TK=e=>new wK(e),EK=(e,t=0)=>new wK(e,!0,t),DK=EK(`render`),OK=TK(`object`);var kK=class extends PU{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=OK}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const AK=(e,t)=>{let n=fW(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return mW(new kK(r,n))};var jK=class extends _U{static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const MK=(e,t)=>mW(new jK(e,t));var NK=class extends yU{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=WV.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const PK=z(NK).setParameterLength(2);R(`assign`,PK);var FK=class extends yU{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(xW(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(xW(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const IK=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?gW(t):hW(t[0]),mW(new FK(mW(e),t)));R(`call`,IK);var LK=class extends _U{static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?MK(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
397
397
|
|
|
398
398
|
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
|
|
399
399
|
|
|
@@ -403,11 +403,11 @@ var<${n}> ${e} : ${a};`}},oj=class{constructor(e){this.backend=e}getCurrentDepth
|
|
|
403
403
|
|
|
404
404
|
`)}else e.addFlowCode(`
|
|
405
405
|
|
|
406
|
-
`);return e.format(l,n,t)}};const IK=z(FK).setParameterLength(2,3);R(`select`,IK);const LK=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),IK(...e));R(`cond`,LK);var RK=class extends hU{static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const zK=z(RK).setParameterLength(1,2),BK=(e,t)=>zK(e,{label:t});R(`context`,zK),R(`label`,BK);var VK=class extends hU{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const HK=z(VK),UK=(e,t=null)=>HK(e,t).toStack(),WK=(e,t=null)=>HK(e,t,!0).toStack();R(`toVar`,UK),R(`toConst`,WK);const GK=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),HK(e));R(`temp`,GK);var KK=class extends hU{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){var t;let n=e.getNodeProperties(this),r=n.varying;if(r===void 0){let t=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;n.varying=r=e.getVaryingFromNode(this,t,i,a,o),n.node=this.node}return(t=r).needsInterpolation||(t.needsInterpolation=e.shaderStage===`fragment`),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(zV.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(zV.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,zV.VERTEX);e.flowNodeFromShaderStage(zV.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const qK=z(KK).setParameterLength(1,2),JK=e=>qK(e);R(`toVarying`,qK),R(`toVertexStage`,JK),R(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),qK(...e))),R(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),qK(...e)));const YK=gW(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=uK(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),XK=gW(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=uK(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),ZK=`WorkingColorSpace`,QK=`OutputColorSpace`;var $K=class extends _U{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===ZK?NH.workingColorSpace:t===QK?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return NH.enabled===!1||n===r||!n||!r?i:(NH.getTransfer(n)===SH&&(i=jW(YK(i.rgb),i.a)),NH.getPrimaries(n)!==NH.getPrimaries(r)&&(i=jW(IW(NH._getMatrix(new EH,n,r)).mul(i.rgb),i.a)),NH.getTransfer(r)===SH&&(i=jW(XK(i.rgb),i.a)),i)}};const eq=(e,t)=>fW(new $K(fW(e),ZK,t)),tq=(e,t)=>fW(new $K(fW(e),t,ZK));R(`workingToColorSpace`,eq),R(`colorSpaceToWorking`,tq);var nq=class extends yU{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},rq=class extends hU{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=BV.OBJECT}setGroup(e){return this.group=e,this}element(e){return fW(new nq(this,fW(e)))}setNodeType(e){let t=OK(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},iq=rq,aq=class extends iq{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(TK)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const oq=(e,t,n=null)=>fW(new aq(e,t,n));var sq=class extends _U{static get type(){return`ToneMappingNode`}constructor(e,t=lq,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return iU(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===gH)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=jW(i(t.rgb,this.exposureNode),t.a),r}};const cq=(e,t,n)=>fW(new sq(e,fW(t),fW(n))),lq=oq(`toneMappingExposure`,`float`);R(`toneMapping`,(e,t,n)=>cq(t,n,e));const uq=new WH,dq=new tU;let fq=0;var pq=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:fq++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=CH,this.updateRanges=[],this.gpuType=_H,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)dq.fromBufferAttribute(this,t),dq.applyMatrix3(e),this.setXY(t,dq.x,dq.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)uq.fromBufferAttribute(this,t),uq.applyMatrix3(e),this.setXYZ(t,uq.x,uq.y,uq.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)uq.fromBufferAttribute(this,t),uq.applyMatrix4(e),this.setXYZ(t,uq.x,uq.y,uq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)uq.fromBufferAttribute(this,t),uq.applyNormalMatrix(e),this.setXYZ(t,uq.x,uq.y,uq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)uq.fromBufferAttribute(this,t),uq.transformDirection(e),this.setXYZ(t,uq.x,uq.y,uq.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=pH(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=mH(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=pH(t,this.array)),t}setX(e,t){return this.normalized&&(t=mH(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=pH(t,this.array)),t}setY(e,t){return this.normalized&&(t=mH(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=pH(t,this.array)),t}setZ(e,t){return this.normalized&&(t=mH(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=pH(t,this.array)),t}setW(e,t){return this.normalized&&(t=mH(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=mH(t,this.array),n=mH(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=mH(t,this.array),n=mH(n,this.array),r=mH(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=mH(t,this.array),n=mH(n,this.array),r=mH(r,this.array),i=mH(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==CH&&(e.usage=this.usage),e}};const mq=new WH;var hq=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)mq.fromBufferAttribute(this,t),mq.applyMatrix4(e),this.setXYZ(t,mq.x,mq.y,mq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)mq.fromBufferAttribute(this,t),mq.applyNormalMatrix(e),this.setXYZ(t,mq.x,mq.y,mq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)mq.fromBufferAttribute(this,t),mq.transformDirection(e),this.setXYZ(t,mq.x,mq.y,mq.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=pH(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=mH(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=mH(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=mH(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=mH(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=mH(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=pH(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=pH(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=pH(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=pH(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=mH(t,this.array),n=mH(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=mH(t,this.array),n=mH(n,this.array),r=mH(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=mH(t,this.array),n=mH(n,this.array),r=mH(r,this.array),i=mH(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new pq(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},gq=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=CH,this.updateRanges=[],this.version=0,this.uuid=qV()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=qV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=qV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},_q=class extends MU{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=CH,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new gq(n,i),s=new hq(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=qK(this);i=n.build(e,t)}return i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};const vq=(e,t=null,n=0,r=0)=>fW(new _q(e,t,n,r));R(`toAttribute`,e=>vq(e.value));var yq=class extends hU{static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=BV.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const bq=(e,t,n)=>fW(new yq(fW(e),t,n));R(`compute`,bq);var xq=class extends hU{static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const Sq=(e,t)=>fW(new xq(fW(e),t));R(`cache`,Sq);var Cq=class extends hU{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const wq=z(Cq).setParameterLength(2);R(`bypass`,wq);var Tq=class extends hU{static get type(){return`RemapNode`}constructor(e,t,n,r=yW(0),i=yW(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const Eq=z(Tq,null,null,{doClamp:!1}).setParameterLength(3,5),Dq=z(Tq).setParameterLength(3,5);R(`remap`,Eq),R(`remapClamp`,Dq);var Oq=class extends hU{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const kq=z(Oq).setParameterLength(1,2),Aq=e=>(e?IK(e,kq(`discard`)):kq(`discard`)).toStack();R(`discard`,Aq);var jq=class extends _U{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||gH,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||vH;return n!==gH&&(t=t.toneMapping(n)),r!==vH&&r!==NH.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const Mq=(e,t=null,n=null)=>fW(new jq(fW(e),t,n));R(`renderOutput`,Mq);var Nq=class extends _U{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
|
|
406
|
+
`);return e.format(l,n,t)}};const RK=z(LK).setParameterLength(2,3);R(`select`,RK);const zK=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),RK(...e));R(`cond`,zK);var BK=class extends _U{static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const VK=z(BK).setParameterLength(1,2),HK=(e,t)=>VK(e,{label:t});R(`context`,VK),R(`label`,HK);var UK=class extends _U{static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const WK=z(UK),GK=(e,t=null)=>WK(e,t).toStack(),KK=(e,t=null)=>WK(e,t,!0).toStack();R(`toVar`,GK),R(`toConst`,KK);const qK=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),WK(e));R(`temp`,qK);var JK=class extends _U{static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){var t;let n=e.getNodeProperties(this),r=n.varying;if(r===void 0){let t=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;n.varying=r=e.getVaryingFromNode(this,t,i,a,o),n.node=this.node}return(t=r).needsInterpolation||(t.needsInterpolation=e.shaderStage===`fragment`),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(VV.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(VV.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,VV.VERTEX);e.flowNodeFromShaderStage(VV.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const YK=z(JK).setParameterLength(1,2),XK=e=>YK(e);R(`toVarying`,YK),R(`toVertexStage`,XK),R(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),YK(...e))),R(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),YK(...e)));const ZK=vW(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=fK(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),QK=vW(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=fK(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),$K=`WorkingColorSpace`,eq=`OutputColorSpace`;var tq=class extends yU{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===$K?FH.workingColorSpace:t===eq?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return FH.enabled===!1||n===r||!n||!r?i:(FH.getTransfer(n)===wH&&(i=NW(ZK(i.rgb),i.a)),FH.getPrimaries(n)!==FH.getPrimaries(r)&&(i=NW(RW(FH._getMatrix(new OH,n,r)).mul(i.rgb),i.a)),FH.getTransfer(r)===wH&&(i=NW(QK(i.rgb),i.a)),i)}};const nq=(e,t)=>mW(new tq(mW(e),$K,t)),rq=(e,t)=>mW(new tq(mW(e),t,$K));R(`workingToColorSpace`,nq),R(`colorSpaceToWorking`,rq);var iq=class extends xU{static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},aq=class extends _U{static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=HV.OBJECT}setGroup(e){return this.group=e,this}element(e){return mW(new iq(this,mW(e)))}setNodeType(e){let t=AK(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},oq=aq,sq=class extends oq{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(DK)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const cq=(e,t,n=null)=>mW(new sq(e,t,n));var lq=class extends yU{static get type(){return`ToneMappingNode`}constructor(e,t=dq,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return oU(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===vH)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=NW(i(t.rgb,this.exposureNode),t.a),r}};const uq=(e,t,n)=>mW(new lq(e,mW(t),mW(n))),dq=cq(`toneMappingExposure`,`float`);R(`toneMapping`,(e,t,n)=>uq(t,n,e));const fq=new KH,pq=new rU;let mq=0;var hq=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:mq++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=TH,this.updateRanges=[],this.gpuType=yH,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)pq.fromBufferAttribute(this,t),pq.applyMatrix3(e),this.setXY(t,pq.x,pq.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)fq.fromBufferAttribute(this,t),fq.applyMatrix3(e),this.setXYZ(t,fq.x,fq.y,fq.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)fq.fromBufferAttribute(this,t),fq.applyMatrix4(e),this.setXYZ(t,fq.x,fq.y,fq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)fq.fromBufferAttribute(this,t),fq.applyNormalMatrix(e),this.setXYZ(t,fq.x,fq.y,fq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)fq.fromBufferAttribute(this,t),fq.transformDirection(e),this.setXYZ(t,fq.x,fq.y,fq.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=hH(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=gH(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=hH(t,this.array)),t}setX(e,t){return this.normalized&&(t=gH(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=hH(t,this.array)),t}setY(e,t){return this.normalized&&(t=gH(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=hH(t,this.array)),t}setZ(e,t){return this.normalized&&(t=gH(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=hH(t,this.array)),t}setW(e,t){return this.normalized&&(t=gH(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=gH(t,this.array),n=gH(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=gH(t,this.array),n=gH(n,this.array),r=gH(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=gH(t,this.array),n=gH(n,this.array),r=gH(r,this.array),i=gH(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==TH&&(e.usage=this.usage),e}};const gq=new KH;var _q=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)gq.fromBufferAttribute(this,t),gq.applyMatrix4(e),this.setXYZ(t,gq.x,gq.y,gq.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)gq.fromBufferAttribute(this,t),gq.applyNormalMatrix(e),this.setXYZ(t,gq.x,gq.y,gq.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)gq.fromBufferAttribute(this,t),gq.transformDirection(e),this.setXYZ(t,gq.x,gq.y,gq.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=hH(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=gH(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=gH(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=gH(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=gH(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=gH(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=hH(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=hH(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=hH(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=hH(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=gH(t,this.array),n=gH(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=gH(t,this.array),n=gH(n,this.array),r=gH(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=gH(t,this.array),n=gH(n,this.array),r=gH(r,this.array),i=gH(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new hq(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},vq=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=TH,this.updateRanges=[],this.version=0,this.uuid=YV()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=YV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=YV()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},yq=class extends PU{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=TH,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new vq(n,i),s=new _q(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=YK(this);i=n.build(e,t)}return i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};const bq=(e,t=null,n=0,r=0)=>mW(new yq(e,t,n,r));R(`toAttribute`,e=>bq(e.value));var xq=class extends _U{static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=HV.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const Sq=(e,t,n)=>mW(new xq(mW(e),t,n));R(`compute`,Sq);var Cq=class extends _U{static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const wq=(e,t)=>mW(new Cq(mW(e),t));R(`cache`,wq);var Tq=class extends _U{static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const Eq=z(Tq).setParameterLength(2);R(`bypass`,Eq);var Dq=class extends _U{static get type(){return`RemapNode`}constructor(e,t,n,r=xW(0),i=xW(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const Oq=z(Dq,null,null,{doClamp:!1}).setParameterLength(3,5),kq=z(Dq).setParameterLength(3,5);R(`remap`,Oq),R(`remapClamp`,kq);var Aq=class extends _U{static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const jq=z(Aq).setParameterLength(1,2),Mq=e=>(e?RK(e,jq(`discard`)):jq(`discard`)).toStack();R(`discard`,Mq);var Nq=class extends yU{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||vH,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||bH;return n!==vH&&(t=t.toneMapping(n)),r!==bH&&r!==FH.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const Pq=(e,t=null,n=null)=>mW(new Nq(mW(e),t,n));R(`renderOutput`,Pq);var Fq=class extends yU{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
|
|
407
407
|
`,a+=e.flow.code.replace(/^\t/gm,``)+`
|
|
408
408
|
`,a+=`/* ... */ `+n+` /* ... */
|
|
409
409
|
`,a+=`// #`+i+`#
|
|
410
|
-
`,t===null?console.log(a):t(e,a),n}};const Pq=(e,t=null)=>fW(new Nq(fW(e),t));R(`debug`,Pq);const Fq=gW(([e])=>zq(e.rgb)),Iq=gW(([e,t=yW(1)])=>t.mix(zq(e.rgb),e.rgb)),Lq=gW(([e,t=yW(1)])=>{let n=HW(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return uK(e.rgb,r,i)}),Rq=gW(([e,t=yW(1)])=>{let n=DW(.57735,.57735,.57735),r=t.cos();return DW(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(tK(n,e.rgb).mul(r.oneMinus())))))}),zq=(e,t=DW(NH.getLuminanceCoefficients(new WH)))=>tK(e,t),Bq={name:`Grayscale`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t}=yj;if(!e)return console.error(`You must pass a child component into the Grayscale shader.`),t(0);let n=e||t(0,0,0,0);return t(Fq(n.rgb).rgb,n.a)}};var Vq=r({__name:`Grayscale`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Bq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Bq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Bq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Bq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(Bq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Bq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Hq=Vq;const Uq={name:`HueShift`,props:{shift:{type:Number,default:0,description:`The amount to shift the hue by`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=yj;if(!t)return console.error(`You must pass a child component into the Hue Shift shader.`),n(0);let r=t||n(0,0,0,0);return n(Rq(r.rgb,e.shift.uniform).rgb,r.a)}};var Wq=r({__name:`HueShift`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},shift:{}},{blendMode:`normal`,opacity:1,...Object.entries(Uq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Uq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Uq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Uq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(Uq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Uq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Gq=Wq;const Kq={name:`Invert`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t,vec3:n}=yj;if(!e)return console.error(`You must pass a child component into the Invert shader.`),t(0);let r=e||t(0,0,0,0);return t(n(1,1,1).sub(r.rgb),r.a)}};var qq=r({__name:`Invert`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Kq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Kq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Kq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Kq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(Kq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Kq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Jq=qq;const Yq={name:`LinearGradient`,props:{startColor:{type:String,default:`#1aff00`,transform:xV,description:`The starting color of the gradient`},endColor:{type:String,default:`#0000ff`,transform:xV,description:`The ending color of the gradient`},angle:{type:Number,default:0,description:`rotation angle in degrees (0-360, where 0 = left-to-right)`},center:{type:Object,default:{x:.5,y:.5},transform:SV},autoRotate:{type:Boolean,default:!1,description:`Enable automatic rotation of the gradient`},autoRotateSpeed:{type:Number,default:1,description:`Speed of the automatic rotation in degrees per second`}},fragmentNode:({uniforms:e,onBeforeRender:t})=>{let{vec2:n,mix:r,float:i,cos:a,sin:o,dot:s,radians:c,viewportUV:l,abs:u,div:d,uniform:f}=yj,p=f(0);t(({deltaTime:t})=>{if(e.autoRotate.uniform.value){let n=e.autoRotateSpeed.uniform.value*t*100;p.value=(p.value+n)%360}});let m=e.angle.uniform.add(p),h=c(m),g=a(h),_=o(h),v=n(g,_),y=n(e.center.uniform[0],e.center.uniform[1]),b=l.sub(y),x=s(b,v),S=i(.5).mul(u(g).add(u(_))),ee=d(x,S.max(1e-6)),te=ee.mul(.5).add(.5).clamp(i(0),i(1));return r(e.startColor.uniform,e.endColor.uniform,te)}};var Xq=r({__name:`LinearGradient`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},startColor:{},endColor:{},angle:{},center:{},autoRotate:{type:Boolean},autoRotateSpeed:{}},{blendMode:`normal`,opacity:1,...Object.entries(Yq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Yq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Yq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Yq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(Yq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Yq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Zq=Xq;const Qq={name:`MouseDistortion`,props:{distortionRadius:{type:Number,default:.2,description:`Radius of the distortion effect (0-1)`},distortionStrength:{type:Number,default:.1,description:`Strength of the distortion (0-1)`},smoothing:{type:Number,default:.85,description:`Smoothing factor for mouse movement (0-1, higher = smoother)`}},fragmentNode:({uniforms:e,onBeforeRender:t,childNode:n})=>{let{vec2:r,vec4:i,float:a,uniform:o,length:s,smoothstep:c,screenUV:l,convertToTexture:u}=yj;if(!n)return console.warn(`MouseDistortion: No child node provided`),i(0,0,0,0);let d=u(n),f=o(.5),p=o(.5),m=o(0),h=o(0),g=.5,_=.5,v=.5,y=.5,b=0,x=0;t(({pointer:t,deltaTime:n})=>{let r=(t.x-g)/n,i=(t.y-_)/n,a=e.smoothing.uniform.value,o=v+(t.x-v)*(1-a),s=y+(t.y-y)*(1-a),c=b+(r-b)*(1-a),l=x+(i-x)*(1-a);f.value=o,p.value=s,m.value=c,h.value=l,g=t.x,_=t.y,v=o,y=s,b=c,x=l});let S=l,ee=r(f,p),te=S.sub(ee),ne=s(te),re=e.distortionRadius.uniform,ie=c(re,a(0),ne),ae=r(m,h),oe=e.distortionStrength.uniform,se=ie.mul(oe).mul(a(.5)),ce=te.mul(se),le=a(2),ue=ae.mul(le).mul(ie).mul(oe),de=ce.add(ue),fe=S.sub(de);return d.sample(fe)}};var $q=r({__name:`MouseDistortion`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},distortionRadius:{},distortionStrength:{},smoothing:{}},{blendMode:`normal`,opacity:1,...Object.entries(Qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Qq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Qq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(Qq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Qq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),eJ=$q,tJ=class extends _U{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const nJ=z(tJ).setParameterLength(2),rJ={name:`Posterize`,props:{intensity:{type:Number,default:5,description:`The intensity of the posterization effect (lower is more posterized)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n,int:r}=yj;if(!t)return console.error(`You must pass a child component into the Posterize shader.`),n(0);let i=t||n(0,0,0,0);return nJ(i,r(e.intensity.uniform))}};var iJ=r({__name:`Posterize`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(rJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${rJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(rJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(rJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(rJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,rJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),aJ=iJ;const oJ={name:`Saturation`,props:{intensity:{type:Number,default:1,description:`The intensity of the saturation effect (1 being no change)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=yj;if(!t)return console.error(`You must pass a child component into the Saturation shader.`),n(0);let r=t||n(0,0,0,0);return n(Iq(r.rgb,e.intensity.uniform).rgb,r.a)}};var sJ=r({__name:`Saturation`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(oJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${oJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(oJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(oJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(oJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,oJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),cJ=sJ;const lJ={name:`SolidColor`,props:{color:{type:String,default:`#5b18ca`,transform:xV,description:`The solid color to display`}},fragmentNode:({uniforms:e})=>e.color.uniform};var uJ=r({__name:`SolidColor`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{}},{blendMode:`normal`,opacity:1,...Object.entries(lJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${lJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(lJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(lJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(lJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,lJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),dJ=uJ;const fJ={name:`Swirl`,props:{colorA:{type:String,default:`#1275d8`,description:`Primary gradient color`,transform:xV},colorB:{type:String,default:`#e19136`,description:`Secondary gradient color`,transform:xV},colorC:{type:String,default:`#320485`,description:`Accent gradient color`,transform:xV},speed:{type:Number,default:1,description:`Flow animation speed`},scale:{type:Number,default:5,description:`Gradient scale`},complexity:{type:Number,default:5,description:`Flow complexity`}},fragmentNode:({uniforms:e})=>{let t=rF(),n=CP.mul(e.speed.uniform),r=e.scale.uniform,i=e.complexity.uniform,a=BN(t.x.mul(r.mul(1.2)).add(n.mul(.8))).mul(.3),o=AM(t.y.mul(r.mul(.9)).sub(n.mul(.6))).mul(.3),s=uF(t.x.add(BN(t.y.mul(i.mul(2)).add(n)).mul(.08)),t.y.add(AM(t.x.mul(i.mul(1.5)).sub(n.mul(.7))).mul(.08))),c=BN(s.x.mul(r.mul(3)).add(s.y.mul(r.mul(2))).add(n.mul(.5))),l=AM(s.x.sub(s.y).mul(r.mul(2.5)).add(n.mul(.3))),u=BN(s.x.mul(i).add(a).add(s.y.mul(i.mul(.8)).add(o)).add(n.mul(.4))),d=LM(c,l,u.mul(.5).add(.5)),f=s.x.mul(.7).add(s.y.mul(.3)).add(d.mul(.2)),p=LM(e.colorA.uniform,e.colorB.uniform,UN(.1,.6,f)),m=LM(p,e.colorC.uniform,UN(.4,.9,f.add(u.mul(.3)))),h=BN(n.mul(3).add(f.mul(10))).mul(.02).add(1),g=m.mul(h);return fF(g,1)}};var pJ=r({__name:`Swirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},colorA:{},colorB:{},colorC:{},speed:{},scale:{},complexity:{}},{blendMode:`normal`,opacity:1,...Object.entries(fJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${fJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(fJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(fJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(fJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,fJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),mJ=pJ;const hJ={name:`Twirl`,props:{center:{type:Object,default:{x:.5,y:.5},transform:SV,description:`The center point of the twirl effect`},intensity:{type:Number,default:1,description:`The strength of the twirl effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec2:n,vec4:r,cos:i,sin:a,length:o,uv:s,convertToTexture:c}=yj;if(!t)return console.error(`You must pass a child component into the Twirl shader.`),r(0);let l=c(t),u=s(),d=n(e.center.uniform.x,e.center.uniform.y),f=u.sub(d),p=e.intensity.uniform.mul(o(f)),m=i(p),h=a(p),g=m.mul(f.x).sub(h.mul(f.y)),_=h.mul(f.x).add(m.mul(f.y)),v=n(g.add(d.x),_.add(d.y));return r(l.sample(v))}};var gJ=r({__name:`Twirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},center:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(hJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${hJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(hJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(hJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(hJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,hJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),_J=gJ;const vJ={name:`Vibrance`,props:{intensity:{type:Number,default:0,description:`The intensity of the vibrance effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=yj;if(!t)return console.error(`You must pass a child component into the Vibrance shader.`),n(0);let r=t||n(0,0,0,0);return n(Lq(r.rgb,e.intensity.uniform).rgb,r.a)}};var yJ=r({__name:`Vibrance`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(vJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${vJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(vJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(vJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=rI(vJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,vJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),bJ=yJ;const xJ=`177`,SJ=0,CJ=3,wJ=0,TJ=1,EJ=0,DJ=1,OJ=100,kJ=204,AJ=205,jJ=3,MJ=0,NJ=0,PJ=300,FJ=301,IJ=302,LJ=306,RJ=1e3,zJ=1001,BJ=1002,VJ=1003,HJ=1006,UJ=1008,WJ=1008,GJ=1009,KJ=1013,qJ=1014,JJ=1015,YJ=1016,XJ=1023,ZJ=1026,QJ=1027,$J=1030,eY=2300,tY=2301,nY=2302,rY=2400,iY=2401,aY=2402,oY=0,sY=1,cY=``,lY=`srgb`,uY=`srgb-linear`,dY=`linear`,fY=`srgb`,pY=7680,mY=519,hY=512,gY=513,_Y=514,vY=515,yY=516,bY=517,xY=518,SY=519,CY=35044,wY=35048,TY=2e3,EY=2001;var DY=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const OY=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let kY=1234567;const AY=Math.PI/180,jY=180/Math.PI;function MY(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=OY[e&255]+OY[e>>8&255]+OY[e>>16&255]+OY[e>>24&255]+`-`+OY[t&255]+OY[t>>8&255]+`-`+OY[t>>16&15|64]+OY[t>>24&255]+`-`+OY[n&63|128]+OY[n>>8&255]+`-`+OY[n>>16&255]+OY[n>>24&255]+OY[r&255]+OY[r>>8&255]+OY[r>>16&255]+OY[r>>24&255];return i.toLowerCase()}function NY(e,t,n){return Math.max(t,Math.min(n,e))}function PY(e,t){return(e%t+t)%t}function FY(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function IY(e,t,n){return e===t?0:(n-e)/(t-e)}function LY(e,t,n){return(1-n)*e+n*t}function RY(e,t,n,r){return LY(e,t,1-Math.exp(-n*r))}function zY(e,t=1){return t-Math.abs(PY(e,t*2)-t)}function BY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function VY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function HY(e,t){return e+Math.floor(Math.random()*(t-e+1))}function UY(e,t){return e+Math.random()*(t-e)}function WY(e){return e*(.5-Math.random())}function GY(e){e!==void 0&&(kY=e);let t=kY+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function KY(e){return e*AY}function qY(e){return e*jY}function JY(e){return(e&e-1)==0&&e!==0}function YY(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function XY(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function ZY(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function QY(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function $Y(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const eX={DEG2RAD:AY,RAD2DEG:jY,generateUUID:MY,clamp:NY,euclideanModulo:PY,mapLinear:FY,inverseLerp:IY,lerp:LY,damp:RY,pingpong:zY,smoothstep:BY,smootherstep:VY,randInt:HY,randFloat:UY,randFloatSpread:WY,seededRandom:GY,degToRad:KY,radToDeg:qY,isPowerOfTwo:JY,ceilPowerOfTwo:YY,floorPowerOfTwo:XY,setQuaternionFromProperEuler:ZY,normalize:$Y,denormalize:QY};var tX=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=NY(this.x,e.x,t.x),this.y=NY(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=NY(this.x,e,t),this.y=NY(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(NY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(NY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},nX=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(NY(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},V=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(iX.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(iX.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=NY(this.x,e.x,t.x),this.y=NY(this.y,e.y,t.y),this.z=NY(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=NY(this.x,e,t),this.y=NY(this.y,e,t),this.z=NY(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(NY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return rX.copy(this).projectOnVector(e),this.sub(rX)}reflect(e){return this.sub(rX.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(NY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const rX=new V,iX=new nX;var aX=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(oX.makeScale(e,t)),this}rotate(e){return this.premultiply(oX.makeRotation(-e)),this}translate(e,t){return this.premultiply(oX.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const oX=new aX;function sX(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function cX(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}const lX={};function uX(e){e in lX||(lX[e]=!0,console.warn(e))}const dX=new aX().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),fX=new aX().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function pX(){let e={enabled:!0,workingColorSpace:uY,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===fY&&(e.r=hX(e.r),e.g=hX(e.g),e.b=hX(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===fY&&(e.r=gX(e.r),e.g=gX(e.g),e.b=gX(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===cY?dY:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return uX(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return uX(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[uY]:{primaries:t,whitePoint:r,transfer:dY,toXYZ:dX,fromXYZ:fX,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:lY},outputColorSpaceConfig:{drawingBufferColorSpace:lY}},[lY]:{primaries:t,whitePoint:r,transfer:fY,toXYZ:dX,fromXYZ:fX,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:lY}}}),e}const mX=pX();function hX(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function gX(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let _X;var vX=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{_X===void 0&&(_X=cX(`canvas`)),_X.width=e.width,_X.height=e.height;let t=_X.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=_X}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=cX(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=hX(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(hX(t[e]/255)*255):t[e]=hX(t[e]);return{data:t,width:e.width,height:e.height}}else return console.warn(`THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}};let yX=0;var bX=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:yX++}),this.uuid=MY(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(xX(r[t].image)):e.push(xX(r[t]))}else e=xX(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function xX(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?vX.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}let SX=0;const CX=new V;var wX=class e extends DY{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=zJ,i=zJ,a=HJ,o=UJ,s=XJ,c=GJ,l=e.DEFAULT_ANISOTROPY,u=cY){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:SX++}),this.uuid=MY(),this.name=``,this.source=new bX(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new tX(0,0),this.repeat=new tX(1,1),this.center=new tX(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new aX,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(CX).x}get height(){return this.source.getSize(CX).y}get depth(){return this.source.getSize(CX).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==PJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case RJ:e.x-=Math.floor(e.x);break;case zJ:e.x=e.x<0?0:1;break;case BJ:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case RJ:e.y-=Math.floor(e.y);break;case zJ:e.y=e.y<0?0:1;break;case BJ:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};wX.DEFAULT_IMAGE=null,wX.DEFAULT_MAPPING=PJ,wX.DEFAULT_ANISOTROPY=1;var TX=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=NY(this.x,e.x,t.x),this.y=NY(this.y,e.y,t.y),this.z=NY(this.z,e.z,t.z),this.w=NY(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=NY(this.x,e,t),this.y=NY(this.y,e,t),this.z=NY(this.z,e,t),this.w=NY(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(NY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},EX=class extends DY{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:HJ,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new TX(0,0,e,t),this.scissorTest=!1,this.viewport=new TX(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new wX(r);this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:HJ,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){let n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new bX(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},DX=class extends wX{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=VJ,this.minFilter=VJ,this.wrapR=zJ,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},OX=class{constructor(e=new V(1/0,1/0,1/0),t=new V(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(AX.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(AX.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=AX.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,AX):AX.fromBufferAttribute(r,t),AX.applyMatrix4(e.matrixWorld),this.expandByPoint(AX);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),jX.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),jX.copy(e.boundingBox)),jX.applyMatrix4(e.matrixWorld),this.union(jX)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,AX),AX.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(RX),zX.subVectors(this.max,RX),MX.subVectors(e.a,RX),NX.subVectors(e.b,RX),PX.subVectors(e.c,RX),FX.subVectors(NX,MX),IX.subVectors(PX,NX),LX.subVectors(MX,PX);let t=[0,-FX.z,FX.y,0,-IX.z,IX.y,0,-LX.z,LX.y,FX.z,0,-FX.x,IX.z,0,-IX.x,LX.z,0,-LX.x,-FX.y,FX.x,0,-IX.y,IX.x,0,-LX.y,LX.x,0];return!HX(t,MX,NX,PX,zX)||(t=[1,0,0,0,1,0,0,0,1],!HX(t,MX,NX,PX,zX))?!1:(BX.crossVectors(FX,IX),t=[BX.x,BX.y,BX.z],HX(t,MX,NX,PX,zX))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,AX).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(AX).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(kX[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),kX[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),kX[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),kX[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),kX[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),kX[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),kX[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),kX[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(kX),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const kX=[new V,new V,new V,new V,new V,new V,new V,new V],AX=new V,jX=new OX,MX=new V,NX=new V,PX=new V,FX=new V,IX=new V,LX=new V,RX=new V,zX=new V,BX=new V,VX=new V;function HX(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){VX.fromArray(e,a);let o=i.x*Math.abs(VX.x)+i.y*Math.abs(VX.y)+i.z*Math.abs(VX.z),s=t.dot(VX),c=n.dot(VX),l=r.dot(VX);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const UX=new OX,WX=new V,GX=new V;var KX=class{constructor(e=new V,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?UX.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;WX.subVectors(e,this.center);let t=WX.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(WX,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(GX.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(WX.copy(e.center).add(GX)),this.expandByPoint(WX.copy(e.center).sub(GX))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const qX=new V,JX=new V,YX=new V,XX=new V,ZX=new V,QX=new V,$X=new V;var eZ=class{constructor(e=new V,t=new V(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,qX)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=qX.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(qX.copy(this.origin).addScaledVector(this.direction,t),qX.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){JX.copy(e).add(t).multiplyScalar(.5),YX.copy(t).sub(e).normalize(),XX.copy(this.origin).sub(JX);let i=e.distanceTo(t)*.5,a=-this.direction.dot(YX),o=XX.dot(this.direction),s=-XX.dot(YX),c=XX.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(JX).addScaledVector(YX,d),f}intersectSphere(e,t){qX.subVectors(e.center,this.origin);let n=qX.dot(this.direction),r=qX.dot(qX)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;let n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,qX)!==null}intersectTriangle(e,t,n,r,i){ZX.subVectors(t,e),QX.subVectors(n,e),$X.crossVectors(ZX,QX);let a=this.direction.dot($X),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;XX.subVectors(this.origin,e);let s=o*this.direction.dot(QX.crossVectors(XX,QX));if(s<0)return null;let c=o*this.direction.dot(ZX.cross(XX));if(c<0||s+c>a)return null;let l=-o*XX.dot($X);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},tZ=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/nZ.setFromMatrixColumn(e,0).length(),i=1/nZ.setFromMatrixColumn(e,1).length(),a=1/nZ.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(iZ,e,aZ)}lookAt(e,t,n){let r=this.elements;return cZ.subVectors(e,t),cZ.lengthSq()===0&&(cZ.z=1),cZ.normalize(),oZ.crossVectors(n,cZ),oZ.lengthSq()===0&&(Math.abs(n.z)===1?cZ.x+=1e-4:cZ.z+=1e-4,cZ.normalize(),oZ.crossVectors(n,cZ)),oZ.normalize(),sZ.crossVectors(cZ,oZ),r[0]=oZ.x,r[4]=sZ.x,r[8]=cZ.x,r[1]=oZ.y,r[5]=sZ.y,r[9]=cZ.y,r[2]=oZ.z,r[6]=sZ.z,r[10]=cZ.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=nZ.set(r[0],r[1],r[2]).length(),a=nZ.set(r[4],r[5],r[6]).length(),o=nZ.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],rZ.copy(this);let c=1/i,l=1/a,u=1/o;return rZ.elements[0]*=c,rZ.elements[1]*=c,rZ.elements[2]*=c,rZ.elements[4]*=l,rZ.elements[5]*=l,rZ.elements[6]*=l,rZ.elements[8]*=u,rZ.elements[9]*=u,rZ.elements[10]*=u,t.setFromRotationMatrix(rZ),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=TY){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===TY)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===EY)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=TY){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===TY)p=(a+i)*u,m=-2*u;else if(o===EY)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const nZ=new V,rZ=new tZ,iZ=new V(0,0,0),aZ=new V(1,1,1),oZ=new V,sZ=new V,cZ=new V,lZ=new tZ,uZ=new nX;var dZ=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(NY(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-NY(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(NY(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-NY(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(NY(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-NY(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return lZ.makeRotationFromQuaternion(e),this.setFromRotationMatrix(lZ,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return uZ.setFromEuler(this),this.setFromQuaternion(uZ,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};dZ.DEFAULT_ORDER=`XYZ`;var fZ=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}};let pZ=0;const mZ=new V,hZ=new nX,gZ=new tZ,_Z=new V,vZ=new V,yZ=new V,bZ=new nX,xZ=new V(1,0,0),SZ=new V(0,1,0),CZ=new V(0,0,1),wZ={type:`added`},TZ={type:`removed`},EZ={type:`childadded`,child:null},DZ={type:`childremoved`,child:null};var OZ=class e extends DY{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:pZ++}),this.uuid=MY(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new V,n=new dZ,r=new nX,i=new V(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new tZ},normalMatrix:{value:new aX}}),this.matrix=new tZ,this.matrixWorld=new tZ,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new fZ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return hZ.setFromAxisAngle(e,t),this.quaternion.multiply(hZ),this}rotateOnWorldAxis(e,t){return hZ.setFromAxisAngle(e,t),this.quaternion.premultiply(hZ),this}rotateX(e){return this.rotateOnAxis(xZ,e)}rotateY(e){return this.rotateOnAxis(SZ,e)}rotateZ(e){return this.rotateOnAxis(CZ,e)}translateOnAxis(e,t){return mZ.copy(e).applyQuaternion(this.quaternion),this.position.add(mZ.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(xZ,e)}translateY(e){return this.translateOnAxis(SZ,e)}translateZ(e){return this.translateOnAxis(CZ,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(gZ.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?_Z.copy(e):_Z.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),vZ.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?gZ.lookAt(vZ,_Z,this.up):gZ.lookAt(_Z,vZ,this.up),this.quaternion.setFromRotationMatrix(gZ),r&&(gZ.extractRotation(r.matrixWorld),hZ.setFromRotationMatrix(gZ),this.quaternion.premultiply(hZ.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error(`THREE.Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(wZ),EZ.child=e,this.dispatchEvent(EZ),EZ.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(TZ),DZ.child=e,this.dispatchEvent(DZ),DZ.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),gZ.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),gZ.multiply(e.parent.matrixWorld)),e.applyMatrix4(gZ),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(wZ),EZ.child=e,this.dispatchEvent(EZ),EZ.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n],i=r.getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vZ,e,yZ),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vZ,bZ,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};OZ.DEFAULT_UP=new V(0,1,0),OZ.DEFAULT_MATRIX_AUTO_UPDATE=!0,OZ.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const kZ=new V,AZ=new V,jZ=new V,MZ=new V,NZ=new V,PZ=new V,FZ=new V,IZ=new V,LZ=new V,RZ=new V,zZ=new TX,BZ=new TX,VZ=new TX;var HZ=class e{constructor(e=new V,t=new V,n=new V){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),kZ.subVectors(e,t),r.cross(kZ);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){kZ.subVectors(r,t),AZ.subVectors(n,t),jZ.subVectors(e,t);let a=kZ.dot(kZ),o=kZ.dot(AZ),s=kZ.dot(jZ),c=AZ.dot(AZ),l=AZ.dot(jZ),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,MZ)===null?!1:MZ.x>=0&&MZ.y>=0&&MZ.x+MZ.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,MZ)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,MZ.x),s.addScaledVector(a,MZ.y),s.addScaledVector(o,MZ.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return zZ.setScalar(0),BZ.setScalar(0),VZ.setScalar(0),zZ.fromBufferAttribute(e,t),BZ.fromBufferAttribute(e,n),VZ.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(zZ,i.x),a.addScaledVector(BZ,i.y),a.addScaledVector(VZ,i.z),a}static isFrontFacing(e,t,n,r){return kZ.subVectors(n,t),AZ.subVectors(e,t),kZ.cross(AZ).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return kZ.subVectors(this.c,this.b),AZ.subVectors(this.a,this.b),kZ.cross(AZ).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;NZ.subVectors(r,n),PZ.subVectors(i,n),IZ.subVectors(e,n);let s=NZ.dot(IZ),c=PZ.dot(IZ);if(s<=0&&c<=0)return t.copy(n);LZ.subVectors(e,r);let l=NZ.dot(LZ),u=PZ.dot(LZ);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(NZ,a);RZ.subVectors(e,i);let f=NZ.dot(RZ),p=PZ.dot(RZ);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(PZ,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return FZ.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(FZ,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(NZ,a).addScaledVector(PZ,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const UZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},WZ={h:0,s:0,l:0},GZ={h:0,s:0,l:0};function KZ(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var qZ=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=lY){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,mX.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=mX.workingColorSpace){return this.r=e,this.g=t,this.b=n,mX.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=mX.workingColorSpace){if(e=PY(e,1),t=NY(t,0,1),n=NY(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=KZ(i,r,e+1/3),this.g=KZ(i,r,e),this.b=KZ(i,r,e-1/3)}return mX.colorSpaceToWorking(this,r),this}setStyle(e,t=lY){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=lY){let n=UZ[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=hX(e.r),this.g=hX(e.g),this.b=hX(e.b),this}copyLinearToSRGB(e){return this.r=gX(e.r),this.g=gX(e.g),this.b=gX(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=lY){return mX.workingToColorSpace(JZ.copy(this),e),Math.round(NY(JZ.r*255,0,255))*65536+Math.round(NY(JZ.g*255,0,255))*256+Math.round(NY(JZ.b*255,0,255))}getHexString(e=lY){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=mX.workingColorSpace){mX.workingToColorSpace(JZ.copy(this),t);let n=JZ.r,r=JZ.g,i=JZ.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=mX.workingColorSpace){return mX.workingToColorSpace(JZ.copy(this),t),e.r=JZ.r,e.g=JZ.g,e.b=JZ.b,e}getStyle(e=lY){mX.workingToColorSpace(JZ.copy(this),e);let t=JZ.r,n=JZ.g,r=JZ.b;return e===lY?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(WZ),this.setHSL(WZ.h+e,WZ.s+t,WZ.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(WZ),e.getHSL(GZ);let n=LY(WZ.h,GZ.h,t),r=LY(WZ.s,GZ.s,t),i=LY(WZ.l,GZ.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const JZ=new qZ;qZ.NAMES=UZ;let YZ=0;var XZ=class extends DY{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:YZ++}),this.uuid=MY(),this.name=``,this.type=`Material`,this.blending=DJ,this.side=wJ,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=kJ,this.blendDst=AJ,this.blendEquation=OJ,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new qZ(0,0,0),this.blendAlpha=0,this.depthFunc=jJ,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=mY,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pY,this.stencilZFail=pY,this.stencilZPass=pY,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==DJ&&(n.blending=this.blending),this.side!==wJ&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==kJ&&(n.blendSrc=this.blendSrc),this.blendDst!==AJ&&(n.blendDst=this.blendDst),this.blendEquation!==OJ&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==jJ&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==mY&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==pY&&(n.stencilFail=this.stencilFail),this.stencilZFail!==pY&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==pY&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},ZZ=class extends XZ{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new qZ(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new dZ,this.combine=MJ,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const QZ=new V,$Z=new tX;let eQ=0;var tQ=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:eQ++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=CY,this.updateRanges=[],this.gpuType=JJ,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)$Z.fromBufferAttribute(this,t),$Z.applyMatrix3(e),this.setXY(t,$Z.x,$Z.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.applyMatrix3(e),this.setXYZ(t,QZ.x,QZ.y,QZ.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.applyMatrix4(e),this.setXYZ(t,QZ.x,QZ.y,QZ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.applyNormalMatrix(e),this.setXYZ(t,QZ.x,QZ.y,QZ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.transformDirection(e),this.setXYZ(t,QZ.x,QZ.y,QZ.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=QY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=$Y(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=QY(t,this.array)),t}setX(e,t){return this.normalized&&(t=$Y(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=QY(t,this.array)),t}setY(e,t){return this.normalized&&(t=$Y(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=QY(t,this.array)),t}setZ(e,t){return this.normalized&&(t=$Y(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=QY(t,this.array)),t}setW(e,t){return this.normalized&&(t=$Y(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array),r=$Y(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array),r=$Y(r,this.array),i=$Y(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==CY&&(e.usage=this.usage),e}},nQ=class extends tQ{constructor(e,t,n){super(new Uint16Array(e),t,n)}},rQ=class extends tQ{constructor(e,t,n){super(new Uint32Array(e),t,n)}},iQ=class extends tQ{constructor(e,t,n){super(new Float32Array(e),t,n)}};let aQ=0;const oQ=new tZ,sQ=new OZ,cQ=new V,lQ=new OX,uQ=new OX,dQ=new V;var fQ=class e extends DY{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:aQ++}),this.uuid=MY(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(sX(e)?rQ:nQ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new aX().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return oQ.makeRotationFromQuaternion(e),this.applyMatrix4(oQ),this}rotateX(e){return oQ.makeRotationX(e),this.applyMatrix4(oQ),this}rotateY(e){return oQ.makeRotationY(e),this.applyMatrix4(oQ),this}rotateZ(e){return oQ.makeRotationZ(e),this.applyMatrix4(oQ),this}translate(e,t,n){return oQ.makeTranslation(e,t,n),this.applyMatrix4(oQ),this}scale(e,t,n){return oQ.makeScale(e,t,n),this.applyMatrix4(oQ),this}lookAt(e){return sQ.lookAt(e),sQ.updateMatrix(),this.applyMatrix4(sQ.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(cQ).negate(),this.translate(cQ.x,cQ.y,cQ.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new iQ(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&console.warn(`THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new OX);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];lQ.setFromBufferAttribute(n),this.morphTargetsRelative?(dQ.addVectors(this.boundingBox.min,lQ.min),this.boundingBox.expandByPoint(dQ),dQ.addVectors(this.boundingBox.max,lQ.max),this.boundingBox.expandByPoint(dQ)):(this.boundingBox.expandByPoint(lQ.min),this.boundingBox.expandByPoint(lQ.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error(`THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new KX);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new V,1/0);return}if(e){let n=this.boundingSphere.center;if(lQ.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];uQ.setFromBufferAttribute(n),this.morphTargetsRelative?(dQ.addVectors(lQ.min,uQ.min),lQ.expandByPoint(dQ),dQ.addVectors(lQ.max,uQ.max),lQ.expandByPoint(dQ)):(lQ.expandByPoint(uQ.min),lQ.expandByPoint(uQ.max))}lQ.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)dQ.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(dQ));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)dQ.fromBufferAttribute(a,t),o&&(cQ.fromBufferAttribute(e,t),dQ.add(cQ)),r=Math.max(r,n.distanceToSquared(dQ))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error(`THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new tQ(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new V,s[e]=new V;let c=new V,l=new V,u=new V,d=new tX,f=new tX,p=new tX,m=new V,h=new V;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new V,y=new V,b=new V,x=new V;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e]),i=n<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,i)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new tQ(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new V,i=new V,a=new V,o=new V,s=new V,c=new V,l=new V,u=new V;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)dQ.fromBufferAttribute(e,t),dQ.normalize(),e.setXYZ(t,dQ.x,dQ.y,dQ.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new tQ(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}};const pQ=new tZ,mQ=new eZ,hQ=new KX,gQ=new V,_Q=new V,vQ=new V,yQ=new V,bQ=new V,xQ=new V,SQ=new V,CQ=new V;var wQ=class extends OZ{constructor(e=new fQ,t=new ZZ){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry,t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){xQ.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(bQ.fromBufferAttribute(s,e),a?xQ.addScaledVector(bQ,r):xQ.addScaledVector(bQ.sub(t),r))}t.add(xQ)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),hQ.copy(n.boundingSphere),hQ.applyMatrix4(i),mQ.copy(e.ray).recast(e.near),!(hQ.containsPoint(mQ.origin)===!1&&(mQ.intersectSphere(hQ,gQ)===null||mQ.origin.distanceToSquared(gQ)>(e.far-e.near)**2))&&(pQ.copy(i).invert(),mQ.copy(e.ray).applyMatrix4(pQ),!(n.boundingBox!==null&&mQ.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,mQ)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=EQ(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=EQ(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=EQ(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=EQ(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function TQ(e,t,n,r,i,a,o,s){let c;if(c=t.side===TJ?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===wJ,s),c===null)return null;CQ.copy(s),CQ.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(CQ);return l<n.near||l>n.far?null:{distance:l,point:CQ.clone(),object:e}}function EQ(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,_Q),e.getVertexPosition(c,vQ),e.getVertexPosition(l,yQ);let u=TQ(e,t,n,r,_Q,vQ,yQ,SQ);if(u){let e=new V;HZ.getBarycoord(SQ,_Q,vQ,yQ,e),i&&(u.uv=HZ.getInterpolatedAttribute(i,s,c,l,e,new tX)),a&&(u.uv1=HZ.getInterpolatedAttribute(a,s,c,l,e,new tX)),o&&(u.normal=HZ.getInterpolatedAttribute(o,s,c,l,e,new V),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new V,materialIndex:0};HZ.getNormal(_Q,vQ,yQ,t.normal),u.face=t,u.barycoord=e}return u}var DQ=class e extends fQ{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new iQ(c,3)),this.setAttribute(`normal`,new iQ(l,3)),this.setAttribute(`uv`,new iQ(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,ee=h+1,te=g+1,ne=0,re=0,ie=new V;for(let a=0;a<te;a++){let o=a*y-x;for(let s=0;s<ee;s++){let d=s*v-b;ie[e]=d*r,ie[t]=o*i,ie[n]=S,c.push(ie.x,ie.y,ie.z),ie[e]=0,ie[t]=0,ie[n]=m>0?1:-1,l.push(ie.x,ie.y,ie.z),u.push(s/h),u.push(1-a/g),ne+=1}}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+ee*e,r=d+t+ee*(e+1),i=d+(t+1)+ee*(e+1),a=d+(t+1)+ee*e;s.push(n,r,a),s.push(r,i,a),re+=6}o.addGroup(f,re,_),f+=re,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},OQ=class extends OZ{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new tZ,this.projectionMatrix=new tZ,this.projectionMatrixInverse=new tZ,this.coordinateSystem=TY}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const kQ=new V,AQ=new tX,jQ=new tX;var MQ=class extends OQ{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=jY*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(AY*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return jY*2*Math.atan(Math.tan(AY*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){kQ.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(kQ.x,kQ.y).multiplyScalar(-e/kQ.z),kQ.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(kQ.x,kQ.y).multiplyScalar(-e/kQ.z)}getViewSize(e,t){return this.getViewBounds(e,AQ,jQ),t.subVectors(jQ,AQ)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(AY*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},NQ=class extends wX{constructor(e=[],t=FJ,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},PQ=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=CY,this.updateRanges=[],this.version=0,this.uuid=MY()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=MY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=MY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const FQ=new V;var IQ=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)FQ.fromBufferAttribute(this,t),FQ.applyMatrix4(e),this.setXYZ(t,FQ.x,FQ.y,FQ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)FQ.fromBufferAttribute(this,t),FQ.applyNormalMatrix(e),this.setXYZ(t,FQ.x,FQ.y,FQ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)FQ.fromBufferAttribute(this,t),FQ.transformDirection(e),this.setXYZ(t,FQ.x,FQ.y,FQ.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=QY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=$Y(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=$Y(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=$Y(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=$Y(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=$Y(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=QY(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=QY(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=QY(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=QY(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array),r=$Y(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=$Y(t,this.array),n=$Y(n,this.array),r=$Y(r,this.array),i=$Y(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new tQ(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},LQ=class extends tQ{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};const RQ=new V,zQ=new V,BQ=new aX;var VQ=class{constructor(e=new V(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=RQ.subVectors(n,t).cross(zQ.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(RQ),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||BQ.getNormalMatrix(e),r=this.coplanarPoint(RQ).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},HQ=class extends wX{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=VJ,this.minFilter=VJ,this.generateMipmaps=!1,this.needsUpdate=!0}},UQ=class extends wX{constructor(e,t,n=qJ,r,i,a,o=VJ,s=VJ,c,l=ZJ,u=1){if(l!==ZJ&&l!==QJ)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);let d={width:e,height:t,depth:u};super(d,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new bX(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};function WQ(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function GQ(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var KQ=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},qQ=class extends KQ{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:rY,endingEnd:rY}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case iY:i=e,o=2*t-n;break;case aY:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case iY:a=e,s=2*n-t;break;case aY:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},JQ=class extends KQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},YQ=class extends KQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},XQ=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=WQ(t,this.TimeBufferType),this.values=WQ(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:WQ(e.times,Array),values:WQ(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new YQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new JQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new qQ(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case eY:t=this.InterpolantFactoryMethodDiscrete;break;case tY:t=this.InterpolantFactoryMethodLinear;break;case nY:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return eY;case this.InterpolantFactoryMethodLinear:return tY;case this.InterpolantFactoryMethodSmooth:return nY}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&GQ(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===nY,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o],c=e[o+1];if(s!==c&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};XQ.prototype.ValueTypeName=``,XQ.prototype.TimeBufferType=Float32Array,XQ.prototype.ValueBufferType=Float32Array,XQ.prototype.DefaultInterpolation=tY;var ZQ=class extends XQ{constructor(e,t,n){super(e,t,n)}};ZQ.prototype.ValueTypeName=`bool`,ZQ.prototype.ValueBufferType=Array,ZQ.prototype.DefaultInterpolation=eY,ZQ.prototype.InterpolantFactoryMethodLinear=void 0,ZQ.prototype.InterpolantFactoryMethodSmooth=void 0;var QQ=class extends XQ{constructor(e,t,n,r){super(e,t,n,r)}};QQ.prototype.ValueTypeName=`color`;var $Q=class extends XQ{constructor(e,t,n,r){super(e,t,n,r)}};$Q.prototype.ValueTypeName=`number`;var e$=class extends KQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)nX.slerpFlat(i,0,a,c-o,a,c,s);return i}},t$=class extends XQ{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new e$(this.times,this.values,this.getValueSize(),e)}};t$.prototype.ValueTypeName=`quaternion`,t$.prototype.InterpolantFactoryMethodSmooth=void 0;var n$=class extends XQ{constructor(e,t,n){super(e,t,n)}};n$.prototype.ValueTypeName=`string`,n$.prototype.ValueBufferType=Array,n$.prototype.DefaultInterpolation=eY,n$.prototype.InterpolantFactoryMethodLinear=void 0,n$.prototype.InterpolantFactoryMethodSmooth=void 0;var r$=class extends XQ{constructor(e,t,n,r){super(e,t,n,r)}};r$.prototype.ValueTypeName=`vector`;var i$=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}};const a$=new i$;var o$=class{constructor(e){this.manager=e===void 0?a$:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};o$.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var s$=class extends OQ{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};const c$=`\\[\\]\\.:\\/`,l$=RegExp(`[`+c$+`]`,`g`),u$=`[^`+c$+`]`,d$=`[^`+c$.replace(`\\.`,``)+`]`,f$=/((?:WC+[\/:])*)/.source.replace(`WC`,u$),p$=/(WCOD+)?/.source.replace(`WCOD`,d$),m$=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,u$),h$=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,u$),g$=RegExp(`^`+f$+p$+m$+h$+`$`),_$=[`material`,`materials`,`bones`,`map`];var v$=class{constructor(e,t,n){let r=n||y$.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},y$=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(l$,``)}static parseTrackName(e){let t=g$.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);_$.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};y$.Composite=v$,y$.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},y$.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},y$.prototype.GetterByBindingType=[y$.prototype._getValue_direct,y$.prototype._getValue_array,y$.prototype._getValue_arrayElement,y$.prototype._getValue_toArray],y$.prototype.SetterByBindingTypeAndVersioning=[[y$.prototype._setValue_direct,y$.prototype._setValue_direct_setNeedsUpdate,y$.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[y$.prototype._setValue_array,y$.prototype._setValue_array_setNeedsUpdate,y$.prototype._setValue_array_setMatrixWorldNeedsUpdate],[y$.prototype._setValue_arrayElement,y$.prototype._setValue_arrayElement_setNeedsUpdate,y$.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[y$.prototype._setValue_fromArray,y$.prototype._setValue_fromArray_setNeedsUpdate,y$.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const foe=new Float32Array(1);var b$=class extends PQ{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},x$=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:xJ}})),typeof window<`u`&&(window.__THREE__?console.warn(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=xJ);const S$=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`);var C$=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=S$,this.renderId=0}firstInitialization(e){let t=this.renderObjects.has(e);return t===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];if(r==null)continue;typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r}return t}equals(e){let{object:t,material:n,geometry:r}=e,i=this.getRenderObjectData(e);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;let a=i.material;for(let e in a){let t=a[e],r=n[e];if(t.equals!==void 0){if(t.equals(r)===!1)return t.copy(r),!1}else if(r.isTexture===!0){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){let{width:t,height:n}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==n)return i.bufferWidth=t,i.bufferHeight=n,!1}let o=i.geometry,s=r.attributes,c=o.attributes,l=Object.keys(c),u=Object.keys(s);if(o.id!==r.id)return o.id=r.id,!1;if(l.length!==u.length)return i.geometry.attributes=this.getAttributesData(s),!1;for(let e of l){let t=c[e],n=s[e];if(n===void 0)return delete c[e],!1;if(t.version!==n.version)return t.version=n.version,!1}let d=r.index,f=o.indexVersion,p=d?d.version:null;if(f!==p)return o.indexVersion=p,!1;if(o.drawRange.start!==r.drawRange.start||o.drawRange.count!==r.drawRange.count)return o.drawRange.start=r.drawRange.start,o.drawRange.count=r.drawRange.count,!1;if(i.morphTargetInfluences){let e=!1;for(let n=0;n<i.morphTargetInfluences.length;n++)i.morphTargetInfluences[n]!==t.morphTargetInfluences[n]&&(e=!0);if(e)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(e.bundle!==null&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.equals(e)!==!0;return a}};function w$(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const T$=e=>w$(e),E$=e=>w$(e),D$=(...e)=>w$(e);function O$(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of k$(e))n.push(w$(r.slice(0,-4)),i.getCacheKey(t));return w$(n)}function*k$(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}const A$=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),j$=new WeakMap;function M$(e){return A$.get(e)}function N$(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function P$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function F$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function I$(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e))return 48;if(/mat4/.test(e))return 64;console.error(`THREE.TSL: Unsupported type:`,e)}function L$(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function R$(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new qZ(...t):n===`vec2`?new tX(...t):n===`vec3`?new V(...t):n===`vec4`?new TX(...t):n===`mat2`?new x$(...t):n===`mat3`?new aX(...t):n===`mat4`?new tZ(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?V$(t[0]):null}function z$(e){let t=j$.get(e);return t===void 0&&(t={},j$.set(e,t)),t}function B$(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function V$(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}const H$={VERTEX:`vertex`,FRAGMENT:`fragment`},U$={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},W$={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},G$={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},K$=[`fragment`,`vertex`],q$=[`setup`,`analyze`,`generate`],J$=[...K$,`compute`],Y$=[`x`,`y`,`z`,`w`],X$={analyze:`setup`,generate:`analyze`};let Z$=0;var Q$=class extends DY{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=U$.NONE,this.updateBeforeType=U$.NONE,this.updateAfterType=U$.NONE,this.uuid=eX.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:Z$++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,U$.FRAME)}onRenderUpdate(e){return this.onUpdate(e,U$.RENDER)}onObjectUpdate(e){return this.onUpdate(e,U$.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of k$(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=D$(O$(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=X$[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return k$(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},$$=class extends Q${static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},e1=class extends Q${static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},t1=class extends Q${static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},n1=class extends t1{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}};const r1=Y$.join(``);var i1=class extends Q${static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(Y$.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===r1.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},a1=class extends t1{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=Y$[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},o1=class extends t1{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=Y$[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},s1=class extends Q${static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?L$(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=L$(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=B$(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?R$(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}};const c1=/float|u?int/;var l1=class extends s1{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return c1.test(n)&&c1.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},u1=class extends Q${static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}};let d1=null;const f1=new Map;function H(e,t){if(f1.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);f1.set(e,t)}const p1=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),m1=e=>p1(e).split(``).sort().join(``),h1={setup(e,t){let n=t.shift();return e(V1(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(d1.assign(n,...e),n);if(f1.has(t)){let r=f1.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&f1.has(t.slice(0,t.length-6))){let r=f1.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=p1(t),U(new i1(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=m1(t.slice(3).toLowerCase()),n=>U(new a1(e,t,U(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=m1(t.slice(4).toLowerCase()),()=>U(new o1(U(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),U(new i1(e,t));else if(/^\d+$/.test(t)===!0)return U(new $$(n,new l1(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>U(new u1(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},g1=new WeakMap,_1=new WeakMap,v1=function(e,t=null){let n=L$(e);if(n===`node`){let t=g1.get(e);return t===void 0&&(t=new Proxy(e,h1),g1.set(e,t),g1.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return U(F1(e,t));else if(n===`shader`)return K(e);return e},y1=function(e,t=null){for(let n in e)e[n]=U(e[n],t);return e},b1=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=U(e[r],t);return e},x1=function(e,t=null,n=null,r=null){let i=e=>U(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...H1(l(t)))):n===null?a=(...n)=>i(new e(t,...H1(l(n)))):(n=U(n),a=(...r)=>i(new e(t,...H1(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},S1=function(e,...t){return U(new e(...H1(t)))};var C1=class extends Q${constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=_1.get(e.constructor);r===void 0&&(r=new WeakMap,_1.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=U(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=U(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=U(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},w1=class extends Q${constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return V1(e),U(new C1(this,e))}setup(){return this.call()}};const T1=[!1,!0],E1=[0,1,2,3],D1=[-1,-2],O1=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],k1=new Map;for(let e of T1)k1.set(e,new l1(e));const A1=new Map;for(let e of E1)A1.set(e,new l1(e,`uint`));const j1=new Map([...A1].map(e=>new l1(e.value,`int`)));for(let e of D1)j1.set(e,new l1(e,`int`));const M1=new Map([...j1].map(e=>new l1(e.value)));for(let e of O1)M1.set(e,new l1(e));for(let e of O1)M1.set(-e,new l1(-e));const N1={bool:k1,uint:A1,ints:j1,float:M1},P1=new Map([...k1,...M1]),F1=(e,t)=>P1.has(e)?P1.get(e):e.isNode===!0?e:new l1(e,t),I1=e=>{try{return e.getNodeType()}catch{return}},L1=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[R$(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return U(t.get(n[0]));if(n.length===1){let t=F1(n[0],e);return I1(t)===e?U(t):U(new e1(t,e))}let r=n.map(e=>F1(e));return U(new n1(r,e))}},R1=e=>typeof e==`object`&&e?e.value:e,z1=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function B1(e,t){return new Proxy(new w1(e,t),h1)}const U=(e,t=null)=>v1(e,t),V1=(e,t=null)=>new y1(e,t),H1=(e,t=null)=>new b1(e,t),W=(...e)=>new x1(...e),G=(...e)=>new S1(...e);let U1=0;const K=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new B1(e,n),i=(...e)=>{let t;V1(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ U1++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i},W1=e=>{d1=e},G1=()=>d1,K1=(...e)=>d1.If(...e),q1=(...e)=>d1.Switch(...e);function J1(e){return d1&&d1.add(e),e}H(`toStack`,J1);const Y1=new L1(`color`),q=new L1(`float`,N1.float),J=new L1(`int`,N1.ints),X1=new L1(`uint`,N1.uint),Z1=new L1(`bool`,N1.bool),Y=new L1(`vec2`),Q1=new L1(`ivec2`),$1=new L1(`uvec2`),e0=new L1(`bvec2`),X=new L1(`vec3`),t0=new L1(`ivec3`),n0=new L1(`uvec3`),r0=new L1(`bvec3`),i0=new L1(`vec4`),a0=new L1(`ivec4`),o0=new L1(`uvec4`),s0=new L1(`bvec4`),c0=new L1(`mat2`),l0=new L1(`mat3`),u0=new L1(`mat4`),d0=(e=``)=>U(new l1(e,`string`)),f0=e=>U(new l1(e,`ArrayBuffer`));H(`toColor`,Y1),H(`toFloat`,q),H(`toInt`,J),H(`toUint`,X1),H(`toBool`,Z1),H(`toVec2`,Y),H(`toIVec2`,Q1),H(`toUVec2`,$1),H(`toBVec2`,e0),H(`toVec3`,X),H(`toIVec3`,t0),H(`toUVec3`,n0),H(`toBVec3`,r0),H(`toVec4`,i0),H(`toIVec4`,a0),H(`toUVec4`,o0),H(`toBVec4`,s0),H(`toMat2`,c0),H(`toMat3`,l0),H(`toMat4`,u0);const p0=W($$).setParameterLength(2),m0=(e,t)=>U(new e1(U(e),t)),h0=(e,t)=>U(new i1(U(e),t));H(`element`,p0),H(`convert`,m0);const g0=e=>(console.warn(`THREE.TSL: append() has been renamed to Stack().`),J1(e));H(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),J1(e)));const _0=(...e)=>(console.warn(`THREE.TSL: tslFn() has been renamed to Fn().`),K(...e));var v0=class extends Q${static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const y0=(e,t)=>U(new v0(e,t)),b0=(e,t)=>U(new v0(e,t,!0)),x0=G(v0,`vec4`,`DiffuseColor`),S0=G(v0,`vec3`,`EmissiveColor`),C0=G(v0,`float`,`Roughness`),w0=G(v0,`float`,`Metalness`),T0=G(v0,`float`,`Clearcoat`),E0=G(v0,`float`,`ClearcoatRoughness`),D0=G(v0,`vec3`,`Sheen`),O0=G(v0,`float`,`SheenRoughness`),k0=G(v0,`float`,`Iridescence`),A0=G(v0,`float`,`IridescenceIOR`),j0=G(v0,`float`,`IridescenceThickness`),M0=G(v0,`float`,`AlphaT`),N0=G(v0,`float`,`Anisotropy`),P0=G(v0,`vec3`,`AnisotropyT`),F0=G(v0,`vec3`,`AnisotropyB`),I0=G(v0,`color`,`SpecularColor`),L0=G(v0,`float`,`SpecularF90`),R0=G(v0,`float`,`Shininess`),z0=G(v0,`vec4`,`Output`),B0=G(v0,`float`,`dashSize`),V0=G(v0,`float`,`gapSize`),H0=G(v0,`float`,`pointWidth`),U0=G(v0,`float`,`IOR`),W0=G(v0,`float`,`Transmission`),G0=G(v0,`float`,`Thickness`),K0=G(v0,`float`,`AttenuationDistance`),q0=G(v0,`color`,`AttenuationColor`),J0=G(v0,`float`,`Dispersion`);var Y0=class extends Q${static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const X0=e=>new Y0(e),Z0=(e,t=0)=>new Y0(e,!0,t),Q0=Z0(`frame`),$0=Z0(`render`),e2=X0(`object`);var t2=class extends s1{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=e2}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const n2=(e,t)=>{let n=z1(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return U(new t2(r,n))};var r2=class extends t1{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const i2=(...e)=>{let t;if(e.length===1){let n=e[0];t=new r2(null,n.length,n)}else{let n=e[0],r=e[1];t=new r2(n,r)}return U(t)};H(`toArray`,(e,t)=>i2(Array(t).fill(e)));var a2=class extends t1{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=Y$.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const o2=W(a2).setParameterLength(2);H(`assign`,o2);var s2=class extends t1{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(q(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(q(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const c2=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?H1(t):V1(t[0]),U(new s2(U(e),t)));H(`call`,c2);const l2={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var u2=class e extends t1{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(l2[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===TY;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const d2=W(u2,`+`).setParameterLength(2,1/0).setName(`add`),f2=W(u2,`-`).setParameterLength(2,1/0).setName(`sub`),p2=W(u2,`*`).setParameterLength(2,1/0).setName(`mul`),m2=W(u2,`/`).setParameterLength(2,1/0).setName(`div`),h2=W(u2,`%`).setParameterLength(2).setName(`mod`),g2=W(u2,`==`).setParameterLength(2).setName(`equal`),_2=W(u2,`!=`).setParameterLength(2).setName(`notEqual`),v2=W(u2,`<`).setParameterLength(2).setName(`lessThan`),y2=W(u2,`>`).setParameterLength(2).setName(`greaterThan`),b2=W(u2,`<=`).setParameterLength(2).setName(`lessThanEqual`),x2=W(u2,`>=`).setParameterLength(2).setName(`greaterThanEqual`),S2=W(u2,`&&`).setParameterLength(2,1/0).setName(`and`),C2=W(u2,`||`).setParameterLength(2,1/0).setName(`or`),w2=W(u2,`!`).setParameterLength(1).setName(`not`),T2=W(u2,`^^`).setParameterLength(2).setName(`xor`),E2=W(u2,`&`).setParameterLength(2).setName(`bitAnd`),D2=W(u2,`~`).setParameterLength(2).setName(`bitNot`),O2=W(u2,`|`).setParameterLength(2).setName(`bitOr`),k2=W(u2,`^`).setParameterLength(2).setName(`bitXor`),A2=W(u2,`<<`).setParameterLength(2).setName(`shiftLeft`),j2=W(u2,`>>`).setParameterLength(2).setName(`shiftRight`),M2=K(([e])=>(e.addAssign(1),e)),N2=K(([e])=>(e.subAssign(1),e)),P2=K(([e])=>{let t=J(e).toConst();return e.addAssign(1),t}),F2=K(([e])=>{let t=J(e).toConst();return e.subAssign(1),t});H(`add`,d2),H(`sub`,f2),H(`mul`,p2),H(`div`,m2),H(`mod`,h2),H(`equal`,g2),H(`notEqual`,_2),H(`lessThan`,v2),H(`greaterThan`,y2),H(`lessThanEqual`,b2),H(`greaterThanEqual`,x2),H(`and`,S2),H(`or`,C2),H(`not`,w2),H(`xor`,T2),H(`bitAnd`,E2),H(`bitNot`,D2),H(`bitOr`,O2),H(`bitXor`,k2),H(`shiftLeft`,A2),H(`shiftRight`,j2),H(`incrementBefore`,M2),H(`decrementBefore`,N2),H(`increment`,P2),H(`decrement`,F2);const I2=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),h2(e,t)),L2=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),h2(J(e),J(t)));H(`remainder`,I2),H(`modInt`,L2);var Z=class e extends t1{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=f2(1,n);else if(i===e.RECIPROCAL)a=m2(1,n);else if(i===e.DIFFERENCE)a=c4(f2(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=i0(X(i),0):e=i0(X(e),0);let o=p2(e,i).xyz;a=e4(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===TY&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===TY&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===EY&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Z.ALL=`all`,Z.ANY=`any`,Z.RADIANS=`radians`,Z.DEGREES=`degrees`,Z.EXP=`exp`,Z.EXP2=`exp2`,Z.LOG=`log`,Z.LOG2=`log2`,Z.SQRT=`sqrt`,Z.INVERSE_SQRT=`inversesqrt`,Z.FLOOR=`floor`,Z.CEIL=`ceil`,Z.NORMALIZE=`normalize`,Z.FRACT=`fract`,Z.SIN=`sin`,Z.COS=`cos`,Z.TAN=`tan`,Z.ASIN=`asin`,Z.ACOS=`acos`,Z.ATAN=`atan`,Z.ABS=`abs`,Z.SIGN=`sign`,Z.LENGTH=`length`,Z.NEGATE=`negate`,Z.ONE_MINUS=`oneMinus`,Z.DFDX=`dFdx`,Z.DFDY=`dFdy`,Z.ROUND=`round`,Z.RECIPROCAL=`reciprocal`,Z.TRUNC=`trunc`,Z.FWIDTH=`fwidth`,Z.TRANSPOSE=`transpose`,Z.BITCAST=`bitcast`,Z.EQUALS=`equals`,Z.MIN=`min`,Z.MAX=`max`,Z.STEP=`step`,Z.REFLECT=`reflect`,Z.DISTANCE=`distance`,Z.DIFFERENCE=`difference`,Z.DOT=`dot`,Z.CROSS=`cross`,Z.POW=`pow`,Z.TRANSFORM_DIRECTION=`transformDirection`,Z.MIX=`mix`,Z.CLAMP=`clamp`,Z.REFRACT=`refract`,Z.SMOOTHSTEP=`smoothstep`,Z.FACEFORWARD=`faceforward`;const R2=q(1e-6),z2=q(1e6),B2=q(Math.PI),V2=q(Math.PI*2),H2=W(Z,Z.ALL).setParameterLength(1),U2=W(Z,Z.ANY).setParameterLength(1),W2=W(Z,Z.RADIANS).setParameterLength(1),G2=W(Z,Z.DEGREES).setParameterLength(1),K2=W(Z,Z.EXP).setParameterLength(1),q2=W(Z,Z.EXP2).setParameterLength(1),J2=W(Z,Z.LOG).setParameterLength(1),Y2=W(Z,Z.LOG2).setParameterLength(1),X2=W(Z,Z.SQRT).setParameterLength(1),Z2=W(Z,Z.INVERSE_SQRT).setParameterLength(1),Q2=W(Z,Z.FLOOR).setParameterLength(1),$2=W(Z,Z.CEIL).setParameterLength(1),e4=W(Z,Z.NORMALIZE).setParameterLength(1),t4=W(Z,Z.FRACT).setParameterLength(1),n4=W(Z,Z.SIN).setParameterLength(1),r4=W(Z,Z.COS).setParameterLength(1),i4=W(Z,Z.TAN).setParameterLength(1),a4=W(Z,Z.ASIN).setParameterLength(1),o4=W(Z,Z.ACOS).setParameterLength(1),s4=W(Z,Z.ATAN).setParameterLength(1,2),c4=W(Z,Z.ABS).setParameterLength(1),l4=W(Z,Z.SIGN).setParameterLength(1),u4=W(Z,Z.LENGTH).setParameterLength(1),d4=W(Z,Z.NEGATE).setParameterLength(1),f4=W(Z,Z.ONE_MINUS).setParameterLength(1),p4=W(Z,Z.DFDX).setParameterLength(1),m4=W(Z,Z.DFDY).setParameterLength(1),h4=W(Z,Z.ROUND).setParameterLength(1),g4=W(Z,Z.RECIPROCAL).setParameterLength(1),_4=W(Z,Z.TRUNC).setParameterLength(1),v4=W(Z,Z.FWIDTH).setParameterLength(1),y4=W(Z,Z.TRANSPOSE).setParameterLength(1),b4=W(Z,Z.BITCAST).setParameterLength(2),x4=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),g2(e,t)),S4=W(Z,Z.MIN).setParameterLength(2,1/0),C4=W(Z,Z.MAX).setParameterLength(2,1/0),w4=W(Z,Z.STEP).setParameterLength(2),T4=W(Z,Z.REFLECT).setParameterLength(2),E4=W(Z,Z.DISTANCE).setParameterLength(2),D4=W(Z,Z.DIFFERENCE).setParameterLength(2),O4=W(Z,Z.DOT).setParameterLength(2),k4=W(Z,Z.CROSS).setParameterLength(2),A4=W(Z,Z.POW).setParameterLength(2),j4=W(Z,Z.POW,2).setParameterLength(1),M4=W(Z,Z.POW,3).setParameterLength(1),N4=W(Z,Z.POW,4).setParameterLength(1),P4=W(Z,Z.TRANSFORM_DIRECTION).setParameterLength(2),F4=e=>p2(l4(e),A4(c4(e),1/3)),I4=e=>O4(e,e),L4=W(Z,Z.MIX).setParameterLength(3),R4=(e,t=0,n=1)=>U(new Z(Z.CLAMP,U(e),U(t),U(n))),z4=e=>R4(e),B4=W(Z,Z.REFRACT).setParameterLength(3),V4=W(Z,Z.SMOOTHSTEP).setParameterLength(3),H4=W(Z,Z.FACEFORWARD).setParameterLength(3),U4=K(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=O4(e.xy,Y(t,n)),a=h2(i,B2);return t4(n4(a).mul(r))}),W4=(e,t,n)=>L4(t,n,e),G4=(e,t,n)=>V4(t,n,e),K4=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),s4(e,t)),q4=H4,J4=Z2;H(`all`,H2),H(`any`,U2),H(`equals`,x4),H(`radians`,W2),H(`degrees`,G2),H(`exp`,K2),H(`exp2`,q2),H(`log`,J2),H(`log2`,Y2),H(`sqrt`,X2),H(`inverseSqrt`,Z2),H(`floor`,Q2),H(`ceil`,$2),H(`normalize`,e4),H(`fract`,t4),H(`sin`,n4),H(`cos`,r4),H(`tan`,i4),H(`asin`,a4),H(`acos`,o4),H(`atan`,s4),H(`abs`,c4),H(`sign`,l4),H(`length`,u4),H(`lengthSq`,I4),H(`negate`,d4),H(`oneMinus`,f4),H(`dFdx`,p4),H(`dFdy`,m4),H(`round`,h4),H(`reciprocal`,g4),H(`trunc`,_4),H(`fwidth`,v4),H(`atan2`,K4),H(`min`,S4),H(`max`,C4),H(`step`,w4),H(`reflect`,T4),H(`distance`,E4),H(`dot`,O4),H(`cross`,k4),H(`pow`,A4),H(`pow2`,j4),H(`pow3`,M4),H(`pow4`,N4),H(`transformDirection`,P4),H(`mix`,W4),H(`clamp`,R4),H(`refract`,B4),H(`smoothstep`,G4),H(`faceForward`,H4),H(`difference`,D4),H(`saturate`,z4),H(`cbrt`,F4),H(`transpose`,y4),H(`rand`,U4);var Y4=class extends Q${static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?y0(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
410
|
+
`,t===null?console.log(a):t(e,a),n}};const Iq=(e,t=null)=>mW(new Fq(mW(e),t));R(`debug`,Iq);const Lq=vW(([e])=>Vq(e.rgb)),Rq=vW(([e,t=xW(1)])=>t.mix(Vq(e.rgb),e.rgb)),zq=vW(([e,t=xW(1)])=>{let n=WW(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return fK(e.rgb,r,i)}),Bq=vW(([e,t=xW(1)])=>{let n=kW(.57735,.57735,.57735),r=t.cos();return kW(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(rK(n,e.rgb).mul(r.oneMinus())))))}),Vq=(e,t=kW(FH.getLuminanceCoefficients(new KH)))=>rK(e,t),Hq={name:`Grayscale`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t}=yj;if(!e)return console.error(`You must pass a child component into the Grayscale shader.`),t(0);let n=e||t(0,0,0,0);return t(Lq(n.rgb).rgb,n.a)}};var Uq=r({__name:`Grayscale`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Hq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Hq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Hq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Hq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(Hq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Hq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Wq=Uq;const Gq={name:`HueShift`,props:{shift:{type:Number,default:0,description:`The amount to shift the hue by`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=yj;if(!t)return console.error(`You must pass a child component into the Hue Shift shader.`),n(0);let r=t||n(0,0,0,0);return n(Bq(r.rgb,e.shift.uniform).rgb,r.a)}};var Kq=r({__name:`HueShift`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},shift:{}},{blendMode:`normal`,opacity:1,...Object.entries(Gq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Gq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Gq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Gq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(Gq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Gq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),qq=Kq;const Jq={name:`Invert`,props:{},fragmentNode:({childNode:e})=>{let{vec4:t,vec3:n}=yj;if(!e)return console.error(`You must pass a child component into the Invert shader.`),t(0);let r=e||t(0,0,0,0);return t(n(1,1,1).sub(r.rgb),r.a)}};var Yq=r({__name:`Invert`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{}},{blendMode:`normal`,opacity:1,...Object.entries(Jq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Jq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Jq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Jq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(Jq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Jq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),Xq=Yq;const Zq={name:`LinearGradient`,props:{startColor:{type:String,default:`#1aff00`,transform:CV,description:`The starting color of the gradient`},endColor:{type:String,default:`#0000ff`,transform:CV,description:`The ending color of the gradient`},angle:{type:Number,default:0,description:`rotation angle in degrees (0-360, where 0 = left-to-right)`},center:{type:Object,default:{x:.5,y:.5},transform:wV},autoRotate:{type:Boolean,default:!1,description:`Enable automatic rotation of the gradient`},autoRotateSpeed:{type:Number,default:1,description:`Speed of the automatic rotation in degrees per second`}},fragmentNode:({uniforms:e,onBeforeRender:t})=>{let{vec2:n,mix:r,float:i,cos:a,sin:o,dot:s,radians:c,viewportUV:l,abs:u,div:d,uniform:f}=yj,p=f(0);t(({deltaTime:t})=>{if(e.autoRotate.uniform.value){let n=e.autoRotateSpeed.uniform.value*t*100;p.value=(p.value+n)%360}});let m=e.angle.uniform.add(p),h=c(m),g=a(h),_=o(h),v=n(g,_),y=n(e.center.uniform[0],e.center.uniform[1]),b=l.sub(y),x=s(b,v),S=i(.5).mul(u(g).add(u(_))),ee=d(x,S.max(1e-6)),te=ee.mul(.5).add(.5).clamp(i(0),i(1));return r(e.startColor.uniform,e.endColor.uniform,te)}};var Qq=r({__name:`LinearGradient`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},startColor:{},endColor:{},angle:{},center:{},autoRotate:{type:Boolean},autoRotateSpeed:{}},{blendMode:`normal`,opacity:1,...Object.entries(Zq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${Zq.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(Zq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(Zq.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(Zq,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,Zq.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),$q=Qq,eJ=class extends yU{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const tJ=z(eJ).setParameterLength(2),nJ={name:`Posterize`,props:{intensity:{type:Number,default:5,description:`The intensity of the posterization effect (lower is more posterized)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n,int:r}=yj;if(!t)return console.error(`You must pass a child component into the Posterize shader.`),n(0);let i=t||n(0,0,0,0);return tJ(i,r(e.intensity.uniform))}};var rJ=r({__name:`Posterize`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(nJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${nJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(nJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(nJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(nJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,nJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),iJ=rJ;const aJ={name:`Saturation`,props:{intensity:{type:Number,default:1,description:`The intensity of the saturation effect (1 being no change)`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=yj;if(!t)return console.error(`You must pass a child component into the Saturation shader.`),n(0);let r=t||n(0,0,0,0);return n(Rq(r.rgb,e.intensity.uniform).rgb,r.a)}};var oJ=r({__name:`Saturation`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(aJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${aJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(aJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(aJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(aJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,aJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),sJ=oJ;const cJ={name:`SolidColor`,props:{color:{type:String,default:`#5b18ca`,transform:CV,description:`The solid color to display`}},fragmentNode:({uniforms:e})=>e.color.uniform};var lJ=r({__name:`SolidColor`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},color:{}},{blendMode:`normal`,opacity:1,...Object.entries(cJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${cJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(cJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(cJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(cJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,cJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),uJ=lJ;const dJ={name:`Swirl`,props:{colorA:{type:String,default:`#1275d8`,description:`Primary gradient color`,transform:CV},colorB:{type:String,default:`#e19136`,description:`Secondary gradient color`,transform:CV},colorC:{type:String,default:`#320485`,description:`Accent gradient color`,transform:CV},speed:{type:Number,default:1,description:`Flow animation speed`},scale:{type:Number,default:5,description:`Gradient scale`},complexity:{type:Number,default:5,description:`Flow complexity`}},fragmentNode:({uniforms:e})=>{let t=aF(),n=TP.mul(e.speed.uniform),r=e.scale.uniform,i=e.complexity.uniform,a=HN(t.x.mul(r.mul(1.2)).add(n.mul(.8))).mul(.3),o=jM(t.y.mul(r.mul(.9)).sub(n.mul(.6))).mul(.3),s=fF(t.x.add(HN(t.y.mul(i.mul(2)).add(n)).mul(.08)),t.y.add(jM(t.x.mul(i.mul(1.5)).sub(n.mul(.7))).mul(.08))),c=HN(s.x.mul(r.mul(3)).add(s.y.mul(r.mul(2))).add(n.mul(.5))),l=jM(s.x.sub(s.y).mul(r.mul(2.5)).add(n.mul(.3))),u=HN(s.x.mul(i).add(a).add(s.y.mul(i.mul(.8)).add(o)).add(n.mul(.4))),d=RM(c,l,u.mul(.5).add(.5)),f=s.x.mul(.7).add(s.y.mul(.3)).add(d.mul(.2)),p=RM(e.colorA.uniform,e.colorB.uniform,GN(.1,.6,f)),m=RM(p,e.colorC.uniform,GN(.4,.9,f.add(u.mul(.3)))),h=HN(n.mul(3).add(f.mul(10))).mul(.02).add(1),g=m.mul(h);return mF(g,1)}};var fJ=r({__name:`Swirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},colorA:{},colorB:{},colorC:{},speed:{},scale:{},complexity:{}},{blendMode:`normal`,opacity:1,...Object.entries(dJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${dJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(dJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(dJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(dJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,dJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),pJ=fJ;const mJ={name:`Twirl`,props:{center:{type:Object,default:{x:.5,y:.5},transform:wV,description:`The center point of the twirl effect`},intensity:{type:Number,default:1,description:`The strength of the twirl effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec2:n,vec4:r,cos:i,sin:a,length:o,uv:s,convertToTexture:c}=yj;if(!t)return console.error(`You must pass a child component into the Twirl shader.`),r(0);let l=c(t),u=s(),d=n(e.center.uniform.x,e.center.uniform.y),f=u.sub(d),p=e.intensity.uniform.mul(o(f)),m=i(p),h=a(p),g=m.mul(f.x).sub(h.mul(f.y)),_=h.mul(f.x).add(m.mul(f.y)),v=n(g.add(d.x),_.add(d.y));return r(l.sample(v))}};var hJ=r({__name:`Twirl`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},center:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(mJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${mJ.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(mJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(mJ.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(mJ,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,mJ.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),gJ=hJ;const _J={name:`Vibrance`,props:{intensity:{type:Number,default:0,description:`The intensity of the vibrance effect`}},fragmentNode:({uniforms:e,childNode:t})=>{let{vec4:n}=yj;if(!t)return console.error(`You must pass a child component into the Vibrance shader.`),n(0);let r=t||n(0,0,0,0);return n(zq(r.rgb,e.intensity.uniform).rgb,r.a)}};var vJ=r({__name:`Vibrance`,props:o({blendMode:{},opacity:{},id:{},maskSource:{},maskType:{},intensity:{}},{blendMode:`normal`,opacity:1,...Object.entries(_J.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})}),setup(t){let n=t,r=n.id||`${_J.name.toLowerCase()}_${Math.random().toString(36).substring(7)}`;d(`ombreParentId`,r);let o=e(()=>{let e={...Object.entries(_J.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})};for(let t in n)t!==`blendMode`&&t!==`opacity`&&n[t]!==Object.entries(_J.props).reduce((e,[t,n])=>(e[t]=n.default,e),{})[t]&&(e[t]=m(n[t]));return e}),s=aI(_J,o.value,r),l=a(`ombreParentId`);if(l===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let u=a(`ombreNodeRegister`);if(u===void 0)throw Error(`Shader components must be used inside an <Shader> component or another shader component`);let f=a(`ombreUniformUpdate`);if(f===void 0)throw Error(`Shader components require ombreUniformUpdate from parent`);let g=a(`ombreMetadataUpdate`);if(g===void 0)throw Error(`Shader components require ombreMetadataUpdate from parent`);let _=()=>{let e=i();e.run(()=>{Object.entries(s).forEach(([e,{uniform:t,transform:i}])=>{h(()=>n[e],n=>{if(t&&t.value!==void 0){let t=i?i(n):n;f(r,e,t)}},{deep:!0})}),h(()=>[n.blendMode,n.opacity,n.maskSource,n.maskType],([e,t])=>{g(r,{blendMode:e,opacity:t,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0})},{deep:!0}),u(r,_J.fragmentNode,l,{blendMode:n.blendMode,opacity:n.opacity,id:n.id,mask:n.maskSource?{source:n.maskSource,type:n.maskType||`alpha`}:void 0,renderOrder:0},s)}),c(()=>{e.stop()})};return _(),c(()=>{u(r,null,null,null,null)}),(e,t)=>p(e.$slots,`default`)}}),yJ=vJ;const bJ=`177`,xJ=0,SJ=3,CJ=0,wJ=1,TJ=0,EJ=1,DJ=100,OJ=204,kJ=205,AJ=3,jJ=0,MJ=0,NJ=300,PJ=301,FJ=302,IJ=306,LJ=1e3,RJ=1001,zJ=1002,BJ=1003,VJ=1006,HJ=1008,UJ=1008,WJ=1009,GJ=1013,KJ=1014,qJ=1015,JJ=1016,YJ=1023,XJ=1026,ZJ=1027,QJ=1030,$J=2300,eY=2301,tY=2302,nY=2400,rY=2401,iY=2402,aY=0,oY=1,sY=``,cY=`srgb`,lY=`srgb-linear`,uY=`linear`,dY=`srgb`,fY=7680,pY=519,mY=512,hY=513,gY=514,_Y=515,vY=516,yY=517,bY=518,xY=519,SY=35044,CY=35048,wY=2e3,TY=2001;var EY=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}};const DY=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`);let OY=1234567;const kY=Math.PI/180,AY=180/Math.PI;function jY(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0,i=DY[e&255]+DY[e>>8&255]+DY[e>>16&255]+DY[e>>24&255]+`-`+DY[t&255]+DY[t>>8&255]+`-`+DY[t>>16&15|64]+DY[t>>24&255]+`-`+DY[n&63|128]+DY[n>>8&255]+`-`+DY[n>>16&255]+DY[n>>24&255]+DY[r&255]+DY[r>>8&255]+DY[r>>16&255]+DY[r>>24&255];return i.toLowerCase()}function MY(e,t,n){return Math.max(t,Math.min(n,e))}function NY(e,t){return(e%t+t)%t}function PY(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function FY(e,t,n){return e===t?0:(n-e)/(t-e)}function IY(e,t,n){return(1-n)*e+n*t}function LY(e,t,n,r){return IY(e,t,1-Math.exp(-n*r))}function RY(e,t=1){return t-Math.abs(NY(e,t*2)-t)}function zY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function BY(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function VY(e,t){return e+Math.floor(Math.random()*(t-e+1))}function HY(e,t){return e+Math.random()*(t-e)}function UY(e){return e*(.5-Math.random())}function WY(e){e!==void 0&&(OY=e);let t=OY+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function GY(e){return e*kY}function KY(e){return e*AY}function qY(e){return(e&e-1)==0&&e!==0}function JY(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function YY(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function XY(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function ZY(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function QY(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}const $Y={DEG2RAD:kY,RAD2DEG:AY,generateUUID:jY,clamp:MY,euclideanModulo:NY,mapLinear:PY,inverseLerp:FY,lerp:IY,damp:LY,pingpong:RY,smoothstep:zY,smootherstep:BY,randInt:VY,randFloat:HY,randFloatSpread:UY,seededRandom:WY,degToRad:GY,radToDeg:KY,isPowerOfTwo:qY,ceilPowerOfTwo:JY,floorPowerOfTwo:YY,setQuaternionFromProperEuler:XY,normalize:QY,denormalize:ZY};var eX=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=MY(this.x,e.x,t.x),this.y=MY(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=MY(this.x,e,t),this.y=MY(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(MY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},tX=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(o===0){e[t+0]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=f,e[t+2]=p,e[t+3]=m;return}if(u!==m||s!==d||c!==f||l!==p){let e=1-o,t=s*d+c*f+l*p+u*m,n=t>=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(MY(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},V=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(rX.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(rX.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=MY(this.x,e.x,t.x),this.y=MY(this.y,e.y,t.y),this.z=MY(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=MY(this.x,e,t),this.y=MY(this.y,e,t),this.z=MY(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return nX.copy(this).projectOnVector(e),this.sub(nX)}reflect(e){return this.sub(nX.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(MY(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};const nX=new V,rX=new tX;var iX=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(aX.makeScale(e,t)),this}rotate(e){return this.premultiply(aX.makeRotation(-e)),this}translate(e,t){return this.premultiply(aX.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};const aX=new iX;function oX(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function sX(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}const cX={};function lX(e){e in cX||(cX[e]=!0,console.warn(e))}const uX=new iX().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dX=new iX().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function fX(){let e={enabled:!0,workingColorSpace:lY,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===dY&&(e.r=mX(e.r),e.g=mX(e.g),e.b=mX(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===dY&&(e.r=hX(e.r),e.g=hX(e.g),e.b=hX(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===sY?uY:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return lX(`THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return lX(`THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[lY]:{primaries:t,whitePoint:r,transfer:uY,toXYZ:uX,fromXYZ:dX,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:cY},outputColorSpaceConfig:{drawingBufferColorSpace:cY}},[cY]:{primaries:t,whitePoint:r,transfer:dY,toXYZ:uX,fromXYZ:dX,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:cY}}}),e}const pX=fX();function mX(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function hX(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}let gX;var _X=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{gX===void 0&&(gX=sX(`canvas`)),gX.width=e.width,gX.height=e.height;let t=gX.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=gX}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=sX(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=mX(i[e]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(mX(t[e]/255)*255):t[e]=mX(t[e]);return{data:t,width:e.width,height:e.height}}else return console.warn(`THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}};let vX=0;var yX=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,`id`,{value:vX++}),this.uuid=jY(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t===null?e.set(0,0,0):e.set(t.width,t.height,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(bX(r[t].image)):e.push(bX(r[t]))}else e=bX(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function bX(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?_X.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn(`THREE.Texture: Unable to serialize Texture.`),{})}let xX=0;const SX=new V;var CX=class e extends EY{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=RJ,i=RJ,a=VJ,o=HJ,s=YJ,c=WJ,l=e.DEFAULT_ANISOTROPY,u=sY){super(),this.isTexture=!0,Object.defineProperty(this,`id`,{value:xX++}),this.uuid=jY(),this.name=``,this.source=new yX(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new eX(0,0),this.repeat=new eX(1,1),this.center=new eX(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new iX,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(SX).x}get height(){return this.source.getSize(SX).y}get depth(){return this.source.getSize(SX).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==NJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case LJ:e.x-=Math.floor(e.x);break;case RJ:e.x=e.x<0?0:1;break;case zJ:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case LJ:e.y-=Math.floor(e.y);break;case RJ:e.y=e.y<0?0:1;break;case zJ:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};CX.DEFAULT_IMAGE=null,CX.DEFAULT_MAPPING=NJ,CX.DEFAULT_ANISOTROPY=1;var wX=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=MY(this.x,e.x,t.x),this.y=MY(this.y,e.y,t.y),this.z=MY(this.z,e.z,t.z),this.w=MY(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=MY(this.x,e,t),this.y=MY(this.y,e,t),this.z=MY(this.z,e,t),this.w=MY(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(MY(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},TX=class extends EY{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:VJ,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new wX(0,0,e,t),this.scissorTest=!1,this.viewport=new wX(0,0,e,t);let r={width:e,height:t,depth:n.depth},i=new CX(r);this.textures=[];let a=n.count;for(let e=0;e<a;e++)this.textures[e]=i.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){let t={minFilter:VJ,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++){let n=this.textures[e];n.setValues(t)}}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isArrayTexture=this.textures[r].image.depth>1;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new yX(n)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:`dispose`})}},EX=class extends CX{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=BJ,this.minFilter=BJ,this.wrapR=RJ,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},DX=class{constructor(e=new V(1/0,1/0,1/0),t=new V(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(kX.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(kX.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=kX.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,kX):kX.fromBufferAttribute(r,t),kX.applyMatrix4(e.matrixWorld),this.expandByPoint(kX);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),AX.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),AX.copy(e.boundingBox)),AX.applyMatrix4(e.matrixWorld),this.union(AX)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,kX),kX.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(LX),RX.subVectors(this.max,LX),jX.subVectors(e.a,LX),MX.subVectors(e.b,LX),NX.subVectors(e.c,LX),PX.subVectors(MX,jX),FX.subVectors(NX,MX),IX.subVectors(jX,NX);let t=[0,-PX.z,PX.y,0,-FX.z,FX.y,0,-IX.z,IX.y,PX.z,0,-PX.x,FX.z,0,-FX.x,IX.z,0,-IX.x,-PX.y,PX.x,0,-FX.y,FX.x,0,-IX.y,IX.x,0];return!VX(t,jX,MX,NX,RX)||(t=[1,0,0,0,1,0,0,0,1],!VX(t,jX,MX,NX,RX))?!1:(zX.crossVectors(PX,FX),t=[zX.x,zX.y,zX.z],VX(t,jX,MX,NX,RX))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kX).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(kX).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(OX[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),OX[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),OX[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),OX[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),OX[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),OX[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),OX[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),OX[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(OX),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}};const OX=[new V,new V,new V,new V,new V,new V,new V,new V],kX=new V,AX=new DX,jX=new V,MX=new V,NX=new V,PX=new V,FX=new V,IX=new V,LX=new V,RX=new V,zX=new V,BX=new V;function VX(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){BX.fromArray(e,a);let o=i.x*Math.abs(BX.x)+i.y*Math.abs(BX.y)+i.z*Math.abs(BX.z),s=t.dot(BX),c=n.dot(BX),l=r.dot(BX);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}const HX=new DX,UX=new V,WX=new V;var GX=class{constructor(e=new V,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?HX.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;UX.subVectors(e,this.center);let t=UX.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(UX,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(WX.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(UX.copy(e.center).add(WX)),this.expandByPoint(UX.copy(e.center).sub(WX))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}};const KX=new V,qX=new V,JX=new V,YX=new V,XX=new V,ZX=new V,QX=new V;var $X=class{constructor(e=new V,t=new V(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,KX)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=KX.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(KX.copy(this.origin).addScaledVector(this.direction,t),KX.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){qX.copy(e).add(t).multiplyScalar(.5),JX.copy(t).sub(e).normalize(),YX.copy(this.origin).sub(qX);let i=e.distanceTo(t)*.5,a=-this.direction.dot(JX),o=YX.dot(this.direction),s=-YX.dot(JX),c=YX.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(qX).addScaledVector(JX,d),f}intersectSphere(e,t){KX.subVectors(e.center,this.origin);let n=KX.dot(this.direction),r=KX.dot(KX)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(t===0)return!0;let n=e.normal.dot(this.direction);return n*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,KX)!==null}intersectTriangle(e,t,n,r,i){XX.subVectors(t,e),ZX.subVectors(n,e),QX.crossVectors(XX,ZX);let a=this.direction.dot(QX),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;YX.subVectors(this.origin,e);let s=o*this.direction.dot(ZX.crossVectors(YX,ZX));if(s<0)return null;let c=o*this.direction.dot(XX.cross(YX));if(c<0||s+c>a)return null;let l=-o*YX.dot(QX);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},eZ=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/tZ.setFromMatrixColumn(e,0).length(),i=1/tZ.setFromMatrixColumn(e,1).length(),a=1/tZ.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(rZ,e,iZ)}lookAt(e,t,n){let r=this.elements;return sZ.subVectors(e,t),sZ.lengthSq()===0&&(sZ.z=1),sZ.normalize(),aZ.crossVectors(n,sZ),aZ.lengthSq()===0&&(Math.abs(n.z)===1?sZ.x+=1e-4:sZ.z+=1e-4,sZ.normalize(),aZ.crossVectors(n,sZ)),aZ.normalize(),oZ.crossVectors(sZ,aZ),r[0]=aZ.x,r[4]=oZ.x,r[8]=sZ.x,r[1]=aZ.y,r[5]=oZ.y,r[9]=sZ.y,r[2]=aZ.z,r[6]=oZ.z,r[10]=sZ.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],ee=r[8],te=r[12],ne=r[1],re=r[5],ie=r[9],ae=r[13],oe=r[2],se=r[6],ce=r[10],le=r[14],ue=r[3],de=r[7],fe=r[11],pe=r[15];return i[0]=a*x+o*ne+s*oe+c*ue,i[4]=a*S+o*re+s*se+c*de,i[8]=a*ee+o*ie+s*ce+c*fe,i[12]=a*te+o*ae+s*le+c*pe,i[1]=l*x+u*ne+d*oe+f*ue,i[5]=l*S+u*re+d*se+f*de,i[9]=l*ee+u*ie+d*ce+f*fe,i[13]=l*te+u*ae+d*le+f*pe,i[2]=p*x+m*ne+h*oe+g*ue,i[6]=p*S+m*re+h*se+g*de,i[10]=p*ee+m*ie+h*ce+g*fe,i[14]=p*te+m*ae+h*le+g*pe,i[3]=_*x+v*ne+y*oe+b*ue,i[7]=_*S+v*re+y*se+b*de,i[11]=_*ee+v*ie+y*ce+b*fe,i[15]=_*te+v*ae+y*le+b*pe,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=tZ.set(r[0],r[1],r[2]).length(),a=tZ.set(r[4],r[5],r[6]).length(),o=tZ.set(r[8],r[9],r[10]).length(),s=this.determinant();s<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],nZ.copy(this);let c=1/i,l=1/a,u=1/o;return nZ.elements[0]*=c,nZ.elements[1]*=c,nZ.elements[2]*=c,nZ.elements[4]*=l,nZ.elements[5]*=l,nZ.elements[6]*=l,nZ.elements[8]*=u,nZ.elements[9]*=u,nZ.elements[10]*=u,t.setFromRotationMatrix(nZ),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=wY){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===wY)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===TY)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=wY){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===wY)p=(a+i)*u,m=-2*u;else if(o===TY)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}};const tZ=new V,nZ=new eZ,rZ=new V(0,0,0),iZ=new V(1,1,1),aZ=new V,oZ=new V,sZ=new V,cZ=new eZ,lZ=new tX;var uZ=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(MY(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-MY(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(MY(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-MY(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(MY(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-MY(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return cZ.makeRotationFromQuaternion(e),this.setFromRotationMatrix(cZ,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return lZ.setFromEuler(this),this.setFromQuaternion(lZ,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};uZ.DEFAULT_ORDER=`XYZ`;var dZ=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!=0}};let fZ=0;const pZ=new V,mZ=new tX,hZ=new eZ,gZ=new V,_Z=new V,vZ=new V,yZ=new tX,bZ=new V(1,0,0),xZ=new V(0,1,0),SZ=new V(0,0,1),CZ={type:`added`},wZ={type:`removed`},TZ={type:`childadded`,child:null},EZ={type:`childremoved`,child:null};var DZ=class e extends EY{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,`id`,{value:fZ++}),this.uuid=jY(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new V,n=new uZ,r=new tX,i=new V(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new eZ},normalMatrix:{value:new iX}}),this.matrix=new eZ,this.matrixWorld=new eZ,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new dZ,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return mZ.setFromAxisAngle(e,t),this.quaternion.multiply(mZ),this}rotateOnWorldAxis(e,t){return mZ.setFromAxisAngle(e,t),this.quaternion.premultiply(mZ),this}rotateX(e){return this.rotateOnAxis(bZ,e)}rotateY(e){return this.rotateOnAxis(xZ,e)}rotateZ(e){return this.rotateOnAxis(SZ,e)}translateOnAxis(e,t){return pZ.copy(e).applyQuaternion(this.quaternion),this.position.add(pZ.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(bZ,e)}translateY(e){return this.translateOnAxis(xZ,e)}translateZ(e){return this.translateOnAxis(SZ,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(hZ.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?gZ.copy(e):gZ.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),_Z.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?hZ.lookAt(_Z,gZ,this.up):hZ.lookAt(gZ,_Z,this.up),this.quaternion.setFromRotationMatrix(hZ),r&&(hZ.extractRotation(r.matrixWorld),mZ.setFromRotationMatrix(hZ),this.quaternion.premultiply(mZ.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error(`THREE.Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(CZ),TZ.child=e,this.dispatchEvent(TZ),TZ.child=null):console.error(`THREE.Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(wZ),EZ.child=e,this.dispatchEvent(EZ),EZ.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),hZ.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),hZ.multiply(e.parent.matrixWorld)),e.applyMatrix4(hZ),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(CZ),TZ.child=e,this.dispatchEvent(TZ),TZ.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n],i=r.getObjectByProperty(e,t);if(i!==void 0)return i}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_Z,e,vZ),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_Z,yZ,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let e=this.children;for(let t=0,n=e.length;t<n;t++){let n=e[t];n.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==``&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}};DZ.DEFAULT_UP=new V(0,1,0),DZ.DEFAULT_MATRIX_AUTO_UPDATE=!0,DZ.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const OZ=new V,kZ=new V,AZ=new V,jZ=new V,MZ=new V,NZ=new V,PZ=new V,FZ=new V,IZ=new V,LZ=new V,RZ=new wX,zZ=new wX,BZ=new wX;var VZ=class e{constructor(e=new V,t=new V,n=new V){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),OZ.subVectors(e,t),r.cross(OZ);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){OZ.subVectors(r,t),kZ.subVectors(n,t),AZ.subVectors(e,t);let a=OZ.dot(OZ),o=OZ.dot(kZ),s=OZ.dot(AZ),c=kZ.dot(kZ),l=kZ.dot(AZ),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,jZ)===null?!1:jZ.x>=0&&jZ.y>=0&&jZ.x+jZ.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,jZ)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,jZ.x),s.addScaledVector(a,jZ.y),s.addScaledVector(o,jZ.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return RZ.setScalar(0),zZ.setScalar(0),BZ.setScalar(0),RZ.fromBufferAttribute(e,t),zZ.fromBufferAttribute(e,n),BZ.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(RZ,i.x),a.addScaledVector(zZ,i.y),a.addScaledVector(BZ,i.z),a}static isFrontFacing(e,t,n,r){return OZ.subVectors(n,t),kZ.subVectors(e,t),OZ.cross(kZ).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return OZ.subVectors(this.c,this.b),kZ.subVectors(this.a,this.b),OZ.cross(kZ).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;MZ.subVectors(r,n),NZ.subVectors(i,n),FZ.subVectors(e,n);let s=MZ.dot(FZ),c=NZ.dot(FZ);if(s<=0&&c<=0)return t.copy(n);IZ.subVectors(e,r);let l=MZ.dot(IZ),u=NZ.dot(IZ);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(MZ,a);LZ.subVectors(e,i);let f=MZ.dot(LZ),p=NZ.dot(LZ);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(NZ,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return PZ.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(PZ,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(MZ,a).addScaledVector(NZ,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const HZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},UZ={h:0,s:0,l:0},WZ={h:0,s:0,l:0};function GZ(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var KZ=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=cY){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pX.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=pX.workingColorSpace){return this.r=e,this.g=t,this.b=n,pX.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=pX.workingColorSpace){if(e=NY(e,1),t=MY(t,0,1),n=MY(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=GZ(i,r,e+1/3),this.g=GZ(i,r,e),this.b=GZ(i,r,e-1/3)}return pX.colorSpaceToWorking(this,r),this}setStyle(e,t=cY){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=cY){let n=HZ[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mX(e.r),this.g=mX(e.g),this.b=mX(e.b),this}copyLinearToSRGB(e){return this.r=hX(e.r),this.g=hX(e.g),this.b=hX(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=cY){return pX.workingToColorSpace(qZ.copy(this),e),Math.round(MY(qZ.r*255,0,255))*65536+Math.round(MY(qZ.g*255,0,255))*256+Math.round(MY(qZ.b*255,0,255))}getHexString(e=cY){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pX.workingColorSpace){pX.workingToColorSpace(qZ.copy(this),t);let n=qZ.r,r=qZ.g,i=qZ.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4;break}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=pX.workingColorSpace){return pX.workingToColorSpace(qZ.copy(this),t),e.r=qZ.r,e.g=qZ.g,e.b=qZ.b,e}getStyle(e=cY){pX.workingToColorSpace(qZ.copy(this),e);let t=qZ.r,n=qZ.g,r=qZ.b;return e===cY?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(UZ),this.setHSL(UZ.h+e,UZ.s+t,UZ.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(UZ),e.getHSL(WZ);let n=IY(UZ.h,WZ.h,t),r=IY(UZ.s,WZ.s,t),i=IY(UZ.l,WZ.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const qZ=new KZ;KZ.NAMES=HZ;let JZ=0;var YZ=class extends EY{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,`id`,{value:JZ++}),this.uuid=jY(),this.name=``,this.type=`Material`,this.blending=EJ,this.side=CJ,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=OJ,this.blendDst=kJ,this.blendEquation=DJ,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new KZ(0,0,0),this.blendAlpha=0,this.depthFunc=AJ,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=pY,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fY,this.stencilZFail=fY,this.stencilZPass=fY,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==EJ&&(n.blending=this.blending),this.side!==CJ&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==OJ&&(n.blendSrc=this.blendSrc),this.blendDst!==kJ&&(n.blendDst=this.blendDst),this.blendEquation!==DJ&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==AJ&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==pY&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==fY&&(n.stencilFail=this.stencilFail),this.stencilZFail!==fY&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==fY&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},XZ=class extends YZ{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new KZ(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new uZ,this.combine=jJ,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}};const ZZ=new V,QZ=new eX;let $Z=0;var eQ=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,`id`,{value:$Z++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=SY,this.updateRanges=[],this.gpuType=qJ,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)QZ.fromBufferAttribute(this,t),QZ.applyMatrix3(e),this.setXY(t,QZ.x,QZ.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ZZ.fromBufferAttribute(this,t),ZZ.applyMatrix3(e),this.setXYZ(t,ZZ.x,ZZ.y,ZZ.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ZZ.fromBufferAttribute(this,t),ZZ.applyMatrix4(e),this.setXYZ(t,ZZ.x,ZZ.y,ZZ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ZZ.fromBufferAttribute(this,t),ZZ.applyNormalMatrix(e),this.setXYZ(t,ZZ.x,ZZ.y,ZZ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ZZ.fromBufferAttribute(this,t),ZZ.transformDirection(e),this.setXYZ(t,ZZ.x,ZZ.y,ZZ.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ZY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=QY(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ZY(t,this.array)),t}setX(e,t){return this.normalized&&(t=QY(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ZY(t,this.array)),t}setY(e,t){return this.normalized&&(t=QY(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ZY(t,this.array)),t}setZ(e,t){return this.normalized&&(t=QY(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ZY(t,this.array)),t}setW(e,t){return this.normalized&&(t=QY(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=QY(t,this.array),n=QY(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=QY(t,this.array),n=QY(n,this.array),r=QY(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=QY(t,this.array),n=QY(n,this.array),r=QY(r,this.array),i=QY(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==``&&(e.name=this.name),this.usage!==SY&&(e.usage=this.usage),e}},tQ=class extends eQ{constructor(e,t,n){super(new Uint16Array(e),t,n)}},nQ=class extends eQ{constructor(e,t,n){super(new Uint32Array(e),t,n)}},rQ=class extends eQ{constructor(e,t,n){super(new Float32Array(e),t,n)}};let iQ=0;const aQ=new eZ,oQ=new DZ,sQ=new V,cQ=new DX,lQ=new DX,uQ=new V;var dQ=class e extends EY{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,`id`,{value:iQ++}),this.uuid=jY(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(oX(e)?nQ:tQ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new iX().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return aQ.makeRotationFromQuaternion(e),this.applyMatrix4(aQ),this}rotateX(e){return aQ.makeRotationX(e),this.applyMatrix4(aQ),this}rotateY(e){return aQ.makeRotationY(e),this.applyMatrix4(aQ),this}rotateZ(e){return aQ.makeRotationZ(e),this.applyMatrix4(aQ),this}translate(e,t,n){return aQ.makeTranslation(e,t,n),this.applyMatrix4(aQ),this}scale(e,t,n){return aQ.makeScale(e,t,n),this.applyMatrix4(aQ),this}lookAt(e){return oQ.lookAt(e),oQ.updateMatrix(),this.applyMatrix4(oQ.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(sQ).negate(),this.translate(sQ.x,sQ.y,sQ.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new rQ(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&console.warn(`THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new DX);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new V(-1/0,-1/0,-1/0),new V(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];cQ.setFromBufferAttribute(n),this.morphTargetsRelative?(uQ.addVectors(this.boundingBox.min,cQ.min),this.boundingBox.expandByPoint(uQ),uQ.addVectors(this.boundingBox.max,cQ.max),this.boundingBox.expandByPoint(uQ)):(this.boundingBox.expandByPoint(cQ.min),this.boundingBox.expandByPoint(cQ.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error(`THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new GX);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error(`THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new V,1/0);return}if(e){let n=this.boundingSphere.center;if(cQ.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];lQ.setFromBufferAttribute(n),this.morphTargetsRelative?(uQ.addVectors(cQ.min,lQ.min),cQ.expandByPoint(uQ),uQ.addVectors(cQ.max,lQ.max),cQ.expandByPoint(uQ)):(cQ.expandByPoint(lQ.min),cQ.expandByPoint(lQ.max))}cQ.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)uQ.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(uQ));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)uQ.fromBufferAttribute(a,t),o&&(sQ.fromBufferAttribute(e,t),uQ.add(sQ)),r=Math.max(r,n.distanceToSquared(uQ))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error(`THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv;this.hasAttribute(`tangent`)===!1&&this.setAttribute(`tangent`,new eQ(new Float32Array(4*n.count),4));let a=this.getAttribute(`tangent`),o=[],s=[];for(let e=0;e<n.count;e++)o[e]=new V,s[e]=new V;let c=new V,l=new V,u=new V,d=new eX,f=new eX,p=new eX,m=new V,h=new V;function g(e,t,r){c.fromBufferAttribute(n,e),l.fromBufferAttribute(n,t),u.fromBufferAttribute(n,r),d.fromBufferAttribute(i,e),f.fromBufferAttribute(i,t),p.fromBufferAttribute(i,r),l.sub(c),u.sub(c),f.sub(d),p.sub(d);let a=1/(f.x*p.y-p.x*f.y);isFinite(a)&&(m.copy(l).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(a),h.copy(u).multiplyScalar(f.x).addScaledVector(l,-p.x).multiplyScalar(a),o[e].add(m),o[t].add(m),o[r].add(m),s[e].add(h),s[t].add(h),s[r].add(h))}let _=this.groups;_.length===0&&(_=[{start:0,count:e.count}]);for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)g(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let v=new V,y=new V,b=new V,x=new V;function S(e){b.fromBufferAttribute(r,e),x.copy(b);let t=o[e];v.copy(t),v.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(x,t);let n=y.dot(s[e]),i=n<0?-1:1;a.setXYZW(e,v.x,v.y,v.z,i)}for(let t=0,n=_.length;t<n;++t){let n=_[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)S(e.getX(t+0)),S(e.getX(t+1)),S(e.getX(t+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0)n=new eQ(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new V,i=new V,a=new V,o=new V,s=new V,c=new V,l=new V,u=new V;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)uQ.fromBufferAttribute(e,t),uQ.normalize(),e.setXYZ(t,uQ.x,uQ.y,uQ.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new eQ(a,r,i)}if(this.index===null)return console.warn(`THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:`dispose`})}};const fQ=new eZ,pQ=new $X,mQ=new GX,hQ=new V,gQ=new V,_Q=new V,vQ=new V,yQ=new V,bQ=new V,xQ=new V,SQ=new V;var CQ=class extends DZ{constructor(e=new dQ,t=new XZ){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry,t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){bQ.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(yQ.fromBufferAttribute(s,e),a?bQ.addScaledVector(yQ,r):bQ.addScaledVector(yQ.sub(t),r))}t.add(bQ)}return t}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),mQ.copy(n.boundingSphere),mQ.applyMatrix4(i),pQ.copy(e.ray).recast(e.near),!(mQ.containsPoint(pQ.origin)===!1&&(pQ.intersectSphere(mQ,hQ)===null||pQ.origin.distanceToSquared(hQ)>(e.far-e.near)**2))&&(fQ.copy(i).invert(),pQ.copy(e.ray).applyMatrix4(fQ),!(n.boundingBox!==null&&pQ.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,pQ)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=TQ(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=TQ(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}else if(s!==void 0)if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=TQ(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=TQ(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}};function wQ(e,t,n,r,i,a,o,s){let c;if(c=t.side===wJ?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===CJ,s),c===null)return null;SQ.copy(s),SQ.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(SQ);return l<n.near||l>n.far?null:{distance:l,point:SQ.clone(),object:e}}function TQ(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,gQ),e.getVertexPosition(c,_Q),e.getVertexPosition(l,vQ);let u=wQ(e,t,n,r,gQ,_Q,vQ,xQ);if(u){let e=new V;VZ.getBarycoord(xQ,gQ,_Q,vQ,e),i&&(u.uv=VZ.getInterpolatedAttribute(i,s,c,l,e,new eX)),a&&(u.uv1=VZ.getInterpolatedAttribute(a,s,c,l,e,new eX)),o&&(u.normal=VZ.getInterpolatedAttribute(o,s,c,l,e,new V),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new V,materialIndex:0};VZ.getNormal(gQ,_Q,vQ,t.normal),u.face=t,u.barycoord=e}return u}var EQ=class e extends dQ{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new rQ(c,3)),this.setAttribute(`normal`,new rQ(l,3)),this.setAttribute(`uv`,new rQ(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,ee=h+1,te=g+1,ne=0,re=0,ie=new V;for(let a=0;a<te;a++){let o=a*y-x;for(let s=0;s<ee;s++){let d=s*v-b;ie[e]=d*r,ie[t]=o*i,ie[n]=S,c.push(ie.x,ie.y,ie.z),ie[e]=0,ie[t]=0,ie[n]=m>0?1:-1,l.push(ie.x,ie.y,ie.z),u.push(s/h),u.push(1-a/g),ne+=1}}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+ee*e,r=d+t+ee*(e+1),i=d+(t+1)+ee*(e+1),a=d+(t+1)+ee*e;s.push(n,r,a),s.push(r,i,a),re+=6}o.addGroup(f,re,_),f+=re,d+=ne}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},DQ=class extends DZ{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new eZ,this.projectionMatrix=new eZ,this.projectionMatrixInverse=new eZ,this.coordinateSystem=wY}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};const OQ=new V,kQ=new eX,AQ=new eX;var jQ=class extends DQ{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=AY*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(kY*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return AY*2*Math.atan(Math.tan(kY*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){OQ.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(OQ.x,OQ.y).multiplyScalar(-e/OQ.z),OQ.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(OQ.x,OQ.y).multiplyScalar(-e/OQ.z)}getViewSize(e,t){return this.getViewBounds(e,kQ,AQ),t.subVectors(AQ,kQ)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(kY*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},MQ=class extends CX{constructor(e=[],t=PJ,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},NQ=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=SY,this.updateRanges=[],this.version=0,this.uuid=jY()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=jY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=jY()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}};const PQ=new V;var FQ=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)PQ.fromBufferAttribute(this,t),PQ.applyMatrix4(e),this.setXYZ(t,PQ.x,PQ.y,PQ.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)PQ.fromBufferAttribute(this,t),PQ.applyNormalMatrix(e),this.setXYZ(t,PQ.x,PQ.y,PQ.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)PQ.fromBufferAttribute(this,t),PQ.transformDirection(e),this.setXYZ(t,PQ.x,PQ.y,PQ.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ZY(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=QY(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=QY(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=QY(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=QY(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=QY(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=ZY(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ZY(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ZY(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ZY(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=QY(t,this.array),n=QY(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=QY(t,this.array),n=QY(n,this.array),r=QY(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=QY(t,this.array),n=QY(n,this.array),r=QY(r,this.array),i=QY(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){console.log(`THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new eQ(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log(`THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},IQ=class extends eQ{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}};const LQ=new V,RQ=new V,zQ=new iX;var BQ=class{constructor(e=new V(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=LQ.subVectors(n,t).cross(RQ.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(LQ),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||zQ.getNormalMatrix(e),r=this.coplanarPoint(LQ).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},VQ=class extends CX{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=BJ,this.minFilter=BJ,this.generateMipmaps=!1,this.needsUpdate=!0}},HQ=class extends CX{constructor(e,t,n=KJ,r,i,a,o=BJ,s=BJ,c,l=XJ,u=1){if(l!==XJ&&l!==ZJ)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);let d={width:e,height:t,depth:u};super(d,r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new yX(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}};function UQ(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}function WQ(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}var GQ=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<i)break forward_scan;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(i=r,r=t[++n],e<r)break seek}a=t.length;break linear_scan}if(!(e>=i)){let o=t[1];e<o&&(n=2,i=o);for(let a=n-2;;){if(i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===a)break;if(r=i,i=t[--n-1],e>=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n<a;){let r=n+a>>>1;e<t[r]?a=r:n=r+1}if(r=t[n],i=t[n-1],i===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,i,r)}return this.interpolate_(n,i,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r;for(let e=0;e!==r;++e)t[e]=n[i+e];return t}interpolate_(){throw Error(`call to abstract method`)}intervalChanged_(){}},KQ=class extends GQ{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:nY,endingEnd:nY}}intervalChanged_(e,t,n){let r=this.parameterPositions,i=e-2,a=e+1,o=r[i],s=r[a];if(o===void 0)switch(this.getSettings_().endingStart){case rY:i=e,o=2*t-n;break;case iY:i=r.length-2,o=t+r[i]-r[i+1];break;default:i=e,o=n}if(s===void 0)switch(this.getSettings_().endingEnd){case rY:a=e,s=2*n-t;break;case iY:a=1,s=n+r[1]-r[0];break;default:a=e-1,s=t}let c=(n-t)*.5,l=this.valueSize;this._weightPrev=c/(t-o),this._weightNext=c/(s-n),this._offsetPrev=i*l,this._offsetNext=a*l}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(r-t),m=p*p,h=m*p,g=-d*h+2*d*m-d*p,_=(1+d)*h+(-1.5-2*d)*m+(-.5+d)*p+1,v=(-1-f)*h+(1.5+f)*m+.5*p,y=f*h-f*m;for(let e=0;e!==o;++e)i[e]=g*a[l+e]+_*a[c+e]+v*a[s+e]+y*a[u+e];return i}},qQ=class extends GQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=s-o,l=(n-t)/(r-t),u=1-l;for(let e=0;e!==o;++e)i[e]=a[c+e]*u+a[s+e]*l;return i}},JQ=class extends GQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},YQ=class{constructor(e,t,n,r){if(e===void 0)throw Error(`THREE.KeyframeTrack: track name is undefined`);if(t===void 0||t.length===0)throw Error(`THREE.KeyframeTrack: no keyframes in track named `+e);this.name=e,this.times=UQ(t,this.TimeBufferType),this.values=UQ(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:UQ(e.times,Array),values:UQ(e.values,Array)};let t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new JQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new qQ(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new KQ(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case $J:t=this.InterpolantFactoryMethodDiscrete;break;case eY:t=this.InterpolantFactoryMethodLinear;break;case tY:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let t=`unsupported interpolation for `+this.ValueTypeName+` keyframe track named `+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw Error(t);return console.warn(`THREE.KeyframeTrack:`,t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return $J;case this.InterpolantFactoryMethodLinear:return eY;case this.InterpolantFactoryMethodSmooth:return tY}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,i=0,a=r-1;for(;i!==r&&n[i]<e;)++i;for(;a!==-1&&n[a]>t;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&WQ(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===tY,i=e.length-1,a=1;for(let o=1;o<i;++o){let i=!1,s=e[o],c=e[o+1];if(s!==c&&(o!==1||s!==e[0]))if(r)i=!0;else{let e=o*n,r=e-n,a=e+n;for(let o=0;o!==n;++o){let n=t[e+o];if(n!==t[r+o]||n!==t[a+o]){i=!0;break}}}if(i){if(o!==a){e[a]=e[o];let r=o*n,i=a*n;for(let e=0;e!==n;++e)t[i+e]=t[r+e]}++a}}if(i>0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};YQ.prototype.ValueTypeName=``,YQ.prototype.TimeBufferType=Float32Array,YQ.prototype.ValueBufferType=Float32Array,YQ.prototype.DefaultInterpolation=eY;var XQ=class extends YQ{constructor(e,t,n){super(e,t,n)}};XQ.prototype.ValueTypeName=`bool`,XQ.prototype.ValueBufferType=Array,XQ.prototype.DefaultInterpolation=$J,XQ.prototype.InterpolantFactoryMethodLinear=void 0,XQ.prototype.InterpolantFactoryMethodSmooth=void 0;var ZQ=class extends YQ{constructor(e,t,n,r){super(e,t,n,r)}};ZQ.prototype.ValueTypeName=`color`;var QQ=class extends YQ{constructor(e,t,n,r){super(e,t,n,r)}};QQ.prototype.ValueTypeName=`number`;var $Q=class extends GQ{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)tX.slerpFlat(i,0,a,c-o,a,c,s);return i}},e$=class extends YQ{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new $Q(this.times,this.values,this.getValueSize(),e)}};e$.prototype.ValueTypeName=`quaternion`,e$.prototype.InterpolantFactoryMethodSmooth=void 0;var t$=class extends YQ{constructor(e,t,n){super(e,t,n)}};t$.prototype.ValueTypeName=`string`,t$.prototype.ValueBufferType=Array,t$.prototype.DefaultInterpolation=$J,t$.prototype.InterpolantFactoryMethodLinear=void 0,t$.prototype.InterpolantFactoryMethodSmooth=void 0;var n$=class extends YQ{constructor(e,t,n,r){super(e,t,n,r)}};n$.prototype.ValueTypeName=`vector`;var r$=class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;t<n;t+=2){let n=c[t],r=c[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}};const i$=new r$;var a$=class{constructor(e){this.manager=e===void 0?i$:e,this.crossOrigin=`anonymous`,this.withCredentials=!1,this.path=``,this.resourcePath=``,this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,i){n.load(e,r,t,i)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};a$.DEFAULT_MATERIAL_NAME=`__DEFAULT`;var o$=class extends DQ{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}};const s$=`\\[\\]\\.:\\/`,c$=RegExp(`[`+s$+`]`,`g`),l$=`[^`+s$+`]`,u$=`[^`+s$.replace(`\\.`,``)+`]`,d$=/((?:WC+[\/:])*)/.source.replace(`WC`,l$),f$=/(WCOD+)?/.source.replace(`WCOD`,u$),p$=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace(`WC`,l$),m$=/\.(WC+)(?:\[(.+)\])?/.source.replace(`WC`,l$),h$=RegExp(`^`+d$+f$+p$+m$+`$`),g$=[`material`,`materials`,`bones`,`map`];var _$=class{constructor(e,t,n){let r=n||v$.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},v$=class e{constructor(t,n,r){this.path=n,this.parsedPath=r||e.parseTrackName(n),this.node=e.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,n,r){return t&&t.isAnimationObjectGroup?new e.Composite(t,n,r):new e(t,n,r)}static sanitizeNodeName(e){return e.replace(/\s/g,`_`).replace(c$,``)}static parseTrackName(e){let t=h$.exec(e);if(t===null)throw Error(`PropertyBinding: Cannot parse trackName: `+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(`.`);if(r!==void 0&&r!==-1){let e=n.nodeName.substring(r+1);g$.indexOf(e)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=e)}if(n.propertyName===null||n.propertyName.length===0)throw Error(`PropertyBinding: can not parse propertyName from trackName: `+e);return n}static findNode(e,t){if(t===void 0||t===``||t===`.`||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(e){for(let r=0;r<e.length;r++){let i=e[r];if(i.name===t||i.uuid===t)return i;let a=n(i.children);if(a)return a}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let t=this.node,n=this.parsedPath,r=n.objectName,i=n.propertyName,a=n.propertyIndex;if(t||(t=e.findNode(this.rootNode,n.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn(`THREE.PropertyBinding: No target node found for track: `+this.path+`.`);return}if(r){let e=n.objectIndex;switch(r){case`materials`:if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.materials){console.error(`THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.`,this);return}t=t.material.materials;break;case`bones`:if(!t.skeleton){console.error(`THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.`,this);return}t=t.skeleton.bones;for(let n=0;n<t.length;n++)if(t[n].name===e){e=n;break}break;case`map`:if(`map`in t){t=t.map;break}if(!t.material){console.error(`THREE.PropertyBinding: Can not bind to material as node does not have a material.`,this);return}if(!t.material.map){console.error(`THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.`,this);return}t=t.material.map;break;default:if(t[r]===void 0){console.error(`THREE.PropertyBinding: Can not bind to objectName of node undefined.`,this);return}t=t[r]}if(e!==void 0){if(t[e]===void 0){console.error(`THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.`,this,t);return}t=t[e]}}let o=t[i];if(o===void 0){let e=n.nodeName;console.error(`THREE.PropertyBinding: Trying to update property for track: `+e+`.`+i+` but it wasn't found.`,t);return}let s=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?s=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(s=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(a!==void 0){if(i===`morphTargetInfluences`){if(!t.geometry){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.`,this);return}if(!t.geometry.morphAttributes){console.error(`THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.`,this);return}t.morphTargetDictionary[a]!==void 0&&(a=t.morphTargetDictionary[a])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=a}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][s]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};v$.Composite=_$,v$.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},v$.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},v$.prototype.GetterByBindingType=[v$.prototype._getValue_direct,v$.prototype._getValue_array,v$.prototype._getValue_arrayElement,v$.prototype._getValue_toArray],v$.prototype.SetterByBindingTypeAndVersioning=[[v$.prototype._setValue_direct,v$.prototype._setValue_direct_setNeedsUpdate,v$.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[v$.prototype._setValue_array,v$.prototype._setValue_array_setNeedsUpdate,v$.prototype._setValue_array_setMatrixWorldNeedsUpdate],[v$.prototype._setValue_arrayElement,v$.prototype._setValue_arrayElement_setNeedsUpdate,v$.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[v$.prototype._setValue_fromArray,v$.prototype._setValue_fromArray_setNeedsUpdate,v$.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const uoe=new Float32Array(1);var y$=class extends NQ{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},b$=class e{constructor(t,n,r,i){e.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,n,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let i=this.elements;return i[0]=e,i[2]=t,i[1]=n,i[3]=r,this}};typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`register`,{detail:{revision:bJ}})),typeof window<`u`&&(window.__THREE__?console.warn(`WARNING: Multiple instances of Three.js being imported.`):window.__THREE__=bJ);const x$=`alphaMap.alphaTest.anisotropy.anisotropyMap.anisotropyRotation.aoMap.aoMapIntensity.attenuationColor.attenuationDistance.bumpMap.clearcoat.clearcoatMap.clearcoatNormalMap.clearcoatNormalScale.clearcoatRoughness.color.dispersion.displacementMap.emissive.emissiveIntensity.emissiveMap.envMap.envMapIntensity.gradientMap.ior.iridescence.iridescenceIOR.iridescenceMap.iridescenceThicknessMap.lightMap.lightMapIntensity.map.matcap.metalness.metalnessMap.normalMap.normalScale.opacity.roughness.roughnessMap.sheen.sheenColor.sheenColorMap.sheenRoughnessMap.shininess.specular.specularColor.specularColorMap.specularIntensity.specularIntensityMap.specularMap.thickness.transmission.transmissionMap`.split(`.`);var S$=class{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=x$,this.renderId=0}firstInitialization(e){let t=this.renderObjects.has(e);return t===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){let t=e.getMRT();return t!==null&&t.has(`velocity`)}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){let{geometry:n,material:r,object:i}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){let{width:n,height:r}=e.context;t.bufferWidth=n,t.bufferHeight=r}this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let n in e){let r=e[n];t[n]={version:r.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){let t={};for(let n of this.refreshUniforms){let r=e[n];if(r==null)continue;typeof r==`object`&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r}return t}equals(e){let{object:t,material:n,geometry:r}=e,i=this.getRenderObjectData(e);if(i.worldMatrix.equals(t.matrixWorld)!==!0)return i.worldMatrix.copy(t.matrixWorld),!1;let a=i.material;for(let e in a){let t=a[e],r=n[e];if(t.equals!==void 0){if(t.equals(r)===!1)return t.copy(r),!1}else if(r.isTexture===!0){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,!1}else if(t!==r)return a[e]=r,!1}if(a.transmission>0){let{width:t,height:n}=e.context;if(i.bufferWidth!==t||i.bufferHeight!==n)return i.bufferWidth=t,i.bufferHeight=n,!1}let o=i.geometry,s=r.attributes,c=o.attributes,l=Object.keys(c),u=Object.keys(s);if(o.id!==r.id)return o.id=r.id,!1;if(l.length!==u.length)return i.geometry.attributes=this.getAttributesData(s),!1;for(let e of l){let t=c[e],n=s[e];if(n===void 0)return delete c[e],!1;if(t.version!==n.version)return t.version=n.version,!1}let d=r.index,f=o.indexVersion,p=d?d.version:null;if(f!==p)return o.indexVersion=p,!1;if(o.drawRange.start!==r.drawRange.start||o.drawRange.count!==r.drawRange.count)return o.drawRange.start=r.drawRange.start,o.drawRange.count=r.drawRange.count,!1;if(i.morphTargetInfluences){let e=!1;for(let n=0;n<i.morphTargetInfluences.length;n++)i.morphTargetInfluences[n]!==t.morphTargetInfluences[n]&&(e=!0);if(e)return!0}return i.center&&i.center.equals(t.center)===!1?(i.center.copy(t.center),!0):(e.bundle!==null&&(i.version=e.bundle.version),!0)}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;let r=e.object.static===!0,i=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||i)return!1;let a=this.equals(e)!==!0;return a}};function C$(e,t=0){let n=3735928559^t,r=1103547991^t;if(e instanceof Array)for(let t=0,i;t<e.length;t++)i=e[t],n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);else for(let t=0,i;t<e.length;t++)i=e.charCodeAt(t),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}const w$=e=>C$(e),T$=e=>C$(e),E$=(...e)=>C$(e);function D$(e,t=!1){let n=[];e.isNode===!0&&(n.push(e.id),e=e.getSelf());for(let{property:r,childNode:i}of O$(e))n.push(C$(r.slice(0,-4)),i.getCacheKey(t));return C$(n)}function*O$(e,t=!1){for(let n in e){if(n.startsWith(`_`)===!0)continue;let r=e[n];if(Array.isArray(r)===!0)for(let e=0;e<r.length;e++){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}else if(r&&r.isNode===!0)yield{property:n,childNode:r};else if(typeof r==`object`)for(let e in r){let i=r[e];i&&(i.isNode===!0||t&&typeof i.toJSON==`function`)&&(yield{property:n,index:e,childNode:i})}}}const k$=new Map([[1,`float`],[2,`vec2`],[3,`vec3`],[4,`vec4`],[9,`mat3`],[16,`mat4`]]),A$=new WeakMap;function j$(e){return k$.get(e)}function M$(e){if(/[iu]?vec\d/.test(e))return e.startsWith(`ivec`)?Int32Array:e.startsWith(`uvec`)?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function N$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 9;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function P$(e){if(/float|int|uint/.test(e))return 1;if(/vec2/.test(e))return 2;if(/vec3/.test(e))return 3;if(/vec4/.test(e)||/mat2/.test(e))return 4;if(/mat3/.test(e))return 12;if(/mat4/.test(e))return 16;console.error(`THREE.TSL: Unsupported type:`,e)}function F$(e){if(/float|int|uint/.test(e))return 4;if(/vec2/.test(e))return 8;if(/vec3/.test(e)||/vec4/.test(e))return 16;if(/mat2/.test(e))return 8;if(/mat3/.test(e))return 48;if(/mat4/.test(e))return 64;console.error(`THREE.TSL: Unsupported type:`,e)}function I$(e){if(e==null)return null;let t=typeof e;return e.isNode===!0?`node`:t===`number`?`float`:t===`boolean`?`bool`:t===`string`?`string`:t===`function`?`shader`:e.isVector2===!0?`vec2`:e.isVector3===!0?`vec3`:e.isVector4===!0?`vec4`:e.isMatrix2===!0?`mat2`:e.isMatrix3===!0?`mat3`:e.isMatrix4===!0?`mat4`:e.isColor===!0?`color`:e instanceof ArrayBuffer?`ArrayBuffer`:null}function L$(e,...t){let n=e?e.slice(-4):void 0;return t.length===1&&(n===`vec2`?t=[t[0],t[0]]:n===`vec3`?t=[t[0],t[0],t[0]]:n===`vec4`&&(t=[t[0],t[0],t[0],t[0]])),e===`color`?new KZ(...t):n===`vec2`?new eX(...t):n===`vec3`?new V(...t):n===`vec4`?new wX(...t):n===`mat2`?new b$(...t):n===`mat3`?new iX(...t):n===`mat4`?new eZ(...t):e===`bool`?t[0]||!1:e===`float`||e===`int`||e===`uint`?t[0]||0:e===`string`?t[0]||``:e===`ArrayBuffer`?B$(t[0]):null}function R$(e){let t=A$.get(e);return t===void 0&&(t={},A$.set(e,t)),t}function z$(e){let t=``,n=new Uint8Array(e);for(let e=0;e<n.length;e++)t+=String.fromCharCode(n[e]);return btoa(t)}function B$(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}const V$={VERTEX:`vertex`,FRAGMENT:`fragment`},H$={NONE:`none`,FRAME:`frame`,RENDER:`render`,OBJECT:`object`},U$={BOOLEAN:`bool`,INTEGER:`int`,FLOAT:`float`,VECTOR2:`vec2`,VECTOR3:`vec3`,VECTOR4:`vec4`,MATRIX2:`mat2`,MATRIX3:`mat3`,MATRIX4:`mat4`},W$={READ_ONLY:`readOnly`,WRITE_ONLY:`writeOnly`,READ_WRITE:`readWrite`},G$=[`fragment`,`vertex`],K$=[`setup`,`analyze`,`generate`],q$=[...G$,`compute`],J$=[`x`,`y`,`z`,`w`],Y$={analyze:`setup`,generate:`analyze`};let X$=0;var Z$=class extends EY{static get type(){return`Node`}constructor(e=null){super(),this.nodeType=e,this.updateType=H$.NONE,this.updateBeforeType=H$.NONE,this.updateAfterType=H$.NONE,this.uuid=$Y.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,`id`,{value:X$++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,H$.FRAME)}onRenderUpdate(e){return this.onUpdate(e,H$.RENDER)}onObjectUpdate(e){return this.onUpdate(e,H$.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of O$(this))yield e}dispose(){this.dispatchEvent({type:`dispose`})}traverse(e){e(this);for(let t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e||=this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=E$(D$(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){let t=this.getNodeType(e),n=e.getElementType(t);return n}getMemberType(){return`void`}getNodeType(e){let t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){let t=this.getHash(e),n=e.getNodeFromHash(t);return n||this}setup(e){let t=e.getNodeProperties(this),n=0;for(let e of this.getChildren())t[`node`+ n++]=e;return t.outputNode||null}analyze(e,t=null){let n=e.increaseUsage(this);if(this.parents===!0){let n=e.getDataFromNode(this,`any`);n.stages=n.stages||{},n.stages[e.shaderStage]=n.stages[e.shaderStage]||[],n.stages[e.shaderStage].push(t)}if(n===1){let t=e.getNodeProperties(this);for(let n of Object.values(t))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){let{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){console.warn(`Abstract function.`)}updateAfter(){console.warn(`Abstract function.`)}update(){console.warn(`Abstract function.`)}build(e,t=null){let n=this.getShared(e);if(this!==n)return n.build(e,t);let r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;let i=Y$[e.buildStage];if(i&&r.buildStages[i]!==!0){let t=e.getBuildStage();e.setBuildStage(i),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let a=null,o=e.getBuildStage();if(o===`setup`){this.updateReference(e);let t=e.getNodeProperties(this);if(t.initialized!==!0){t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null;for(let n of Object.values(t))if(n&&n.isNode===!0){if(n.parents===!0){let t=e.getNodeProperties(n);t.parents=t.parents||[],t.parents.push(this)}n.build(e)}}a=t.outputNode}else if(o===`analyze`)this.analyze(e,t);else if(o===`generate`){let n=this.generate.length===1;if(n){let n=this.getNodeType(e),r=e.getDataFromNode(this);a=r.snippet,a===void 0?r.generated===void 0?(r.generated=!0,a=this.generate(e)||``,r.snippet=a):(console.warn(`THREE.Node: Recursion detected.`,this),a=``):r.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,n,t)}else a=this.generate(e,t)||``}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return O$(this)}serialize(e){let t=this.getSerializeChildren(),n={};for(let{property:r,index:i,childNode:a}of t)i===void 0?n[r]=a.toJSON(e.meta).uuid:(n[r]===void 0&&(n[r]=Number.isInteger(i)?[]:{}),n[r][i]=a.toJSON(e.meta).uuid);Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){let t=e.meta.nodes;for(let n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){let r=[];for(let i of e.inputNodes[n])r.push(t[i]);this[n]=r}else if(typeof e.inputNodes[n]==`object`){let r={};for(let i in e.inputNodes[n]){let a=e.inputNodes[n][i];r[i]=t[a]}this[n]=r}else{let r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){let{uuid:t,type:n}=this,r=e===void 0||typeof e==`string`;r&&(e={textures:{},images:{},nodes:{}});let i=e.nodes[t];i===void 0&&(i={uuid:t,type:n,meta:e,metadata:{version:4.7,type:`Node`,generator:`Node.toJSON`}},r!==!0&&(e.nodes[i.uuid]=i),this.serialize(i),delete i.meta);function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(r){let t=a(e.textures),n=a(e.images),r=a(e.nodes);t.length>0&&(i.textures=t),n.length>0&&(i.images=n),r.length>0&&(i.nodes=r)}return i}},Q$=class extends Z${static get type(){return`ArrayElementNode`}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){let t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:`uint`);return`${n}[ ${r} ]`}},$$=class extends Z${static get type(){return`ConvertNode`}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),n=null;for(let r of this.convertTo.split(`|`))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let n=this.node,r=this.getNodeType(e),i=n.build(e,r);return e.format(i,r,t)}},e1=class extends Z${static get type(){return`TempNode`}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){let n=e.getBuildStage();if(n===`generate`){let n=e.getVectorType(this.getNodeType(e,t)),r=e.getDataFromNode(this);if(r.propertyName!==void 0)return e.format(r.propertyName,n,t);if(n!==`void`&&t!==`void`&&this.hasDependencies(e)){let i=super.build(e,n),a=e.getVarFromNode(this,null,n),o=e.getPropertyName(a);return e.addLineFlowCode(`${o} = ${i}`,this),r.snippet=i,r.propertyName=o,e.format(r.propertyName,n,t)}}return super.build(e,t)}},t1=class extends e1{static get type(){return`JoinNode`}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType===null?e.getTypeFromLength(this.nodes.reduce((t,n)=>t+e.getTypeLength(n.getNodeType(e)),0)):e.getVectorType(this.nodeType)}generate(e,t){let n=this.getNodeType(e),r=e.getTypeLength(n),i=this.nodes,a=e.getComponentType(n),o=[],s=0;for(let t of i){if(s>=r){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let i=t.getNodeType(e),c=e.getTypeLength(i),l;s+c>r&&(console.error(`THREE.TSL: Length of '${n}()' data exceeds maximum length of output type.`),c=r-s,i=e.getTypeFromLength(c)),s+=c,l=t.build(e,i);let u=e.getComponentType(i);u!==a&&(l=e.format(l,u,a)),o.push(l)}let c=`${e.getType(n)}( ${o.join(`, `)} )`;return e.format(c,n,t)}};const n1=J$.join(``);var r1=class extends Z${static get type(){return`SplitNode`}constructor(e,t=`x`){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(let t of this.components)e=Math.max(J$.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let n=this.node,r=e.getTypeLength(n.getNodeType(e)),i=null;if(r>1){let a=null,o=this.getVectorLength();o>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let s=n.build(e,a);i=this.components.length===r&&this.components===n1.slice(0,this.components.length)?e.format(s,a,t):e.format(`${s}.${this.components}`,this.getNodeType(e),t)}else i=n.build(e,t);return i}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}},i1=class extends e1{static get type(){return`SetNode`}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:n,targetNode:r}=this,i=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),o=e.getTypeFromLength(n.length,a),s=r.build(e,o),c=t.build(e,i),l=e.getTypeLength(i),u=[];for(let e=0;e<l;e++){let t=J$[e];t===n[0]?(u.push(s),e+=n.length-1):u.push(c+`.`+t)}return`${e.getType(i)}( ${u.join(`, `)} )`}},a1=class extends e1{static get type(){return`FlipNode`}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:n}=this,r=this.getNodeType(e),i=n.build(e),a=e.getVarFromNode(this),o=e.getPropertyName(a);e.addLineFlowCode(o+` = `+i,this);let s=e.getTypeLength(r),c=[],l=0;for(let e=0;e<s;e++){let n=J$[e];n===t[l]?(c.push(`1.0 - `+(o+`.`+n)),l++):c.push(o+`.`+n)}return`${e.getType(r)}( ${c.join(`, `)} )`}},o1=class extends Z${static get type(){return`InputNode`}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?I$(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=I$(this.value),e.nodeType=this.nodeType,e.valueType===`ArrayBuffer`&&(e.value=z$(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?L$(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn(`Abstract function.`)}};const s1=/float|u?int/;var c1=class extends o1{static get type(){return`ConstNode`}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let n=this.getNodeType(e);return s1.test(n)&&s1.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}},l1=class extends Z${static get type(){return`MemberNode`}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){let t=this.node.build(e);return t+`.`+this.property}};let u1=null;const d1=new Map;function H(e,t){if(d1.has(e)){console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);return}if(typeof t!=`function`)throw Error(`THREE.TSL: Node element ${e} is not a function`);d1.set(e,t)}const f1=e=>e.replace(/r|s/g,`x`).replace(/g|t/g,`y`).replace(/b|p/g,`z`).replace(/a|q/g,`w`),p1=e=>f1(e).split(``).sort().join(``),m1={setup(e,t){let n=t.shift();return e(B1(n),...t)},get(e,t,n){if(typeof t==`string`&&e[t]===void 0){if(e.isStackNode!==!0&&t===`assign`)return(...e)=>(u1.assign(n,...e),n);if(d1.has(t)){let r=d1.get(t);return e.isStackNode?(...e)=>n.add(r(...e)):(...e)=>r(n,...e)}else if(t===`self`)return e;else if(t.endsWith(`Assign`)&&d1.has(t.slice(0,t.length-6))){let r=d1.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>n.assign(e[0],r(...e)):(...e)=>n.assign(r(n,...e))}else if(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0)return t=f1(t),U(new r1(n,t));else if(/^set[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=p1(t.slice(3).toLowerCase()),n=>U(new i1(e,t,U(n)));else if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(t)===!0)return t=p1(t.slice(4).toLowerCase()),()=>U(new a1(U(e),t));else if(t===`width`||t===`height`||t===`depth`)return t===`width`?t=`x`:t===`height`?t=`y`:t===`depth`&&(t=`z`),U(new r1(e,t));else if(/^\d+$/.test(t)===!0)return U(new Q$(n,new c1(Number(t),`uint`)));else if(/^get$/.test(t)===!0)return e=>U(new l1(n,e))}return Reflect.get(e,t,n)},set(e,t,n,r){return typeof t==`string`&&e[t]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(t)===!0||t===`width`||t===`height`||t===`depth`||/^\d+$/.test(t)===!0)?(r[t].assign(n),!0):Reflect.set(e,t,n,r)}},h1=new WeakMap,g1=new WeakMap,_1=function(e,t=null){let n=I$(e);if(n===`node`){let t=h1.get(e);return t===void 0&&(t=new Proxy(e,m1),h1.set(e,t),h1.set(t,t)),t}else if(t===null&&(n===`float`||n===`boolean`)||n&&n!==`shader`&&n!==`string`)return U(P1(e,t));else if(n===`shader`)return K(e);return e},v1=function(e,t=null){for(let n in e)e[n]=U(e[n],t);return e},y1=function(e,t=null){let n=e.length;for(let r=0;r<n;r++)e[r]=U(e[r],t);return e},b1=function(e,t=null,n=null,r=null){let i=e=>U(r===null?e:Object.assign(e,r)),a,o=t,s,c;function l(t){let n;return n=o?/[a-z]/i.test(o)?o+`()`:o:e.type,s!==void 0&&t.length<s?(console.error(`THREE.TSL: "${n}" parameter length is less than minimum required.`),t.concat(Array(s-t.length).fill(0))):c!==void 0&&t.length>c?(console.error(`THREE.TSL: "${n}" parameter length exceeds limit.`),t.slice(0,c)):t}return t===null?a=(...t)=>i(new e(...V1(l(t)))):n===null?a=(...n)=>i(new e(t,...V1(l(n)))):(n=U(n),a=(...r)=>i(new e(t,...V1(l(r)),n))),a.setParameterLength=(...e)=>(e.length===1?s=c=e[0]:e.length===2&&([s,c]=e),a),a.setName=e=>(o=e,a),a},x1=function(e,...t){return U(new e(...V1(t)))};var S1=class extends Z${constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:n}=this,r=e.getNodeProperties(t),i=t.namespace&&t.namespace===e.namespace?e.getNamespace(`once`):`once`;if(r[i])return r[i];let a=null;if(t.layout){let r=g1.get(e.constructor);r===void 0&&(r=new WeakMap,g1.set(e.constructor,r));let i=r.get(t);i===void 0&&(i=U(e.buildFunctionNode(t)),r.set(t,i)),e.addInclude(i),a=U(i.call(n))}else{let r=t.jsFunc,i=n!==null||r.length>1?r(n||[],e):r(e);a=U(i)}return t.once&&(r[i]=a),a}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),n=e.getOutputNamespace();return t[n]=t[n]||this.setupOutput(e),t[n]}build(e,t=null){let n=null,r=e.getBuildStage(),i=e.getNodeProperties(this),a=e.getOutputNamespace(),o=this.getOutputNode(e);if(r===`setup`){let t=e.getNamespace(`initialized`);i[t]!==!0&&(i[t]=!0,i[a]=this.getOutputNode(e),i[a].build(e)),n=i[a]}else r===`analyze`?o.build(e,t):r===`generate`&&(n=o.build(e,t)||``);return n}},C1=class extends Z${constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return B1(e),U(new S1(this,e))}setup(){return this.call()}};const w1=[!1,!0],T1=[0,1,2,3],E1=[-1,-2],D1=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],O1=new Map;for(let e of w1)O1.set(e,new c1(e));const k1=new Map;for(let e of T1)k1.set(e,new c1(e,`uint`));const A1=new Map([...k1].map(e=>new c1(e.value,`int`)));for(let e of E1)A1.set(e,new c1(e,`int`));const j1=new Map([...A1].map(e=>new c1(e.value)));for(let e of D1)j1.set(e,new c1(e));for(let e of D1)j1.set(-e,new c1(-e));const M1={bool:O1,uint:k1,ints:A1,float:j1},N1=new Map([...O1,...j1]),P1=(e,t)=>N1.has(e)?N1.get(e):e.isNode===!0?e:new c1(e,t),F1=e=>{try{return e.getNodeType()}catch{return}},I1=function(e,t=null){return(...n)=>{if((n.length===0||![`bool`,`float`,`int`,`uint`].includes(e)&&n.every(e=>typeof e!=`object`))&&(n=[L$(e,...n)]),n.length===1&&t!==null&&t.has(n[0]))return U(t.get(n[0]));if(n.length===1){let t=P1(n[0],e);return F1(t)===e?U(t):U(new $$(t,e))}let r=n.map(e=>P1(e));return U(new t1(r,e))}},L1=e=>typeof e==`object`&&e?e.value:e,R1=e=>e==null?null:e.nodeType||e.convertTo||(typeof e==`string`?e:null);function z1(e,t){return new Proxy(new C1(e,t),m1)}const U=(e,t=null)=>_1(e,t),B1=(e,t=null)=>new v1(e,t),V1=(e,t=null)=>new y1(e,t),W=(...e)=>new b1(...e),G=(...e)=>new x1(...e);let H1=0;const K=(e,t=null)=>{let n=null;t!==null&&(typeof t==`object`?n=t.return:(typeof t==`string`?n=t:console.error(`THREE.TSL: Invalid layout type.`),t=null));let r=new z1(e,n),i=(...e)=>{let t;B1(e);let i=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype);t=i?[...e]:e[0];let a=r.call(t);return n===`void`&&a.toStack(),a};if(i.shaderNode=r,i.id=r.id,i.getNodeType=(...e)=>r.getNodeType(...e),i.getCacheKey=(...e)=>r.getCacheKey(...e),i.setLayout=e=>(r.setLayout(e),i),i.once=(e=null)=>(r.once=!0,r.namespace=e,i),t!==null){if(typeof t.inputs!=`object`){let e={name:`fn`+ H1++,type:n,inputs:[]};for(let n in t){if(n===`return`)continue;e.inputs.push({name:n,type:t[n]})}t=e}i.setLayout(t)}return i},U1=e=>{u1=e},W1=()=>u1,G1=(...e)=>u1.If(...e),K1=(...e)=>u1.Switch(...e);function q1(e){return u1&&u1.add(e),e}H(`toStack`,q1);const J1=new I1(`color`),q=new I1(`float`,M1.float),J=new I1(`int`,M1.ints),Y1=new I1(`uint`,M1.uint),X1=new I1(`bool`,M1.bool),Y=new I1(`vec2`),Z1=new I1(`ivec2`),Q1=new I1(`uvec2`),$1=new I1(`bvec2`),X=new I1(`vec3`),e0=new I1(`ivec3`),t0=new I1(`uvec3`),n0=new I1(`bvec3`),r0=new I1(`vec4`),i0=new I1(`ivec4`),a0=new I1(`uvec4`),o0=new I1(`bvec4`),s0=new I1(`mat2`),c0=new I1(`mat3`),l0=new I1(`mat4`),u0=(e=``)=>U(new c1(e,`string`)),d0=e=>U(new c1(e,`ArrayBuffer`));H(`toColor`,J1),H(`toFloat`,q),H(`toInt`,J),H(`toUint`,Y1),H(`toBool`,X1),H(`toVec2`,Y),H(`toIVec2`,Z1),H(`toUVec2`,Q1),H(`toBVec2`,$1),H(`toVec3`,X),H(`toIVec3`,e0),H(`toUVec3`,t0),H(`toBVec3`,n0),H(`toVec4`,r0),H(`toIVec4`,i0),H(`toUVec4`,a0),H(`toBVec4`,o0),H(`toMat2`,s0),H(`toMat3`,c0),H(`toMat4`,l0);const f0=W(Q$).setParameterLength(2),p0=(e,t)=>U(new $$(U(e),t)),m0=(e,t)=>U(new r1(U(e),t));H(`element`,f0),H(`convert`,p0);const h0=e=>(console.warn(`THREE.TSL: append() has been renamed to Stack().`),q1(e));H(`append`,e=>(console.warn(`THREE.TSL: .append() has been renamed to .toStack().`),q1(e)));const g0=(...e)=>(console.warn(`THREE.TSL: tslFn() has been renamed to Fn().`),K(...e));var _0=class extends Z${static get type(){return`PropertyNode`}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}};const v0=(e,t)=>U(new _0(e,t)),y0=(e,t)=>U(new _0(e,t,!0)),b0=G(_0,`vec4`,`DiffuseColor`),x0=G(_0,`vec3`,`EmissiveColor`),S0=G(_0,`float`,`Roughness`),C0=G(_0,`float`,`Metalness`),w0=G(_0,`float`,`Clearcoat`),T0=G(_0,`float`,`ClearcoatRoughness`),E0=G(_0,`vec3`,`Sheen`),D0=G(_0,`float`,`SheenRoughness`),O0=G(_0,`float`,`Iridescence`),k0=G(_0,`float`,`IridescenceIOR`),A0=G(_0,`float`,`IridescenceThickness`),j0=G(_0,`float`,`AlphaT`),M0=G(_0,`float`,`Anisotropy`),N0=G(_0,`vec3`,`AnisotropyT`),P0=G(_0,`vec3`,`AnisotropyB`),F0=G(_0,`color`,`SpecularColor`),I0=G(_0,`float`,`SpecularF90`),L0=G(_0,`float`,`Shininess`),R0=G(_0,`vec4`,`Output`),z0=G(_0,`float`,`dashSize`),B0=G(_0,`float`,`gapSize`),V0=G(_0,`float`,`pointWidth`),H0=G(_0,`float`,`IOR`),U0=G(_0,`float`,`Transmission`),W0=G(_0,`float`,`Thickness`),G0=G(_0,`float`,`AttenuationDistance`),K0=G(_0,`color`,`AttenuationColor`),q0=G(_0,`float`,`Dispersion`);var J0=class extends Z${static get type(){return`UniformGroupNode`}constructor(e,t=!1,n=1){super(`string`),this.name=e,this.shared=t,this.order=n,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}};const Y0=e=>new J0(e),X0=(e,t=0)=>new J0(e,!0,t),Z0=X0(`frame`),Q0=X0(`render`),$0=Y0(`object`);var e2=class extends o1{static get type(){return`UniformNode`}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name=``,this.groupNode=$0}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){let n=this.getSelf();return e=e.bind(n),super.onUpdate(t=>{let r=e(t,n);r!==void 0&&(this.value=r)},t)}generate(e,t){let n=this.getNodeType(e),r=this.getUniformHash(e),i=e.getNodeFromHash(r);i===void 0&&(e.setHashNode(this,r),i=this);let a=i.getInputType(e),o=e.getUniformFromNode(i,a,e.shaderStage,this.name||e.context.label),s=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(s,n,t)}};const t2=(e,t)=>{let n=R1(t||e),r=e&&e.isNode===!0?e.node&&e.node.value||e.value:e;return U(new e2(r,n))};var n2=class extends e1{static get type(){return`ArrayNode`}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}};const r2=(...e)=>{let t;if(e.length===1){let n=e[0];t=new n2(null,n.length,n)}else{let n=e[0],r=e[1];t=new n2(n,r)}return U(t)};H(`toArray`,(e,t)=>r2(Array(t).fill(e)));var i2=class extends e1{static get type(){return`AssignNode`}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t===`void`?`void`:this.targetNode.getNodeType(e)}needsSplitAssign(e){let{targetNode:t}=this;if(e.isAvailable(`swizzleAssign`)===!1&&t.isSplitNode&&t.components.length>1){let n=e.getTypeLength(t.node.getNodeType(e)),r=J$.join(``).slice(0,n)!==t.components;return r}return!1}setup(e){let{targetNode:t,sourceNode:n}=this,r=e.getNodeProperties(this);r.sourceNode=n,r.targetNode=t.context({assign:!0})}generate(e,t){let{targetNode:n,sourceNode:r}=e.getNodeProperties(this),i=this.needsSplitAssign(e),a=n.getNodeType(e),o=n.build(e),s=r.build(e,a),c=r.getNodeType(e),l=e.getDataFromNode(this),u;if(l.initialized===!0)t!==`void`&&(u=o);else if(i){let r=e.getVarFromNode(this,null,a),i=e.getPropertyName(r);e.addLineFlowCode(`${i} = ${s}`,this);let c=n.node,l=c.node.context({assign:!0}),d=l.build(e);for(let t=0;t<c.components.length;t++){let n=c.components[t];e.addLineFlowCode(`${d}.${n} = ${i}[ ${t} ]`,this)}t!==`void`&&(u=o)}else u=`${o} = ${s}`,(t===`void`||c===`void`)&&(e.addLineFlowCode(u,this),t!==`void`&&(u=o));return l.initialized=!0,e.format(u,a,t)}};const a2=W(i2).setParameterLength(2);H(`assign`,a2);var o2=class extends e1{static get type(){return`FunctionCallNode`}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],n=this.functionNode,r=n.getInputs(e),i=this.parameters,a=(t,n)=>{let r=n.type,i=r===`pointer`,a;return a=i?`&`+t.build(e):t.build(e,r),a};if(Array.isArray(i)){if(i.length>r.length)console.error(`THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'.`),i.length=r.length;else if(i.length<r.length)for(console.error(`THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.`);i.length<r.length;)i.push(q(0));for(let e=0;e<i.length;e++)t.push(a(i[e],r[e]))}else for(let e of r){let n=i[e.name];n===void 0?(console.error(`THREE.TSL: Input '${e.name}' not found in \'Fn()\'.`),t.push(a(q(0),e))):t.push(a(n,e))}let o=n.build(e,`property`);return`${o}( ${t.join(`, `)} )`}};const s2=(e,...t)=>(t=t.length>1||t[0]&&t[0].isNode===!0?V1(t):B1(t[0]),U(new o2(U(e),t)));H(`call`,s2);const c2={"==":`equal`,"!=":`notEqual`,"<":`lessThan`,">":`greaterThan`,"<=":`lessThanEqual`,">=":`greaterThanEqual`,"%":`mod`};var l2=class e extends e1{static get type(){return`OperatorNode`}constructor(t,n,r,...i){if(super(),i.length>0){let a=new e(t,n,r);for(let n=0;n<i.length-1;n++)a=new e(t,a,i[n]);n=a,r=i[i.length-1]}this.op=t,this.aNode=n,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(c2[this.op],t)}getNodeType(e){let t=this.op,n=this.aNode,r=this.bNode,i=n.getNodeType(e),a=r?r.getNodeType(e):null;if(i===`void`||a===`void`)return`void`;if(t===`%`)return i;if(t===`~`||t===`&`||t===`|`||t===`^`||t===`>>`||t===`<<`)return e.getIntegerType(i);if(t===`!`||t===`&&`||t===`||`||t===`^^`)return`bool`;if(t===`==`||t===`!=`||t===`<`||t===`>`||t===`<=`||t===`>=`){let t=Math.max(e.getTypeLength(i),e.getTypeLength(a));return t>1?`bvec${t}`:`bool`}else{if(e.isMatrix(i)){if(a===`float`)return i;if(e.isVector(a))return e.getVectorFromMatrix(i);if(e.isMatrix(a))return i}else if(e.isMatrix(a)){if(i===`float`)return a;if(e.isVector(i))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(i)?a:i}}generate(e,t){let n=this.op,{aNode:r,bNode:i}=this,a=this.getNodeType(e),o=null,s=null;a===`void`?o=s=a:(o=r.getNodeType(e),s=i?i.getNodeType(e):null,n===`<`||n===`>`||n===`<=`||n===`>=`||n===`==`||n===`!=`?e.isVector(o)?s=o:e.isVector(s)?o=s:o!==s&&(o=s=`float`):n===`>>`||n===`<<`?(o=a,s=e.changeComponentType(s,`uint`)):n===`%`?(o=a,s=e.isInteger(o)&&e.isInteger(s)?s:o):e.isMatrix(o)?s===`float`?s=`float`:e.isVector(s)?s=e.getVectorFromMatrix(o):e.isMatrix(s)||(o=s=a):o=e.isMatrix(s)?o===`float`?`float`:e.isVector(o)?e.getVectorFromMatrix(s):s=a:s=a);let c=r.build(e,o),l=i?i.build(e,s):null,u=e.getFunctionOperator(n);if(t!==`void`){let r=e.renderer.coordinateSystem===wY;if(n===`==`||n===`!=`||n===`<`||n===`>`||n===`<=`||n===`>=`)return r&&e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${l} )`,a,t):e.format(`( ${c} ${n} ${l} )`,a,t);if(n===`%`)return e.isInteger(s)?e.format(`( ${c} % ${l} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${l} )`,a,t);if(n===`!`||n===`~`)return e.format(`(${n}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${l} )`,a,t);if(e.isMatrix(o)&&s===`float`)return e.format(`( ${l} ${n} ${c} )`,a,t);if(o===`float`&&e.isMatrix(s))return e.format(`${c} ${n} ${l}`,a,t);{let i=`( ${c} ${n} ${l} )`;return!r&&a===`bool`&&e.isVector(o)&&e.isVector(s)&&(i=`all${i}`),e.format(i,a,t)}}else if(o!==`void`)return u?e.format(`${u}( ${c}, ${l} )`,a,t):e.isMatrix(o)&&s===`float`?e.format(`${l} ${n} ${c}`,a,t):e.format(`${c} ${n} ${l}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}};const u2=W(l2,`+`).setParameterLength(2,1/0).setName(`add`),d2=W(l2,`-`).setParameterLength(2,1/0).setName(`sub`),f2=W(l2,`*`).setParameterLength(2,1/0).setName(`mul`),p2=W(l2,`/`).setParameterLength(2,1/0).setName(`div`),m2=W(l2,`%`).setParameterLength(2).setName(`mod`),h2=W(l2,`==`).setParameterLength(2).setName(`equal`),g2=W(l2,`!=`).setParameterLength(2).setName(`notEqual`),_2=W(l2,`<`).setParameterLength(2).setName(`lessThan`),v2=W(l2,`>`).setParameterLength(2).setName(`greaterThan`),y2=W(l2,`<=`).setParameterLength(2).setName(`lessThanEqual`),b2=W(l2,`>=`).setParameterLength(2).setName(`greaterThanEqual`),x2=W(l2,`&&`).setParameterLength(2,1/0).setName(`and`),S2=W(l2,`||`).setParameterLength(2,1/0).setName(`or`),C2=W(l2,`!`).setParameterLength(1).setName(`not`),w2=W(l2,`^^`).setParameterLength(2).setName(`xor`),T2=W(l2,`&`).setParameterLength(2).setName(`bitAnd`),E2=W(l2,`~`).setParameterLength(2).setName(`bitNot`),D2=W(l2,`|`).setParameterLength(2).setName(`bitOr`),O2=W(l2,`^`).setParameterLength(2).setName(`bitXor`),k2=W(l2,`<<`).setParameterLength(2).setName(`shiftLeft`),A2=W(l2,`>>`).setParameterLength(2).setName(`shiftRight`),j2=K(([e])=>(e.addAssign(1),e)),M2=K(([e])=>(e.subAssign(1),e)),N2=K(([e])=>{let t=J(e).toConst();return e.addAssign(1),t}),P2=K(([e])=>{let t=J(e).toConst();return e.subAssign(1),t});H(`add`,u2),H(`sub`,d2),H(`mul`,f2),H(`div`,p2),H(`mod`,m2),H(`equal`,h2),H(`notEqual`,g2),H(`lessThan`,_2),H(`greaterThan`,v2),H(`lessThanEqual`,y2),H(`greaterThanEqual`,b2),H(`and`,x2),H(`or`,S2),H(`not`,C2),H(`xor`,w2),H(`bitAnd`,T2),H(`bitNot`,E2),H(`bitOr`,D2),H(`bitXor`,O2),H(`shiftLeft`,k2),H(`shiftRight`,A2),H(`incrementBefore`,j2),H(`decrementBefore`,M2),H(`increment`,N2),H(`decrement`,P2);const F2=(e,t)=>(console.warn(`THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.`),m2(e,t)),I2=(e,t)=>(console.warn(`THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.`),m2(J(e),J(t)));H(`remainder`,F2),H(`modInt`,I2);var Z=class e extends e1{static get type(){return`MathNode`}constructor(t,n,r=null,i=null){if(super(),(t===e.MAX||t===e.MIN)&&arguments.length>3){let a=new e(t,n,r);for(let n=2;n<arguments.length-1;n++)a=new e(t,a,arguments[n]);n=a,r=arguments[arguments.length-1],i=null}this.method=t,this.aNode=n,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),o=e.isMatrix(r)?0:e.getTypeLength(r);return i>a&&i>o?t:a>o?n:o>i?r:t}getNodeType(t){let n=this.method;return n===e.LENGTH||n===e.DISTANCE||n===e.DOT?`float`:n===e.CROSS?`vec3`:n===e.ALL||n===e.ANY?`bool`:n===e.EQUALS?t.changeComponentType(this.aNode.getNodeType(t),`bool`):this.getInputType(t)}setup(t){let{aNode:n,bNode:r,method:i}=this,a=null;if(i===e.ONE_MINUS)a=d2(1,n);else if(i===e.RECIPROCAL)a=p2(1,n);else if(i===e.DIFFERENCE)a=s4(d2(n,r));else if(i===e.TRANSFORM_DIRECTION){let e=n,i=r;t.isMatrix(e.getNodeType(t))?i=r0(X(i),0):e=r0(X(e),0);let o=f2(e,i).xyz;a=$2(o)}return a===null?super.setup(t):a}generate(t,n){let r=t.getNodeProperties(this);if(r.outputNode)return super.generate(t,n);let i=this.method,a=this.getNodeType(t),o=this.getInputType(t),s=this.aNode,c=this.bNode,l=this.cNode,u=t.renderer.coordinateSystem;if(i===e.NEGATE)return t.format(`( - `+s.build(t,o)+` )`,a,n);{let r=[];return i===e.CROSS?r.push(s.build(t,a),c.build(t,a)):u===wY&&i===e.STEP?r.push(s.build(t,t.getTypeLength(s.getNodeType(t))===1?`float`:o),c.build(t,o)):u===wY&&(i===e.MIN||i===e.MAX)?r.push(s.build(t,o),c.build(t,t.getTypeLength(c.getNodeType(t))===1?`float`:o)):i===e.REFRACT?r.push(s.build(t,o),c.build(t,o),l.build(t,`float`)):i===e.MIX?r.push(s.build(t,o),c.build(t,o),l.build(t,t.getTypeLength(l.getNodeType(t))===1?`float`:o)):(u===TY&&i===e.ATAN&&c!==null&&(i=`atan2`),t.shaderStage!==`fragment`&&(i===e.DFDX||i===e.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${t.shaderStage} stage.`),i=`/*`+i+`*/`),r.push(s.build(t,o)),c!==null&&r.push(c.build(t,o)),l!==null&&r.push(l.build(t,o))),t.format(`${t.getMethod(i,a)}( ${r.join(`, `)} )`,a,n)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}};Z.ALL=`all`,Z.ANY=`any`,Z.RADIANS=`radians`,Z.DEGREES=`degrees`,Z.EXP=`exp`,Z.EXP2=`exp2`,Z.LOG=`log`,Z.LOG2=`log2`,Z.SQRT=`sqrt`,Z.INVERSE_SQRT=`inversesqrt`,Z.FLOOR=`floor`,Z.CEIL=`ceil`,Z.NORMALIZE=`normalize`,Z.FRACT=`fract`,Z.SIN=`sin`,Z.COS=`cos`,Z.TAN=`tan`,Z.ASIN=`asin`,Z.ACOS=`acos`,Z.ATAN=`atan`,Z.ABS=`abs`,Z.SIGN=`sign`,Z.LENGTH=`length`,Z.NEGATE=`negate`,Z.ONE_MINUS=`oneMinus`,Z.DFDX=`dFdx`,Z.DFDY=`dFdy`,Z.ROUND=`round`,Z.RECIPROCAL=`reciprocal`,Z.TRUNC=`trunc`,Z.FWIDTH=`fwidth`,Z.TRANSPOSE=`transpose`,Z.BITCAST=`bitcast`,Z.EQUALS=`equals`,Z.MIN=`min`,Z.MAX=`max`,Z.STEP=`step`,Z.REFLECT=`reflect`,Z.DISTANCE=`distance`,Z.DIFFERENCE=`difference`,Z.DOT=`dot`,Z.CROSS=`cross`,Z.POW=`pow`,Z.TRANSFORM_DIRECTION=`transformDirection`,Z.MIX=`mix`,Z.CLAMP=`clamp`,Z.REFRACT=`refract`,Z.SMOOTHSTEP=`smoothstep`,Z.FACEFORWARD=`faceforward`;const L2=q(1e-6),R2=q(1e6),z2=q(Math.PI),B2=q(Math.PI*2),V2=W(Z,Z.ALL).setParameterLength(1),H2=W(Z,Z.ANY).setParameterLength(1),U2=W(Z,Z.RADIANS).setParameterLength(1),W2=W(Z,Z.DEGREES).setParameterLength(1),G2=W(Z,Z.EXP).setParameterLength(1),K2=W(Z,Z.EXP2).setParameterLength(1),q2=W(Z,Z.LOG).setParameterLength(1),J2=W(Z,Z.LOG2).setParameterLength(1),Y2=W(Z,Z.SQRT).setParameterLength(1),X2=W(Z,Z.INVERSE_SQRT).setParameterLength(1),Z2=W(Z,Z.FLOOR).setParameterLength(1),Q2=W(Z,Z.CEIL).setParameterLength(1),$2=W(Z,Z.NORMALIZE).setParameterLength(1),e4=W(Z,Z.FRACT).setParameterLength(1),t4=W(Z,Z.SIN).setParameterLength(1),n4=W(Z,Z.COS).setParameterLength(1),r4=W(Z,Z.TAN).setParameterLength(1),i4=W(Z,Z.ASIN).setParameterLength(1),a4=W(Z,Z.ACOS).setParameterLength(1),o4=W(Z,Z.ATAN).setParameterLength(1,2),s4=W(Z,Z.ABS).setParameterLength(1),c4=W(Z,Z.SIGN).setParameterLength(1),l4=W(Z,Z.LENGTH).setParameterLength(1),u4=W(Z,Z.NEGATE).setParameterLength(1),d4=W(Z,Z.ONE_MINUS).setParameterLength(1),f4=W(Z,Z.DFDX).setParameterLength(1),p4=W(Z,Z.DFDY).setParameterLength(1),m4=W(Z,Z.ROUND).setParameterLength(1),h4=W(Z,Z.RECIPROCAL).setParameterLength(1),g4=W(Z,Z.TRUNC).setParameterLength(1),_4=W(Z,Z.FWIDTH).setParameterLength(1),v4=W(Z,Z.TRANSPOSE).setParameterLength(1),y4=W(Z,Z.BITCAST).setParameterLength(2),b4=(e,t)=>(console.warn(`THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"`),h2(e,t)),x4=W(Z,Z.MIN).setParameterLength(2,1/0),S4=W(Z,Z.MAX).setParameterLength(2,1/0),C4=W(Z,Z.STEP).setParameterLength(2),w4=W(Z,Z.REFLECT).setParameterLength(2),T4=W(Z,Z.DISTANCE).setParameterLength(2),E4=W(Z,Z.DIFFERENCE).setParameterLength(2),D4=W(Z,Z.DOT).setParameterLength(2),O4=W(Z,Z.CROSS).setParameterLength(2),k4=W(Z,Z.POW).setParameterLength(2),A4=W(Z,Z.POW,2).setParameterLength(1),j4=W(Z,Z.POW,3).setParameterLength(1),M4=W(Z,Z.POW,4).setParameterLength(1),N4=W(Z,Z.TRANSFORM_DIRECTION).setParameterLength(2),P4=e=>f2(c4(e),k4(s4(e),1/3)),F4=e=>D4(e,e),I4=W(Z,Z.MIX).setParameterLength(3),L4=(e,t=0,n=1)=>U(new Z(Z.CLAMP,U(e),U(t),U(n))),R4=e=>L4(e),z4=W(Z,Z.REFRACT).setParameterLength(3),B4=W(Z,Z.SMOOTHSTEP).setParameterLength(3),V4=W(Z,Z.FACEFORWARD).setParameterLength(3),H4=K(([e])=>{let t=12.9898,n=78.233,r=43758.5453,i=D4(e.xy,Y(t,n)),a=m2(i,z2);return e4(t4(a).mul(r))}),U4=(e,t,n)=>I4(t,n,e),W4=(e,t,n)=>B4(t,n,e),G4=(e,t)=>(console.warn(`THREE.TSL: "atan2" is overloaded. Use "atan" instead.`),o4(e,t)),K4=V4,q4=X2;H(`all`,V2),H(`any`,H2),H(`equals`,b4),H(`radians`,U2),H(`degrees`,W2),H(`exp`,G2),H(`exp2`,K2),H(`log`,q2),H(`log2`,J2),H(`sqrt`,Y2),H(`inverseSqrt`,X2),H(`floor`,Z2),H(`ceil`,Q2),H(`normalize`,$2),H(`fract`,e4),H(`sin`,t4),H(`cos`,n4),H(`tan`,r4),H(`asin`,i4),H(`acos`,a4),H(`atan`,o4),H(`abs`,s4),H(`sign`,c4),H(`length`,l4),H(`lengthSq`,F4),H(`negate`,u4),H(`oneMinus`,d4),H(`dFdx`,f4),H(`dFdy`,p4),H(`round`,m4),H(`reciprocal`,h4),H(`trunc`,g4),H(`fwidth`,_4),H(`atan2`,G4),H(`min`,x4),H(`max`,S4),H(`step`,C4),H(`reflect`,w4),H(`distance`,T4),H(`dot`,D4),H(`cross`,O4),H(`pow`,k4),H(`pow2`,A4),H(`pow3`,j4),H(`pow4`,M4),H(`transformDirection`,N4),H(`mix`,U4),H(`clamp`,L4),H(`refract`,z4),H(`smoothstep`,W4),H(`faceForward`,V4),H(`difference`,E4),H(`saturate`,R4),H(`cbrt`,P4),H(`transpose`,v4),H(`rand`,H4);var J4=class extends Z${static get type(){return`ConditionalNode`}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){let{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);let r=t.getNodeType(e);if(n!==null){let t=n.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(r))return t}return r}setup(e){let t=this.condNode.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():null,i=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=i,r!==null&&(e.getDataFromNode(r).parentNodeBlock=i);let a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n.context({nodeBlock:n}),a.elseNode=r?r.context({nodeBlock:r}):null}generate(e,t){let n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;let{condNode:i,ifNode:a,elseNode:o}=e.getNodeProperties(this),s=e.currentFunctionNode,c=t!==`void`,l=c?v0(n).build(e):``;r.nodeProperty=l;let u=i.build(e,`bool`);e.addFlowCode(`\n${e.tab}if ( ${u} ) {\n\n`).addFlowTab();let d=a.build(e,n);if(d&&(c?d=l+` = `+d+`;`:(d=`return `+d+`;`,s===null&&(console.warn(`THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.`),d=`// `+d))),e.removeFlowTab().addFlowCode(e.tab+` `+d+`
|
|
411
411
|
|
|
412
412
|
`+e.tab+`}`),o!==null){e.addFlowCode(` else {
|
|
413
413
|
|
|
@@ -417,20 +417,20 @@ var<${n}> ${e} : ${a};`}},oj=class{constructor(e){this.backend=e}getCurrentDepth
|
|
|
417
417
|
|
|
418
418
|
`)}else e.addFlowCode(`
|
|
419
419
|
|
|
420
|
-
`);return e.format(l,n,t)}};const X4=W(Y4).setParameterLength(2,3);H(`select`,X4);const Z4=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),X4(...e));H(`cond`,Z4);var Q4=class extends Q${static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const $4=W(Q4).setParameterLength(1,2),e3=(e,t)=>$4(e,{label:t});H(`context`,$4),H(`label`,e3);var poe=class extends Q${static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const t3=W(poe),n3=(e,t=null)=>t3(e,t).toStack(),r3=(e,t=null)=>t3(e,t,!0).toStack();H(`toVar`,n3),H(`toConst`,r3);const i3=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),t3(e));H(`temp`,i3);var moe=class extends Q${static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=this.node}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(H$.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(H$.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,H$.VERTEX);e.flowNodeFromShaderStage(H$.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const a3=W(moe).setParameterLength(1,2),o3=e=>a3(e);H(`toVarying`,a3),H(`toVertexStage`,o3),H(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),a3(...e))),H(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),a3(...e)));const s3=K(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=L4(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),c3=K(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=L4(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),l3=`WorkingColorSpace`,hoe=`OutputColorSpace`;var u3=class extends t1{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===l3?mX.workingColorSpace:t===hoe?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return mX.enabled===!1||n===r||!n||!r?i:(mX.getTransfer(n)===fY&&(i=i0(s3(i.rgb),i.a)),mX.getPrimaries(n)!==mX.getPrimaries(r)&&(i=i0(l0(mX._getMatrix(new aX,n,r)).mul(i.rgb),i.a)),mX.getTransfer(r)===fY&&(i=i0(c3(i.rgb),i.a)),i)}};const d3=(e,t)=>U(new u3(U(e),l3,t)),f3=(e,t)=>U(new u3(U(e),t,l3)),goe=(e,t,n)=>U(new u3(U(e),t,n));H(`workingToColorSpace`,d3),H(`colorSpaceToWorking`,f3);let _oe=class extends $${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};var voe=class extends Q${static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=U$.OBJECT}setGroup(e){return this.group=e,this}element(e){return U(new _oe(this,U(e)))}setNodeType(e){let t=n2(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},yoe=class extends voe{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup($0)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const p3=(e,t,n=null)=>U(new yoe(e,t,n));var boe=class extends t1{static get type(){return`ToneMappingNode`}constructor(e,t=h3,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return D$(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===NJ)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=i0(i(t.rgb,this.exposureNode),t.a),r}};const m3=(e,t,n)=>U(new boe(e,U(t),U(n))),h3=p3(`toneMappingExposure`,`float`);H(`toneMapping`,(e,t,n)=>m3(t,n,e));var xoe=class extends s1{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=CY,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new PQ(n,i),s=new IQ(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=a3(this);i=n.build(e,t)}return i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};const g3=(e,t=null,n=0,r=0)=>U(new xoe(e,t,n,r)),_3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setUsage(wY),v3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setInstanced(!0),y3=(e,t=null,n=0,r=0)=>_3(e,t,n,r).setInstanced(!0);H(`toAttribute`,e=>g3(e.value));var Soe=class extends Q${static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=U$.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const b3=(e,t,n)=>U(new Soe(U(e),t,n));H(`compute`,b3);var Coe=class extends Q${static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const x3=(e,t)=>U(new Coe(U(e),t)),S3=(e,t)=>e.context({namespace:t});H(`cache`,x3);var woe=class extends Q${static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const C3=W(woe).setParameterLength(2);H(`bypass`,C3);var w3=class extends Q${static get type(){return`RemapNode`}constructor(e,t,n,r=q(0),i=q(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const T3=W(w3,null,null,{doClamp:!1}).setParameterLength(3,5),E3=W(w3).setParameterLength(3,5);H(`remap`,T3),H(`remapClamp`,E3);var Toe=class extends Q${static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const D3=W(Toe).setParameterLength(1,2),O3=e=>(e?X4(e,D3(`discard`)):D3(`discard`)).toStack(),Eoe=()=>D3(`return`).toStack();H(`discard`,O3);var Doe=class extends t1{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||NJ,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||cY;return n!==NJ&&(t=t.toneMapping(n)),r!==cY&&r!==mX.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const k3=(e,t=null,n=null)=>U(new Doe(U(e),t,n));H(`renderOutput`,k3);var Ooe=class extends t1{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
|
|
420
|
+
`);return e.format(l,n,t)}};const Y4=W(J4).setParameterLength(2,3);H(`select`,Y4);const X4=(...e)=>(console.warn(`THREE.TSL: cond() has been renamed to select().`),Y4(...e));H(`cond`,X4);var Z4=class extends Z${static get type(){return`ContextNode`}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}setup(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}generate(e,t){let n=e.getContext();e.setContext({...e.context,...this.value});let r=this.node.build(e,t);return e.setContext(n),r}};const Q4=W(Z4).setParameterLength(1,2),$4=(e,t)=>Q4(e,{label:t});H(`context`,Q4),H(`label`,$4);var e3=class extends Z${static get type(){return`VarNode`}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){let{node:t,name:n,readOnly:r}=this,{renderer:i}=e,a=i.backend.isWebGPUBackend===!0,o=!1,s=!1;r&&(o=e.isDeterministic(t),s=a?r:o);let c=e.getVectorType(this.getNodeType(e)),l=t.build(e,c),u=e.getVarFromNode(this,n,c,void 0,s),d=e.getPropertyName(u),f=d;if(s)if(a)f=o?`const ${d}`:`let ${d}`;else{let n=e.getArrayCount(t);f=`const ${e.getVar(u.type,d,n)}`}return e.addLineFlowCode(`${f} = ${l}`,this),d}};const t3=W(e3),n3=(e,t=null)=>t3(e,t).toStack(),r3=(e,t=null)=>t3(e,t,!0).toStack();H(`toVar`,n3),H(`toConst`,r3);const i3=e=>(console.warn(`TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.`),t3(e));H(`temp`,i3);var doe=class extends Z${static get type(){return`VaryingNode`}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){let t=e.getNodeProperties(this),n=t.varying;if(n===void 0){let r=this.name,i=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,i,a,o),t.node=this.node}return n.needsInterpolation||=e.shaderStage===`fragment`,n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(V$.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(V$.VERTEX,this.node)}generate(e){let t=e.getNodeProperties(this),n=this.setupVarying(e);if(t.propertyName===void 0){let r=this.getNodeType(e),i=e.getPropertyName(n,V$.VERTEX);e.flowNodeFromShaderStage(V$.VERTEX,this.node,r,i),t.propertyName=i}return e.getPropertyName(n)}};const a3=W(doe).setParameterLength(1,2),o3=e=>a3(e);H(`toVarying`,a3),H(`toVertexStage`,o3),H(`varying`,(...e)=>(console.warn(`THREE.TSL: .varying() has been renamed to .toVarying().`),a3(...e))),H(`vertexStage`,(...e)=>(console.warn(`THREE.TSL: .vertexStage() has been renamed to .toVertexStage().`),a3(...e)));const s3=K(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),n=e.mul(.0773993808),r=e.lessThanEqual(.04045),i=I4(t,n,r);return i}).setLayout({name:`sRGBTransferEOTF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),c3=K(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),n=e.mul(12.92),r=e.lessThanEqual(.0031308),i=I4(t,n,r);return i}).setLayout({name:`sRGBTransferOETF`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),l3=`WorkingColorSpace`,foe=`OutputColorSpace`;var u3=class extends e1{static get type(){return`ColorSpaceNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===l3?pX.workingColorSpace:t===foe?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target),i=t;return pX.enabled===!1||n===r||!n||!r?i:(pX.getTransfer(n)===dY&&(i=r0(s3(i.rgb),i.a)),pX.getPrimaries(n)!==pX.getPrimaries(r)&&(i=r0(c0(pX._getMatrix(new iX,n,r)).mul(i.rgb),i.a)),pX.getTransfer(r)===dY&&(i=r0(c3(i.rgb),i.a)),i)}};const d3=(e,t)=>U(new u3(U(e),l3,t)),f3=(e,t)=>U(new u3(U(e),t,l3)),poe=(e,t,n)=>U(new u3(U(e),t,n));H(`workingToColorSpace`,d3),H(`colorSpaceToWorking`,f3);let moe=class extends Q${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};var hoe=class extends Z${static get type(){return`ReferenceBaseNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.updateType=H$.OBJECT}setGroup(e){return this.group=e,this}element(e){return U(new moe(this,U(e)))}setNodeType(e){let t=t2(null,e).getSelf();this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}},goe=class extends hoe{static get type(){return`RendererReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Q0)}updateReference(e){return this.reference=this.renderer===null?e.renderer:this.renderer,this.reference}};const p3=(e,t,n=null)=>U(new goe(e,t,n));var _oe=class extends e1{static get type(){return`ToneMappingNode`}constructor(e,t=h3,n=null){super(`vec3`),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return E$(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,n=this.toneMapping;if(n===MJ)return t;let r=null,i=e.renderer.library.getToneMappingFunction(n);return i===null?(console.error(`ToneMappingNode: Unsupported Tone Mapping configuration.`,n),r=t):r=r0(i(t.rgb,this.exposureNode),t.a),r}};const m3=(e,t,n)=>U(new _oe(e,U(t),U(n))),h3=p3(`toneMappingExposure`,`float`);H(`toneMapping`,(e,t,n)=>m3(t,n,e));var voe=class extends o1{static get type(){return`BufferAttributeNode`}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=SY,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;let t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),i=this.bufferStride||r,a=this.bufferOffset,o=n.isInterleavedBuffer===!0?n:new NQ(n,i),s=new FQ(o,r,a);o.setUsage(this.usage),this.attribute=s,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n),i=null;if(e.shaderStage===`vertex`||e.shaderStage===`compute`)this.name=r,i=r;else{let n=a3(this);i=n.build(e,t)}return i}getInputType(){return`bufferAttribute`}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}};const g3=(e,t=null,n=0,r=0)=>U(new voe(e,t,n,r)),_3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setUsage(CY),v3=(e,t=null,n=0,r=0)=>g3(e,t,n,r).setInstanced(!0),y3=(e,t=null,n=0,r=0)=>_3(e,t,n,r).setInstanced(!0);H(`toAttribute`,e=>g3(e.value));var yoe=class extends Z${static get type(){return`ComputeNode`}constructor(e,t,n=[64]){super(`void`),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=n,this.dispatchCount=0,this.version=1,this.name=``,this.updateBeforeType=H$.OBJECT,this.onInitFunction=null,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:`dispose`})}label(e){return this.name=e,this}updateDispatchCount(){let{count:e,workgroupSize:t}=this,n=t[0];for(let e=1;e<t.length;e++)n*=t[e];this.dispatchCount=Math.ceil(e/n)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);if(t){let n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){let{shaderStage:n}=e;if(n===`compute`){let t=this.computeNode.build(e,`void`);t!==``&&e.addLineFlowCode(t,this)}else{let n=e.getNodeProperties(this),r=n.outputComputeNode;if(r)return r.build(e,t)}}};const b3=(e,t,n)=>U(new yoe(U(e),t,n));H(`compute`,b3);var boe=class extends Z${static get type(){return`CacheNode`}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){let t=e.getCache(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);let r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){let n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.build(e,...t);return e.setCache(n),i}};const x3=(e,t)=>U(new boe(U(e),t)),S3=(e,t)=>e.context({namespace:t});H(`cache`,x3);var xoe=class extends Z${static get type(){return`BypassNode`}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){let t=this.callNode.build(e,`void`);return t!==``&&e.addLineFlowCode(t,this),this.outputNode.build(e)}};const C3=W(xoe).setParameterLength(2);H(`bypass`,C3);var w3=class extends Z${static get type(){return`RemapNode`}constructor(e,t,n,r=q(0),i=q(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=i,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:i,doClamp:a}=this,o=e.sub(t).div(n.sub(t));return a===!0&&(o=o.clamp()),o.mul(i.sub(r)).add(r)}};const T3=W(w3,null,null,{doClamp:!1}).setParameterLength(3,5),E3=W(w3).setParameterLength(3,5);H(`remap`,T3),H(`remapClamp`,E3);var Soe=class extends Z${static get type(){return`ExpressionNode`}constructor(e=``,t=`void`){super(t),this.snippet=e}generate(e,t){let n=this.getNodeType(e),r=this.snippet;if(n===`void`)e.addLineFlowCode(r,this);else return e.format(r,n,t)}};const D3=W(Soe).setParameterLength(1,2),O3=e=>(e?Y4(e,D3(`discard`)):D3(`discard`)).toStack(),Coe=()=>D3(`return`).toStack();H(`discard`,O3);var woe=class extends e1{static get type(){return`RenderOutputNode`}constructor(e,t,n){super(`vec4`),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,n=(this.toneMapping===null?e.toneMapping:this.toneMapping)||MJ,r=(this.outputColorSpace===null?e.outputColorSpace:this.outputColorSpace)||sY;return n!==MJ&&(t=t.toneMapping(n)),r!==sY&&r!==pX.workingColorSpace&&(t=t.workingToColorSpace(r)),t}};const k3=(e,t=null,n=null)=>U(new woe(U(e),t,n));H(`renderOutput`,k3);var Toe=class extends e1{static get type(){return`DebugNode`}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){let t=this.callback,n=this.node.build(e),r=`--- TSL debug - `+e.shaderStage+` shader ---`,i=`-`.repeat(r.length),a=``;return a+=`// #`+r+`#
|
|
421
421
|
`,a+=e.flow.code.replace(/^\t/gm,``)+`
|
|
422
422
|
`,a+=`/* ... */ `+n+` /* ... */
|
|
423
423
|
`,a+=`// #`+i+`#
|
|
424
|
-
`,t===null?console.log(a):t(e,a),n}};const A3=(e,t=null)=>U(new Ooe(U(e),t));H(`debug`,A3);function koe(e){console.warn(`THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var j3=class extends Q${static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e),r=e.hasGeometryAttribute(t);if(r===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);if(e.shaderStage===`vertex`)return e.format(a.name,i,n);{let t=a3(this);return t.build(e,n)}}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}};const M3=(e,t=null)=>U(new j3(e,t)),N3=(e=0)=>M3(`uv`+(e>0?e:``),`vec2`);var Aoe=class extends Q${static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}};const P3=W(Aoe).setParameterLength(1,2);var joe=class extends t2{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=U$.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}};const F3=W(joe).setParameterLength(1),I3=new wX;var L3=class extends t2{static get type(){return`TextureNode`}constructor(e=I3,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=U$.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?`float`:this.value.type===qJ?`uvec4`:this.value.type===KJ?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return N3(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=n2(this.value.matrix)),this._matrixUniform.mul(X(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?U$.OBJECT:U$.NONE,this}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this,e)),r||=this.getDefaultUV(),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s){let c=this.value,l;return l=r?e.generateTextureLevel(c,t,n,r,a):i?e.generateTextureBias(c,t,n,i,a):s?e.generateTextureGrad(c,t,n,s,a):o?e.generateTextureCompare(c,t,n,o,a):this.sampler===!1?e.generateTextureLoad(c,t,n,a):e.generateTexture(c,t,n,a),l}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=a.propertyName;if(o===void 0){let{uvNode:t,levelNode:n,biasNode:s,compareNode:c,depthNode:l,gradNode:u}=r,d=this.generateUV(e,t),f=n?n.build(e,`float`):null,p=s?s.build(e,`float`):null,m=l?l.build(e,`int`):null,h=c?c.build(e,`float`):null,g=u?[u[0].build(e,`vec2`),u[1].build(e,`vec2`)]:null,_=e.getVarFromNode(this);o=e.getPropertyName(_);let v=this.generateSnippet(e,i,d,f,p,m,h,g);e.addLineFlowCode(`${o} = ${v}`,this),a.snippet=v,a.propertyName=o}let s=o,c=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(s=f3(D3(s,c),n.colorSpace).setup(e).build(e,c)),e.format(s,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn(`THREE.TextureNode: .uv() has been renamed. Use .sample() instead.`),this.sample(e)}sample(e){let t=this.clone();return t.uvNode=U(e),t.referenceNode=this.getSelf(),U(t)}blur(e){let t=this.clone();t.biasNode=U(e).mul(F3(t)),t.referenceNode=this.getSelf();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===VJ||n.magFilter===VJ)&&(console.warn(`THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),U(t)}level(e){let t=this.clone();return t.levelNode=U(e),t.referenceNode=this.getSelf(),U(t)}size(e){return P3(this,e)}bias(e){let t=this.clone();return t.biasNode=U(e),t.referenceNode=this.getSelf(),U(t)}compare(e){let t=this.clone();return t.compareNode=U(e),t.referenceNode=this.getSelf(),U(t)}grad(e,t){let n=this.clone();return n.gradNode=[U(e),U(t)],n.referenceNode=this.getSelf(),U(n)}depth(e){let t=this.clone();return t.depthNode=U(e),t.referenceNode=this.getSelf(),U(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}};const Moe=W(L3).setParameterLength(1,4).setName(`texture`),R3=(e=I3,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=Moe(e,t,n,r),i},Noe=(e=I3)=>R3(e),z3=(...e)=>R3(...e).setSampler(!1),Poe=e=>(e.isNode===!0?e:R3(e)).convert(`sampler`),Foe=e=>(e.isNode===!0?e:R3(e)).convert(`samplerComparison`);var B3=class extends t2{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}};const V3=(e,t,n)=>U(new B3(e,t,n));var Ioe=class extends $${static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},H3=class extends B3{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?L$(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=U$.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,super.setup(e)}element(e){return U(new Ioe(this,U(e)))}};const U3=(e,t)=>U(new H3(e,t)),Loe=(e,t)=>(console.warn(`THREE.TSL: uniforms() has been renamed to uniformArray().`),U(new H3(e,t)));var Roe=class extends Q${constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}};const W3=W(Roe).setParameterLength(1),G3=n2(0,`uint`).label(`u_cameraIndex`).setGroup(Z0(`cameraIndex`)).toVarying(`v_cameraIndex`),K3=n2(`float`).label(`cameraNear`).setGroup($0).onRenderUpdate(({camera:e})=>e.near),q3=n2(`float`).label(`cameraFar`).setGroup($0).onRenderUpdate(({camera:e})=>e.far),J3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);let r=U3(n).setGroup($0).label(`cameraProjectionMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrix`)}else t=n2(`mat4`).label(`cameraProjectionMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),zoe=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);let r=U3(n).setGroup($0).label(`cameraProjectionMatricesInverse`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrixInverse`)}else t=n2(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup($0).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Y3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);let r=U3(n).setGroup($0).label(`cameraViewMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraViewMatrix`)}else t=n2(`mat4`).label(`cameraViewMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),Boe=n2(`mat4`).label(`cameraWorldMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.matrixWorld),Voe=n2(`mat3`).label(`cameraNormalMatrix`).setGroup($0).onRenderUpdate(({camera:e})=>e.normalMatrix),Hoe=n2(new V).label(`cameraPosition`).setGroup($0).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),X3=new KX;var Z3=class e extends Q${static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=U$.OBJECT,this.uniformNode=new t2(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new V,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new V,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),X3.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=X3.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Z3.WORLD_MATRIX=`worldMatrix`,Z3.POSITION=`position`,Z3.SCALE=`scale`,Z3.VIEW_POSITION=`viewPosition`,Z3.DIRECTION=`direction`,Z3.RADIUS=`radius`;const Uoe=W(Z3,Z3.DIRECTION).setParameterLength(1),Woe=W(Z3,Z3.WORLD_MATRIX).setParameterLength(1),Q3=W(Z3,Z3.POSITION).setParameterLength(1),Goe=W(Z3,Z3.SCALE).setParameterLength(1),Koe=W(Z3,Z3.VIEW_POSITION).setParameterLength(1),qoe=W(Z3,Z3.RADIUS).setParameterLength(1);var $3=class extends Z3{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};const Joe=G($3,$3.DIRECTION),e6=G($3,$3.WORLD_MATRIX),Yoe=G($3,$3.POSITION),Xoe=G($3,$3.SCALE),Zoe=G($3,$3.VIEW_POSITION),Qoe=G($3,$3.RADIUS),t6=n2(new aX).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),$oe=n2(new tZ).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),n6=K(e=>e.renderer.overrideNodes.modelViewMatrix||r6).once()().toVar(`modelViewMatrix`),r6=Y3.mul(e6),ese=K(e=>(e.context.isHighPrecisionModelViewMatrix=!0,n2(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),tse=K(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return n2(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),i6=M3(`position`,`vec3`),a6=i6.toVarying(`positionLocal`),o6=i6.toVarying(`positionPrevious`),s6=K(e=>e6.mul(a6).xyz.toVarying(e.getNamespace(`v_positionWorld`)),`vec3`).once(`POSITION`)(),c6=K(e=>{let t=a6.transformDirection(e6).toVarying(e.getNamespace(`v_positionWorldDirection`));return t.normalize().toVar(`positionWorldDirection`)},`vec3`).once(`POSITION`)(),l6=K(e=>e.context.setupPositionView().toVarying(e.getNamespace(`v_positionView`)),`vec3`).once(`POSITION`)(),u6=l6.negate().toVarying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`);var nse=class extends Q${static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){let{renderer:t,material:n}=e;return t.coordinateSystem===TY&&n.side===TJ?`false`:e.getFrontFacing()}};const d6=G(nse),f6=q(d6).mul(2).sub(1),p6=M3(`normal`,`vec3`),m6=K(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`THREE.TSL: Vertex attribute "normal" not found on geometry.`),X(0,1,0)):p6,`vec3`).once()().toVar(`normalLocal`),h6=l6.dFdx().cross(l6.dFdy()).normalize().toVar(`normalFlat`),g6=K(e=>{let t;return t=e.material.flatShading===!0?h6:a3(x6(m6),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),_6=K(e=>{let t=g6.transformDirection(Y3);return e.material.flatShading!==!0&&(t=a3(t,`v_normalWorld`)),t},`vec3`).once()().normalize().toVar(`normalWorld`),v6=K(e=>{let t=e.context.setupNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedNormalView`),y6=v6.transformDirection(Y3).toVar(`transformedNormalWorld`),rse=K(e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedClearcoatNormalView`),b6=K(([e,t=e6])=>{let n=l0(t),r=e.div(X(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),x6=K(([e],t)=>{let n=t.renderer.overrideNodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=t6.mul(e);return Y3.transformDirection(r)}),S6=new dZ,C6=new tZ,w6=n2(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),ise=n2(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),T6=n2(new tZ).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(S6.copy(n),C6.makeRotationFromEuler(S6)):C6.identity(),C6}),E6=u6.negate().reflect(v6),D6=u6.negate().refract(v6,w6),O6=E6.transformDirection(Y3).toVar(`reflectVector`),k6=D6.transformDirection(Y3).toVar(`reflectVector`),A6=new NQ;var ase=class extends L3{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===FJ?O6:e.mapping===IJ?k6:(console.error(`THREE.CubeTextureNode: Mapping "%s" not supported.`,e.mapping),X(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return(e.renderer.coordinateSystem===EY||!n.isRenderTargetTexture)&&(t=X(t.x.negate(),t.yz)),T6.mul(t)}generateUV(e,t){return t.build(e,`vec3`)}};const j6=W(ase).setParameterLength(1,4).setName(`cubeTexture`),M6=(e=A6,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=j6(e,t,n,r),i},ose=(e=A6)=>j6(e);var sse=class extends $${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},N6=class extends Q${static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=U$.OBJECT}element(e){return U(new sse(this,U(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?U3(null,e):e===`texture`?R3(null):e===`cubeTexture`?M6(null):n2(null,e):V3(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}};const P6=(e,t,n)=>U(new N6(e,t,n)),F6=(e,t,n,r)=>U(new N6(e,t,r,n));var cse=class extends N6{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}};const I6=(e,t,n=null)=>U(new cse(e,t,n)),L6=K(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),M3(`tangent`,`vec4`)))(),R6=L6.xyz.toVar(`tangentLocal`),z6=n6.mul(i0(R6,0)).xyz.toVarying(`v_tangentView`).normalize().toVar(`tangentView`),B6=z6.transformDirection(Y3).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),V6=z6.toVar(`transformedTangentView`),lse=V6.transformDirection(Y3).normalize().toVar(`transformedTangentWorld`),H6=K(([e,t],n)=>{let r=e.mul(L6.w).xyz;return n.material.flatShading!==!0&&(r=a3(r,t)),r}).once(),use=H6(p6.cross(L6),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),dse=H6(m6.cross(R6),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),U6=H6(g6.cross(z6),`v_bitangentView`).normalize().toVar(`bitangentView`),fse=H6(_6.cross(B6),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),W6=H6(v6.cross(V6),`v_transformedBitangentView`).normalize().toVar(`transformedBitangentView`),pse=W6.transformDirection(Y3).normalize().toVar(`transformedBitangentWorld`),G6=l0(z6,U6,g6),K6=u6.mul(G6),mse=(e,t)=>e.sub(K6.mul(t)),hse=(()=>{let e=F0.cross(u6);return e=e.cross(F0).normalize(),e=L4(e,v6,N0.mul(C0.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),gse=K(e=>{let{eye_pos:t,surf_norm:n,mapN:r,uv:i}=e,a=t.dFdx(),o=t.dFdy(),s=i.dFdx(),c=i.dFdy(),l=n,u=o.cross(l),d=l.cross(a),f=u.mul(s.x).add(d.mul(c.x)),p=u.mul(s.y).add(d.mul(c.y)),m=f.dot(f).max(p.dot(p)),h=f6.mul(m.inverseSqrt());return d2(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()});var _se=class extends t1{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=oY}setup(e){let{normalMapType:t,scaleNode:n}=this,r=this.node.mul(2).sub(1);n!==null&&(r=X(r.xy.mul(n),r.z));let i=null;if(t===sY)i=x6(r);else if(t===oY){let t=e.hasGeometryAttribute(`tangent`);i=t===!0?G6.mul(r).normalize():gse({eye_pos:l6,surf_norm:g6,mapN:r,uv:N3()})}return i}};const q6=W(_se).setParameterLength(1,2),vse=K(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||N3()),forceUVContext:!0}),r=q(n(e=>e));return Y(q(n(e=>e.add(e.dFdx()))).sub(r),q(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),yse=K(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(f6),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()});var bse=class extends t1{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode,t=vse({textureNode:this.textureNode,bumpScale:e});return yse({surf_pos:l6,surf_norm:g6,dHdxy:t})}};const J6=W(bse).setParameterLength(1,2),Y6=new Map;var Q=class e extends Q${static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Y6.get(e);return n===void 0&&(n=I6(e,t),Y6.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?X():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:q(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=q6(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?J6(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):g6;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?q6(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):g6;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(.07,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r),t=c0(r8.x,r8.y,r8.y.negate(),r8.x);i=t.mul(e.rg.mul(2).sub(Y(1)).normalize().mul(e.b))}else i=r8;else if(r===e.IRIDESCENCE_THICKNESS){let e=P6(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=P6(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):q(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};Q.ALPHA_TEST=`alphaTest`,Q.COLOR=`color`,Q.OPACITY=`opacity`,Q.SHININESS=`shininess`,Q.SPECULAR=`specular`,Q.SPECULAR_STRENGTH=`specularStrength`,Q.SPECULAR_INTENSITY=`specularIntensity`,Q.SPECULAR_COLOR=`specularColor`,Q.REFLECTIVITY=`reflectivity`,Q.ROUGHNESS=`roughness`,Q.METALNESS=`metalness`,Q.NORMAL=`normal`,Q.CLEARCOAT=`clearcoat`,Q.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,Q.CLEARCOAT_NORMAL=`clearcoatNormal`,Q.EMISSIVE=`emissive`,Q.ROTATION=`rotation`,Q.SHEEN=`sheen`,Q.SHEEN_ROUGHNESS=`sheenRoughness`,Q.ANISOTROPY=`anisotropy`,Q.IRIDESCENCE=`iridescence`,Q.IRIDESCENCE_IOR=`iridescenceIOR`,Q.IRIDESCENCE_THICKNESS=`iridescenceThickness`,Q.IOR=`ior`,Q.TRANSMISSION=`transmission`,Q.THICKNESS=`thickness`,Q.ATTENUATION_DISTANCE=`attenuationDistance`,Q.ATTENUATION_COLOR=`attenuationColor`,Q.LINE_SCALE=`scale`,Q.LINE_DASH_SIZE=`dashSize`,Q.LINE_GAP_SIZE=`gapSize`,Q.LINE_WIDTH=`linewidth`,Q.LINE_DASH_OFFSET=`dashOffset`,Q.POINT_SIZE=`size`,Q.DISPERSION=`dispersion`,Q.LIGHT_MAP=`light`,Q.AO=`ao`;const X6=G(Q,Q.ALPHA_TEST),Z6=G(Q,Q.COLOR),xse=G(Q,Q.SHININESS),Q6=G(Q,Q.EMISSIVE),$6=G(Q,Q.OPACITY),Sse=G(Q,Q.SPECULAR),Cse=G(Q,Q.SPECULAR_INTENSITY),wse=G(Q,Q.SPECULAR_COLOR),Tse=G(Q,Q.SPECULAR_STRENGTH),Ese=G(Q,Q.REFLECTIVITY),Dse=G(Q,Q.ROUGHNESS),Ose=G(Q,Q.METALNESS),e8=G(Q,Q.NORMAL),kse=G(Q,Q.CLEARCOAT),Ase=G(Q,Q.CLEARCOAT_ROUGHNESS),jse=G(Q,Q.CLEARCOAT_NORMAL),Mse=G(Q,Q.ROTATION),Nse=G(Q,Q.SHEEN),Pse=G(Q,Q.SHEEN_ROUGHNESS),Fse=G(Q,Q.ANISOTROPY),Ise=G(Q,Q.IRIDESCENCE),Lse=G(Q,Q.IRIDESCENCE_IOR),Rse=G(Q,Q.IRIDESCENCE_THICKNESS),zse=G(Q,Q.TRANSMISSION),Bse=G(Q,Q.THICKNESS),Vse=G(Q,Q.IOR),Hse=G(Q,Q.ATTENUATION_DISTANCE),Use=G(Q,Q.ATTENUATION_COLOR),Wse=G(Q,Q.LINE_SCALE),Gse=G(Q,Q.LINE_DASH_SIZE),Kse=G(Q,Q.LINE_GAP_SIZE),qse=G(Q,Q.LINE_WIDTH),Jse=G(Q,Q.LINE_DASH_OFFSET),Yse=G(Q,Q.POINT_SIZE),Xse=G(Q,Q.DISPERSION),t8=G(Q,Q.LIGHT_MAP),n8=G(Q,Q.AO),r8=n2(new tX).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),i8=K(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`);var a8=class e extends Q${static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;if(t.shaderStage===`vertex`||t.shaderStage===`compute`)a=i;else{let e=a3(this);a=e.build(t,n)}return a}};a8.VERTEX=`vertex`,a8.INSTANCE=`instance`,a8.SUBGROUP=`subgroup`,a8.INVOCATION_LOCAL=`invocationLocal`,a8.INVOCATION_SUBGROUP=`invocationSubgroup`,a8.DRAW=`draw`;const o8=G(a8,a8.VERTEX),s8=G(a8,a8.INSTANCE),Zse=G(a8,a8.SUBGROUP),Qse=G(a8,a8.INVOCATION_SUBGROUP),$se=G(a8,a8.INVOCATION_LOCAL),c8=G(a8,a8.DRAW);var l8=class extends Q${static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=U$.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{count:t,instanceMatrix:n,instanceColor:r}=this,{instanceMatrixNode:i,instanceColorNode:a}=this;if(i===null){if(t<=1e3)i=V3(n.array,`mat4`,Math.max(t,1)).element(s8);else{let e=new b$(n.array,16,1);this.buffer=e;let t=n.usage===wY?y3:v3,r=[t(e,`vec4`,16,0),t(e,`vec4`,16,4),t(e,`vec4`,16,8),t(e,`vec4`,16,12)];i=u0(...r)}this.instanceMatrixNode=i}if(r&&a===null){let e=new LQ(r.array,3),t=r.usage===wY?y3:v3;this.bufferColor=e,a=X(t(e,`vec3`,3,0)),this.instanceColorNode=a}let o=i.mul(a6).xyz;if(a6.assign(o),e.hasGeometryAttribute(`normal`)){let e=b6(m6,i);m6.assign(e)}this.instanceColorNode!==null&&b0(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==wY&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==wY&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}};const ece=W(l8).setParameterLength(2,3);var tce=class extends l8{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}};const u8=W(tce).setParameterLength(1);var nce=class extends Q${static get type(){return`BatchNode`}constructor(e){super(`void`),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=s8:this.batchingIdNode=c8);let t=K(([e])=>{let t=J(P3(z3(this.batchMesh._indirectTexture),0).x),n=J(e).mod(t),r=J(e).div(t);return z3(this.batchMesh._indirectTexture,Q1(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]}),n=t(J(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=J(P3(z3(r),0).x),a=q(n).mul(4).toInt().toVar(),o=a.mod(i),s=a.div(i),c=u0(z3(r,Q1(o,s)),z3(r,Q1(o.add(1),s)),z3(r,Q1(o.add(2),s)),z3(r,Q1(o.add(3),s))),l=this.batchMesh._colorsTexture;if(l!==null){let e=K(([e])=>{let t=J(P3(z3(l),0).x),n=e,r=n.mod(t),i=n.div(t);return z3(l,Q1(r,i)).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]}),t=e(n);b0(`vec3`,`vBatchColor`).assign(t)}let u=l0(c);a6.assign(c.mul(a6));let d=m6.div(X(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;m6.assign(f),e.hasGeometryAttribute(`tangent`)&&R6.mulAssign(u)}};const d8=W(nce).setParameterLength(1);var rce=class extends $${static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}};const ice=W(rce).setParameterLength(2);var ace=class extends B3{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=M$(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=G$.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return ice(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(G$.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=g3(this.value),this._varying=a3(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}};const f8=(e,t=null,n=0)=>U(new ace(e,t,n)),oce=(e,t,n)=>(console.warn(`THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.`),f8(e,t,n).setPBO(!0)),p8=new WeakMap;var m8=class extends Q${static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=U$.OBJECT,this.skinIndexNode=M3(`skinIndex`,`uvec4`),this.skinWeightNode=M3(`skinWeight`,`vec4`),this.bindMatrixNode=P6(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=P6(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=F6(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=a6,this.toPositionNode=a6,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=d2(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=m6){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=d2(r.x.mul(o),r.y.mul(s),r.z.mul(c),r.w.mul(l));return u=a.mul(u).mul(i),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=F6(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,o6)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)||z$(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&o6.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();m6.assign(t),e.hasGeometryAttribute(`tangent`)&&R6.assign(t)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;p8.get(t)!==e.frameId&&(p8.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const h8=e=>U(new m8(e)),sce=(e,t=null)=>{let n=new m8(e);return n.positionNode=f8(new LQ(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinIndexNode=f8(new LQ(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinWeightNode=f8(new LQ(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.bindMatrixNode=n2(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=n2(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=V3(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,U(n)};var cce=class extends Q${static get type(){return`LoopNode`}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e),i=t.isNode!==!0&&t.type||`int`;n[r]=D3(r,i)}let r=e.addStack();t.returnsNode=this.params[this.params.length-1](n,e),t.stackNode=r;let i=this.params[0];return i.isNode!==!0&&typeof i.update==`function`&&(t.updateNode=K(this.params[0].update)(n)),e.removeStack(),t}getNodeType(e){let{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):`void`}setup(e){this.getProperties(e)}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:let n=e.flowStagesNode(t.updateNode,`void`),r=n.code.replace(/\t|;/g,``);a=r;break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(console.error(`THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number.`),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;let m=e.getVar(l,c)+` = `+r,h=c+` `+u+` `+i;f=`for ( ${m}; ${h}; ${a} )`}e.addFlowCode((r===0?`
|
|
424
|
+
`,t===null?console.log(a):t(e,a),n}};const A3=(e,t=null)=>U(new Toe(U(e),t));H(`debug`,A3);function Eoe(e){console.warn(`THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add`,e)}var j3=class extends Z${static get type(){return`AttributeNode`}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(t===null){let n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){let r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t=`float`}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),n=this.getNodeType(e),r=e.hasGeometryAttribute(t);if(r===!0){let r=e.geometry.getAttribute(t),i=e.getTypeFromAttribute(r),a=e.getAttribute(t,i);if(e.shaderStage===`vertex`)return e.format(a.name,i,n);{let t=a3(this);return t.build(e,n)}}else return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}};const M3=(e,t=null)=>U(new j3(e,t)),N3=(e=0)=>M3(`uv`+(e>0?e:``),`vec2`);var Doe=class extends Z${static get type(){return`TextureSizeNode`}constructor(e,t=null){super(`uvec2`),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let n=this.textureNode.build(e,`property`),r=this.levelNode===null?`0`:this.levelNode.build(e,`int`);return e.format(`${e.getMethod(`textureDimensions`)}( ${n}, ${r} )`,this.getNodeType(e),t)}};const P3=W(Doe).setParameterLength(1,2);var Ooe=class extends e2{static get type(){return`MaxMipLevelNode`}constructor(e){super(0),this._textureNode=e,this.updateType=H$.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){let{width:e,height:t}=n;this.value=Math.log2(Math.max(e,t))}}};const F3=W(Ooe).setParameterLength(1),I3=new CX;var L3=class extends e2{static get type(){return`TextureNode`}constructor(e=I3,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=H$.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return this.value.isDepthTexture===!0?`float`:this.value.type===KJ?`uvec4`:this.value.type===GJ?`ivec4`:`vec4`}getInputType(){return`texture`}getDefaultUV(){return N3(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=t2(this.value.matrix)),this._matrixUniform.mul(X(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?H$.OBJECT:H$.NONE,this}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let n=this.value;if(!n||n.isTexture!==!0)throw Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this,e)),r||=this.getDefaultUV(),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);let i=this.levelNode;i===null&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,this.sampler===!0?`vec2`:`ivec2`)}generateSnippet(e,t,n,r,i,a,o,s){let c=this.value,l;return l=r?e.generateTextureLevel(c,t,n,r,a):i?e.generateTextureBias(c,t,n,i,a):s?e.generateTextureGrad(c,t,n,s,a):o?e.generateTextureCompare(c,t,n,o,a):this.sampler===!1?e.generateTextureLoad(c,t,n,a):e.generateTexture(c,t,n,a),l}generate(e,t){let n=this.value,r=e.getNodeProperties(this),i=super.generate(e,`property`);if(/^sampler/.test(t))return i+`_sampler`;if(e.isReference(t))return i;{let a=e.getDataFromNode(this),o=a.propertyName;if(o===void 0){let{uvNode:t,levelNode:n,biasNode:s,compareNode:c,depthNode:l,gradNode:u}=r,d=this.generateUV(e,t),f=n?n.build(e,`float`):null,p=s?s.build(e,`float`):null,m=l?l.build(e,`int`):null,h=c?c.build(e,`float`):null,g=u?[u[0].build(e,`vec2`),u[1].build(e,`vec2`)]:null,_=e.getVarFromNode(this);o=e.getPropertyName(_);let v=this.generateSnippet(e,i,d,f,p,m,h,g);e.addLineFlowCode(`${o} = ${v}`,this),a.snippet=v,a.propertyName=o}let s=o,c=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(s=f3(D3(s,c),n.colorSpace).setup(e).build(e,c)),e.format(s,c,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return console.warn(`THREE.TextureNode: .uv() has been renamed. Use .sample() instead.`),this.sample(e)}sample(e){let t=this.clone();return t.uvNode=U(e),t.referenceNode=this.getSelf(),U(t)}blur(e){let t=this.clone();t.biasNode=U(e).mul(F3(t)),t.referenceNode=this.getSelf();let n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===BJ||n.magFilter===BJ)&&(console.warn(`THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture.`),t.biasNode=null),U(t)}level(e){let t=this.clone();return t.levelNode=U(e),t.referenceNode=this.getSelf(),U(t)}size(e){return P3(this,e)}bias(e){let t=this.clone();return t.biasNode=U(e),t.referenceNode=this.getSelf(),U(t)}compare(e){let t=this.clone();return t.compareNode=U(e),t.referenceNode=this.getSelf(),U(t)}grad(e,t){let n=this.clone();return n.gradNode=[U(e),U(t)],n.referenceNode=this.getSelf(),U(n)}depth(e){let t=this.clone();return t.depthNode=U(e),t.referenceNode=this.getSelf(),U(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix()}clone(){let e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}};const koe=W(L3).setParameterLength(1,4).setName(`texture`),R3=(e=I3,t=null,n=null,r=null)=>{let i;return e&&e.isTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=koe(e,t,n,r),i},Aoe=(e=I3)=>R3(e),z3=(...e)=>R3(...e).setSampler(!1),joe=e=>(e.isNode===!0?e:R3(e)).convert(`sampler`),Moe=e=>(e.isNode===!0?e:R3(e)).convert(`samplerComparison`);var B3=class extends e2{static get type(){return`BufferNode`}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return`buffer`}};const V3=(e,t,n)=>U(new B3(e,t,n));var Noe=class extends Q${static get type(){return`UniformArrayElementNode`}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}},H3=class extends B3{static get type(){return`UniformArrayNode`}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?I$(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=H$.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t=`vec4`;return e===`mat2`?t=`mat2`:/mat/.test(e)===!0?t=`mat4`:e.charAt(0)===`i`?t=`ivec4`:e.charAt(0)===`u`&&(t=`uvec4`),t}update(){let{array:e,value:t}=this,n=this.elementType;if(n===`float`||n===`int`||n===`uint`)for(let n=0;n<e.length;n++){let r=n*4;t[r]=e[n]}else if(n===`color`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.r,t[r+1]=i.g,t[r+2]=i.b||0}else if(n===`mat2`)for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+3]=i.elements[3]}else if(n===`mat3`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];t[r]=i.elements[0],t[r+1]=i.elements[1],t[r+2]=i.elements[2],t[r+4]=i.elements[3],t[r+5]=i.elements[4],t[r+6]=i.elements[5],t[r+8]=i.elements[6],t[r+9]=i.elements[7],t[r+10]=i.elements[8],t[r+15]=1}else if(n===`mat4`)for(let n=0;n<e.length;n++){let r=n*16,i=e[n];for(let e=0;e<i.elements.length;e++)t[r+e]=i.elements[e]}else for(let n=0;n<e.length;n++){let r=n*4,i=e[n];t[r]=i.x,t[r+1]=i.y,t[r+2]=i.z||0,t[r+3]=i.w||0}}setup(e){let t=this.array.length,n=this.elementType,r=Float32Array,i=this.paddedType,a=e.getTypeLength(i);return n.charAt(0)===`i`&&(r=Int32Array),n.charAt(0)===`u`&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=i,super.setup(e)}element(e){return U(new Noe(this,U(e)))}};const U3=(e,t)=>U(new H3(e,t)),Poe=(e,t)=>(console.warn(`THREE.TSL: uniforms() has been renamed to uniformArray().`),U(new H3(e,t)));var Foe=class extends Z${constructor(e){super(`float`),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}};const W3=W(Foe).setParameterLength(1),G3=t2(0,`uint`).label(`u_cameraIndex`).setGroup(X0(`cameraIndex`)).toVarying(`v_cameraIndex`),K3=t2(`float`).label(`cameraNear`).setGroup(Q0).onRenderUpdate(({camera:e})=>e.near),q3=t2(`float`).label(`cameraFar`).setGroup(Q0).onRenderUpdate(({camera:e})=>e.far),J3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrix);let r=U3(n).setGroup(Q0).label(`cameraProjectionMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrix`)}else t=t2(`mat4`).label(`cameraProjectionMatrix`).setGroup(Q0).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),Ioe=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.projectionMatrixInverse);let r=U3(n).setGroup(Q0).label(`cameraProjectionMatricesInverse`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraProjectionMatrixInverse`)}else t=t2(`mat4`).label(`cameraProjectionMatrixInverse`).setGroup(Q0).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),Y3=K(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let n=[];for(let t of e.cameras)n.push(t.matrixWorldInverse);let r=U3(n).setGroup(Q0).label(`cameraViewMatrices`);t=r.element(e.isMultiViewCamera?W3(`gl_ViewID_OVR`):G3).toVar(`cameraViewMatrix`)}else t=t2(`mat4`).label(`cameraViewMatrix`).setGroup(Q0).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),Loe=t2(`mat4`).label(`cameraWorldMatrix`).setGroup(Q0).onRenderUpdate(({camera:e})=>e.matrixWorld),Roe=t2(`mat3`).label(`cameraNormalMatrix`).setGroup(Q0).onRenderUpdate(({camera:e})=>e.normalMatrix),zoe=t2(new V).label(`cameraPosition`).setGroup(Q0).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),X3=new GX;var Z3=class e extends Z${static get type(){return`Object3DNode`}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=H$.OBJECT,this.uniformNode=new e2(null)}getNodeType(){let t=this.scope;if(t===e.WORLD_MATRIX)return`mat4`;if(t===e.POSITION||t===e.VIEW_POSITION||t===e.DIRECTION||t===e.SCALE)return`vec3`;if(t===e.RADIUS)return`float`}update(t){let n=this.object3d,r=this.uniformNode,i=this.scope;if(i===e.WORLD_MATRIX)r.value=n.matrixWorld;else if(i===e.POSITION)r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld);else if(i===e.SCALE)r.value=r.value||new V,r.value.setFromMatrixScale(n.matrixWorld);else if(i===e.DIRECTION)r.value=r.value||new V,n.getWorldDirection(r.value);else if(i===e.VIEW_POSITION){let e=t.camera;r.value=r.value||new V,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(e.matrixWorldInverse)}else if(i===e.RADIUS){let e=t.object.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),X3.copy(e.boundingSphere).applyMatrix4(n.matrixWorld),r.value=X3.radius}}generate(t){let n=this.scope;return n===e.WORLD_MATRIX?this.uniformNode.nodeType=`mat4`:n===e.POSITION||n===e.VIEW_POSITION||n===e.DIRECTION||n===e.SCALE?this.uniformNode.nodeType=`vec3`:n===e.RADIUS&&(this.uniformNode.nodeType=`float`),this.uniformNode.build(t)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}};Z3.WORLD_MATRIX=`worldMatrix`,Z3.POSITION=`position`,Z3.SCALE=`scale`,Z3.VIEW_POSITION=`viewPosition`,Z3.DIRECTION=`direction`,Z3.RADIUS=`radius`;const Boe=W(Z3,Z3.DIRECTION).setParameterLength(1),Voe=W(Z3,Z3.WORLD_MATRIX).setParameterLength(1),Q3=W(Z3,Z3.POSITION).setParameterLength(1),Hoe=W(Z3,Z3.SCALE).setParameterLength(1),Uoe=W(Z3,Z3.VIEW_POSITION).setParameterLength(1),Woe=W(Z3,Z3.RADIUS).setParameterLength(1);var $3=class extends Z3{static get type(){return`ModelNode`}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}};const Goe=G($3,$3.DIRECTION),e6=G($3,$3.WORLD_MATRIX),Koe=G($3,$3.POSITION),qoe=G($3,$3.SCALE),Joe=G($3,$3.VIEW_POSITION),Yoe=G($3,$3.RADIUS),t6=t2(new iX).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),Xoe=t2(new eZ).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),n6=K(e=>e.renderer.overrideNodes.modelViewMatrix||r6).once()().toVar(`modelViewMatrix`),r6=Y3.mul(e6),Zoe=K(e=>(e.context.isHighPrecisionModelViewMatrix=!0,t2(`mat4`).onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar(`highpModelViewMatrix`),Qoe=K(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return t2(`mat3`).onObjectUpdate(({object:e,camera:n})=>(t!==!0&&e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar(`highpModelNormalViewMatrix`),i6=M3(`position`,`vec3`),a6=i6.toVarying(`positionLocal`),o6=i6.toVarying(`positionPrevious`),s6=K(e=>e6.mul(a6).xyz.toVarying(e.getNamespace(`v_positionWorld`)),`vec3`).once(`POSITION`)(),c6=K(e=>{let t=a6.transformDirection(e6).toVarying(e.getNamespace(`v_positionWorldDirection`));return t.normalize().toVar(`positionWorldDirection`)},`vec3`).once(`POSITION`)(),l6=K(e=>e.context.setupPositionView().toVarying(e.getNamespace(`v_positionView`)),`vec3`).once(`POSITION`)(),u6=l6.negate().toVarying(`v_positionViewDirection`).normalize().toVar(`positionViewDirection`);var $oe=class extends Z${static get type(){return`FrontFacingNode`}constructor(){super(`bool`),this.isFrontFacingNode=!0}generate(e){let{renderer:t,material:n}=e;return t.coordinateSystem===wY&&n.side===wJ?`false`:e.getFrontFacing()}};const d6=G($oe),f6=q(d6).mul(2).sub(1),p6=M3(`normal`,`vec3`),m6=K(e=>e.geometry.hasAttribute(`normal`)===!1?(console.warn(`THREE.TSL: Vertex attribute "normal" not found on geometry.`),X(0,1,0)):p6,`vec3`).once()().toVar(`normalLocal`),h6=l6.dFdx().cross(l6.dFdy()).normalize().toVar(`normalFlat`),g6=K(e=>{let t;return t=e.material.flatShading===!0?h6:a3(x6(m6),`v_normalView`).normalize(),t},`vec3`).once()().toVar(`normalView`),_6=K(e=>{let t=g6.transformDirection(Y3);return e.material.flatShading!==!0&&(t=a3(t,`v_normalWorld`)),t},`vec3`).once()().normalize().toVar(`normalWorld`),v6=K(e=>{let t=e.context.setupNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedNormalView`),y6=v6.transformDirection(Y3).toVar(`transformedNormalWorld`),ese=K(e=>{let t=e.context.setupClearcoatNormal().context({getUV:null});return e.material.flatShading!==!0&&(t=t.mul(f6)),t},`vec3`).once()().toVar(`transformedClearcoatNormalView`),b6=K(([e,t=e6])=>{let n=c0(t),r=e.div(X(n[0].dot(n[0]),n[1].dot(n[1]),n[2].dot(n[2])));return n.mul(r).xyz}),x6=K(([e],t)=>{let n=t.renderer.overrideNodes.modelNormalViewMatrix;if(n!==null)return n.transformDirection(e);let r=t6.mul(e);return Y3.transformDirection(r)}),S6=new uZ,C6=new eZ,w6=t2(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),tse=t2(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),T6=t2(new eZ).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let n=t.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation;return n?(S6.copy(n),C6.makeRotationFromEuler(S6)):C6.identity(),C6}),E6=u6.negate().reflect(v6),D6=u6.negate().refract(v6,w6),O6=E6.transformDirection(Y3).toVar(`reflectVector`),k6=D6.transformDirection(Y3).toVar(`reflectVector`),A6=new MQ;var nse=class extends L3{static get type(){return`CubeTextureNode`}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return`cubeTexture`}getDefaultUV(){let e=this.value;return e.mapping===PJ?O6:e.mapping===FJ?k6:(console.error(`THREE.CubeTextureNode: Mapping "%s" not supported.`,e.mapping),X(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return(e.renderer.coordinateSystem===TY||!n.isRenderTargetTexture)&&(t=X(t.x.negate(),t.yz)),T6.mul(t)}generateUV(e,t){return t.build(e,`vec3`)}};const j6=W(nse).setParameterLength(1,4).setName(`cubeTexture`),M6=(e=A6,t=null,n=null,r=null)=>{let i;return e&&e.isCubeTextureNode===!0?(i=U(e.clone()),i.referenceNode=e.getSelf(),t!==null&&(i.uvNode=U(t)),n!==null&&(i.levelNode=U(n)),r!==null&&(i.biasNode=U(r))):i=j6(e,t,n,r),i},rse=(e=A6)=>j6(e);var ise=class extends Q${static get type(){return`ReferenceElementNode`}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}},N6=class extends Z${static get type(){return`ReferenceNode`}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split(`.`),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=H$.OBJECT}element(e){return U(new ise(this,U(e)))}setGroup(e){return this.group=e,this}label(e){return this.name=e,this}setNodeType(e){let t=null;t=this.count===null?Array.isArray(this.getValueFromReference())?U3(null,e):e===`texture`?R3(null):e===`cubeTexture`?M6(null):t2(null,e):V3(null,e,this.count),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.label(this.name),this.node=t.getSelf()}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,n=e[t[0]];for(let e=1;e<t.length;e++)n=n[t[e]];return n}updateReference(e){return this.reference=this.object===null?e.object:this.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}};const P6=(e,t,n)=>U(new N6(e,t,n)),F6=(e,t,n,r)=>U(new N6(e,t,r,n));var ase=class extends N6{static get type(){return`MaterialReferenceNode`}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material===null?e.material:this.material,this.reference}};const I6=(e,t,n=null)=>U(new ase(e,t,n)),L6=K(e=>(e.geometry.hasAttribute(`tangent`)===!1&&e.geometry.computeTangents(),M3(`tangent`,`vec4`)))(),R6=L6.xyz.toVar(`tangentLocal`),z6=n6.mul(r0(R6,0)).xyz.toVarying(`v_tangentView`).normalize().toVar(`tangentView`),B6=z6.transformDirection(Y3).toVarying(`v_tangentWorld`).normalize().toVar(`tangentWorld`),V6=z6.toVar(`transformedTangentView`),ose=V6.transformDirection(Y3).normalize().toVar(`transformedTangentWorld`),H6=K(([e,t],n)=>{let r=e.mul(L6.w).xyz;return n.material.flatShading!==!0&&(r=a3(r,t)),r}).once(),sse=H6(p6.cross(L6),`v_bitangentGeometry`).normalize().toVar(`bitangentGeometry`),cse=H6(m6.cross(R6),`v_bitangentLocal`).normalize().toVar(`bitangentLocal`),U6=H6(g6.cross(z6),`v_bitangentView`).normalize().toVar(`bitangentView`),lse=H6(_6.cross(B6),`v_bitangentWorld`).normalize().toVar(`bitangentWorld`),W6=H6(v6.cross(V6),`v_transformedBitangentView`).normalize().toVar(`transformedBitangentView`),use=W6.transformDirection(Y3).normalize().toVar(`transformedBitangentWorld`),G6=c0(z6,U6,g6),K6=u6.mul(G6),dse=(e,t)=>e.sub(K6.mul(t)),fse=(()=>{let e=P0.cross(u6);return e=e.cross(P0).normalize(),e=I4(e,v6,M0.mul(S0.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),pse=K(e=>{let{eye_pos:t,surf_norm:n,mapN:r,uv:i}=e,a=t.dFdx(),o=t.dFdy(),s=i.dFdx(),c=i.dFdy(),l=n,u=o.cross(l),d=l.cross(a),f=u.mul(s.x).add(d.mul(c.x)),p=u.mul(s.y).add(d.mul(c.y)),m=f.dot(f).max(p.dot(p)),h=f6.mul(m.inverseSqrt());return u2(f.mul(r.x,h),p.mul(r.y,h),l.mul(r.z)).normalize()});var mse=class extends e1{static get type(){return`NormalMapNode`}constructor(e,t=null){super(`vec3`),this.node=e,this.scaleNode=t,this.normalMapType=aY}setup(e){let{normalMapType:t,scaleNode:n}=this,r=this.node.mul(2).sub(1);n!==null&&(r=X(r.xy.mul(n),r.z));let i=null;if(t===oY)i=x6(r);else if(t===aY){let t=e.hasGeometryAttribute(`tangent`);i=t===!0?G6.mul(r).normalize():pse({eye_pos:l6,surf_norm:g6,mapN:r,uv:N3()})}return i}};const q6=W(mse).setParameterLength(1,2),hse=K(({textureNode:e,bumpScale:t})=>{let n=t=>e.cache().context({getUV:e=>t(e.uvNode||N3()),forceUVContext:!0}),r=q(n(e=>e));return Y(q(n(e=>e.add(e.dFdx()))).sub(r),q(n(e=>e.add(e.dFdy()))).sub(r)).mul(t)}),gse=K(e=>{let{surf_pos:t,surf_norm:n,dHdxy:r}=e,i=t.dFdx().normalize(),a=t.dFdy().normalize(),o=n,s=a.cross(o),c=o.cross(i),l=i.dot(s).mul(f6),u=l.sign().mul(r.x.mul(s).add(r.y.mul(c)));return l.abs().mul(n).sub(u).normalize()});var _se=class extends e1{static get type(){return`BumpMapNode`}constructor(e,t=null){super(`vec3`),this.textureNode=e,this.scaleNode=t}setup(){let e=this.scaleNode===null?1:this.scaleNode,t=hse({textureNode:this.textureNode,bumpScale:e});return gse({surf_pos:l6,surf_norm:g6,dHdxy:t})}};const J6=W(_se).setParameterLength(1,2),Y6=new Map;var Q=class e extends Z${static get type(){return`MaterialNode`}constructor(e){super(),this.scope=e}getCache(e,t){let n=Y6.get(e);return n===void 0&&(n=I6(e,t),Y6.set(e,n)),n}getFloat(e){return this.getCache(e,`float`)}getColor(e){return this.getCache(e,`color`)}getTexture(e){return this.getCache(e===`map`?`map`:e+`Map`,`texture`)}setup(t){let n=t.context.material,r=this.scope,i=null;if(r===e.COLOR){let e=n.color===void 0?X():this.getColor(r);i=n.map&&n.map.isTexture===!0?e.mul(this.getTexture(`map`)):e}else if(r===e.OPACITY){let e=this.getFloat(r);i=n.alphaMap&&n.alphaMap.isTexture===!0?e.mul(this.getTexture(`alpha`)):e}else if(r===e.SPECULAR_STRENGTH)i=n.specularMap&&n.specularMap.isTexture===!0?this.getTexture(`specular`).r:q(1);else if(r===e.SPECULAR_INTENSITY){let e=this.getFloat(r);i=n.specularIntensityMap&&n.specularIntensityMap.isTexture===!0?e.mul(this.getTexture(r).a):e}else if(r===e.SPECULAR_COLOR){let e=this.getColor(r);i=n.specularColorMap&&n.specularColorMap.isTexture===!0?e.mul(this.getTexture(r).rgb):e}else if(r===e.ROUGHNESS){let e=this.getFloat(r);i=n.roughnessMap&&n.roughnessMap.isTexture===!0?e.mul(this.getTexture(r).g):e}else if(r===e.METALNESS){let e=this.getFloat(r);i=n.metalnessMap&&n.metalnessMap.isTexture===!0?e.mul(this.getTexture(r).b):e}else if(r===e.EMISSIVE){let e=this.getFloat(`emissiveIntensity`),t=this.getColor(r).mul(e);i=n.emissiveMap&&n.emissiveMap.isTexture===!0?t.mul(this.getTexture(r)):t}else if(r===e.NORMAL)n.normalMap?(i=q6(this.getTexture(`normal`),this.getCache(`normalScale`,`vec2`)),i.normalMapType=n.normalMapType):i=n.bumpMap?J6(this.getTexture(`bump`).r,this.getFloat(`bumpScale`)):g6;else if(r===e.CLEARCOAT){let e=this.getFloat(r);i=n.clearcoatMap&&n.clearcoatMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=n.clearcoatRoughnessMap&&n.clearcoatRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).r):e}else if(r===e.CLEARCOAT_NORMAL)i=n.clearcoatNormalMap?q6(this.getTexture(r),this.getCache(r+`Scale`,`vec2`)):g6;else if(r===e.SHEEN){let e=this.getColor(`sheenColor`).mul(this.getFloat(`sheen`));i=n.sheenColorMap&&n.sheenColorMap.isTexture===!0?e.mul(this.getTexture(`sheenColor`).rgb):e}else if(r===e.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=n.sheenRoughnessMap&&n.sheenRoughnessMap.isTexture===!0?e.mul(this.getTexture(r).a):e,i=i.clamp(.07,1)}else if(r===e.ANISOTROPY)if(n.anisotropyMap&&n.anisotropyMap.isTexture===!0){let e=this.getTexture(r),t=s0(r8.x,r8.y,r8.y.negate(),r8.x);i=t.mul(e.rg.mul(2).sub(Y(1)).normalize().mul(e.b))}else i=r8;else if(r===e.IRIDESCENCE_THICKNESS){let e=P6(`1`,`float`,n.iridescenceThicknessRange);if(n.iridescenceThicknessMap){let t=P6(`0`,`float`,n.iridescenceThicknessRange);i=e.sub(t).mul(this.getTexture(r).g).add(t)}else i=e}else if(r===e.TRANSMISSION){let e=this.getFloat(r);i=n.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===e.THICKNESS){let e=this.getFloat(r);i=n.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===e.IOR)i=this.getFloat(r);else if(r===e.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat(`lightMapIntensity`));else if(r===e.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat(`aoMapIntensity`)).add(1);else if(r===e.LINE_DASH_OFFSET)i=n.dashOffset?this.getFloat(r):q(0);else{let e=this.getNodeType(t);i=this.getCache(r,e)}return i}};Q.ALPHA_TEST=`alphaTest`,Q.COLOR=`color`,Q.OPACITY=`opacity`,Q.SHININESS=`shininess`,Q.SPECULAR=`specular`,Q.SPECULAR_STRENGTH=`specularStrength`,Q.SPECULAR_INTENSITY=`specularIntensity`,Q.SPECULAR_COLOR=`specularColor`,Q.REFLECTIVITY=`reflectivity`,Q.ROUGHNESS=`roughness`,Q.METALNESS=`metalness`,Q.NORMAL=`normal`,Q.CLEARCOAT=`clearcoat`,Q.CLEARCOAT_ROUGHNESS=`clearcoatRoughness`,Q.CLEARCOAT_NORMAL=`clearcoatNormal`,Q.EMISSIVE=`emissive`,Q.ROTATION=`rotation`,Q.SHEEN=`sheen`,Q.SHEEN_ROUGHNESS=`sheenRoughness`,Q.ANISOTROPY=`anisotropy`,Q.IRIDESCENCE=`iridescence`,Q.IRIDESCENCE_IOR=`iridescenceIOR`,Q.IRIDESCENCE_THICKNESS=`iridescenceThickness`,Q.IOR=`ior`,Q.TRANSMISSION=`transmission`,Q.THICKNESS=`thickness`,Q.ATTENUATION_DISTANCE=`attenuationDistance`,Q.ATTENUATION_COLOR=`attenuationColor`,Q.LINE_SCALE=`scale`,Q.LINE_DASH_SIZE=`dashSize`,Q.LINE_GAP_SIZE=`gapSize`,Q.LINE_WIDTH=`linewidth`,Q.LINE_DASH_OFFSET=`dashOffset`,Q.POINT_SIZE=`size`,Q.DISPERSION=`dispersion`,Q.LIGHT_MAP=`light`,Q.AO=`ao`;const X6=G(Q,Q.ALPHA_TEST),Z6=G(Q,Q.COLOR),vse=G(Q,Q.SHININESS),Q6=G(Q,Q.EMISSIVE),$6=G(Q,Q.OPACITY),yse=G(Q,Q.SPECULAR),bse=G(Q,Q.SPECULAR_INTENSITY),xse=G(Q,Q.SPECULAR_COLOR),Sse=G(Q,Q.SPECULAR_STRENGTH),Cse=G(Q,Q.REFLECTIVITY),wse=G(Q,Q.ROUGHNESS),Tse=G(Q,Q.METALNESS),e8=G(Q,Q.NORMAL),Ese=G(Q,Q.CLEARCOAT),Dse=G(Q,Q.CLEARCOAT_ROUGHNESS),Ose=G(Q,Q.CLEARCOAT_NORMAL),kse=G(Q,Q.ROTATION),Ase=G(Q,Q.SHEEN),jse=G(Q,Q.SHEEN_ROUGHNESS),Mse=G(Q,Q.ANISOTROPY),Nse=G(Q,Q.IRIDESCENCE),Pse=G(Q,Q.IRIDESCENCE_IOR),Fse=G(Q,Q.IRIDESCENCE_THICKNESS),Ise=G(Q,Q.TRANSMISSION),Lse=G(Q,Q.THICKNESS),Rse=G(Q,Q.IOR),zse=G(Q,Q.ATTENUATION_DISTANCE),Bse=G(Q,Q.ATTENUATION_COLOR),Vse=G(Q,Q.LINE_SCALE),Hse=G(Q,Q.LINE_DASH_SIZE),Use=G(Q,Q.LINE_GAP_SIZE),Wse=G(Q,Q.LINE_WIDTH),Gse=G(Q,Q.LINE_DASH_OFFSET),Kse=G(Q,Q.POINT_SIZE),qse=G(Q,Q.DISPERSION),t8=G(Q,Q.LIGHT_MAP),n8=G(Q,Q.AO),r8=t2(new eX).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),i8=K(e=>e.context.setupModelViewProjection(),`vec4`).once()().toVarying(`v_modelViewProjection`);var a8=class e extends Z${static get type(){return`IndexNode`}constructor(e){super(`uint`),this.scope=e,this.isIndexNode=!0}generate(t){let n=this.getNodeType(t),r=this.scope,i;if(r===e.VERTEX)i=t.getVertexIndex();else if(r===e.INSTANCE)i=t.getInstanceIndex();else if(r===e.DRAW)i=t.getDrawIndex();else if(r===e.INVOCATION_LOCAL)i=t.getInvocationLocalIndex();else if(r===e.INVOCATION_SUBGROUP)i=t.getInvocationSubgroupIndex();else if(r===e.SUBGROUP)i=t.getSubgroupIndex();else throw Error(`THREE.IndexNode: Unknown scope: `+r);let a;if(t.shaderStage===`vertex`||t.shaderStage===`compute`)a=i;else{let e=a3(this);a=e.build(t,n)}return a}};a8.VERTEX=`vertex`,a8.INSTANCE=`instance`,a8.SUBGROUP=`subgroup`,a8.INVOCATION_LOCAL=`invocationLocal`,a8.INVOCATION_SUBGROUP=`invocationSubgroup`,a8.DRAW=`draw`;const o8=G(a8,a8.VERTEX),s8=G(a8,a8.INSTANCE),Jse=G(a8,a8.SUBGROUP),Yse=G(a8,a8.INVOCATION_SUBGROUP),Xse=G(a8,a8.INVOCATION_LOCAL),c8=G(a8,a8.DRAW);var l8=class extends Z${static get type(){return`InstanceNode`}constructor(e,t,n=null){super(`void`),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=H$.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{count:t,instanceMatrix:n,instanceColor:r}=this,{instanceMatrixNode:i,instanceColorNode:a}=this;if(i===null){if(t<=1e3)i=V3(n.array,`mat4`,Math.max(t,1)).element(s8);else{let e=new y$(n.array,16,1);this.buffer=e;let t=n.usage===CY?y3:v3,r=[t(e,`vec4`,16,0),t(e,`vec4`,16,4),t(e,`vec4`,16,8),t(e,`vec4`,16,12)];i=l0(...r)}this.instanceMatrixNode=i}if(r&&a===null){let e=new IQ(r.array,3),t=r.usage===CY?y3:v3;this.bufferColor=e,a=X(t(e,`vec3`,3,0)),this.instanceColorNode=a}let o=i.mul(a6).xyz;if(a6.assign(o),e.hasGeometryAttribute(`normal`)){let e=b6(m6,i);m6.assign(e)}this.instanceColorNode!==null&&y0(`vec3`,`vInstanceColor`).assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==CY&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==CY&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}};const Zse=W(l8).setParameterLength(2,3);var Qse=class extends l8{static get type(){return`InstancedMeshNode`}constructor(e){let{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}};const u8=W(Qse).setParameterLength(1);var $se=class extends Z${static get type(){return`BatchNode`}constructor(e){super(`void`),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=s8:this.batchingIdNode=c8);let t=K(([e])=>{let t=J(P3(z3(this.batchMesh._indirectTexture),0).x),n=J(e).mod(t),r=J(e).div(t);return z3(this.batchMesh._indirectTexture,Z1(n,r)).x}).setLayout({name:`getIndirectIndex`,type:`uint`,inputs:[{name:`id`,type:`int`}]}),n=t(J(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=J(P3(z3(r),0).x),a=q(n).mul(4).toInt().toVar(),o=a.mod(i),s=a.div(i),c=l0(z3(r,Z1(o,s)),z3(r,Z1(o.add(1),s)),z3(r,Z1(o.add(2),s)),z3(r,Z1(o.add(3),s))),l=this.batchMesh._colorsTexture;if(l!==null){let e=K(([e])=>{let t=J(P3(z3(l),0).x),n=e,r=n.mod(t),i=n.div(t);return z3(l,Z1(r,i)).rgb}).setLayout({name:`getBatchingColor`,type:`vec3`,inputs:[{name:`id`,type:`int`}]}),t=e(n);y0(`vec3`,`vBatchColor`).assign(t)}let u=c0(c);a6.assign(c.mul(a6));let d=m6.div(X(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),f=u.mul(d).xyz;m6.assign(f),e.hasGeometryAttribute(`tangent`)&&R6.mulAssign(u)}};const d8=W($se).setParameterLength(1);var ece=class extends Q${static get type(){return`StorageArrayElementNode`}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){let n=this.storageBufferNode.structTypeNode;return n?n.getMemberType(e,t):`void`}setup(e){return e.isAvailable(`storageBuffer`)===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let n,r=e.context.assign;if(n=e.isAvailable(`storageBuffer`)===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!==`compute`)?e.generatePBO(this):this.node.build(e):super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}};const tce=W(ece).setParameterLength(2);var nce=class extends B3{static get type(){return`StorageBufferNode`}constructor(e,t=null,n=0){let r,i=null;t&&t.isStruct?(r=`struct`,i=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=j$(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=i,this.access=W$.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?`indirectStorageBuffer`:`storageBuffer`}element(e){return tce(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(W$.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=g3(this.value),this._varying=a3(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.getNodeType(e);let{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode===null?`void`:this.structTypeNode.getMemberType(e,t)}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable(`storageBuffer`)||e.isAvailable(`indirectStorageBuffer`))return super.generate(e);let{attribute:t,varying:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}};const f8=(e,t=null,n=0)=>U(new nce(e,t,n)),rce=(e,t,n)=>(console.warn(`THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.`),f8(e,t,n).setPBO(!0)),p8=new WeakMap;var m8=class extends Z${static get type(){return`SkinningNode`}constructor(e){super(`void`),this.skinnedMesh=e,this.updateType=H$.OBJECT,this.skinIndexNode=M3(`skinIndex`,`uvec4`),this.skinWeightNode=M3(`skinWeight`,`vec4`),this.bindMatrixNode=P6(`bindMatrix`,`mat4`),this.bindMatrixInverseNode=P6(`bindMatrixInverse`,`mat4`),this.boneMatricesNode=F6(`skeleton.boneMatrices`,`mat4`,e.skeleton.bones.length),this.positionNode=a6,this.toPositionNode=a6,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=i.mul(t),d=u2(o.mul(r.x).mul(u),s.mul(r.y).mul(u),c.mul(r.z).mul(u),l.mul(r.w).mul(u));return a.mul(d).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=m6){let{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:i,bindMatrixInverseNode:a}=this,o=e.element(n.x),s=e.element(n.y),c=e.element(n.z),l=e.element(n.w),u=u2(r.x.mul(o),r.y.mul(s),r.z.mul(c),r.w.mul(l));return u=a.mul(u).mul(i),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=F6(`skeleton.previousBoneMatrices`,`mat4`,t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,o6)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has(`velocity`)||R$(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&o6.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute(`normal`)){let t=this.getSkinnedNormal();m6.assign(t),e.hasGeometryAttribute(`tangent`)&&R6.assign(t)}return t}generate(e,t){if(t!==`void`)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;p8.get(t)!==e.frameId&&(p8.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}};const h8=e=>U(new m8(e)),ice=(e,t=null)=>{let n=new m8(e);return n.positionNode=f8(new IQ(e.geometry.getAttribute(`position`).array,3),`vec3`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinIndexNode=f8(new IQ(new Uint32Array(e.geometry.getAttribute(`skinIndex`).array),4),`uvec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.skinWeightNode=f8(new IQ(e.geometry.getAttribute(`skinWeight`).array,4),`vec4`).setPBO(!0).toReadOnly().element(s8).toVar(),n.bindMatrixNode=t2(e.bindMatrix,`mat4`),n.bindMatrixInverseNode=t2(e.bindMatrixInverse,`mat4`),n.boneMatricesNode=V3(e.skeleton.boneMatrices,`mat4`,e.skeleton.bones.length),n.toPositionNode=t,U(n)};var ace=class extends Z${static get type(){return`LoopNode`}constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){let t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;let n={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],r=t.isNode!==!0&&t.name||this.getVarName(e),i=t.isNode!==!0&&t.type||`int`;n[r]=D3(r,i)}let r=e.addStack();t.returnsNode=this.params[this.params.length-1](n,e),t.stackNode=r;let i=this.params[0];return i.isNode!==!0&&typeof i.update==`function`&&(t.updateNode=K(this.params[0].update)(n)),e.removeStack(),t}getNodeType(e){let{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):`void`}setup(e){this.getProperties(e)}generate(e){let t=this.getProperties(e),n=this.params,r=t.stackNode;for(let r=0,i=n.length-1;r<i;r++){let i=n[r],a=!1,o=null,s=null,c=null,l=null,u=null,d=null;i.isNode?i.getNodeType(e)===`bool`?(a=!0,l=`bool`,s=i.build(e,l)):(l=`int`,c=this.getVarName(r),o=`0`,s=i.build(e,l),u=`<`):(l=i.type||`int`,c=i.name||this.getVarName(r),o=i.start,s=i.end,u=i.condition,d=i.update,typeof o==`number`?o=e.generateConst(l,o):o&&o.isNode&&(o=o.build(e,l)),typeof s==`number`?s=e.generateConst(l,s):s&&s.isNode&&(s=s.build(e,l)),o!==void 0&&s===void 0?(o+=` - 1`,s=`0`,u=`>=`):s!==void 0&&o===void 0&&(o=`0`,u=`<`),u===void 0&&(u=Number(o)>Number(s)?`>=`:`<`));let f;if(a)f=`while ( ${s} )`;else{let n={start:o,end:s},r=n.start,i=n.end,a,p=()=>u.includes(`<`)?`+=`:`-=`;if(d!=null)switch(typeof d){case`function`:let n=e.flowStagesNode(t.updateNode,`void`),r=n.code.replace(/\t|;/g,``);a=r;break;case`number`:a=c+` `+p()+` `+e.generateConst(l,d);break;case`string`:a=c+` `+d;break;default:d.isNode?a=c+` `+p()+` `+d.build(e):(console.error(`THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number.`),a=`break /* invalid update */`)}else d=l===`int`||l===`uint`?u.includes(`<`)?`++`:`--`:p()+` 1.`,a=c+` `+d;let m=e.getVar(l,c)+` = `+r,h=c+` `+u+` `+i;f=`for ( ${m}; ${h}; ${a} )`}e.addFlowCode((r===0?`
|
|
425
425
|
`:``)+e.tab+f+` {
|
|
426
426
|
|
|
427
427
|
`).addFlowTab()}let i=r.build(e,`void`),a=t.returnsNode?t.returnsNode.build(e):``;e.removeFlowTab().addFlowCode(`
|
|
428
428
|
`+e.tab+i);for(let t=0,n=this.params.length-1;t<n;t++)e.addFlowCode((t===0?``:e.tab)+`}
|
|
429
429
|
|
|
430
|
-
`).removeFlowTab();return e.addFlowTab(),a}};const g8=(...e)=>U(new cce(H1(e,`int`))).toStack(),lce=()=>D3(`continue`).toStack(),_8=()=>D3(`break`).toStack(),uce=(...e)=>(console.warn(`THREE.TSL: loop() has been renamed to Loop().`),g8(...e)),v8=new WeakMap,y8=new TX,b8=K(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=J(o8).mul(n).add(a),s=o.div(r),c=o.sub(s.mul(r)),l=z3(e,Q1(c,s)).depth(i).xyz;return l.mul(t)});function dce(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=v8.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new DX(p,u,d,a);m.type=JJ,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(y8.fromBufferAttribute(a,e),p[f+i+0]=y8.x,p[f+i+1]=y8.y,p[f+i+2]=y8.z,p[f+i+3]=0),n===!0&&(y8.fromBufferAttribute(o,e),p[f+i+4]=y8.x,p[f+i+5]=y8.y,p[f+i+6]=y8.z,p[f+i+7]=0),r===!0&&(y8.fromBufferAttribute(l,e),p[f+i+8]=y8.x,p[f+i+9]=y8.y,p[f+i+10]=y8.z,p[f+i+11]=l.itemSize===4?y8.w:1)}}o={count:a,texture:m,stride:l,size:new tX(u,d)},v8.set(e,o);function g(){m.dispose(),v8.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var fce=class extends Q${static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=n2(1),this.updateType=U$.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=dce(t);n===!0&&a6.mulAssign(this.morphBaseInfluence),r===!0&&m6.mulAssign(this.morphBaseInfluence);let l=J(c.width);g8(a,({i:e})=>{let t=q(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(z3(this.mesh.morphTexture,Q1(J(e).add(1),J(s8))).r):t.assign(P6(`morphTargetInfluences`,`float`).element(e).toVar()),K1(t.notEqual(0),()=>{n===!0&&a6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(0)})),r===!0&&m6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}};const x8=W(fce).setParameterLength(1);var S8=class extends Q${static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},pce=class extends S8{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},mce=class extends Q4{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n=X().toVar(`directDiffuse`),r=X().toVar(`directSpecular`),i=X().toVar(`indirectDiffuse`),a=X().toVar(`indirectSpecular`),o={directDiffuse:n,directSpecular:r,indirectDiffuse:i,indirectSpecular:a},s={radiance:X().toVar(`radiance`),irradiance:X().toVar(`irradiance`),iblIrradiance:X().toVar(`iblIrradiance`),ambientOcclusion:q(1).toVar(`ambientOcclusion`),reflectedLight:o,backdrop:e,backdropAlpha:t};return s}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}};const C8=W(mce);var hce=class extends S8{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}};let w8,T8;var E8=class e extends Q${static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=U$.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT)&&(t=U$.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(T8),T8.multiplyScalar(t.getPixelRatio())):T8.copy(n.viewport):n===null?t.getDrawingBufferSize(w8):(w8.width=n.width,w8.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?n2(w8||=new tX):t===e.VIEWPORT?n2(T8||=new TX):Y(k8.div(O8)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(O8).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};E8.COORDINATE=`coordinate`,E8.VIEWPORT=`viewport`,E8.SIZE=`size`,E8.UV=`uv`;const D8=G(E8,E8.UV),O8=G(E8,E8.SIZE),k8=G(E8,E8.COORDINATE),A8=G(E8,E8.VIEWPORT),j8=A8.zw,M8=k8.sub(A8.xy),gce=M8.div(j8),_ce=K(()=>(console.warn(`THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`),O8),`vec2`).once()(),vce=K(()=>(console.warn(`THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),D8),`vec2`).once()(),yce=K(()=>(console.warn(`THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),D8.flipY()),`vec2`).once()(),N8=new tX;var P8=class extends L3{static get type(){return`ViewportTextureNode`}constructor(e=D8,t=null,n=null){n===null&&(n=new HQ,n.minFilter=UJ),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=U$.FRAME}updateBefore(e){let t=e.renderer;t.getDrawingBufferSize(N8);let n=this.value;(n.image.width!==N8.width||n.image.height!==N8.height)&&(n.image.width=N8.width,n.image.height=N8.height,n.needsUpdate=!0);let r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}};const bce=W(P8).setParameterLength(0,3),xce=W(P8,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let F8=null;var Sce=class extends P8{static get type(){return`ViewportDepthTextureNode`}constructor(e=D8,t=null){F8===null&&(F8=new UQ),super(e,t,F8)}};const I8=W(Sce).setParameterLength(0,2);var L8=class e extends Q${static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;if(n===e.DEPTH_BASE)r!==null&&(i=H8().assign(r));else if(n===e.DEPTH)i=t.isPerspectiveCamera?z8(l6.z,K3,q3):R8(l6.z,K3,q3);else if(n===e.LINEAR_DEPTH)if(r!==null)if(t.isPerspectiveCamera){let e=B8(r,K3,q3);i=R8(e,K3,q3)}else i=r;else i=R8(l6.z,K3,q3);return i}};L8.DEPTH_BASE=`depthBase`,L8.DEPTH=`depth`,L8.LINEAR_DEPTH=`linearDepth`;const R8=(e,t,n)=>e.add(t).div(t.sub(n)),Cce=(e,t,n)=>t.sub(n).mul(e).sub(t),z8=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),B8=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),V8=(e,t,n)=>{t=t.max(1e-6).toVar();let r=Y2(e.negate().div(t)),i=Y2(n.div(t));return r.div(i)},wce=(e,t,n)=>{let r=e.mul(J2(n.div(t)));return q(Math.E).pow(r).mul(t).negate()},H8=W(L8,L8.DEPTH_BASE),U8=G(L8,L8.DEPTH),W8=W(L8,L8.LINEAR_DEPTH).setParameterLength(0,1),Tce=W8(I8());U8.assign=e=>H8(e);var G8=class e extends Q${static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let n=t.clippingContext,{intersectionPlanes:r,unionPlanes:i}=n;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===e.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return K(()=>{let n=q().toVar(`distanceToPlane`),r=q().toVar(`distanceToGradient`),i=q(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=U3(t);g8(a,({i:t})=>{let a=e.element(t);n.assign(l6.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(V4(r.negate(),r,n))})}let o=e.length;if(o>0){let t=U3(e),a=q(1).toVar(`intersectionClipOpacity`);g8(o,({i:e})=>{let i=t.element(e);n.assign(l6.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(V4(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}x0.a.mulAssign(i),x0.a.equal(0).discard()})()}setupDefault(e,t){return K(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=U3(t);g8(n,({i:t})=>{let n=e.element(t);l6.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=U3(e),n=Z1(!0).toVar(`clipped`);g8(r,({i:e})=>{let r=t.element(e);n.assign(l6.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),K(()=>{let r=U3(e),i=W3(t.getClipDistance());g8(n,({i:e})=>{let t=r.element(e),n=l6.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};G8.ALPHA_TO_COVERAGE=`alphaToCoverage`,G8.DEFAULT=`default`,G8.HARDWARE=`hardware`;const Ece=()=>U(new G8),Dce=()=>U(new G8(G8.ALPHA_TO_COVERAGE)),Oce=()=>U(new G8(G8.HARDWARE)),kce=.05,K8=K(([e])=>t4(p2(1e4,n4(p2(17,e.x).add(p2(.1,e.y)))).mul(d2(.1,c4(n4(p2(13,e.y).add(e.x))))))),q8=K(([e])=>K8(Y(K8(e.xy),e.z))),Ace=K(([e])=>{let t=C4(u4(p4(e.xyz)),u4(m4(e.xyz))),n=q(1).div(q(kce).mul(t)).toVar(`pixScale`),r=Y(q2(Q2(Y2(n))),q2($2(Y2(n)))),i=Y(q8(Q2(r.x.mul(e.xyz))),q8(Q2(r.y.mul(e.xyz)))),a=t4(Y2(n)),o=d2(p2(a.oneMinus(),i.x),p2(a,i.y)),s=S4(a,a.oneMinus()),c=X(o.mul(o).div(p2(2,s).mul(f2(1,s))),o.sub(p2(.5,s)).div(f2(1,s)),f2(1,f2(1,o).mul(f2(1,o)).div(p2(2,s).mul(f2(1,s))))),l=o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z);return R4(l,1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]});var jce=class extends j3{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new TX(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}};const J8=(e=0)=>U(new jce(e));var Y8=class extends XZ{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,`shadowPositionNode`,{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn(`THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".`),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+O$(this)}build(e){this.setup(e)}setupObserver(e){return new C$(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=this.vertexNode||r;e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.add(o);let i=i0(r,x0.a).max(0);a=this.setupOutput(e,i),z0.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&z0.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=i0(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.samples;this.alphaToCoverage&&t>1?r=Dce():e.stack.add(Ece())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.add(Oce()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?V8(l6.z,K3,q3):R8(l6.z,K3,q3))}r!==null&&U8.assign(r).toStack()}setupPositionView(){return n6.mul(a6).xyz}setupModelViewProjection(){return J3.mul(l6)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),i8}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&x8(t).toStack(),t.isSkinnedMesh===!0&&h8(t).toStack(),this.displacementMap){let e=I6(`displacementMap`,`texture`),t=I6(`displacementScale`,`float`),n=I6(`displacementBias`,`float`);a6.addAssign(m6.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&d8(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&u8(t).toStack(),this.positionNode!==null&&a6.assign(S3(this.positionNode,`POSITION`)),a6}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&Z1(this.maskNode).not().discard();let n=this.colorNode?i0(this.colorNode):Z6;if(this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=n.mul(J8())),e.instanceColor){let e=b0(`vec3`,`vInstanceColor`);n=e.mul(n)}if(e.isBatchedMesh&&e._colorsTexture){let e=b0(`vec3`,`vBatchColor`);n=e.mul(n)}x0.assign(n);let r=this.opacityNode?q(this.opacityNode):$6;x0.a.assign(x0.a.mul(r));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?X6:q(this.alphaTestNode),x0.a.lessThanEqual(i).discard()),this.alphaHash===!0&&x0.a.lessThan(Ace(a6)).discard();let a=this.transparent===!1&&this.blending===DJ&&this.alphaToCoverage===!1;a?x0.a.assign(1):i===null&&x0.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?X(0):x0.rgb}setupNormal(){return this.normalNode?X(this.normalNode):e8}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?I6(`envMap`,`cubeTexture`):I6(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new hce(t8)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){let e=this.aoNode===null?n8:this.aoNode;t.push(new pce(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=a?this.setupLights(e):null,s=this.setupOutgoingLight(e);if(o&&o.getScope().hasLights){let t=this.setupLightingModel(e)||null;s=C8(o,t,n,r)}else n!==null&&(s=X(r===null?n:L4(s,n,r)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(S0.assign(X(i||Q6)),s=s.add(S0)),s}setupFog(e,t){let n=e.fogNode;return n&&(z0.assign(t),t=i0(n)),t}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=XZ.prototype.toJSON.call(this,e),r=k$(this);n.inputNodes={};for(let{property:t,childNode:i}of r)n.inputNodes[t]=i.toJSON(e).uuid;function i(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=i(e.textures),r=i(e.images),a=i(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}};let X8=null;var Mce=class extends P8{static get type(){return`ViewportSharedTextureNode`}constructor(e=D8,t=null){X8===null&&(X8=new HQ),super(e,t,X8)}updateReference(){return this}};const Nce=W(Mce).setParameterLength(0,2),Pce=e=>U(e).mul(.5).add(.5),Fce=e=>U(e).mul(2).sub(1);var Ice=class extends t1{static get type(){return`EquirectUVNode`}constructor(e=c6){super(`vec2`),this.dirNode=e}setup(){let e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Y(t,n)}};const Z8=W(Ice).setParameterLength(0,1),Q8=K(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),Lce=K(e=>e.diffuseColor.mul(1/Math.PI)),$8=K(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return q(0);let t=g6.dFdx().abs().max(g6.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),Rce=K(e=>{let{roughness:t}=e,n=$8(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),e5=K(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return m2(.5,i.add(a).max(R2))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),zce=K(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(X(e.mul(n),t.mul(r),o).length()),l=o.mul(X(e.mul(i),t.mul(a),s).length()),u=m2(.5,c.add(l));return u.saturate()}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),t5=K(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Bce=q(1/Math.PI),Vce=K(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=X(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Bce.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),Hce=K(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||v6,l=i.pow2(),u=t.add(u6).normalize(),d=c.dot(t).clamp(),f=c.dot(u6).clamp(),p=c.dot(u).clamp(),m=u6.dot(u).clamp(),h=Q8({f0:n,f90:r,dotVH:m}),g,_;if(R1(o)&&(h=k0.mix(h,a)),R1(s)){let e=P0.dot(t),n=P0.dot(u6),r=P0.dot(u),i=F0.dot(t),a=F0.dot(u6),o=F0.dot(u);g=zce({alphaT:M0,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),_=Vce({alphaT:M0,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else g=e5({alpha:l,dotNL:d,dotNV:f}),_=t5({alpha:l,dotNH:p});return h.mul(g).mul(_)}),Uce=K(({roughness:e,dotNV:t})=>{let n=i0(-1,-.0275,-.572,.022),r=i0(1,.0425,1.04,-.04),i=e.mul(n).add(r),a=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y),o=Y(-1.04,1.04).mul(a).add(i.zw);return o}).setLayout({name:`DFGApprox`,type:`vec2`,inputs:[{name:`roughness`,type:`float`},{name:`dotNV`,type:`vec3`}]}),Wce=K(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(X(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),n5=1/6,r5=e=>p2(n5,p2(e,p2(e,e.negate().add(3)).sub(3)).add(1)),i5=e=>p2(n5,p2(e,p2(e,p2(3,e).sub(6))).add(4)),a5=e=>p2(n5,p2(e,p2(e,p2(-3,e).add(3)).add(3)).add(1)),o5=e=>p2(n5,A4(e,3)),s5=e=>r5(e).add(i5(e)),c5=e=>a5(e).add(o5(e)),l5=e=>d2(-1,i5(e).div(r5(e).add(i5(e)))),u5=e=>d2(1,o5(e).div(a5(e).add(o5(e)))),d5=(e,t,n)=>{let r=e.uvNode,i=p2(r,t.zw).add(.5),a=Q2(i),o=t4(i),s=s5(o.x),c=c5(o.x),l=l5(o.x),u=u5(o.x),d=l5(o.y),f=u5(o.y),p=Y(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=Y(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=Y(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=Y(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=s5(o.y).mul(d2(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=c5(o.y).mul(d2(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Gce=K(([e,t=q(3)])=>{let n=Y(e.size(J(t))),r=Y(e.size(J(t.add(1)))),i=m2(1,n),a=m2(1,r),o=d5(e,i0(i,n),Q2(t)),s=d5(e,i0(a,r),$2(t));return t4(t).mix(o,s)}),Kce=X(.04),qce=q(1),f5=q(1),p5=q(-2),m5=q(.8),h5=q(-1),g5=q(.4),_5=q(2),v5=q(.305),y5=q(3),b5=q(.21),Jce=q(4),x5=q(4),Yce=q(16),Xce=K(([e])=>{let t=X(c4(e)).toVar(),n=q(-1).toVar();return K1(t.x.greaterThan(t.z),()=>{K1(t.x.greaterThan(t.y),()=>{n.assign(X4(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(X4(e.y.greaterThan(0),1,4))})}).Else(()=>{K1(t.z.greaterThan(t.y),()=>{n.assign(X4(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(X4(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),Zce=K(([e,t])=>{let n=Y().toVar();return K1(t.equal(0),()=>{n.assign(Y(e.z,e.y).div(c4(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(Y(e.x.negate(),e.z.negate()).div(c4(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(Y(e.x.negate(),e.y).div(c4(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(Y(e.z.negate(),e.y).div(c4(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(Y(e.x.negate(),e.z).div(c4(e.y)))}).Else(()=>{n.assign(Y(e.x,e.y).div(c4(e.z)))}),p2(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),Qce=K(([e])=>{let t=q(0).toVar();return K1(e.greaterThanEqual(m5),()=>{t.assign(f5.sub(e).mul(h5.sub(p5)).div(f5.sub(m5)).add(p5))}).ElseIf(e.greaterThanEqual(g5),()=>{t.assign(m5.sub(e).mul(_5.sub(h5)).div(m5.sub(g5)).add(h5))}).ElseIf(e.greaterThanEqual(v5),()=>{t.assign(g5.sub(e).mul(y5.sub(_5)).div(g5.sub(v5)).add(_5))}).ElseIf(e.greaterThanEqual(b5),()=>{t.assign(v5.sub(e).mul(Jce.sub(y5)).div(v5.sub(b5)).add(y5))}).Else(()=>{t.assign(q(-2).mul(Y2(p2(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),S5=K(([e,t])=>{let n=e.toVar();n.assign(p2(2,n).sub(1));let r=X(n,1).toVar();return K1(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),C5=K(([e,t,n,r,i,a])=>{let o=q(n),s=X(t),c=R4(Qce(o),p5,a),l=t4(c),u=Q2(c),d=X(w5(e,s,u,r,i,a)).toVar();return K1(l.notEqual(0),()=>{let t=X(w5(e,s,u.add(1),r,i,a)).toVar();d.assign(L4(d,t,l))}),d}),w5=K(([e,t,n,r,i,a])=>{let o=q(n).toVar(),s=X(t),c=q(Xce(s)).toVar(),l=q(C4(x5.sub(o),0)).toVar();o.assign(C4(o,x5));let u=q(q2(o)).toVar(),d=Y(Zce(s,c).mul(u.sub(2)).add(1)).toVar();return K1(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(p2(3,Yce))),d.y.addAssign(p2(4,q2(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(Y(),Y())}),T5=K(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=r4(r),l=n.mul(c).add(i.cross(n).mul(n4(r))).add(i.mul(i.dot(n).mul(c.oneMinus())));return w5(e,l,t,a,o,s)}),E5=K(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=X(X4(t,n,k4(n,r))).toVar();K1(f.equal(X(0)),()=>{f.assign(X(r.z,0,r.x.negate()))}),f.assign(e4(f));let p=X().toVar();return p.addAssign(i.element(0).mul(T5({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),g8({start:J(1),end:e},({i:e})=>{K1(e.greaterThanEqual(a),()=>{_8()});let t=q(o.mul(q(e))).toVar();p.addAssign(i.element(e).mul(T5({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(T5({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),i0(p,1)}),D5=4,O5=[.125,.215,.35,.446,.526,.582],k5=20,A5=new s$(-1,1,1,-1,0,1),$ce=new MQ(90,1),j5=new qZ;let M5=null,N5=0,P5=0;const F5=(1+Math.sqrt(5))/2,I5=1/F5,L5=[new V(-F5,I5,0),new V(F5,I5,0),new V(-I5,0,F5),new V(I5,0,F5),new V(0,F5,-I5),new V(0,F5,I5),new V(-1,1,-1),new V(1,1,-1),new V(-1,1,1),new V(1,1,1)],ele=new V,R5=new WeakMap,tle=[3,1,5,0,4,2],z5=S5(N3(),M3(`faceIndex`)).normalize(),B5=X(z5.x,z5.y,z5.z);var nle=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=ele,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.`);let a=s||this._allocateTarget();return i.renderTarget=a,this.fromSceneAsync(e,t,n,r,i),a}M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=W5(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=G5(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===FJ||e.mapping===IJ?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(M5,N5,P5),e.scissorTest=!1,H5(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){let e=3*Math.max(this._cubeSize,16*7),t=4*this._cubeSize,n=V5(e,t);return n}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=V5(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=rle(t)),this._blurMaterial=ile(t,e.width,e.height)}}async _compileMaterial(e){let t=new wQ(this._lodPlanes[0],e);await this._renderer.compile(t,A5)}_sceneToCubeUV(e,t,n,r,i){let a=$ce;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(j5),c.autoClear=!1;let u=this._backgroundBox;if(u===null){let e=new ZZ({name:`PMREM.Background`,side:TJ,depthWrite:!1,depthTest:!1});u=new wQ(new DQ,e)}let d=!1,f=e.background;f?f.isColor&&(u.material.color.copy(f),e.background=null,d=!0):(u.material.color.copy(j5),d=!0),c.setRenderTarget(r),c.clear(),d&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;H5(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===FJ||e.mapping===IJ;r?this._cubemapMaterial===null&&(this._cubemapMaterial=W5(e)):this._equirectMaterial===null&&(this._equirectMaterial=G5(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;H5(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,A5)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;t<r;t++){let n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=L5[(r-t-1)%L5.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&console.error(`blur direction must be either latitudinal or longitudinal!`);let l=3,u=this._lodMeshes[r];u.material=c;let d=R5.get(c),f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/(2*k5-1),m=i/p,h=isFinite(i)?1+Math.floor(l*m):k5;h>k5&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${k5}`);let g=[],_=0;for(let e=0;e<k5;++e){let t=e/m,n=Math.exp(-t*t/2);g.push(n),e===0?_+=n:e<h&&(_+=2*n)}for(let e=0;e<g.length;e++)g[e]=g[e]/_;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=h,d.weights.array=g,d.latitudinal.value=a===`latitudinal`?1:0,o&&(d.poleAxis.value=o);let{_lodMax:v}=this;d.dTheta.value=p,d.mipInt.value=v-n;let y=this._sizeLods[r],b=3*y*(r>v-D5?r-v+D5:0),x=4*(this._cubeSize-y);H5(t,b,x,3*y,2*y),s.setRenderTarget(t),s.render(u,A5)}};function rle(e){let t=[],n=[],r=[],i=[],a=e,o=e-D5+1+O5.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-D5?c=O5[s-e+D5-1]:s===0&&(c=0),r.push(c);let l=1/(o-2),u=-l,d=1+l,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,m=6,h=3,g=2,_=1,v=new Float32Array(h*m*p),y=new Float32Array(g*m*p),b=new Float32Array(_*m*p);for(let e=0;e<p;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=tle[e];v.set(r,h*m*i),y.set(f,g*m*i);let a=[i,i,i,i,i,i];b.set(a,_*m*i)}let x=new fQ;x.setAttribute(`position`,new tQ(v,h)),x.setAttribute(`uv`,new tQ(y,g)),x.setAttribute(`faceIndex`,new tQ(b,_)),t.push(x),i.push(new wQ(x,null)),a>D5&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function V5(e,t){let n={magFilter:HJ,minFilter:HJ,generateMipmaps:!1,type:YJ,format:XJ,colorSpace:uY},r=new EX(e,t,n);return r.texture.mapping=LJ,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function H5(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function U5(e){let t=new Y8;return t.depthTest=!1,t.depthWrite=!1,t.blending=EJ,t.name=`PMREM_${e}`,t}function ile(e,t,n){let r=U3(Array(k5).fill(0)),i=n2(new V(0,1,0)),a=n2(0),o=q(k5),s=n2(0),c=n2(1),l=R3(null),u=n2(0),d=q(1/t),f=q(1/n),p=q(e),m={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:B5,dTheta:a,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:f,CUBEUV_MAX_MIP:p},h=U5(`blur`);return h.fragmentNode=E5({...m,latitudinal:s.equal(1)}),R5.set(h,m),h}function W5(e){let t=U5(`cubemap`);return t.fragmentNode=M6(e,B5),t}function G5(e){let t=U5(`equirect`);return t.fragmentNode=R3(e,Z8(B5),0),t}const K5=new WeakMap;function ale(e){let t=Math.log2(e)-2,n=1/e,r=1/(3*Math.max(2**t,7*16));return{texelWidth:r,texelHeight:n,maxMip:t}}function ole(e,t,n){let r=sle(t),i=r.get(e),a=i===void 0?-1:i.pmremVersion;if(a!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(lle(t))i=n.fromCubemap(e,i);else return null;else if(ule(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function sle(e){let t=K5.get(e);return t===void 0&&(t=new WeakMap,K5.set(e,t)),t}var cle=class extends t1{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new wX;r.isRenderTargetTexture=!0,this._texture=R3(r),this._width=n2(0),this._height=n2(0),this._maxMip=n2(0),this.updateBeforeType=U$.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=ale(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:ole(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new nle(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=T6.mul(X(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),C5(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function lle(e){if(e==null)return!1;let t=0,n=6;for(let r=0;r<n;r++)e[r]!==void 0&&t++;return t===n}function ule(e){return e==null?!1:e.height>0}const dle=W(cle).setParameterLength(1,3);var fle=class extends t1{static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=X(u6.z,0,u6.x.negate()).normalize(),t=u6.cross(e);return Y(e.dot(v6),t.dot(v6)).mul(.495).add(.5)}};const ple=G(fle);var mle=class extends t1{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this,r=this.getNodeType(e);if(r===`vec2`){let e=t.cos(),r=t.sin(),i=c0(e,r,r.negate(),e);return i.mul(n)}else{let e=t,r=u0(i0(1,0,0,0),i0(0,r4(e.x),n4(e.x).negate(),0),i0(0,n4(e.x),r4(e.x),0),i0(0,0,0,1)),i=u0(i0(r4(e.y),0,n4(e.y),0),i0(0,1,0,0),i0(n4(e.y).negate(),0,r4(e.y),0),i0(0,0,0,1)),a=u0(i0(r4(e.z),n4(e.z).negate(),0,0),i0(n4(e.z),r4(e.z),0,0),i0(0,0,1,0),i0(0,0,0,1));return r.mul(i).mul(a).mul(i0(n,1)).xyz}}};const q5=W(mle).setParameterLength(2),hle=y0(`vec3`),gle=y0(`vec3`),_le=y0(`vec3`);var vle=class{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},yle=class extends v0{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}};const ble=(e,t)=>U(new yle(e,t));var xle=class extends Q${static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}add(e){return this.nodes.push(e),this}If(e,t){let n=new B1(t);return this._currentCond=X4(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new B1(t),r=X4(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new B1(e),this}Switch(e){return this._expressionNode=U(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(U(e[n])));else throw Error(`TSL: Invalid parameter length. Case() requires at least two parameters.`);let n=e[e.length-1],r=new B1(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=X4(i,r);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}build(e,...t){let n=G1();W1(this);let r=e.buildStage;for(let t of this.nodes)if(r===`setup`)t.build(e);else if(r===`analyze`)t.build(e,this);else if(r===`generate`){let n=e.getDataFromNode(t,`any`).stages,r=n&&n[e.shaderStage];if(t.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)continue;t.build(e,`void`)}return W1(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn(`THREE.TSL: .else() has been renamed to .Else().`),this.Else(...e)}elseif(...e){return console.warn(`THREE.TSL: .elseif() has been renamed to .ElseIf().`),this.ElseIf(...e)}};const Sle=W(xle).setParameterLength(0,1);function Cle(e){return Object.entries(e).map(([e,t])=>typeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var wle=class extends Q${static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=Cle(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=8,t=Float32Array.BYTES_PER_ELEMENT,n=0;for(let r of this.membersLayout){let i=r.type,a=F$(i)*t,o=I$(i),s=n%e,c=s%o,l=s+c;n+=c,l!==0&&e-l<a&&(n+=e-l),n+=a}return Math.ceil(n/e)*e/t}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}getNodeType(e){let t=e.getStructTypeFromNode(this,this.membersLayout,this.name);return t.name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}},Tle=class extends Q${static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}};const Ele=(e,t=null)=>{let n=new wle(e,t),r=(...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;e<t.length;e++)r[n[e]]=t[e]}else r=t[0];return U(new Tle(n,r))};return r.layout=n,r.isStruct=!0,r};var J5=class extends Q${static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){let t=e.getNodeProperties(this);if(t.membersLayout===void 0){let n=this.members,r=[];for(let t=0;t<n.length;t++){let i=`m`+t,a=n[t].getNodeType(e);r.push({name:i,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){let t=e.getOutputStructName(),n=this.members,r=t===``?``:t+`.`;for(let t=0;t<n.length;t++){let i=n[t].build(e);e.addLineFlowCode(`${r}m${t} = ${i}`,this)}return t}};const Dle=W(J5);function Y5(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var Ole=class extends J5{static get type(){return`MRTNode`}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes};return X5(t)}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=Y5(i,e);r[n]=i0(t[e])}return this.members=r,super.setup(e)}};const X5=W(Ole),kle=K(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737),r=n.shiftRight(22).bitXor(n);return r.toFloat().mul(1/2**32)}),Z5=(e,t)=>A4(p2(4,e.mul(f2(1,e))),t),Ale=(e,t)=>e.lessThan(.5)?Z5(e.mul(2),t).div(2):f2(1,Z5(p2(f2(1,e),2),t).div(2)),jle=(e,t,n)=>A4(m2(A4(e,t),d2(A4(e,t),A4(f2(1,e),n))),1/t),Mle=(e,t)=>n4(B2.mul(t.mul(e).sub(1))).div(B2.mul(t.mul(e).sub(1))),Q5=K(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),Nle=K(([e])=>X(Q5(e.z.add(Q5(e.y.mul(1)))),Q5(e.z.add(Q5(e.x.mul(1)))),Q5(e.y.add(Q5(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Ple=K(([e,t,n])=>{let r=X(e).toVar(),i=q(1.4).toVar(),a=q(0).toVar(),o=X(r).toVar();return g8({start:q(0),end:q(3),type:`float`,condition:`<=`},()=>{let e=X(Nle(o.mul(2))).toVar();r.addAssign(e.add(n.mul(q(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=q(Q5(r.z.add(Q5(r.x.add(Q5(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]});var Fle=class extends Q${static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){let t=this.parametersNodes,n=this._candidateFnCall;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode,o=a.layout;if(o===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let s=o.inputs;if(t.length===s.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=s[n];r.getNodeType(e)===i.type?a++:a=0}a>i&&(r=n,i=a)}}this._candidateFnCall=n=r(...t)}return n}};const Ile=W(Fle),$5=e=>(...t)=>Ile(e,...t),e7=n2(0).setGroup($0).onRenderUpdate(e=>e.time),t7=n2(0).setGroup($0).onRenderUpdate(e=>e.deltaTime),Lle=n2(0,`uint`).setGroup($0).onRenderUpdate(e=>e.frameId),Rle=(e=1)=>(console.warn(`TSL: timerLocal() is deprecated. Use "time" instead.`),e7.mul(e)),zle=(e=1)=>(console.warn(`TSL: timerGlobal() is deprecated. Use "time" instead.`),e7.mul(e)),Ble=(e=1)=>(console.warn(`TSL: timerDelta() is deprecated. Use "deltaTime" instead.`),t7.mul(e)),Vle=(e=e7)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Hle=(e=e7)=>e.fract().round(),Ule=(e=e7)=>e.add(.5).fract().mul(2).sub(1).abs(),Wle=(e=e7)=>e.fract(),Gle=K(([e,t,n=Y(.5)])=>q5(e.sub(n),t).add(n)),Kle=K(([e,t,n=Y(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i),o=a.mul(t);return e.add(r.mul(o))}),qle=K(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=e6:(r=e6.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Y3.mul(r);return R1(t)&&(i[0][0]=e6[0].length(),i[0][1]=0,i[0][2]=0),R1(n)&&(i[1][0]=0,i[1][1]=e6[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,J3.mul(i).mul(a6)}),Jle=K(([e=null])=>{let t=W8(),n=W8(I8(e)).sub(t),r=n.lessThan(0).select(D8,e);return r});var Yle=class extends Q${static get type(){return`SpriteSheetUVNode`}constructor(e,t=N3(),n=q(0)){super(`vec2`),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){let{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:i}=n,a=e.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=n.reciprocal(),l=Y(o,s);return t.add(l).mul(c)}};const Xle=W(Yle).setParameterLength(3);var Zle=class extends Q${static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=q(1),i=a6,a=m6){super(`vec4`),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=i,this.normalNode=a}setup(){let{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:i,normalNode:a}=this,o=a.abs().normalize();o=o.div(o.dot(X(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value,p=R3(u,s).mul(o.x),m=R3(d,c).mul(o.y),h=R3(f,l).mul(o.z);return d2(p,m,h)}};const n7=W(Zle).setParameterLength(1,6),Qle=(...e)=>n7(...e),r7=new VQ,i7=new V,a7=new V,o7=new V,s7=new tZ,c7=new V(0,0,-1),l7=new TX,u7=new V,d7=new V,f7=new TX,p7=new tX,m7=new EX,$le=D8.flipX();m7.depthTexture=new UQ(1,1);let h7=!1;var eue=class e extends L3{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||m7.texture,$le),this._reflectorBaseNode=e.reflector||new tue(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=U(new e({defaultTexture:m7.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},tue=class extends Q${static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new OZ,resolution:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=i,this.bounces=a,this.depth=o,this.updateBeforeType=a?U$.RENDER:U$.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolution;t.getDrawingBufferSize(p7),e.setSize(Math.round(p7.width*n),Math.round(p7.height*n))}setup(e){return this._updateResolution(m7,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new EX(0,0,{type:YJ}),this.generateMipmaps===!0&&(t.texture.minFilter=WJ,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new UQ),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&h7)return!1;h7=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(p7),this._updateResolution(s,r),a7.setFromMatrixPosition(a.matrixWorld),o7.setFromMatrixPosition(n.matrixWorld),s7.extractRotation(a.matrixWorld),i7.set(0,0,1),i7.applyMatrix4(s7),u7.subVectors(a7,o7);let c=u7.dot(i7)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){h7=!1;return}l=!0}u7.reflect(i7).negate(),u7.add(a7),s7.extractRotation(n.matrixWorld),c7.set(0,0,-1),c7.applyMatrix4(s7),c7.add(o7),d7.subVectors(a7,c7),d7.reflect(i7).negate(),d7.add(a7),o.coordinateSystem=n.coordinateSystem,o.position.copy(u7),o.up.set(0,1,0),o.up.applyMatrix4(s7),o.up.reflect(i7),o.lookAt(d7),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),r7.setFromNormalAndCoplanarPoint(i7,a7),r7.applyMatrix4(o.matrixWorldInverse),l7.set(r7.normal.x,r7.normal.y,r7.normal.z,r7.constant);let u=o.projectionMatrix;f7.x=(Math.sign(l7.x)+u.elements[8])/u.elements[0],f7.y=(Math.sign(l7.y)+u.elements[9])/u.elements[5],f7.z=-1,f7.w=(1+u.elements[10])/u.elements[14],l7.multiplyScalar(1/l7.dot(f7));let d=0;u.elements[2]=l7.x,u.elements[6]=l7.y,u.elements[10]=r.coordinateSystem===EY?l7.z-d:l7.z+1-d,u.elements[14]=l7.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let f=r.getRenderTarget(),p=r.getMRT(),m=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),r.setMRT(p),r.setRenderTarget(f),r.autoClear=m,i.visible=!0,h7=!1,this.forceUpdate=!1}};const nue=e=>U(new eue(e)),g7=new s$(-1,1,1,-1,0,1);var rue=class extends fQ{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new iQ([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new iQ(t,2))}};const iue=new rue;var _7=class extends wQ{constructor(e=null){super(iue,e),this.camera=g7,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,g7)}render(e){e.render(this,g7)}};const aue=new tX;var oue=class extends L3{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:YJ}){let i=new EX(t,n,r);super(i.texture,N3()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new _7(new Y8),this.updateBeforeType=U$.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();let t=e.getSize(aue);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new L3(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}};const v7=(e,...t)=>U(new oue(U(e),...t)),sue=(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():v7(e,...t),y7=K(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===EY?(e=Y(e.x,e.y.oneMinus()).mul(2).sub(1),i=i0(X(e,t),1)):i=i0(X(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=i0(n.mul(i));return a.xyz.div(a.w)}),cue=K(([e,t])=>{let n=t.mul(i0(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return Y(r.x,r.y.oneMinus())}),lue=K(([e,t,n])=>{let r=P3(z3(t)),i=Q1(e.mul(r)).toVar(),a=z3(t,i).toVar(),o=z3(t,i.sub(Q1(2,0))).toVar(),s=z3(t,i.sub(Q1(1,0))).toVar(),c=z3(t,i.add(Q1(1,0))).toVar(),l=z3(t,i.add(Q1(2,0))).toVar(),u=z3(t,i.add(Q1(0,2))).toVar(),d=z3(t,i.add(Q1(0,1))).toVar(),f=z3(t,i.sub(Q1(0,1))).toVar(),p=z3(t,i.sub(Q1(0,2))).toVar(),m=c4(f2(q(2).mul(s).sub(o),a)).toVar(),h=c4(f2(q(2).mul(c).sub(l),a)).toVar(),g=c4(f2(q(2).mul(d).sub(u),a)).toVar(),_=c4(f2(q(2).mul(f).sub(p),a)).toVar(),v=y7(e,a,n).toVar(),y=m.lessThan(h).select(v.sub(y7(e.sub(Y(q(1).div(r.x),0)),s,n)),v.negate().add(y7(e.add(Y(q(1).div(r.x),0)),c,n))),b=g.lessThan(_).select(v.sub(y7(e.add(Y(0,q(1).div(r.y))),d,n)),v.negate().add(y7(e.sub(Y(0,q(1).div(r.y))),f,n)));return e4(k4(y,b))});var uue=class extends LQ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},due=class extends tQ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}};const fue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=N$(`float`)):(n=P$(t),r=N$(t));let i=new due(e,n,r),a=f8(i,t,e);return a},pue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=N$(`float`)):(n=P$(t),r=N$(t));let i=new uue(e,n,r),a=f8(i,t,e);return a};var mue=class extends Q${static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}};const hue=G(mue),b7=new dZ,x7=new tZ;var S7=class e extends Q${static get type(){return`SceneNode`}constructor(t=e.BACKGROUND_BLURRINESS,n=null){super(),this.scope=t,this.scene=n}setup(t){let n=this.scope,r=this.scene===null?t.scene:this.scene,i;return n===e.BACKGROUND_BLURRINESS?i=P6(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=P6(`backgroundIntensity`,`float`,r):n===e.BACKGROUND_ROTATION?i=n2(`mat4`).label(`backgroundRotation`).setGroup($0).onRenderUpdate(()=>{let e=r.background;return e!==null&&e.isTexture&&e.mapping!==PJ?(b7.copy(r.backgroundRotation),b7.x*=-1,b7.y*=-1,b7.z*=-1,x7.makeRotationFromEuler(b7)):x7.identity(),x7}):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};S7.BACKGROUND_BLURRINESS=`backgroundBlurriness`,S7.BACKGROUND_INTENSITY=`backgroundIntensity`,S7.BACKGROUND_ROTATION=`backgroundRotation`;const gue=G(S7,S7.BACKGROUND_BLURRINESS),_ue=G(S7,S7.BACKGROUND_INTENSITY),vue=G(S7,S7.BACKGROUND_ROTATION);var yue=class extends L3{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=G$.WRITE_ONLY}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}toReadWrite(){return this.setAccess(G$.READ_WRITE)}toReadOnly(){return this.setAccess(G$.READ_ONLY)}toWriteOnly(){return this.setAccess(G$.WRITE_ONLY)}generateStore(e){let t=e.getNodeProperties(this),{uvNode:n,storeNode:r,depthNode:i}=t,a=super.generate(e,`property`),o=n.build(e,`uvec2`),s=r.build(e,`vec4`),c=i?i.build(e,`int`):null,l=e.generateTextureStore(e,a,o,c,s);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e}};const C7=W(yue).setParameterLength(1,3),bue=(e,t,n)=>{let r=C7(e,t,n);return n!==null&&r.toStack(),r},xue=K(({texture:e,uv:t})=>{let n=1e-4,r=X().toVar();return K1(t.x.lessThan(n),()=>{r.assign(X(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(X(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(X(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(X(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(X(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(X(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(X(-.01,0,0))).r.sub(e.sample(t.add(X(n,0,0))).r),a=e.sample(t.add(X(0,-.01,0))).r.sub(e.sample(t.add(X(0,n,0))).r),o=e.sample(t.add(X(0,0,-.01))).r.sub(e.sample(t.add(X(0,0,n))).r);r.assign(X(i,a,o))}),r.normalize()});var Sue=class extends L3{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return X(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return xue({texture:this,uv:e})}};const Cue=W(Sue).setParameterLength(1,3);var wue=class extends N6{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}};const Tue=(e,t,n)=>U(new wue(e,t,n)),w7=new WeakMap;var Eue=class extends t1{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=U$.OBJECT,this.updateAfterType=U$.OBJECT,this.previousModelWorldMatrix=n2(new tZ),this.previousProjectionMatrix=n2(new tZ).setGroup($0),this.previousCameraViewMatrix=n2(new tZ)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=E7(n);this.previousModelWorldMatrix.value.copy(r);let i=T7(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new tZ,i.previousCameraViewMatrix=new tZ,i.currentProjectionMatrix=new tZ,i.currentCameraViewMatrix=new tZ,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){E7(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?J3:n2(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(n6).mul(a6),r=this.previousProjectionMatrix.mul(t).mul(o6),i=n.xy.div(n.w),a=r.xy.div(r.w),o=f2(i,a);return o}};function T7(e){let t=w7.get(e);return t===void 0&&(t={},w7.set(e,t)),t}function E7(e,t=0){let n=T7(e),r=n[t];return r===void 0&&(n[t]=r=new tZ,n[t].copy(e.matrixWorld)),r}const Due=G(Eue),D7=K(([e,t])=>S4(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),O7=K(([e,t])=>S4(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),k7=K(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),A7=K(([e,t])=>L4(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),w4(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Oue=K(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return i0(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),kue=K(([e])=>i0(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),Aue=K(([e])=>(K1(e.a.equal(0),()=>i0(0)),i0(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),jue=(...e)=>(console.warn(`THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.`),D7(e)),Mue=(...e)=>(console.warn(`THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.`),O7(e)),Nue=(...e)=>(console.warn(`THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.`),k7(e)),Pue=(...e)=>(console.warn(`THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.`),A7(e)),Fue=K(([e])=>j7(e.rgb)),Iue=K(([e,t=q(1)])=>t.mix(j7(e.rgb),e.rgb)),Lue=K(([e,t=q(1)])=>{let n=d2(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return L4(e.rgb,r,i)}),Rue=K(([e,t=q(1)])=>{let n=X(.57735,.57735,.57735),r=t.cos();return X(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(O4(n,e.rgb).mul(r.oneMinus())))))}),j7=(e,t=X(mX.getLuminanceCoefficients(new V)))=>O4(e,t),zue=K(([e,t=X(1),n=X(0),r=X(1),i=q(1),a=X(mX.getLuminanceCoefficients(new V,uY))])=>{let o=e.rgb.dot(X(a)),s=C4(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return K1(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),K1(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),K1(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),i0(s.rgb,e.a)});var Bue=class extends t1{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const Vue=W(Bue).setParameterLength(2),M7=new tX;var N7=class extends L3{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},P7=class extends N7{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}},F7=class e extends t1{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new UQ;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new EX(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:YJ,...r});a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=n2(0),this._cameraFar=n2(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=U$.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){let n=this.renderTarget.texture;t=n.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=U(new P7(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=U(new P7(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=B8(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=R8(i,n,r)}return t}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,t.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.texture.type=t.getColorBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),M7.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(M7)),this._pixelRatio=i,this.setSize(M7.width,M7.height);let o=t.getRenderTarget(),s=t.getMRT(),c=r.layers.mask;for(let e in this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(o),t.setMRT(s),r.layers.mask=c}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio*this._resolution,r=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};F7.COLOR=`color`,F7.DEPTH=`depth`;const Hue=(e,t,n)=>U(new F7(F7.COLOR,e,t,n)),Uue=(e,t)=>U(new N7(e,t)),Wue=(e,t,n)=>U(new F7(F7.DEPTH,e,t,n));var Gue=class extends F7{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(F7.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new Y8;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=TJ;let t=m6.negate(),n=J3.mul(n6),r=q(1),i=n.mul(i0(a6,1)),a=n.mul(i0(a6.add(t),1)),o=e4(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=i0(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}};const Kue=(e,t,n=new qZ(0,0,0),r=.003,i=1)=>U(new Gue(e,t,U(n),U(r),U(i))),que=K(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Jue=K(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Yue=K(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Xue=K(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),Zue=K(([e,t])=>{let n=l0(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=l0(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=Xue(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Que=l0(X(1.6605,-.1246,-.0182),X(-.5876,1.1329,-.1006),X(-.0728,-.0083,1.1187)),$ue=l0(X(.6274,.0691,.0164),X(.3293,.9195,.088),X(.0433,.0113,.8956)),ede=K(([e])=>{let t=X(e).toVar(),n=X(t.mul(t)).toVar(),r=X(n.mul(n)).toVar();return q(15.5).mul(r.mul(n)).sub(p2(40.14,r.mul(t))).add(p2(31.96,r).sub(p2(6.868,n.mul(t))).add(p2(.4298,n).add(p2(.1191,t).sub(.00232))))}),tde=K(([e,t])=>{let n=X(e).toVar(),r=l0(X(.856627153315983,.137318972929847,.11189821299995),X(.0951212405381588,.761241990602591,.0767994186031903),X(.0482516061458583,.101439036467562,.811302368396859)),i=l0(X(1.1271005818144368,-.1413297634984383,-.14132976349843826),X(-.11060664309660323,1.157823702216272,-.11060664309660294),X(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=q(-12.47393),o=q(4.026069);return n.mulAssign(t),n.assign($ue.mul(n)),n.assign(r.mul(n)),n.assign(C4(n,1e-10)),n.assign(Y2(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(R4(n,0,1)),n.assign(ede(n)),n.assign(i.mul(n)),n.assign(A4(C4(X(0),n),X(2.2))),n.assign(Que.mul(n)),n.assign(R4(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),nde=K(([e,t])=>{let n=q(.76),r=q(.15);e=e.mul(t);let i=S4(e.r,S4(e.g,e.b)),a=X4(i.lessThan(.08),i.sub(p2(6.25,i.mul(i))),.04);e.subAssign(a);let o=C4(e.r,C4(e.g,e.b));K1(o.lessThan(n),()=>e);let s=f2(1,n),c=f2(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=f2(1,m2(1,r.mul(o.sub(c)).add(1)));return L4(e,X(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]});var I7=class extends Q${static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}};const L7=W(I7).setParameterLength(1,3),rde=(e,t)=>L7(e,t,`js`),ide=(e,t)=>L7(e,t,`wgsl`),ade=(e,t)=>L7(e,t,`glsl`);var ode=class extends I7{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a),s=this.getNodeFunction(e).getCode(o);return a.code=s+`
|
|
431
|
-
`,t===`property`?o:e.format(`${o}()`,i,t)}};const R7=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=U(new
|
|
430
|
+
`).removeFlowTab();return e.addFlowTab(),a}};const g8=(...e)=>U(new ace(V1(e,`int`))).toStack(),oce=()=>D3(`continue`).toStack(),_8=()=>D3(`break`).toStack(),sce=(...e)=>(console.warn(`THREE.TSL: loop() has been renamed to Loop().`),g8(...e)),v8=new WeakMap,y8=new wX,b8=K(({bufferMap:e,influence:t,stride:n,width:r,depth:i,offset:a})=>{let o=J(o8).mul(n).add(a),s=o.div(r),c=o.sub(s.mul(r)),l=z3(e,Z1(c,s)).depth(i).xyz;return l.mul(t)});function cce(e){let t=e.morphAttributes.position!==void 0,n=e.morphAttributes.normal!==void 0,r=e.morphAttributes.color!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,a=i===void 0?0:i.length,o=v8.get(e);if(o===void 0||o.count!==a){o!==void 0&&o.texture.dispose();let i=e.morphAttributes.position||[],s=e.morphAttributes.normal||[],c=e.morphAttributes.color||[],l=0;t===!0&&(l=1),n===!0&&(l=2),r===!0&&(l=3);let u=e.attributes.position.count*l,d=1,f=4096;u>f&&(d=Math.ceil(u/f),u=f);let p=new Float32Array(u*d*4*a),m=new EX(p,u,d,a);m.type=qJ,m.needsUpdate=!0;let h=l*4;for(let e=0;e<a;e++){let a=i[e],o=s[e],l=c[e],f=u*d*4*e;for(let e=0;e<a.count;e++){let i=e*h;t===!0&&(y8.fromBufferAttribute(a,e),p[f+i+0]=y8.x,p[f+i+1]=y8.y,p[f+i+2]=y8.z,p[f+i+3]=0),n===!0&&(y8.fromBufferAttribute(o,e),p[f+i+4]=y8.x,p[f+i+5]=y8.y,p[f+i+6]=y8.z,p[f+i+7]=0),r===!0&&(y8.fromBufferAttribute(l,e),p[f+i+8]=y8.x,p[f+i+9]=y8.y,p[f+i+10]=y8.z,p[f+i+11]=l.itemSize===4?y8.w:1)}}o={count:a,texture:m,stride:l,size:new eX(u,d)},v8.set(e,o);function g(){m.dispose(),v8.delete(e),e.removeEventListener(`dispose`,g)}e.addEventListener(`dispose`,g)}return o}var lce=class extends Z${static get type(){return`MorphNode`}constructor(e){super(`void`),this.mesh=e,this.morphBaseInfluence=t2(1),this.updateType=H$.OBJECT}setup(e){let{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute(`normal`)&&t.morphAttributes.normal!==void 0,i=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=i===void 0?0:i.length,{texture:o,stride:s,size:c}=cce(t);n===!0&&a6.mulAssign(this.morphBaseInfluence),r===!0&&m6.mulAssign(this.morphBaseInfluence);let l=J(c.width);g8(a,({i:e})=>{let t=q(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?t.assign(z3(this.mesh.morphTexture,Z1(J(e).add(1),J(s8))).r):t.assign(P6(`morphTargetInfluences`,`float`).element(e).toVar()),G1(t.notEqual(0),()=>{n===!0&&a6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(0)})),r===!0&&m6.addAssign(b8({bufferMap:o,influence:t,stride:s,width:l,depth:e,offset:J(1)}))})})}update(){let e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((e,t)=>e+t,0)}};const x8=W(lce).setParameterLength(1);var S8=class extends Z${static get type(){return`LightingNode`}constructor(){super(`vec3`),this.isLightingNode=!0}},uce=class extends S8{static get type(){return`AONode`}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}},dce=class extends Z4{static get type(){return`LightingContextNode`}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,n=X().toVar(`directDiffuse`),r=X().toVar(`directSpecular`),i=X().toVar(`indirectDiffuse`),a=X().toVar(`indirectSpecular`),o={directDiffuse:n,directSpecular:r,indirectDiffuse:i,indirectSpecular:a},s={radiance:X().toVar(`radiance`),irradiance:X().toVar(`irradiance`),iblIrradiance:X().toVar(`iblIrradiance`),ambientOcclusion:q(1).toVar(`ambientOcclusion`),reflectedLight:o,backdrop:e,backdropAlpha:t};return s}setup(e){return this.value=this._value||=this.getContext(),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}};const C8=W(dce);var fce=class extends S8{static get type(){return`IrradianceNode`}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}};let w8,T8;var E8=class e extends Z${static get type(){return`ScreenNode`}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===e.VIEWPORT?`vec4`:`vec2`}getUpdateType(){let t=H$.NONE;return(this.scope===e.SIZE||this.scope===e.VIEWPORT)&&(t=H$.RENDER),this.updateType=t,t}update({renderer:t}){let n=t.getRenderTarget();this.scope===e.VIEWPORT?n===null?(t.getViewport(T8),T8.multiplyScalar(t.getPixelRatio())):T8.copy(n.viewport):n===null?t.getDrawingBufferSize(w8):(w8.width=n.width,w8.height=n.height)}setup(){let t=this.scope,n=null;return n=t===e.SIZE?t2(w8||=new eX):t===e.VIEWPORT?t2(T8||=new wX):Y(k8.div(O8)),n}generate(t){if(this.scope===e.COORDINATE){let e=t.getFragCoord();if(t.isFlipY()){let n=t.getNodeProperties(O8).outputNode.build(t);e=`${t.getType(`vec2`)}( ${e}.x, ${n}.y - ${e}.y )`}return e}return super.generate(t)}};E8.COORDINATE=`coordinate`,E8.VIEWPORT=`viewport`,E8.SIZE=`size`,E8.UV=`uv`;const D8=G(E8,E8.UV),O8=G(E8,E8.SIZE),k8=G(E8,E8.COORDINATE),A8=G(E8,E8.VIEWPORT),j8=A8.zw,M8=k8.sub(A8.xy),pce=M8.div(j8),mce=K(()=>(console.warn(`THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.`),O8),`vec2`).once()(),hce=K(()=>(console.warn(`THREE.TSL: "viewportTopLeft" is deprecated. Use "screenUV" instead.`),D8),`vec2`).once()(),gce=K(()=>(console.warn(`THREE.TSL: "viewportBottomLeft" is deprecated. Use "screenUV.flipY()" instead.`),D8.flipY()),`vec2`).once()(),N8=new eX;var P8=class extends L3{static get type(){return`ViewportTextureNode`}constructor(e=D8,t=null,n=null){n===null&&(n=new VQ,n.minFilter=HJ),super(n,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=H$.FRAME}updateBefore(e){let t=e.renderer;t.getDrawingBufferSize(N8);let n=this.value;(n.image.width!==N8.width||n.image.height!==N8.height)&&(n.image.width=N8.width,n.image.height=N8.height,n.needsUpdate=!0);let r=n.generateMipmaps;n.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(n),n.generateMipmaps=r}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}};const _ce=W(P8).setParameterLength(0,3),vce=W(P8,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let F8=null;var yce=class extends P8{static get type(){return`ViewportDepthTextureNode`}constructor(e=D8,t=null){F8===null&&(F8=new HQ),super(e,t,F8)}};const I8=W(yce).setParameterLength(0,2);var L8=class e extends Z${static get type(){return`ViewportDepthNode`}constructor(e,t=null){super(`float`),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(t){let{scope:n}=this;return n===e.DEPTH_BASE?t.getFragDepth():super.generate(t)}setup({camera:t}){let{scope:n}=this,r=this.valueNode,i=null;if(n===e.DEPTH_BASE)r!==null&&(i=H8().assign(r));else if(n===e.DEPTH)i=t.isPerspectiveCamera?z8(l6.z,K3,q3):R8(l6.z,K3,q3);else if(n===e.LINEAR_DEPTH)if(r!==null)if(t.isPerspectiveCamera){let e=B8(r,K3,q3);i=R8(e,K3,q3)}else i=r;else i=R8(l6.z,K3,q3);return i}};L8.DEPTH_BASE=`depthBase`,L8.DEPTH=`depth`,L8.LINEAR_DEPTH=`linearDepth`;const R8=(e,t,n)=>e.add(t).div(t.sub(n)),bce=(e,t,n)=>t.sub(n).mul(e).sub(t),z8=(e,t,n)=>t.add(e).mul(n).div(n.sub(t).mul(e)),B8=(e,t,n)=>t.mul(n).div(n.sub(t).mul(e).sub(n)),V8=(e,t,n)=>{t=t.max(1e-6).toVar();let r=J2(e.negate().div(t)),i=J2(n.div(t));return r.div(i)},xce=(e,t,n)=>{let r=e.mul(q2(n.div(t)));return q(Math.E).pow(r).mul(t).negate()},H8=W(L8,L8.DEPTH_BASE),U8=G(L8,L8.DEPTH),W8=W(L8,L8.LINEAR_DEPTH).setParameterLength(0,1),Sce=W8(I8());U8.assign=e=>H8(e);var G8=class e extends Z${static get type(){return`ClippingNode`}constructor(t=e.DEFAULT){super(),this.scope=t}setup(t){super.setup(t);let n=t.clippingContext,{intersectionPlanes:r,unionPlanes:i}=n;return this.hardwareClipping=t.material.hardwareClipping,this.scope===e.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===e.HARDWARE?this.setupHardwareClipping(i,t):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return K(()=>{let n=q().toVar(`distanceToPlane`),r=q().toVar(`distanceToGradient`),i=q(1).toVar(`clipOpacity`),a=t.length;if(this.hardwareClipping===!1&&a>0){let e=U3(t);g8(a,({i:t})=>{let a=e.element(t);n.assign(l6.dot(a.xyz).negate().add(a.w)),r.assign(n.fwidth().div(2)),i.mulAssign(B4(r.negate(),r,n))})}let o=e.length;if(o>0){let t=U3(e),a=q(1).toVar(`intersectionClipOpacity`);g8(o,({i:e})=>{let i=t.element(e);n.assign(l6.dot(i.xyz).negate().add(i.w)),r.assign(n.fwidth().div(2)),a.mulAssign(B4(r.negate(),r,n).oneMinus())}),i.mulAssign(a.oneMinus())}b0.a.mulAssign(i),b0.a.equal(0).discard()})()}setupDefault(e,t){return K(()=>{let n=t.length;if(this.hardwareClipping===!1&&n>0){let e=U3(t);g8(n,({i:t})=>{let n=e.element(t);l6.dot(n.xyz).greaterThan(n.w).discard()})}let r=e.length;if(r>0){let t=U3(e),n=X1(!0).toVar(`clipped`);g8(r,({i:e})=>{let r=t.element(e);n.assign(l6.dot(r.xyz).greaterThan(r.w).and(n))}),n.discard()}})()}setupHardwareClipping(e,t){let n=e.length;return t.enableHardwareClipping(n),K(()=>{let r=U3(e),i=W3(t.getClipDistance());g8(n,({i:e})=>{let t=r.element(e),n=l6.dot(t.xyz).sub(t.w).negate();i.element(e).assign(n)})})()}};G8.ALPHA_TO_COVERAGE=`alphaToCoverage`,G8.DEFAULT=`default`,G8.HARDWARE=`hardware`;const Cce=()=>U(new G8),wce=()=>U(new G8(G8.ALPHA_TO_COVERAGE)),Tce=()=>U(new G8(G8.HARDWARE)),Ece=.05,K8=K(([e])=>e4(f2(1e4,t4(f2(17,e.x).add(f2(.1,e.y)))).mul(u2(.1,s4(t4(f2(13,e.y).add(e.x))))))),q8=K(([e])=>K8(Y(K8(e.xy),e.z))),Dce=K(([e])=>{let t=S4(l4(f4(e.xyz)),l4(p4(e.xyz))),n=q(1).div(q(Ece).mul(t)).toVar(`pixScale`),r=Y(K2(Z2(J2(n))),K2(Q2(J2(n)))),i=Y(q8(Z2(r.x.mul(e.xyz))),q8(Z2(r.y.mul(e.xyz)))),a=e4(J2(n)),o=u2(f2(a.oneMinus(),i.x),f2(a,i.y)),s=x4(a,a.oneMinus()),c=X(o.mul(o).div(f2(2,s).mul(d2(1,s))),o.sub(f2(.5,s)).div(d2(1,s)),d2(1,d2(1,o).mul(d2(1,o)).div(f2(2,s).mul(d2(1,s))))),l=o.lessThan(s.oneMinus()).select(o.lessThan(s).select(c.x,c.y),c.z);return L4(l,1e-6,1)}).setLayout({name:`getAlphaHashThreshold`,type:`float`,inputs:[{name:`position`,type:`vec3`}]});var Oce=class extends j3{static get type(){return`VertexColorNode`}constructor(e){super(null,`vec4`),this.isVertexColorNode=!0,this.index=e}getAttributeName(){let e=this.index;return`color`+(e>0?e:``)}generate(e){let t=this.getAttributeName(e),n=e.hasGeometryAttribute(t),r;return r=n===!0?super.generate(e):e.generateConst(this.nodeType,new wX(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}};const J8=(e=0)=>U(new Oce(e));var Y8=class extends YZ{static get type(){return`NodeMaterial`}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,`shadowPositionNode`,{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn(`THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".`),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+D$(this)}build(e){this.setup(e)}setupObserver(e){return new S$(e)}setup(e){e.context.setupNormal=()=>this.setupNormal(e),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let t=e.renderer,n=t.getRenderTarget();e.addStack();let r=this.setupVertex(e),i=this.vertexNode||r;e.stack.outputNode=i,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow(`vertex`,e.removeStack()),e.addStack();let a,o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n===null?t.depth===!0&&this.setupDepth(e):n.depthBuffer===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);let r=this.setupLighting(e);o!==null&&e.stack.add(o);let i=r0(r,b0.a).max(0);a=this.setupOutput(e,i),R0.assign(a);let s=this.outputNode!==null;if(s&&(a=this.outputNode),n!==null){let e=t.getMRT(),n=this.mrtNode;e===null?n!==null&&(a=n):(s&&R0.assign(a),a=e,n!==null&&(a=e.merge(n)))}}else{let t=this.fragmentNode;t.isOutputStructNode!==!0&&(t=r0(t)),a=this.setupOutput(e,t)}e.stack.outputNode=a,e.addFlow(`fragment`,e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;let{unionPlanes:t,intersectionPlanes:n}=e.clippingContext,r=null;if(t.length>0||n.length>0){let t=e.renderer.samples;this.alphaToCoverage&&t>1?r=wce():e.stack.add(Cce())}return r}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable(`clipDistance`)&&(e.stack.add(Tce()),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:n}=e,r=this.depthNode;if(r===null){let e=t.getMRT();e&&e.has(`depth`)?r=e.get(`depth`):t.logarithmicDepthBuffer===!0&&(r=n.isPerspectiveCamera?V8(l6.z,K3,q3):R8(l6.z,K3,q3))}r!==null&&U8.assign(r).toStack()}setupPositionView(){return n6.mul(a6).xyz}setupModelViewProjection(){return J3.mul(l6)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),i8}setupPosition(e){let{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&x8(t).toStack(),t.isSkinnedMesh===!0&&h8(t).toStack(),this.displacementMap){let e=I6(`displacementMap`,`texture`),t=I6(`displacementScale`,`float`),n=I6(`displacementBias`,`float`);a6.addAssign(m6.normalize().mul(e.x.mul(t).add(n)))}return t.isBatchedMesh&&d8(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&u8(t).toStack(),this.positionNode!==null&&a6.assign(S3(this.positionNode,`POSITION`)),a6}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&X1(this.maskNode).not().discard();let n=this.colorNode?r0(this.colorNode):Z6;if(this.vertexColors===!0&&t.hasAttribute(`color`)&&(n=n.mul(J8())),e.instanceColor){let e=y0(`vec3`,`vInstanceColor`);n=e.mul(n)}if(e.isBatchedMesh&&e._colorsTexture){let e=y0(`vec3`,`vBatchColor`);n=e.mul(n)}b0.assign(n);let r=this.opacityNode?q(this.opacityNode):$6;b0.a.assign(b0.a.mul(r));let i=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(i=this.alphaTestNode===null?X6:q(this.alphaTestNode),b0.a.lessThanEqual(i).discard()),this.alphaHash===!0&&b0.a.lessThan(Dce(a6)).discard();let a=this.transparent===!1&&this.blending===EJ&&this.alphaToCoverage===!1;a?b0.a.assign(1):i===null&&b0.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?X(0):b0.rgb}setupNormal(){return this.normalNode?X(this.normalNode):e8}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?I6(`envMap`,`cubeTexture`):I6(`envMap`,`texture`)),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new fce(t8)),t}setupLights(e){let t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);let r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){let e=this.aoNode===null?n8:this.aoNode;t.push(new uce(e))}let i=this.lightsNode||e.lightsNode;return t.length>0&&(i=e.renderer.lighting.createNode([...i.getLights(),...t])),i}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:n,backdropAlphaNode:r,emissiveNode:i}=this,a=this.lights===!0||this.lightsNode!==null,o=a?this.setupLights(e):null,s=this.setupOutgoingLight(e);if(o&&o.getScope().hasLights){let t=this.setupLightingModel(e)||null;s=C8(o,t,n,r)}else n!==null&&(s=X(r===null?n:I4(s,n,r)));return(i&&i.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(x0.assign(X(i||Q6)),s=s.add(x0)),s}setupFog(e,t){let n=e.fogNode;return n&&(R0.assign(t),t=r0(n)),t}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),t}setDefaultValues(e){for(let t in e){let n=e[t];this[t]===void 0&&(this[t]=n,n&&n.clone&&(this[t]=n.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,e)===void 0&&t[e].get!==void 0&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{},nodes:{}});let n=YZ.prototype.toJSON.call(this,e),r=O$(this);n.inputNodes={};for(let{property:t,childNode:i}of r)n.inputNodes[t]=i.toJSON(e).uuid;function i(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=i(e.textures),r=i(e.images),a=i(e.nodes);t.length>0&&(n.textures=t),r.length>0&&(n.images=r),a.length>0&&(n.nodes=a)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}};let X8=null;var kce=class extends P8{static get type(){return`ViewportSharedTextureNode`}constructor(e=D8,t=null){X8===null&&(X8=new VQ),super(e,t,X8)}updateReference(){return this}};const Ace=W(kce).setParameterLength(0,2),jce=e=>U(e).mul(.5).add(.5),Mce=e=>U(e).mul(2).sub(1);var Nce=class extends e1{static get type(){return`EquirectUVNode`}constructor(e=c6){super(`vec2`),this.dirNode=e}setup(){let e=this.dirNode,t=e.z.atan(e.x).mul(1/(Math.PI*2)).add(.5),n=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Y(t,n)}};const Z8=W(Nce).setParameterLength(0,1),Q8=K(({f0:e,f90:t,dotVH:n})=>{let r=n.mul(-5.55473).sub(6.98316).mul(n).exp2();return e.mul(r.oneMinus()).add(t.mul(r))}),Pce=K(e=>e.diffuseColor.mul(1/Math.PI)),$8=K(e=>{if(e.geometry.hasAttribute(`normal`)===!1)return q(0);let t=g6.dFdx().abs().max(g6.dFdy().abs()),n=t.x.max(t.y).max(t.z);return n}),Fce=K(e=>{let{roughness:t}=e,n=$8(),r=t.max(.0525);return r=r.add(n),r=r.min(1),r}),e5=K(({alpha:e,dotNL:t,dotNV:n})=>{let r=e.pow2(),i=t.mul(r.add(r.oneMinus().mul(n.pow2())).sqrt()),a=n.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt());return p2(.5,i.add(a).max(L2))}).setLayout({name:`V_GGX_SmithCorrelated`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNL`,type:`float`},{name:`dotNV`,type:`float`}]}),Ice=K(({alphaT:e,alphaB:t,dotTV:n,dotBV:r,dotTL:i,dotBL:a,dotNV:o,dotNL:s})=>{let c=s.mul(X(e.mul(n),t.mul(r),o).length()),l=o.mul(X(e.mul(i),t.mul(a),s).length()),u=p2(.5,c.add(l));return u.saturate()}).setLayout({name:`V_GGX_SmithCorrelated_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotTV`,type:`float`,qualifier:`in`},{name:`dotBV`,type:`float`,qualifier:`in`},{name:`dotTL`,type:`float`,qualifier:`in`},{name:`dotBL`,type:`float`,qualifier:`in`},{name:`dotNV`,type:`float`,qualifier:`in`},{name:`dotNL`,type:`float`,qualifier:`in`}]}),t5=K(({alpha:e,dotNH:t})=>{let n=e.pow2(),r=t.pow2().mul(n.oneMinus()).oneMinus();return n.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:`D_GGX`,type:`float`,inputs:[{name:`alpha`,type:`float`},{name:`dotNH`,type:`float`}]}),Lce=q(1/Math.PI),Rce=K(({alphaT:e,alphaB:t,dotNH:n,dotTH:r,dotBH:i})=>{let a=e.mul(t),o=X(t.mul(r),e.mul(i),a.mul(n)),s=o.dot(o),c=a.div(s);return Lce.mul(a.mul(c.pow2()))}).setLayout({name:`D_GGX_Anisotropic`,type:`float`,inputs:[{name:`alphaT`,type:`float`,qualifier:`in`},{name:`alphaB`,type:`float`,qualifier:`in`},{name:`dotNH`,type:`float`,qualifier:`in`},{name:`dotTH`,type:`float`,qualifier:`in`},{name:`dotBH`,type:`float`,qualifier:`in`}]}),zce=K(e=>{let{lightDirection:t,f0:n,f90:r,roughness:i,f:a,USE_IRIDESCENCE:o,USE_ANISOTROPY:s}=e,c=e.normalView||v6,l=i.pow2(),u=t.add(u6).normalize(),d=c.dot(t).clamp(),f=c.dot(u6).clamp(),p=c.dot(u).clamp(),m=u6.dot(u).clamp(),h=Q8({f0:n,f90:r,dotVH:m}),g,_;if(L1(o)&&(h=O0.mix(h,a)),L1(s)){let e=N0.dot(t),n=N0.dot(u6),r=N0.dot(u),i=P0.dot(t),a=P0.dot(u6),o=P0.dot(u);g=Ice({alphaT:j0,alphaB:l,dotTV:n,dotBV:a,dotTL:e,dotBL:i,dotNV:f,dotNL:d}),_=Rce({alphaT:j0,alphaB:l,dotNH:p,dotTH:r,dotBH:o})}else g=e5({alpha:l,dotNL:d,dotNV:f}),_=t5({alpha:l,dotNH:p});return h.mul(g).mul(_)}),Bce=K(({roughness:e,dotNV:t})=>{let n=r0(-1,-.0275,-.572,.022),r=r0(1,.0425,1.04,-.04),i=e.mul(n).add(r),a=i.x.mul(i.x).min(t.mul(-9.28).exp2()).mul(i.x).add(i.y),o=Y(-1.04,1.04).mul(a).add(i.zw);return o}).setLayout({name:`DFGApprox`,type:`vec2`,inputs:[{name:`roughness`,type:`float`},{name:`dotNV`,type:`vec3`}]}),Vce=K(({f:e,f90:t,dotVH:n})=>{let r=n.oneMinus().saturate(),i=r.mul(r),a=r.mul(i,i).clamp(0,.9999);return e.sub(X(t).mul(a)).div(a.oneMinus())}).setLayout({name:`Schlick_to_F0`,type:`vec3`,inputs:[{name:`f`,type:`vec3`},{name:`f90`,type:`float`},{name:`dotVH`,type:`float`}]}),n5=1/6,r5=e=>f2(n5,f2(e,f2(e,e.negate().add(3)).sub(3)).add(1)),i5=e=>f2(n5,f2(e,f2(e,f2(3,e).sub(6))).add(4)),a5=e=>f2(n5,f2(e,f2(e,f2(-3,e).add(3)).add(3)).add(1)),o5=e=>f2(n5,k4(e,3)),s5=e=>r5(e).add(i5(e)),c5=e=>a5(e).add(o5(e)),l5=e=>u2(-1,i5(e).div(r5(e).add(i5(e)))),u5=e=>u2(1,o5(e).div(a5(e).add(o5(e)))),d5=(e,t,n)=>{let r=e.uvNode,i=f2(r,t.zw).add(.5),a=Z2(i),o=e4(i),s=s5(o.x),c=c5(o.x),l=l5(o.x),u=u5(o.x),d=l5(o.y),f=u5(o.y),p=Y(a.x.add(l),a.y.add(d)).sub(.5).mul(t.xy),m=Y(a.x.add(u),a.y.add(d)).sub(.5).mul(t.xy),h=Y(a.x.add(l),a.y.add(f)).sub(.5).mul(t.xy),g=Y(a.x.add(u),a.y.add(f)).sub(.5).mul(t.xy),_=s5(o.y).mul(u2(s.mul(e.sample(p).level(n)),c.mul(e.sample(m).level(n)))),v=c5(o.y).mul(u2(s.mul(e.sample(h).level(n)),c.mul(e.sample(g).level(n))));return _.add(v)},Hce=K(([e,t=q(3)])=>{let n=Y(e.size(J(t))),r=Y(e.size(J(t.add(1)))),i=p2(1,n),a=p2(1,r),o=d5(e,r0(i,n),Z2(t)),s=d5(e,r0(a,r),Q2(t));return e4(t).mix(o,s)}),Uce=X(.04),Wce=q(1),f5=q(1),p5=q(-2),m5=q(.8),h5=q(-1),g5=q(.4),_5=q(2),v5=q(.305),y5=q(3),b5=q(.21),Gce=q(4),x5=q(4),Kce=q(16),qce=K(([e])=>{let t=X(s4(e)).toVar(),n=q(-1).toVar();return G1(t.x.greaterThan(t.z),()=>{G1(t.x.greaterThan(t.y),()=>{n.assign(Y4(e.x.greaterThan(0),0,3))}).Else(()=>{n.assign(Y4(e.y.greaterThan(0),1,4))})}).Else(()=>{G1(t.z.greaterThan(t.y),()=>{n.assign(Y4(e.z.greaterThan(0),2,5))}).Else(()=>{n.assign(Y4(e.y.greaterThan(0),1,4))})}),n}).setLayout({name:`getFace`,type:`float`,inputs:[{name:`direction`,type:`vec3`}]}),Jce=K(([e,t])=>{let n=Y().toVar();return G1(t.equal(0),()=>{n.assign(Y(e.z,e.y).div(s4(e.x)))}).ElseIf(t.equal(1),()=>{n.assign(Y(e.x.negate(),e.z.negate()).div(s4(e.y)))}).ElseIf(t.equal(2),()=>{n.assign(Y(e.x.negate(),e.y).div(s4(e.z)))}).ElseIf(t.equal(3),()=>{n.assign(Y(e.z.negate(),e.y).div(s4(e.x)))}).ElseIf(t.equal(4),()=>{n.assign(Y(e.x.negate(),e.z).div(s4(e.y)))}).Else(()=>{n.assign(Y(e.x,e.y).div(s4(e.z)))}),f2(.5,n.add(1))}).setLayout({name:`getUV`,type:`vec2`,inputs:[{name:`direction`,type:`vec3`},{name:`face`,type:`float`}]}),Yce=K(([e])=>{let t=q(0).toVar();return G1(e.greaterThanEqual(m5),()=>{t.assign(f5.sub(e).mul(h5.sub(p5)).div(f5.sub(m5)).add(p5))}).ElseIf(e.greaterThanEqual(g5),()=>{t.assign(m5.sub(e).mul(_5.sub(h5)).div(m5.sub(g5)).add(h5))}).ElseIf(e.greaterThanEqual(v5),()=>{t.assign(g5.sub(e).mul(y5.sub(_5)).div(g5.sub(v5)).add(_5))}).ElseIf(e.greaterThanEqual(b5),()=>{t.assign(v5.sub(e).mul(Gce.sub(y5)).div(v5.sub(b5)).add(y5))}).Else(()=>{t.assign(q(-2).mul(J2(f2(1.16,e))))}),t}).setLayout({name:`roughnessToMip`,type:`float`,inputs:[{name:`roughness`,type:`float`}]}),S5=K(([e,t])=>{let n=e.toVar();n.assign(f2(2,n).sub(1));let r=X(n,1).toVar();return G1(t.equal(0),()=>{r.assign(r.zyx)}).ElseIf(t.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:`getDirection`,type:`vec3`,inputs:[{name:`uv`,type:`vec2`},{name:`face`,type:`float`}]}),C5=K(([e,t,n,r,i,a])=>{let o=q(n),s=X(t),c=L4(Yce(o),p5,a),l=e4(c),u=Z2(c),d=X(w5(e,s,u,r,i,a)).toVar();return G1(l.notEqual(0),()=>{let t=X(w5(e,s,u.add(1),r,i,a)).toVar();d.assign(I4(d,t,l))}),d}),w5=K(([e,t,n,r,i,a])=>{let o=q(n).toVar(),s=X(t),c=q(qce(s)).toVar(),l=q(S4(x5.sub(o),0)).toVar();o.assign(S4(o,x5));let u=q(K2(o)).toVar(),d=Y(Jce(s,c).mul(u.sub(2)).add(1)).toVar();return G1(c.greaterThan(2),()=>{d.y.addAssign(u),c.subAssign(3)}),d.x.addAssign(c.mul(u)),d.x.addAssign(l.mul(f2(3,Kce))),d.y.addAssign(f2(4,K2(a).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),e.sample(d).grad(Y(),Y())}),T5=K(({envMap:e,mipInt:t,outputDirection:n,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:s})=>{let c=n4(r),l=n.mul(c).add(i.cross(n).mul(t4(r))).add(i.mul(i.dot(n).mul(c.oneMinus())));return w5(e,l,t,a,o,s)}),E5=K(({n:e,latitudinal:t,poleAxis:n,outputDirection:r,weights:i,samples:a,dTheta:o,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{let f=X(Y4(t,n,O4(n,r))).toVar();G1(f.equal(X(0)),()=>{f.assign(X(r.z,0,r.x.negate()))}),f.assign($2(f));let p=X().toVar();return p.addAssign(i.element(0).mul(T5({theta:0,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),g8({start:J(1),end:e},({i:e})=>{G1(e.greaterThanEqual(a),()=>{_8()});let t=q(o.mul(q(e))).toVar();p.addAssign(i.element(e).mul(T5({theta:t.mul(-1),axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(e).mul(T5({theta:t,axis:f,outputDirection:r,mipInt:s,envMap:c,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),r0(p,1)}),D5=4,O5=[.125,.215,.35,.446,.526,.582],k5=20,A5=new o$(-1,1,1,-1,0,1),Xce=new jQ(90,1),j5=new KZ;let M5=null,N5=0,P5=0;const F5=(1+Math.sqrt(5))/2,I5=1/F5,L5=[new V(-F5,I5,0),new V(F5,I5,0),new V(-I5,0,F5),new V(I5,0,F5),new V(0,F5,-I5),new V(0,F5,I5),new V(-1,1,-1),new V(1,1,-1),new V(-1,1,1),new V(1,1,1)],Zce=new V,R5=new WeakMap,Qce=[3,1,5,0,4,2],z5=S5(N3(),M3(`faceIndex`)).normalize(),B5=X(z5.x,z5.y,z5.z);var $ce=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,i={}){let{size:a=256,position:o=Zce,renderTarget:s=null}=i;if(this._setSize(a),this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.`);let a=s||this._allocateTarget();return i.renderTarget=a,this.fromSceneAsync(e,t,n,r,i),a}M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let c=s||this._allocateTarget();return c.depthBuffer=!0,this._init(c),this._sceneToCubeUV(e,n,r,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,n=.1,r=100,i={}){return this._hasInitialized===!1&&await this._renderer.init(),this.fromScene(e,t,n,r,i)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn(`THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead.`),this._setSizeFromTexture(e);let n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return this._hasInitialized===!1&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=W5(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=G5(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===PJ||e.mapping===FJ?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(M5,N5,P5),e.scissorTest=!1,H5(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),M5=this._renderer.getRenderTarget(),N5=this._renderer.getActiveCubeFace(),P5=this._renderer.getActiveMipmapLevel();let n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){let e=3*Math.max(this._cubeSize,16*7),t=4*this._cubeSize,n=V5(e,t);return n}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=V5(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=ele(t)),this._blurMaterial=tle(t,e.width,e.height)}}async _compileMaterial(e){let t=new CQ(this._lodPlanes[0],e);await this._renderer.compile(t,A5)}_sceneToCubeUV(e,t,n,r,i){let a=Xce;a.near=t,a.far=n;let o=[1,1,1,1,-1,1],s=[1,-1,1,-1,1,-1],c=this._renderer,l=c.autoClear;c.getClearColor(j5),c.autoClear=!1;let u=this._backgroundBox;if(u===null){let e=new XZ({name:`PMREM.Background`,side:wJ,depthWrite:!1,depthTest:!1});u=new CQ(new EQ,e)}let d=!1,f=e.background;f?f.isColor&&(u.material.color.copy(f),e.background=null,d=!0):(u.material.color.copy(j5),d=!0),c.setRenderTarget(r),c.clear(),d&&c.render(u,a);for(let t=0;t<6;t++){let n=t%3;n===0?(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x+s[t],i.y,i.z)):n===1?(a.up.set(0,0,o[t]),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y+s[t],i.z)):(a.up.set(0,o[t],0),a.position.set(i.x,i.y,i.z),a.lookAt(i.x,i.y,i.z+s[t]));let l=this._cubeSize;H5(r,n*l,t>2?l:0,l,l),c.render(e,a)}c.autoClear=l,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===PJ||e.mapping===FJ;r?this._cubemapMaterial===null&&(this._cubemapMaterial=W5(e)):this._equirectMaterial===null&&(this._equirectMaterial=G5(e));let i=r?this._cubemapMaterial:this._equirectMaterial;i.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=i;let o=this._cubeSize;H5(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,A5)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let t=1;t<r;t++){let n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),i=L5[(r-t-1)%L5.length];this._blur(e,t-1,t,n,i)}t.autoClear=n}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&console.error(`blur direction must be either latitudinal or longitudinal!`);let l=3,u=this._lodMeshes[r];u.material=c;let d=R5.get(c),f=this._sizeLods[n]-1,p=isFinite(i)?Math.PI/(2*f):2*Math.PI/(2*k5-1),m=i/p,h=isFinite(i)?1+Math.floor(l*m):k5;h>k5&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${k5}`);let g=[],_=0;for(let e=0;e<k5;++e){let t=e/m,n=Math.exp(-t*t/2);g.push(n),e===0?_+=n:e<h&&(_+=2*n)}for(let e=0;e<g.length;e++)g[e]=g[e]/_;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=h,d.weights.array=g,d.latitudinal.value=a===`latitudinal`?1:0,o&&(d.poleAxis.value=o);let{_lodMax:v}=this;d.dTheta.value=p,d.mipInt.value=v-n;let y=this._sizeLods[r],b=3*y*(r>v-D5?r-v+D5:0),x=4*(this._cubeSize-y);H5(t,b,x,3*y,2*y),s.setRenderTarget(t),s.render(u,A5)}};function ele(e){let t=[],n=[],r=[],i=[],a=e,o=e-D5+1+O5.length;for(let s=0;s<o;s++){let o=2**a;n.push(o);let c=1/o;s>e-D5?c=O5[s-e+D5-1]:s===0&&(c=0),r.push(c);let l=1/(o-2),u=-l,d=1+l,f=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,m=6,h=3,g=2,_=1,v=new Float32Array(h*m*p),y=new Float32Array(g*m*p),b=new Float32Array(_*m*p);for(let e=0;e<p;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0],i=Qce[e];v.set(r,h*m*i),y.set(f,g*m*i);let a=[i,i,i,i,i,i];b.set(a,_*m*i)}let x=new dQ;x.setAttribute(`position`,new eQ(v,h)),x.setAttribute(`uv`,new eQ(y,g)),x.setAttribute(`faceIndex`,new eQ(b,_)),t.push(x),i.push(new CQ(x,null)),a>D5&&a--}return{lodPlanes:t,sizeLods:n,sigmas:r,lodMeshes:i}}function V5(e,t){let n={magFilter:VJ,minFilter:VJ,generateMipmaps:!1,type:JJ,format:YJ,colorSpace:lY},r=new TX(e,t,n);return r.texture.mapping=IJ,r.texture.name=`PMREM.cubeUv`,r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function H5(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function U5(e){let t=new Y8;return t.depthTest=!1,t.depthWrite=!1,t.blending=TJ,t.name=`PMREM_${e}`,t}function tle(e,t,n){let r=U3(Array(k5).fill(0)),i=t2(new V(0,1,0)),a=t2(0),o=q(k5),s=t2(0),c=t2(1),l=R3(null),u=t2(0),d=q(1/t),f=q(1/n),p=q(e),m={n:o,latitudinal:s,weights:r,poleAxis:i,outputDirection:B5,dTheta:a,samples:c,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:f,CUBEUV_MAX_MIP:p},h=U5(`blur`);return h.fragmentNode=E5({...m,latitudinal:s.equal(1)}),R5.set(h,m),h}function W5(e){let t=U5(`cubemap`);return t.fragmentNode=M6(e,B5),t}function G5(e){let t=U5(`equirect`);return t.fragmentNode=R3(e,Z8(B5),0),t}const K5=new WeakMap;function nle(e){let t=Math.log2(e)-2,n=1/e,r=1/(3*Math.max(2**t,7*16));return{texelWidth:r,texelHeight:n,maxMip:t}}function rle(e,t,n){let r=ile(t),i=r.get(e),a=i===void 0?-1:i.pmremVersion;if(a!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(ole(t))i=n.fromCubemap(e,i);else return null;else if(sle(t))i=n.fromEquirectangular(e,i);else return null;i.pmremVersion=e.pmremVersion,r.set(e,i)}return i.texture}function ile(e){let t=K5.get(e);return t===void 0&&(t=new WeakMap,K5.set(e,t)),t}var ale=class extends e1{static get type(){return`PMREMNode`}constructor(e,t=null,n=null){super(`vec3`),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;let r=new CX;r.isRenderTargetTexture=!0,this._texture=R3(r),this._width=t2(0),this._height=t2(0),this._maxMip=t2(0),this.updateBeforeType=H$.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=nle(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(t=r.isPMREMTexture===!0?r:rle(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new $ce(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=T6.mul(X(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),C5(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}};function ole(e){if(e==null)return!1;let t=0,n=6;for(let r=0;r<n;r++)e[r]!==void 0&&t++;return t===n}function sle(e){return e==null?!1:e.height>0}const cle=W(ale).setParameterLength(1,3);var lle=class extends e1{static get type(){return`MatcapUVNode`}constructor(){super(`vec2`)}setup(){let e=X(u6.z,0,u6.x.negate()).normalize(),t=u6.cross(e);return Y(e.dot(v6),t.dot(v6)).mul(.495).add(.5)}};const ule=G(lle);var dle=class extends e1{static get type(){return`RotateNode`}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){let{rotationNode:t,positionNode:n}=this,r=this.getNodeType(e);if(r===`vec2`){let e=t.cos(),r=t.sin(),i=s0(e,r,r.negate(),e);return i.mul(n)}else{let e=t,r=l0(r0(1,0,0,0),r0(0,n4(e.x),t4(e.x).negate(),0),r0(0,t4(e.x),n4(e.x),0),r0(0,0,0,1)),i=l0(r0(n4(e.y),0,t4(e.y),0),r0(0,1,0,0),r0(t4(e.y).negate(),0,n4(e.y),0),r0(0,0,0,1)),a=l0(r0(n4(e.z),t4(e.z).negate(),0,0),r0(t4(e.z),n4(e.z),0,0),r0(0,0,1,0),r0(0,0,0,1));return r.mul(i).mul(a).mul(r0(n,1)).xyz}}};const q5=W(dle).setParameterLength(2),fle=v0(`vec3`),ple=v0(`vec3`),mle=v0(`vec3`);var hle=class{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this.weakMap;for(let t=0;t<e.length-1;t++){let r=e[t];n.has(r)===!1&&n.set(r,new WeakMap),n=n.get(r)}return n.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}},gle=class extends _0{static get type(){return`ParameterNode`}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}};const _le=(e,t)=>U(new gle(e,t));var vle=class extends Z${static get type(){return`StackNode`}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):`void`}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):`void`}add(e){return this.nodes.push(e),this}If(e,t){let n=new z1(t);return this._currentCond=Y4(e,n),this.add(this._currentCond)}ElseIf(e,t){let n=new z1(t),r=Y4(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new z1(e),this}Switch(e){return this._expressionNode=U(e),this}Case(...e){let t=[];if(e.length>=2)for(let n=0;n<e.length-1;n++)t.push(this._expressionNode.equal(U(e[n])));else throw Error(`TSL: Invalid parameter length. Case() requires at least two parameters.`);let n=e[e.length-1],r=new z1(n),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let a=Y4(i,r);return this._currentCond===null?(this._currentCond=a,this.add(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}build(e,...t){let n=W1();U1(this);let r=e.buildStage;for(let t of this.nodes)if(r===`setup`)t.build(e);else if(r===`analyze`)t.build(e,this);else if(r===`generate`){let n=e.getDataFromNode(t,`any`).stages,r=n&&n[e.shaderStage];if(t.isVarNode&&r&&r.length===1&&r[0]&&r[0].isStackNode)continue;t.build(e,`void`)}return U1(n),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn(`THREE.TSL: .else() has been renamed to .Else().`),this.Else(...e)}elseif(...e){return console.warn(`THREE.TSL: .elseif() has been renamed to .ElseIf().`),this.ElseIf(...e)}};const yle=W(vle).setParameterLength(0,1);function ble(e){return Object.entries(e).map(([e,t])=>typeof t==`string`?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}var xle=class extends Z${static get type(){return`StructTypeNode`}constructor(e,t=null){super(`struct`),this.membersLayout=ble(e),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=8,t=Float32Array.BYTES_PER_ELEMENT,n=0;for(let r of this.membersLayout){let i=r.type,a=P$(i)*t,o=F$(i),s=n%e,c=s%o,l=s+c;n+=c,l!==0&&e-l<a&&(n+=e-l),n+=a}return Math.ceil(n/e)*e/t}getMemberType(e,t){let n=this.membersLayout.find(e=>e.name===t);return n?n.type:`void`}getNodeType(e){let t=e.getStructTypeFromNode(this,this.membersLayout,this.name);return t.name}setup(e){e.addInclude(this)}generate(e){return this.getNodeType(e)}},Sle=class extends Z${static get type(){return`StructNode`}constructor(e,t){super(`vec3`),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}};const Cle=(e,t=null)=>{let n=new xle(e,t),r=(...t)=>{let r=null;if(t.length>0)if(t[0].isNode){r={};let n=Object.keys(e);for(let e=0;e<t.length;e++)r[n[e]]=t[e]}else r=t[0];return U(new Sle(n,r))};return r.layout=n,r.isStruct=!0,r};var J5=class extends Z${static get type(){return`OutputStructNode`}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){let t=e.getNodeProperties(this);if(t.membersLayout===void 0){let n=this.members,r=[];for(let t=0;t<n.length;t++){let i=`m`+t,a=n[t].getNodeType(e);r.push({name:i,type:a,index:t})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){let t=e.getOutputStructName(),n=this.members,r=t===``?``:t+`.`;for(let t=0;t<n.length;t++){let i=n[t].build(e);e.addLineFlowCode(`${r}m${t} = ${i}`,this)}return t}};const wle=W(J5);function Y5(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t)return n;return-1}var Tle=class extends J5{static get type(){return`MRTNode`}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes};return X5(t)}setup(e){let t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],i=n.textures;for(let e in t){let n=Y5(i,e);r[n]=r0(t[e])}return this.members=r,super.setup(e)}};const X5=W(Tle),Ele=K(([e])=>{let t=e.toUint().mul(747796405).add(2891336453),n=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737),r=n.shiftRight(22).bitXor(n);return r.toFloat().mul(1/2**32)}),Z5=(e,t)=>k4(f2(4,e.mul(d2(1,e))),t),Dle=(e,t)=>e.lessThan(.5)?Z5(e.mul(2),t).div(2):d2(1,Z5(f2(d2(1,e),2),t).div(2)),Ole=(e,t,n)=>k4(p2(k4(e,t),u2(k4(e,t),k4(d2(1,e),n))),1/t),kle=(e,t)=>t4(z2.mul(t.mul(e).sub(1))).div(z2.mul(t.mul(e).sub(1))),Q5=K(([e])=>e.fract().sub(.5).abs()).setLayout({name:`tri`,type:`float`,inputs:[{name:`x`,type:`float`}]}),Ale=K(([e])=>X(Q5(e.z.add(Q5(e.y.mul(1)))),Q5(e.z.add(Q5(e.x.mul(1)))),Q5(e.y.add(Q5(e.x.mul(1)))))).setLayout({name:`tri3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),jle=K(([e,t,n])=>{let r=X(e).toVar(),i=q(1.4).toVar(),a=q(0).toVar(),o=X(r).toVar();return g8({start:q(0),end:q(3),type:`float`,condition:`<=`},()=>{let e=X(Ale(o.mul(2))).toVar();r.addAssign(e.add(n.mul(q(.1).mul(t)))),o.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);let s=q(Q5(r.z.add(Q5(r.x.add(Q5(r.y)))))).toVar();a.addAssign(s.div(i)),o.addAssign(.14)}),a}).setLayout({name:`triNoise3D`,type:`float`,inputs:[{name:`position`,type:`vec3`},{name:`speed`,type:`float`},{name:`time`,type:`float`}]});var Mle=class extends Z${static get type(){return`FunctionOverloadingNode`}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){let t=this.parametersNodes,n=this._candidateFnCall;if(n===null){let r=null,i=-1;for(let n of this.functionNodes){let a=n.shaderNode,o=a.layout;if(o===null)throw Error(`FunctionOverloadingNode: FunctionNode must be a layout.`);let s=o.inputs;if(t.length===s.length){let a=0;for(let n=0;n<t.length;n++){let r=t[n],i=s[n];r.getNodeType(e)===i.type?a++:a=0}a>i&&(r=n,i=a)}}this._candidateFnCall=n=r(...t)}return n}};const Nle=W(Mle),$5=e=>(...t)=>Nle(e,...t),e7=t2(0).setGroup(Q0).onRenderUpdate(e=>e.time),t7=t2(0).setGroup(Q0).onRenderUpdate(e=>e.deltaTime),Ple=t2(0,`uint`).setGroup(Q0).onRenderUpdate(e=>e.frameId),Fle=(e=1)=>(console.warn(`TSL: timerLocal() is deprecated. Use "time" instead.`),e7.mul(e)),Ile=(e=1)=>(console.warn(`TSL: timerGlobal() is deprecated. Use "time" instead.`),e7.mul(e)),Lle=(e=1)=>(console.warn(`TSL: timerDelta() is deprecated. Use "deltaTime" instead.`),t7.mul(e)),Rle=(e=e7)=>e.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),zle=(e=e7)=>e.fract().round(),Ble=(e=e7)=>e.add(.5).fract().mul(2).sub(1).abs(),Vle=(e=e7)=>e.fract(),Hle=K(([e,t,n=Y(.5)])=>q5(e.sub(n),t).add(n)),Ule=K(([e,t,n=Y(.5)])=>{let r=e.sub(n),i=r.dot(r),a=i.mul(i),o=a.mul(t);return e.add(r.mul(o))}),Wle=K(({position:e=null,horizontal:t=!0,vertical:n=!1})=>{let r;e===null?r=e6:(r=e6.toVar(),r[3][0]=e.x,r[3][1]=e.y,r[3][2]=e.z);let i=Y3.mul(r);return L1(t)&&(i[0][0]=e6[0].length(),i[0][1]=0,i[0][2]=0),L1(n)&&(i[1][0]=0,i[1][1]=e6[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,J3.mul(i).mul(a6)}),Gle=K(([e=null])=>{let t=W8(),n=W8(I8(e)).sub(t),r=n.lessThan(0).select(D8,e);return r});var Kle=class extends Z${static get type(){return`SpriteSheetUVNode`}constructor(e,t=N3(),n=q(0)){super(`vec2`),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){let{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:i}=n,a=e.mod(r.mul(i)).floor(),o=a.mod(r),s=i.sub(a.add(1).div(r).ceil()),c=n.reciprocal(),l=Y(o,s);return t.add(l).mul(c)}};const qle=W(Kle).setParameterLength(3);var Jle=class extends Z${static get type(){return`TriplanarTexturesNode`}constructor(e,t=null,n=null,r=q(1),i=a6,a=m6){super(`vec4`),this.textureXNode=e,this.textureYNode=t,this.textureZNode=n,this.scaleNode=r,this.positionNode=i,this.normalNode=a}setup(){let{textureXNode:e,textureYNode:t,textureZNode:n,scaleNode:r,positionNode:i,normalNode:a}=this,o=a.abs().normalize();o=o.div(o.dot(X(1)));let s=i.yz.mul(r),c=i.zx.mul(r),l=i.xy.mul(r),u=e.value,d=t===null?u:t.value,f=n===null?u:n.value,p=R3(u,s).mul(o.x),m=R3(d,c).mul(o.y),h=R3(f,l).mul(o.z);return u2(p,m,h)}};const n7=W(Jle).setParameterLength(1,6),Yle=(...e)=>n7(...e),r7=new BQ,i7=new V,a7=new V,o7=new V,s7=new eZ,c7=new V(0,0,-1),l7=new wX,u7=new V,d7=new V,f7=new wX,p7=new eX,m7=new TX,Xle=D8.flipX();m7.depthTexture=new HQ(1,1);let h7=!1;var Zle=class e extends L3{static get type(){return`ReflectorNode`}constructor(e={}){super(e.defaultTexture||m7.texture,Xle),this._reflectorBaseNode=e.reflector||new Qle(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw Error(`THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. `);this._depthNode=U(new e({defaultTexture:m7.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){let e=new this.constructor(this.reflectorNode);return e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}},Qle=class extends Z${static get type(){return`ReflectorBaseNode`}constructor(e,t={}){super();let{target:n=new DZ,resolution:r=1,generateMipmaps:i=!1,bounces:a=!0,depth:o=!1}=t;this.textureNode=e,this.target=n,this.resolution=r,this.generateMipmaps=i,this.bounces=a,this.depth=o,this.updateBeforeType=a?H$.RENDER:H$.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let n=this.resolution;t.getDrawingBufferSize(p7),e.setSize(Math.round(p7.width*n),Math.round(p7.height*n))}setup(e){return this._updateResolution(m7,e.renderer),super.setup(e)}dispose(){super.dispose();for(let e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new TX(0,0,{type:JJ}),this.generateMipmaps===!0&&(t.texture.minFilter=UJ,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new HQ),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&h7)return!1;h7=!0;let{scene:t,camera:n,renderer:r,material:i}=e,{target:a}=this,o=this.getVirtualCamera(n),s=this.getRenderTarget(o);r.getDrawingBufferSize(p7),this._updateResolution(s,r),a7.setFromMatrixPosition(a.matrixWorld),o7.setFromMatrixPosition(n.matrixWorld),s7.extractRotation(a.matrixWorld),i7.set(0,0,1),i7.applyMatrix4(s7),u7.subVectors(a7,o7);let c=u7.dot(i7)>0,l=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){h7=!1;return}l=!0}u7.reflect(i7).negate(),u7.add(a7),s7.extractRotation(n.matrixWorld),c7.set(0,0,-1),c7.applyMatrix4(s7),c7.add(o7),d7.subVectors(a7,c7),d7.reflect(i7).negate(),d7.add(a7),o.coordinateSystem=n.coordinateSystem,o.position.copy(u7),o.up.set(0,1,0),o.up.applyMatrix4(s7),o.up.reflect(i7),o.lookAt(d7),o.near=n.near,o.far=n.far,o.updateMatrixWorld(),o.projectionMatrix.copy(n.projectionMatrix),r7.setFromNormalAndCoplanarPoint(i7,a7),r7.applyMatrix4(o.matrixWorldInverse),l7.set(r7.normal.x,r7.normal.y,r7.normal.z,r7.constant);let u=o.projectionMatrix;f7.x=(Math.sign(l7.x)+u.elements[8])/u.elements[0],f7.y=(Math.sign(l7.y)+u.elements[9])/u.elements[5],f7.z=-1,f7.w=(1+u.elements[10])/u.elements[14],l7.multiplyScalar(1/l7.dot(f7));let d=0;u.elements[2]=l7.x,u.elements[6]=l7.y,u.elements[10]=r.coordinateSystem===TY?l7.z-d:l7.z+1-d,u.elements[14]=l7.w,this.textureNode.value=s.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=s.depthTexture),i.visible=!1;let f=r.getRenderTarget(),p=r.getMRT(),m=r.autoClear;r.setMRT(null),r.setRenderTarget(s),r.autoClear=!0,l?(r.clear(),this.hasOutput=!1):(r.render(t,o),this.hasOutput=!0),r.setMRT(p),r.setRenderTarget(f),r.autoClear=m,i.visible=!0,h7=!1,this.forceUpdate=!1}};const $le=e=>U(new Zle(e)),g7=new o$(-1,1,1,-1,0,1);var eue=class extends dQ{constructor(e=!1){super();let t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute(`position`,new rQ([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new rQ(t,2))}};const tue=new eue;var _7=class extends CQ{constructor(e=null){super(tue,e),this.camera=g7,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,g7)}render(e){e.render(this,g7)}};const nue=new eX;var rue=class extends L3{static get type(){return`RTTNode`}constructor(e,t=null,n=null,r={type:JJ}){let i=new TX(t,n,r);super(i.texture,N3()),this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=i,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new _7(new Y8),this.updateBeforeType=H$.RENDER}get autoSize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name=`RTT`,this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;let n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoSize===!0){this.pixelRatio=e.getPixelRatio();let t=e.getSize(nue);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;let t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new L3(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}};const v7=(e,...t)=>U(new rue(U(e),...t)),iue=(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():v7(e,...t),y7=K(([e,t,n],r)=>{let i;r.renderer.coordinateSystem===TY?(e=Y(e.x,e.y.oneMinus()).mul(2).sub(1),i=r0(X(e,t),1)):i=r0(X(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=r0(n.mul(i));return a.xyz.div(a.w)}),aue=K(([e,t])=>{let n=t.mul(r0(e,1)),r=n.xy.div(n.w).mul(.5).add(.5).toVar();return Y(r.x,r.y.oneMinus())}),oue=K(([e,t,n])=>{let r=P3(z3(t)),i=Z1(e.mul(r)).toVar(),a=z3(t,i).toVar(),o=z3(t,i.sub(Z1(2,0))).toVar(),s=z3(t,i.sub(Z1(1,0))).toVar(),c=z3(t,i.add(Z1(1,0))).toVar(),l=z3(t,i.add(Z1(2,0))).toVar(),u=z3(t,i.add(Z1(0,2))).toVar(),d=z3(t,i.add(Z1(0,1))).toVar(),f=z3(t,i.sub(Z1(0,1))).toVar(),p=z3(t,i.sub(Z1(0,2))).toVar(),m=s4(d2(q(2).mul(s).sub(o),a)).toVar(),h=s4(d2(q(2).mul(c).sub(l),a)).toVar(),g=s4(d2(q(2).mul(d).sub(u),a)).toVar(),_=s4(d2(q(2).mul(f).sub(p),a)).toVar(),v=y7(e,a,n).toVar(),y=m.lessThan(h).select(v.sub(y7(e.sub(Y(q(1).div(r.x),0)),s,n)),v.negate().add(y7(e.add(Y(q(1).div(r.x),0)),c,n))),b=g.lessThan(_).select(v.sub(y7(e.add(Y(0,q(1).div(r.y))),d,n)),v.negate().add(y7(e.sub(Y(0,q(1).div(r.y))),f,n)));return $2(O4(y,b))});var sue=class extends IQ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}},cue=class extends eQ{constructor(e,t,n=Float32Array){let r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}};const lue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=M$(`float`)):(n=N$(t),r=M$(t));let i=new cue(e,n,r),a=f8(i,t,e);return a},uue=(e,t=`float`)=>{let n,r;t.isStruct===!0?(n=t.layout.getLength(),r=M$(`float`)):(n=N$(t),r=M$(t));let i=new sue(e,n,r),a=f8(i,t,e);return a};var due=class extends Z${static get type(){return`PointUVNode`}constructor(){super(`vec2`),this.isPointUVNode=!0}generate(){return`vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )`}};const fue=G(due),b7=new uZ,x7=new eZ;var S7=class e extends Z${static get type(){return`SceneNode`}constructor(t=e.BACKGROUND_BLURRINESS,n=null){super(),this.scope=t,this.scene=n}setup(t){let n=this.scope,r=this.scene===null?t.scene:this.scene,i;return n===e.BACKGROUND_BLURRINESS?i=P6(`backgroundBlurriness`,`float`,r):n===e.BACKGROUND_INTENSITY?i=P6(`backgroundIntensity`,`float`,r):n===e.BACKGROUND_ROTATION?i=t2(`mat4`).label(`backgroundRotation`).setGroup(Q0).onRenderUpdate(()=>{let e=r.background;return e!==null&&e.isTexture&&e.mapping!==NJ?(b7.copy(r.backgroundRotation),b7.x*=-1,b7.y*=-1,b7.z*=-1,x7.makeRotationFromEuler(b7)):x7.identity(),x7}):console.error(`THREE.SceneNode: Unknown scope:`,n),i}};S7.BACKGROUND_BLURRINESS=`backgroundBlurriness`,S7.BACKGROUND_INTENSITY=`backgroundIntensity`,S7.BACKGROUND_ROTATION=`backgroundRotation`;const pue=G(S7,S7.BACKGROUND_BLURRINESS),mue=G(S7,S7.BACKGROUND_INTENSITY),hue=G(S7,S7.BACKGROUND_ROTATION);var gue=class extends L3{static get type(){return`StorageTextureNode`}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=W$.WRITE_ONLY}getInputType(){return`storageTexture`}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}generate(e,t){let n;return n=this.storeNode===null?super.generate(e,t):this.generateStore(e),n}toReadWrite(){return this.setAccess(W$.READ_WRITE)}toReadOnly(){return this.setAccess(W$.READ_ONLY)}toWriteOnly(){return this.setAccess(W$.WRITE_ONLY)}generateStore(e){let t=e.getNodeProperties(this),{uvNode:n,storeNode:r,depthNode:i}=t,a=super.generate(e,`property`),o=n.build(e,`uvec2`),s=r.build(e,`vec4`),c=i?i.build(e,`int`):null,l=e.generateTextureStore(e,a,o,c,s);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e}};const C7=W(gue).setParameterLength(1,3),_ue=(e,t,n)=>{let r=C7(e,t,n);return n!==null&&r.toStack(),r},vue=K(({texture:e,uv:t})=>{let n=1e-4,r=X().toVar();return G1(t.x.lessThan(n),()=>{r.assign(X(1,0,0))}).ElseIf(t.y.lessThan(n),()=>{r.assign(X(0,1,0))}).ElseIf(t.z.lessThan(n),()=>{r.assign(X(0,0,1))}).ElseIf(t.x.greaterThan(1-n),()=>{r.assign(X(-1,0,0))}).ElseIf(t.y.greaterThan(1-n),()=>{r.assign(X(0,-1,0))}).ElseIf(t.z.greaterThan(1-n),()=>{r.assign(X(0,0,-1))}).Else(()=>{let n=.01,i=e.sample(t.add(X(-.01,0,0))).r.sub(e.sample(t.add(X(n,0,0))).r),a=e.sample(t.add(X(0,-.01,0))).r.sub(e.sample(t.add(X(0,n,0))).r),o=e.sample(t.add(X(0,0,-.01))).r.sub(e.sample(t.add(X(0,0,n))).r);r.assign(X(i,a,o))}),r.normalize()});var yue=class extends L3{static get type(){return`Texture3DNode`}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return`texture3D`}getDefaultUV(){return X(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){let n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(t=this.sampler?t.flipY():t.setY(J(P3(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,`vec3`)}normal(e){return vue({texture:this,uv:e})}};const bue=W(yue).setParameterLength(1,3);var xue=class extends N6{static get type(){return`UserDataNode`}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData===null?e.object.userData:this.userData,this.reference}};const Sue=(e,t,n)=>U(new xue(e,t,n)),w7=new WeakMap;var Cue=class extends e1{static get type(){return`VelocityNode`}constructor(){super(`vec2`),this.projectionMatrix=null,this.updateType=H$.OBJECT,this.updateAfterType=H$.OBJECT,this.previousModelWorldMatrix=t2(new eZ),this.previousProjectionMatrix=t2(new eZ).setGroup(Q0),this.previousCameraViewMatrix=t2(new eZ)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){let r=E7(n);this.previousModelWorldMatrix.value.copy(r);let i=T7(t);i.frameId!==e&&(i.frameId=e,i.previousProjectionMatrix===void 0?(i.previousProjectionMatrix=new eZ,i.previousCameraViewMatrix=new eZ,i.currentProjectionMatrix=new eZ,i.currentCameraViewMatrix=new eZ,i.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(i.previousProjectionMatrix.copy(i.currentProjectionMatrix),i.previousCameraViewMatrix.copy(i.currentCameraViewMatrix)),i.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),i.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(i.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(i.previousCameraViewMatrix))}updateAfter({object:e}){E7(e).copy(e.matrixWorld)}setup(){let e=this.projectionMatrix===null?J3:t2(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(n6).mul(a6),r=this.previousProjectionMatrix.mul(t).mul(o6),i=n.xy.div(n.w),a=r.xy.div(r.w),o=d2(i,a);return o}};function T7(e){let t=w7.get(e);return t===void 0&&(t={},w7.set(e,t)),t}function E7(e,t=0){let n=T7(e),r=n[t];return r===void 0&&(n[t]=r=new eZ,n[t].copy(e.matrixWorld)),r}const wue=G(Cue),D7=K(([e,t])=>x4(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:`blendBurn`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),O7=K(([e,t])=>x4(e.div(t.oneMinus()),1)).setLayout({name:`blendDodge`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),k7=K(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:`blendScreen`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),A7=K(([e,t])=>I4(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),C4(.5,e))).setLayout({name:`blendOverlay`,type:`vec3`,inputs:[{name:`base`,type:`vec3`},{name:`blend`,type:`vec3`}]}),Tue=K(([e,t])=>{let n=t.a.add(e.a.mul(t.a.oneMinus()));return r0(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(n),n)}).setLayout({name:`blendColor`,type:`vec4`,inputs:[{name:`base`,type:`vec4`},{name:`blend`,type:`vec4`}]}),Eue=K(([e])=>r0(e.rgb.mul(e.a),e.a),{color:`vec4`,return:`vec4`}),Due=K(([e])=>(G1(e.a.equal(0),()=>r0(0)),r0(e.rgb.div(e.a),e.a)),{color:`vec4`,return:`vec4`}),Oue=(...e)=>(console.warn(`THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.`),D7(e)),kue=(...e)=>(console.warn(`THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.`),O7(e)),Aue=(...e)=>(console.warn(`THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.`),k7(e)),jue=(...e)=>(console.warn(`THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.`),A7(e)),Mue=K(([e])=>j7(e.rgb)),Nue=K(([e,t=q(1)])=>t.mix(j7(e.rgb),e.rgb)),Pue=K(([e,t=q(1)])=>{let n=u2(e.r,e.g,e.b).div(3),r=e.r.max(e.g.max(e.b)),i=r.sub(n).mul(t).mul(-3);return I4(e.rgb,r,i)}),Fue=K(([e,t=q(1)])=>{let n=X(.57735,.57735,.57735),r=t.cos();return X(e.rgb.mul(r).add(n.cross(e.rgb).mul(t.sin()).add(n.mul(D4(n,e.rgb).mul(r.oneMinus())))))}),j7=(e,t=X(pX.getLuminanceCoefficients(new V)))=>D4(e,t),Iue=K(([e,t=X(1),n=X(0),r=X(1),i=q(1),a=X(pX.getLuminanceCoefficients(new V,lY))])=>{let o=e.rgb.dot(X(a)),s=S4(e.rgb.mul(t).add(n),0).toVar(),c=s.pow(r).toVar();return G1(s.r.greaterThan(0),()=>{s.r.assign(c.r)}),G1(s.g.greaterThan(0),()=>{s.g.assign(c.g)}),G1(s.b.greaterThan(0),()=>{s.b.assign(c.b)}),s.assign(o.add(s.sub(o).mul(i))),r0(s.rgb,e.a)});var Lue=class extends e1{static get type(){return`PosterizeNode`}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){let{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}};const Rue=W(Lue).setParameterLength(2),M7=new eX;var N7=class extends L3{static get type(){return`PassTextureNode`}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}},P7=class extends N7{static get type(){return`PassMultipleTextureNode`}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}},F7=class e extends e1{static get type(){return`PassNode`}constructor(e,t,n,r={}){super(`vec4`),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;let i=new HQ;i.isRenderTargetTexture=!0,i.name=`depth`;let a=new TX(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:JJ,...r});a.texture.name=`output`,a.depthTexture=i,this.renderTarget=a,this._textures={output:a.texture,depth:i},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=t2(0),this._cameraFar=t2(0),this._mrt=null,this._layers=null,this._resolution=1,this.isPassNode=!0,this.updateBeforeType=H$.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){let n=this.renderTarget.texture;t=n.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(t!==void 0){let n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e=`output`){let t=this._textureNodes[e];return t===void 0&&(t=U(new P7(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e=`output`){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=U(new P7(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e=`depth`){let t=this._viewZNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=B8(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e=`depth`){let t=this._linearDepthNodes[e];if(t===void 0){let n=this._cameraNear,r=this._cameraFar,i=this.getViewZNode(e);this._linearDepthNodes[e]=t=R8(i,n,r)}return t}setup({renderer:t}){return this.renderTarget.samples=this.options.samples===void 0?t.samples:this.options.samples,t.backend.isWebGLBackend===!0&&(this.renderTarget.samples=0),this.renderTarget.texture.type=t.getColorBufferType(),this.scope===e.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let{renderer:t}=e,{scene:n}=this,r,i,a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(i=1,r=t.xr.getCamera(),t.xr.updateCamera(r),M7.set(a.width,a.height)):(r=this.camera,i=t.getPixelRatio(),t.getSize(M7)),this._pixelRatio=i,this.setSize(M7.width,M7.height);let o=t.getRenderTarget(),s=t.getMRT(),c=r.layers.mask;for(let e in this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(o),t.setMRT(s),r.layers.mask=c}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio*this._resolution,r=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}};F7.COLOR=`color`,F7.DEPTH=`depth`;const zue=(e,t,n)=>U(new F7(F7.COLOR,e,t,n)),Bue=(e,t)=>U(new N7(e,t)),Vue=(e,t,n)=>U(new F7(F7.DEPTH,e,t,n));var Hue=class extends F7{static get type(){return`ToonOutlinePassNode`}constructor(e,t,n,r,i){super(F7.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=i,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((e,n,r,i,a,o,s,c)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&a.wireframe===!1){let l=this._getOutlineMaterial(a);t.renderObject(e,n,r,i,l,o,s,c)}t.renderObject(e,n,r,i,a,o,s,c)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){let e=new Y8;e.isMeshToonOutlineMaterial=!0,e.name=`Toon_Outline`,e.side=wJ;let t=m6.negate(),n=J3.mul(n6),r=q(1),i=n.mul(r0(a6,1)),a=n.mul(r0(a6.add(t),1)),o=$2(i.sub(a));return e.vertexNode=i.add(o.mul(this.thicknessNode).mul(i.w).mul(r)),e.colorNode=r0(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}};const Uue=(e,t,n=new KZ(0,0,0),r=.003,i=1)=>U(new Hue(e,t,U(n),U(r),U(i))),Wue=K(([e,t])=>e.mul(t).clamp()).setLayout({name:`linearToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Gue=K(([e,t])=>(e=e.mul(t),e.div(e.add(1)).clamp())).setLayout({name:`reinhardToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Kue=K(([e,t])=>{e=e.mul(t),e=e.sub(.004).max(0);let n=e.mul(e.mul(6.2).add(.5)),r=e.mul(e.mul(6.2).add(1.7)).add(.06);return n.div(r).pow(2.2)}).setLayout({name:`cineonToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),que=K(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),n=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(n)}),Jue=K(([e,t])=>{let n=c0(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=c0(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=n.mul(e),e=que(e),e=r.mul(e),e.clamp()}).setLayout({name:`acesFilmicToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),Yue=c0(X(1.6605,-.1246,-.0182),X(-.5876,1.1329,-.1006),X(-.0728,-.0083,1.1187)),Xue=c0(X(.6274,.0691,.0164),X(.3293,.9195,.088),X(.0433,.0113,.8956)),Zue=K(([e])=>{let t=X(e).toVar(),n=X(t.mul(t)).toVar(),r=X(n.mul(n)).toVar();return q(15.5).mul(r.mul(n)).sub(f2(40.14,r.mul(t))).add(f2(31.96,r).sub(f2(6.868,n.mul(t))).add(f2(.4298,n).add(f2(.1191,t).sub(.00232))))}),Que=K(([e,t])=>{let n=X(e).toVar(),r=c0(X(.856627153315983,.137318972929847,.11189821299995),X(.0951212405381588,.761241990602591,.0767994186031903),X(.0482516061458583,.101439036467562,.811302368396859)),i=c0(X(1.1271005818144368,-.1413297634984383,-.14132976349843826),X(-.11060664309660323,1.157823702216272,-.11060664309660294),X(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=q(-12.47393),o=q(4.026069);return n.mulAssign(t),n.assign(Xue.mul(n)),n.assign(r.mul(n)),n.assign(S4(n,1e-10)),n.assign(J2(n)),n.assign(n.sub(a).div(o.sub(a))),n.assign(L4(n,0,1)),n.assign(Zue(n)),n.assign(i.mul(n)),n.assign(k4(S4(X(0),n),X(2.2))),n.assign(Yue.mul(n)),n.assign(L4(n,0,1)),n}).setLayout({name:`agxToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]}),$ue=K(([e,t])=>{let n=q(.76),r=q(.15);e=e.mul(t);let i=x4(e.r,x4(e.g,e.b)),a=Y4(i.lessThan(.08),i.sub(f2(6.25,i.mul(i))),.04);e.subAssign(a);let o=S4(e.r,S4(e.g,e.b));G1(o.lessThan(n),()=>e);let s=d2(1,n),c=d2(1,s.mul(s).div(o.add(s.sub(n))));e.mulAssign(c.div(o));let l=d2(1,p2(1,r.mul(o.sub(c)).add(1)));return I4(e,X(c),l)}).setLayout({name:`neutralToneMapping`,type:`vec3`,inputs:[{name:`color`,type:`vec3`},{name:`exposure`,type:`float`}]});var I7=class extends Z${static get type(){return`CodeNode`}constructor(e=``,t=[],n=``){super(`code`),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){let t=this.getIncludes(e);for(let n of t)n.build(e);let n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}};const L7=W(I7).setParameterLength(1,3),ede=(e,t)=>L7(e,t,`js`),tde=(e,t)=>L7(e,t,`wgsl`),nde=(e,t)=>L7(e,t,`glsl`);var rde=class extends I7{static get type(){return`FunctionNode`}constructor(e=``,t=[],n=``){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);let n=this.getNodeFunction(e),r=n.name,i=n.type,a=e.getCodeFromNode(this,i);r!==``&&(a.name=r);let o=e.getPropertyName(a),s=this.getNodeFunction(e).getCode(o);return a.code=s+`
|
|
431
|
+
`,t===`property`?o:e.format(`${o}()`,i,t)}};const R7=(e,t=[],n=``)=>{for(let e=0;e<t.length;e++){let n=t[e];typeof n==`function`&&(t[e]=n.functionNode)}let r=U(new rde(e,t,n)),i=(...e)=>r.call(...e);return i.functionNode=r,i},ide=(e,t)=>R7(e,t,`glsl`),ade=(e,t)=>R7(e,t,`wgsl`);var ode=class extends Z${static get type(){return`ScriptableValueNode`}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new EY,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType===`URL`&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:`change`}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:`refresh`})}getValue(){let e=this.value;if(e&&this._cache===null&&this.inputType===`URL`&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType===`URL`||this.inputType===`String`)&&typeof e.value==`string`||this.inputType===`Number`&&typeof e.value==`number`||this.inputType===`Vector2`&&e.value.isVector2||this.inputType===`Vector3`&&e.value.isVector3||this.inputType===`Vector4`&&e.value.isVector4||this.inputType===`Color`&&e.value.isColor||this.inputType===`Matrix3`&&e.value.isMatrix3||this.inputType===`Matrix4`&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):`float`}setup(){return this.value&&this.value.isNode?this.value:q()}serialize(e){super.serialize(e),this.value===null?e.value=null:this.inputType===`ArrayBuffer`?e.value=z$(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;e.value!==null&&(t=e.inputType===`ArrayBuffer`?B$(e.value):e.inputType===`Texture`?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}};const z7=W(ode).setParameterLength(1);var B7=class extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){let r=t(...n);return this.set(e,r),r}}},sde=class{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){let t=this.parameters[e],n=t?t.getValue():null;return n}};const V7=new B7;var cde=class extends Z${static get type(){return`ScriptableNode`}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new B7,this._output=z7(null),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:``}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(let t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(let t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){let n=this._outputs;return n[e]===void 0?n[e]=z7(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){let n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener(`refresh`,this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e]===void 0?(n[e]=z7(t),n[e].events.addEventListener(`refresh`,this.onRefresh)):n[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener(`refresh`,this.onRefresh)),this}clearParameters(){for(let e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r(...t)}async callAsync(e,...t){let n=this.getObject(),r=n[e];if(typeof r==`function`)return r.constructor.name===`AsyncFunction`?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e===null?this._refresh():this.getOutput(e).refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;let e=()=>this.refresh(),t=(e,t)=>this.setOutput(e,t),n=new sde(this),r=V7.get(`THREE`),i=V7.get(`TSL`),a=this.getMethod(),o=[n,this._local,V7,e,t,r,i];this._object=a(...o);let s=this._object.layout;if(s&&(s.cache===!1&&this._local.clear(),this._output.outputType=s.outputType||null,Array.isArray(s.elements)))for(let e of s.elements){let t=e.id||e.name;e.inputType&&(this.getParameter(t)===void 0&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(this.getOutput(t)===void 0&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){for(let t in super.deserialize(e),this.parameters){let e=this.parameters[t];e.isScriptableNode&&(e=e.getDefaultOutput()),e.events.addEventListener(`refresh`,this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){let e=this.getDefaultOutput().value;return e&&e.isNode?e:q()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;let e=[`parameters`,`local`,`global`,`refresh`,`setOutput`,`THREE`,`TSL`],t=[`layout`,`init`,`main`,`dispose`],n=t.join(`, `),r=`var `+n+`; var output = {};
|
|
432
432
|
`,i=`
|
|
433
|
-
return { ...output, `+n+` };`,a=r+this.codeNode.code+i;return this._method=Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose==`function`&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){let t=[T$(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return E$(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call(`main`),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}};const fde=W(dde).setParameterLength(1,2);function H7(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||l6.z).negate()}const U7=K(([e,t],n)=>{let r=H7(n);return V4(e,t,r)}),W7=K(([e],t)=>{let n=H7(t);return e.mul(e,n,n).negate().exp().oneMinus()}),G7=K(([e,t])=>i0(t.toFloat().mix(z0.rgb,e.toVec3()),z0.a));function pde(e,t,n){return console.warn(`THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.`),G7(e,U7(t,n))}function mde(e,t){return console.warn(`THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.`),G7(e,W7(t))}let K7=null,q7=null;var hde=class extends Q${static get type(){return`RangeNode`}constructor(e=q(),t=q()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(L$(this.minNode.value)),n=e.getTypeLength(L$(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.minNode.value,i=this.maxNode.value,a=e.getTypeLength(L$(r)),o=e.getTypeLength(L$(i));K7||=new TX,q7||=new TX,K7.setScalar(0),q7.setScalar(0),a===1?K7.setScalar(r):r.isColor?K7.set(r.r,r.g,r.b,1):K7.set(r.x,r.y,r.z||0,r.w||0),o===1?q7.setScalar(i):i.isColor?q7.set(i.r,i.g,i.b,1):q7.set(i.x,i.y,i.z||0,i.w||0);let s=4,c=s*t.count,l=new Float32Array(c);for(let e=0;e<c;e++){let t=e%s,n=K7.getComponent(t),r=q7.getComponent(t);l[e]=eX.lerp(n,r,Math.random())}let u=this.getNodeType(e);if(t.count<=4096)n=V3(l,`vec4`,t.count).element(s8).convert(u);else{let t=new LQ(l,4);e.geometry.setAttribute(`__range`+this.id,t),n=v3(t).convert(u)}}else n=q(0);return n}};const gde=W(hde).setParameterLength(2);var _de=class extends Q${static get type(){return`ComputeBuiltinNode`}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}};const J7=(e,t)=>U(new _de(e,t)),vde=J7(`numWorkgroups`,`uvec3`),yde=J7(`workgroupId`,`uvec3`),bde=J7(`globalId`,`uvec3`),xde=J7(`localId`,`uvec3`),Sde=J7(`subgroupSize`,`uint`);var Cde=class extends Q${constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}};const Y7=W(Cde),wde=()=>Y7(`workgroup`).toStack(),Tde=()=>Y7(`storage`).toStack(),Ede=()=>Y7(`texture`).toStack();var Dde=class extends $${constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},Ode=class extends Q${constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return U(new Dde(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}};const kde=(e,t)=>U(new Ode(`Workgroup`,e,t));var X7=class extends Q${static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`,u=n.length===1&&n[0].isStackNode===!0;if(u)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=D3(l,i).toConst()),t.constNode.build(e)}};X7.ATOMIC_LOAD=`atomicLoad`,X7.ATOMIC_STORE=`atomicStore`,X7.ATOMIC_ADD=`atomicAdd`,X7.ATOMIC_SUB=`atomicSub`,X7.ATOMIC_MAX=`atomicMax`,X7.ATOMIC_MIN=`atomicMin`,X7.ATOMIC_AND=`atomicAnd`,X7.ATOMIC_OR=`atomicOr`,X7.ATOMIC_XOR=`atomicXor`;const Ade=W(X7),Z7=(e,t,n)=>Ade(e,t,n).toStack(),jde=e=>Z7(X7.ATOMIC_LOAD,e,null),Mde=(e,t)=>Z7(X7.ATOMIC_STORE,e,t),Nde=(e,t)=>Z7(X7.ATOMIC_ADD,e,t),Pde=(e,t)=>Z7(X7.ATOMIC_SUB,e,t),Fde=(e,t)=>Z7(X7.ATOMIC_MAX,e,t),Ide=(e,t)=>Z7(X7.ATOMIC_MIN,e,t),Lde=(e,t)=>Z7(X7.ATOMIC_AND,e,t),Rde=(e,t)=>Z7(X7.ATOMIC_OR,e,t),zde=(e,t)=>Z7(X7.ATOMIC_XOR,e,t);let Q7;function $7(e){Q7||=new WeakMap;let t=Q7.get(e);return t===void 0&&Q7.set(e,t={}),t}function e9(e){let t=$7(e);return t.shadowMatrix||=n2(`mat4`).setGroup($0).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&e.shadow.updateMatrices(e),e.shadow.matrix))}function Bde(e,t=s6){let n=e9(e).mul(t),r=n.xyz.div(n.w);return r}function t9(e){let t=$7(e);return t.position||=n2(new V).setGroup($0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function n9(e){let t=$7(e);return t.targetPosition||=n2(new V).setGroup($0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function Vde(e){let t=$7(e);return t.viewPosition||=n2(new V).setGroup($0).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new V,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}const Hde=e=>Y3.transformDirection(t9(e).sub(n9(e))),Ude=e=>e.sort((e,t)=>e.id-t.id),Wde=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},r9=new WeakMap,i9=[];var Gde=class extends Q${static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=X().toVar(),this.totalSpecularNode=X().toVar(),this.outgoingLightNode=X().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(i9.push(n.id),i9.push(n.castShadow?1:0),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;i9.push(e,t)}}let t=E$(i9);return i9.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getSelf().getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=Ude(this._lights),i=e.renderer.library;for(let e of r)if(e.isNode)t.push(U(e));else{let r=null;if(n!==null&&(r=Wde(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;r9.has(e)?r=r9.get(e):(r=U(new n(e)),r9.set(e,r)),t.push(r)}}this._lightNodes=t}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n;let s=e.addStack();a.nodes=s.nodes,i.start(e);let{backdrop:c,backdropAlpha:l}=r,{directDiffuse:u,directSpecular:d,indirectDiffuse:f,indirectSpecular:p}=r.reflectedLight,m=u.add(f);c!==null&&(m=X(l===null?c:l.mix(m,c)),r.material.transparent=!0),t.assign(m),o.assign(d.add(p)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}};const Kde=(e=[])=>U(new Gde).setLights(e);var qde=class extends Q${static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=U$.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){a9.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||s6)}};const a9=y0(`vec3`,`shadowPositionWorld`);function Jde(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new qZ),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function Yde(e,t){return t=Jde(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function Xde(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function Zde(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function Qde(e,t){return t=Zde(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function $de(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function efe(e,t,n){return n=Yde(e,n),n=Qde(t,n),n}function tfe(e,t,n){Xde(e,n),$de(t,n)}const o9=new WeakMap,s9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=R3(e,t.xy).label(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),c9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup($0),o=P6(`radius`,`float`,n).setGroup($0),s=Y(1).div(a),c=s.x.negate().mul(o),l=s.y.negate().mul(o),u=s.x.mul(o),d=s.y.mul(o),f=c.div(2),p=l.div(2),m=u.div(2),h=d.div(2);return d2(i(t.xy.add(Y(c,l)),t.z),i(t.xy.add(Y(0,l)),t.z),i(t.xy.add(Y(u,l)),t.z),i(t.xy.add(Y(f,p)),t.z),i(t.xy.add(Y(0,p)),t.z),i(t.xy.add(Y(m,p)),t.z),i(t.xy.add(Y(c,0)),t.z),i(t.xy.add(Y(f,0)),t.z),i(t.xy,t.z),i(t.xy.add(Y(m,0)),t.z),i(t.xy.add(Y(u,0)),t.z),i(t.xy.add(Y(f,h)),t.z),i(t.xy.add(Y(0,h)),t.z),i(t.xy.add(Y(m,h)),t.z),i(t.xy.add(Y(c,d)),t.z),i(t.xy.add(Y(0,d)),t.z),i(t.xy.add(Y(u,d)),t.z)).mul(1/17)}),l9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup($0),o=Y(1).div(a),s=o.x,c=o.y,l=t.xy,u=t4(l.mul(a).add(.5));return l.subAssign(u.mul(o)),d2(i(l,t.z),i(l.add(Y(s,0)),t.z),i(l.add(Y(0,c)),t.z),i(l.add(o),t.z),L4(i(l.add(Y(s.negate(),0)),t.z),i(l.add(Y(s.mul(2),0)),t.z),u.x),L4(i(l.add(Y(s.negate(),c)),t.z),i(l.add(Y(s.mul(2),c)),t.z),u.x),L4(i(l.add(Y(0,c.negate())),t.z),i(l.add(Y(0,c.mul(2))),t.z),u.y),L4(i(l.add(Y(s,c.negate())),t.z),i(l.add(Y(s,c.mul(2))),t.z),u.y),L4(L4(i(l.add(Y(s.negate(),c.negate())),t.z),i(l.add(Y(s.mul(2),c.negate())),t.z),u.x),L4(i(l.add(Y(s.negate(),c.mul(2))),t.z),i(l.add(Y(s.mul(2),c.mul(2))),t.z),u.x),u.y)).mul(1/9)}),u9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=q(1).toVar(),i=R3(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=w4(t.z,i.x);return K1(a.notEqual(q(1)),()=>{let e=t.z.sub(i.x),n=C4(0,i.y.mul(i.y)),o=n.div(n.add(e.mul(e)));o=R4(f2(o,.3).div(.6499999999999999)),r.assign(R4(C4(a,o)))}),r}),nfe=K(([e,t,n])=>{let r=s6.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r}),rfe=e=>{let t=e.shadow.camera,n=P6(`near`,`float`,t).setGroup($0),r=P6(`far`,`float`,t).setGroup($0),i=Q3(e);return nfe(i,n,r)},d9=e=>{let t=o9.get(e);if(t===void 0){let n=e.isPointLight?rfe(e):null;t=new Y8,t.colorNode=i0(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.fog=!1,o9.set(e,t)}return t},f9=new vle,p9=[],m9=(e,t,n,r)=>{p9[0]=e,p9[1]=t;let i=f9.get(p9);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,...u)=>{(i.castShadow===!0||i.receiveShadow&&n===CJ)&&(r&&(z$(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,...u),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,f9.set(p9,i)),p9[0]=null,p9[1]=null,i},ife=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanVertical`),o=q(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(d2(k8.xy,Y(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e);let l=X2(o.sub(a.mul(a)));return Y(a,l)}),afe=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanHorizontal`),o=q(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(d2(k8.xy,Y(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(d2(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e);let l=X2(o.sub(a.mul(a)));return Y(a,l)}),ofe=[s9,c9,l9,u9];let h9;const g9=new _7;var _9=class extends qde{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,q(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=P6(`bias`,`float`,n).setGroup($0),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,r.coordinateSystem===EY&&(o=o.mul(2).sub(1));else{let e=a.w;a=a.xy.div(e);let t=P6(`near`,`float`,n.camera).setGroup($0),r=P6(`far`,`float`,n.camera).setGroup($0);o=V8(e.negate(),t,r)}return a=X(a.x,a.y.oneMinus(),o.add(i)),a}getShadowFilterFn(e){return ofe[e]}setupRenderTarget(e,t){let n=new UQ(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=gY;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t}=e,{light:n,shadow:r}=this,i=t.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(r,e);if(r.camera.updateProjectionMatrix(),i===CJ&&r.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:$J,type:YJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:$J,type:YJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:$J,type:YJ,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:$J,type:YJ,depthBuffer:!1}));let t=R3(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=R3(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let i=P6(`blurSamples`,`float`,r).setGroup($0),s=P6(`radius`,`float`,r).setGroup($0),c=P6(`mapSize`,`vec2`,r).setGroup($0),l=this.vsmMaterialVertical||=new Y8;l.fragmentNode=ife({samples:i,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new Y8,l.fragmentNode=afe({samples:i,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let s=P6(`intensity`,`float`,r).setGroup($0),c=P6(`normalBias`,`float`,r).setGroup($0),l=e9(n).mul(a9.add(y6.mul(c))),u=this.setupShadowCoord(e,l),d=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(d===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let f=i===CJ&&r.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:o.texture,depthTexture:f,shadowCoord:u,shadow:r,depthLayer:this.depthLayer}),m=R3(o.texture,u);a.isArrayTexture&&(m=m.depth(this.depthLayer));let h=L4(1,p.rgb.mix(m,1),s.mul(m.a)).toVar();return this.shadowMap=o,this.shadow.map=o,h}setup(e){if(e.renderer.shadowMap.enabled!==!1)return K(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn(`THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.`),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),i.render(a,t.camera)}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;h9=efe(i,a,h9),a.overrideMaterial=d9(n),i.setRenderObjectFunction(m9(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===CJ&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,tfe(i,a,h9)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),g9.material=this.vsmMaterialVertical,g9.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),g9.material=this.vsmMaterialHorizontal,g9.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}};const sfe=(e,t)=>U(new _9(e,t)),cfe=new qZ,v9=K(([e,t])=>{let n=e.toVar(),r=c4(n),i=m2(1,C4(r.x,C4(r.y,r.z)));r.mulAssign(i),n.mulAssign(i.mul(t.mul(2).oneMinus()));let a=Y(n.xy).toVar(),o=t.mul(1.5),s=o.oneMinus();return K1(r.z.greaterThanEqual(s),()=>{K1(n.z.greaterThan(0),()=>{a.x.assign(f2(4,n.x))})}).ElseIf(r.x.greaterThanEqual(s),()=>{let e=l4(n.x);a.x.assign(n.z.mul(e).add(e.mul(2)))}).ElseIf(r.y.greaterThanEqual(s),()=>{let e=l4(n.y);a.x.assign(n.x.add(e.mul(2)).add(2)),a.y.assign(n.z.mul(e).sub(2))}),Y(.125,.25).mul(a).add(Y(.375,.75)).flipY()}).setLayout({name:`cubeToUV`,type:`vec2`,inputs:[{name:`pos`,type:`vec3`},{name:`texelSizeY`,type:`float`}]}),y9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r})=>R3(e,v9(t,r.y)).compare(n)),b9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{let a=P6(`radius`,`float`,i).setGroup($0),o=Y(-1,1).mul(a).mul(r.y);return R3(e,v9(t.add(o.xyy),r.y)).compare(n).add(R3(e,v9(t.add(o.yyy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xyx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yyx),r.y)).compare(n)).add(R3(e,v9(t,r.y)).compare(n)).add(R3(e,v9(t.add(o.xxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xxx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxx),r.y)).compare(n)).mul(1/9)}),lfe=K(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r})=>{let i=n.xyz.toVar(),a=i.length(),o=n2(`float`).setGroup($0).onRenderUpdate(()=>r.camera.near),s=n2(`float`).setGroup($0).onRenderUpdate(()=>r.camera.far),c=P6(`bias`,`float`,r).setGroup($0),l=n2(r.mapSize).setGroup($0),u=q(1).toVar();return K1(a.sub(s).lessThanEqual(0).and(a.sub(o).greaterThanEqual(0)),()=>{let n=a.sub(o).div(s.sub(o)).toVar();n.addAssign(c);let d=i.normalize(),f=Y(1).div(l.mul(Y(4,2)));u.assign(e({depthTexture:t,bd3D:d,dp:n,texelSize:f,shadow:r}))}),u}),x9=new TX,S9=new tX,C9=new tX;var ufe=class extends _9{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===SJ?y9:b9}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a}){return lfe({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a})}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.getFrameExtents();C9.copy(t.mapSize),C9.multiply(o),n.setSize(C9.width,C9.height),S9.copy(t.mapSize);let s=i.autoClear,c=i.getClearColor(cfe),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();let u=t.getViewportCount();for(let e=0;e<u;e++){let o=t.getViewport(e),s=S9.x*o.x,c=C9.y-S9.y-S9.y*o.y;x9.set(s,c,S9.x*o.z,S9.y*o.w),n.viewport.copy(x9),t.updateMatrices(r,e),i.render(a,t.camera)}i.autoClear=s,i.setClearColor(c,l)}};const dfe=(e,t)=>U(new ufe(e,t)),w9=K(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),ffe=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=t.length(),o=w9({lightDistance:a,cutoffDistance:n,decayExponent:r}),s=e.mul(o);return{lightDirection:i,lightColor:s}},pfe=K(([e=N3()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor(),i=n.add(r).mod(2);return i.sign()}),mfe=K(([e=N3()],{renderer:t,material:n})=>{let r=I4(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.samples>1){let e=q(r.fwidth()).toVar();i=V4(e.oneMinus(),e.add(1),r).oneMinus()}else i=X4(r.greaterThan(1),0,1);return i}),T9=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=Z1(e).toVar();return X4(a,i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),E9=K(([e,t])=>{let n=Z1(t).toVar(),r=q(e).toVar();return X4(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),D9=K(([e])=>{let t=q(e).toVar();return J(Q2(t))}).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),O9=K(([e,t])=>{let n=q(e).toVar();return t.assign(D9(n)),n.sub(q(t))}),hfe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=q(r).toVar(),l=q(n).toVar(),u=q(t).toVar(),d=q(e).toVar(),f=q(f2(1,s)).toVar();return f2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),gfe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=X(r).toVar(),l=X(n).toVar(),u=X(t).toVar(),d=X(e).toVar(),f=q(f2(1,s)).toVar();return f2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),k9=$5([hfe,gfe]),_fe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=q(s).toVar(),h=q(o).toVar(),g=q(a).toVar(),_=q(i).toVar(),v=q(r).toVar(),y=q(n).toVar(),b=q(t).toVar(),x=q(e).toVar(),S=q(f2(1,p)).toVar(),ee=q(f2(1,f)).toVar(),te=q(f2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),vfe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=X(s).toVar(),h=X(o).toVar(),g=X(a).toVar(),_=X(i).toVar(),v=X(r).toVar(),y=X(n).toVar(),b=X(t).toVar(),x=X(e).toVar(),S=q(f2(1,p)).toVar(),ee=q(f2(1,f)).toVar(),te=q(f2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),A9=$5([_fe,vfe]),yfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=X1(e).toVar(),o=X1(a.bitAnd(X1(7))).toVar(),s=q(T9(o.lessThan(X1(4)),i,r)).toVar(),c=q(p2(2,T9(o.lessThan(X1(4)),r,i))).toVar();return E9(s,Z1(o.bitAnd(X1(1)))).add(E9(c,Z1(o.bitAnd(X1(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),bfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=X1(e).toVar(),c=X1(s.bitAnd(X1(15))).toVar(),l=q(T9(c.lessThan(X1(8)),o,a)).toVar(),u=q(T9(c.lessThan(X1(4)),a,T9(c.equal(X1(12)).or(c.equal(X1(14))),o,i))).toVar();return E9(l,Z1(c.bitAnd(X1(1)))).add(E9(u,Z1(c.bitAnd(X1(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]}),j9=$5([yfe,bfe]),xfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=n0(e).toVar();return X(j9(a.x,i,r),j9(a.y,i,r),j9(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),Sfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=n0(e).toVar();return X(j9(s.x,o,a,i),j9(s.y,o,a,i),j9(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]}),M9=$5([xfe,Sfe]),Cfe=K(([e])=>{let t=q(e).toVar();return p2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),wfe=K(([e])=>{let t=q(e).toVar();return p2(.982,t)}).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),Tfe=K(([e])=>{let t=X(e).toVar();return p2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),N9=$5([Cfe,Tfe]),Efe=K(([e])=>{let t=X(e).toVar();return p2(.982,t)}).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),P9=$5([wfe,Efe]),F9=K(([e,t])=>{let n=J(t).toVar(),r=X1(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(J(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),I9=K(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(F9(n,J(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(F9(n,J(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(4))),t.addAssign(e)}),L9=K(([e,t,n])=>{let r=X1(n).toVar(),i=X1(t).toVar(),a=X1(e).toVar();return r.bitXorAssign(i),r.subAssign(F9(i,J(14))),a.bitXorAssign(r),a.subAssign(F9(r,J(11))),i.bitXorAssign(a),i.subAssign(F9(a,J(25))),r.bitXorAssign(i),r.subAssign(F9(i,J(16))),a.bitXorAssign(r),a.subAssign(F9(r,J(4))),i.bitXorAssign(a),i.subAssign(F9(a,J(14))),r.bitXorAssign(i),r.subAssign(F9(i,J(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),R9=K(([e])=>{let t=X1(e).toVar();return q(t).div(q(X1(J(4294967295))))}).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),z9=K(([e])=>{let t=q(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),Dfe=K(([e])=>{let t=J(e).toVar(),n=X1(X1(1)).toVar(),r=X1(X1(J(3735928559)).add(n.shiftLeft(X1(2))).add(X1(13))).toVar();return L9(r.add(X1(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),Ofe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=X1(X1(2)).toVar(),a=X1().toVar(),o=X1().toVar(),s=X1().toVar();return a.assign(o.assign(s.assign(X1(J(3735928559)).add(i.shiftLeft(X1(2))).add(X1(13))))),a.addAssign(X1(r)),o.addAssign(X1(n)),L9(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),kfe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=X1(X1(3)).toVar(),s=X1().toVar(),c=X1().toVar(),l=X1().toVar();return s.assign(c.assign(l.assign(X1(J(3735928559)).add(o.shiftLeft(X1(2))).add(X1(13))))),s.addAssign(X1(a)),c.addAssign(X1(i)),l.addAssign(X1(r)),L9(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),Afe=K(([e,t,n,r])=>{let i=J(r).toVar(),a=J(n).toVar(),o=J(t).toVar(),s=J(e).toVar(),c=X1(X1(4)).toVar(),l=X1().toVar(),u=X1().toVar(),d=X1().toVar();return l.assign(u.assign(d.assign(X1(J(3735928559)).add(c.shiftLeft(X1(2))).add(X1(13))))),l.addAssign(X1(s)),u.addAssign(X1(o)),d.addAssign(X1(a)),I9(l,u,d),l.addAssign(X1(i)),L9(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),jfe=K(([e,t,n,r,i])=>{let a=J(i).toVar(),o=J(r).toVar(),s=J(n).toVar(),c=J(t).toVar(),l=J(e).toVar(),u=X1(X1(5)).toVar(),d=X1().toVar(),f=X1().toVar(),p=X1().toVar();return d.assign(f.assign(p.assign(X1(J(3735928559)).add(u.shiftLeft(X1(2))).add(X1(13))))),d.addAssign(X1(l)),f.addAssign(X1(c)),p.addAssign(X1(s)),I9(d,f,p),d.addAssign(X1(o)),f.addAssign(X1(a)),L9(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]}),B9=$5([Dfe,Ofe,kfe,Afe,jfe]),Mfe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=X1(B9(r,n)).toVar(),a=n0().toVar();return a.x.assign(i.bitAnd(J(255))),a.y.assign(i.shiftRight(J(8)).bitAnd(J(255))),a.z.assign(i.shiftRight(J(16)).bitAnd(J(255))),a}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),Nfe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=X1(B9(a,i,r)).toVar(),s=n0().toVar();return s.x.assign(o.bitAnd(J(255))),s.y.assign(o.shiftRight(J(8)).bitAnd(J(255))),s.z.assign(o.shiftRight(J(16)).bitAnd(J(255))),s}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),V9=$5([Mfe,Nfe]),Pfe=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=q(k9(j9(B9(n,r),i,a),j9(B9(n.add(J(1)),r),i.sub(1),a),j9(B9(n,r.add(J(1))),i,a.sub(1)),j9(B9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Ffe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=q(A9(j9(B9(n,r,i),a,o,s),j9(B9(n.add(J(1)),r,i),a.sub(1),o,s),j9(B9(n,r.add(J(1)),i),a,o.sub(1),s),j9(B9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),j9(B9(n,r,i.add(J(1))),a,o,s.sub(1)),j9(B9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),j9(B9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),j9(B9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),H9=$5([Pfe,Ffe]),Ife=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=X(k9(M9(V9(n,r),i,a),M9(V9(n.add(J(1)),r),i.sub(1),a),M9(V9(n,r.add(J(1))),i,a.sub(1)),M9(V9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Lfe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=X(A9(M9(V9(n,r,i),a,o,s),M9(V9(n.add(J(1)),r,i),a.sub(1),o,s),M9(V9(n,r.add(J(1)),i),a,o.sub(1),s),M9(V9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),M9(V9(n,r,i.add(J(1))),a,o,s.sub(1)),M9(V9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),M9(V9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),M9(V9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),U9=$5([Ife,Lfe]),Rfe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return R9(B9(n))}).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),zfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return R9(B9(n,r))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Bfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return R9(B9(n,r,i))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),Vfe=K(([e])=>{let t=i0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return R9(B9(n,r,i,a))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]}),Hfe=$5([Rfe,zfe,Bfe,Vfe]),Ufe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return X(R9(B9(n,J(0))),R9(B9(n,J(1))),R9(B9(n,J(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),Wfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return X(R9(B9(n,r,J(0))),R9(B9(n,r,J(1))),R9(B9(n,r,J(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Gfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return X(R9(B9(n,r,i,J(0))),R9(B9(n,r,i,J(1))),R9(B9(n,r,i,J(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Kfe=K(([e])=>{let t=i0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return X(R9(B9(n,r,i,a,J(0))),R9(B9(n,r,i,a,J(1))),R9(B9(n,r,i,a,J(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]}),W9=$5([Ufe,Wfe,Gfe,Kfe]),G9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=q(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(H9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),K9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(U9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),qfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar();return Y(G9(s,o,a,i),G9(s.add(X(J(19),J(193),J(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Jfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(K9(s,o,a,i)).toVar(),l=q(G9(s.add(X(J(19),J(193),J(17))),o,a,i)).toVar();return i0(c,l)}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Yfe=K(([e,t,n,r,i,a,o])=>{let s=J(o).toVar(),c=q(a).toVar(),l=J(i).toVar(),u=J(r).toVar(),d=J(n).toVar(),f=J(t).toVar(),p=Y(e).toVar(),m=X(W9(Y(f.add(u),d.add(l)))).toVar(),h=Y(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=Y(Y(q(f),q(d)).add(h)).toVar(),_=Y(g.sub(p)).toVar();return K1(s.equal(J(2)),()=>c4(_.x).add(c4(_.y))),K1(s.equal(J(3)),()=>C4(c4(_.x),c4(_.y))),O4(_,_)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Xfe=K(([e,t,n,r,i,a,o,s,c])=>{let l=J(c).toVar(),u=q(s).toVar(),d=J(o).toVar(),f=J(a).toVar(),p=J(i).toVar(),m=J(r).toVar(),h=J(n).toVar(),g=J(t).toVar(),_=X(e).toVar(),v=X(W9(X(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=X(X(q(g),q(h),q(m)).add(v)).toVar(),b=X(y.sub(_)).toVar();return K1(l.equal(J(2)),()=>c4(b.x).add(c4(b.y)).add(c4(b.z))),K1(l.equal(J(3)),()=>C4(c4(b.x),c4(b.y),c4(b.z))),O4(b,b)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),q9=$5([Yfe,Xfe]),Zfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();l.assign(S4(l,n))})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Qfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();K1(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),$fe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();K1(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),K1(r.equal(J(0)),()=>{l.assign(X2(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),epe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();u.assign(S4(u,a))})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),tpe=$5([Zfe,epe]),npe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();K1(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),rpe=$5([Qfe,npe]),ipe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();K1(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),K1(r.equal(J(0)),()=>{u.assign(X2(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),ape=$5([$fe,ipe]),ope=K(([e])=>{let t=e.y,n=e.z,r=X().toVar();return K1(t.lessThan(1e-4),()=>{r.assign(X(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(Q2(i)).mul(6).toVar();let a=J(_4(i)),o=i.sub(q(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());K1(a.equal(J(0)),()=>{r.assign(X(n,l,s))}).ElseIf(a.equal(J(1)),()=>{r.assign(X(c,n,s))}).ElseIf(a.equal(J(2)),()=>{r.assign(X(s,n,l))}).ElseIf(a.equal(J(3)),()=>{r.assign(X(s,c,n))}).ElseIf(a.equal(J(4)),()=>{r.assign(X(l,s,n))}).Else(()=>{r.assign(X(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),spe=K(([e])=>{let t=X(e).toVar(),n=q(t.x).toVar(),r=q(t.y).toVar(),i=q(t.z).toVar(),a=q(S4(n,S4(r,i))).toVar(),o=q(C4(n,C4(r,i))).toVar(),s=q(o.sub(a)).toVar(),c=q().toVar(),l=q().toVar(),u=q().toVar();return u.assign(o),K1(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),K1(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{K1(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(d2(2,i.sub(n).div(s)))}).Else(()=>{c.assign(d2(4,n.sub(r).div(s)))}),c.mulAssign(1/6),K1(c.lessThan(0),()=>{c.addAssign(1)})}),X(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),cpe=K(([e])=>{let t=X(e).toVar(),n=r0(y2(t,X(.04045))).toVar(),r=X(t.div(12.92)).toVar(),i=X(A4(C4(t.add(X(.055)),X(0)).div(1.055),X(2.4))).toVar();return L4(r,i,n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),J9=(e,t)=>{e=q(e),t=q(t);let n=Y(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return V4(e.sub(n),e.add(n),t)},Y9=(e,t,n,r)=>L4(e,t,n[r].clamp()),lpe=(e,t,n=N3())=>Y9(e,t,n,`x`),upe=(e,t,n=N3())=>Y9(e,t,n,`y`),X9=(e,t,n,r,i)=>L4(e,t,J9(n,r[i])),dpe=(e,t,n,r=N3())=>X9(e,t,n,r,`x`),fpe=(e,t,n,r=N3())=>X9(e,t,n,r,`y`),ppe=(e=1,t=0,n=N3())=>n.mul(e).add(t),mpe=(e,t=1)=>(e=q(e),e.abs().pow(t).mul(e.sign())),hpe=(e,t=1,n=.5)=>q(e).sub(n).mul(t).add(n),gpe=(e=N3(),t=1,n=0)=>H9(e.convert(`vec2|vec3`)).mul(t).add(n),_pe=(e=N3(),t=1,n=0)=>U9(e.convert(`vec2|vec3`)).mul(t).add(n),vpe=(e=N3(),t=1,n=0)=>{e=e.convert(`vec2|vec3`);let r=i0(U9(e),H9(e.add(Y(19,73))));return r.mul(t).add(n)},ype=(e=N3(),t=1)=>tpe(e.convert(`vec2|vec3`),t,J(1)),bpe=(e=N3(),t=1)=>rpe(e.convert(`vec2|vec3`),t,J(1)),xpe=(e=N3(),t=1)=>ape(e.convert(`vec2|vec3`),t,J(1)),Spe=(e=N3())=>Hfe(e.convert(`vec2|vec3`)),Cpe=(e=N3(),t=3,n=2,r=.5,i=1)=>G9(e,J(t),n,r).mul(i),wpe=(e=N3(),t=3,n=2,r=.5,i=1)=>qfe(e,J(t),n,r).mul(i),Tpe=(e=N3(),t=3,n=2,r=.5,i=1)=>K9(e,J(t),n,r).mul(i),Epe=(e=N3(),t=3,n=2,r=.5,i=1)=>Jfe(e,J(t),n,r).mul(i),Dpe=K(([e,t,n])=>{let r=e4(e).toVar(),i=f2(q(.5).mul(t.sub(n)),s6).div(r).toVar(),a=f2(q(-.5).mul(t.sub(n)),s6).div(r).toVar(),o=X().toVar();o.x=r.x.greaterThan(q(0)).select(i.x,a.x),o.y=r.y.greaterThan(q(0)).select(i.y,a.y),o.z=r.z.greaterThan(q(0)).select(i.z,a.z);let s=S4(o.x,o.y,o.z).toVar(),c=s6.add(r.mul(s)).toVar();return c.sub(n)}),Ope=K(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(p2(n,n).sub(p2(r,r)))),a});var $=Object.freeze({__proto__:null,BRDF_GGX:Hce,BRDF_Lambert:Lce,BasicPointShadowFilter:y9,BasicShadowFilter:s9,Break:_8,Const:r3,Continue:lce,DFGApprox:Uce,D_GGX:t5,Discard:O3,EPSILON:R2,F_Schlick:Q8,Fn:K,INFINITY:z2,If:K1,Loop:g8,NodeAccess:G$,NodeShaderStage:H$,NodeType:W$,NodeUpdateType:U$,PCFShadowFilter:c9,PCFSoftShadowFilter:l9,PI:B2,PI2:V2,PointShadowFilter:b9,Return:Eoe,Schlick_to_F0:Wce,ScriptableNodeResources:V7,ShaderNode:B1,Stack:J1,Switch:q1,TBNViewMatrix:G6,VSMShadowFilter:u9,V_GGX_SmithCorrelated:e5,Var:n3,abs:c4,acesFilmicToneMapping:Zue,acos:o4,add:d2,addMethodChaining:H,addNodeElement:koe,agxToneMapping:tde,all:H2,alphaT:M0,and:S2,anisotropy:N0,anisotropyB:F0,anisotropyT:P0,any:U2,append:g0,array:i2,arrayBuffer:f0,asin:a4,assign:o2,atan:s4,atan2:K4,atomicAdd:Nde,atomicAnd:Lde,atomicFunc:Z7,atomicLoad:jde,atomicMax:Fde,atomicMin:Ide,atomicOr:Rde,atomicStore:Mde,atomicSub:Pde,atomicXor:zde,attenuationColor:q0,attenuationDistance:K0,attribute:M3,attributeArray:fue,backgroundBlurriness:gue,backgroundIntensity:_ue,backgroundRotation:vue,batch:d8,billboarding:qle,bitAnd:E2,bitNot:D2,bitOr:O2,bitXor:k2,bitangentGeometry:use,bitangentLocal:dse,bitangentView:U6,bitangentWorld:fse,bitcast:b4,blendBurn:D7,blendColor:Oue,blendDodge:O7,blendOverlay:A7,blendScreen:k7,blur:E5,bool:Z1,buffer:V3,bufferAttribute:g3,bumpMap:J6,burn:jue,bvec2:e0,bvec3:r0,bvec4:s0,bypass:C3,cache:x3,call:c2,cameraFar:q3,cameraIndex:G3,cameraNear:K3,cameraNormalMatrix:Voe,cameraPosition:Hoe,cameraProjectionMatrix:J3,cameraProjectionMatrixInverse:zoe,cameraViewMatrix:Y3,cameraWorldMatrix:Boe,cbrt:F4,cdl:zue,ceil:$2,checker:pfe,cineonToneMapping:Yue,clamp:R4,clearcoat:T0,clearcoatRoughness:E0,code:L7,color:Y1,colorSpaceToWorking:f3,colorToDirection:Fce,compute:b3,computeSkinning:sce,cond:Z4,context:$4,convert:m0,convertColorSpace:goe,convertToTexture:sue,cos:r4,cross:k4,cubeTexture:M6,cubeTextureBase:j6,cubeToUV:v9,dFdx:p4,dFdy:m4,dashSize:B0,debug:A3,decrement:F2,decrementBefore:N2,defaultBuildStages:q$,defaultShaderStages:K$,defined:R1,degrees:G2,deltaTime:t7,densityFog:mde,densityFogFactor:W7,depth:U8,depthPass:Wue,difference:D4,diffuseColor:x0,directPointLight:ffe,directionToColor:Pce,dispersion:J0,distance:E4,div:m2,dodge:Mue,dot:O4,drawIndex:c8,dynamicBufferAttribute:_3,element:p0,emissive:S0,equal:g2,equals:x4,equirectUV:Z8,exp:K2,exp2:q2,expression:D3,faceDirection:f6,faceForward:H4,faceforward:q4,float:q,floor:Q2,fog:G7,fract:t4,frameGroup:Q0,frameId:Lle,frontFacing:d6,fwidth:v4,gain:Ale,gapSize:V0,getConstNodeType:z1,getCurrentStack:G1,getDirection:S5,getDistanceAttenuation:w9,getGeometryRoughness:$8,getNormalFromDepth:lue,getParallaxCorrectNormal:Dpe,getRoughness:Rce,getScreenPosition:cue,getShIrradianceAt:Ope,getShadowMaterial:d9,getShadowRenderObjectFunction:m9,getTextureIndex:Y5,getViewPosition:y7,globalId:bde,glsl:ade,glslFn:sde,grayscale:Fue,greaterThan:y2,greaterThanEqual:x2,hash:kle,highpModelNormalViewMatrix:tse,highpModelViewMatrix:ese,hue:Rue,increment:P2,incrementBefore:M2,instance:ece,instanceIndex:s8,instancedArray:pue,instancedBufferAttribute:v3,instancedDynamicBufferAttribute:y3,instancedMesh:u8,int:J,inverseSqrt:Z2,inversesqrt:J4,invocationLocalIndex:$se,invocationSubgroupIndex:Qse,ior:U0,iridescence:k0,iridescenceIOR:A0,iridescenceThickness:j0,ivec2:Q1,ivec3:t0,ivec4:a0,js:rde,label:e3,length:u4,lengthSq:I4,lessThan:v2,lessThanEqual:b2,lightPosition:t9,lightProjectionUV:Bde,lightShadowMatrix:e9,lightTargetDirection:Hde,lightTargetPosition:n9,lightViewPosition:Vde,lightingContext:C8,lights:Kde,linearDepth:W8,linearToneMapping:que,localId:xde,log:J2,log2:Y2,logarithmicDepthToViewZ:wce,loop:uce,luminance:j7,mat2:c0,mat3:l0,mat4:u0,matcapUV:ple,materialAO:n8,materialAlphaTest:X6,materialAnisotropy:Fse,materialAnisotropyVector:r8,materialAttenuationColor:Use,materialAttenuationDistance:Hse,materialClearcoat:kse,materialClearcoatNormal:jse,materialClearcoatRoughness:Ase,materialColor:Z6,materialDispersion:Xse,materialEmissive:Q6,materialEnvIntensity:ise,materialEnvRotation:T6,materialIOR:Vse,materialIridescence:Ise,materialIridescenceIOR:Lse,materialIridescenceThickness:Rse,materialLightMap:t8,materialLineDashOffset:Jse,materialLineDashSize:Gse,materialLineGapSize:Kse,materialLineScale:Wse,materialLineWidth:qse,materialMetalness:Ose,materialNormal:e8,materialOpacity:$6,materialPointSize:Yse,materialReference:I6,materialReflectivity:Ese,materialRefractionRatio:w6,materialRotation:Mse,materialRoughness:Dse,materialSheen:Nse,materialSheenRoughness:Pse,materialShininess:xse,materialSpecular:Sse,materialSpecularColor:wse,materialSpecularIntensity:Cse,materialSpecularStrength:Tse,materialThickness:Bse,materialTransmission:zse,max:C4,maxMipLevel:F3,mediumpModelViewMatrix:r6,metalness:w0,min:S4,mix:L4,mixElement:W4,mod:h2,modInt:L2,modelDirection:Joe,modelNormalMatrix:t6,modelPosition:Yoe,modelRadius:Qoe,modelScale:Xoe,modelViewMatrix:n6,modelViewPosition:Zoe,modelViewProjection:i8,modelWorldMatrix:e6,modelWorldMatrixInverse:$oe,morphReference:x8,mrt:X5,mul:p2,mx_aastep:J9,mx_cell_noise_float:Spe,mx_contrast:hpe,mx_fractal_noise_float:Cpe,mx_fractal_noise_vec2:wpe,mx_fractal_noise_vec3:Tpe,mx_fractal_noise_vec4:Epe,mx_hsvtorgb:ope,mx_noise_float:gpe,mx_noise_vec3:_pe,mx_noise_vec4:vpe,mx_ramplr:lpe,mx_ramptb:upe,mx_rgbtohsv:spe,mx_safepower:mpe,mx_splitlr:dpe,mx_splittb:fpe,mx_srgb_texture_to_lin_rec709:cpe,mx_transform_uv:ppe,mx_worley_noise_float:ype,mx_worley_noise_vec2:bpe,mx_worley_noise_vec3:xpe,namespace:S3,negate:d4,neutralToneMapping:nde,nodeArray:H1,nodeImmutable:G,nodeObject:U,nodeObjects:V1,nodeProxy:W,normalFlat:h6,normalGeometry:p6,normalLocal:m6,normalMap:q6,normalView:g6,normalWorld:_6,normalize:e4,not:w2,notEqual:_2,numWorkgroups:vde,objectDirection:Uoe,objectGroup:e2,objectPosition:Q3,objectRadius:qoe,objectScale:Goe,objectViewPosition:Koe,objectWorldMatrix:Woe,oneMinus:f4,or:C2,orthographicDepthToViewZ:Cce,oscSawtooth:Wle,oscSine:Vle,oscSquare:Hle,oscTriangle:Ule,output:z0,outputStruct:Dle,overlay:Pue,overloadingFn:$5,parabola:Z5,parallaxDirection:K6,parallaxUV:mse,parameter:ble,pass:Hue,passTexture:Uue,pcurve:jle,perspectiveDepthToViewZ:B8,pmremTexture:dle,pointShadow:dfe,pointUV:hue,pointWidth:H0,positionGeometry:i6,positionLocal:a6,positionPrevious:o6,positionView:l6,positionViewDirection:u6,positionWorld:s6,positionWorldDirection:c6,posterize:Vue,pow:A4,pow2:j4,pow3:M4,pow4:N4,premult:kue,property:y0,radians:W2,rand:U4,range:gde,rangeFog:pde,rangeFogFactor:U7,reciprocal:g4,reference:P6,referenceBuffer:F6,reflect:T4,reflectVector:O6,reflectView:E6,reflector:nue,refract:B4,refractVector:k6,refractView:D6,reinhardToneMapping:Jue,remainder:I2,remap:T3,remapClamp:E3,renderGroup:$0,renderOutput:k3,rendererReference:p3,rotate:q5,rotateUV:Gle,roughness:C0,round:h4,rtt:v7,sRGBTransferEOTF:s3,sRGBTransferOETF:c3,sampler:Poe,samplerComparison:Foe,saturate:z4,saturation:Iue,screen:Nue,screenCoordinate:k8,screenSize:O8,screenUV:D8,scriptable:fde,scriptableValue:z7,select:X4,setCurrentStack:W1,shaderStages:J$,shadow:sfe,shadowPositionWorld:a9,shapeCircle:mfe,sharedUniformGroup:Z0,sheen:D0,sheenRoughness:O0,shiftLeft:A2,shiftRight:j2,shininess:R0,sign:l4,sin:n4,sinc:Mle,skinning:h8,smoothstep:V4,smoothstepElement:G4,specularColor:I0,specularF90:L0,spherizeUV:Kle,split:h0,spritesheetUV:Xle,sqrt:X2,stack:Sle,step:w4,storage:f8,storageBarrier:Tde,storageObject:oce,storageTexture:C7,string:d0,struct:Ele,sub:f2,subgroupIndex:Zse,subgroupSize:Sde,tan:i4,tangentGeometry:L6,tangentLocal:R6,tangentView:z6,tangentWorld:B6,temp:i3,texture:R3,texture3D:Cue,textureBarrier:Ede,textureBicubic:Gce,textureCubeUV:C5,textureLoad:z3,textureSize:P3,textureStore:bue,thickness:G0,time:e7,timerDelta:Ble,timerGlobal:zle,timerLocal:Rle,toneMapping:m3,toneMappingExposure:h3,toonOutlinePass:Kue,transformDirection:P4,transformNormal:b6,transformNormalToView:x6,transformedBentNormalView:hse,transformedBitangentView:W6,transformedBitangentWorld:pse,transformedClearcoatNormalView:rse,transformedNormalView:v6,transformedNormalWorld:y6,transformedTangentView:V6,transformedTangentWorld:lse,transmission:W0,transpose:y4,triNoise3D:Ple,triplanarTexture:Qle,triplanarTextures:n7,trunc:_4,tslFn:_0,uint:X1,uniform:n2,uniformArray:U3,uniformCubeTexture:ose,uniformGroup:X0,uniformTexture:Noe,uniforms:Loe,unpremult:Aue,userData:Tue,uv:N3,uvec2:$1,uvec3:n0,uvec4:o0,varying:a3,varyingProperty:b0,vec2:Y,vec3:X,vec4:i0,vectorComponents:Y$,velocity:Due,vertexColor:J8,vertexIndex:o8,vertexStage:o3,vibrance:Lue,viewZToLogarithmicDepth:V8,viewZToOrthographicDepth:R8,viewZToPerspectiveDepth:z8,viewport:A8,viewportBottomLeft:yce,viewportCoordinate:M8,viewportDepthTexture:I8,viewportLinearDepth:Tce,viewportMipTexture:xce,viewportResolution:_ce,viewportSafeUV:Jle,viewportSharedTexture:Nce,viewportSize:j8,viewportTexture:bce,viewportTopLeft:vce,viewportUV:gce,wgsl:ide,wgslFn:cde,workgroupArray:kde,workgroupBarrier:wde,workgroupId:yde,workingToColorSpace:d3,xor:T2}),kpe=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};kpe.isNodeFunctionInput=!0;var Ape=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};Ape.isNodeFunction=!0;const jpe={[hY]:`never`,[gY]:`less`,[_Y]:`equal`,[vY]:`less-equal`,[yY]:`greater`,[xY]:`greater-equal`,[SY]:`always`,[bY]:`not-equal`},Z9=typeof self<`u`?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},Mpe={[G$.READ_ONLY]:`read`,[G$.WRITE_ONLY]:`write`,[G$.READ_WRITE]:`read_write`},Npe={[RJ]:`repeat`,[zJ]:`clamp`,[BJ]:`mirror`},Ppe={vertex:Z9?Z9.VERTEX:1,fragment:Z9?Z9.FRAGMENT:2,compute:Z9?Z9.COMPUTE:4},Q9={tsl_xor:new I7(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new I7(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new I7(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new I7(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new I7(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new I7(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new I7(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new I7(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new I7(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new I7(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new I7(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new I7(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new I7(`
|
|
433
|
+
return { ...output, `+n+` };`,a=r+this.codeNode.code+i;return this._method=Function(...e,a),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose==`function`&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){let t=[w$(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return T$(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call(`main`),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}};const lde=W(cde).setParameterLength(1,2);function H7(e){let t,n=e.context.getViewZ;return n!==void 0&&(t=n(this)),(t||l6.z).negate()}const U7=K(([e,t],n)=>{let r=H7(n);return B4(e,t,r)}),W7=K(([e],t)=>{let n=H7(t);return e.mul(e,n,n).negate().exp().oneMinus()}),G7=K(([e,t])=>r0(t.toFloat().mix(R0.rgb,e.toVec3()),R0.a));function ude(e,t,n){return console.warn(`THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.`),G7(e,U7(t,n))}function dde(e,t){return console.warn(`THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.`),G7(e,W7(t))}let K7=null,q7=null;var fde=class extends Z${static get type(){return`RangeNode`}constructor(e=q(),t=q()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(I$(this.minNode.value)),n=e.getTypeLength(I$(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):`float`}setup(e){let t=e.object,n=null;if(t.count>1){let r=this.minNode.value,i=this.maxNode.value,a=e.getTypeLength(I$(r)),o=e.getTypeLength(I$(i));K7||=new wX,q7||=new wX,K7.setScalar(0),q7.setScalar(0),a===1?K7.setScalar(r):r.isColor?K7.set(r.r,r.g,r.b,1):K7.set(r.x,r.y,r.z||0,r.w||0),o===1?q7.setScalar(i):i.isColor?q7.set(i.r,i.g,i.b,1):q7.set(i.x,i.y,i.z||0,i.w||0);let s=4,c=s*t.count,l=new Float32Array(c);for(let e=0;e<c;e++){let t=e%s,n=K7.getComponent(t),r=q7.getComponent(t);l[e]=$Y.lerp(n,r,Math.random())}let u=this.getNodeType(e);if(t.count<=4096)n=V3(l,`vec4`,t.count).element(s8).convert(u);else{let t=new IQ(l,4);e.geometry.setAttribute(`__range`+this.id,t),n=v3(t).convert(u)}}else n=q(0);return n}};const pde=W(fde).setParameterLength(2);var mde=class extends Z${static get type(){return`ComputeBuiltinNode`}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){let n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage===`compute`?e.format(n,r,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}};const J7=(e,t)=>U(new mde(e,t)),hde=J7(`numWorkgroups`,`uvec3`),gde=J7(`workgroupId`,`uvec3`),_de=J7(`globalId`,`uvec3`),vde=J7(`localId`,`uvec3`),yde=J7(`subgroupSize`,`uint`);var bde=class extends Z${constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(`\t// ${t}Barrier \n`):e.addLineFlowCode(`${t}Barrier()`,this)}};const Y7=W(bde),xde=()=>Y7(`workgroup`).toStack(),Sde=()=>Y7(`storage`).toStack(),Cde=()=>Y7(`texture`).toStack();var wde=class extends Q${constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n,r=e.context.assign;if(n=super.generate(e),r!==!0){let r=this.getNodeType(e);n=e.format(n,r,t)}return n}},Tde=class extends Z${constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e}label(e){return this.name=e,this}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return U(new wde(this,e))}generate(e){return e.getScopedArray(this.name||`${this.scope}Array_${this.id}`,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}};const Ede=(e,t)=>U(new Tde(`Workgroup`,e,t));var X7=class extends Z${static get type(){return`AtomicFunctionNode`}constructor(e,t,n){super(`uint`),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),n=t.parents,r=this.method,i=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,s=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),s!==null&&c.push(s.build(e,a));let l=`${e.getMethod(r,i)}( ${c.join(`, `)} )`,u=n.length===1&&n[0].isStackNode===!0;if(u)e.addLineFlowCode(l,this);else return t.constNode===void 0&&(t.constNode=D3(l,i).toConst()),t.constNode.build(e)}};X7.ATOMIC_LOAD=`atomicLoad`,X7.ATOMIC_STORE=`atomicStore`,X7.ATOMIC_ADD=`atomicAdd`,X7.ATOMIC_SUB=`atomicSub`,X7.ATOMIC_MAX=`atomicMax`,X7.ATOMIC_MIN=`atomicMin`,X7.ATOMIC_AND=`atomicAnd`,X7.ATOMIC_OR=`atomicOr`,X7.ATOMIC_XOR=`atomicXor`;const Dde=W(X7),Z7=(e,t,n)=>Dde(e,t,n).toStack(),Ode=e=>Z7(X7.ATOMIC_LOAD,e,null),kde=(e,t)=>Z7(X7.ATOMIC_STORE,e,t),Ade=(e,t)=>Z7(X7.ATOMIC_ADD,e,t),jde=(e,t)=>Z7(X7.ATOMIC_SUB,e,t),Mde=(e,t)=>Z7(X7.ATOMIC_MAX,e,t),Nde=(e,t)=>Z7(X7.ATOMIC_MIN,e,t),Pde=(e,t)=>Z7(X7.ATOMIC_AND,e,t),Fde=(e,t)=>Z7(X7.ATOMIC_OR,e,t),Ide=(e,t)=>Z7(X7.ATOMIC_XOR,e,t);let Q7;function $7(e){Q7||=new WeakMap;let t=Q7.get(e);return t===void 0&&Q7.set(e,t={}),t}function e9(e){let t=$7(e);return t.shadowMatrix||=t2(`mat4`).setGroup(Q0).onRenderUpdate(t=>((e.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&e.shadow.updateMatrices(e),e.shadow.matrix))}function Lde(e,t=s6){let n=e9(e).mul(t),r=n.xyz.div(n.w);return r}function t9(e){let t=$7(e);return t.position||=t2(new V).setGroup(Q0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.matrixWorld))}function n9(e){let t=$7(e);return t.targetPosition||=t2(new V).setGroup(Q0).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(e.target.matrixWorld))}function Rde(e){let t=$7(e);return t.viewPosition||=t2(new V).setGroup(Q0).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new V,n.value.setFromMatrixPosition(e.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)})}const zde=e=>Y3.transformDirection(t9(e).sub(n9(e))),Bde=e=>e.sort((e,t)=>e.id-t.id),Vde=(e,t)=>{for(let n of t)if(n.isAnalyticLightNode&&n.light.id===e)return n;return null},r9=new WeakMap,i9=[];var Hde=class extends Z${static get type(){return`LightsNode`}constructor(){super(`vec3`),this.totalDiffuseNode=X().toVar(),this.totalSpecularNode=X().toVar(),this.outgoingLightNode=X().toVar(),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let n=e[t];if(i9.push(n.id),i9.push(n.castShadow?1:0),n.isSpotLight===!0){let e=n.map===null?-1:n.map.id,t=n.colorNode?n.colorNode.getCacheKey():-1;i9.push(e,t)}}let t=T$(i9);return i9.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getSelf().getHash());this._lightNodesHash=`lights-`+t.join(`,`)}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],n=this._lightNodes,r=Bde(this._lights),i=e.renderer.library;for(let e of r)if(e.isNode)t.push(U(e));else{let r=null;if(n!==null&&(r=Vde(e.id,n)),r===null){let n=i.getLightNodeClass(e.constructor);if(n===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let r=null;r9.has(e)?r=r9.get(e):(r=U(new n(e)),r9.set(e,r)),t.push(r)}}this._lightNodes=t}setupDirectLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.direct({...n,lightNode:t,reflectedLight:i},e)}setupDirectRectAreaLight(e,t,n){let{lightingModel:r,reflectedLight:i}=e.context;r.directRectArea({...n,lightNode:t,reflectedLight:i},e)}setupLights(e,t){for(let n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode,r=e.context,i=r.lightingModel,a=e.getNodeProperties(this);if(i){let{totalDiffuseNode:t,totalSpecularNode:o}=this;r.outgoingLight=n;let s=e.addStack();a.nodes=s.nodes,i.start(e);let{backdrop:c,backdropAlpha:l}=r,{directDiffuse:u,directSpecular:d,indirectDiffuse:f,indirectSpecular:p}=r.reflectedLight,m=u.add(f);c!==null&&(m=X(l===null?c:l.mix(m,c)),r.material.transparent=!0),t.assign(m),o.assign(d.add(p)),n.assign(t.add(o)),i.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}};const Ude=(e=[])=>U(new Hde).setLights(e);var Wde=class extends Z${static get type(){return`ShadowBaseNode`}constructor(e){super(),this.light=e,this.updateBeforeType=H$.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){a9.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||s6)}};const a9=v0(`vec3`,`shadowPositionWorld`);function Gde(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new KZ),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}function Kde(e,t){return t=Gde(e,t),e.setMRT(null),e.setRenderObjectFunction(null),e.setClearColor(0,1),e.autoClear=!0,t}function qde(e,t){e.toneMapping=t.toneMapping,e.toneMappingExposure=t.toneMappingExposure,e.outputColorSpace=t.outputColorSpace,e.setRenderTarget(t.renderTarget,t.activeCubeFace,t.activeMipmapLevel),e.setRenderObjectFunction(t.renderObjectFunction),e.setPixelRatio(t.pixelRatio),e.setMRT(t.mrt),e.setClearColor(t.clearColor,t.clearAlpha),e.autoClear=t.autoClear,e.setScissorTest(t.scissorTest)}function Jde(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}function Yde(e,t){return t=Jde(e,t),e.background=null,e.backgroundNode=null,e.overrideMaterial=null,t}function Xde(e,t){e.background=t.background,e.backgroundNode=t.backgroundNode,e.overrideMaterial=t.overrideMaterial}function Zde(e,t,n){return n=Kde(e,n),n=Yde(t,n),n}function Qde(e,t,n){qde(e,n),Xde(t,n)}const o9=new WeakMap,s9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=R3(e,t.xy).label(`t_basic`);return e.isArrayTexture&&(r=r.depth(n)),r.compare(t.z)}),c9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup(Q0),o=P6(`radius`,`float`,n).setGroup(Q0),s=Y(1).div(a),c=s.x.negate().mul(o),l=s.y.negate().mul(o),u=s.x.mul(o),d=s.y.mul(o),f=c.div(2),p=l.div(2),m=u.div(2),h=d.div(2);return u2(i(t.xy.add(Y(c,l)),t.z),i(t.xy.add(Y(0,l)),t.z),i(t.xy.add(Y(u,l)),t.z),i(t.xy.add(Y(f,p)),t.z),i(t.xy.add(Y(0,p)),t.z),i(t.xy.add(Y(m,p)),t.z),i(t.xy.add(Y(c,0)),t.z),i(t.xy.add(Y(f,0)),t.z),i(t.xy,t.z),i(t.xy.add(Y(m,0)),t.z),i(t.xy.add(Y(u,0)),t.z),i(t.xy.add(Y(f,h)),t.z),i(t.xy.add(Y(0,h)),t.z),i(t.xy.add(Y(m,h)),t.z),i(t.xy.add(Y(c,d)),t.z),i(t.xy.add(Y(0,d)),t.z),i(t.xy.add(Y(u,d)),t.z)).mul(1/17)}),l9=K(({depthTexture:e,shadowCoord:t,shadow:n,depthLayer:r})=>{let i=(t,n)=>{let i=R3(e,t);return e.isArrayTexture&&(i=i.depth(r)),i.compare(n)},a=P6(`mapSize`,`vec2`,n).setGroup(Q0),o=Y(1).div(a),s=o.x,c=o.y,l=t.xy,u=e4(l.mul(a).add(.5));return l.subAssign(u.mul(o)),u2(i(l,t.z),i(l.add(Y(s,0)),t.z),i(l.add(Y(0,c)),t.z),i(l.add(o),t.z),I4(i(l.add(Y(s.negate(),0)),t.z),i(l.add(Y(s.mul(2),0)),t.z),u.x),I4(i(l.add(Y(s.negate(),c)),t.z),i(l.add(Y(s.mul(2),c)),t.z),u.x),I4(i(l.add(Y(0,c.negate())),t.z),i(l.add(Y(0,c.mul(2))),t.z),u.y),I4(i(l.add(Y(s,c.negate())),t.z),i(l.add(Y(s,c.mul(2))),t.z),u.y),I4(I4(i(l.add(Y(s.negate(),c.negate())),t.z),i(l.add(Y(s.mul(2),c.negate())),t.z),u.x),I4(i(l.add(Y(s.negate(),c.mul(2))),t.z),i(l.add(Y(s.mul(2),c.mul(2))),t.z),u.x),u.y)).mul(1/9)}),u9=K(({depthTexture:e,shadowCoord:t,depthLayer:n})=>{let r=q(1).toVar(),i=R3(e).sample(t.xy);e.isArrayTexture&&(i=i.depth(n)),i=i.rg;let a=C4(t.z,i.x);return G1(a.notEqual(q(1)),()=>{let e=t.z.sub(i.x),n=S4(0,i.y.mul(i.y)),o=n.div(n.add(e.mul(e)));o=L4(d2(o,.3).div(.6499999999999999)),r.assign(L4(S4(a,o)))}),r}),$de=K(([e,t,n])=>{let r=s6.sub(e).length();return r=r.sub(t).div(n.sub(t)),r=r.saturate(),r}),efe=e=>{let t=e.shadow.camera,n=P6(`near`,`float`,t).setGroup(Q0),r=P6(`far`,`float`,t).setGroup(Q0),i=Q3(e);return $de(i,n,r)},d9=e=>{let t=o9.get(e);if(t===void 0){let n=e.isPointLight?efe(e):null;t=new Y8,t.colorNode=r0(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name=`ShadowMaterial`,t.fog=!1,o9.set(e,t)}return t},f9=new hle,p9=[],m9=(e,t,n,r)=>{p9[0]=e,p9[1]=t;let i=f9.get(p9);return(i===void 0||i.shadowType!==n||i.useVelocity!==r)&&(i=(i,a,o,s,c,l,...u)=>{(i.castShadow===!0||i.receiveShadow&&n===SJ)&&(r&&(R$(i).useVelocity=!0),i.onBeforeShadow(e,i,o,t.camera,s,a.overrideMaterial,l),e.renderObject(i,a,o,s,c,l,...u),i.onAfterShadow(e,i,o,t.camera,s,a.overrideMaterial,l))},i.shadowType=n,i.useVelocity=r,f9.set(p9,i)),p9[0]=null,p9[1]=null,i},tfe=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanVertical`),o=q(0).toVar(`squareMeanVertical`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(u2(k8.xy,Y(0,l).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),u=u.x,a.addAssign(u),o.addAssign(u.mul(u))}),a.divAssign(e),o.divAssign(e);let l=Y2(o.sub(a.mul(a)));return Y(a,l)}),nfe=K(({samples:e,radius:t,size:n,shadowPass:r,depthLayer:i})=>{let a=q(0).toVar(`meanHorizontal`),o=q(0).toVar(`squareMeanHorizontal`),s=e.lessThanEqual(q(1)).select(q(0),q(2).div(e.sub(1))),c=e.lessThanEqual(q(1)).select(q(0),q(-1));g8({start:J(0),end:J(e),type:`int`,condition:`<`},({i:e})=>{let l=c.add(q(e).mul(s)),u=r.sample(u2(k8.xy,Y(l,0).mul(t)).div(n));r.value.isArrayTexture&&(u=u.depth(i)),a.addAssign(u.x),o.addAssign(u2(u.y.mul(u.y),u.x.mul(u.x)))}),a.divAssign(e),o.divAssign(e);let l=Y2(o.sub(a.mul(a)));return Y(a,l)}),rfe=[s9,c9,l9,u9];let h9;const g9=new _7;var _9=class extends Wde{static get type(){return`ShadowNode`}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a}){let o=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),s=t({depthTexture:n,shadowCoord:r,shadow:i,depthLayer:a});return o.select(s,q(1))}setupShadowCoord(e,t){let{shadow:n}=this,{renderer:r}=e,i=P6(`bias`,`float`,n).setGroup(Q0),a=t,o;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z,r.coordinateSystem===TY&&(o=o.mul(2).sub(1));else{let e=a.w;a=a.xy.div(e);let t=P6(`near`,`float`,n.camera).setGroup(Q0),r=P6(`far`,`float`,n.camera).setGroup(Q0);o=V8(e.negate(),t,r)}return a=X(a.x,a.y.oneMinus(),o.add(i)),a}getShadowFilterFn(e){return rfe[e]}setupRenderTarget(e,t){let n=new HQ(e.mapSize.width,e.mapSize.height);n.name=`ShadowDepthTexture`,n.compareFunction=hY;let r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name=`ShadowMap`,r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){let{renderer:t}=e,{light:n,shadow:r}=this,i=t.shadowMap.type,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(r,e);if(r.camera.updateProjectionMatrix(),i===SJ&&r.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:QJ,type:JJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name=`VSMVertical`),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:QJ,type:JJ,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name=`VSMHorizontal`),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:QJ,type:JJ,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:QJ,type:JJ,depthBuffer:!1}));let t=R3(a);a.isArrayTexture&&(t=t.depth(this.depthLayer));let n=R3(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(n=n.depth(this.depthLayer));let i=P6(`blurSamples`,`float`,r).setGroup(Q0),s=P6(`radius`,`float`,r).setGroup(Q0),c=P6(`mapSize`,`vec2`,r).setGroup(Q0),l=this.vsmMaterialVertical||=new Y8;l.fragmentNode=tfe({samples:i,radius:s,size:c,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMVertical`,l=this.vsmMaterialHorizontal||=new Y8,l.fragmentNode=nfe({samples:i,radius:s,size:c,shadowPass:n,depthLayer:this.depthLayer}).context(e.getSharedContext()),l.name=`VSMHorizontal`}let s=P6(`intensity`,`float`,r).setGroup(Q0),c=P6(`normalBias`,`float`,r).setGroup(Q0),l=e9(n).mul(a9.add(y6.mul(c))),u=this.setupShadowCoord(e,l),d=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(d===null)throw Error(`THREE.WebGPURenderer: Shadow map type not supported yet.`);let f=i===SJ&&r.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,p=this.setupShadowFilter(e,{filterFn:d,shadowTexture:o.texture,depthTexture:f,shadowCoord:u,shadow:r,depthLayer:this.depthLayer}),m=R3(o.texture,u);a.isArrayTexture&&(m=m.depth(this.depthLayer));let h=I4(1,p.rgb.mix(m,1),s.mul(m.a)).toVar();return this.shadowMap=o,this.shadow.map=o,h}setup(e){if(e.renderer.shadowMap.enabled!==!1)return K(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn(`THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.`),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth),i.render(a,t.camera)}updateShadow(e){let{shadowMap:t,light:n,shadow:r}=this,{renderer:i,scene:a,camera:o}=e,s=i.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;let l=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=o.layers.mask);let u=i.getRenderObjectFunction(),d=i.getMRT(),f=d?d.has(`velocity`):!1;h9=Zde(i,a,h9),a.overrideMaterial=d9(n),i.setRenderObjectFunction(m9(i,r,s,f)),i.setClearColor(0,0),i.setRenderTarget(t),this.renderShadow(e),i.setRenderObjectFunction(u),s===SJ&&r.isPointLightShadow!==!0&&this.vsmPass(i),r.camera.layers.mask=l,Qde(i,a,h9)}vsmPass(e){let{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),g9.material=this.vsmMaterialVertical,g9.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),g9.material=this.vsmMaterialHorizontal,g9.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){let{shadow:t}=this,n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}};const ife=(e,t)=>U(new _9(e,t)),afe=new KZ,v9=K(([e,t])=>{let n=e.toVar(),r=s4(n),i=p2(1,S4(r.x,S4(r.y,r.z)));r.mulAssign(i),n.mulAssign(i.mul(t.mul(2).oneMinus()));let a=Y(n.xy).toVar(),o=t.mul(1.5),s=o.oneMinus();return G1(r.z.greaterThanEqual(s),()=>{G1(n.z.greaterThan(0),()=>{a.x.assign(d2(4,n.x))})}).ElseIf(r.x.greaterThanEqual(s),()=>{let e=c4(n.x);a.x.assign(n.z.mul(e).add(e.mul(2)))}).ElseIf(r.y.greaterThanEqual(s),()=>{let e=c4(n.y);a.x.assign(n.x.add(e.mul(2)).add(2)),a.y.assign(n.z.mul(e).sub(2))}),Y(.125,.25).mul(a).add(Y(.375,.75)).flipY()}).setLayout({name:`cubeToUV`,type:`vec2`,inputs:[{name:`pos`,type:`vec3`},{name:`texelSizeY`,type:`float`}]}),y9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r})=>R3(e,v9(t,r.y)).compare(n)),b9=K(({depthTexture:e,bd3D:t,dp:n,texelSize:r,shadow:i})=>{let a=P6(`radius`,`float`,i).setGroup(Q0),o=Y(-1,1).mul(a).mul(r.y);return R3(e,v9(t.add(o.xyy),r.y)).compare(n).add(R3(e,v9(t.add(o.yyy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xyx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yyx),r.y)).compare(n)).add(R3(e,v9(t,r.y)).compare(n)).add(R3(e,v9(t.add(o.xxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxy),r.y)).compare(n)).add(R3(e,v9(t.add(o.xxx),r.y)).compare(n)).add(R3(e,v9(t.add(o.yxx),r.y)).compare(n)).mul(1/9)}),ofe=K(({filterFn:e,depthTexture:t,shadowCoord:n,shadow:r})=>{let i=n.xyz.toVar(),a=i.length(),o=t2(`float`).setGroup(Q0).onRenderUpdate(()=>r.camera.near),s=t2(`float`).setGroup(Q0).onRenderUpdate(()=>r.camera.far),c=P6(`bias`,`float`,r).setGroup(Q0),l=t2(r.mapSize).setGroup(Q0),u=q(1).toVar();return G1(a.sub(s).lessThanEqual(0).and(a.sub(o).greaterThanEqual(0)),()=>{let n=a.sub(o).div(s.sub(o)).toVar();n.addAssign(c);let d=i.normalize(),f=Y(1).div(l.mul(Y(4,2)));u.assign(e({depthTexture:t,bd3D:d,dp:n,texelSize:f,shadow:r}))}),u}),x9=new wX,S9=new eX,C9=new eX;var sfe=class extends _9{static get type(){return`PointShadowNode`}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===xJ?y9:b9}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a}){return ofe({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:i,shadow:a})}renderShadow(e){let{shadow:t,shadowMap:n,light:r}=this,{renderer:i,scene:a}=e,o=t.getFrameExtents();C9.copy(t.mapSize),C9.multiply(o),n.setSize(C9.width,C9.height),S9.copy(t.mapSize);let s=i.autoClear,c=i.getClearColor(afe),l=i.getClearAlpha();i.autoClear=!1,i.setClearColor(t.clearColor,t.clearAlpha),i.clear();let u=t.getViewportCount();for(let e=0;e<u;e++){let o=t.getViewport(e),s=S9.x*o.x,c=C9.y-S9.y-S9.y*o.y;x9.set(s,c,S9.x*o.z,S9.y*o.w),n.viewport.copy(x9),t.updateMatrices(r,e),i.render(a,t.camera)}i.autoClear=s,i.setClearColor(c,l)}};const cfe=(e,t)=>U(new sfe(e,t)),w9=K(({lightDistance:e,cutoffDistance:t,decayExponent:n})=>{let r=e.pow(n).max(.01).reciprocal();return t.greaterThan(0).select(r.mul(e.div(t).pow4().oneMinus().clamp().pow2()),r)}),lfe=({color:e,lightVector:t,cutoffDistance:n,decayExponent:r})=>{let i=t.normalize(),a=t.length(),o=w9({lightDistance:a,cutoffDistance:n,decayExponent:r}),s=e.mul(o);return{lightDirection:i,lightColor:s}},ufe=K(([e=N3()])=>{let t=e.mul(2),n=t.x.floor(),r=t.y.floor(),i=n.add(r).mod(2);return i.sign()}),dfe=K(([e=N3()],{renderer:t,material:n})=>{let r=F4(e.mul(2).sub(1)),i;if(n.alphaToCoverage&&t.samples>1){let e=q(r.fwidth()).toVar();i=B4(e.oneMinus(),e.add(1),r).oneMinus()}else i=Y4(r.greaterThan(1),0,1);return i}),T9=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=X1(e).toVar();return Y4(a,i,r)}).setLayout({name:`mx_select`,type:`float`,inputs:[{name:`b`,type:`bool`},{name:`t`,type:`float`},{name:`f`,type:`float`}]}),E9=K(([e,t])=>{let n=X1(t).toVar(),r=q(e).toVar();return Y4(n,r.negate(),r)}).setLayout({name:`mx_negate_if`,type:`float`,inputs:[{name:`val`,type:`float`},{name:`b`,type:`bool`}]}),D9=K(([e])=>{let t=q(e).toVar();return J(Z2(t))}).setLayout({name:`mx_floor`,type:`int`,inputs:[{name:`x`,type:`float`}]}),O9=K(([e,t])=>{let n=q(e).toVar();return t.assign(D9(n)),n.sub(q(t))}),ffe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=q(r).toVar(),l=q(n).toVar(),u=q(t).toVar(),d=q(e).toVar(),f=q(d2(1,s)).toVar();return d2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),pfe=K(([e,t,n,r,i,a])=>{let o=q(a).toVar(),s=q(i).toVar(),c=X(r).toVar(),l=X(n).toVar(),u=X(t).toVar(),d=X(e).toVar(),f=q(d2(1,s)).toVar();return d2(1,o).mul(d.mul(f).add(u.mul(s))).add(o.mul(l.mul(f).add(c.mul(s))))}).setLayout({name:`mx_bilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`}]}),k9=$5([ffe,pfe]),mfe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=q(s).toVar(),h=q(o).toVar(),g=q(a).toVar(),_=q(i).toVar(),v=q(r).toVar(),y=q(n).toVar(),b=q(t).toVar(),x=q(e).toVar(),S=q(d2(1,p)).toVar(),ee=q(d2(1,f)).toVar(),te=q(d2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_0`,type:`float`,inputs:[{name:`v0`,type:`float`},{name:`v1`,type:`float`},{name:`v2`,type:`float`},{name:`v3`,type:`float`},{name:`v4`,type:`float`},{name:`v5`,type:`float`},{name:`v6`,type:`float`},{name:`v7`,type:`float`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),hfe=K(([e,t,n,r,i,a,o,s,c,l,u])=>{let d=q(u).toVar(),f=q(l).toVar(),p=q(c).toVar(),m=X(s).toVar(),h=X(o).toVar(),g=X(a).toVar(),_=X(i).toVar(),v=X(r).toVar(),y=X(n).toVar(),b=X(t).toVar(),x=X(e).toVar(),S=q(d2(1,p)).toVar(),ee=q(d2(1,f)).toVar(),te=q(d2(1,d)).toVar();return te.mul(ee.mul(x.mul(S).add(b.mul(p))).add(f.mul(y.mul(S).add(v.mul(p))))).add(d.mul(ee.mul(_.mul(S).add(g.mul(p))).add(f.mul(h.mul(S).add(m.mul(p))))))}).setLayout({name:`mx_trilerp_1`,type:`vec3`,inputs:[{name:`v0`,type:`vec3`},{name:`v1`,type:`vec3`},{name:`v2`,type:`vec3`},{name:`v3`,type:`vec3`},{name:`v4`,type:`vec3`},{name:`v5`,type:`vec3`},{name:`v6`,type:`vec3`},{name:`v7`,type:`vec3`},{name:`s`,type:`float`},{name:`t`,type:`float`},{name:`r`,type:`float`}]}),A9=$5([mfe,hfe]),gfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=Y1(e).toVar(),o=Y1(a.bitAnd(Y1(7))).toVar(),s=q(T9(o.lessThan(Y1(4)),i,r)).toVar(),c=q(f2(2,T9(o.lessThan(Y1(4)),r,i))).toVar();return E9(s,X1(o.bitAnd(Y1(1)))).add(E9(c,X1(o.bitAnd(Y1(2)))))}).setLayout({name:`mx_gradient_float_0`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),_fe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=Y1(e).toVar(),c=Y1(s.bitAnd(Y1(15))).toVar(),l=q(T9(c.lessThan(Y1(8)),o,a)).toVar(),u=q(T9(c.lessThan(Y1(4)),a,T9(c.equal(Y1(12)).or(c.equal(Y1(14))),o,i))).toVar();return E9(l,X1(c.bitAnd(Y1(1)))).add(E9(u,X1(c.bitAnd(Y1(2)))))}).setLayout({name:`mx_gradient_float_1`,type:`float`,inputs:[{name:`hash`,type:`uint`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]}),j9=$5([gfe,_fe]),vfe=K(([e,t,n])=>{let r=q(n).toVar(),i=q(t).toVar(),a=t0(e).toVar();return X(j9(a.x,i,r),j9(a.y,i,r),j9(a.z,i,r))}).setLayout({name:`mx_gradient_vec3_0`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`}]}),yfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=q(t).toVar(),s=t0(e).toVar();return X(j9(s.x,o,a,i),j9(s.y,o,a,i),j9(s.z,o,a,i))}).setLayout({name:`mx_gradient_vec3_1`,type:`vec3`,inputs:[{name:`hash`,type:`uvec3`},{name:`x`,type:`float`},{name:`y`,type:`float`},{name:`z`,type:`float`}]}),M9=$5([vfe,yfe]),bfe=K(([e])=>{let t=q(e).toVar();return f2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),xfe=K(([e])=>{let t=q(e).toVar();return f2(.982,t)}).setLayout({name:`mx_gradient_scale3d_0`,type:`float`,inputs:[{name:`v`,type:`float`}]}),Sfe=K(([e])=>{let t=X(e).toVar();return f2(.6616,t)}).setLayout({name:`mx_gradient_scale2d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),N9=$5([bfe,Sfe]),Cfe=K(([e])=>{let t=X(e).toVar();return f2(.982,t)}).setLayout({name:`mx_gradient_scale3d_1`,type:`vec3`,inputs:[{name:`v`,type:`vec3`}]}),P9=$5([xfe,Cfe]),F9=K(([e,t])=>{let n=J(t).toVar(),r=Y1(e).toVar();return r.shiftLeft(n).bitOr(r.shiftRight(J(32).sub(n)))}).setLayout({name:`mx_rotl32`,type:`uint`,inputs:[{name:`x`,type:`uint`},{name:`k`,type:`int`}]}),I9=K(([e,t,n])=>{e.subAssign(n),e.bitXorAssign(F9(n,J(4))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(6))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(8))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(F9(n,J(16))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(F9(e,J(19))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(F9(t,J(4))),t.addAssign(e)}),L9=K(([e,t,n])=>{let r=Y1(n).toVar(),i=Y1(t).toVar(),a=Y1(e).toVar();return r.bitXorAssign(i),r.subAssign(F9(i,J(14))),a.bitXorAssign(r),a.subAssign(F9(r,J(11))),i.bitXorAssign(a),i.subAssign(F9(a,J(25))),r.bitXorAssign(i),r.subAssign(F9(i,J(16))),a.bitXorAssign(r),a.subAssign(F9(r,J(4))),i.bitXorAssign(a),i.subAssign(F9(a,J(14))),r.bitXorAssign(i),r.subAssign(F9(i,J(24))),r}).setLayout({name:`mx_bjfinal`,type:`uint`,inputs:[{name:`a`,type:`uint`},{name:`b`,type:`uint`},{name:`c`,type:`uint`}]}),R9=K(([e])=>{let t=Y1(e).toVar();return q(t).div(q(Y1(J(4294967295))))}).setLayout({name:`mx_bits_to_01`,type:`float`,inputs:[{name:`bits`,type:`uint`}]}),z9=K(([e])=>{let t=q(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))}).setLayout({name:`mx_fade`,type:`float`,inputs:[{name:`t`,type:`float`}]}),wfe=K(([e])=>{let t=J(e).toVar(),n=Y1(Y1(1)).toVar(),r=Y1(Y1(J(3735928559)).add(n.shiftLeft(Y1(2))).add(Y1(13))).toVar();return L9(r.add(Y1(t)),r,r)}).setLayout({name:`mx_hash_int_0`,type:`uint`,inputs:[{name:`x`,type:`int`}]}),Tfe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=Y1(Y1(2)).toVar(),a=Y1().toVar(),o=Y1().toVar(),s=Y1().toVar();return a.assign(o.assign(s.assign(Y1(J(3735928559)).add(i.shiftLeft(Y1(2))).add(Y1(13))))),a.addAssign(Y1(r)),o.addAssign(Y1(n)),L9(a,o,s)}).setLayout({name:`mx_hash_int_1`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),Efe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=Y1(Y1(3)).toVar(),s=Y1().toVar(),c=Y1().toVar(),l=Y1().toVar();return s.assign(c.assign(l.assign(Y1(J(3735928559)).add(o.shiftLeft(Y1(2))).add(Y1(13))))),s.addAssign(Y1(a)),c.addAssign(Y1(i)),l.addAssign(Y1(r)),L9(s,c,l)}).setLayout({name:`mx_hash_int_2`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),Dfe=K(([e,t,n,r])=>{let i=J(r).toVar(),a=J(n).toVar(),o=J(t).toVar(),s=J(e).toVar(),c=Y1(Y1(4)).toVar(),l=Y1().toVar(),u=Y1().toVar(),d=Y1().toVar();return l.assign(u.assign(d.assign(Y1(J(3735928559)).add(c.shiftLeft(Y1(2))).add(Y1(13))))),l.addAssign(Y1(s)),u.addAssign(Y1(o)),d.addAssign(Y1(a)),I9(l,u,d),l.addAssign(Y1(i)),L9(l,u,d)}).setLayout({name:`mx_hash_int_3`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`}]}),Ofe=K(([e,t,n,r,i])=>{let a=J(i).toVar(),o=J(r).toVar(),s=J(n).toVar(),c=J(t).toVar(),l=J(e).toVar(),u=Y1(Y1(5)).toVar(),d=Y1().toVar(),f=Y1().toVar(),p=Y1().toVar();return d.assign(f.assign(p.assign(Y1(J(3735928559)).add(u.shiftLeft(Y1(2))).add(Y1(13))))),d.addAssign(Y1(l)),f.addAssign(Y1(c)),p.addAssign(Y1(s)),I9(d,f,p),d.addAssign(Y1(o)),f.addAssign(Y1(a)),L9(d,f,p)}).setLayout({name:`mx_hash_int_4`,type:`uint`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xx`,type:`int`},{name:`yy`,type:`int`}]}),B9=$5([wfe,Tfe,Efe,Dfe,Ofe]),kfe=K(([e,t])=>{let n=J(t).toVar(),r=J(e).toVar(),i=Y1(B9(r,n)).toVar(),a=t0().toVar();return a.x.assign(i.bitAnd(J(255))),a.y.assign(i.shiftRight(J(8)).bitAnd(J(255))),a.z.assign(i.shiftRight(J(16)).bitAnd(J(255))),a}).setLayout({name:`mx_hash_vec3_0`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`}]}),Afe=K(([e,t,n])=>{let r=J(n).toVar(),i=J(t).toVar(),a=J(e).toVar(),o=Y1(B9(a,i,r)).toVar(),s=t0().toVar();return s.x.assign(o.bitAnd(J(255))),s.y.assign(o.shiftRight(J(8)).bitAnd(J(255))),s.z.assign(o.shiftRight(J(16)).bitAnd(J(255))),s}).setLayout({name:`mx_hash_vec3_1`,type:`uvec3`,inputs:[{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`}]}),V9=$5([kfe,Afe]),jfe=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=q(k9(j9(B9(n,r),i,a),j9(B9(n.add(J(1)),r),i.sub(1),a),j9(B9(n,r.add(J(1))),i,a.sub(1)),j9(B9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Mfe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=q(A9(j9(B9(n,r,i),a,o,s),j9(B9(n.add(J(1)),r,i),a.sub(1),o,s),j9(B9(n,r.add(J(1)),i),a,o.sub(1),s),j9(B9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),j9(B9(n,r,i.add(J(1))),a,o,s.sub(1)),j9(B9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),j9(B9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),j9(B9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),H9=$5([jfe,Mfe]),Nfe=K(([e])=>{let t=Y(e).toVar(),n=J().toVar(),r=J().toVar(),i=q(O9(t.x,n)).toVar(),a=q(O9(t.y,r)).toVar(),o=q(z9(i)).toVar(),s=q(z9(a)).toVar(),c=X(k9(M9(V9(n,r),i,a),M9(V9(n.add(J(1)),r),i.sub(1),a),M9(V9(n,r.add(J(1))),i,a.sub(1)),M9(V9(n.add(J(1)),r.add(J(1))),i.sub(1),a.sub(1)),o,s)).toVar();return N9(c)}).setLayout({name:`mx_perlin_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Pfe=K(([e])=>{let t=X(e).toVar(),n=J().toVar(),r=J().toVar(),i=J().toVar(),a=q(O9(t.x,n)).toVar(),o=q(O9(t.y,r)).toVar(),s=q(O9(t.z,i)).toVar(),c=q(z9(a)).toVar(),l=q(z9(o)).toVar(),u=q(z9(s)).toVar(),d=X(A9(M9(V9(n,r,i),a,o,s),M9(V9(n.add(J(1)),r,i),a.sub(1),o,s),M9(V9(n,r.add(J(1)),i),a,o.sub(1),s),M9(V9(n.add(J(1)),r.add(J(1)),i),a.sub(1),o.sub(1),s),M9(V9(n,r,i.add(J(1))),a,o,s.sub(1)),M9(V9(n.add(J(1)),r,i.add(J(1))),a.sub(1),o,s.sub(1)),M9(V9(n,r.add(J(1)),i.add(J(1))),a,o.sub(1),s.sub(1)),M9(V9(n.add(J(1)),r.add(J(1)),i.add(J(1))),a.sub(1),o.sub(1),s.sub(1)),c,l,u)).toVar();return P9(d)}).setLayout({name:`mx_perlin_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),U9=$5([Nfe,Pfe]),Ffe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return R9(B9(n))}).setLayout({name:`mx_cell_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`float`}]}),Ife=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return R9(B9(n,r))}).setLayout({name:`mx_cell_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec2`}]}),Lfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return R9(B9(n,r,i))}).setLayout({name:`mx_cell_noise_float_2`,type:`float`,inputs:[{name:`p`,type:`vec3`}]}),Rfe=K(([e])=>{let t=r0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return R9(B9(n,r,i,a))}).setLayout({name:`mx_cell_noise_float_3`,type:`float`,inputs:[{name:`p`,type:`vec4`}]}),zfe=$5([Ffe,Ife,Lfe,Rfe]),Bfe=K(([e])=>{let t=q(e).toVar(),n=J(D9(t)).toVar();return X(R9(B9(n,J(0))),R9(B9(n,J(1))),R9(B9(n,J(2))))}).setLayout({name:`mx_cell_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`float`}]}),Vfe=K(([e])=>{let t=Y(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar();return X(R9(B9(n,r,J(0))),R9(B9(n,r,J(1))),R9(B9(n,r,J(2))))}).setLayout({name:`mx_cell_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec2`}]}),Hfe=K(([e])=>{let t=X(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar();return X(R9(B9(n,r,i,J(0))),R9(B9(n,r,i,J(1))),R9(B9(n,r,i,J(2))))}).setLayout({name:`mx_cell_noise_vec3_2`,type:`vec3`,inputs:[{name:`p`,type:`vec3`}]}),Ufe=K(([e])=>{let t=r0(e).toVar(),n=J(D9(t.x)).toVar(),r=J(D9(t.y)).toVar(),i=J(D9(t.z)).toVar(),a=J(D9(t.w)).toVar();return X(R9(B9(n,r,i,a,J(0))),R9(B9(n,r,i,a,J(1))),R9(B9(n,r,i,a,J(2))))}).setLayout({name:`mx_cell_noise_vec3_3`,type:`vec3`,inputs:[{name:`p`,type:`vec4`}]}),W9=$5([Bfe,Vfe,Hfe,Ufe]),G9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=q(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(H9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_float`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),K9=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(0).toVar(),l=q(1).toVar();return g8(o,()=>{c.addAssign(l.mul(U9(s))),l.mulAssign(i),s.mulAssign(a)}),c}).setLayout({name:`mx_fractal_noise_vec3`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Wfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar();return Y(G9(s,o,a,i),G9(s.add(X(J(19),J(193),J(17))),o,a,i))}).setLayout({name:`mx_fractal_noise_vec2`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Gfe=K(([e,t,n,r])=>{let i=q(r).toVar(),a=q(n).toVar(),o=J(t).toVar(),s=X(e).toVar(),c=X(K9(s,o,a,i)).toVar(),l=q(G9(s.add(X(J(19),J(193),J(17))),o,a,i)).toVar();return r0(c,l)}).setLayout({name:`mx_fractal_noise_vec4`,type:`vec4`,inputs:[{name:`p`,type:`vec3`},{name:`octaves`,type:`int`},{name:`lacunarity`,type:`float`},{name:`diminish`,type:`float`}]}),Kfe=K(([e,t,n,r,i,a,o])=>{let s=J(o).toVar(),c=q(a).toVar(),l=J(i).toVar(),u=J(r).toVar(),d=J(n).toVar(),f=J(t).toVar(),p=Y(e).toVar(),m=X(W9(Y(f.add(u),d.add(l)))).toVar(),h=Y(m.x,m.y).toVar();h.subAssign(.5),h.mulAssign(c),h.addAssign(.5);let g=Y(Y(q(f),q(d)).add(h)).toVar(),_=Y(g.sub(p)).toVar();return G1(s.equal(J(2)),()=>s4(_.x).add(s4(_.y))),G1(s.equal(J(3)),()=>S4(s4(_.x),s4(_.y))),D4(_,_)}).setLayout({name:`mx_worley_distance_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),qfe=K(([e,t,n,r,i,a,o,s,c])=>{let l=J(c).toVar(),u=q(s).toVar(),d=J(o).toVar(),f=J(a).toVar(),p=J(i).toVar(),m=J(r).toVar(),h=J(n).toVar(),g=J(t).toVar(),_=X(e).toVar(),v=X(W9(X(g.add(p),h.add(f),m.add(d)))).toVar();v.subAssign(.5),v.mulAssign(u),v.addAssign(.5);let y=X(X(q(g),q(h),q(m)).add(v)).toVar(),b=X(y.sub(_)).toVar();return G1(l.equal(J(2)),()=>s4(b.x).add(s4(b.y)).add(s4(b.z))),G1(l.equal(J(3)),()=>S4(s4(b.x),s4(b.y),s4(b.z))),D4(b,b)}).setLayout({name:`mx_worley_distance_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`x`,type:`int`},{name:`y`,type:`int`},{name:`z`,type:`int`},{name:`xoff`,type:`int`},{name:`yoff`,type:`int`},{name:`zoff`,type:`int`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),q9=$5([Kfe,qfe]),Jfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();l.assign(x4(l,n))})}),G1(r.equal(J(0)),()=>{l.assign(Y2(l))}),l}).setLayout({name:`mx_worley_noise_float_0`,type:`float`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Yfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();G1(n.lessThan(l.x),()=>{l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.y.assign(n)})})}),G1(r.equal(J(0)),()=>{l.assign(Y2(l))}),l}).setLayout({name:`mx_worley_noise_vec2_0`,type:`vec2`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Xfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=Y(e).toVar(),o=J().toVar(),s=J().toVar(),c=Y(O9(a.x,o),O9(a.y,s)).toVar(),l=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{let n=q(q9(c,e,t,o,s,i,r)).toVar();G1(n.lessThan(l.x),()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(n)}).ElseIf(n.lessThan(l.y),()=>{l.z.assign(l.y),l.y.assign(n)}).ElseIf(n.lessThan(l.z),()=>{l.z.assign(n)})})}),G1(r.equal(J(0)),()=>{l.assign(Y2(l))}),l}).setLayout({name:`mx_worley_noise_vec3_0`,type:`vec3`,inputs:[{name:`p`,type:`vec2`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Zfe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=q(1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();u.assign(x4(u,a))})})}),G1(r.equal(J(0)),()=>{u.assign(Y2(u))}),u}).setLayout({name:`mx_worley_noise_float_1`,type:`float`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),Qfe=$5([Jfe,Zfe]),$fe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=Y(1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();G1(a.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.y.assign(a)})})})}),G1(r.equal(J(0)),()=>{u.assign(Y2(u))}),u}).setLayout({name:`mx_worley_noise_vec2_1`,type:`vec2`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),epe=$5([Yfe,$fe]),tpe=K(([e,t,n])=>{let r=J(n).toVar(),i=q(t).toVar(),a=X(e).toVar(),o=J().toVar(),s=J().toVar(),c=J().toVar(),l=X(O9(a.x,o),O9(a.y,s),O9(a.z,c)).toVar(),u=X(1e6,1e6,1e6).toVar();return g8({start:-1,end:J(1),name:`x`,condition:`<=`},({x:e})=>{g8({start:-1,end:J(1),name:`y`,condition:`<=`},({y:t})=>{g8({start:-1,end:J(1),name:`z`,condition:`<=`},({z:n})=>{let a=q(q9(l,e,t,n,o,s,c,i,r)).toVar();G1(a.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(a)}).ElseIf(a.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(a)}).ElseIf(a.lessThan(u.z),()=>{u.z.assign(a)})})})}),G1(r.equal(J(0)),()=>{u.assign(Y2(u))}),u}).setLayout({name:`mx_worley_noise_vec3_1`,type:`vec3`,inputs:[{name:`p`,type:`vec3`},{name:`jitter`,type:`float`},{name:`metric`,type:`int`}]}),npe=$5([Xfe,tpe]),rpe=K(([e])=>{let t=e.y,n=e.z,r=X().toVar();return G1(t.lessThan(1e-4),()=>{r.assign(X(n,n,n))}).Else(()=>{let i=e.x;i=i.sub(Z2(i)).mul(6).toVar();let a=J(g4(i)),o=i.sub(q(a)),s=n.mul(t.oneMinus()),c=n.mul(t.mul(o).oneMinus()),l=n.mul(t.mul(o.oneMinus()).oneMinus());G1(a.equal(J(0)),()=>{r.assign(X(n,l,s))}).ElseIf(a.equal(J(1)),()=>{r.assign(X(c,n,s))}).ElseIf(a.equal(J(2)),()=>{r.assign(X(s,n,l))}).ElseIf(a.equal(J(3)),()=>{r.assign(X(s,c,n))}).ElseIf(a.equal(J(4)),()=>{r.assign(X(l,s,n))}).Else(()=>{r.assign(X(n,s,c))})}),r}).setLayout({name:`mx_hsvtorgb`,type:`vec3`,inputs:[{name:`hsv`,type:`vec3`}]}),ipe=K(([e])=>{let t=X(e).toVar(),n=q(t.x).toVar(),r=q(t.y).toVar(),i=q(t.z).toVar(),a=q(x4(n,x4(r,i))).toVar(),o=q(S4(n,S4(r,i))).toVar(),s=q(o.sub(a)).toVar(),c=q().toVar(),l=q().toVar(),u=q().toVar();return u.assign(o),G1(o.greaterThan(0),()=>{l.assign(s.div(o))}).Else(()=>{l.assign(0)}),G1(l.lessThanEqual(0),()=>{c.assign(0)}).Else(()=>{G1(n.greaterThanEqual(o),()=>{c.assign(r.sub(i).div(s))}).ElseIf(r.greaterThanEqual(o),()=>{c.assign(u2(2,i.sub(n).div(s)))}).Else(()=>{c.assign(u2(4,n.sub(r).div(s)))}),c.mulAssign(1/6),G1(c.lessThan(0),()=>{c.addAssign(1)})}),X(c,l,u)}).setLayout({name:`mx_rgbtohsv`,type:`vec3`,inputs:[{name:`c`,type:`vec3`}]}),ape=K(([e])=>{let t=X(e).toVar(),n=n0(v2(t,X(.04045))).toVar(),r=X(t.div(12.92)).toVar(),i=X(k4(S4(t.add(X(.055)),X(0)).div(1.055),X(2.4))).toVar();return I4(r,i,n)}).setLayout({name:`mx_srgb_texture_to_lin_rec709`,type:`vec3`,inputs:[{name:`color`,type:`vec3`}]}),J9=(e,t)=>{e=q(e),t=q(t);let n=Y(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return B4(e.sub(n),e.add(n),t)},Y9=(e,t,n,r)=>I4(e,t,n[r].clamp()),ope=(e,t,n=N3())=>Y9(e,t,n,`x`),spe=(e,t,n=N3())=>Y9(e,t,n,`y`),X9=(e,t,n,r,i)=>I4(e,t,J9(n,r[i])),cpe=(e,t,n,r=N3())=>X9(e,t,n,r,`x`),lpe=(e,t,n,r=N3())=>X9(e,t,n,r,`y`),upe=(e=1,t=0,n=N3())=>n.mul(e).add(t),dpe=(e,t=1)=>(e=q(e),e.abs().pow(t).mul(e.sign())),fpe=(e,t=1,n=.5)=>q(e).sub(n).mul(t).add(n),ppe=(e=N3(),t=1,n=0)=>H9(e.convert(`vec2|vec3`)).mul(t).add(n),mpe=(e=N3(),t=1,n=0)=>U9(e.convert(`vec2|vec3`)).mul(t).add(n),hpe=(e=N3(),t=1,n=0)=>{e=e.convert(`vec2|vec3`);let r=r0(U9(e),H9(e.add(Y(19,73))));return r.mul(t).add(n)},gpe=(e=N3(),t=1)=>Qfe(e.convert(`vec2|vec3`),t,J(1)),_pe=(e=N3(),t=1)=>epe(e.convert(`vec2|vec3`),t,J(1)),vpe=(e=N3(),t=1)=>npe(e.convert(`vec2|vec3`),t,J(1)),ype=(e=N3())=>zfe(e.convert(`vec2|vec3`)),bpe=(e=N3(),t=3,n=2,r=.5,i=1)=>G9(e,J(t),n,r).mul(i),xpe=(e=N3(),t=3,n=2,r=.5,i=1)=>Wfe(e,J(t),n,r).mul(i),Spe=(e=N3(),t=3,n=2,r=.5,i=1)=>K9(e,J(t),n,r).mul(i),Cpe=(e=N3(),t=3,n=2,r=.5,i=1)=>Gfe(e,J(t),n,r).mul(i),wpe=K(([e,t,n])=>{let r=$2(e).toVar(),i=d2(q(.5).mul(t.sub(n)),s6).div(r).toVar(),a=d2(q(-.5).mul(t.sub(n)),s6).div(r).toVar(),o=X().toVar();o.x=r.x.greaterThan(q(0)).select(i.x,a.x),o.y=r.y.greaterThan(q(0)).select(i.y,a.y),o.z=r.z.greaterThan(q(0)).select(i.z,a.z);let s=x4(o.x,o.y,o.z).toVar(),c=s6.add(r.mul(s)).toVar();return c.sub(n)}),Tpe=K(([e,t])=>{let n=e.x,r=e.y,i=e.z,a=t.element(0).mul(.886227);return a=a.add(t.element(1).mul(2*.511664).mul(r)),a=a.add(t.element(2).mul(2*.511664).mul(i)),a=a.add(t.element(3).mul(2*.511664).mul(n)),a=a.add(t.element(4).mul(2*.429043).mul(n).mul(r)),a=a.add(t.element(5).mul(2*.429043).mul(r).mul(i)),a=a.add(t.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),a=a.add(t.element(7).mul(2*.429043).mul(n).mul(i)),a=a.add(t.element(8).mul(.429043).mul(f2(n,n).sub(f2(r,r)))),a});var $=Object.freeze({__proto__:null,BRDF_GGX:zce,BRDF_Lambert:Pce,BasicPointShadowFilter:y9,BasicShadowFilter:s9,Break:_8,Const:r3,Continue:oce,DFGApprox:Bce,D_GGX:t5,Discard:O3,EPSILON:L2,F_Schlick:Q8,Fn:K,INFINITY:R2,If:G1,Loop:g8,NodeAccess:W$,NodeShaderStage:V$,NodeType:U$,NodeUpdateType:H$,PCFShadowFilter:c9,PCFSoftShadowFilter:l9,PI:z2,PI2:B2,PointShadowFilter:b9,Return:Coe,Schlick_to_F0:Vce,ScriptableNodeResources:V7,ShaderNode:z1,Stack:q1,Switch:K1,TBNViewMatrix:G6,VSMShadowFilter:u9,V_GGX_SmithCorrelated:e5,Var:n3,abs:s4,acesFilmicToneMapping:Jue,acos:a4,add:u2,addMethodChaining:H,addNodeElement:Eoe,agxToneMapping:Que,all:V2,alphaT:j0,and:x2,anisotropy:M0,anisotropyB:P0,anisotropyT:N0,any:H2,append:h0,array:r2,arrayBuffer:d0,asin:i4,assign:a2,atan:o4,atan2:G4,atomicAdd:Ade,atomicAnd:Pde,atomicFunc:Z7,atomicLoad:Ode,atomicMax:Mde,atomicMin:Nde,atomicOr:Fde,atomicStore:kde,atomicSub:jde,atomicXor:Ide,attenuationColor:K0,attenuationDistance:G0,attribute:M3,attributeArray:lue,backgroundBlurriness:pue,backgroundIntensity:mue,backgroundRotation:hue,batch:d8,billboarding:Wle,bitAnd:T2,bitNot:E2,bitOr:D2,bitXor:O2,bitangentGeometry:sse,bitangentLocal:cse,bitangentView:U6,bitangentWorld:lse,bitcast:y4,blendBurn:D7,blendColor:Tue,blendDodge:O7,blendOverlay:A7,blendScreen:k7,blur:E5,bool:X1,buffer:V3,bufferAttribute:g3,bumpMap:J6,burn:Oue,bvec2:$1,bvec3:n0,bvec4:o0,bypass:C3,cache:x3,call:s2,cameraFar:q3,cameraIndex:G3,cameraNear:K3,cameraNormalMatrix:Roe,cameraPosition:zoe,cameraProjectionMatrix:J3,cameraProjectionMatrixInverse:Ioe,cameraViewMatrix:Y3,cameraWorldMatrix:Loe,cbrt:P4,cdl:Iue,ceil:Q2,checker:ufe,cineonToneMapping:Kue,clamp:L4,clearcoat:w0,clearcoatRoughness:T0,code:L7,color:J1,colorSpaceToWorking:f3,colorToDirection:Mce,compute:b3,computeSkinning:ice,cond:X4,context:Q4,convert:p0,convertColorSpace:poe,convertToTexture:iue,cos:n4,cross:O4,cubeTexture:M6,cubeTextureBase:j6,cubeToUV:v9,dFdx:f4,dFdy:p4,dashSize:z0,debug:A3,decrement:P2,decrementBefore:M2,defaultBuildStages:K$,defaultShaderStages:G$,defined:L1,degrees:W2,deltaTime:t7,densityFog:dde,densityFogFactor:W7,depth:U8,depthPass:Vue,difference:E4,diffuseColor:b0,directPointLight:lfe,directionToColor:jce,dispersion:q0,distance:T4,div:p2,dodge:kue,dot:D4,drawIndex:c8,dynamicBufferAttribute:_3,element:f0,emissive:x0,equal:h2,equals:b4,equirectUV:Z8,exp:G2,exp2:K2,expression:D3,faceDirection:f6,faceForward:V4,faceforward:K4,float:q,floor:Z2,fog:G7,fract:e4,frameGroup:Z0,frameId:Ple,frontFacing:d6,fwidth:_4,gain:Dle,gapSize:B0,getConstNodeType:R1,getCurrentStack:W1,getDirection:S5,getDistanceAttenuation:w9,getGeometryRoughness:$8,getNormalFromDepth:oue,getParallaxCorrectNormal:wpe,getRoughness:Fce,getScreenPosition:aue,getShIrradianceAt:Tpe,getShadowMaterial:d9,getShadowRenderObjectFunction:m9,getTextureIndex:Y5,getViewPosition:y7,globalId:_de,glsl:nde,glslFn:ide,grayscale:Mue,greaterThan:v2,greaterThanEqual:b2,hash:Ele,highpModelNormalViewMatrix:Qoe,highpModelViewMatrix:Zoe,hue:Fue,increment:N2,incrementBefore:j2,instance:Zse,instanceIndex:s8,instancedArray:uue,instancedBufferAttribute:v3,instancedDynamicBufferAttribute:y3,instancedMesh:u8,int:J,inverseSqrt:X2,inversesqrt:q4,invocationLocalIndex:Xse,invocationSubgroupIndex:Yse,ior:H0,iridescence:O0,iridescenceIOR:k0,iridescenceThickness:A0,ivec2:Z1,ivec3:e0,ivec4:i0,js:ede,label:$4,length:l4,lengthSq:F4,lessThan:_2,lessThanEqual:y2,lightPosition:t9,lightProjectionUV:Lde,lightShadowMatrix:e9,lightTargetDirection:zde,lightTargetPosition:n9,lightViewPosition:Rde,lightingContext:C8,lights:Ude,linearDepth:W8,linearToneMapping:Wue,localId:vde,log:q2,log2:J2,logarithmicDepthToViewZ:xce,loop:sce,luminance:j7,mat2:s0,mat3:c0,mat4:l0,matcapUV:ule,materialAO:n8,materialAlphaTest:X6,materialAnisotropy:Mse,materialAnisotropyVector:r8,materialAttenuationColor:Bse,materialAttenuationDistance:zse,materialClearcoat:Ese,materialClearcoatNormal:Ose,materialClearcoatRoughness:Dse,materialColor:Z6,materialDispersion:qse,materialEmissive:Q6,materialEnvIntensity:tse,materialEnvRotation:T6,materialIOR:Rse,materialIridescence:Nse,materialIridescenceIOR:Pse,materialIridescenceThickness:Fse,materialLightMap:t8,materialLineDashOffset:Gse,materialLineDashSize:Hse,materialLineGapSize:Use,materialLineScale:Vse,materialLineWidth:Wse,materialMetalness:Tse,materialNormal:e8,materialOpacity:$6,materialPointSize:Kse,materialReference:I6,materialReflectivity:Cse,materialRefractionRatio:w6,materialRotation:kse,materialRoughness:wse,materialSheen:Ase,materialSheenRoughness:jse,materialShininess:vse,materialSpecular:yse,materialSpecularColor:xse,materialSpecularIntensity:bse,materialSpecularStrength:Sse,materialThickness:Lse,materialTransmission:Ise,max:S4,maxMipLevel:F3,mediumpModelViewMatrix:r6,metalness:C0,min:x4,mix:I4,mixElement:U4,mod:m2,modInt:I2,modelDirection:Goe,modelNormalMatrix:t6,modelPosition:Koe,modelRadius:Yoe,modelScale:qoe,modelViewMatrix:n6,modelViewPosition:Joe,modelViewProjection:i8,modelWorldMatrix:e6,modelWorldMatrixInverse:Xoe,morphReference:x8,mrt:X5,mul:f2,mx_aastep:J9,mx_cell_noise_float:ype,mx_contrast:fpe,mx_fractal_noise_float:bpe,mx_fractal_noise_vec2:xpe,mx_fractal_noise_vec3:Spe,mx_fractal_noise_vec4:Cpe,mx_hsvtorgb:rpe,mx_noise_float:ppe,mx_noise_vec3:mpe,mx_noise_vec4:hpe,mx_ramplr:ope,mx_ramptb:spe,mx_rgbtohsv:ipe,mx_safepower:dpe,mx_splitlr:cpe,mx_splittb:lpe,mx_srgb_texture_to_lin_rec709:ape,mx_transform_uv:upe,mx_worley_noise_float:gpe,mx_worley_noise_vec2:_pe,mx_worley_noise_vec3:vpe,namespace:S3,negate:u4,neutralToneMapping:$ue,nodeArray:V1,nodeImmutable:G,nodeObject:U,nodeObjects:B1,nodeProxy:W,normalFlat:h6,normalGeometry:p6,normalLocal:m6,normalMap:q6,normalView:g6,normalWorld:_6,normalize:$2,not:C2,notEqual:g2,numWorkgroups:hde,objectDirection:Boe,objectGroup:$0,objectPosition:Q3,objectRadius:Woe,objectScale:Hoe,objectViewPosition:Uoe,objectWorldMatrix:Voe,oneMinus:d4,or:S2,orthographicDepthToViewZ:bce,oscSawtooth:Vle,oscSine:Rle,oscSquare:zle,oscTriangle:Ble,output:R0,outputStruct:wle,overlay:jue,overloadingFn:$5,parabola:Z5,parallaxDirection:K6,parallaxUV:dse,parameter:_le,pass:zue,passTexture:Bue,pcurve:Ole,perspectiveDepthToViewZ:B8,pmremTexture:cle,pointShadow:cfe,pointUV:fue,pointWidth:V0,positionGeometry:i6,positionLocal:a6,positionPrevious:o6,positionView:l6,positionViewDirection:u6,positionWorld:s6,positionWorldDirection:c6,posterize:Rue,pow:k4,pow2:A4,pow3:j4,pow4:M4,premult:Eue,property:v0,radians:U2,rand:H4,range:pde,rangeFog:ude,rangeFogFactor:U7,reciprocal:h4,reference:P6,referenceBuffer:F6,reflect:w4,reflectVector:O6,reflectView:E6,reflector:$le,refract:z4,refractVector:k6,refractView:D6,reinhardToneMapping:Gue,remainder:F2,remap:T3,remapClamp:E3,renderGroup:Q0,renderOutput:k3,rendererReference:p3,rotate:q5,rotateUV:Hle,roughness:S0,round:m4,rtt:v7,sRGBTransferEOTF:s3,sRGBTransferOETF:c3,sampler:joe,samplerComparison:Moe,saturate:R4,saturation:Nue,screen:Aue,screenCoordinate:k8,screenSize:O8,screenUV:D8,scriptable:lde,scriptableValue:z7,select:Y4,setCurrentStack:U1,shaderStages:q$,shadow:ife,shadowPositionWorld:a9,shapeCircle:dfe,sharedUniformGroup:X0,sheen:E0,sheenRoughness:D0,shiftLeft:k2,shiftRight:A2,shininess:L0,sign:c4,sin:t4,sinc:kle,skinning:h8,smoothstep:B4,smoothstepElement:W4,specularColor:F0,specularF90:I0,spherizeUV:Ule,split:m0,spritesheetUV:qle,sqrt:Y2,stack:yle,step:C4,storage:f8,storageBarrier:Sde,storageObject:rce,storageTexture:C7,string:u0,struct:Cle,sub:d2,subgroupIndex:Jse,subgroupSize:yde,tan:r4,tangentGeometry:L6,tangentLocal:R6,tangentView:z6,tangentWorld:B6,temp:i3,texture:R3,texture3D:bue,textureBarrier:Cde,textureBicubic:Hce,textureCubeUV:C5,textureLoad:z3,textureSize:P3,textureStore:_ue,thickness:W0,time:e7,timerDelta:Lle,timerGlobal:Ile,timerLocal:Fle,toneMapping:m3,toneMappingExposure:h3,toonOutlinePass:Uue,transformDirection:N4,transformNormal:b6,transformNormalToView:x6,transformedBentNormalView:fse,transformedBitangentView:W6,transformedBitangentWorld:use,transformedClearcoatNormalView:ese,transformedNormalView:v6,transformedNormalWorld:y6,transformedTangentView:V6,transformedTangentWorld:ose,transmission:U0,transpose:v4,triNoise3D:jle,triplanarTexture:Yle,triplanarTextures:n7,trunc:g4,tslFn:g0,uint:Y1,uniform:t2,uniformArray:U3,uniformCubeTexture:rse,uniformGroup:Y0,uniformTexture:Aoe,uniforms:Poe,unpremult:Due,userData:Sue,uv:N3,uvec2:Q1,uvec3:t0,uvec4:a0,varying:a3,varyingProperty:y0,vec2:Y,vec3:X,vec4:r0,vectorComponents:J$,velocity:wue,vertexColor:J8,vertexIndex:o8,vertexStage:o3,vibrance:Pue,viewZToLogarithmicDepth:V8,viewZToOrthographicDepth:R8,viewZToPerspectiveDepth:z8,viewport:A8,viewportBottomLeft:gce,viewportCoordinate:M8,viewportDepthTexture:I8,viewportLinearDepth:Sce,viewportMipTexture:vce,viewportResolution:mce,viewportSafeUV:Gle,viewportSharedTexture:Ace,viewportSize:j8,viewportTexture:_ce,viewportTopLeft:hce,viewportUV:pce,wgsl:tde,wgslFn:ade,workgroupArray:Ede,workgroupBarrier:xde,workgroupId:gde,workingToColorSpace:d3,xor:w2}),Epe=class{constructor(e,t,n=null,r=``,i=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=i}};Epe.isNodeFunctionInput=!0;var Dpe=class{constructor(e,t,n=``,r=``){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn(`Abstract function.`)}};Dpe.isNodeFunction=!0;const Ope={[mY]:`never`,[hY]:`less`,[gY]:`equal`,[_Y]:`less-equal`,[vY]:`greater`,[bY]:`greater-equal`,[xY]:`always`,[yY]:`not-equal`},Z9=typeof self<`u`?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},kpe={[W$.READ_ONLY]:`read`,[W$.WRITE_ONLY]:`write`,[W$.READ_WRITE]:`read_write`},Ape={[LJ]:`repeat`,[RJ]:`clamp`,[zJ]:`mirror`},jpe={vertex:Z9?Z9.VERTEX:1,fragment:Z9?Z9.FRAGMENT:2,compute:Z9?Z9.COMPUTE:4},Q9={tsl_xor:new I7(`fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }`),mod_float:new I7(`fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }`),mod_vec2:new I7(`fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }`),mod_vec3:new I7(`fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }`),mod_vec4:new I7(`fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }`),equals_bool:new I7(`fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }`),equals_bvec2:new I7(`fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }`),equals_bvec3:new I7(`fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }`),equals_bvec4:new I7(`fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }`),repeatWrapping_float:new I7(`fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }`),mirrorWrapping_float:new I7(`fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }`),clampWrapping_float:new I7(`fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }`),biquadraticTexture:new I7(`
|
|
434
434
|
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
|
|
435
435
|
|
|
436
436
|
let res = vec2f( iRes );
|
|
@@ -452,5 +452,5 @@ fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, l
|
|
|
452
452
|
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
|
|
453
453
|
|
|
454
454
|
}
|
|
455
|
-
`)},$9={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast<f32>`};typeof navigator<`u`&&/Windows/g.test(navigator.userAgent)&&(Q9.pow_float=new I7(`fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }`),Q9.pow_vec2=new I7(`fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }`,[Q9.pow_float]),Q9.pow_vec3=new I7(`fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }`,[Q9.pow_float]),Q9.pow_vec4=new I7(`fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }`,[Q9.pow_float]),$9.pow_float=`tsl_pow_float`,$9.pow_vec2=`tsl_pow_vec2`,$9.pow_vec3=`tsl_pow_vec3`,$9.pow_vec4=`tsl_pow_vec4`);let
|
|
456
|
-
`);const Ipe=$.BRDF_GGX,Lpe=$.BRDF_Lambert,Rpe=$.BasicShadowFilter,zpe=$.Break,Bpe=$.Continue,Vpe=$.DFGApprox,Hpe=$.D_GGX,Upe=$.Discard,Wpe=$.EPSILON,Gpe=$.F_Schlick,Kpe=$.Fn,qpe=$.INFINITY,Jpe=$.If,Ype=$.Switch,Xpe=$.Loop,Zpe=$.NodeShaderStage,Qpe=$.NodeType,$pe=$.NodeUpdateType,eme=$.NodeAccess,tme=$.PCFShadowFilter,nme=$.PCFSoftShadowFilter,rme=$.PI,ime=$.PI2,ame=$.Return,ome=$.Schlick_to_F0,sme=$.ScriptableNodeResources,cme=$.ShaderNode,lme=$.TBNViewMatrix,ume=$.VSMShadowFilter,dme=$.V_GGX_SmithCorrelated,fme=$.abs,pme=$.acesFilmicToneMapping,mme=$.acos,hme=$.add,gme=$.addNodeElement,_me=$.agxToneMapping,vme=$.all,yme=$.alphaT,bme=$.and,xme=$.anisotropy,Sme=$.anisotropyB,Cme=$.anisotropyT,wme=$.any,Tme=$.append,Eme=$.array,Dme=$.arrayBuffer,Ome=$.asin,kme=$.assign,Ame=$.atan,jme=$.atan2,Mme=$.atomicAdd,Nme=$.atomicAnd,Pme=$.atomicFunc,Fme=$.atomicMax,Ime=$.atomicMin,Lme=$.atomicOr,Rme=$.atomicStore,zme=$.atomicSub,Bme=$.atomicXor,Vme=$.atomicLoad,Hme=$.attenuationColor,Ume=$.attenuationDistance,Wme=$.attribute,Gme=$.attributeArray,Kme=$.backgroundBlurriness,qme=$.backgroundIntensity,Jme=$.backgroundRotation,Yme=$.batch,Xme=$.billboarding,Zme=$.bitAnd,Qme=$.bitNot,$me=$.bitOr,ehe=$.bitXor,the=$.bitangentGeometry,nhe=$.bitangentLocal,rhe=$.bitangentView,ihe=$.bitangentWorld,ahe=$.bitcast,ohe=$.blendBurn,she=$.blendColor,che=$.blendDodge,lhe=$.blendOverlay,uhe=$.blendScreen,dhe=$.blur,fhe=$.bool,phe=$.buffer,mhe=$.bufferAttribute,hhe=$.bumpMap,ghe=$.burn,_he=$.bvec2,vhe=$.bvec3,yhe=$.bvec4,bhe=$.bypass,xhe=$.cache,She=$.call,Che=$.cameraFar,whe=$.cameraIndex,The=$.cameraNear,Ehe=$.cameraNormalMatrix,Dhe=$.cameraPosition,Ohe=$.cameraProjectionMatrix,khe=$.cameraProjectionMatrixInverse,Ahe=$.cameraViewMatrix,jhe=$.cameraWorldMatrix,Mhe=$.cbrt,Nhe=$.cdl,Phe=$.ceil,Fhe=$.checker,Ihe=$.cineonToneMapping,Lhe=$.clamp,Rhe=$.clearcoat,zhe=$.clearcoatRoughness,Bhe=$.code,Vhe=$.color,Hhe=$.colorSpaceToWorking,Uhe=$.colorToDirection,Whe=$.compute,Ghe=$.computeSkinning,Khe=$.cond,qhe=$.Const,Jhe=$.context,Yhe=$.convert,Xhe=$.convertColorSpace,Zhe=$.convertToTexture,Qhe=$.cos,$he=$.cross,ege=$.cubeTexture,tge=$.dFdx,nge=$.dFdy,rge=$.dashSize,ige=$.debug,age=$.decrement,oge=$.decrementBefore,sge=$.defaultBuildStages,cge=$.defaultShaderStages,lge=$.defined,uge=$.degrees,dge=$.deltaTime,fge=$.densityFog,pge=$.densityFogFactor,mge=$.depth,hge=$.depthPass,gge=$.difference,_ge=$.diffuseColor,vge=$.directPointLight,yge=$.directionToColor,bge=$.dispersion,xge=$.distance,Sge=$.div,Cge=$.dodge,wge=$.dot,Tge=$.drawIndex,Ege=$.dynamicBufferAttribute,Dge=$.element,Oge=$.emissive,kge=$.equal,Age=$.equals,jge=$.equirectUV,Mge=$.exp,Nge=$.exp2,Pge=$.expression,Fge=$.faceDirection,Ige=$.faceForward,Lge=$.faceforward,Rge=$.float,zge=$.floor,Bge=$.fog,Vge=$.fract,Hge=$.frameGroup,Uge=$.frameId,Wge=$.frontFacing,Gge=$.fwidth,Kge=$.gain,qge=$.gapSize,Jge=$.getConstNodeType,Yge=$.getCurrentStack,Xge=$.getDirection,Zge=$.getDistanceAttenuation,Qge=$.getGeometryRoughness,$ge=$.getNormalFromDepth,e_e=$.getParallaxCorrectNormal,t_e=$.getRoughness,n_e=$.getScreenPosition,r_e=$.getShIrradianceAt,i_e=$.getTextureIndex,a_e=$.getViewPosition,o_e=$.getShadowMaterial,s_e=$.getShadowRenderObjectFunction,c_e=$.glsl,l_e=$.glslFn,u_e=$.grayscale,d_e=$.greaterThan,f_e=$.greaterThanEqual,p_e=$.hash,m_e=$.highpModelNormalViewMatrix,h_e=$.highpModelViewMatrix,g_e=$.hue,__e=$.increment,v_e=$.incrementBefore,y_e=$.instance,b_e=$.instanceIndex,x_e=$.instancedArray,S_e=$.instancedBufferAttribute,C_e=$.instancedDynamicBufferAttribute,w_e=$.instancedMesh,T_e=$.int,E_e=$.inverseSqrt,D_e=$.inversesqrt,O_e=$.invocationLocalIndex,k_e=$.invocationSubgroupIndex,A_e=$.ior,j_e=$.iridescence,M_e=$.iridescenceIOR,N_e=$.iridescenceThickness,P_e=$.ivec2,F_e=$.ivec3,I_e=$.ivec4,L_e=$.js,R_e=$.label,z_e=$.length,B_e=$.lengthSq,V_e=$.lessThan,H_e=$.lessThanEqual,U_e=$.lightPosition,W_e=$.lightShadowMatrix,G_e=$.lightTargetDirection,K_e=$.lightTargetPosition,q_e=$.lightViewPosition,J_e=$.lightingContext,Y_e=$.lights,X_e=$.linearDepth,Z_e=$.linearToneMapping,Q_e=$.localId,$_e=$.globalId,eve=$.log,tve=$.log2,nve=$.logarithmicDepthToViewZ,rve=$.loop,ive=$.luminance,ave=$.mediumpModelViewMatrix,ove=$.mat2,sve=$.mat3,cve=$.mat4,lve=$.matcapUV,uve=$.materialAO,dve=$.materialAlphaTest,fve=$.materialAnisotropy,pve=$.materialAnisotropyVector,mve=$.materialAttenuationColor,hve=$.materialAttenuationDistance,gve=$.materialClearcoat,_ve=$.materialClearcoatNormal,vve=$.materialClearcoatRoughness,yve=$.materialColor,bve=$.materialDispersion,xve=$.materialEmissive,Sve=$.materialIOR,Cve=$.materialIridescence,wve=$.materialIridescenceIOR,Tve=$.materialIridescenceThickness,Eve=$.materialLightMap,Dve=$.materialLineDashOffset,Ove=$.materialLineDashSize,kve=$.materialLineGapSize,Ave=$.materialLineScale,jve=$.materialLineWidth,Mve=$.materialMetalness,Nve=$.materialNormal,Pve=$.materialOpacity,Fve=$.materialPointSize,Ive=$.materialReference,Lve=$.materialReflectivity,Rve=$.materialRefractionRatio,zve=$.materialRotation,Bve=$.materialRoughness,Vve=$.materialSheen,Hve=$.materialSheenRoughness,Uve=$.materialShininess,Wve=$.materialSpecular,Gve=$.materialSpecularColor,Kve=$.materialSpecularIntensity,qve=$.materialSpecularStrength,Jve=$.materialThickness,Yve=$.materialTransmission,Xve=$.max,Zve=$.maxMipLevel,Qve=$.metalness,$ve=$.min,eye=$.mix,tye=$.mixElement,nye=$.mod,rye=$.modInt,iye=$.modelDirection,aye=$.modelNormalMatrix,oye=$.modelPosition,sye=$.modelRadius,cye=$.modelScale,lye=$.modelViewMatrix,uye=$.modelViewPosition,dye=$.modelViewProjection,fye=$.modelWorldMatrix,pye=$.modelWorldMatrixInverse,mye=$.morphReference,hye=$.mrt,gye=$.mul,_ye=$.mx_aastep,vye=$.mx_cell_noise_float,yye=$.mx_contrast,bye=$.mx_fractal_noise_float,xye=$.mx_fractal_noise_vec2,Sye=$.mx_fractal_noise_vec3,Cye=$.mx_fractal_noise_vec4,wye=$.mx_hsvtorgb,Tye=$.mx_noise_float,Eye=$.mx_noise_vec3,Dye=$.mx_noise_vec4,Oye=$.mx_ramplr,kye=$.mx_ramptb,Aye=$.mx_rgbtohsv,jye=$.mx_safepower,Mye=$.mx_splitlr,Nye=$.mx_splittb,Pye=$.mx_srgb_texture_to_lin_rec709,Fye=$.mx_transform_uv,Iye=$.mx_worley_noise_float,Lye=$.mx_worley_noise_vec2,Rye=$.mx_worley_noise_vec3,zye=$.namespace,Bye=$.negate,Vye=$.neutralToneMapping,Hye=$.nodeArray,Uye=$.nodeImmutable,Wye=$.nodeObject,Gye=$.nodeObjects,Kye=$.nodeProxy,qye=$.normalFlat,Jye=$.normalGeometry,Yye=$.normalLocal,Xye=$.normalMap,Zye=$.normalView,Qye=$.normalWorld,$ye=$.normalize,ebe=$.not,tbe=$.notEqual,nbe=$.numWorkgroups,rbe=$.objectDirection,ibe=$.objectGroup,abe=$.objectPosition,obe=$.objectRadius,sbe=$.objectScale,cbe=$.objectViewPosition,lbe=$.objectWorldMatrix,ube=$.oneMinus,dbe=$.or,fbe=$.orthographicDepthToViewZ,pbe=$.oscSawtooth,mbe=$.oscSine,hbe=$.oscSquare,gbe=$.oscTriangle,_be=$.output,vbe=$.outputStruct,ybe=$.overlay,bbe=$.overloadingFn,xbe=$.parabola,Sbe=$.parallaxDirection,Cbe=$.parallaxUV,wbe=$.parameter,Tbe=$.pass,Ebe=$.passTexture,Dbe=$.pcurve,Obe=$.perspectiveDepthToViewZ,kbe=$.pmremTexture,Abe=$.pointUV,jbe=$.pointWidth,Mbe=$.positionGeometry,Nbe=$.positionLocal,Pbe=$.positionPrevious,Fbe=$.positionView,Ibe=$.positionViewDirection,Lbe=$.positionWorld,Rbe=$.positionWorldDirection,zbe=$.posterize,Bbe=$.pow,Vbe=$.pow2,Hbe=$.pow3,Ube=$.pow4,Wbe=$.premult,Gbe=$.property,Kbe=$.radians,qbe=$.rand,Jbe=$.range,Ybe=$.rangeFog,Xbe=$.rangeFogFactor,Zbe=$.reciprocal,Qbe=$.lightProjectionUV,$be=$.reference,exe=$.referenceBuffer,txe=$.reflect,nxe=$.reflectVector,rxe=$.reflectView,ixe=$.reflector,axe=$.refract,oxe=$.refractVector,sxe=$.refractView,cxe=$.reinhardToneMapping,lxe=$.remainder,uxe=$.remap,dxe=$.remapClamp,fxe=$.renderGroup,pxe=$.renderOutput,mxe=$.rendererReference,hxe=$.rotate,gxe=$.rotateUV,_xe=$.roughness,vxe=$.round,yxe=$.rtt,bxe=$.sRGBTransferEOTF,xxe=$.sRGBTransferOETF,Sxe=$.sampler,Cxe=$.samplerComparison,wxe=$.saturate,Txe=$.saturation,Exe=$.screen,Dxe=$.screenCoordinate,Oxe=$.screenSize,kxe=$.screenUV,Axe=$.scriptable,jxe=$.scriptableValue,Mxe=$.select,Nxe=$.setCurrentStack,Pxe=$.shaderStages,Fxe=$.shadow,Ixe=$.pointShadow,Lxe=$.shadowPositionWorld,Rxe=$.sharedUniformGroup,zxe=$.shapeCircle,Bxe=$.sheen,Vxe=$.sheenRoughness,Hxe=$.shiftLeft,Uxe=$.shiftRight,Wxe=$.shininess,Gxe=$.sign,Kxe=$.sin,qxe=$.sinc,Jxe=$.skinning,Yxe=$.smoothstep,Xxe=$.smoothstepElement,Zxe=$.specularColor,Qxe=$.specularF90,$xe=$.spherizeUV,eSe=$.split,tSe=$.spritesheetUV,nSe=$.sqrt,rSe=$.stack,iSe=$.step,aSe=$.storage,oSe=$.storageBarrier,sSe=$.storageObject,cSe=$.storageTexture,lSe=$.string,uSe=$.struct,dSe=$.sub,fSe=$.subgroupIndex,pSe=$.subgroupSize,mSe=$.tan,hSe=$.tangentGeometry,gSe=$.tangentLocal,_Se=$.tangentView,vSe=$.tangentWorld,ySe=$.temp,bSe=$.texture,xSe=$.texture3D,SSe=$.textureBarrier,CSe=$.textureBicubic,wSe=$.textureCubeUV,TSe=$.textureLoad,ESe=$.textureSize,DSe=$.textureStore,OSe=$.thickness,kSe=$.time,ASe=$.timerDelta,jSe=$.timerGlobal,MSe=$.timerLocal,NSe=$.toneMapping,PSe=$.toneMappingExposure,FSe=$.toonOutlinePass,ISe=$.transformDirection,LSe=$.transformNormal,RSe=$.transformNormalToView,zSe=$.transformedBentNormalView,BSe=$.transformedBitangentView,VSe=$.transformedBitangentWorld,HSe=$.transformedClearcoatNormalView,USe=$.transformedNormalView,WSe=$.transformedNormalWorld,GSe=$.transformedTangentView,KSe=$.transformedTangentWorld,qSe=$.transmission,JSe=$.transpose,YSe=$.triNoise3D,XSe=$.triplanarTexture,ZSe=$.triplanarTextures,QSe=$.trunc,$Se=$.tslFn,eCe=$.uint,tCe=$.uniform,nCe=$.uniformCubeTexture,rCe=$.uniformArray,iCe=$.uniformGroup,aCe=$.uniformTexture,oCe=$.uniforms,sCe=$.unpremult,cCe=$.userData,lCe=$.uv,uCe=$.uvec2,dCe=$.uvec3,fCe=$.uvec4,pCe=$.Var,mCe=$.varying,hCe=$.varyingProperty,gCe=$.vec2,_Ce=$.vec3,vCe=$.vec4,yCe=$.vectorComponents,bCe=$.velocity,xCe=$.vertexColor,SCe=$.vertexIndex,CCe=$.vibrance,wCe=$.viewZToLogarithmicDepth,TCe=$.viewZToOrthographicDepth,ECe=$.viewZToPerspectiveDepth,DCe=$.viewport,OCe=$.viewportBottomLeft,kCe=$.viewportCoordinate,ACe=$.viewportDepthTexture,jCe=$.viewportLinearDepth,MCe=$.viewportMipTexture,NCe=$.viewportResolution,PCe=$.viewportSafeUV,FCe=$.viewportSharedTexture,ICe=$.viewportSize,LCe=$.viewportTexture,RCe=$.viewportTopLeft,zCe=$.viewportUV,BCe=$.wgsl,VCe=$.wgslFn,HCe=$.workgroupArray,UCe=$.workgroupBarrier,WCe=$.workgroupId,GCe=$.workingToColorSpace,KCe=$.xor;var qCe=r({__name:`Shader`,props:{hideNotice:{type:Boolean,default:!1}},setup(e){let r=e,i=f(null),a=f(`ombre-root-`+Math.random().toString(36).substring(7)),o=f(tI());return d(`ombreParentId`,a.value),d(`ombreNodeRegister`,(e,t,n,r,i=null)=>{o.value.registerNode(e,t,n,r,i)}),d(`ombreUniformUpdate`,(e,t,n)=>{o.value.updateUniformValue(e,t,n)}),d(`ombreMetadataUpdate`,(e,t)=>{o.value.updateNodeMetadata(e,t)}),l(async()=>{i.value&&(o.value.registerNode(a.value,({childNode:e})=>e||vCe(0,0,0,0),null,null,{}),await o.value.initialize({canvas:i.value}),r.hideNotice||o.value.showLicenseWarning())}),c(()=>{o.value.cleanup()}),(e,r)=>(u(),t(`div`,null,[n(`canvas`,s({"data-renderer":`ombre`,ref_key:`canvasRef`,ref:i,style:{...e.$attrs.class?{}:{width:`1200px`,height:`800px`},...typeof e.$attrs.style==`object`?e.$attrs.style:{}}},e.$attrs),null,16),p(e.$slots,`default`)]))}}),JCe=qCe;export{OV as Circle,jV as DotGrid,PV as FilmGrain,RV as GlassTiles,Hq as Grayscale,Gq as HueShift,Jq as Invert,Zq as LinearGradient,eJ as MouseDistortion,aJ as Posterize,cJ as Saturation,JCe as Shader,dJ as SolidColor,mJ as Swirl,_J as Twirl,bJ as Vibrance};
|
|
455
|
+
`)},$9={dFdx:`dpdx`,dFdy:`- dpdy`,mod_float:`tsl_mod_float`,mod_vec2:`tsl_mod_vec2`,mod_vec3:`tsl_mod_vec3`,mod_vec4:`tsl_mod_vec4`,equals_bool:`tsl_equals_bool`,equals_bvec2:`tsl_equals_bvec2`,equals_bvec3:`tsl_equals_bvec3`,equals_bvec4:`tsl_equals_bvec4`,inversesqrt:`inverseSqrt`,bitcast:`bitcast<f32>`};typeof navigator<`u`&&/Windows/g.test(navigator.userAgent)&&(Q9.pow_float=new I7(`fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }`),Q9.pow_vec2=new I7(`fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }`,[Q9.pow_float]),Q9.pow_vec3=new I7(`fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }`,[Q9.pow_float]),Q9.pow_vec4=new I7(`fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }`,[Q9.pow_float]),$9.pow_float=`tsl_pow_float`,$9.pow_vec2=`tsl_pow_vec2`,$9.pow_vec3=`tsl_pow_vec3`,$9.pow_vec4=`tsl_pow_vec4`);let Mpe=``;(typeof navigator<`u`&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(Mpe+=`diagnostic( off, derivative_uniformity );
|
|
456
|
+
`);const Npe=$.BRDF_GGX,Ppe=$.BRDF_Lambert,Fpe=$.BasicShadowFilter,Ipe=$.Break,Lpe=$.Continue,Rpe=$.DFGApprox,zpe=$.D_GGX,Bpe=$.Discard,Vpe=$.EPSILON,Hpe=$.F_Schlick,Upe=$.Fn,Wpe=$.INFINITY,Gpe=$.If,Kpe=$.Switch,qpe=$.Loop,Jpe=$.NodeShaderStage,Ype=$.NodeType,Xpe=$.NodeUpdateType,Zpe=$.NodeAccess,Qpe=$.PCFShadowFilter,$pe=$.PCFSoftShadowFilter,eme=$.PI,tme=$.PI2,nme=$.Return,rme=$.Schlick_to_F0,ime=$.ScriptableNodeResources,ame=$.ShaderNode,ome=$.TBNViewMatrix,sme=$.VSMShadowFilter,cme=$.V_GGX_SmithCorrelated,lme=$.abs,ume=$.acesFilmicToneMapping,dme=$.acos,fme=$.add,pme=$.addNodeElement,mme=$.agxToneMapping,hme=$.all,gme=$.alphaT,_me=$.and,vme=$.anisotropy,yme=$.anisotropyB,bme=$.anisotropyT,xme=$.any,Sme=$.append,Cme=$.array,wme=$.arrayBuffer,Tme=$.asin,Eme=$.assign,Dme=$.atan,Ome=$.atan2,kme=$.atomicAdd,Ame=$.atomicAnd,jme=$.atomicFunc,Mme=$.atomicMax,Nme=$.atomicMin,Pme=$.atomicOr,Fme=$.atomicStore,Ime=$.atomicSub,Lme=$.atomicXor,Rme=$.atomicLoad,zme=$.attenuationColor,Bme=$.attenuationDistance,Vme=$.attribute,Hme=$.attributeArray,Ume=$.backgroundBlurriness,Wme=$.backgroundIntensity,Gme=$.backgroundRotation,Kme=$.batch,qme=$.billboarding,Jme=$.bitAnd,Yme=$.bitNot,Xme=$.bitOr,Zme=$.bitXor,Qme=$.bitangentGeometry,$me=$.bitangentLocal,ehe=$.bitangentView,the=$.bitangentWorld,nhe=$.bitcast,rhe=$.blendBurn,ihe=$.blendColor,ahe=$.blendDodge,ohe=$.blendOverlay,she=$.blendScreen,che=$.blur,lhe=$.bool,uhe=$.buffer,dhe=$.bufferAttribute,fhe=$.bumpMap,phe=$.burn,mhe=$.bvec2,hhe=$.bvec3,ghe=$.bvec4,_he=$.bypass,vhe=$.cache,yhe=$.call,bhe=$.cameraFar,xhe=$.cameraIndex,She=$.cameraNear,Che=$.cameraNormalMatrix,whe=$.cameraPosition,The=$.cameraProjectionMatrix,Ehe=$.cameraProjectionMatrixInverse,Dhe=$.cameraViewMatrix,Ohe=$.cameraWorldMatrix,khe=$.cbrt,Ahe=$.cdl,jhe=$.ceil,Mhe=$.checker,Nhe=$.cineonToneMapping,Phe=$.clamp,Fhe=$.clearcoat,Ihe=$.clearcoatRoughness,Lhe=$.code,Rhe=$.color,zhe=$.colorSpaceToWorking,Bhe=$.colorToDirection,Vhe=$.compute,Hhe=$.computeSkinning,Uhe=$.cond,Whe=$.Const,Ghe=$.context,Khe=$.convert,qhe=$.convertColorSpace,Jhe=$.convertToTexture,Yhe=$.cos,Xhe=$.cross,Zhe=$.cubeTexture,Qhe=$.dFdx,$he=$.dFdy,ege=$.dashSize,tge=$.debug,nge=$.decrement,rge=$.decrementBefore,ige=$.defaultBuildStages,age=$.defaultShaderStages,oge=$.defined,sge=$.degrees,cge=$.deltaTime,lge=$.densityFog,uge=$.densityFogFactor,dge=$.depth,fge=$.depthPass,pge=$.difference,mge=$.diffuseColor,hge=$.directPointLight,gge=$.directionToColor,_ge=$.dispersion,vge=$.distance,yge=$.div,bge=$.dodge,xge=$.dot,Sge=$.drawIndex,Cge=$.dynamicBufferAttribute,wge=$.element,Tge=$.emissive,Ege=$.equal,Dge=$.equals,Oge=$.equirectUV,kge=$.exp,Age=$.exp2,jge=$.expression,Mge=$.faceDirection,Nge=$.faceForward,Pge=$.faceforward,Fge=$.float,Ige=$.floor,Lge=$.fog,Rge=$.fract,zge=$.frameGroup,Bge=$.frameId,Vge=$.frontFacing,Hge=$.fwidth,Uge=$.gain,Wge=$.gapSize,Gge=$.getConstNodeType,Kge=$.getCurrentStack,qge=$.getDirection,Jge=$.getDistanceAttenuation,Yge=$.getGeometryRoughness,Xge=$.getNormalFromDepth,Zge=$.getParallaxCorrectNormal,Qge=$.getRoughness,$ge=$.getScreenPosition,e_e=$.getShIrradianceAt,t_e=$.getTextureIndex,n_e=$.getViewPosition,r_e=$.getShadowMaterial,i_e=$.getShadowRenderObjectFunction,a_e=$.glsl,o_e=$.glslFn,s_e=$.grayscale,c_e=$.greaterThan,l_e=$.greaterThanEqual,u_e=$.hash,d_e=$.highpModelNormalViewMatrix,f_e=$.highpModelViewMatrix,p_e=$.hue,m_e=$.increment,h_e=$.incrementBefore,g_e=$.instance,__e=$.instanceIndex,v_e=$.instancedArray,y_e=$.instancedBufferAttribute,b_e=$.instancedDynamicBufferAttribute,x_e=$.instancedMesh,S_e=$.int,C_e=$.inverseSqrt,w_e=$.inversesqrt,T_e=$.invocationLocalIndex,E_e=$.invocationSubgroupIndex,D_e=$.ior,O_e=$.iridescence,k_e=$.iridescenceIOR,A_e=$.iridescenceThickness,j_e=$.ivec2,M_e=$.ivec3,N_e=$.ivec4,P_e=$.js,F_e=$.label,I_e=$.length,L_e=$.lengthSq,R_e=$.lessThan,z_e=$.lessThanEqual,B_e=$.lightPosition,V_e=$.lightShadowMatrix,H_e=$.lightTargetDirection,U_e=$.lightTargetPosition,W_e=$.lightViewPosition,G_e=$.lightingContext,K_e=$.lights,q_e=$.linearDepth,J_e=$.linearToneMapping,Y_e=$.localId,X_e=$.globalId,Z_e=$.log,Q_e=$.log2,$_e=$.logarithmicDepthToViewZ,eve=$.loop,tve=$.luminance,nve=$.mediumpModelViewMatrix,rve=$.mat2,ive=$.mat3,ave=$.mat4,ove=$.matcapUV,sve=$.materialAO,cve=$.materialAlphaTest,lve=$.materialAnisotropy,uve=$.materialAnisotropyVector,dve=$.materialAttenuationColor,fve=$.materialAttenuationDistance,pve=$.materialClearcoat,mve=$.materialClearcoatNormal,hve=$.materialClearcoatRoughness,gve=$.materialColor,_ve=$.materialDispersion,vve=$.materialEmissive,yve=$.materialIOR,bve=$.materialIridescence,xve=$.materialIridescenceIOR,Sve=$.materialIridescenceThickness,Cve=$.materialLightMap,wve=$.materialLineDashOffset,Tve=$.materialLineDashSize,Eve=$.materialLineGapSize,Dve=$.materialLineScale,Ove=$.materialLineWidth,kve=$.materialMetalness,Ave=$.materialNormal,jve=$.materialOpacity,Mve=$.materialPointSize,Nve=$.materialReference,Pve=$.materialReflectivity,Fve=$.materialRefractionRatio,Ive=$.materialRotation,Lve=$.materialRoughness,Rve=$.materialSheen,zve=$.materialSheenRoughness,Bve=$.materialShininess,Vve=$.materialSpecular,Hve=$.materialSpecularColor,Uve=$.materialSpecularIntensity,Wve=$.materialSpecularStrength,Gve=$.materialThickness,Kve=$.materialTransmission,qve=$.max,Jve=$.maxMipLevel,Yve=$.metalness,Xve=$.min,Zve=$.mix,Qve=$.mixElement,$ve=$.mod,eye=$.modInt,tye=$.modelDirection,nye=$.modelNormalMatrix,rye=$.modelPosition,iye=$.modelRadius,aye=$.modelScale,oye=$.modelViewMatrix,sye=$.modelViewPosition,cye=$.modelViewProjection,lye=$.modelWorldMatrix,uye=$.modelWorldMatrixInverse,dye=$.morphReference,fye=$.mrt,pye=$.mul,mye=$.mx_aastep,hye=$.mx_cell_noise_float,gye=$.mx_contrast,_ye=$.mx_fractal_noise_float,vye=$.mx_fractal_noise_vec2,yye=$.mx_fractal_noise_vec3,bye=$.mx_fractal_noise_vec4,xye=$.mx_hsvtorgb,Sye=$.mx_noise_float,Cye=$.mx_noise_vec3,wye=$.mx_noise_vec4,Tye=$.mx_ramplr,Eye=$.mx_ramptb,Dye=$.mx_rgbtohsv,Oye=$.mx_safepower,kye=$.mx_splitlr,Aye=$.mx_splittb,jye=$.mx_srgb_texture_to_lin_rec709,Mye=$.mx_transform_uv,Nye=$.mx_worley_noise_float,Pye=$.mx_worley_noise_vec2,Fye=$.mx_worley_noise_vec3,Iye=$.namespace,Lye=$.negate,Rye=$.neutralToneMapping,zye=$.nodeArray,Bye=$.nodeImmutable,Vye=$.nodeObject,Hye=$.nodeObjects,Uye=$.nodeProxy,Wye=$.normalFlat,Gye=$.normalGeometry,Kye=$.normalLocal,qye=$.normalMap,Jye=$.normalView,Yye=$.normalWorld,Xye=$.normalize,Zye=$.not,Qye=$.notEqual,$ye=$.numWorkgroups,ebe=$.objectDirection,tbe=$.objectGroup,nbe=$.objectPosition,rbe=$.objectRadius,ibe=$.objectScale,abe=$.objectViewPosition,obe=$.objectWorldMatrix,sbe=$.oneMinus,cbe=$.or,lbe=$.orthographicDepthToViewZ,ube=$.oscSawtooth,dbe=$.oscSine,fbe=$.oscSquare,pbe=$.oscTriangle,mbe=$.output,hbe=$.outputStruct,gbe=$.overlay,_be=$.overloadingFn,vbe=$.parabola,ybe=$.parallaxDirection,bbe=$.parallaxUV,xbe=$.parameter,Sbe=$.pass,Cbe=$.passTexture,wbe=$.pcurve,Tbe=$.perspectiveDepthToViewZ,Ebe=$.pmremTexture,Dbe=$.pointUV,Obe=$.pointWidth,kbe=$.positionGeometry,Abe=$.positionLocal,jbe=$.positionPrevious,Mbe=$.positionView,Nbe=$.positionViewDirection,Pbe=$.positionWorld,Fbe=$.positionWorldDirection,Ibe=$.posterize,Lbe=$.pow,Rbe=$.pow2,zbe=$.pow3,Bbe=$.pow4,Vbe=$.premult,Hbe=$.property,Ube=$.radians,Wbe=$.rand,Gbe=$.range,Kbe=$.rangeFog,qbe=$.rangeFogFactor,Jbe=$.reciprocal,Ybe=$.lightProjectionUV,Xbe=$.reference,Zbe=$.referenceBuffer,Qbe=$.reflect,$be=$.reflectVector,exe=$.reflectView,txe=$.reflector,nxe=$.refract,rxe=$.refractVector,ixe=$.refractView,axe=$.reinhardToneMapping,oxe=$.remainder,sxe=$.remap,cxe=$.remapClamp,lxe=$.renderGroup,uxe=$.renderOutput,dxe=$.rendererReference,fxe=$.rotate,pxe=$.rotateUV,mxe=$.roughness,hxe=$.round,gxe=$.rtt,_xe=$.sRGBTransferEOTF,vxe=$.sRGBTransferOETF,yxe=$.sampler,bxe=$.samplerComparison,xxe=$.saturate,Sxe=$.saturation,Cxe=$.screen,wxe=$.screenCoordinate,Txe=$.screenSize,Exe=$.screenUV,Dxe=$.scriptable,Oxe=$.scriptableValue,kxe=$.select,Axe=$.setCurrentStack,jxe=$.shaderStages,Mxe=$.shadow,Nxe=$.pointShadow,Pxe=$.shadowPositionWorld,Fxe=$.sharedUniformGroup,Ixe=$.shapeCircle,Lxe=$.sheen,Rxe=$.sheenRoughness,zxe=$.shiftLeft,Bxe=$.shiftRight,Vxe=$.shininess,Hxe=$.sign,Uxe=$.sin,Wxe=$.sinc,Gxe=$.skinning,Kxe=$.smoothstep,qxe=$.smoothstepElement,Jxe=$.specularColor,Yxe=$.specularF90,Xxe=$.spherizeUV,Zxe=$.split,Qxe=$.spritesheetUV,$xe=$.sqrt,eSe=$.stack,tSe=$.step,nSe=$.storage,rSe=$.storageBarrier,iSe=$.storageObject,aSe=$.storageTexture,oSe=$.string,sSe=$.struct,cSe=$.sub,lSe=$.subgroupIndex,uSe=$.subgroupSize,dSe=$.tan,fSe=$.tangentGeometry,pSe=$.tangentLocal,mSe=$.tangentView,hSe=$.tangentWorld,gSe=$.temp,_Se=$.texture,vSe=$.texture3D,ySe=$.textureBarrier,bSe=$.textureBicubic,xSe=$.textureCubeUV,SSe=$.textureLoad,CSe=$.textureSize,wSe=$.textureStore,TSe=$.thickness,ESe=$.time,DSe=$.timerDelta,OSe=$.timerGlobal,kSe=$.timerLocal,ASe=$.toneMapping,jSe=$.toneMappingExposure,MSe=$.toonOutlinePass,NSe=$.transformDirection,PSe=$.transformNormal,FSe=$.transformNormalToView,ISe=$.transformedBentNormalView,LSe=$.transformedBitangentView,RSe=$.transformedBitangentWorld,zSe=$.transformedClearcoatNormalView,BSe=$.transformedNormalView,VSe=$.transformedNormalWorld,HSe=$.transformedTangentView,USe=$.transformedTangentWorld,WSe=$.transmission,GSe=$.transpose,KSe=$.triNoise3D,qSe=$.triplanarTexture,JSe=$.triplanarTextures,YSe=$.trunc,XSe=$.tslFn,ZSe=$.uint,QSe=$.uniform,$Se=$.uniformCubeTexture,eCe=$.uniformArray,tCe=$.uniformGroup,nCe=$.uniformTexture,rCe=$.uniforms,iCe=$.unpremult,aCe=$.userData,oCe=$.uv,sCe=$.uvec2,cCe=$.uvec3,lCe=$.uvec4,uCe=$.Var,dCe=$.varying,fCe=$.varyingProperty,pCe=$.vec2,mCe=$.vec3,hCe=$.vec4,gCe=$.vectorComponents,_Ce=$.velocity,vCe=$.vertexColor,yCe=$.vertexIndex,bCe=$.vibrance,xCe=$.viewZToLogarithmicDepth,SCe=$.viewZToOrthographicDepth,CCe=$.viewZToPerspectiveDepth,wCe=$.viewport,TCe=$.viewportBottomLeft,ECe=$.viewportCoordinate,DCe=$.viewportDepthTexture,OCe=$.viewportLinearDepth,kCe=$.viewportMipTexture,ACe=$.viewportResolution,jCe=$.viewportSafeUV,MCe=$.viewportSharedTexture,NCe=$.viewportSize,PCe=$.viewportTexture,FCe=$.viewportTopLeft,ICe=$.viewportUV,LCe=$.wgsl,RCe=$.wgslFn,zCe=$.workgroupArray,BCe=$.workgroupBarrier,VCe=$.workgroupId,HCe=$.workingToColorSpace,UCe=$.xor;var WCe=r({__name:`Shader`,props:{hideNotice:{type:Boolean,default:!1}},setup(e){let r=e,i=f(null),a=f(`ombre-root-`+Math.random().toString(36).substring(7)),o=f(rI());return d(`ombreParentId`,a.value),d(`ombreNodeRegister`,(e,t,n,r,i=null)=>{o.value.registerNode(e,t,n,r,i)}),d(`ombreUniformUpdate`,(e,t,n)=>{o.value.updateUniformValue(e,t,n)}),d(`ombreMetadataUpdate`,(e,t)=>{o.value.updateNodeMetadata(e,t)}),l(async()=>{i.value&&(o.value.registerNode(a.value,({childNode:e})=>e||hCe(0,0,0,0),null,null,{}),await o.value.initialize({canvas:i.value}),r.hideNotice||o.value.showLicenseWarning())}),c(()=>{o.value.cleanup()}),(e,r)=>(u(),t(`div`,null,[n(`canvas`,s({"data-renderer":`ombre`,ref_key:`canvasRef`,ref:i,style:{...e.$attrs.class?{}:{width:`1200px`,height:`800px`},...typeof e.$attrs.style==`object`?e.$attrs.style:{}}},e.$attrs),null,16),p(e.$slots,`default`)]))}}),GCe=WCe;export{AV as Circle,NV as DotGrid,IV as FilmGrain,BV as GlassTiles,Wq as Grayscale,qq as HueShift,Xq as Invert,$q as LinearGradient,iJ as Posterize,sJ as Saturation,GCe as Shader,uJ as SolidColor,pJ as Swirl,gJ as Twirl,yJ as Vibrance};
|