PageSourceSearch

https://cosmos.network/_next/static/chunks/b055d1fb.bab269bac246992f.js

js cosmos.network collected 2026-09-24 08:40:23 UTC 551,050 bytes, 305 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f94a46c7-889a-41e1-bc26-67c4ffd39262",e._sentryDebugIdIdentifier="sentry-dbid-f94a46c7-889a-41e1-bc26-67c4ffd39262")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[950],{82752:(e,t,r)=>{let i,s,n,a,o,l;r.d(t,{Z$U:()=>hM,uV1:()=>yU,uuE:()=>gD});var u=r(85339);let d=["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"],h=new WeakMap;class c{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=d,this.renderId=0}firstInitialization(e){return!1===this.renderObjects.has(e)&&(this.getRenderObjectData(e),!0)}needsVelocity(e){let t=e.getMRT();return null!==t&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(void 0===t){let{geometry:r,material:i,object:s}=e;if(t={material:this.getMaterialData(i),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:s.matrixWorld.clone()},s.center&&(t.center=s.center.clone()),s.morphTargetInfluences&&(t.morphTargetInfluences=s.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),t.material.transmission>0){let{width:r,height:i}=e.context;t.bufferWidth=r,t.bufferHeight=i}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){let t={};for(let r in e){let i=e[r];t[r]={version:i.version}}return t}containsNode(e){let t=e.material;for(let e in t)if(t[e]&&t[e].isNode)return!0;return null!==e.renderer.overrideNodes.modelViewMatrix||null!==e.renderer.overrideNodes.modelNormalViewMatrix}getMaterialData(e){let t={};for(let r of this.refreshUniforms){let i=e[r];null!=i&&("object"==typeof i&&void 0!==i.clone?!0===i.isTexture?t[r]={id:i.id,version:i.version}:t[r]=i.clone():t[r]=i)}return t}equals(e,t){let{object:r,material:i,geometry:s}=e,n=this.getRenderObjectData(e);if(!0!==n.worldMatrix.equals(r.matrixWorld))return n.worldMatrix.copy(r.matrixWorld),!1;let a=n.material;for(let e in a){let t=a[e],r=i[e];if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),!1}else if(!0===r.isTexture){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:r}=e.context;if(n.bufferWidth!==t||n.bufferHeight!==r)return n.bufferWidth=t,n.bufferHeight=r,!1}let o=n.geometry,l=s.attributes,u=o.attributes,d=Object.keys(u),h=Object.keys(l);if(o.id!==s.id)return o.id=s.id,!1;if(d.length!==h.length)return n.geometry.attributes=this.getAttributesData(l),!1;for(let e of d){let t=u[e],r=l[e];if(void 0===r)return delete u[e],!1;if(t.version!==r.version)return t.version=r.version,!1}let c=s.index,p=o.indexVersion,g=c?c.version:null;if(p!==g)return o.indexVersion=g,!1;if(o.drawRange.start!==s.drawRange.start||o.drawRange.count!==s.drawRange.count)return o.drawRange.start=s.drawRange.start,o.drawRange.count=s.drawRange.count,!1;if(n.morphTargetInfluences){let e=!1;for(let t=0;t<n.morphTargetInfluences.length;t++)n.morphTargetInfluences[t]!==r.morphTargetInfluences[t]&&(e=!0);if(e)return!0}if(n.lights){for(let e=0;e<t.length;e++)if(n.lights[e].map!==t[e].map)return!1}return n.center&&!1===n.center.equals(r.center)?n.center.copy(r.center):null!==e.bundle&&(n.version=e.bundle.version),!0}getLightsData(e){let t=[];
1for(let r of e)!0===r.isSpotLight&&null!==r.map&&t.push({map:r.map.version});return t}getLights(e,t){if(h.has(e)){let r=h.get(e);if(r.renderId===t)return r.lightsData}let r=this.getLightsData(e.getLights());return h.set(e,{renderId:t,lightsData:r}),r}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;let{renderId:r}=t;if(this.renderId!==r)return this.renderId=r,!0;let i=!0===e.object.static,s=null!==e.bundle&&!0===e.bundle.static&&this.getRenderObjectData(e).version===e.bundle.version;if(i||s)return!1;let n=this.getLights(e.lightsNode,r);return!0!==this.equals(e,n)}}function p(e,t=0){let r=0xdeadbeef^t,i=0x41c6ce57^t;if(e instanceof Array)for(let t=0,s;t<e.length;t++)r=Math.imul(r^(s=e[t]),0x9e3779b1),i=Math.imul(i^s,0x5f356495);else for(let t=0,s;t<e.length;t++)r=Math.imul(r^(s=e.charCodeAt(t)),0x9e3779b1),i=Math.imul(i^s,0x5f356495);return r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(i^i>>>13,0xc2b2ae35),0x100000000*(2097151&(i=Math.imul(i^i>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35)))+(r>>>0)}let g=e=>p(e),m=e=>p(e),f=(...e)=>p(e);function y(e,t=!1){let r=[];for(let{property:i,childNode:s}of(!0===e.isNode&&r.push(e.id),b(e)))r.push(p(i.slice(0,-4)),s.getCacheKey(t));return p(r)}function*b(e,t=!1){for(let r of Object.getOwnPropertyNames(e)){if(!0===r.startsWith("_"))continue;let i=e[r];if(!0===Array.isArray(i))for(let e=0;e<i.length;e++){let s=i[e];s&&(!0===s.isNode||t&&"function"==typeof s.toJSON)&&(yield{property:r,index:e,childNode:s})}else if(i&&!0===i.isNode)yield{property:r,childNode:i};else if(i&&Object.getPrototypeOf(i)===Object.prototype)for(let e in i){if(!0===e.startsWith("_"))continue;let s=i[e];s&&(!0===s.isNode||t&&"function"==typeof s.toJSON)&&(yield{property:r,index:e,childNode:s})}}}let x=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),T=new WeakMap;function _(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 v(e){return/float|int|uint/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)?3:/vec4/.test(e)||/mat2/.test(e)?4:/mat3/.test(e)?9:/mat4/.test(e)?16:void console.error("THREE.TSL: Unsupported type:",e)}function N(e){if(null==e)return null;let t=typeof e;if(!0===e.isNode)return"node";if("number"===t)return"float";if("boolean"===t)return"bool";if("string"===t)return"string";if("function"===t)return"shader";else if(!0===e.isVector2)return"vec2";else if(!0===e.isVector3)return"vec3";else if(!0===e.isVector4)return"vec4";else if(!0===e.isMatrix2)return"mat2";else if(!0===e.isMatrix3)return"mat3";else if(!0===e.isMatrix4)return"mat4";else if(!0===e.isColor)return"color";else if(e instanceof ArrayBuffer)return"ArrayBuffer";return null}function S(e,...t){let r=e?e.slice(-4):void 0;if(1===t.length&&("vec2"===r?t=[t[0],t[0]]:"vec3"===r?t=[t[0],t[0],t[0]]:"vec4"===r&&(t=[t[0],t[0],t[0],t[0]])),"color"===e)return new u.Q1f(...t);if("vec2"===r)return new u.I9Y(...t);if("vec3"===r)return new u.Pq0(...t);if("vec4"===r)return new u.IUQ(...t);if("mat2"===r)return new u.k_V(...t);else if("mat3"===r)return new u.dwI(...t);else if("mat4"===r)return new u.kn4(...t);else if("bool"===e)return t[0]||!1;else if("float"===e||"int"===e||"uint"===e)return t[0]||0;else if("string"===e)return t[0]||"";else if("ArrayBuffer"===e)return E(t[0]);return null}function R(e){let t=T.get(e);return void 0===t&&(t={},T.set(e,t)),t}function A(e){let t="",r=new Uint8Array(e);for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return btoa(t)}function E(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}let C={VERTEX:"vertex",FRAGMENT:"fragment"},w={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},M={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},B=["fragment","vertex"],L=["setup","analyze","generate"],P=[...B,"compute"],F=["x","y","z","w"],U={analyze:"setup",generate:"analyze"},I=0;class D extends u.Qev{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=w.NONE,this.updateBeforeType=w.NONE,this.updateAfterType=w.NONE,this.uuid=u.cj9.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:I++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,w.FRAME)}
1onRenderUpdate(e){return this.onUpdate(e,w.RENDER)}onObjectUpdate(e){return this.onUpdate(e,w.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of b(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){for(let t of(e(this),this.getChildren()))t.traverse(e)}getCacheKey(e=!1){return(!0===(e=e||this.version!==this._cacheKeyVersion)||null===this._cacheKey)&&(this._cacheKey=f(y(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);return e.getElementType(t)}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);return e.getNodeFromHash(t)||this}getArrayCount(){return null}setup(e){let t=e.getNodeProperties(this),r=0;for(let e of this.getChildren())t["node"+r++]=e;return t.outputNode||null}analyze(e,t=null){let r=e.increaseUsage(this);if(!0===this.parents){let r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(1===r)for(let t of Object.values(e.getNodeProperties(this)))t&&!0===t.isNode&&t.build(e,this)}generate(e,t){let{outputNode:r}=e.getNodeProperties(this);if(r&&!0===r.isNode)return r.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){let r=this.getShared(e);if(this!==r)return r.build(e,t);let i=e.getDataFromNode(this);i.buildStages=i.buildStages||{},i.buildStages[e.buildStage]=!0;let s=U[e.buildStage];if(s&&!0!==i.buildStages[s]){let t=e.getBuildStage();e.setBuildStage(s),this.build(e),e.setBuildStage(t)}e.addNode(this),e.addChain(this);let n=null,a=e.getBuildStage();if("setup"===a){this.updateReference(e);let t=e.getNodeProperties(this);if(!0!==t.initialized){for(let r of(t.initialized=!0,t.outputNode=this.setup(e)||t.outputNode||null,Object.values(t)))if(r&&!0===r.isNode){if(!0===r.parents){let t=e.getNodeProperties(r);t.parents=t.parents||[],t.parents.push(this)}r.build(e)}}n=t.outputNode}else if("analyze"===a)this.analyze(e,t);else if("generate"===a){if(1===this.generate.length){let r=this.getNodeType(e),i=e.getDataFromNode(this);void 0===(n=i.snippet)?void 0===i.generated?(i.generated=!0,i.snippet=n=this.generate(e)||""):(console.warn("THREE.Node: Recursion detected.",this),n="/* Recursion detected. */"):void 0!==i.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),n=e.format(n,r,t)}else n=this.generate(e,t)||"";""===n&&null!==t&&"void"!==t&&"OutputType"!==t&&(console.error(`THREE.TSL: Invalid generated code, expected a "${t}".`),n=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return b(this)}serialize(e){let t=this.getSerializeChildren(),r={};for(let{property:i,index:s,childNode:n}of t)void 0!==s?(void 0===r[i]&&(r[i]=Number.isInteger(s)?[]:{}),r[i][s]=n.toJSON(e.meta).uuid):r[i]=n.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(void 0!==e.inputNodes){let t=e.meta.nodes;for(let r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){let i=[];for(let s of e.inputNodes[r])i.push(t[s]);this[r]=i}else if("object"==typeof e.inputNodes[r]){let i={};for(let s in e.inputNodes[r]){let n=e.inputNodes[r][s];i[s]=t[n]}this[r]=i}else{let i=e.inputNodes[r];this[r]=t[i]}}}toJSON(e){let{uuid:t,type:r}=this,i=void 0===e||"string"==typeof e;i&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];function n(e){let t=[];for(let r in e){let i=e[r];delete i.metadata,t.push(i)}return t}if(void 0===s&&(s={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},!0!==i&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta),i){let t=n(e.textures),r=n(e.images),i=n(e.nodes);t.length>0&&(s.textures=t),r.length>0&&(s.images=r),i.length>0&&(s.nodes=i)}return s}}class O extends D{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),r=this.node.build(e),i=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${r}[ ${i} ]`}}class V extends D{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){let t=this.node.getNodeType(e),r=null;for(let i of this.convertTo.split("|"))(null===r||e.getTypeLength(t)===e.getTypeLength(i))&&(r=i);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let r=this.node,i=this.getNodeType(e),s=r.build(e,i);return e.format(s,i,t)}}class G extends D{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){let r=e.getVectorType(this.getNodeType(e,t)),i=e.getDataFromNode(this);if(void 0!==i.propertyName)return e.format(i.propertyName,r,t);if("void"!==r&&"void"!==t&&this.hasDependencies(e)){let s=super.build(e,r),n=e.getVarFromNode(this,null,r),a=e.getPropertyName(n);return e.addLineFlowCode(`${a} = ${s}`,this),i.snippet=s,i.propertyName=a,e.format(i.propertyName,r,t)}}return super.build(e,t)}}class k extends G{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}
1getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,r)=>t+e.getTypeLength(r.getNodeType(e)),0))}generate(e,t){let r=this.getNodeType(e),i=e.getTypeLength(r),s=this.nodes,n=e.getComponentType(r),a=[],o=0;for(let t of s){let s;if(o>=i){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let l=t.getNodeType(e),u=e.getTypeLength(l);if(o+u>i&&(console.error(`THREE.TSL: Length of '${r}()' data exceeds maximum length of output type.`),u=i-o,l=e.getTypeFromLength(u)),o+=u,s=t.build(e,l),e.getComponentType(l)!==n){let t=e.getTypeFromLength(u,n);s=e.format(s,l,t)}a.push(s)}let l=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(l,r,t)}}let z=F.join("");class $ extends D{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(F.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))}getScope(){return this.node.getScope()}generate(e,t){let r=this.node,i=e.getTypeLength(r.getNodeType(e)),s=null;if(i>1){let n=null;this.getVectorLength()>=i&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let a=r.build(e,n);s=this.components.length===i&&this.components===z.slice(0,this.components.length)?e.format(a,n,t):e.format(`${a}.${this.components}`,this.getNodeType(e),t)}else s=r.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class H extends G{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:r,targetNode:i}=this,s=this.getNodeType(e),n=e.getComponentType(i.getNodeType(e)),a=e.getTypeFromLength(r.length,n),o=i.build(e,a),l=t.build(e,s),u=e.getTypeLength(s),d=[];for(let e=0;e<u;e++){let t=F[e];t===r[0]?(d.push(o),e+=r.length-1):d.push(l+"."+t)}return`${e.getType(s)}( ${d.join(", ")} )`}}class W extends G{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:r}=this,i=this.getNodeType(e),s=r.build(e),n=e.getVarFromNode(this),a=e.getPropertyName(n);e.addLineFlowCode(a+" = "+s,this);let o=e.getTypeLength(i),l=[],u=0;for(let e=0;e<o;e++){let r=F[e];r===t[u]?(l.push("1.0 - "+a+"."+r),u++):l.push(a+"."+r)}return`${e.getType(i)}( ${l.join(", ")} )`}}class q extends D{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return null===this.nodeType?N(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=N(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=A(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?S(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.")}}let j=/float|u?int/;class X extends q{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 r=this.getNodeType(e);return j.test(r)&&j.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class K extends D{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return(!this.structNode.isMemberNode||!1!==this.structNode.hasMember(e))&&"void"!==this.structNode.getMemberType(e,this.property)}getNodeType(e){return!1===this.hasMember(e)?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(!1===this.hasMember(e))return"float";let r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}generate(e){if(!1===this.hasMember(e)){console.warn(`THREE.TSL: Member "${this.property}" does not exist in struct.`);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+"."+this.property}}let Q=null,Y=new Map;function Z(e,t){if(Y.has(e))return void console.warn(`THREE.TSL: Redefinition of method chaining '${e}'.`);if("function"!=typeof t)throw Error(`THREE.TSL: Node element ${e} is not a function`);Y.set(e,t),"assign"!==e&&(D.prototype[e]=function(...e){return this.isStackNode?this.add(t(...e)):t(this,...e)},D.prototype[e+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}let J=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w").split("").sort().join("");D.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==Q?Q.assign(this,...e):console.error("THREE.TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{let t=Y.get("assign");return this.add(t(...e))}},D.prototype.toVarIntent=function(){return this},D.prototype.get=function(e){return new K(this,e)};let ee={};function et(e,t,r){ee[e]=ee[t]=ee[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new $(this,e),this._cache[e]=t),t},set(t){this[e].assign(eR(t))}};let i=e.toUpperCase(),s=t.toUpperCase(),n=r.toUpperCase();D.prototype["set"+i]=D.prototype["set"+s]=D.prototype["set"+n]=function(t){return new H(this,J(e),eR(t))},D.prototype["flip"+i]=D.prototype["flip"+s]=D.prototype["flip"+n]=function(){return new W(this,J(e))}}let er=["x","y","z","w"],ei=["r","g","b","a"],es=["s","t","p","q"];for(let e=0;e<4;e++){let t=er[e],r=ei[e],i=es[e];et(t,r,i);for(let s=0;s<4;s++){t=er[e]+er[s],et(t,r=ei[e]+ei[s],i=es[e]+es[s]);for(let n=0;n<4;n++){t=er[e]+er[s]+er[n],et(t,r=ei[e]+ei[s]+ei[n],i=es[e]+es[s]+es[n]);for(let a=0;a<4;a++)t=er[e]+er[s]+er[n]+er[a],et(t,r=ei[e]+ei[s]+ei[n]+ei[a],i=es[e]+es[s]+es[n]+es[a])}}}for(let e=0;e<32;e++)ee[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new O(this,new X(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(eR(t))}};Object.defineProperties(D.prototype,ee);let en=new WeakMap,ea=function(e,t=null){let r=N(e);if("node"===r);else if(null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r)return eR(eT(e,t));else if("shader"===r)return e.isFn?e:eF(e);return e},eo=function(e,t=null){for(let r in e)e[r]=eR(e[r],t);return e},el=function(e,t=null){let r=e.length;for(let i=0;i<r;i++)e[i]=eR(e[i],t);return e},eu=function(e,t=null,r=null,i=null){function s(e){return null!==i?(e=eR(Object.assign(e,i)),!0===i.intent&&(e=e.toVarIntent
1())):e=eR(e),e}let n,a=t,o,l;function u(t){let r;return(r=a?/[a-z]/i.test(a)?a+"()":a:e.type,void 0!==o&&t.length<o)?(console.error(`THREE.TSL: "${r}" parameter length is less than minimum required.`),t.concat(Array(o-t.length).fill(0))):void 0!==l&&t.length>l?(console.error(`THREE.TSL: "${r}" parameter length exceeds limit.`),t.slice(0,l)):t}return null===t?n=(...t)=>s(new e(...eC(u(t)))):null!==r?(r=eR(r),n=(...i)=>s(new e(t,...eC(u(i)),r))):n=(...r)=>s(new e(t,...eC(u(r)))),n.setParameterLength=(...e)=>(1===e.length?o=l=e[0]:2===e.length&&([o,l]=e),n),n.setName=e=>(a=e,n),n},ed=function(e,...t){return eR(new e(...eC(t)))};class eh extends D{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=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){var t,r;let{shaderNode:i,rawInputs:s}=this,n=e.getNodeProperties(i),a=e.getClosestSubBuild(i.subBuilds)||"",o=a||"default";if(n[o])return n[o];let l=e.subBuildFn;e.subBuildFn=a;let u=null;if(i.layout){let r=en.get(e.constructor);void 0===r&&(r=new WeakMap,en.set(e.constructor,r));let n=r.get(i);void 0===n&&(n=eR(e.buildFunctionNode(i)),r.set(i,n)),e.addInclude(n);let a=s?(eE(t=s),t[0]&&(t[0].isNode||Object.getPrototypeOf(t[0])!==Object.prototype)?[...t]:t[0]):null;u=eR(n.call(a))}else{let t,n=new Proxy(e,{get:(e,t,r)=>Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r)}),a=s?(t=0,eE(r=s),new Proxy(r,{get:(e,i,s)=>{let n;if("length"===i)return r.length;if(Symbol.iterator===i)n=function*(){for(let e of r)yield eR(e)};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){let e=r[0];n=void 0===e[i]?e[t++]:Reflect.get(e,i,s)}else r[0]instanceof D&&(n=void 0===r[i]?r[t++]:Reflect.get(r,i,s));else n=Reflect.get(e,i,s);n=eR(n)}return n}})):null,o=Array.isArray(s)?s.length>0:null!==s,l=i.jsFunc;u=eR(o||l.length>1?l(a,n):l(n))}return e.subBuildFn=l,i.once&&(n[o]=u),u}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){let t=e.getNodeProperties(this),r=e.getSubBuildOutput(this);return t[r]=t[r]||this.setupOutput(e),t[r].subBuild=e.getClosestSubBuild(this),t[r]}build(e,t=null){let r=null,i=e.getBuildStage(),s=e.getNodeProperties(this),n=e.getSubBuildOutput(this),a=this.getOutputNode(e);if("setup"===i){let t=e.getSubBuildProperty("initialized",this);if(!0!==s[t]&&(s[t]=!0,s[n]=this.getOutputNode(e),s[n].build(e),this.shaderNode.subBuilds))for(let t of e.chaining){let r=e.getDataFromNode(t,"any");for(let e of(r.subBuilds=r.subBuilds||new Set,this.shaderNode.subBuilds))r.subBuilds.add(e)}r=s[n]}else"analyze"===i?a.build(e,t):"generate"===i&&(r=a.build(e,t)||"");return r}}class ec extends D{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return eR(new eh(this,e))}setup(){return this.call()}}let ep=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],eg=new Map;for(let e of[!1,!0])eg.set(e,new X(e));let em=new Map;for(let e of[0,1,2,3])em.set(e,new X(e,"uint"));let ef=new Map([...em].map(e=>new X(e.value,"int")));for(let e of[-1,-2])ef.set(e,new X(e,"int"));let ey=new Map([...ef].map(e=>new X(e.value)));for(let e of ep)ey.set(e,new X(e));for(let e of ep)ey.set(-e,new X(-e));let eb={bool:eg,uint:em,ints:ef,float:ey},ex=new Map([...eg,...ey]),eT=(e,t)=>ex.has(e)?ex.get(e):!0===e.isNode?e:new X(e,t),e_=function(e,t=null){return(...r)=>{for(let t of r)if(void 0===t)return console.error(`THREE.TSL: Invalid parameter for the type "${e}".`),eR(new X(0,e));if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every(e=>{let t=typeof e;return"object"!==t&&"function"!==t}))&&(r=[S(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return eA(t.get(r[0]));if(1===r.length){let t=eT(r[0],e);return t.nodeType===e?eA(t):eA(new V(t,e))}return eA(new k(r.map(e=>eT(e)),e))}},ev=e=>"object"==typeof e&&null!==e?e.value:e,eN=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function eS(e,t){return new ec(e,t)}let eR=(e,t=null)=>ea(e,t),eA=(e,t=null)=>
1eR(e,t).toVarIntent(),eE=(e,t=null)=>new eo(e,t),eC=(e,t=null)=>new el(e,t),ew=(e,t=null,r=null,i=null)=>new eu(e,t,r,i),eM=(e,...t)=>new ed(e,...t),eB=(e,t=null,r=null,i={})=>new eu(e,t,r,{intent:!0,...i}),eL=0;class eP extends D{constructor(e,t=null){super();let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:console.error("THREE.TSL: Invalid layout type."),t=null)),this.shaderNode=new eS(e,r),null!==t&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if("object"!=typeof e.inputs){let r={name:"fn"+eL++,type:t,inputs:[]};for(let t in e)"return"!==t&&r.inputs.push({name:t,type:e[t]});e=r}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){let t=this.shaderNode.call(e);return"void"===this.shaderNode.nodeType&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return console.error('THREE.TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function eF(e,t=null){let r=new eP(e,t);return new Proxy(()=>{},{apply:(e,t,i)=>r.call(...i),get:(e,t,i)=>Reflect.get(r,t,i),set:(e,t,i,s)=>Reflect.set(r,t,i,s)})}let eU=e=>{Q=e},eI=()=>Q,eD=(...e)=>Q.If(...e);function eO(e){return Q&&Q.add(e),e}Z("toStack",eO);let eV=new e_("color"),eG=new e_("float",eb.float),ek=new e_("int",eb.ints),ez=new e_("uint",eb.uint),e$=new e_("bool",eb.bool),eH=new e_("vec2"),eW=new e_("ivec2"),eq=new e_("uvec2"),ej=new e_("bvec2"),eX=new e_("vec3"),eK=new e_("ivec3"),eQ=new e_("uvec3"),eY=new e_("bvec3"),eZ=new e_("vec4"),eJ=new e_("ivec4"),e0=new e_("uvec4"),e1=new e_("bvec4"),e2=new e_("mat2"),e3=new e_("mat3"),e4=new e_("mat4");Z("toColor",eV),Z("toFloat",eG),Z("toInt",ek),Z("toUint",ez),Z("toBool",e$),Z("toVec2",eH),Z("toIVec2",eW),Z("toUVec2",eq),Z("toBVec2",ej),Z("toVec3",eX),Z("toIVec3",eK),Z("toUVec3",eQ),Z("toBVec3",eY),Z("toVec4",eZ),Z("toIVec4",eJ),Z("toUVec4",e0),Z("toBVec4",e1),Z("toMat2",e2),Z("toMat3",e3),Z("toMat4",e4);let e6=ew(O).setParameterLength(2),e8=(e,t)=>eR(new V(eR(e),t));Z("element",e6),Z("convert",e8),Z("append",e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),eO(e)));class e5 extends D{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name)).needsInterpolation=!0:t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}let e9=(e,t)=>eR(new e5(e,t)),e7=(e,t)=>eR(new e5(e,t,!0)),te=eM(e5,"vec4","DiffuseColor"),tt=eM(e5,"vec3","EmissiveColor"),tr=eM(e5,"float","Roughness"),ti=eM(e5,"float","Metalness"),ts=eM(e5,"float","Clearcoat"),tn=eM(e5,"float","ClearcoatRoughness"),ta=eM(e5,"vec3","Sheen"),to=eM(e5,"float","SheenRoughness"),tl=eM(e5,"float","Iridescence"),tu=eM(e5,"float","IridescenceIOR"),td=eM(e5,"float","IridescenceThickness"),th=eM(e5,"float","AlphaT"),tc=eM(e5,"float","Anisotropy"),tp=eM(e5,"vec3","AnisotropyT"),tg=eM(e5,"vec3","AnisotropyB"),tm=eM(e5,"color","SpecularColor"),tf=eM(e5,"float","SpecularF90"),ty=eM(e5,"float","Shininess"),tb=eM(e5,"vec4","Output"),tx=eM(e5,"float","dashSize"),tT=eM(e5,"float","gapSize"),t_=eM(e5,"float","pointWidth"),tv=eM(e5,"float","IOR"),tN=eM(e5,"float","Transmission"),tS=eM(e5,"float","Thickness"),tR=eM(e5,"float","AttenuationDistance"),tA=eM(e5,"color","AttenuationColor"),tE=eM(e5,"float","Dispersion");class tC extends D{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,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}}let tw=e=>new tC(e),tM=(e,t=0)=>new tC(e,!0,t),tB=tM("frame"),tL=tM("render"),tP=tw("object");class tF extends q{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=tP}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}
1onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let r=e(t,this);void 0!==r&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return"bool"===t&&(t="uint"),t}generate(e,t){let r=this.getNodeType(e),i=this.getUniformHash(e),s=e.getNodeFromHash(i);void 0===s&&(e.setHashNode(this,i),s=this);let n=s.getInputType(e),a=e.getUniformFromNode(s,n,e.shaderStage,this.name||e.context.nodeName),o=e.getPropertyName(a);void 0!==e.context.nodeName&&delete e.context.nodeName;let l=o;if("bool"===r){let t=e.getDataFromNode(this),i=t.propertyName;if(void 0===i){let s=e.getVarFromNode(this,null,"bool");t.propertyName=i=e.getPropertyName(s),l=e.format(o,n,r),e.addLineFlowCode(`${i} = ${l}`,this)}l=i}return e.format(l,r,t)}}let tU=(e,t)=>{let r=eN(t||e);return r===e&&(e=S(r)),eR(new tF(e=e&&!0===e.isNode?e.node&&e.node.value||e.value:e,r))};class tI extends G{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return null===this.nodeType&&(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)}}let tD=(...e)=>{let t;if(1===e.length){let r=e[0];t=new tI(null,r.length,r)}else t=new tI(e[0],e[1]);return eR(t)};Z("toArray",(e,t)=>tD(Array(t).fill(e)));class tO extends G{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"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){let{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){let r=e.getTypeLength(t.node.getNodeType(e));return F.join("").slice(0,r)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:r}=this,i=t.getScope();e.getNodeProperties(i).assign=!0;let s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){let r,{targetNode:i,sourceNode:s}=e.getNodeProperties(this),n=this.needsSplitAssign(e),a=i.build(e),o=i.getNodeType(e),l=s.build(e,o),u=s.getNodeType(e),d=e.getDataFromNode(this);if(!0===d.initialized)"void"!==t&&(r=a);else if(n){let s=e.getVarFromNode(this,null,o),n=e.getPropertyName(s);e.addLineFlowCode(`${n} = ${l}`,this);let u=i.node,d=u.node.context({assign:!0}).build(e);for(let t=0;t<u.components.length;t++){let r=u.components[t];e.addLineFlowCode(`${d}.${r} = ${n}[ ${t} ]`,this)}"void"!==t&&(r=a)}else r=`${a} = ${l}`,("void"===t||"void"===u)&&(e.addLineFlowCode(r,this),"void"!==t&&(r=a));return d.initialized=!0,e.format(r,o,t)}}let tV=ew(tO).setParameterLength(2);Z("assign",tV);class tG extends G{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)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],r=this.functionNode,i=r.getInputs(e),s=this.parameters,n=(t,r)=>{let i=r.type;return"pointer"===i?"&"+t.build(e):t.build(e,i)};if(Array.isArray(s)){if(s.length>i.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=i.length;else if(s.length<i.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<i.length;)s.push(eG(0));for(let e=0;e<s.length;e++)t.push(n(s[e],i[e]))}else for(let e of i){let r=s[e.name];void 0!==r?t.push(n(r,e)):(console.error(`THREE.TSL: Input '${e.name}' not found in 'Fn()'.`),t.push(n(eG(0),e)))}let a=r.build(e,"property");return`${a}( ${t.join(", ")} )`}}let tk=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?eC(t):eE(t[0]),eR(new tG(eR(e),t)));Z("call",tk);let tz={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class t$ extends G{static get type(){return"OperatorNode"}constructor(e,t,r,...i){if(super(),i.length>0){let s=new t$(e,t,r);for(let t=0;t<i.length-1;t++)s=new t$(e,s,i[t]);t=s,r=i[i.length-1]}this.op=e,this.aNode=t,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(tz[this.op],t)}getNodeType(e,t=null){let r=this.op,i=this.aNode,s=this.bNode,n=i.getNodeType(e),a=s?s.getNodeType(e):null;if("void"===n||"void"===a)return t||"void";if("%"===r)return n;if("~"===r||"&"===r||"|"===r||"^"===r||">>"===r||"<<"===r)return e.getIntegerType(n);if("!"===r||"&&"===r||"||"===r||"^^"===r)return"bool";if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r){let t=Math.max(e.getTypeLength(n),e.getTypeLength(a));return t>1?`bvec${t}`:"bool"}else{if(e.isMatrix(n)){if("float"===a)return n;else if(e.isVector(a))return e.getVectorFromMatrix(n);else if(e.isMatrix(a))return n}else if(e.isMatrix(a)){if("float"===n)return a;else if(e.isVector(n))return e.getVectorFromMatrix(a)}return e.getTypeLength(a)>e.getTypeLength(n)?a:n}}generate(e,t){let r=this.op,{aNode:i,bNode:s}=this,n=this.getNodeType(e,t),a=null,o=null;"void"!==n?(a=i.getNodeType(e),o=s?s.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(a)?o=a:e.isVector(o)?a=o:a!==o&&(a=o="float"):">>"===r||"<<"===r?(a=n,o=e.changeComponentType(o,"uint")):"%"===r?(a=n,o=e.isInteger(a)&&e.isInteger(o)?o:a):e.isMatrix(a)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(a):e.isMatrix(o)||(a=o=n):a=e.isMatrix(o)?"float"===a?"float":e.isVector(a)?e.getVectorFromMatrix(o):o=n:o=n):a=o=n;let l=i.build(e,a),d=s?s.build(e,o):null,h=e.getFunctionOperator(r);if("void"!==t){let i=e.renderer.coordinateSystem===u.TdN;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)if(!i)return e.format(`( ${l} ${r} ${d} )`,n,t);else if(e.isVector(a))return e.format(`${this.getOperatorMethod(e,t)}( ${l}, ${d} )`,n,t);else return e.format(`( ${l} ${r} ${d} )`,n,t);if("%"===r)if(e.isInteger(o))return e.format(`( ${l} % ${d} )`,n,t);else return e.format(`${this.getOperatorMethod(e,n)}( ${l}, ${d} )`,n,t);{if("!"===r||"~"===r)return e.format(`(${r}${l})`,a,t);if(h)return e.format(`${h}( ${l}, ${d} )`,n,t);if(e.isMatrix(a)&&"float"===o)return e.format(`( ${d} ${r} ${l} )`,n,t);if("float"===a&&e.isMatrix(o))return e.format(`${l} ${r} ${d}`,n,t);let s=`( ${l} ${r} ${d} )`;return!i&&"bool"===n&&e.isVector(a)&&e.isVector(o)&&(s=`all${s}`),e.format(s,n,t)}}if("void"!==a)if(h)return e.format(`${h}( ${l}, ${d} )`,n,t);else if(e.isMatrix(a)&&"float"===o)return e.format(`${d} ${r} ${l}`,n,t);else return e.format(`${l} ${r} ${d}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}let tH=eB(t$,"+").setParameterLength(2,1/0).setName("add"),tW=eB(t$,"-").setParameterLength(2,1/0).setName("sub"),tq=eB(t$,"*").setParameterLength(2,1/0).setName("mul"),tj=eB(t$,"/").setParameterLength(2,1/0).setName("div"),tX=eB(t$,"%").setParameterLength(2).setName("mod"),tK=eB(t$,"==").setParameterLength(2).setName("equal"),tQ=eB(t$,"!=").setParameterLength(2).setName("notEqual"),tY=eB(t$,"<").setParameterLength(2).setName("lessThan"),tZ=eB(t$,">").setParameterLength(2).setName("greaterThan"),tJ=eB(t$,"<=").setParameterLength(2).setName("lessThanEqual"),t0=eB(t$,">=").setParameterLength(2).setName("greaterThanEqual"),t1=eB(t$,"&&").setParameterLength(2,1/0).setName("and"),t2=eB(t$,"||").setParameterLength(2,1/0).setName("or"),t3=eB(t$,"!").setParameterLength(1).setName("not"),t4=eB(t$,"^^").setParameterLength(2).setName("xor"),t6=eB(t$,"&").setParameterLength(2).setName("bitAnd"),t8=eB(t$,"~").setParameterLength(2).setName("bitNot"),t5=eB(t$,"|").setParameterLength(2).setName("bitOr"),t9=eB(t$,"^").setParameterLength(2).setName("bitXor"),t7=eB(t$,"<<").setParameterLength(2).setName("shiftLeft"),re=eB(t$,">>").setParameterLength(2).setName("shiftRight"),rt=eF(([e])=>(e.addAssign(1),e)),rr=eF(([e])=>(e.subAssign(1),e)),ri=eF(([e])=>{let t=ek(e).toConst();return e.addAssign(1),t}),rs=eF(([e])=>{let t=ek(e).toConst();return e.subAssign(1),t});Z("add",tH),Z("sub",tW),Z("mul",tq),Z("div",tj),Z("mod",tX),Z("equal",tK),Z("notEqual",tQ),Z("lessThan",tY),Z("greaterThan",tZ),Z("lessThanEqual",tJ),Z("greaterThanEqual",t0),Z("and",t1),Z("or",t2),Z("not",t3),Z("xor",t4),Z("bitAnd",t6),Z("bitNot",t8),Z("bitOr",t5),Z("bitXor",t9),Z("shiftLeft",t7),Z("shiftRight",re),Z("incrementBefore",rt),Z("decrementBefore",rr),Z("increment",ri
1),Z("decrement",rs);let rn=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),tX(ek(e),ek(t)));Z("modInt",rn);class ra extends G{static get type(){return"MathNode"}constructor(e,t,r=null,i=null){if(super(),(e===ra.MAX||e===ra.MIN)&&arguments.length>3){let s=new ra(e,t,r);for(let t=2;t<arguments.length-1;t++)s=new ra(e,s,arguments[t]);t=s,r=arguments[arguments.length-1],i=null}this.method=e,this.aNode=t,this.bNode=r,this.cNode=i,this.isMathNode=!0}getInputType(e){let t=this.aNode.getNodeType(e),r=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),n=e.isMatrix(r)?0:e.getTypeLength(r),a=e.isMatrix(i)?0:e.getTypeLength(i);if(s>n&&s>a);else if(n>a)return r;else if(a>s)return i;return t}getNodeType(e){let t=this.method;return t===ra.LENGTH||t===ra.DISTANCE||t===ra.DOT?"float":t===ra.CROSS?"vec3":t===ra.ALL||t===ra.ANY?"bool":t===ra.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:t,bNode:r,method:i}=this,s=null;if(i===ra.ONE_MINUS)s=tW(1,t);else if(i===ra.RECIPROCAL)s=tj(1,t);else if(i===ra.DIFFERENCE)s=rB(tW(t,r));else if(i===ra.TRANSFORM_DIRECTION){let i=t,n=r;e.isMatrix(i.getNodeType(e))?n=eZ(eX(n),0):i=eZ(eX(i),0),s=rN(tq(i,n).xyz)}return null!==s?s:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method,i=this.getNodeType(e),s=this.getInputType(e),n=this.aNode,a=this.bNode,o=this.cNode,l=e.renderer.coordinateSystem;if(r===ra.NEGATE)return e.format("( - "+n.build(e,s)+" )",i,t);{let d=[];return r===ra.CROSS?d.push(n.build(e,i),a.build(e,i)):l===u.TdN&&r===ra.STEP?d.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":s),a.build(e,s)):l===u.TdN&&(r===ra.MIN||r===ra.MAX)?d.push(n.build(e,s),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":s)):r===ra.REFRACT?d.push(n.build(e,s),a.build(e,s),o.build(e,"float")):r===ra.MIX?d.push(n.build(e,s),a.build(e,s),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":s)):(l===u.i7u&&r===ra.ATAN&&null!==a&&(r="atan2"),"fragment"!==e.shaderStage&&(r===ra.DFDX||r===ra.DFDY)&&(console.warn(`THREE.TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),d.push(n.build(e,s)),null!==a&&d.push(a.build(e,s)),null!==o&&d.push(o.build(e,s))),e.format(`${e.getMethod(r,i)}( ${d.join(", ")} )`,i,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}ra.ALL="all",ra.ANY="any",ra.RADIANS="radians",ra.DEGREES="degrees",ra.EXP="exp",ra.EXP2="exp2",ra.LOG="log",ra.LOG2="log2",ra.SQRT="sqrt",ra.INVERSE_SQRT="inversesqrt",ra.FLOOR="floor",ra.CEIL="ceil",ra.NORMALIZE="normalize",ra.FRACT="fract",ra.SIN="sin",ra.COS="cos",ra.TAN="tan",ra.ASIN="asin",ra.ACOS="acos",ra.ATAN="atan",ra.ABS="abs",ra.SIGN="sign",ra.LENGTH="length",ra.NEGATE="negate",ra.ONE_MINUS="oneMinus",ra.DFDX="dFdx",ra.DFDY="dFdy",ra.ROUND="round",ra.RECIPROCAL="reciprocal",ra.TRUNC="trunc",ra.FWIDTH="fwidth",ra.TRANSPOSE="transpose",ra.DETERMINANT="determinant",ra.INVERSE="inverse",ra.EQUALS="equals",ra.MIN="min",ra.MAX="max",ra.STEP="step",ra.REFLECT="reflect",ra.DISTANCE="distance",ra.DIFFERENCE="difference",ra.DOT="dot",ra.CROSS="cross",ra.POW="pow",ra.TRANSFORM_DIRECTION="transformDirection",ra.MIX="mix",ra.CLAMP="clamp",ra.REFRACT="refract",ra.SMOOTHSTEP="smoothstep",ra.FACEFORWARD="faceforward";let ro=eG(1e-6),rl=eG(1e6),ru=eG(Math.PI),rd=eG(2*Math.PI),rh=eB(ra,ra.ALL).setParameterLength(1),rc=eB(ra,ra.ANY).setParameterLength(1),rp=eB(ra,ra.RADIANS).setParameterLength(1),rg=eB(ra,ra.DEGREES).setParameterLength(1),rm=eB(ra,ra.EXP).setParameterLength(1),rf=eB(ra,ra.EXP2).setParameterLength(1),ry=eB(ra,ra.LOG).setParameterLength(1),rb=eB(ra,ra.LOG2).setParameterLength(1),rx=eB(ra,ra.SQRT).setParameterLength(1),rT=eB(ra,ra.INVERSE_SQRT).setParameterLength(1),r_=eB(ra,ra.FLOOR).setParameterLength(1),rv=eB(ra,ra.CEIL).setParameterLength(1),rN=eB(ra,ra.NORMALIZE).setParameterLength(1),rS=eB(ra,ra.FRACT).setParameterLength(1),rR=eB(ra,ra.SIN).setParameterLength(1),rA=eB(ra,ra.COS).setParameterLength(1),rE=eB(ra,ra.TAN).setParameterLength(1),rC=eB(ra,ra.ASIN).setParameterLength(1),rw=eB(ra,ra.ACOS).setParameterLength(1),rM=eB(ra,ra.ATAN).setParameterLength(1,2),rB=eB(ra,ra.ABS).setParameterLength(1),rL=eB(ra,ra.SIGN).setParameterLength(1),rP=eB(ra,ra.LENGTH).setParameterLength(1),rF=eB(ra,ra.NEGATE).setParameterLength(1),rU=eB(ra,ra.ONE_MINUS).setParameterLength(1),rI=eB(ra,ra.DFDX).setParameterLength(1),rD=eB(ra,ra.DFDY).setParameterLength(1),rO=eB(ra,ra.ROUND).setParameterLength(1),rV=eB(ra,ra.RECIPROCAL).setParameterLength(1),rG=eB(ra,ra.TRUNC).setParameterLength(1),rk=eB(ra,ra.FWIDTH).setParameterLength(1),rz=eB(ra,ra.TRANSPOSE).setParameterLength(1),r$=eB(ra,ra.DETERMINANT).setParameterLength(1),rH=eB(ra,ra.INVERSE).setParameterLength(1),rW=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),tK(e,t)),rq=eB(ra,ra.MIN).setParameterLength(2,1/0),rj=eB(ra,ra.MAX).setParameterLength(2,1/0),rX=eB(ra,ra.STEP).setParameterLength(2),rK=eB(ra,ra.REFLECT).setParameterLength(2),rQ=eB(ra,ra.DISTANCE).setParameterLength(2),rY=eB(ra,ra.DIFFERENCE).setParameterLength(2),rZ=eB(ra,ra.DOT).setParameterLength(2),rJ=eB(ra,ra.CROSS).setParameterLength(2),r0=eB(ra,ra.POW).setParameterLength(2),r1=e=>tq(e,e),r2=e=>tq(e,e,e),r3=e=>tq(e,e,e,e),r4=eB(ra,ra.TRANSFORM_DIRECTION).setParameterLength(2),r6=e=>tq(rL(e),r0(rB(e),1/3)),r8=e=>rZ(e,e),r5=eB(ra,ra.MIX).setParameterLength(3),r9=(e,t=0,r=1)=>eR(new ra(ra.CLAMP,eR(e),eR(t),eR(r))),r7=e=>r9(e),ie=eB(ra,ra.REFRACT).setParameterLength(3),it=eB(ra,ra.SMOOTHSTEP).setParameterLength(3),ir=eB(ra,ra.FACEFORWARD).setParameterLength(3),ii=eF(([e])=>rS(rR(tX(rZ(e.xy,eH(12.9898,78.233)),ru)).mul(43758.5453))),is=(e,t,r)=>r5(t,r,e),ia=(e,t,r)=>it(t,r,e),io=(e,t)=>rX(t,e),il=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),rM(e,t));Z("all",rh),Z("any",rc),Z("equals",rW),Z("radians",rp),Z("degrees",rg),Z("exp",rm),Z("exp2",rf),Z("log",ry),Z("log2",rb),Z("sqrt",rx),Z("inverseSqrt",rT),Z("floor",r_),Z("ceil",rv),Z("normalize",rN),Z("fract",rS),Z("sin",rR),Z("cos",rA),Z("tan",rE),Z("asin",rC),Z("acos",rw),Z("atan",rM),Z("abs",rB),Z("sign",rL),Z("length",rP),Z("lengthSq",r8),Z("negate",rF),Z("oneMinus",rU),Z("dFdx",rI),Z("dFdy",rD),Z("round",rO),Z("reciprocal",rV),Z("trunc",rG),Z("fwidth",rk),Z("atan2",il),Z("min",rq),Z("max",rj),Z("step",io),Z("reflect",rK),Z("distance",rQ),Z("dot",rZ),Z("cross",rJ),Z("pow",r0),Z("pow2",r1),Z("pow3",r2),Z("pow4",r3),Z("transformDirection",r4),Z("mix",is),Z("clamp",r9),Z("refract",ie),Z("smoothstep",ia),Z("faceForward",ir),Z("difference",rY),Z("saturate",r7),Z("cbrt",r6),Z("transpose",rz),Z("determinant",r$),Z("inverse",rH),Z("rand",ii);class iu extends D{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){let{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(void 0===t)return e.flowBuildStage(this,"setup"),this.getNodeType(e);let i=t.getNodeType(e);if(null!==r){let t=r.getNodeType(e);if(e.getTypeLength(t)>e.getTypeLength(i))return t}return i}
1setup(e){let t=this.condNode.cache(),r=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,s=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=s,null!==i&&(e.getDataFromNode(i).parentNodeBlock=s);let n=e.context.uniformFlow,a=e.getNodeProperties(this);a.condNode=t,a.ifNode=n?r:r.context({nodeBlock:r}),a.elseNode=i?n?i:i.context({nodeBlock:i}):null}generate(e,t){let r=this.getNodeType(e),i=e.getDataFromNode(this);if(void 0!==i.nodeProperty)return i.nodeProperty;let{condNode:s,ifNode:n,elseNode:a}=e.getNodeProperties(this),o=e.currentFunctionNode,l="void"!==t,u=l?e9(r).build(e):"";i.nodeProperty=u;let d=s.build(e,"bool");if(e.context.uniformFlow&&null!==a){let i=n.build(e,r),s=a.build(e,r),o=e.getTernary(d,i,s);return e.format(o,r,t)}e.addFlowCode(`
2${e.tab}if ( ${d} ) {
3
4`).addFlowTab();let h=n.build(e,r);if(h&&(l?h=u+" = "+h+";":(h="return "+h+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),h="// "+h))),e.removeFlowTab().addFlowCode(e.tab+"	"+h+"\n\n"+e.tab+"}"),null!==a){e.addFlowCode(" else {\n\n").addFlowTab();let t=a.build(e,r);t&&(l?t=u+" = "+t+";":(t="return "+t+";",null===o&&(console.warn("THREE.TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"	"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(u,r,t)}}let id=ew(iu).setParameterLength(2,3);Z("select",id);class ih extends D{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)}getMemberType(e,t){return this.node.getMemberType(e,t)}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 r=e.getContext();e.setContext({...e.context,...this.value});let i=this.node.build(e,t);return e.setContext(r),i}}let ic=ew(ih).setParameterLength(1,2),ip=e=>ic(e,{uniformFlow:!0}),ig=(e,t)=>ic(e,{nodeName:t});function im(e,t){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),ig(e,t)}Z("context",ic),Z("label",im),Z("uniformFlow",ip),Z("setName",ig);class iy extends D{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}build(...e){return!0===this.intent&&!0!==e[0].getNodeProperties(this).assign?this.node.build(...e):super.build(...e)}generate(e){let{node:t,name:r,readOnly:i}=this,{renderer:s}=e,n=!0===s.backend.isWebGPUBackend,a=!1,o=!1;i&&(a=e.isDeterministic(t),o=n?i:a);let l=e.getVectorType(this.getNodeType(e)),u=t.build(e,l),d=e.getVarFromNode(this,r,l,void 0,o),h=e.getPropertyName(d),c=h;if(o)if(n)c=a?`const ${h}`:`let ${h}`;else{let r=t.getArrayCount(e);c=`const ${e.getVar(d.type,h,r)}`}return e.addLineFlowCode(`${c} = ${u}`,this),h}}let ib=ew(iy),ix=(e,t=null)=>ib(e,t).toStack(),iT=(e,t=null)=>ib(e,t,!0).toStack(),i_=e=>null===eI()?e:ib(e).setIntent(!0).toStack();Z("toVar",ix),Z("toConst",iT),Z("toVarIntent",i_);class iv extends D{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(null!==this.nodeType)return this.nodeType;e.addSubBuild(this.name);let t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);let r=this.node.build(e,...t);return e.removeSubBuild(),r}}let iN=(e,t,r=null)=>eR(new iv(eR(e),t,r));class iS extends D{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),r=t.varying;if(void 0===r){let i=this.name,s=this.getNodeType(e),n=this.interpolationType,a=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,i,s,n,a),t.node=iN(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(C.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(C.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),i=this.setupVarying(e);if(void 0===r[t]){let s=this.getNodeType(e),n=e.getPropertyName(i,C.VERTEX);e.flowNodeFromShaderStage(C.VERTEX,r.node,s,n),r[t]=n}return e.getPropertyName(i)}}let iR=ew(iS).setParameterLength(1,2),iA=e=>iR(e);Z("toVarying",iR),Z("toVertexStage",iA),Z("varying",(...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),iR(...e))),Z("vertexStage",(...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),iR(...e)));let iE=eF(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4);return r5(t,e.mul(.0773993808),e.lessThanEqual(.04045))}
4).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),iC=eF(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055);return r5(t,e.mul(12.92),e.lessThanEqual(.0031308))}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),iw="WorkingColorSpace";class iM extends G{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===iw?u.ppV.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),i=this.resolveColorSpace(e,this.target),s=t;return!1!==u.ppV.enabled&&r!==i&&r&&i&&(u.ppV.getTransfer(r)===u.KLL&&(s=eZ(iE(s.rgb),s.a)),u.ppV.getPrimaries(r)!==u.ppV.getPrimaries(i)&&(s=eZ(e3(u.ppV._getMatrix(new u.dwI,r,i)).mul(s.rgb),s.a)),u.ppV.getTransfer(i)===u.KLL&&(s=eZ(iC(s.rgb),s.a))),s}}let iB=(e,t)=>eR(new iM(eR(e),iw,t)),iL=(e,t)=>eR(new iM(eR(e),t,iw));Z("workingToColorSpace",iB),Z("colorSpaceToWorking",iL);let iP=class extends O{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),r=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,r,i)}};class iF extends D{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,i=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=i,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=w.OBJECT}setGroup(e){return this.group=e,this}element(e){return eR(new iP(this,eR(e)))}setNodeType(e){let t=tU(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,r=e[t[0]];for(let e=1;e<t.length;e++)r=r[t[e]];return r}updateReference(e){return this.reference=null!==this.object?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}class iU extends iF{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(tL)}updateReference(e){return this.reference=null!==this.renderer?this.renderer:e.renderer,this.reference}}let iI=(e,t,r=null)=>eR(new iU(e,t,r));class iD extends G{static get type(){return"ToneMappingNode"}constructor(e,t=iV,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return f(this.toneMapping)}setup(e){let t=this.colorNode||e.context.color,r=this.toneMapping;if(r===u.y_p)return t;let i=null,s=e.renderer.library.getToneMappingFunction(r);return null!==s?i=eZ(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=t),i}}let iO=(e,t,r)=>eR(new iD(e,eR(t),eR(r))),iV=iI("toneMappingExposure","float");Z("toneMapping",(e,t,r)=>iO(t,r,e));class iG extends q{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=i,this.usage=u.agE,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;let t=this.getNodeType(e),r=this.value,i=e.getTypeLength(t),s=this.bufferStride||i,n=this.bufferOffset,a=!0===r.isInterleavedBuffer?r:new u.eB$(r,s),o=new u.eHs(a,i,n);a.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),i=e.getPropertyName(r),s=null;return"vertex"===e.shaderStage||"compute"===e.shaderStage?(this.name=i,s=i):s=iR(this).build(e,t),s}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}let ik=(e,t=null,r=0,i=0)=>
4eR(new iG(e,t,r,i)),iz=(e,t=null,r=0,i=0)=>ik(e,t,r,i).setUsage(u.Vnu),i$=(e,t=null,r=0,i=0)=>ik(e,t,r,i).setInstanced(!0),iH=(e,t=null,r=0,i=0)=>iz(e,t,r,i).setInstanced(!0);Z("toAttribute",e=>ik(e.value));class iW extends D{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=w.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){let t=this.computeNode.build(e);return t&&(e.getNodeProperties(this).outputComputeNode=t.outputNode,t.outputNode=null),t}generate(e,t){let{shaderStage:r}=e;if("compute"===r){let t=this.computeNode.build(e,"void");""!==t&&e.addLineFlowCode(t,this)}else{let r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}let iq=(e,t=[64])=>{(0===t.length||t.length>3)&&console.error("THREE.TSL: compute() workgroupSize must have 1, 2, or 3 elements");for(let e=0;e<t.length;e++){let r=t[e];("number"!=typeof r||r<=0||!Number.isInteger(r))&&console.error(`THREE.TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`)}for(;t.length<3;)t.push(1);return eR(new iW(eR(e),t))},ij=(e,t,r)=>iq(e,r).setCount(t);Z("compute",ij),Z("computeKernel",iq);class iX extends D{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(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);let i=this.node.getNodeType(e);return e.setCache(t),i}build(e,...t){let r=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);let s=this.node.build(e,...t);return e.setCache(r),s}}let iK=(e,t)=>eR(new iX(eR(e),t));Z("cache",iK);class iQ extends D{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)}}let iY=ew(iQ).setParameterLength(2);Z("bypass",iY);class iZ extends D{static get type(){return"RemapNode"}constructor(e,t,r,i=eG(0),s=eG(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=i,this.outHighNode=s,this.doClamp=!0}setup(){let{node:e,inLowNode:t,inHighNode:r,outLowNode:i,outHighNode:s,doClamp:n}=this,a=e.sub(t).div(r.sub(t));return!0===n&&(a=a.clamp()),a.mul(s.sub(i)).add(i)}}let iJ=ew(iZ,null,null,{doClamp:!1}).setParameterLength(3,5),i0=ew(iZ).setParameterLength(3,5);Z("remap",iJ),Z("remapClamp",i0);class i1 extends D{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){let r=this.getNodeType(e),i=this.snippet;if("void"!==r)return e.format(i,r,t);e.addLineFlowCode(i,this)}}let i2=ew(i1).setParameterLength(1,2),i3=e=>(e?id(e,i2("discard")):i2("discard")).toStack();Z("discard",i3);class i4 extends G{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color,r=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||u.y_p,i=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||u.jf0;return r!==u.y_p&&(t=t.toneMapping(r)),i!==u.jf0&&i!==u.ppV.workingColorSpace&&(t=t.workingToColorSpace(i)),t}}let i6=(e,t=null,r=null)=>eR(new i4(eR(e),t,r));Z("renderOutput",i6);class i8 extends G{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,r=this.node.build(e),i="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(i.length),n="";return n+="// #"+i+"#\n"+e.flow.code.replace(/^\t/mg,"")+"\n"+("/* ... */ "+r)+" /* ... */\n"+("// #"+s)+"#\n",null!==t?t(e,n):console.log(n),r}}let i5=(e,t=null)=>eR(new i8(eR(e),t)).toStack();Z("debug",i5);class i9 extends D{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(null===t){let r=this.getAttributeName(e);
4if(e.hasGeometryAttribute(r)){let i=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(i)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){let t=this.getAttributeName(e),r=this.getNodeType(e);if(!0!==e.hasGeometryAttribute(t))return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r);{let i=e.geometry.getAttribute(t),s=e.getTypeFromAttribute(i),n=e.getAttribute(t,s);return"vertex"===e.shaderStage?e.format(n.name,s,r):iR(this).build(e,r)}}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}}let i7=(e,t=null)=>eR(new i9(e,t)),se=(e=0)=>i7("uv"+(e>0?e:""),"vec2");class st extends D{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){let r=this.textureNode.build(e,"property"),i=null===this.levelNode?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${i} )`,this.getNodeType(e),t)}}let sr=ew(st).setParameterLength(1,2);class si extends tF{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=w.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){let{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}let ss=ew(si).setParameterLength(1),sn=new u.gPd;class sa extends tF{static get type(){return"TextureNode"}constructor(e=sn,t=null,r=null,i=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=w.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}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!0===this.value.isDepthTexture?"float":this.value.type===u.bkx?"uvec4":this.value.type===u.Yuy?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return se(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=tU(this.value.matrix)),this._matrixUniform.mul(eX(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?w.OBJECT:w.NONE,this}setupUV(e,t){let r=this.value;return e.isFlipY()&&(r.image instanceof ImageBitmap&&!0===r.flipY||!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture||!0===r.isDepthTexture)&&(t=this.sampler?t.flipY():t.setY(ek(sr(this,this.levelNode).y).sub(t.y).sub(1))),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let r=this.value;if(!r||!0!==r.isTexture)throw Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");let i=this.uvNode;(null===i||!0===e.context.forceUVContext)&&e.context.getUV&&(i=e.context.getUV(this,e)),i||(i=this.getDefaultUV()),!0===this.updateMatrix&&(i=this.getTransformedUV(i)),i=this.setupUV(e,i);let s=this.levelNode;null===s&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this)),t.uvNode=i,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,i,s,n,a,o,l){let u=this.value;return i?e.generateTextureLevel(u,t,r,i,n,l):s?e.generateTextureBias(u,t,r,s,n,l):o?e.generateTextureGrad(u,t,r,o,n,l):a?e.generateTextureCompare(u,t,r,a,n,l):!1===this.sampler?e.generateTextureLoad(u,t,r,n,l):e.generateTexture(u,t,r,n,l)}generate(e,t){let r=this.value,i=e.getNodeProperties(this),s=super.generate(e,"property");if(/^sampler/.test(t))return s+"_sampler";{if(e.isReference(t))return s;let n=e.getDataFromNode(this),a=n.propertyName;if(void 0===a){let{uvNode:t,levelNode:r,biasNode:o,compareNode:l,depthNode:u,gradNode:d,offsetNode:h}=i,c=this.generateUV(e,t),p=r?r.build(e,"float"):null,g=o?o.build(e,"float"):null,m=u?u.build(e,"int"):null,f=l?l.build(e,"float"):null,y=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,b=h?this.generateOffset(e,h):null,x=e.getVarFromNode(this);a=e.getPropertyName(x);let T=this.generateSnippet(e,s,c,p,g,m,f,y,b);e.addLineFlowCode(`${a} = ${T}`,this),n.snippet=T,n.propertyName=a}let o=a,l=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=iL(i2(o,l),r.colorSpace).setup(e).build(e,l)),e.format(o,l,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=eR(e),t.referenceNode=this.getBase(),eR(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=eR(e).mul(ss(t)),t.referenceNode=this.getBase();let r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===u.hxR||r.magFilter===u.hxR)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),eR(t)}level(e){let t=this.clone();return t.levelNode=eR(e),t.referenceNode=this.getBase(),eR(t)}size(e){return sr(this,e)}bias(e){let t=this.clone();return t.biasNode=eR(e),t.referenceNode=this.getBase(),eR(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=eR(e),t.referenceNode=this.getBase(),eR(t)}grad(e,t){let r=this.clone();return r.gradNode=[eR(e),eR(t)],r.referenceNode=this.getBase(),eR(r)}depth(e){let t=this.clone();return t.depthNode=eR(e),t.referenceNode=this.getBase(),eR(t)}offset(e){let t=this.clone();return t.offsetNode=eR(e),t.referenceNode=this.getBase(),eR(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;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&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.offsetNode=this.offsetNode,e}}let so=ew(sa).setParameterLength(1,4).setName("texture"),sl=(e=sn,t=null,r=null,i=null)=>{let s;return e&&!0===e.isTextureNode?((s=eR(e.clone())).referenceNode=e.getBase(),null!==t&&(s.uvNode=eR(t)),null!==r&&(s.levelNode=eR(r)),null!==i&&(s.biasNode=eR(i))):s=so(e,t,r,i),s},su=(...e)=>sl(...e).setSampler(!1);class sd extends tF{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}let sh=(e,t,r)=>eR(new sd(e,t,r));class sc extends O{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){let t=super.generate(e),r=this.getNodeType(),i=this.node.getPaddedType();return e.format(t,i,r)}}class sp extends sd{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?N(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=w.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){let e=this.elementType,t="vec4";return"mat2"===e?t="mat2":!0===/mat/.test(e)?t="mat4":"i"===e.charAt(0)?t="ivec4":"u"===e.charAt(0)&&(t="uvec4"),t}update(){let{array:e,value:t}=this,r=this.elementType;if("float"===r||"int"===r||"uint"===r)for(let r=0;r<e.length;r++)t[4*r]=e[r];else if("color"===r)for(let r=0;r<e.length;r++){let i=4*r,s=e[r];t[i]=s.r,t[i+1]=s.g,t[i+2]=s.b||0}else if("mat2"===r)for(let r=0;r<e.length;r++){let i=4*r,s=e[r];t[i]=s.elements[0],t[i+1]=s.elements[1],t[i+2]=s.elements[2],t[i+3]=s.elements[3]}else if("mat3"===r)for(let r=0;r<e.length;r++){let i=16*r,s=e[r];t[i]=s.elements[0],t[i+1]=s.elements[1],t[i+2]=s.elements[2],t[i+4]=s.elements[3],t[i+5]=s.elements[4],t[i+6]=s.elements[5],t[i+8]=s.elements[6],t[i+9]=s.elements[7],t[i+10]=s.elements[8],t[i+15]=1}else if("mat4"===r)for(let r=0;r<e.length;r++){let i=16*r,s=e[r];for(let e=0;e<s.elements.length;e++)t[i+e]=s.elements[e]}else for(let r=0;r<e.length;r++){let i=4*r,s=e[r];t[i]=s.x,t[i+1]=s.y,t[i+2]=s.z||0,t[i+3]=s.w||0}}setup(e){let t=this.array.length,r=this.elementType,i=Float32Array,s=this.paddedType,n=e.getTypeLength(s);return"i"===r.charAt(0)&&(i=Int32Array),"u"===r.charAt(0)&&(i=Uint32Array),this.value=new i(t*n),this.bufferCount=t,this.bufferType=s,super.setup(e)}element(e){return eR(new sc(this,eR(e)))}}let sg=(e,t)=>
4eR(new sp(e,t));class sm extends D{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}let sf=ew(sm).setParameterLength(1);class sy extends D{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===sy.DPR?"float":this.scope===sy.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=w.NONE;return(this.scope===sy.SIZE||this.scope===sy.VIEWPORT||this.scope===sy.DPR)&&(e=w.RENDER),this.updateType=e,e}update({renderer:e}){let t=e.getRenderTarget();this.scope===sy.VIEWPORT?null!==t?s.copy(t.viewport):(e.getViewport(s),s.multiplyScalar(e.getPixelRatio())):this.scope===sy.DPR?this._output.value=e.getPixelRatio():null!==t?(i.width=t.width,i.height=t.height):e.getDrawingBufferSize(i)}setup(){let e=this.scope,t=null;return t=e===sy.SIZE?tU(i||(i=new u.I9Y)):e===sy.VIEWPORT?tU(s||(s=new u.IUQ)):e===sy.DPR?tU(1):eH(s_.div(sT)),this._output=t,t}generate(e){if(this.scope===sy.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){let r=e.getNodeProperties(sT).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}sy.COORDINATE="coordinate",sy.VIEWPORT="viewport",sy.SIZE="size",sy.UV="uv",sy.DPR="dpr";let sb=eM(sy,sy.DPR),sx=eM(sy,sy.UV),sT=eM(sy,sy.SIZE),s_=eM(sy,sy.COORDINATE),sv=eM(sy,sy.VIEWPORT),sN=sv.zw,sS=s_.sub(sv.xy),sR=sS.div(sN),sA=eF(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),sT),"vec2").once()(),sE=tU(0,"uint").setName("u_cameraIndex").setGroup(tM("cameraIndex")).toVarying("v_cameraIndex"),sC=tU("float").setName("cameraNear").setGroup(tL).onRenderUpdate(({camera:e})=>e.near),sw=tU("float").setName("cameraFar").setGroup(tL).onRenderUpdate(({camera:e})=>e.far),sM=eF(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.projectionMatrix);t=sg(r).setGroup(tL).setName("cameraProjectionMatrices").element(e.isMultiViewCamera?sf("gl_ViewID_OVR"):sE).toConst("cameraProjectionMatrix")}else t=tU("mat4").setName("cameraProjectionMatrix").setGroup(tL).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),sB=eF(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.projectionMatrixInverse);t=sg(r).setGroup(tL).setName("cameraProjectionMatricesInverse").element(e.isMultiViewCamera?sf("gl_ViewID_OVR"):sE).toConst("cameraProjectionMatrixInverse")}else t=tU("mat4").setName("cameraProjectionMatrixInverse").setGroup(tL).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),sL=eF(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.matrixWorldInverse);t=sg(r).setGroup(tL).setName("cameraViewMatrices").element(e.isMultiViewCamera?sf("gl_ViewID_OVR"):sE).toConst("cameraViewMatrix")}else t=tU("mat4").setName("cameraViewMatrix").setGroup(tL).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),sP=eF(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.matrixWorld);t=sg(r).setGroup(tL).setName("cameraWorldMatrices").element(e.isMultiViewCamera?sf("gl_ViewID_OVR"):sE).toConst("cameraWorldMatrix")}else t=tU("mat4").setName("cameraWorldMatrix").setGroup(tL).onRenderUpdate(({camera:e})=>e.matrixWorld);return t}).once()(),sF=eF(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.normalMatrix);t=sg(r).setGroup(tL).setName("cameraNormalMatrices").element(e.isMultiViewCamera?sf("gl_ViewID_OVR"):sE).toConst("cameraNormalMatrix")}else t=tU("mat3").setName("cameraNormalMatrix").setGroup(tL).onRenderUpdate(({camera:e})=>e.normalMatrix);return t}).once()(),sU=eF(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t=0,i=e.cameras.length;t<i;t++)r.push(new u.Pq0);t=sg(r).setGroup(tL).setName("cameraPositions").onRenderUpdate(({camera:e},t)=>{let r=e.cameras,i=t.array;for(let e=0,t=r.length;e<t;e++)i[e].setFromMatrixPosition(r[e].matrixWorld)}
4).element(e.isMultiViewCamera?sf("gl_ViewID_OVR"):sE).toConst("cameraPosition")}else t=tU(new u.Pq0).setName("cameraPosition").setGroup(tL).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld));return t}).once()(),sI=eF(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.viewport);t=sg(r,"vec4").setGroup(tL).setName("cameraViewports").element(sE).toConst("cameraViewport")}else t=eZ(0,0,sT.x,sT.y).toConst("cameraViewport");return t}).once()(),sD=new u.iyt;class sO extends D{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=w.OBJECT,this.uniformNode=new tF(null)}getNodeType(){let e=this.scope;return e===sO.WORLD_MATRIX?"mat4":e===sO.POSITION||e===sO.VIEW_POSITION||e===sO.DIRECTION||e===sO.SCALE?"vec3":e===sO.RADIUS?"float":void 0}update(e){let t=this.object3d,r=this.uniformNode,i=this.scope;if(i===sO.WORLD_MATRIX)r.value=t.matrixWorld;else if(i===sO.POSITION)r.value=r.value||new u.Pq0,r.value.setFromMatrixPosition(t.matrixWorld);else if(i===sO.SCALE)r.value=r.value||new u.Pq0,r.value.setFromMatrixScale(t.matrixWorld);else if(i===sO.DIRECTION)r.value=r.value||new u.Pq0,t.getWorldDirection(r.value);else if(i===sO.VIEW_POSITION){let i=e.camera;r.value=r.value||new u.Pq0,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}else if(i===sO.RADIUS){let i=e.object.geometry;null===i.boundingSphere&&i.computeBoundingSphere(),sD.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),r.value=sD.radius}}generate(e){let t=this.scope;return t===sO.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===sO.POSITION||t===sO.VIEW_POSITION||t===sO.DIRECTION||t===sO.SCALE?this.uniformNode.nodeType="vec3":t===sO.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}sO.WORLD_MATRIX="worldMatrix",sO.POSITION="position",sO.SCALE="scale",sO.VIEW_POSITION="viewPosition",sO.DIRECTION="direction",sO.RADIUS="radius";let sV=ew(sO,sO.DIRECTION).setParameterLength(1),sG=ew(sO,sO.WORLD_MATRIX).setParameterLength(1),sk=ew(sO,sO.POSITION).setParameterLength(1),sz=ew(sO,sO.SCALE).setParameterLength(1),s$=ew(sO,sO.VIEW_POSITION).setParameterLength(1),sH=ew(sO,sO.RADIUS).setParameterLength(1);class sW extends sO{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}let sq=eM(sW,sW.DIRECTION),sj=eM(sW,sW.WORLD_MATRIX),sX=eM(sW,sW.POSITION),sK=eM(sW,sW.SCALE),sQ=eM(sW,sW.VIEW_POSITION),sY=eM(sW,sW.RADIUS),sZ=tU(new u.dwI).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),sJ=tU(new u.kn4).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),s0=eF(e=>e.renderer.overrideNodes.modelViewMatrix||s1).once()().toVar("modelViewMatrix"),s1=sL.mul(sj),s2=eF(e=>
4(e.context.isHighPrecisionModelViewMatrix=!0,tU("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),s3=eF(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return tU("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),s4=i7("position","vec3"),s6=s4.toVarying("positionLocal"),s8=s4.toVarying("positionPrevious"),s5=eF(e=>sj.mul(s6).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),s9=eF(()=>s6.transformDirection(sj).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),s7=eF(e=>e.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),ne=s7.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class nt extends D{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";let{material:t}=e;return t.side===u.hsX?"false":e.getFrontFacing()}}let nr=eM(nt),ni=eG(nr).mul(2).sub(1),ns=eF(([e],{material:t})=>{let r=t.side;return r===u.hsX?e=e.mul(-1):r===u.$EB&&(e=e.mul(ni)),e}),nn=i7("normal","vec3"),na=eF(e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),eX(0,1,0)):nn,"vec3").once()().toVar("normalLocal"),no=s7.dFdx().cross(s7.dFdy()).normalize().toVar("normalFlat"),nl=eF(e=>!0===e.material.flatShading?no:ng(na).toVarying("v_normalViewGeometry").normalize(),"vec3").once()().toVar("normalViewGeometry"),nu=eF(e=>{let t=nl.transformDirection(sL);return!0!==e.material.flatShading&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),nd=eF(({subBuildFn:e,material:t,context:r})=>{let i;return"NORMAL"===e||"VERTEX"===e?(i=nl,!0!==t.flatShading&&(i=ns(i))):i=r.setupNormal().context({getUV:null}),i},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),nh=nd.transformDirection(sL).toVar("normalWorld"),nc=eF(({subBuildFn:e,context:t})=>"NORMAL"===e||"VERTEX"===e?nd:t.setupClearcoatNormal().context({getUV:null}),"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),np=eF(([e,t=sj])=>{let r=e3(t),i=e.div(eX(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(i).xyz}),ng=eF(([e],t)=>{let r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);let i=sZ.mul(e);return sL.transformDirection(i)}),nm=eF(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),nd)).once(["NORMAL","VERTEX"])(),nf=eF(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),nh)).once(["NORMAL","VERTEX"])(),ny=eF(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),nc)).once(["NORMAL","VERTEX"])(),nb=new u.O9p,nx=new u.kn4,nT=tU(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),n_=tU(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),nv=tU(new u.kn4).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let r=null!==t.environment&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?(nb.copy(r),nx.makeRotationFromEuler(nb)):nx.identity(),nx}),nN=ne.negate().reflect(nd),nS=ne.negate().refract(nd,nT),nR=nN.transformDirection(sL).toVar("reflectVector"),nA=nS.transformDirection(sL).toVar("reflectVector"),nE=new u.b4q;class nC extends sa{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,i=null){super(e,t,r,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){let e=this.value;return e.mapping===u.hy7?nR:e.mapping===u.xFO?nA:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),eX(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let r=this.value;return e.renderer.coordinateSystem!==u.i7u&&r.isRenderTargetTexture||(t=eX(t.x.negate(),t.yz)),nv.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}let nw=ew(nC).setParameterLength(1,4).setName("cubeTexture"),nM=(e=nE,t=null,r=null,i=null)=>{let s;return e&&!0===e.isCubeTextureNode?((s=eR(e.clone())).referenceNode=e,null!==t&&(s.uvNode=eR(t)),null!==r&&(s.levelNode=eR(r)),null!==i&&(s.biasNode=eR(i))):s=nw(e,t,r,i),s};
4class nB extends O{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),r=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,r,i)}}class nL extends D{static get type(){return"ReferenceNode"}constructor(e,t,r=null,i=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=i,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=w.OBJECT}element(e){return eR(new nB(this,eR(e)))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;t=null!==this.count?sh(null,e,this.count):Array.isArray(this.getValueFromReference())?sg(null,e):"texture"===e?sl(null):"cubeTexture"===e?nM(null):tU(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t}getNodeType(e){return null===this.node&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){let{properties:t}=this,r=e[t[0]];for(let e=1;e<t.length;e++)r=r[t[e]];return r}updateReference(e){return this.reference=null!==this.object?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){null===this.node&&this.setNodeType(this.uniformType);let e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}let nP=(e,t,r)=>eR(new nL(e,t,r)),nF=(e,t,r,i)=>eR(new nL(e,t,i,r));class nU extends nL{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}let nI=(e,t,r=null)=>eR(new nU(e,t,r)),nD=se(),nO=s7.dFdx(),nV=s7.dFdy(),nG=nD.dFdx(),nk=nD.dFdy(),nz=nV.cross(nd),n$=nd.cross(nO),nH=nz.mul(nG.x).add(n$.mul(nk.x)),nW=nz.mul(nG.y).add(n$.mul(nk.y)),nq=nH.dot(nH).max(nW.dot(nW)),nj=nq.equal(0).select(0,nq.inverseSqrt()),nX=nH.mul(nj).toVar("tangentViewFrame"),nK=nW.mul(nj).toVar("bitangentViewFrame"),nQ=eF(e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),i7("tangent","vec4")))(),nY=nQ.xyz.toVar("tangentLocal"),nZ=eF(({subBuildFn:e,geometry:t,material:r})=>{let i;return i="VERTEX"===e||t.hasAttribute("tangent")?s0.mul(eZ(nY,0)).xyz.toVarying("v_tangentView").normalize():nX,!0!==r.flatShading&&(i=ns(i)),i},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),nJ=nZ.transformDirection(sL).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),n0=eF(([e,t],{subBuildFn:r,material:i})=>{let s=e.mul(nQ.w).xyz;return"NORMAL"===r&&!0!==i.flatShading&&(s=s.toVarying(t)),s}).once(["NORMAL"]),n1=n0(nn.cross(nQ),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),n2=n0(na.cross(nY),"v_bitangentLocal").normalize().toVar("bitangentLocal"),n3=eF(({subBuildFn:e,geometry:t,material:r})=>{let i;return i="VERTEX"===e||t.hasAttribute("tangent")?n0(nd.cross(nZ),"v_bitangentView").normalize():nK,!0!==r.flatShading&&(i=ns(i)),i},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),n4=n0(nh.cross(nJ),"v_bitangentWorld").normalize().toVar("bitangentWorld"),n6=e3(nZ,n3,nd).toVar("TBNViewMatrix"),n8=ne.mul(n6),n5=eF(()=>{let e=tg.cross(ne);return r5(e=e.cross(tg).normalize(),nd,tc.mul(tr.oneMinus()).oneMinus().pow2().pow2()).normalize()}).once()();class n9 extends G{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=u.bI3}setup({material:e}){let{normalMapType:t,scaleNode:r}=this,i=this.node.mul(2).sub(1);if(null!==r){let t=r;!0===e.flatShading&&(t=ns(t)),i=eX(i.xy.mul(t),i.z)}let s=null;return t===u.vyJ?s=ng(i):t===u.bI3?s=n6.mul(i).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),s=nd),s}}let n7=ew(n9).setParameterLength(1,2),ae=eF(({textureNode:e,bumpScale:t})=>{let r=t=>e.cache().context({getUV:e=>t(e.uvNode||se()),forceUVContext:!0}),i=eG(r(e=>e));return eH(eG(r(e=>e.add(e.dFdx()))).sub(i),eG(r(e=>e.add(e.dFdy()))).sub(i)).mul(t)}
4),at=eF(e=>{let{surf_pos:t,surf_norm:r,dHdxy:i}=e,s=t.dFdx().normalize(),n=t.dFdy().normalize().cross(r),a=r.cross(s),o=s.dot(n).mul(ni),l=o.sign().mul(i.x.mul(n).add(i.y.mul(a)));return o.abs().mul(r).sub(l).normalize()});class ar extends G{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){let e=null!==this.scaleNode?this.scaleNode:1;return at({surf_pos:s7,surf_norm:nd,dHdxy:ae({textureNode:this.textureNode,bumpScale:e})})}}let ai=ew(ar).setParameterLength(1,2),as=new Map;class an extends D{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=as.get(e);return void 0===r&&(r=nI(e,t),as.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){let t=e.context.material,r=this.scope,i=null;if(r===an.COLOR){let e=void 0!==t.color?this.getColor(r):eX();i=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===an.OPACITY){let e=this.getFloat(r);i=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===an.SPECULAR_STRENGTH)i=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:eG(1);else if(r===an.SPECULAR_INTENSITY){let e=this.getFloat(r);i=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===an.SPECULAR_COLOR){let e=this.getColor(r);i=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===an.ROUGHNESS){let e=this.getFloat(r);i=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===an.METALNESS){let e=this.getFloat(r);i=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===an.EMISSIVE){let e=this.getFloat("emissiveIntensity"),s=this.getColor(r).mul(e);i=t.emissiveMap&&!0===t.emissiveMap.isTexture?s.mul(this.getTexture(r)):s}else if(r===an.NORMAL)t.normalMap?(i=n7(this.getTexture("normal"),this.getCache("normalScale","vec2"))).normalMapType=t.normalMapType:i=t.bumpMap?ai(this.getTexture("bump").r,this.getFloat("bumpScale")):nd;else if(r===an.CLEARCOAT){let e=this.getFloat(r);i=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===an.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===an.CLEARCOAT_NORMAL)i=t.clearcoatNormalMap?n7(this.getTexture(r),this.getCache(r+"Scale","vec2")):nd;else if(r===an.SHEEN){let e=this.getColor("sheenColor").mul(this.getFloat("sheen"));i=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(r===an.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=(i=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e).clamp(.07,1)}else if(r===an.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){let e=this.getTexture(r);i=e2(a$.x,a$.y,a$.y.negate(),a$.x).mul(e.rg.mul(2).sub(eH(1)).normalize().mul(e.b))}else i=a$;else if(r===an.IRIDESCENCE_THICKNESS){let e=nP("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){let s=nP("0","float",t.iridescenceThicknessRange);i=e.sub(s).mul(this.getTexture(r).g).add(s)}else i=e}else if(r===an.TRANSMISSION){let e=this.getFloat(r);i=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===an.THICKNESS){let e=this.getFloat(r);i=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===an.IOR)i=this.getFloat(r);else if(r===an.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===an.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===an.LINE_DASH_OFFSET)i=t.dashOffset?this.getFloat(r):eG(0);else{let t=this.getNodeType(e);i=this.getCache(r,t)}return i}}an.ALPHA_TEST="alphaTest",an.COLOR="color",an.OPACITY="opacity",an.SHININESS="shininess",an.SPECULAR="specular",an.SPECULAR_STRENGTH="specularStrength",an.SPECULAR_INTENSITY="specularIntensity",an.SPECULAR_COLOR="specularColor",an.REFLECTIVITY="reflectivity",an.ROUGHNESS="roughness",an.METALNESS="metalness",an.NORMAL="normal",an.CLEARCOAT="clearcoat",an.CLEARCOAT_ROUGHNESS="clearcoatRoughness",an.CLEARCOAT_NORMAL="clearcoatNormal",an.EMISSIVE="emissive",an.ROTATION="rotation",an.SHEEN="sheen",an.SHEEN_ROUGHNESS="sheenRoughness",an.ANISOTROPY="anisotropy",an.IRIDESCENCE="iridescence",an.IRIDESCENCE_IOR="iridescenceIOR",an.IRIDESCENCE_THICKNESS="iridescenceThickness",an.IOR="ior",an.TRANSMISSION="transmission",an.THICKNESS="thickness",an.ATTENUATION_DISTANCE="attenuationDistance",an.ATTENUATION_COLOR="attenuationColor",an.LINE_SCALE="scale",an.LINE_DASH_SIZE="dashSize",an.LINE_GAP_SIZE="gapSize",an.LINE_WIDTH="linewidth",an.LINE_DASH_OFFSET="dashOffset",an.POINT_SIZE="size",an.DISPERSION="dispersion",an.LIGHT_MAP="light",an.AO="ao";let aa=eM(an,an.ALPHA_TEST),ao=eM(an,an.COLOR),al=eM(an,an.SHININESS),au=eM(an,an.EMISSIVE),ad=eM(an,an.OPACITY),ah=eM(an,an.SPECULAR),ac=eM(an,an.SPECULAR_INTENSITY),ap=eM(an,an.SPECULAR_COLOR),ag=eM(an,an.SPECULAR_STRENGTH),am=eM(an,an.REFLECTIVITY),af=eM(an,an.ROUGHNESS),ay=eM(an,an.METALNESS),ab=eM(an,an.NORMAL),ax=eM(an,an.CLEARCOAT),aT=eM(an,an.CLEARCOAT_ROUGHNESS),a_=eM(an,an.CLEARCOAT_NORMAL),av=eM(an,an.ROTATION),aN=eM(an,an.SHEEN),aS=eM(an,an.SHEEN_ROUGHNESS),aR=eM(an,an.ANISOTROPY),aA=eM(an,an.IRIDESCENCE),aE=eM(an,an.IRIDESCENCE_IOR),aC=eM(an,an.IRIDESCENCE_THICKNESS),aw=eM(an,an.TRANSMISSION),aM=eM(an,an.THICKNESS),aB=eM(an,an.IOR),aL=eM(an,an.ATTENUATION_DISTANCE),aP=eM(an,an.ATTENUATION_COLOR),aF=eM(an,an.LINE_SCALE),aU=eM(an,an.LINE_DASH_SIZE),aI=eM(an,an.LINE_GAP_SIZE),aD=eM(an,an.LINE_WIDTH),aO=eM(an,an.LINE_DASH_OFFSET),aV=eM(an,an.POINT_SIZE),aG=eM(an,an.DISPERSION),ak=eM(an,an.LIGHT_MAP),az=eM(an,an.AO),a$=tU(new u.I9Y).onReference(function(e){return e.material}
4).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),aH=eF(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class aW extends D{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){let t,r=this.getNodeType(e),i=this.scope;if(i===aW.VERTEX)t=e.getVertexIndex();else if(i===aW.INSTANCE)t=e.getInstanceIndex();else if(i===aW.DRAW)t=e.getDrawIndex();else if(i===aW.INVOCATION_LOCAL)t=e.getInvocationLocalIndex();else if(i===aW.INVOCATION_SUBGROUP)t=e.getInvocationSubgroupIndex();else if(i===aW.SUBGROUP)t=e.getSubgroupIndex();else throw Error("THREE.IndexNode: Unknown scope: "+i);return"vertex"===e.shaderStage||"compute"===e.shaderStage?t:iR(this).build(e,r)}}aW.VERTEX="vertex",aW.INSTANCE="instance",aW.SUBGROUP="subgroup",aW.INVOCATION_LOCAL="invocationLocal",aW.INVOCATION_SUBGROUP="invocationSubgroup",aW.DRAW="draw";let aq=eM(aW,aW.VERTEX),aj=eM(aW,aW.INSTANCE),aX=eM(aW,aW.SUBGROUP),aK=eM(aW,aW.INVOCATION_SUBGROUP),aQ=eM(aW,aW.INVOCATION_LOCAL),aY=eM(aW,aW.DRAW);class aZ extends D{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=w.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{instanceMatrix:t,instanceColor:r}=this,{count:i}=t,{instanceMatrixNode:s,instanceColorNode:n}=this;if(null===s){if(i<=1e3)s=sh(t.array,"mat4",Math.max(i,1)).element(aj);else{let e=new u.LuO(t.array,16,1);this.buffer=e;let r=t.usage===u.Vnu?iH:i$;s=e4(r(e,"vec4",16,0),r(e,"vec4",16,4),r(e,"vec4",16,8),r(e,"vec4",16,12))}this.instanceMatrixNode=s}if(r&&null===n){let e=new u.uWO(r.array,3),t=r.usage===u.Vnu?iH:i$;this.bufferColor=e,n=eX(t(e,"vec3",3,0)),this.instanceColorNode=n}let a=s.mul(s6).xyz;if(s6.assign(a),e.hasGeometryAttribute("normal")){let e=np(na,s);na.assign(e)}null!==this.instanceColorNode&&e7("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==u.Vnu&&null!==this.buffer&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==u.Vnu&&null!==this.bufferColor&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}let aJ=ew(aZ).setParameterLength(2,3);class a0 extends aZ{static get type(){return"InstancedMeshNode"}
4constructor(e){let{count:t,instanceMatrix:r,instanceColor:i}=e;super(t,r,i),this.instancedMesh=e}}let a1=ew(a0).setParameterLength(1);class a2 extends D{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=aj:this.batchingIdNode=aY);let t=eF(([e])=>{let t=ek(sr(su(this.batchMesh._indirectTexture),0).x),r=ek(e).mod(t),i=ek(e).div(t);return su(this.batchMesh._indirectTexture,eW(r,i)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(ek(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=ek(sr(su(r),0).x),s=eG(t).mul(4).toInt().toVar(),n=s.mod(i),a=s.div(i),o=e4(su(r,eW(n,a)),su(r,eW(n.add(1),a)),su(r,eW(n.add(2),a)),su(r,eW(n.add(3),a))),l=this.batchMesh._colorsTexture;if(null!==l){let e=eF(([e])=>{let t=ek(sr(su(l),0).x);return su(l,eW(e.mod(t),e.div(t))).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);e7("vec3","vBatchColor").assign(e)}let u=e3(o);s6.assign(o.mul(s6));let d=na.div(eX(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),h=u.mul(d).xyz;na.assign(h),e.hasGeometryAttribute("tangent")&&nY.mulAssign(u)}}let a3=ew(a2).setParameterLength(1);class a4 extends O{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 r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return!1===e.isAvailable("storageBuffer")&&!0===this.node.isPBO&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r,i=e.context.assign;if(r=!1===e.isAvailable("storageBuffer")?!0===this.node.isPBO&&!0!==i&&(this.node.value.isInstancedBufferAttribute||"compute"!==e.shaderStage)?e.generatePBO(this):this.node.build(e):super.generate(e),!0!==i){let i=this.getNodeType(e);r=e.format(r,i,t)}return r}}let a6=ew(a4).setParameterLength(2);class a8 extends sd{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let i,s=null;if(t&&t.isStruct)i="struct",s=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count);else if(null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)){var n;n=e.itemSize,i=x.get(n),r=e.count}else i=t;super(e,i,r),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=M.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(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 a6(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(M.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=ik(this.value),this._varying=iR(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(null!==this.structTypeNode)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 null!==this.structTypeNode?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(null!==this.structTypeNode&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);let{attribute:t,varying:r}=this.getAttributeData(),i=r.build(e);return e.registerTransform(i,t),i}}let a5=(e,t=null,r=0)=>eR(new a8(e,t,r)),a9=new WeakMap;class a7 extends D{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=w.OBJECT,this.skinIndexNode=i7("skinIndex","uvec4"),this.skinWeightNode=i7("skinWeight","vec4"),this.bindMatrixNode=nP("bindMatrix","mat4"),this.bindMatrixInverseNo
4de=nP("bindMatrixInverse","mat4"),this.boneMatricesNode=nF("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=s6,this.toPositionNode=s6,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){let{skinIndexNode:r,skinWeightNode:i,bindMatrixNode:s,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),l=e.element(r.z),u=e.element(r.w),d=s.mul(t),h=tH(a.mul(i.x).mul(d),o.mul(i.y).mul(d),l.mul(i.z).mul(d),u.mul(i.w).mul(d));return n.mul(h).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=na){let{skinIndexNode:r,skinWeightNode:i,bindMatrixNode:s,bindMatrixInverseNode:n}=this,a=e.element(r.x),o=e.element(r.y),l=e.element(r.z),u=e.element(r.w),d=tH(i.x.mul(a),i.y.mul(o),i.z.mul(l),i.w.mul(u));return(d=n.mul(d).mul(s)).transformDirection(t).xyz}getPreviousSkinnedPosition(e){let t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=nF("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,s8)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has("velocity")||!0===R(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&s8.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){let t=this.getSkinnedNormal();na.assign(t),e.hasGeometryAttribute("tangent")&&nY.assign(t)}return t}generate(e,t){if("void"!==t)return super.generate(e,t)}update(e){let t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;a9.get(t)!==e.frameId&&(a9.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}let oe=e=>eR(new a7(e));class ot extends D{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(void 0!==t.stackNode)return t;let r={};for(let e=0,t=this.params.length-1;e<t;e++){let t=this.params[e],i=!0!==t.isNode&&t.name||this.getVarName(e),s=!0!==t.isNode&&t.type||"int";r[i]=i2(i,s)}let i=e.addStack();t.returnsNode=this.params[this.params.length-1](r,e),t.stackNode=i;let s=this.params[0];return!0!==s.isNode&&"function"==typeof s.update&&(t.updateNode=eF(this.params[0].update)(r)),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),r=this.params,i=t.stackNode;for(let i=0,s=r.length-1;i<s;i++){let s,n=r[i],a=!1,o=null,l=null,u=null,d=null,h=null,c=null;if(n.isNode?"bool"===n.getNodeType(e)?(a=!0,d="bool",l=n.build(e,d)):(d="int",u=this.getVarName(i),o="0",l=n.build(e,d),h="<"):(d=n.type||"int",u=n.name||this.getVarName(i),o=n.start,l=n.end,h=n.condition,c=n.update,"number"==typeof o?o=e.generateConst(d,o):o&&o.isNode&&(o=o.build(e,d)),"number"==typeof l?l=e.generateConst(d,l):l&&l.isNode&&(l=l.build(e,d)),void 0!==o&&void 0===l?(o+=" - 1",l="0",h=">="):void 0!==l&&void 0===o&&(o="0",h="<"),void 0===h&&(h=Number(o)>Number(l)?">=":"<")),a)s=`while ( ${l} )`;else{let r,i=o,n=l,a=()=>h.includes("<")?"+=":"-=";if(null!=c)switch(typeof c){case"function":r=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":r=u+" "+a()+" "+e.generateConst(d,c);break;case"string":r=u+" "+c;break;default:c.isNode?r=u+" "+a()+" "+c.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),r="break /* invalid update */")}else r=u+" "+(c="int"===d||"uint"===d?h.includes("<")?"++":"--":a()+" 1.");let p=e.getVar(d,u)+" = "+i,g=u+" "+h+" "+n;s=`for ( ${p}; ${g}; ${r} )`}e.addFlowCode((0===i?"\n":"")+e.tab+s+" {\n\n").addFlowTab()}let s=i.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+s);for(let t=0,r=this.params.length-1;t<r;t++)e.addFlowCode((0===t?"":e.tab)+"}\n\n").removeFlowTab();return e.addFlowTab(),n}}let or=(...e)=>eR(new ot(eC(e,"int"))).toStack(),oi=()=>i2("break").toStack(),os=new WeakMap,on=new u.IUQ,oa=eF(({bufferMap:e,influence:t,stride:r,width:i,depth:s,offset:n})=>{let a=ek(aq).mul(r).add(n),o=a.div(i);return su(e,eW(a.sub(o.mul(i)),o)).depth(s).xyz.mul(t)});class oo extends D{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=tU(1),this.updateType=w.OBJECT}setup(e){let{geometry:t}=e,r=void 0!==t.morphAttributes.position,i=t.hasAttribute("normal")&&void 0!==t.morphAttributes.normal,s=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,n=void 0!==s?s.length:0,{texture:a,stride:o,size:l}=function(e){let t=void 0!==e.morphAttributes.position,r=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,s=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,n=void 0!==s?s.length:0,a=os.get(e);if(void 0===a||a.count!==n){void 0!==a&&a.texture.dispose();let s=e.morphAttributes.position||[],o=e.morphAttributes.normal||[],l=e.morphAttributes.color||[],d=0;!0===t&&(d=1),!0===r&&(d=2),!0===i&&(d=3);let h=e.attributes.position.count*d,c=1;h>4096&&(c=Math.ceil(h/4096),h=4096);let p=new Float32Array(h*c*4*n),g=new u.rFo(p,h,c,n);g.type=u.RQf,g.needsUpdate=!0;let m=4*d;for(let e=0;e<n;e++){let n=s[e],a=o[e],u=l[e],d=h*c*4*e;for(let e=0;e<n.count;e++){let s=e*m;!0===t&&(on.fromBufferAttribute(n,e),p[d+s+0]=on.x,p[d+s+1]=on.y,p[d+s+2]=on.z,p[d+s+3]=0),!0===r&&(on.fromBufferAttribute(a,e),p[d+s+4]=on.x,p[d+s+5]=on.y,p[d+s+6]=on.z,p[d+s+7]=0),!0===i&&(on.fromBufferAttribute(u,e),p[d+s+8]=on.x,p[d+s+9]=on.y,p[d+s+10]=on.z,p[d+s+11]=4===u.itemSize?on.w:1)}}a={count:n,texture:g,stride:d,size:new u.I9Y(h,c)},os.set(e,a),e.addEventListener("dispose",function t(){g.dispose(),os.delete(e),e.removeEventListener("dispose",t)})}return a}(t);!0===r&&s6.mulAssign(this.morphBaseInfluence),!0===i&&na.mulAssign(this.morphBaseInfluence);let d=ek(l.width);or(n,({i:e})=>{let t=eG(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(su(this.mesh.morphTexture,eW(ek(e).add(1),ek(aj))).r):t.assign(nP("morphTargetInfluences","float").element
4(e).toVar()),eD(t.notEqual(0),()=>{!0===r&&s6.addAssign(oa({bufferMap:a,influence:t,stride:o,width:d,depth:e,offset:ek(0)})),!0===i&&na.addAssign(oa({bufferMap:a,influence:t,stride:o,width:d,depth:e,offset:ek(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)}}let ol=ew(oo).setParameterLength(1);class ou extends D{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class od extends ou{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class oh extends ih{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,i=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=i,this._value=null}getContext(){let{backdropNode:e,backdropAlphaNode:t}=this,r=eX().toVar("directDiffuse"),i=eX().toVar("directSpecular"),s=eX().toVar("indirectDiffuse"),n=eX().toVar("indirectSpecular");return{radiance:eX().toVar("radiance"),irradiance:eX().toVar("irradiance"),iblIrradiance:eX().toVar("iblIrradiance"),ambientOcclusion:eG(1).toVar("ambientOcclusion"),reflectedLight:{directDiffuse:r,directSpecular:i,indirectDiffuse:s,indirectSpecular:n},backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}let oc=ew(oh);class op extends ou{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let og=new u.I9Y;class om extends sa{static get type(){return"ViewportTextureNode"}constructor(e=sx,t=null,r=null){let i=null;null===r?((i=new u.Pem).minFilter=u.$_I,r=i):i=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=i,this.isOutputTextureNode=!0,this.updateBeforeType=w.FRAME,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),null===e)return t;if(!1===r.has(e)){let i=t.clone();r.set(e,i)}return r.get(e)}updateReference(e){let t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){let t=e.renderer,r=t.getRenderTarget();null===r?t.getDrawingBufferSize(og):og.set(r.width,r.height);let i=this.getTextureForReference(r);(i.image.width!==og.width||i.image.height!==og.height)&&(i.image.width=og.width,i.image.height=og.height,i.needsUpdate=!0);let s=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=s}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}let of=ew(om).setParameterLength(0,3),oy=ew(om,null,null,{generateMipmaps:!0}).setParameterLength(0,3),ob=null;class ox extends om{static get type(){return"ViewportDepthTextureNode"}constructor(e=sx,t=null){null===ob&&(ob=new u.VCu),super(e,t,ob)}getTextureForReference(){return ob}}let oT=ew(ox).setParameterLength(0,2);class o_ extends D{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){let{scope:t}=this;return t===o_.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){let{scope:t}=this,r=this.valueNode,i=null;return t===o_.DEPTH_BASE?null!==r&&(i=oA().assign(r)):t===o_.DEPTH?i=e.isPerspectiveCamera?oN(s7.z,sC,sw):ov(s7.z,sC,sw):t===o_.LINEAR_DEPTH&&(i=null!==r?e.isPerspectiveCamera?ov(oS(r,sC,sw),sC,sw):r:ov(s7.z,sC,sw)),i}}o_.DEPTH_BASE="depthBase",o_.DEPTH="depth",o_.LINEAR_DEPTH="linearDepth";let ov=(e,t,r)=>e.add(t).div(t.sub(r)),oN=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),oS=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),oR=(e,t,r)=>{t=t.max(1e-6).toVar();let i=rb(e.negate().div(t)),s=rb(r.div(t));return i.div(s)},oA=ew(o_,o_.DEPTH_BASE),oE=eM(o_,o_.DEPTH),oC=ew(o_,o_.LINEAR_DEPTH).setParameterLength(0,1),ow=oC(oT());oE.assign=e=>oA(e);class oM extends D{static get type(){return"ClippingNode"}constructor(e=oM.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);let{intersectionPlanes:t,unionPlanes:r}=e.clippingContext;return(this.hardwareClipping=e.material.hardwareClipping,this.scope===oM.ALPHA_TO_COVERAGE)?this.setupAlphaToCoverage(t,r):this.scope===oM.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(t,r)}setupAlphaToCoverage(e,t){return eF(()=>{let r=eG().toVar("distanceToPlane"),i=eG().toVar("distanceToGradient"),s=eG(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){let e=sg(t).setGroup(tL);or(n,({i:t})=>{let n=e.element(t);r.assign(s7.dot(n.xyz).negate().add(n.w)),i.assign(r.fwidth().div(2)),s.mulAssign(it(i.negate(),i,r))})}let a=e.length;if(a>0){let t=sg(e).setGroup(tL),n=eG(1).toVar("intersectionClipOpacity");or(a,({i:e})=>{let s=t.element(e);r.assign(s7.dot(s.xyz).negate().add(s.w)),i.assign(r.fwidth().div(2)),n.mulAssign(it(i.negate(),i,r).oneMinus())}),s.mulAssign(n.oneMinus())}te.a.mulAssign(s),te.a.equal(0).discard()})()}setupDefault(e,t){return eF(()=>{let r=t.length;if(!1===this.hardwareClipping&&r>0){let e=sg(t).setGroup(tL);or(r,({i:t})=>{let r=e.element(t);s7.dot(r.xyz).greaterThan(r.w).discard()})}let i=e.length;if(i>0){let t=sg(e).setGroup(tL),r=e$(!0).toVar("clipped");or(i,({i:e})=>{let i=t.element(e);r.assign(s7.dot(i.xyz).greaterThan(i.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){let r=e.length;return t.enableHardwareClipping(r),eF(()=>{let i=sg(e).setGroup(tL),s=sf(t.getClipDistance());or(r,({i:e})=>
4{let t=i.element(e),r=s7.dot(t.xyz).sub(t.w).negate();s.element(e).assign(r)})})()}}oM.ALPHA_TO_COVERAGE="alphaToCoverage",oM.DEFAULT="default",oM.HARDWARE="hardware";let oB=eF(([e])=>rS(tq(1e4,rR(tq(17,e.x).add(tq(.1,e.y)))).mul(tH(.1,rB(rR(tq(13,e.y).add(e.x))))))),oL=eF(([e])=>oB(eH(oB(e.xy),e.z))),oP=eF(([e])=>{let t=rj(rP(rI(e.xyz)),rP(rD(e.xyz))),r=eG(1).div(eG(.05).mul(t)).toVar("pixScale"),i=eH(rf(r_(rb(r))),rf(rv(rb(r)))),s=eH(oL(r_(i.x.mul(e.xyz))),oL(r_(i.y.mul(e.xyz)))),n=rS(rb(r)),a=tH(tq(n.oneMinus(),s.x),tq(n,s.y)),o=rq(n,n.oneMinus()),l=eX(a.mul(a).div(tq(2,o).mul(tW(1,o))),a.sub(tq(.5,o)).div(tW(1,o)),tW(1,tW(1,a).mul(tW(1,a)).div(tq(2,o).mul(tW(1,o)))));return r9(a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z),1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class oF extends i9{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);return!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new u.IUQ(1,1,1,1))}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}let oU=(e=0)=>eR(new oF(e)),oI=eF(([e,t])=>rq(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oD=eF(([e,t])=>rq(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oO=eF(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oV=eF(([e,t])=>r5(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),rX(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oG=eF(([e,t])=>{let r=t.a.add(e.a.mul(t.a.oneMinus()));return eZ(t.rgb.mul(t.a).add(e.rgb.mul(e.a).mul(t.a.oneMinus())).div(r),r)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),ok=eF(([e])=>eZ(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),oz=eF(([e])=>(eD(e.a.equal(0),()=>eZ(0)),eZ(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class o$ extends u.imn{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+y(this)}build(e){this.setup(e)}setupObserver(e){return new c(e)}setup(e){let t;e.context.setupNormal=()=>iN(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);let r=e.renderer,i=r.getRenderTarget();e.addStack();let s=iN(this.setupVertex(e),"VERTEX"),n=this.vertexNode||s;e.stack.outputNode=n,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a=this.setupClipping(e);if((!0===this.depthWrite||!0===this.depthTest)&&(null!==i?!0===i.depthBuffer&&this.setupDepth(e):!0===r.depth&&this.setupDepth(e)),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);let s=this.setupLighting(e);null!==a&&e.stack.add(a);let n=eZ(s,te.a).max(0);t=this.setupOutput(e,n),tb.assign(t);let o=null!==this.outputNode;
4if(o&&(t=this.outputNode),null!==i){let e=r.getMRT(),i=this.mrtNode;null!==e?(o&&tb.assign(t),t=e,null!==i&&(t=e.merge(i))):null!==i&&(t=i)}}else{let r=this.fragmentNode;!0!==r.isOutputStructNode&&(r=eZ(r)),t=this.setupOutput(e,r)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(null===e.clippingContext)return null;let{unionPlanes:t,intersectionPlanes:r}=e.clippingContext,i=null;if(t.length>0||r.length>0){let t=e.renderer.samples;this.alphaToCoverage&&t>1?i=eR(new oM(oM.ALPHA_TO_COVERAGE)):e.stack.add(eR(new oM))}return i}setupHardwareClipping(e){if(this.hardwareClipping=!1,null===e.clippingContext)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.add(eR(new oM(oM.HARDWARE))),this.hardwareClipping=!0)}setupDepth(e){let{renderer:t,camera:r}=e,i=this.depthNode;if(null===i){let e=t.getMRT();e&&e.has("depth")?i=e.get("depth"):!0===t.logarithmicDepthBuffer&&(i=r.isPerspectiveCamera?oR(s7.z,sC,sw):ov(s7.z,sC,sw))}null!==i&&oE.assign(i).toStack()}setupPositionView(){return s0.mul(s6).xyz}setupModelViewProjection(){return sM.mul(s7)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),aH}setupPosition(e){let{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&ol(t).toStack(),!0===t.isSkinnedMesh&&oe(t).toStack(),this.displacementMap){let e=nI("displacementMap","texture"),t=nI("displacementScale","float"),r=nI("displacementBias","float");s6.addAssign(na.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&a3(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&a1(t).toStack(),null!==this.positionNode&&s6.assign(iN(this.positionNode,"POSITION","vec3")),s6}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&e$(this.maskNode).not().discard();let r=this.colorNode?eZ(this.colorNode):ao;!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul(oU())),e.instanceColor&&(r=e7("vec3","vInstanceColor").mul(r)),e.isBatchedMesh&&e._colorsTexture&&(r=e7("vec3","vBatchColor").mul(r)),te.assign(r);let i=this.opacityNode?eG(this.opacityNode):ad;te.a.assign(te.a.mul(i));let s=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(s=null!==this.alphaTestNode?eG(this.alphaTestNode):aa,te.a.lessThanEqual(s).discard()),!0===this.alphaHash&&te.a.lessThan(oP(s6)).discard(),!1===this.transparent&&this.blending===u.NTi&&!1===this.alphaToCoverage?te.a.assign(1):null===s&&te.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?eX(0):te.rgb}setupNormal(){return this.normalNode?eX(this.normalNode):ab}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?nI("envMap","cubeTexture"):nI("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new op(ak)),t}setupLights(e){let t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);let i=this.setupLightMap(e);if(i&&i.isLightingNode&&t.push(i),null!==this.aoNode||e.material.aoMap){let e=null!==this.aoNode?this.aoNode:az;t.push(new od(e))}let s=this.lightsNode||e.lightsNode;return t.length>0&&(s=e.renderer.lighting.createNode([...s.getLights(),...t])),s}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:r,backdropAlphaNode:i,emissiveNode:s}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null,a=this.setupOutgoingLight(e);return n&&n.getScope().hasLights?a=oc(n,this.setupLightingModel(e)||null,r,i):null!==r&&(a=eX(null!==i?r5(a,r,i):r)),(s&&!0===s.isNode||t.emissive&&!0===t.emissive.isColor)&&(tt.assign(eX(s||au)),a=a.add(tt)),a}setupFog(e,t){let r=e.fogNode;return r&&(tb.assign(t),t=eZ(r.toVar())),t}setupPremultipliedAlpha(e,t){return ok(t)}setupOutput(e,t){return!0===this.fog&&(t=this.setupFog(e,t)),!0===this.premultipliedAlpha&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(let t in e){let r=e[t];void 0===this[t]&&(this[t]=r,r&&r.clone&&(this[t]=r.clone()))}let t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(let e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});let r=u.imn.prototype.toJSON.call(this,e),i=b(this);for(let{property:t,childNode:s}of(r.inputNodes={},i))r.inputNodes[t]=s.toJSON(e).uuid;function s(e){let t=[];for(let r in e){let i=e[r];delete i.metadata,t.push(i)}return t}if(t){let t=s(e.textures),i=s(e.images),n=s(e.nodes);t.length>0&&(r.textures=t),i.length>0&&(r.images=i),n.length>0&&(r.nodes=n)}return r}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 oH=new u.mrM;class oW extends o${static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(oH),this.setValues(e)}}let oq=new u.Fvt;class oj extends o${static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(oq),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?eG(this.offsetNode):aO,t=this.dashScaleNode?eG(this.dashScaleNode):aF,r=this.dashSizeNode?eG(this.dashSizeNode):aU,i=this.gapSizeNode?eG(this.gapSizeNode):aI;tx.assign(r),tT.assign(i);let s=iR(i7("lineDistance").mul(t));(e?s.add(e):s).mod(tx.add(tT)).greaterThan(tx).discard()}}let oX=null;class oK extends om{static get type(){return"ViewportSharedTextureNode"}constructor(e=sx,t=null){null===oX&&(oX=new u.Pem),super(e,t,oX)}getTextureForReference(){return oX}updateReference(){return this}}let oQ=ew(oK).setParameterLength(0,2),oY=e=>eR(e).mul(.5).add(.5),oZ=new u.qBx;class oJ extends o${static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(oZ),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?eG(this.opacityNode):ad;te.assign(iL(eZ(oY(nd),e),u.er$))}}let o0=eF(([e=s9])=>eH(e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5)));class o1 extends u.o6l{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){let r=t.minFilter,i=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace
4=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let s=new u.iNn(5,5,5),n=o0(s9),a=new o$;a.colorNode=sl(t,n,0),a.side=u.hsX,a.blending=u.XIg;let o=new u.eaF(s,a),l=new u.Z58;l.add(o),t.minFilter===u.$_I&&(t.minFilter=u.k6q);let d=new u.F1T(1,10,this),h=e.getMRT();return e.setMRT(null),d.update(e,l),e.setMRT(h),t.minFilter=r,t.currentGenerateMipmaps=i,o.geometry.dispose(),o.material.dispose(),this}}let o2=new WeakMap;class o3 extends G{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=nM(null);let t=new u.b4q;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=w.RENDER}updateBefore(e){let{renderer:t,material:r}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){let e=i.isTextureNode?i.value:r[i.property];if(e&&e.isTexture){let r=e.mapping;if(r===u.wfO||r===u.uV5){if(o2.has(e)){let t=o2.get(e);o6(t,e.mapping),this._cubeTexture=t}else{var s;let r=e.image;if(null!=(s=r)&&s.height>0){let i=new o1(r.height);i.fromEquirectangularTexture(t,e),o6(i.texture,e.mapping),this._cubeTexture=i.texture,o2.set(e,i.texture),e.addEventListener("dispose",o4)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function o4(e){let t=e.target;t.removeEventListener("dispose",o4);let r=o2.get(t);void 0!==r&&(o2.delete(t),r.dispose())}function o6(e,t){t===u.wfO?e.mapping=u.hy7:t===u.uV5&&(e.mapping=u.xFO)}let o8=ew(o3).setParameterLength(1);class o5 extends ou{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=o8(this.envNode)}}class o9 extends ou{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=eG(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class o7{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class le extends o7{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,r=e.reflectedLight,i=e.irradianceLightMap;r.indirectDiffuse.assign(eZ(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign(eZ(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(te.rgb)}finish(e){let{material:t,context:r}=e,i=r.outgoingLight,s=e.context.environment;if(s)switch(t.combine){case u.caT:i.rgb.assign(r5(i.rgb,i.rgb.mul(s.rgb),ag.mul(am)));break;case u.KRh:i.rgb.assign(r5(i.rgb,s.rgb,ag.mul(am)));break;case u.XrR:i.rgb.addAssign(s.rgb.mul(ag.mul(am)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}let lt=new u.V9B;class lr extends o${static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lt),this.setValues(e)}setupNormal(){return ns(nl)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new o5(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new o9(ak)),t}setupOutgoingLight(){return te.rgb}setupLightingModel(){return new le}}let li=eF(({f0:e,f90:t,dotVH:r})=>{let i=r.mul(-5.55473).sub(6.98316).mul(r).exp2();return e.mul(i.oneMinus()).add(t.mul(i))}),ls=eF(e=>e.diffuseColor.mul(1/Math.PI)),ln=eF(({dotNH:e})=>ty.mul(eG(.5)).add(1).mul(eG(1/Math.PI)).mul(e.pow(ty))),la=eF(({lightDirection:e})=>{let t=e.add(ne).normalize(),r=nd.dot(t).clamp(),i=li({f0:tm,f90:1,dotVH:ne.dot(t).clamp()}),s=eG(.25),n=ln({dotNH:r});return i.mul(s).mul(n)});class lo extends le{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){let i=nd.dot(e).clamp().mul(t);r.directDiffuse.addAssign(i.mul(ls({diffuseColor:te.rgb}))),!0===this.specular&&r.directSpecular.addAssign(i.mul(la({lightDirection:e})).mul(ag))}indirect(e){let{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(ls({diffuseColor:te}))),i.indirectDiffuse.mulAssign(t)}}let ll=new u.G_z;class lu extends o${static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(ll),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new o5(t):null}setupLightingModel(){return new lo(!1)}}let ld=new u.tXL;class lh extends o${static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(ld),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new o5(t):null}setupLightingModel(){return new lo}setupVariants(){let e=(this.shininessNode?eG(this.shininessNode):al).max(1e-4);ty.assign(e);let t=this.specularNode||ah;tm.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}let lc=eF(e=>{if(!1===e.geometry.hasAttribute("normal"))return eG(0);let t=nl.dFdx().abs().max(nl.dFdy().abs());return t.x.max(t.y).max(t.z)}),lp=eF(e=>{let{roughness:t}=e,r=lc(),i=t.max(.0525);return(i=i.add(r)).min(1)}),lg=eF(({alpha:e,dotNL:t,dotNV:r})=>{let i=e.pow2(),s=t.mul(i.add(i.oneMinus().mul(r.pow2())).sqrt()),n=r.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt());return tj(.5,s.add(n).max(ro))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),lm=eF(({alphaT:e,alphaB:t,dotTV:r,dotBV:i,dotTL:s,dotBL:n,dotNV:a,dotNL:o})=>{let l=o.mul(eX(e.mul(r),t.mul(i),a).length()),u=a.mul(eX(e.mul(s),t.mul(n),o).length());return tj(.5,l.add(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"}]}),lf=eF(({alpha:e,dotNH:t})=>{let r=e.pow2(),i=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(i.pow2()).mul(1/Math.PI)}
4).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),ly=eG(1/Math.PI),lb=eF(({alphaT:e,alphaB:t,dotNH:r,dotTH:i,dotBH:s})=>{let n=e.mul(t),a=eX(t.mul(i),e.mul(s),n.mul(r)),o=a.dot(a),l=n.div(o);return ly.mul(n.mul(l.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"}]}),lx=eF(({lightDirection:e,f0:t,f90:r,roughness:i,f:s,normalView:n=nd,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{let l,u,d=i.pow2(),h=e.add(ne).normalize(),c=n.dot(e).clamp(),p=n.dot(ne).clamp(),g=n.dot(h).clamp(),m=li({f0:t,f90:r,dotVH:ne.dot(h).clamp()});if(ev(a)&&(m=tl.mix(m,s)),ev(o)){let t=tp.dot(e),r=tp.dot(ne),i=tp.dot(h),s=tg.dot(e),n=tg.dot(ne),a=tg.dot(h);l=lm({alphaT:th,alphaB:d,dotTV:r,dotBV:n,dotTL:t,dotBL:s,dotNV:p,dotNL:c}),u=lb({alphaT:th,alphaB:d,dotNH:g,dotTH:i,dotBH:a})}else l=lg({alpha:d,dotNL:c,dotNV:p}),u=lf({alpha:d,dotNH:g});return m.mul(l).mul(u)}),lT=eF(({roughness:e,dotNV:t})=>{let r=eZ(-1,-.0275,-.572,.022),i=eZ(1,.0425,1.04,-.04),s=e.mul(r).add(i),n=s.x.mul(s.x).min(t.mul(-9.28).exp2()).mul(s.x).add(s.y);return eH(-1.04,1.04).mul(n).add(s.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),l_=eF(e=>{let{dotNV:t,specularColor:r,specularF90:i,roughness:s}=e,n=lT({dotNV:t,roughness:s});return r.mul(n.x).add(i.mul(n.y))}),lv=eF(({f:e,f90:t,dotVH:r})=>{let i=r.oneMinus().saturate(),s=i.mul(i),n=i.mul(s,s).clamp(0,.9999);return e.sub(eX(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),lN=eF(({roughness:e,dotNH:t})=>{let r=e.pow2(),i=eG(1).div(r),s=t.pow2().oneMinus().max(.0078125);return eG(2).add(i).mul(s.pow(i.mul(.5))).div(2*Math.PI)}
vendor: 4,203 bytes, line 4
4).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),lS=eF(({dotNV:e,dotNL:t})=>eG(1).div(eG(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),lR=eF(({lightDirection:e})=>{let t=e.add(ne).normalize(),r=nd.dot(e).clamp(),i=nd.dot(ne).clamp(),s=lN({roughness:to,dotNH:nd.dot(t).clamp()}),n=lS({dotNV:i,dotNL:r});return ta.mul(s).mul(n)}),lA=eF(({N:e,V:t,roughness:r})=>{let i=eH(r,e.dot(t).saturate().oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),lE=eF(({f:e})=>{let t=e.length();return rj(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),lC=eF(({v1:e,v2:t})=>{let r=e.dot(t),i=r.abs().toVar(),s=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),n=i.add(4.1616724).mul(i).add(3.417594).toVar(),a=s.div(n),o=r.greaterThan(0).select(a,rj(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),lw=eF(({N:e,V:t,P:r,mInv:i,p0:s,p1:n,p2:a,p3:o})=>{let l=n.sub(s).toVar(),u=o.sub(s).toVar(),d=l.cross(u),h=eX().toVar();return eD(d.dot(r.sub(s)).greaterThanEqual(0),()=>{let l=t.sub(e.mul(t.dot(e))).normalize(),u=e.cross(l).negate(),d=i.mul(e3(l,u,e).transpose()).toVar(),c=d.mul(s.sub(r)).normalize().toVar(),p=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(o.sub(r)).normalize().toVar(),f=eX(0).toVar();f.addAssign(lC({v1:c,v2:p})),f.addAssign(lC({v1:p,v2:g})),f.addAssign(lC({v1:g,v2:m})),f.addAssign(lC({v1:m,v2:c})),h.assign(eX(lE({f:f})))}),h}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),lM=1/6,lB=e=>tq(lM,tq(e,tq(e,e.negate().add(3)).sub(3)).add(1)),lL=e=>tq(lM,tq(e,tq(e,tq(3,e).sub(6))).add(4)),lP=e=>tq(lM,tq(e,tq(e,tq(-3,e).add(3)).add(3)).add(1)),lF=e=>tq(lM,r0(e,3)),lU=e=>lB(e).add(lL(e)),lI=e=>lP(e).add(lF(e)),lD=e=>tH(-1,lL(e).div(lB(e).add(lL(e)))),lO=e=>tH(1,lF(e).div(lP(e).add(lF(e)))),lV=(e,t,r)=>{let i=tq(e.uvNode,t.zw).add(.5),s=r_(i),n=rS(i),a=lU(n.x),o=lI(n.x),l=lD(n.x),u=lO(n.x),d=lD(n.y),h=lO(n.y),c=eH(s.x.add(l),s.y.add(d)).sub(.5).mul(t.xy),p=eH(s.x.add(u),s.y.add(d)).sub(.5).mul(t.xy),g=eH(s.x.add(l),s.y.add(h)).sub(.5).mul(t.xy),m=eH(s.x.add(u),s.y.add(h)).sub(.5).mul(t.xy),f=lU(n.y).mul(tH(a.mul(e.sample(c).level(r)),o.mul(e.sample(p).level(r)))),y=lI(n.y).mul(tH(a.mul(e.sample(g).level(r)),o.mul(e.sample(m).level(r))));return f.add(y)},lG=eF(([e,t])=>{let r=eH(e.size(ek(t))),i=eH(e.size(ek(t.add(1)))),s=tj(1,r),n=tj(1,i),a=lV(e,eZ(s,r),r_(t)),o=lV(e,eZ(n,i),rv(t));return rS(t).mix(a,o)}),lk=eF(([e,t])=>{let r=t.mul(ss(e));return lG(e,r)}),lz=eF(([e,t,r,i,s])=>{let n=eX(ie(t.negate(),rN(e),tj(1,i))),a=eX(rP(s[0].xyz),rP(s[1].xyz),rP(s[2].xyz));return rN(n).mul(r.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),l$=eF(([e,t])=>e.mul(r9(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),lH=oy(),lW=oy(),lq=eF(([e,t,r],{material:i})=>lG((i.side===u.hsX?lH:lW).sample(e),rb(sT.x).mul(l$(t,r)))),lj=eF(([e,t,r])=>(eD(r.notEqual(0),()=>rm(ry(t).negate().div(r).negate().mul(e))),eX(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lX=eF(([e,t,r,i,s,n,a,o,l,u,d,h,c,p,g])=>{let m,f;if(g){m=eZ().toVar(),f=eX().toVar();let s=d.sub(1).mul(g.mul(.025)),n=eX(d.sub(s),d,d.add(s));or({start:0,end:3},({i:s})=>
4{let d=n.element(s),g=lz(e,t,h,d,o),y=a.add(g),b=u.mul(l.mul(eZ(y,1))),x=eH(b.xy.div(b.w)).toVar();x.addAssign(1),x.divAssign(2),x.assign(eH(x.x,x.y.oneMinus()));let T=lq(x,r,d);m.element(s).assign(T.element(s)),m.a.addAssign(T.a),f.element(s).assign(i.element(s).mul(lj(rP(g),c,p).element(s)))}),m.a.divAssign(3)}else{let s=lz(e,t,h,d,o),n=a.add(s),g=u.mul(l.mul(eZ(n,1))),y=eH(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(eH(y.x,y.y.oneMinus())),m=lq(y,r,d),f=i.mul(lj(rP(s),c,p))}let y=f.rgb.mul(m.rgb),b=eX(l_({dotNV:e.dot(t).clamp(),specularColor:s,specularF90:n,roughness:r})),x=f.r.add(f.g,f.b).div(3);return eZ(b.oneMinus().mul(y),m.a.oneMinus().mul(x).oneMinus())}),lK=e3(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),lQ=(e,t)=>e.sub(t).div(e.add(t)).pow2(),lY=eF(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:i,baseF0:s})=>{let n=r5(e,t,it(0,.03,i)),a=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();eD(a.lessThan(0),()=>eX(1));let o=a.sqrt(),l=li({f0:lQ(n,e),f90:1,dotVH:r}),u=l.oneMinus(),d=n.lessThan(e).select(Math.PI,0),h=eG(Math.PI).sub(d),c=(e=>{let t=e.sqrt();return eX(1).add(t).div(eX(1).sub(t))})(s.clamp(0,.9999)),p=li({f0:lQ(c,n.toVec3()),f90:1,dotVH:o}),g=eX(c.x.lessThan(n).select(Math.PI,0),c.y.lessThan(n).select(Math.PI,0),c.z.lessThan(n).select(Math.PI,0)),m=n.mul(i,o,2),f=eX(h).add(g),y=l.mul(p).clamp(1e-5,.9999),b=y.sqrt(),x=u.pow2().mul(p).div(eX(1).sub(y)),T=l.add(x).toVar(),_=x.sub(u).toVar();return or({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{_.mulAssign(b);let t=((e,t)=>{let r=e.mul(2*Math.PI*1e-9),i=eX(54856e-17,44201e-17,52481e-17),s=eX(1681e3,1795300,2208400),n=eX(43278e5,93046e5,66121e5),a=eG(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp()),o=i.mul(n.mul(2*Math.PI).sqrt()).mul(s.mul(r).add(t).cos()).mul(r.pow2().negate().mul(n).exp());return o=eX(o.x.add(a),o.y,o.z).div(10685e-11),lK.mul(o)})(eG(e).mul(m),eG(e).mul(f)).mul(2);T.addAssign(_.mul(t))}),T.max(eX(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),lZ=eF(({normal:e,viewDir:t,roughness:r})=>{let i=e.dot(t).saturate(),s=r.pow2(),n=id(r.lessThan(.25),eG(-339.2).mul(s).add(eG(161.4).mul(r)).sub(25.9),eG(-8.48).mul(s).add(eG(14.3).mul(r)).sub(9.95)),a=id(r.lessThan(.25),eG(44).mul(s).sub(eG(23.7).mul(r)).add(3.26),eG(1.97).mul(s).sub(eG(3.27).mul(r)).add(.72));return id(r.lessThan(.25),0,eG(.1).mul(r).sub(.025)).add(n.mul(i).add(a).exp()).mul(1/Math.PI).saturate()}),lJ=eX(.04),l0=eG(1);class l1 extends o7{constructor(e=!1,t=!1,r=!1,i=!1,s=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=i,this.transmission=s,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=eX().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=eX().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=eX().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=eX().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=eX().toVar("sheenSpecularIndirect")),!0===this.iridescence){let e=nd.dot(ne).clamp();this.iridescenceFresnel=lY({outsideIOR:eG(1),eta2:tu,cosTheta1:e,thinFilmThickness:td,baseF0:tm}),this.iridescenceF0=lv({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){let t=sU.sub(s5).normalize(),r=e.context;r.backdrop=lX(nh,t,tr,te,tm,tf,s5,sj,sL,sM,tv,tS,tA,tR,this.dispersion?tE:null),r.backdropAlpha=tN,te.a.mulAssign(r5(1,r.backdrop.a,tN))}super.start(e)}computeMultiscattering(e,t,r){let i=lT({roughness:tr,dotNV:nd.dot(ne).clamp()}),s=(this.iridescenceF0?tl.mix(tm,this.iridescenceF0):tm).mul(i.x).add(r.mul(i.y)),n=i.x.add(i.y).oneMinus(),a=tm.add(tm.oneMinus().mul(.047619)),o=s.mul(a).div(n.mul(a).oneMinus());e.addAssign(s),t.addAssign(o.mul(n))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){let i=nd.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(i.mul(lR({lightDirection:e}))),!0===this.clearcoat){let r=nc.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(lx({lightDirection:e,f0:lJ,f90:l0,roughness:tn,normalView:nc})))}r.directDiffuse.addAssign(i.mul(ls({diffuseColor:te.rgb}))),r.directSpecular.addAssign(i.mul(lx({lightDirection:e,f0:tm,f90:1,roughness:tr,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:i,reflectedLight:s,ltc_1:n,ltc_2:a}){let o=t.add(r).sub(i),l=t.sub(r).sub(i),u=t.sub(r).add(i),d=t.add(r).add(i),h=s7.toVar(),c=lA({N:nd,V:ne,roughness:tr}),p=n.sample(c).toVar(),g=a.sample(c).toVar(),m=e3(eX(p.x,0,p.y),eX(0,1,0),eX(p.z,0,p.w)).toVar(),f=tm.mul(g.x).add(tm.oneMinus().mul(g.y)).toVar();
vendor: 4,695 bytes, line 4
4s.directSpecular.addAssign(e.mul(f).mul(lw({N:nd,V:ne,P:h,mInv:m,p0:o,p1:l,p2:u,p3:d}))),s.directDiffuse.addAssign(e.mul(te).mul(lw({N:nd,V:ne,P:h,mInv:e3(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:u,p3:d})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(ls({diffuseColor:te})))}indirectSpecular(e){let{radiance:t,iblIrradiance:r,reflectedLight:i}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(ta,lZ({normal:nd,viewDir:ne,roughness:to}))),!0===this.clearcoat){let e=l_({dotNV:nc.dot(ne).clamp(),specularColor:lJ,specularF90:l0,roughness:tn});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let s=eX().toVar("singleScattering"),n=eX().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(s,n,tf);let o=s.add(n),l=te.mul(o.r.max(o.g).max(o.b).oneMinus());i.indirectSpecular.addAssign(t.mul(s)),i.indirectSpecular.addAssign(n.mul(a)),i.indirectDiffuse.addAssign(l.mul(a))}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:r}=e.context,i=nd.dot(ne).clamp().add(t),s=tr.mul(-16).oneMinus().negate().exp2(),n=t.sub(i.pow(s).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(t),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(n)}finish({context:e}){let{outgoingLight:t}=e;if(!0===this.clearcoat){let e=li({dotVH:nc.dot(ne).clamp(),f0:lJ,f90:l0}),r=t.mul(ts.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(ts));t.assign(r)}if(!0===this.sheen){let e=ta.r.max(ta.g).max(ta.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}let l2=eG(1),l3=eG(-2),l4=eG(.8),l6=eG(-1),l8=eG(.4),l5=eG(2),l9=eG(.305),l7=eG(3),ue=eG(.21),ut=eG(4),ur=eG(4),ui=eG(16),us=eF(([e])=>{let t=eX(rB(e)).toVar(),r=eG(-1).toVar();return eD(t.x.greaterThan(t.z),()=>{eD(t.x.greaterThan(t.y),()=>{r.assign(id(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(id(e.y.greaterThan(0),1,4))})}).Else(()=>{eD(t.z.greaterThan(t.y),()=>{r.assign(id(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(id(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),un=eF(([e,t])=>{let r=eH().toVar();return eD(t.equal(0),()=>{r.assign(eH(e.z,e.y).div(rB(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(eH(e.x.negate(),e.z.negate()).div(rB(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(eH(e.x.negate(),e.y).div(rB(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(eH(e.z.negate(),e.y).div(rB(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(eH(e.x.negate(),e.z).div(rB(e.y)))}).Else(()=>{r.assign(eH(e.x,e.y).div(rB(e.z)))}),tq(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),ua=eF(([e])=>{let t=eG(0).toVar();return eD(e.greaterThanEqual(l4),()=>{t.assign(l2.sub(e).mul(l6.sub(l3)).div(l2.sub(l4)).add(l3))}).ElseIf(e.greaterThanEqual(l8),()=>{t.assign(l4.sub(e).mul(l5.sub(l6)).div(l4.sub(l8)).add(l6))}).ElseIf(e.greaterThanEqual(l9),()=>{t.assign(l8.sub(e).mul(l7.sub(l5)).div(l8.sub(l9)).add(l5))}).ElseIf(e.greaterThanEqual(ue),()=>{t.assign(l9.sub(e).mul(ut.sub(l7)).div(l9.sub(ue)).add(l7))}).Else(()=>{t.assign(eG(-2).mul(rb(tq(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),uo=eF(([e,t])=>{let r=e.toVar();r.assign(tq(2,r).sub(1));let i=eX(r,1).toVar();return eD(t.equal(0),()=>{i.assign(i.zyx)}).ElseIf(t.equal(1),()=>{i.assign(i.xzy),i.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{i.x.mulAssign(-1)}).ElseIf(t.equal(3),()=>{i.assign(i.zyx),i.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{i.assign(i.xzy),i.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{i.z.mulAssign(-1)}),i}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ul=eF(([e,t,r,i,s,n])=>{let a=eG(r),o=eX(t),l=r9(ua(a),l3,n),u=rS(l),d=r_(l),h=eX(uu(e,o,d,i,s,n)).toVar();return eD(u.notEqual(0),()=>{let t=eX(uu(e,o,d.add(1),i,s,n)).toVar();h.assign(r5(h,t,u))}),h}),uu=eF(([e,t,r,i,s,n])=>{let a=eG(r).toVar(),o=eX(t),l=eG(us(o)).toVar(),u=eG(rj(ur.sub(a),0)).toVar();a.assign(rj(a,ur));let d=eG(rf(a)).toVar(),h=eH(un(o,l).mul(d.sub(2)).add(1)).toVar();return eD(l.greaterThan(2),()=>{h.y.addAssign(d),l.subAssign(3)}),h.x.addAssign(l.mul(d)),h.x.addAssign(u.mul(tq(3,ui))),h.y.addAssign(tq(4,rf(n).sub(d))),h.x.mulAssign(i),h.y.mulAssign(s),e.sample(h).grad(eH(),eH())}),ud=eF(({envMap:e,mipInt:t,outputDirection:r,theta:i,axis:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,
4CUBEUV_MAX_MIP:o})=>{let l=rA(i);return uu(e,r.mul(l).add(s.cross(r).mul(rR(i))).add(s.mul(s.dot(r).mul(l.oneMinus()))),t,n,a,o)}),uh=eF(({n:e,latitudinal:t,poleAxis:r,outputDirection:i,weights:s,samples:n,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})=>{let c=eX(id(t,r,rJ(r,i))).toVar();eD(c.equal(eX(0)),()=>{c.assign(eX(i.z,0,i.x.negate()))}),c.assign(rN(c));let p=eX().toVar();return p.addAssign(s.element(0).mul(ud({theta:0,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),or({start:ek(1),end:e},({i:e})=>{eD(e.greaterThanEqual(n),()=>{oi()});let t=eG(a.mul(eG(e))).toVar();p.addAssign(s.element(e).mul(ud({theta:t.mul(-1),axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),p.addAssign(s.element(e).mul(ud({theta:t,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})))}),eZ(p,1)}),uc=[.125,.215,.35,.446,.526,.582],up=new u.qUd(-1,1,1,-1,0,1),ug=new u.ubm(90,1),um=new u.Q1f,uf=null,uy=0,ub=0,ux=(1+Math.sqrt(5))/2,uT=1/ux,u_=[new u.Pq0(-ux,uT,0),new u.Pq0(ux,uT,0),new u.Pq0(-uT,0,ux),new u.Pq0(uT,0,ux),new u.Pq0(0,ux,-uT),new u.Pq0(0,ux,uT),new u.Pq0(-1,1,-1),new u.Pq0(1,1,-1),new u.Pq0(-1,1,1),new u.Pq0(1,1,1)],uv=new u.Pq0,uN=new WeakMap,uS=[3,1,5,0,4,2],uR=uo(se(),i7("faceIndex")).normalize(),uA=eX(uR.x,uR.y,uR.z);class uE{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,r=.1,i=100,s={}){let{size:n=256,position:a=uv,renderTarget:o=null}=s;if(this._setSize(n),!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");let n=o||this._allocateTarget();return s.renderTarget=n,this.fromSceneAsync(e,t,r,i,s),n}uf=this._renderer.getRenderTarget(),uy=this._renderer.getActiveCubeFace(),ub=this._renderer.getActiveMipmapLevel();let l=o||this._allocateTarget();return l.depthBuffer=!0,this._init(l),this._sceneToCubeUV(e,r,i,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}async fromSceneAsync(e,t=0,r=.1,i=100,s={}){return!1===this._hasInitialized&&await this._renderer.init(),this.fromScene(e,t,r,i,s)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() instead."),this._setSizeFromTexture(e);let r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized){console.warn("THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);let r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return!1===this._hasInitialized&&await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=uB(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=uL(),await this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===u.hy7||e.mapping===u.xFO?this._setSize(0===e.image.length?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=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(uf,uy,ub),e.scissorTest=!1,uw(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),uf=this._renderer.getRenderTarget(),uy=this._renderer.getActiveCubeFace(),ub=this._renderer.getActiveMipmapLevel();let r=t||this._allocateTarget();return this._init(r),this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTarget(){return uC(3*Math.max(this._cubeSize,112),4*this._cubeSize)}_init(e){if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=uC(e.width,e.height);let{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}
4=function(e){let t=[],r=[],i=[],s=[],n=e,a=e-4+1+uc.length;for(let o=0;o<a;o++){let a=Math.pow(2,n);r.push(a);let l=1/a;o>e-4?l=uc[o-e+4-1]:0===o&&(l=0),i.push(l);let d=1/(a-2),h=-d,c=1+d,p=[h,h,c,h,c,c,h,h,c,c,h,c],g=new Float32Array(108),m=new Float32Array(72),f=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,r=e>2?0:-1,i=[t,r,0,t+2/3,r,0,t+2/3,r+1,0,t,r,0,t+2/3,r+1,0,t,r+1,0],s=uS[e];g.set(i,18*s),m.set(p,12*s);let n=[s,s,s,s,s,s];f.set(n,6*s)}let y=new u.LoY;y.setAttribute("position",new u.THS(g,3)),y.setAttribute("uv",new u.THS(m,2)),y.setAttribute("faceIndex",new u.THS(f,1)),t.push(y),s.push(new u.eaF(y,null)),n>4&&n--}return{lodPlanes:t,sizeLods:r,sigmas:i,lodMeshes:s}}(t)),this._blurMaterial=function(e,t,r){let i=sg(Array(20).fill(0)),s=tU(new u.Pq0(0,1,0)),n=tU(0),a=eG(20),o=tU(0),l=tU(1),d=sl(null),h=tU(0),c=eG(1/t),p={n:a,latitudinal:o,weights:i,poleAxis:s,outputDirection:uA,dTheta:n,samples:l,envMap:d,mipInt:h,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:eG(1/r),CUBEUV_MAX_MIP:eG(e)},g=uM("blur");return g.fragmentNode=uh({...p,latitudinal:o.equal(1)}),uN.set(g,p),g}(t,e.width,e.height)}}async _compileMaterial(e){let t=new u.eaF(this._lodPlanes[0],e);await this._renderer.compile(t,up)}_sceneToCubeUV(e,t,r,i,s){ug.near=t,ug.far=r;let n=[1,1,1,1,-1,1],a=[1,-1,1,-1,1,-1],o=this._renderer,l=o.autoClear;o.getClearColor(um),o.autoClear=!1;let d=this._backgroundBox;
4if(null===d){let e=new u.V9B({name:"PMREM.Background",side:u.hsX,depthWrite:!1,depthTest:!1});d=new u.eaF(new u.iNn,e)}let h=!1,c=e.background;c?c.isColor&&(d.material.color.copy(c),e.background=null,h=!0):(d.material.color.copy(um),h=!0),o.setRenderTarget(i),o.clear(),h&&o.render(d,ug);for(let t=0;t<6;t++){let r=t%3;0===r?(ug.up.set(0,n[t],0),ug.position.set(s.x,s.y,s.z),ug.lookAt(s.x+a[t],s.y,s.z)):1===r?(ug.up.set(0,0,n[t]),ug.position.set(s.x,s.y,s.z),ug.lookAt(s.x,s.y+a[t],s.z)):(ug.up.set(0,n[t],0),ug.position.set(s.x,s.y,s.z),ug.lookAt(s.x,s.y,s.z+a[t]));let l=this._cubeSize;uw(i,r*l,t>2?l:0,l,l),o.render(e,ug)}o.autoClear=l,e.background=c}_textureToCubeUV(e,t){let r=this._renderer,i=e.mapping===u.hy7||e.mapping===u.xFO;i?null===this._cubemapMaterial&&(this._cubemapMaterial=uB(e)):null===this._equirectMaterial&&(this._equirectMaterial=uL(e));let s=i?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;let n=this._lodMeshes[0];n.material=s;let a=this._cubeSize;uw(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,up)}_applyPMREM(e){let t=this._renderer,r=t.autoClear;t.autoClear=!1;let i=this._lodPlanes.length;for(let t=1;t<i;t++){let r=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),s=u_[(i-t-1)%u_.length];this._blur(e,t-1,t,r,s)}t.autoClear=r}_blur(e,t,r,i,s){let n=this._pingPongRenderTarget;this._halfBlur(e,n,t,r,i,"latitudinal",s),this._halfBlur(n,e,r,r,i,"longitudinal",s)}_halfBlur(e,t,r,i,s,n,a){let o=this._renderer,l=this._blurMaterial;"latitudinal"!==n&&"longitudinal"!==n&&console.error("blur direction must be either latitudinal or longitudinal!");let u=this._lodMeshes[i];u.material=l;let d=uN.get(l),h=this._sizeLods[r]-1,c=isFinite(s)?Math.PI/(2*h):2*Math.PI/39,p=s/c,g=isFinite(s)?1+Math.floor(3*p):20;g>20&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);let m=[],f=0;for(let e=0;e<20;++e){let t=e/p,r=Math.exp(-t*t/2);m.push(r),0===e?f+=r:e<g&&(f+=2*r)}for(let e=0;e<m.length;e++)m[e]=m[e]/f;e.texture.frame=(e.texture.frame||0)+1,d.envMap.value=e.texture,d.samples.value=g,d.weights.array=m,d.latitudinal.value=+("latitudinal"===n),a&&(d.poleAxis.value=a);let{_lodMax:y}=this;d.dTheta.value=c,d.mipInt.value=y-r;let b=this._sizeLods[i],x=4*(this._cubeSize-b);uw(t,3*b*(i>y-4?i-y+4:0),x,3*b,2*b),o.setRenderTarget(t),o.render(u,up)}}function uC(e,t){let r={magFilter:u.k6q,minFilter:u.k6q,generateMipmaps:!1,type:u.ix0,format:u.GWd,colorSpace:u.Zr2},i=new u.O0B(e,t,r);return i.texture.mapping=u.Om,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function uw(e,t,r,i,s){e.viewport.set(t,r,i,s),e.scissor.set(t,r,i,s)}function uM(e){let t=new o$;return t.depthTest=!1,t.depthWrite=!1,t.blending=u.XIg,t.name=`PMREM_${e}`,t}function uB(e){let t=uM("cubemap");return t.fragmentNode=nM(e,uA),t}function uL(e){let t=uM("equirect");return t.fragmentNode=sl(e,o0(uA),0),t}let uP=new WeakMap;class uF extends G{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;let i=new u.gPd;i.isRenderTargetTexture=!0,this._texture=sl(i),this._width=tU(0),this._height=tU(0),this._maxMip=tU(0),this.updateBeforeType=w.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=function(e){let t=Math.log2(e)-2;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:1/e,maxMip:t}}(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,r=t?t.pmremVersion:-1,i=this._value;r!==i.pmremVersion&&null!==(t=!0===i.isPMREMTexture?i:function(e,t,r){var i,s;let n,a=(i=t,void 0===(n=uP.get(i))&&(n=new WeakMap,uP.set(i,n)),n),o=a.get(e);if((void 0!==o?o.pmremVersion:-1)!==e.pmremVersion){let t=e.image;if(e.isCubeTexture)if(!function(e){if(null==e)return!1;let t=0;for(let r=0;r<6;r++)void 0!==e[r]&&t++;return 6===t}(t))return null;else o=r.fromCubemap(e,o);else{if(!(null!=(s=t)&&s.height>0))return null;o=r.fromEquirectangular(e,o)}o.pmremVersion=e.pmremVersion,a.set(e,o)}return o.texture}(i,e.renderer,this._generator))&&(this._pmrem=t,this.updateFromTexture(t))}setup(e){null===this._generator&&(this._generator=new uE(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=nv.mul(eX(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ul(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}let uU=ew(uF).setParameterLength(1,3),uI=new WeakMap;class uD extends ou{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){let{material:t}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){let e=r.isTextureNode?r.value:t[r.property],i=uI.get(e);void 0===i&&(i=uU(e),uI.set(e,i)),r=i}let i=!0===t.useAnisotropy||t.anisotropy>0?n5:nd,s=r.context(uO(tr,i)).mul(n_),n=r.context(uV(nh)).mul(Math.PI).mul(n_),a=iK(s),o=iK(n);
4e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=iK(r.context(uO(tn,nc)).mul(n_));l.addAssign(e)}}}let uO=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=ne.negate().reflect(t),r=(r=e.mul(e).mix(r,t).normalize()).transformDirection(sL)),r),getTextureLevel:()=>e}},uV=e=>({getUV:()=>e,getTextureLevel:()=>eG(1)}),uG=new u._4j;class uk extends o${static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(uG),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new uD(t):null}setupLightingModel(){return new l1}setupSpecular(){let e=r5(eX(.04),te.rgb,ti);tm.assign(e),tf.assign(1)}setupVariants(){let e=this.metalnessNode?eG(this.metalnessNode):ay;ti.assign(e);let t=this.roughnessNode?eG(this.roughnessNode):af;t=lp({roughness:t}),tr.assign(t),this.setupSpecular(),te.assign(eZ(te.rgb.mul(e.oneMinus()),te.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}let uz=new u.uSd;class u$ extends uk{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(uz),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){let e=this.iorNode?eG(this.iorNode):aB;tv.assign(e),tm.assign(r5(rq(r1(tv.sub(1).div(tv.add(1))).mul(ap),eX(1)).mul(ac),te.rgb,ti)),tf.assign(r5(ac,1,ti))}setupLightingModel(){return new l1(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?eG(this.clearcoatNode):ax,t=this.clearcoatRoughnessNode?eG(this.clearcoatRoughnessNode):aT;ts.assign(e),tn.assign(lp({roughness:t}))}if(this.useSheen){let e=this.sheenNode?eX(this.sheenNode):aN,t=this.sheenRoughnessNode?eG(this.sheenRoughnessNode):aS;ta.assign(e),to.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?eG(this.iridescenceNode):aA,t=this.iridescenceIORNode?eG(this.iridescenceIORNode):aE,r=this.iridescenceThicknessNode?eG(this.iridescenceThicknessNode):aC;tl.assign(e),tu.assign(t),td.assign(r)}if(this.useAnisotropy){let e=(this.anisotropyNode?eH(this.anisotropyNode):aR).toVar();tc.assign(e.length()),eD(tc.equal(0),()=>{e.assign(eH(1,0))}).Else(()=>{e.divAssign(eH(tc)),tc.assign(tc.saturate())}),th.assign(tc.pow2().mix(tr.pow2(),1)),tp.assign(n6[0].mul(e.x).add(n6[1].mul(e.y))),tg.assign(n6[1].mul(e.x).sub(n6[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?eG(this.transmissionNode):aw,t=this.thicknessNode?eG(this.thicknessNode):aM,r=this.attenuationDistanceNode?eG(this.attenuationDistanceNode):aL,i=this.attenuationColorNode?eX(this.attenuationColorNode):aP;if(tN.assign(e),tS.assign(t),tR.assign(r),tA.assign(i),this.useDispersion){let e=this.dispersionNode?eG(this.dispersionNode):aG;tE.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?eX(this.clearcoatNormalNode):a_}setup(e){e.context.setupClearcoatNormal=()=>iN(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dis
4persionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}let uH=eF(({normal:e,lightDirection:t,builder:r})=>{let i=eH(e.dot(t).mul(.5).add(.5),0);if(r.material.gradientMap)return eX(nI("gradientMap","texture").context({getUV:()=>i}).r);{let e=i.fwidth().mul(.5);return r5(eX(.7),eX(1),it(eG(.7).sub(e.x),eG(.7).add(e.x),i.x))}});class uW extends o7{direct({lightDirection:e,lightColor:t,reflectedLight:r},i){let s=uH({normal:nn,lightDirection:e,builder:i}).mul(t);r.directDiffuse.addAssign(s.mul(ls({diffuseColor:te.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(ls({diffuseColor:te}))),i.indirectDiffuse.mulAssign(t)}}let uq=new u.Df;class uj extends o${static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(uq),this.setValues(e)}setupLightingModel(){return new uW}}let uX=eF(()=>{let e=eX(ne.z,0,ne.x.negate()).normalize(),t=ne.cross(e);return eH(e.dot(nd),t.dot(nd)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),uK=new u.FNr;class uQ extends o${static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(uK),this.setValues(e)}setupVariants(e){let t;t=e.material.matcap?nI("matcap","texture").context({getUV:()=>uX}):eX(r5(.2,.8,uX.y)),te.rgb.mulAssign(t.rgb)}}class uY extends G{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:r}=this;if("vec2"===this.getNodeType(e)){let e=t.cos(),i=t.sin();return e2(e,i,i.negate(),e).mul(r)}{let e=e4(eZ(1,0,0,0),eZ(0,rA(t.x),rR(t.x).negate(),0),eZ(0,rR(t.x),rA(t.x),0),eZ(0,0,0,1)),i=e4(eZ(rA(t.y),0,rR(t.y),0),eZ(0,1,0,0),eZ(rR(t.y).negate(),0,rA(t.y),0),eZ(0,0,0,1)),s=e4(eZ(rA(t.z),rR(t.z).negate(),0,0),eZ(rR(t.z),rA(t.z),0,0),eZ(0,0,1,0),eZ(0,0,0,1));return e.mul(i).mul(s).mul(eZ(r,1)).xyz}}}let uZ=ew(uY).setParameterLength(2),uJ=new u.RoJ;class u0 extends o${static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(uJ),this.setValues(e)}setupPositionView(e){let{object:t,camera:r}=e,{positionNode:i,rotationNode:s,scaleNode:n,sizeAttenuation:a}=this,o=s0.mul(eX(i||0)),l=eH(sj[0].xyz.length(),sj[1].xyz.length());null!==n&&(l=l.mul(eH(n))),r.isPerspectiveCamera&&!1===a&&(l=l.mul(o.z.negate()));let u=s4.xy;if(t.center&&!0===t.center.isVector2){let e=eR(new iF("center","vec2",t));u=u.sub(e.sub(.5))}let d=uZ(u=u.mul(l),eG(s||av));return eZ(o.xy.add(d),o.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}let u1=new u.BH$,u2=new u.I9Y;class u3 extends u0{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(u1),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return s0.mul(eX(e||s6)).xyz}setupVertexSprite(e){let{material:t,camera:r}=e,{rotationNode:i,scaleNode:s,sizeNode:n,sizeAttenuation:a}=this,o=super.setupVertex(e);if(!0!==t.isNodeMaterial)return o;let l=null!==n?eH(n):aV;l=l.mul(sb),r.isPerspectiveCamera&&!0===a&&(l=l.mul(u4.div(s7.z.negate()))),s&&s.isNode&&(l=l.mul(eH(s)));let u=s4.xy;return i&&i.isNode&&(u=uZ(u,eG(i))),u=(u=(u=u.mul(l)).div(sN.div(2))).mul(o.w),o=o.add(eZ(u,0,0))}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}let u4=tU(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(u2);this.value=.5*t.y});class u6 extends o7{constructor(){super(),this.shadowNode=eG(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){te.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(te.rgb)}}let u8=new u.q2;class u5 extends o${static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(u8),this.setValues(e)}setupLightingModel(){return new u6}}e9("vec3"),e9("vec3"),e9("vec3");class u9{constructor(e,t){this.nodes=e,this.info=t,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(
4),this.info.frame=this.nodes.nodeFrame.frameId,null!==this._animationLoop&&this._animationLoop(t,r)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class u7{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r<e.length-1;r++)if(void 0===(t=t.get(e[r])))return;return t.get(e[e.length-1])}set(e,t){let r=this.weakMap;for(let t=0;t<e.length-1;t++){let i=e[t];!1===r.has(i)&&r.set(i,new WeakMap),r=r.get(i)}return r.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let r=0;r<e.length-1;r++)if(void 0===(t=t.get(e[r])))return!1;return t.delete(e[e.length-1])}}let de=0;class dt{constructor(e,t,r,i,s,n,a,o,l,u){this.id=de++,this._nodes=e,this._geometries=t,this.renderer=r,this.object=i,this.material=s,this.scene=n,this.camera=a,this.lightsNode=o,this.context=l,this.geometry=i.geometry,this.version=s.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=u,this.clippingContextCacheKey=null!==u?u.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return null!==this.clippingContext&&this.clippingContext.cacheKey!==this.clippingContextCacheKey&&(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return!0===this.material.hardwareClipping?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(let t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(null!==this.attributes)return this.attributes;let e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],i=new Set,s={};for(let n of e){let e;if(n.node&&n.node.attribute?e=n.node.attribute:(e=t.getAttribute(n.name),s[n.name]=e.version),void 0===e)continue;r.push(e);let a=e.isInterleavedBufferAttribute?e.data:e;i.add(a)}return this.attributes=r,this.attributesId=s,this.vertexBuffers=Array.from(i.values()),r}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){let{object:e,material:t,geometry:r,group:i,drawRange:s}=this,n=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),a=this.getIndex(),o=null!==a,l=1;if(!0===r.isInstancedBufferGeometry?l=r.instanceCount:void 0!==e.count&&(l=Math.max(0,e.count)),0===l)return null;if(n.instanceCount=l,!0===e.isBatchedMesh)return n;let u=1;!0!==t.wireframe||e.isPoints||e.isLineSegments||e.isLine||e.isLineLoop||(u=2);let d=s.start*u,h=(s.start+s.count)*u;null!==i&&(d=Math.max(d,i.start*u),h=Math.min(h,(i.start+i.count)*u));let c=r.attributes.position,p=1/0;o?p=a.count:null!=c&&(p=c.count),d=Math.max(d,0);let g=(h=Math.min(h,p))-d;return g<0||g===1/0?null:(n.vertexCount=g,n.firstVertex=d,n)}getGeometryCacheKey(){let{geometry:e}=this,t="";for(let r of Object.keys(e.attributes).sort()){let i=e.attributes[r];t+=r+",",i.data&&(t+=i.data.stride+","),i.offset&&(t+=i.offset+","),i.itemSize&&(t+=i.itemSize+","),i.normalized&&(t+="n,")}for(let r of Object.keys(e.morphAttributes).sort()){let i=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=i.length;e<r;e++)t+=i[e].id+","}return e.index&&(t+="index,"),t}getMaterialCacheKey(){let{object:e,material:t,renderer:r}=this,i=t.customProgramCacheKey();for(let e of function(e){let t=Object.keys(e),r=Object.getPrototypeOf(e);for(;r;){let e=Object.getOwnPropertyDescriptors(r);for(let r in e)if(void 0!==e[r]){let i=e[r];i&&"function"==typeof i.get&&t.push(r)}r=Object.getPrototypeOf(r)}return t}(t)){let s;if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;let n=t[e];if(null!==n){let e=typeof n;"number"===e?s=0!==n?"1":"0":"object"===e?(s="{",n.isTexture&&(s+=n.mapping,!0===r.backend.isWebGPUBackend&&(s+=n.magFilter,s+=n.minFilter,s+=n.wrapS,s+=n.wrapT,s+=n.wrapR)),s+="}"):s=String(n)}else s=String(n);i+=s+","}return i+=this.clippingContextCacheKey+",",e.geometry&&(i+=this.getGeometryCacheKey()),e.skeleton&&(i+=e.skeleton.bones.length+","),e.isBatchedMesh&&(i+=e._matricesTexture.uuid+",",null!==e._colorsTexture&&(i+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1)&&(i+=e.uuid+","),g(i+=e.receiveShadow+",")}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;
4if(null!==this.attributes){let e=this.attributesId;for(let t in e){let r=this.geometry.getAttribute(t);if(void 0===r||e[t]!==r.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return!0!==this.material.isShadowPassMaterial&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=f(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=f(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}let dr=[];class di{constructor(e,t,r,i,s,n){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=i,this.bindings=s,this.info=n,this.chainMaps={}}get(e,t,r,i,s,n,a,o){let l=this.getChainMap(o);dr[0]=e,dr[1]=t,dr[2]=n,dr[3]=s;let u=l.get(dr);return void 0===u?(u=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,i,s,n,a,o),l.set(dr,u)):(u.updateClipping(a),u.needsGeometryUpdate&&u.setGeometry(e.geometry),(u.version!==t.version||u.needsUpdate)&&(u.initialCacheKey!==u.getCacheKey()?(u.dispose(),u=this.get(e,t,r,i,s,n,a,o)):u.version=t.version)),dr.length=0,u}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new u7)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,i,s,n,a,o,l,u,d){let h=this.getChainMap(d),c=new dt(e,t,r,i,s,n,a,o,l,u);return c.onDispose=()=>{this.pipelines.delete(c),this.bindings.delete(c),this.nodes.delete(c),h.delete(c.getChainArray())},c}}class ds{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}let dn={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4};class da extends ds{constructor(e){super(),this.backend=e}delete(e){let t=super.delete(e);return null!==t&&this.backend.destroyAttribute(e),t}update(e,t){let r=this.get(e);if(void 0===r.version)t===dn.VERTEX?this.backend.createAttribute(e):t===dn.INDEX?this.backend.createIndexAttribute(e):t===dn.STORAGE?this.backend.createStorageAttribute(e):t===dn.INDIRECT&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{let t=this._getBufferAttribute(e);(r.version<t.version||t.usage===u.Vnu)&&(this.backend.updateAttribute(e),r.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function dl(e){return null!==e.index?e.index.version:e.attributes.position.version}function du(e){let t=[],r=e.index,i=e.attributes.position;if(null!==r){let e=r.array;for(let r=0,i=e.length;r<i;r+=3){let i=e[r+0],s=e[r+1],n=e[r+2];t.push(i,s,s,n,n,i)}}else{let e=i.array;for(let r=0,i=e.length/3-1;r<i;r+=3){let e=r+0,i=r+1,s=r+2;t.push(e,i,i,s,s,e)}}let s=new((0,u.AQS)(t)?u.MW4:u.A$4)(t,1);return s.version=dl(e),s}class dd extends ds{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){let t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){let t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;let r=()=>{this.info.memory.geometries--;let i=t.index,s=e.getAttributes();for(let e of(null!==i&&this.attributes.delete(i),s))this.attributes.delete(e);let n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",r)};t.addEventListener("dispose",r)}updateAttributes(e){for(let t of e.getAttributes())t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute?this.updateAttribute(t,dn.STORAGE):this.updateAttribute(t,dn.VERTEX);let t=this.getIndex(e);null!==t&&this.updateAttribute(t,dn.INDEX);let r=e.geometry.indirect;null!==r&&this.updateAttribute(r,dn.INDIRECT)}updateAttribute(e,t){let r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){let{geometry:t,material:r}=e,i=t.index;if(!0===r.wireframe){let e=this.wireframes,r=e.get(t);void 0===r?(r=du(t),e.set(t,r)):r.version!==dl(t)&&(this.attributes.delete(r),r=du(t),e.set(t,r)),i=r}return i}}class dh{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=t/3*r:e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=t/2*r:e.isLine?this.render.lines+=r*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class dc{constructor(e){this.cacheKey=e,this.usedTimes=0}}class dp extends dc{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class dg extends dc{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let dm=0;
4class df{constructor(e,t,r,i=null,s=null){this.id=dm++,this.code=e,this.stage=t,this.name=r,this.transforms=i,this.attributes=s,this.usedTimes=0}}class dy extends ds{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){let{backend:r}=this,i=this.get(e);if(this._needsComputeUpdate(e)){let s=i.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);let n=this.nodes.getForCompute(e),a=this.programs.compute.get(n.computeShader);void 0===a&&(s&&0===s.computeProgram.usedTimes&&this._releaseProgram(s.computeProgram),a=new df(n.computeShader,"compute",e.name,n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,a),r.createProgram(a));let o=this._getComputeCacheKey(e,a),l=this.caches.get(o);void 0===l&&(s&&0===s.usedTimes&&this._releasePipeline(s),l=this._getComputePipeline(e,a,o,t)),l.usedTimes++,a.usedTimes++,i.version=e.version,i.pipeline=l}return i.pipeline}getForRender(e,t=null){let{backend:r}=this,i=this.get(e);if(this._needsRenderUpdate(e)){let s=i.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);let n=e.getNodeBuilderState(),a=e.material?e.material.name:"",o=this.programs.vertex.get(n.vertexShader);void 0===o&&(s&&0===s.vertexProgram.usedTimes&&this._releaseProgram(s.vertexProgram),o=new df(n.vertexShader,"vertex",a),this.programs.vertex.set(n.vertexShader,o),r.createProgram(o));let l=this.programs.fragment.get(n.fragmentShader);void 0===l&&(s&&0===s.fragmentProgram.usedTimes&&this._releaseProgram(s.fragmentProgram),l=new df(n.fragmentShader,"fragment",a),this.programs.fragment.set(n.fragmentShader,l),r.createProgram(l));let u=this._getRenderCacheKey(e,o,l),d=this.caches.get(u);void 0===d?(s&&0===s.usedTimes&&this._releasePipeline(s),d=this._getRenderPipeline(e,o,l,u,t)):e.pipeline=d,d.usedTimes++,o.usedTimes++,l.usedTimes++,i.pipeline=d}return i.pipeline}delete(e){let t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,i){r=r||this._getComputeCacheKey(e,t);let s=this.caches.get(r);return void 0===s&&(s=new dg(r,t),this.caches.set(r,s),this.backend.createComputePipeline(s,i)),s}_getRenderPipeline(e,t,r,i,s){i=i||this._getRenderCacheKey(e,t,r);let n=this.caches.get(i);return void 0===n&&(n=new dp(i,t,r),this.caches.set(i,n),e.pipeline=n,this.backend.createRenderPipeline(e,s)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){let t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){let t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class db extends ds{constructor(e,t,r,i,s,n){super(),this.backend=e,this.textures=r,this.pipelines=s,this.attributes=i,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings();for(let e of t){let r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings;for(let e of t){let r=this.get(e);void 0===r.bindGroup&&(this._init(e),this.backend.createBindings(e,t,0),r.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(let t of e)this._update(t,e)}_init(e){for(let t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){let e=t.attribute,r=e.isIndirectStorageBufferAttribute?dn.INDIRECT:dn.STORAGE;this.attributes.update(e,r)}}_update(e,t){let{backend:r}=this,i=!1,s=!0,n=0,a=0;for(let t of e.bindings)if(!t.isNodeUniformsGroup||!1!==this.nodes.updateGroup(t)){if(t.isStorageBuffer){let e=t.attribute,r=e.isIndirectStorageBufferAttribute?dn.INDIRECT:dn.STORAGE;this.attributes.update(e,r)}
4if(t.isUniformBuffer)t.update()&&r.updateBinding(t);else if(t.isSampledTexture){let e=t.update(),o=t.texture,l=this.textures.get(o);if(e&&(this.textures.updateTexture(o),t.generation!==l.generation&&(t.generation=l.generation,i=!0,s=!1)),void 0!==r.get(o).externalTexture||l.isDefaultTexture?s=!1:(n=10*n+o.id,a+=o.version),!0===o.isStorageTexture){let e=this.get(o);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(o)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(o),e.needsMipmap=!1)}}else t.isSampler&&t.update()}!0===i&&this.backend.updateBindings(e,t,s?n:0,a)}}function dx(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?e.z-t.z:e.id-t.id}function dT(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function d_(e){return(e.transmission>0||e.transmissionNode)&&e.side===u.$EB&&!1===e.forceSinglePass}class dv{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,i,s,n,a){let o=this.renderItems[this.renderItemsIndex];return void 0===o?(o={id:e.id,object:e,geometry:t,material:r,groupOrder:i,renderOrder:e.renderOrder,z:s,group:n,clippingContext:a},this.renderItems[this.renderItemsIndex]=o):(o.id=e.id,o.object=e,o.geometry=t,o.material=r,o.groupOrder=i,o.renderOrder=e.renderOrder,o.z=s,o.group=n,o.clippingContext=a),this.renderItemsIndex++,o}push(e,t,r,i,s,n,a){let o=this.getNextRenderItem(e,t,r,i,s,n,a);!0===e.occlusionTest&&this.occlusionQueryCount++,!0===r.transparent||r.transmission>0?(d_(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,i,s,n,a){let o=this.getNextRenderItem(e,t,r,i,s,n,a);!0===r.transparent||r.transmission>0?(d_(r)&&this.transparentDoublePass.unshift(o),this.transparent.unshift(o)):this.opaque.unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||dx),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||dT),this.transparent.length>1&&this.transparent.sort(t||dT)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){let t=this.renderItems[e];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.groupOrder=null,t.renderOrder=null,t.z=null,t.group=null,t.clippingContext=null}}}let dN=[];class dS{constructor(e){this.lighting=e,this.lists=new u7}get(e,t){let r=this.lists;dN[0]=e,dN[1]=t;let i=r.get(dN);return void 0===i&&(i=new dv(this.lighting,e,t),r.set(dN,i)),dN.length=0,i}dispose(){this.lists=new u7}}let dR=0;class dA{constructor(){this.id=dR++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new u.IUQ,this.scissor=!1,this.scissorValue=new u.IUQ,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return dE(this)}}function dE(e){let{textures:t,activeCubeFace:r,activeMipmapLevel:i}=e,s=[r,i];for(let e of t)s.push(e.id);return m(s)}let dC=[],dw=new u.Z58,dM=new u.i7d;class dB{constructor(){this.chainMaps={}}get(e,t,r=null){let i;if(dC[0]=e,dC[1]=t,null===r)i="default";else{let e=r.texture.format,t=r.textures.length;i=`${t}:${e}:${r.samples}:${r.depthBuffer}:${r.stencilBuffer}`}let s=this._getChainMap(i),n=s.get(dC);return void 0===n&&(n=new dA,s.set(dC,n)),dC.length=0,null!==r&&(n.sampleCount=0===r.samples?1:r.samples),n}getForClear(e=null){return this.get(dw,dM,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new u7)}dispose(){this.chainMaps={}}}let dL=new u.Pq0;class dP extends ds{constructor(e,t,r){super(),this.renderer=e,this.backend=t,this.info=r}updateRenderTarget(e,t=0){let r=this.get(e),i=0===e.samples?1:e.samples,s=r.depthTextureMips||(r.depthTextureMips={}),n=e.textures,a=this.getSize(n[0]),o=a.width>>t,l=a.height>>t,d=e.depthTexture||s[t],h=!0===e.depthBuffer||!0===e.stencilBuffer,c=!1;void 0===d&&h&&((d=new u.VCu).format=e.stencilBuffer?u.dcC:u.zdS,d.type=e.stencilBuffer?u.V3x:u.bkx,d.image.width=o,d.image.height=l,d.image.depth=a.depth,d.isArrayTexture=!0===e.multiview&&a.depth>1,s[t]=d),(r.width!==a.width||a.height!==r.height)&&(c=!0,d&&(d.needsUpdate=!0,d.image.width=o,d.image.height=l,d.image.depth=d.isArrayTexture?d.image.depth:1)),r.width=a.width,r.height=a.height,r.textures=n,r.depthTexture=d||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleC
4ount!==i&&(c=!0,d&&(d.needsUpdate=!0),r.sampleCount=i);let p={sampleCount:i};if(!0!==e.isXRRenderTarget){for(let e=0;e<n.length;e++){let t=n[e];c&&(t.needsUpdate=!0),this.updateTexture(t,p)}d&&this.updateTexture(d,p)}if(!0!==r.initialized){r.initialized=!0;let t=()=>{e.removeEventListener("dispose",t);for(let e=0;e<n.length;e++)this._destroyTexture(n[e]);d&&this._destroyTexture(d),this.delete(e),this.backend.delete(e)};e.addEventListener("dispose",t)}}updateTexture(e,t={}){let r=this.get(e);if(!0===r.initialized&&r.version===e.version)return;let i=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,s=this.backend;if(i&&!0===r.initialized&&(s.destroySampler(e),s.destroyTexture(e)),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();t?e.type=t.texture.type:e.type=u.OUM}let{width:n,height:a,depth:o}=this.getSize(e);if(t.width=n,t.height=a,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,n,a):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,i||!0===e.isStorageTexture||!0===e.isExternalTexture)s.createSampler(e),s.createTexture(e,t),r.generation=e.version;else if(!0!==r.initialized&&s.createSampler(e),e.version>0){let i=e.image;if(void 0===i)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===i.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){let r=[];for(let t of e.images)r.push(t);t.images=r}else t.image=i;(void 0===r.isDefaultTexture||!0===r.isDefaultTexture)&&(s.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),!0===e.source.dataReady&&s.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;if(!0!==r.initialized){r.initialized=!0,r.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&u.ppV.getTransfer(e.colorSpace)!==u.KLL&&console.warn("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.");let t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=dL){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){return e.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,r)))+1}needsMipmaps(e){return!0===e.generateMipmaps||e.mipmaps.length>0}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class dF extends u.Q1f{constructor(e,t,r,i=1){super(e,t,r),this.a=i}set(e,t,r,i=1){return this.a=i,super.set(e,t,r)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class dU extends e5{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class dI extends D{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.hasOutput?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput?this.outputNode.getMemberType(e,t):"void"}add(e){return!0!==e.isNode?console.error("THREE.TSL: Invalid node added to stack."):this.nodes.push(e),this}If(e,t){let r=new eS(t);return this._currentCond=id(e,r),this.add(this._currentCond)}ElseIf(e,t){let r=id(e,new eS(t));return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new eS(e),this}Switch(e){return this._expressionNode=eR(e),this}Case(...e){let t=[];if(e.length>=2)for(let r=0;r<e.length-1;r++)t.push(this._expressionNode.equal(eR(e[r])));else console.error("THREE.TSL: Invalid parameter length. Case() requires at least two parameters.");let r=new eS(e[e.length-1]),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let s=id(i,r);return null===this._currentCond?(this._currentCond=s,this.add(this._currentCond)):(this._currentCond.elseNode=s,this._currentCond=s,this)}Default(e){return this.Else(e),this}setup(e){let t=e.getNodeProperties(this),r=0;for(let i of this.getChildren())i.isVarNode&&!0===i.intent&&!0!==e.getNodeProperties(i).assign||(t["node"+r++]=i);return t.outputNode||null}get hasOutput(){return this.outputNode&&this.outputNode.isNode}build(e,...t){let r,i=e.currentStack,s=eI();eU(this),e.currentStack=this;let n=e.buildStage;
4for(let t of this.nodes)if(!t.isVarNode||!0!==t.intent||!0===e.getNodeProperties(t).assign){if("setup"===n)t.build(e);else if("analyze"===n)t.build(e,this);else if("generate"===n){let r=e.getDataFromNode(t,"any").stages,i=r&&r[e.shaderStage];if(t.isVarNode&&i&&1===i.length&&i[0]&&i[0].isStackNode)continue;t.build(e,"void")}}return r=this.hasOutput?this.outputNode.build(e,...t):super.build(e,...t),eU(s),e.currentStack=i,r}}let dD=ew(dI).setParameterLength(0,1);class dO extends D{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=Object.entries(e).map(([e,t])=>"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}),this.name=t,this.isStructLayoutNode=!0}getLength(){let e=Float32Array.BYTES_PER_ELEMENT,t=0;for(let r of this.membersLayout){let i=r.type,s=(/float|int|uint/.test(i)?1:/vec2/.test(i)?2:/vec3/.test(i)?3:/vec4/.test(i)||/mat2/.test(i)?4:/mat3/.test(i)?12:/mat4/.test(i)?16:void console.error("THREE.TSL: Unsupported type:",i))*e,n=/float|int|uint/.test(i)?4:/vec2/.test(i)?8:/vec3/.test(i)||/vec4/.test(i)?16:/mat2/.test(i)?8:/mat3/.test(i)?48:/mat4/.test(i)?64:void console.error("THREE.TSL: Unsupported type:",i),a=t%8,o=a%n,l=a+o;t+=o,0!==l&&8-l<s&&(t+=8-l),t+=s}return 8*Math.ceil(t/8)/e}getMemberType(e,t){let r=this.membersLayout.find(e=>e.name===t);return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class dV extends D{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),r=t.type,i=e.getPropertyName(t);return e.addLineFlowCode(`${i} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}class dG extends D{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){let t=e.getNodeProperties(this);if(void 0===t.membersLayout){let r=this.members,i=[];for(let t=0;t<r.length;t++){let s="m"+t,n=r[t].getNodeType(e);i.push({name:s,type:n,index:t})}t.membersLayout=i,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){let t=e.getOutputStructName(),r=this.members,i=""!==t?t+".":"";for(let t=0;t<r.length;t++){let s=r[t].build(e);e.addLineFlowCode(`${i}m${t} = ${s}`,this)}return t}}let dk=ew(dG);function dz(e,t){for(let r=0;r<e.length;r++)if(e[r].name===t)return r;return -1}class d$ extends dG{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return void 0!==this.outputNodes[e]}get(e){return this.outputNodes[e]}merge(e){return dH({...this.outputNodes,...e.outputNodes})}setup(e){let t=this.outputNodes,r=e.renderer.getRenderTarget(),i=[],s=r.textures;for(let e in t)i[dz(s,e)]=eZ(t[e]);return this.members=i,super.setup(e)}}let dH=ew(d$);class dW extends G{static get type(){return"BitcastNode"}constructor(e,t,r=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=r,this.isBitcastNode=!0}getNodeType(e){if(null!==this.inputType){let t=this.valueNode.getNodeType(e),r=e.getTypeLength(t);return e.getTypeFromLength(r,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),r="";if(null!==this.inputType){let t=this.valueNode.getNodeType(e);r=1===e.getTypeLength(t)?this.inputType:e.changeComponentType(t,this.inputType)}else r=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,r)}( ${this.valueNode.build(e,r)} )`}}let dq=eB(dW).setParameterLength(2),dj=eF(([e])=>{let t=e.toUint().mul(0x2c9277b5).add(0xac564b05),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(0x108ef2d9);return r.shiftRight(22).bitXor(r).toFloat().mul(1/0x100000000)}),dX=(e,t)=>r0(tq(4,e.mul(tW(1,e))),t),dK=eF(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),dQ=eF(([e])=>eX(dK(e.z.add(dK(e.y.mul(1)))),dK(e.z.add(dK(e.x.mul(1)))),dK(e.y.add(dK(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",input
4s:[{name:"p",type:"vec3"}]}),dY=eF(([e,t,r])=>{let i=eX(e).toVar(),s=eG(1.4).toVar(),n=eG(0).toVar(),a=eX(i).toVar();return or({start:eG(0),end:eG(3),type:"float",condition:"<="},()=>{let e=eX(dQ(a.mul(2))).toVar();i.addAssign(e.add(r.mul(eG(.1).mul(t)))),a.mulAssign(1.8),s.mulAssign(1.5),i.mulAssign(1.2);let o=eG(dK(i.z.add(dK(i.x.add(dK(i.y)))))).toVar();n.addAssign(o.div(s)),a.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class dZ extends D{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,r=this._candidateFnCall;if(null===r){let i=null,s=-1;for(let r of this.functionNodes){let n=r.shaderNode.layout;if(null===n)throw Error("FunctionOverloadingNode: FunctionNode must be a layout.");let a=n.inputs;if(t.length===a.length){let n=0;for(let r=0;r<t.length;r++){let i=t[r],s=a[r];i.getNodeType(e)===s.type?n++:n=0}n>s&&(i=r,s=n)}}this._candidateFnCall=r=i(...t)}return r}}let dJ=ew(dZ),d0=e=>(...t)=>dJ(e,...t),d1=tU(0).setGroup(tL).onRenderUpdate(e=>e.time),d2=tU(0).setGroup(tL).onRenderUpdate(e=>e.deltaTime),d3=tU(0,"uint").setGroup(tL).onRenderUpdate(e=>e.frameId),d4=eF(([e,t,r=eH(.5)])=>uZ(e.sub(r),t).add(r)),d6=eF(([e,t,r=eH(.5)])=>{let i=e.sub(r),s=i.dot(i),n=s.mul(s).mul(t);return e.add(i.mul(n))}),d8=eF(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let i;null!==e?((i=sj.toVar())[3][0]=e.x,i[3][1]=e.y,i[3][2]=e.z):i=sj;let s=sL.mul(i);return ev(t)&&(s[0][0]=sj[0].length(),s[0][1]=0,s[0][2]=0),ev(r)&&(s[1][0]=0,s[1][1]=sj[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,sM.mul(s).mul(s6)}),d5=eF(([e=null])=>{let t=oC();return oC(oT(e)).sub(t).lessThan(0).select(sx,e)});class d9 extends D{static get type(){return"SpriteSheetUVNode"}constructor(e,t=se(),r=eG(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){let{frameNode:e,uvNode:t,countNode:r}=this,{width:i,height:s}=r,n=e.mod(i.mul(s)).floor(),a=n.mod(i),o=s.sub(n.add(1).div(i).ceil()),l=r.reciprocal(),u=eH(a,o);return t.add(u).mul(l)}}let d7=ew(d9).setParameterLength(3),he=eF(([e,t=null,r=null,i=eG(1),s=s6,n=na])=>{let a=n.abs().normalize();a=a.div(a.dot(eX(1)));let o=s.yz.mul(i),l=s.zx.mul(i),u=s.xy.mul(i),d=e.value,h=null!==t?t.value:d,c=null!==r?r.value:d,p=sl(d,o).mul(a.x);return tH(p,sl(h,l).mul(a.y),sl(c,u).mul(a.z))}),ht=new u.Zcv,hr=new u.Pq0,hi=new u.Pq0,hs=new u.Pq0,hn=new u.kn4,ha=new u.Pq0(0,0,-1),ho=new u.IUQ,hl=new u.Pq0,hu=new u.Pq0,hd=new u.IUQ,hh=new u.I9Y,hc=new u.O0B,hp=sx.flipX();hc.depthTexture=new u.VCu(1,1);let hg=!1;class hm extends sa{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||hc.texture,hp),this._reflectorBaseNode=e.reflector||new hf(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=eR(new hm({defaultTexture:hc.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.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class hf extends D{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();let{target:r=new u.B69,resolutionScale:i=1,generateMipmaps:s=!1,bounces:n=!0,depth:a=!1,samples:o=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=i,void 0!==t.resolution&&((0,u.mcG)('THREE.ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=s,this.bounces=n,this.depth=a,this.samples=o,this.updateBeforeType=n?w.RENDER:w.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let r=this.resolutionScale;t.getDrawingBufferSize(hh),e.setSize(Math.round(hh.width*r),Math.round(hh.height*r))}setup(e){return this._updateResolution(hc,e.renderer),super.setup(e)}dispose(){for(let e of(super.dispose(),this.renderTargets.values())
4)e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new u.O0B(0,0,{type:u.ix0,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=u.NZq,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new u.VCu),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&hg)return!1;hg=!0;let{scene:t,camera:r,renderer:i,material:s}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);i.getDrawingBufferSize(hh),this._updateResolution(o,i),hi.setFromMatrixPosition(n.matrixWorld),hs.setFromMatrixPosition(r.matrixWorld),hn.extractRotation(n.matrixWorld),hr.set(0,0,1),hr.applyMatrix4(hn),hl.subVectors(hi,hs);let l=hl.dot(hr)>0,d=!1;if(!0===l&&!1===this.forceUpdate){if(!1===this.hasOutput){hg=!1;return}d=!0}hl.reflect(hr).negate(),hl.add(hi),hn.extractRotation(r.matrixWorld),ha.set(0,0,-1),ha.applyMatrix4(hn),ha.add(hs),hu.subVectors(hi,ha),hu.reflect(hr).negate(),hu.add(hi),a.coordinateSystem=r.coordinateSystem,a.position.copy(hl),a.up.set(0,1,0),a.up.applyMatrix4(hn),a.up.reflect(hr),a.lookAt(hu),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),ht.setFromNormalAndCoplanarPoint(hr,hi),ht.applyMatrix4(a.matrixWorldInverse),ho.set(ht.normal.x,ht.normal.y,ht.normal.z,ht.constant);let h=a.projectionMatrix;hd.x=(Math.sign(ho.x)+h.elements[8])/h.elements[0],hd.y=(Math.sign(ho.y)+h.elements[9])/h.elements[5],hd.z=-1,hd.w=(1+h.elements[10])/h.elements[14],ho.multiplyScalar(1/ho.dot(hd)),h.elements[2]=ho.x,h.elements[6]=ho.y,h.elements[10]=i.coordinateSystem===u.i7u?ho.z-0:ho.z+1-0,h.elements[14]=ho.w,this.textureNode.value=o.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=o.depthTexture),s.visible=!1;let c=i.getRenderTarget(),p=i.getMRT(),g=i.autoClear;i.setMRT(null),i.setRenderTarget(o),i.autoClear=!0,d?(i.clear(),this.hasOutput=!1):(i.render(t,a),this.hasOutput=!0),i.setMRT(p),i.setRenderTarget(c),i.autoClear=g,s.visible=!0,hg=!1,this.forceUpdate=!1}get resolution(){return(0,u.mcG)('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){(0,u.mcG)('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}let hy=new u.qUd(-1,1,1,-1,0,1);class hb extends u.LoY{constructor(e=!1){super(),this.setAttribute("position",new u.qtW([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new u.qtW(!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0],2))}}let hx=new hb;class hT extends u.eaF{constructor(e=null){super(hx,e),this.camera=hy,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,hy)}render(e){e.render(this,hy)}}let h_=new u.I9Y;class hv extends sa{static get type(){return"RTTNode"}constructor(e,t=null,r=null,i={type:u.ix0}){let s=new u.O0B(t,r,i);super(s.texture,se()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new hT(new o$),this.updateBeforeType=w.RENDER}get autoResize(){return null===this.width}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 r=e*this.pixelRatio,i=t*this.pixelRatio;this.renderTarget.setSize(r,i),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoResize){let t=e.getPixelRatio(),r=e.getSize(h_),i=r.width*t,s=r.height*t;(i!==this.renderTarget.width||s!==this.renderTarget.height)&&(this.renderTarget.setSize(i,s),this.textureNeedsUpdate=!0)}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 sa(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}let hN=(e,...t)=>eR(new hv(eR(e),...t)),hS=eF(([e,t,r],i)=>{let s;s=i.renderer.coordinateSystem===u.i7u?eZ(eX(e=eH(e.x,e.y.oneMinus()).mul(2).sub(1),t),1):eZ(eX(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let n=eZ(r.mul(s));return n.xyz.div(n.w)}),hR=eF(([e,t])=>{let r=t.mul(eZ(e,1)),i=r.xy.div(r.w).mul(.5).add(.5).toVar();return eH(i.x,i.y.oneMinus())}),hA=eF(([e,t,r])=>{let i=sr(su(t)),s=eW(e.mul(i)).toVar(),n=su(t,s).toVar(),a=su(t,s.sub(eW(2,0))).toVar(),o=su(t,s.sub(eW(1,0))).toVar(),l=su(t,s.add(eW(1,0))).toVar(),u=su(t,s.add(eW(2,0))).toVar(),d=su(t,s.add(eW(0,2))).toVar(),h=su(t,s.add(eW(0,1))).toVar(),c=su(t,s.sub(eW(0,1))).toVar(),p=su(t,s.sub(eW(0,2))).toVar(),g=rB(tW(eG(2).mul(o).sub(a),n)).toVar(),m=rB(tW(eG(2).mul(l).sub(u),n)).toVar(),f=rB(tW(eG(2).mul(h).sub(d),n)).toVar(),y=rB(tW(eG(2).mul(c).sub(p),n)).toVar(),b=hS(e,n,r).toVar();return rN(rJ(g.lessThan(m).select(b.sub(hS(e.sub(eH(eG(1).div(i.x),0)),o,r)),b.negate().add(hS(e.add(eH(eG(1).div(i.x),0)),l,r))),f.lessThan(y).select(b.sub(hS(e.add(eH(0,eG(1).div(i.y))),h,r)),b.negate().add(hS(e.sub(eH(0,eG(1).div(i.y))),c,r)))))});class hE extends D{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(se())}sample(e){return this.callback(e)}}class hC extends D{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===hC.OBJECT?this.updateType=w.OBJECT:e===hC.MATERIAL&&(this.updateType=w.RENDER)}update(e){this.callback(e)}}hC.OBJECT="object",hC.MATERIAL="material";let hw=(e,t)=>eR(new hC(e,t)).toStack();class hM extends u.uWO{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class hB extends u.THS{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class hL extends D{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}let hP=eM(hL),hF=new u.O9p,hU=new u.kn4;class hI extends D{static get type(){return"SceneNode"}constructor(e=hI.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){let t,r=this.scope,i=null!==this.scene?this.scene:e.scene;return r===hI.BACKGROUND_BLURRINESS?t=nP("backgroundBlurriness","float",i):r===hI.BACKGROUND_INTENSITY?t=nP("backgroundIntensity","float",i):r===hI.BACKGROUND_ROTATION?t=tU("mat4").setName("backgroundRotation").setGroup(tL).onRenderUpd
4ate(()=>{let e=i.background;return null!==e&&e.isTexture&&e.mapping!==u.UTZ?(hF.copy(i.backgroundRotation),hF.x*=-1,hF.y*=-1,hF.z*=-1,hU.makeRotationFromEuler(hF)):hU.identity(),hU}):console.error("THREE.SceneNode: Unknown scope:",r),t}}hI.BACKGROUND_BLURRINESS="backgroundBlurriness",hI.BACKGROUND_INTENSITY="backgroundIntensity",hI.BACKGROUND_ROTATION="backgroundRotation";let hD=eM(hI,hI.BACKGROUND_BLURRINESS),hO=eM(hI,hI.BACKGROUND_INTENSITY),hV=eM(hI,hI.BACKGROUND_ROTATION);class hG extends sa{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=M.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){return null!==this.storeNode?this.generateStore(e):super.generate(e,t)}toReadWrite(){return this.setAccess(M.READ_WRITE)}toReadOnly(){return this.setAccess(M.READ_ONLY)}toWriteOnly(){return this.setAccess(M.WRITE_ONLY)}generateStore(e){let{uvNode:t,storeNode:r,depthNode:i}=e.getNodeProperties(this),s=super.generate(e,"property"),n=t.build(e,!0===this.value.is3DTexture?"uvec3":"uvec2"),a=r.build(e,"vec4"),o=i?i.build(e,"int"):null,l=e.generateTextureStore(e,s,n,o,a);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e}}let hk=ew(hG).setParameterLength(1,3),hz=eF(({texture:e,uv:t})=>{let r=eX().toVar();return eD(t.x.lessThan(1e-4),()=>{r.assign(eX(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{r.assign(eX(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{r.assign(eX(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{r.assign(eX(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{r.assign(eX(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{r.assign(eX(0,0,-1))}).Else(()=>{let i=e.sample(t.add(eX(-.01,0,0))).r.sub(e.sample(t.add(eX(.01,0,0))).r),s=e.sample(t.add(eX(0,-.01,0))).r.sub(e.sample(t.add(eX(0,.01,0))).r),n=e.sample(t.add(eX(0,0,-.01))).r.sub(e.sample(t.add(eX(0,0,.01))).r);r.assign(eX(i,s,n))}),r.normalize()});class h$ extends sa{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return eX(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){let r=this.value;return e.isFlipY()&&(!0===r.isRenderTargetTexture||!0===r.isFramebufferTexture)&&(t=this.sampler?t.flipY():t.setY(ek(sr(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return hz({texture:this,uv:e})}}let hH=ew(h$).setParameterLength(1,3);class hW extends nL{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=null!==this.userData?this.userData:e.object.userData,this.reference}}let hq=new WeakMap;class hj extends G{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=w.OBJECT,this.updateAfterType=w.OBJECT,this.previousModelWorldMatrix=tU(new u.kn4),this.previousProjectionMatrix=tU(new u.kn4).setGroup(tL),this.previousCameraViewMatrix=tU(new u.kn4)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){let i=hK(r);this.previousModelWorldMatrix.value.copy(i);let s=hX(t);s.frameId!==e&&(s.frameId=e,void 0===s.previousProjectionMatrix?(s.previousProjectionMatrix=new u.kn4,s.previousCameraViewMatrix=new u.kn4,s.currentProjectionMatrix=new u.kn4,s.currentCameraViewMatrix=new u.kn4,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){hK(e).copy(e.matrixWorld)}setup(){let e=null===this.projectionMatrix?sM:tU(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(s0).mul(s6),i=this.previousProjectionMatrix.mul(t).mul(s8);return tW(r.xy.div(r.w),i.xy.div(i.w))}}function hX(e){let t=hq.get(e);return void 0===t&&(t={},hq.set(e,t)),t}function hK(e,t=0){let r=hX(e),i=r[t];return void 0===i&&(r[t]=i=new u.kn4,r[t].copy(e.matrixWorld)),i}let hQ=eM(hj),hY=eF(([e])=>
4h1(e.rgb)),hZ=eF(([e,t=eG(1)])=>t.mix(h1(e.rgb),e.rgb)),hJ=eF(([e,t=eG(1)])=>{let r=tH(e.r,e.g,e.b).div(3),i=e.r.max(e.g.max(e.b)),s=i.sub(r).mul(t).mul(-3);return r5(e.rgb,i,s)}),h0=eF(([e,t=eG(1)])=>{let r=eX(.57735,.57735,.57735),i=t.cos();return eX(e.rgb.mul(i).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(rZ(r,e.rgb).mul(i.oneMinus())))))}),h1=(e,t=eX(u.ppV.getLuminanceCoefficients(new u.Pq0)))=>rZ(e,t),h2=eF(([e,t=eX(1),r=eX(0),i=eX(1),s=eG(1),n=eX(u.ppV.getLuminanceCoefficients(new u.Pq0,u.Zr2))])=>{let a=e.rgb.dot(eX(n)),o=rj(e.rgb.mul(t).add(r),0).toVar(),l=o.pow(i).toVar();return eD(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),eD(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),eD(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(s))),eZ(o.rgb,e.a)});class h3 extends G{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)}}let h4=ew(h3).setParameterLength(2),h6=new u.I9Y;class h8 extends sa{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class h5 extends h8{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){let e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e}}class h9 extends G{static get type(){return"PassNode"}constructor(e,t,r,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;let s=new u.VCu;s.isRenderTargetTexture=!0,s.name="depth";let n=new u.O0B(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:u.ix0,...i});n.texture.name="output",n.depthTexture=s,this.renderTarget=n,this._textures={output:n.texture,depth:s},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=tU(0),this._cameraFar=tU(0),this._mrt=null,this._layers=null,this._resolution=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=w.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];return void 0===t&&((t=this.renderTarget.texture.clone()).name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){let t=this._previousTextures[e];if(void 0!==t){let r=this._textures[e],i=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[i]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&((t=eR(new h5(this,e))).updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),(t=eR(new h5(this,e,!0))).updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){let r=this._cameraNear,i=this._cameraFar;this._viewZNodes[e]=t=oS(this.getTextureNode(e),r,i)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){let r=this._cameraNear,i=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=ov(s,r,i)}return t}async compileAsync(e){let t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===h9.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let t,r,{renderer:i}=e,{scene:s}
4=this,n=i.getOutputRenderTarget();n&&!0===n.isXRRenderTarget?(r=1,t=i.xr.getCamera(),i.xr.updateCamera(t),h6.set(n.width,n.height)):(t=this.camera,r=i.getPixelRatio(),i.getSize(h6)),this._pixelRatio=r,this.setSize(h6.width,h6.height);let a=i.getRenderTarget(),o=i.getMRT(),l=t.layers.mask;for(let e in this._cameraNear.value=t.near,this._cameraFar.value=t.far,null!==this._layers&&(t.layers.mask=this._layers.mask),this._previousTextures)this.toggleTexture(e);i.setRenderTarget(this.renderTarget),i.setMRT(this._mrt),i.render(s,t),i.setRenderTarget(a),i.setMRT(o),t.layers.mask=l}setSize(e,t){this._width=e,this._height=t;let r=this._width*this._pixelRatio*this._resolution,i=this._height*this._pixelRatio*this._resolution;this.renderTarget.setSize(r,i),null!==this._scissor&&this.renderTarget.scissor.copy(this._scissor),null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,r,i){null===e?this._scissor=null:(null===this._scissor&&(this._scissor=new u.IUQ),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,i),this._scissor.multiplyScalar(this._pixelRatio*this._resolution).floor())}setViewport(e,t,r,i){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new u.IUQ),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,i),this._viewport.multiplyScalar(this._pixelRatio*this._resolution).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}h9.COLOR="color",h9.DEPTH="depth";class h7 extends h9{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,i,s){super(h9.COLOR,e,t),this.colorNode=r,this.thicknessNode=i,this.alphaNode=s,this._materialCache=new WeakMap}updateBefore(e){let{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((e,r,i,s,n,a,o,l)=>{if((n.isMeshToonMaterial||n.isMeshToonNodeMaterial)&&!1===n.wireframe){let u=this._getOutlineMaterial(n);t.renderObject(e,r,i,s,u,a,o,l)}t.renderObject(e,r,i,s,n,a,o,l)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){let e=new o$;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=u.hsX;let t=na.negate(),r=sM.mul(s0),i=eG(1),s=r.mul(eZ(s6,1)),n=r.mul(eZ(s6.add(t),1)),a=rN(s.sub(n));return e.vertexNode=s.add(a.mul(this.thicknessNode).mul(s.w).mul(i)),e.colorNode=eZ(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return void 0===t&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}let ce=eF(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ct=eF(([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp()).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cr=eF(([e,t])=>{let r=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),i=e.mul(e.mul(6.2).add(1.7)).add(.06);return r.div(i).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),ci=eF(([e])=>{let t=e.mul(e.add(.0245786)).sub(90537e-9),r=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(r)}),cs=eF(([e,t])=>{let r=e3(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=e3(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=ci(e=r.mul(e)),(e=i.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cn=e3(eX(1.6605,-.1246,-.0182),eX(-.5876,1.1329,-.1006),eX(-.0728,-.0083,1.1187)),ca=e3(eX(.6274,.0691,.0164),eX(.3293,.9195,.088),eX(.0433,.0113,.8956)),co=eF(([e])=>{let t=eX(e).toVar(),r=eX(t.mul(t)).toVar(),i=eX(r.mul(r)).toVar();return eG(15.5).mul(i.mul(r)).sub(tq(40.14,i.mul(t))).add(tq(31.96,i).sub(tq(6.868,r.mul(t))).add(tq(.4298,r).add(tq(.1191,t).sub(.00232))))}),cl=eF(([e,t])=>{let r=eX(e).toVar(),i=e3(eX(.856627153315983,.137318972929847,.11189821299995),eX(.0951212405381588,.761241990602591,.0767994186031903),eX(.0482516061458583,.101439036467562,.811302368396859)),s=e3(eX(1.1271005818144368,-.1413297634984383,-.14132976349843826),eX(-.
vendor: 1,520 bytes, line 4
411060664309660323,1.157823702216272,-.11060664309660294),eX(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=eG(-12.47393),a=eG(4.026069);return r.mulAssign(t),r.assign(ca.mul(r)),r.assign(i.mul(r)),r.assign(rj(r,1e-10)),r.assign(rb(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(r9(r,0,1)),r.assign(co(r)),r.assign(s.mul(r)),r.assign(r0(rj(eX(0),r),eX(2.2))),r.assign(cn.mul(r)),r.assign(r9(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cu=eF(([e,t])=>{let r=eG(.76),i=eG(.15),s=rq((e=e.mul(t)).r,rq(e.g,e.b)),n=id(s.lessThan(.08),s.sub(tq(6.25,s.mul(s))),.04);e.subAssign(n);let a=rj(e.r,rj(e.g,e.b));eD(a.lessThan(r),()=>e);let o=tW(1,r),l=tW(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(l.div(a));let u=tW(1,tj(1,i.mul(a.sub(l)).add(1)));return r5(e,eX(l),u)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class cd extends D{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){for(let t of this.getIncludes(e))t.build(e);let t=e.getCodeFromNode(this,this.getNodeType(e));return t.code=this.code,t.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}}
4let ch=ew(cd).setParameterLength(1,3);class cc extends cd{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){let t=e.getDataFromNode(this),r=t.nodeFunction;return void 0===r&&(t.nodeFunction=r=e.parser.parseFunction(this.code)),r}generate(e,t){super.generate(e);let r=this.getNodeFunction(e),i=r.name,s=r.type,n=e.getCodeFromNode(this,s);""!==i&&(n.name=i);let a=e.getPropertyName(n);return(n.code=this.getNodeFunction(e).getCode(a)+"\n","property"===t)?a:e.format(`${a}()`,s,t)}}let cp=(e,t=[],r="")=>{for(let e=0;e<t.length;e++){let r=t[e];"function"==typeof r&&(t[e]=r.functionNode)}let i=eR(new cc(e,t,r)),s=(...e)=>i.call(...e);return s.functionNode=i,s};class cg extends D{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new u.Qev,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&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&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&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:eG()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=A(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?E(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}let cm=ew(cg).setParameterLength(1);class cf extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(null!==t){let i=t(...r);return this.set(e,i),i}}}class cy{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];return t?t.getValue():null}}let cb=new cf;class cx extends D{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new cf,this._output=cm(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 r=this._outputs;return void 0===r[e]?r[e]=cm(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){let r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):void 0===r[e]?(r[e]=cm(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[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 r=this.getObject()[e];if("function"==typeof r)return r(...t)}async callAsync(e,...t){let r=this.getObject()[e];if("function"==typeof r)return"AsyncFunction"===r.constructor.name?await r(...t):r(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;let e=()=>this.refresh(),t=(e,t)=>this.setOutput(e,t),r=new cy(this),i=cb.get("THREE"),s=cb.get("TSL"),n=this.getMethod(),a=[r,this._local,cb,e,t,i,s];this._object=n(...a);let o=this._object.layout;
4if(o&&(!1===o.cache&&this._local.clear(),this._output.outputType=o.outputType||null,Array.isArray(o.elements)))for(let e of o.elements){let t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&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:eG()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;let e="layout, init, main, dispose",t="var "+e+"; var output = {};\n"+this.codeNode.code+"\nreturn { ...output, "+e+" };";return this._method=Function("parameters","local","global","refresh","setOutput","THREE","TSL",t),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&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=[g(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return m(t)}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}let cT=ew(cx).setParameterLength(1,2);function c_(e){let t,r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||s7.z).negate()}let cv=eF(([e,t],r)=>it(e,t,c_(r))),cN=eF(([e],t)=>{let r=c_(t);return e.mul(e,r,r).negate().exp().oneMinus()}),cS=eF(([e,t])=>eZ(t.toFloat().mix(tb.rgb,e.toVec3()),tb.a)),cR=null,cA=null;class cE extends D{static get type(){return"RangeNode"}constructor(e=eG(),t=eG()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(N(this.minNode.value)),r=e.getTypeLength(N(this.maxNode.value));return t>r?t:r}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){let t=e.object,r=null;if(t.count>1){let i=this.minNode.value,s=this.maxNode.value,n=e.getTypeLength(N(i)),a=e.getTypeLength(N(s));cR=cR||new u.IUQ,cA=cA||new u.IUQ,cR.setScalar(0),cA.setScalar(0),1===n?cR.setScalar(i):i.isColor?cR.set(i.r,i.g,i.b,1):cR.set(i.x,i.y,i.z||0,i.w||0),1===a?cA.setScalar(s):s.isColor?cA.set(s.r,s.g,s.b,1):cA.set(s.x,s.y,s.z||0,s.w||0);let o=4*t.count,l=new Float32Array(o);for(let e=0;e<o;e++){let t=e%4,r=cR.getComponent(t),i=cA.getComponent(t);l[e]=u.cj9.lerp(r,i,Math.random())}let d=this.getNodeType(e);if(t.count<=4096)r=sh(l,"vec4",t.count).element(aj).convert(d);else{let t=new u.uWO(l,4);e.geometry.setAttribute("__range"+this.id,t),r=i$(t).convert(d)}}else r=eG(0);return r}}let cC=ew(cE).setParameterLength(2);class cw extends D{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 r=this.getBuiltinName(e),i=this.getNodeType(e);return"compute"===e.shaderStage?e.format(r,i,t):(console.warn(`ComputeBuiltinNode: Compute built-in value ${r} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(i))}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}}let cM=(e,t)=>eR(new cw(e,t)),cB=cM("numWorkgroups","uvec3"),cL=cM("workgroupId","uvec3"),cP=cM("globalId","uvec3"),cF=cM("localId","uvec3"),cU=cM("subgroupSize","uint");class cI extends D{constructor(e){super(),this.scope=e}generate(e){let{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`	// ${t}Barrier 
5`):e.addLineFlowCode(`${t}Barrier()`,this)}}let cD=ew(cI);class cO extends O{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r,i=e.context.assign;if(r=super.generate(e),!0!==i){let i=this.getNodeType(e);r=e.format(r,i,t)}return r}}class cV extends D{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}
5setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return eR(new cO(this,e))}generate(e){let t=""!==this.name?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}class cG extends D{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),r=t.parents,i=this.method,s=this.getNodeType(e),n=this.getInputType(e),a=this.pointerNode,o=this.valueNode,l=[];l.push(`&${a.build(e,n)}`),null!==o&&l.push(o.build(e,n));let u=`${e.getMethod(i,s)}( ${l.join(", ")} )`;if(!(r&&1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=i2(u,s).toConst()),t.constNode.build(e);e.addLineFlowCode(u,this)}}cG.ATOMIC_LOAD="atomicLoad",cG.ATOMIC_STORE="atomicStore",cG.ATOMIC_ADD="atomicAdd",cG.ATOMIC_SUB="atomicSub",cG.ATOMIC_MAX="atomicMax",cG.ATOMIC_MIN="atomicMin",cG.ATOMIC_AND="atomicAnd",cG.ATOMIC_OR="atomicOr",cG.ATOMIC_XOR="atomicXor";let ck=ew(cG),cz=(e,t,r)=>ck(e,t,r).toStack();class c$ extends G{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(r)?0:e.getTypeLength(r))?t:r}getNodeType(e){let t=this.method;return t===c$.SUBGROUP_ELECT?"bool":t===c$.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){let r=this.method,i=this.getNodeType(e),s=this.getInputType(e),n=this.aNode,a=this.bNode,o=[];if(r===c$.SUBGROUP_BROADCAST||r===c$.SUBGROUP_SHUFFLE||r===c$.QUAD_BROADCAST){let t=a.getNodeType(e);o.push(n.build(e,i),a.build(e,"float"===t?"int":i))}else r===c$.SUBGROUP_SHUFFLE_XOR||r===c$.SUBGROUP_SHUFFLE_DOWN||r===c$.SUBGROUP_SHUFFLE_UP?o.push(n.build(e,i),a.build(e,"uint")):(null!==n&&o.push(n.build(e,s)),null!==a&&o.push(a.build(e,s)));let l=0===o.length?"()":`( ${o.join(", ")} )`;return e.format(`${e.getMethod(r,i)}${l}`,i,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}c$.SUBGROUP_ELECT="subgroupElect",c$.SUBGROUP_BALLOT="subgroupBallot",c$.SUBGROUP_ADD="subgroupAdd",c$.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",c$.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",c$.SUBGROUP_MUL="subgroupMul",c$.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",c$.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",c$.SUBGROUP_AND="subgroupAnd",c$.SUBGROUP_OR="subgroupOr",c$.SUBGROUP_XOR="subgroupXor",c$.SUBGROUP_MIN="subgroupMin",c$.SUBGROUP_MAX="subgroupMax",c$.SUBGROUP_ALL="subgroupAll",c$.SUBGROUP_ANY="subgroupAny",c$.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",c$.QUAD_SWAP_X="quadSwapX",c$.QUAD_SWAP_Y="quadSwapY",c$.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",c$.SUBGROUP_BROADCAST="subgroupBroadcast",c$.SUBGROUP_SHUFFLE="subgroupShuffle",c$.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",c$.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",c$.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",c$.QUAD_BROADCAST="quadBroadcast";let cH=eB(c$,c$.SUBGROUP_ELECT).setParameterLength(0),cW=eB(c$,c$.SUBGROUP_BALLOT).setParameterLength(1),cq=eB(c$,c$.SUBGROUP_ADD).setParameterLength(1),cj=eB(c$,c$.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),cX=eB(c$,c$.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),cK=eB(c$,c$.SUBGROUP_MUL).setParameterLength(1),cQ=eB(c$,c$.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),cY=eB(c$,c$.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),cZ=eB(c$,c$.SUBGROUP_AND).setParameterLength(1),cJ=eB(c$,c$.SUBGROUP_OR).setParameterLength(1),c0=eB(c$,c$.SUBGROUP_XOR).setParameterLength(1),c1=eB(c$,c$.SUBGROUP_MIN).setParameterLength(1),c2=eB(c$,c$.SUBGROUP_MAX).setParameterLength(1),c3=eB(c$,c$.SUBGROUP_ALL).setParameterLength(0),c4=eB(c$,c$.SUBGROUP_ANY).setParameterLength(0),c6=eB(c$,c$.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),c8=eB(c$,c$.QUAD_SWAP_X).setParameterLength(1),c5=eB(c$,c$.QUAD_SWAP_Y).setParameterLength(1),c9=eB(c$,c$.QUAD_SWAP_DIAGONAL).setParameterLength(1),c7=eB(c$,c$.SUBGROUP_BROADCAST).setParameterLength(2),pe=eB(c$,c$.SUBGROUP_SHUFFLE).setParameterLength(2),pt=eB(c$,c$.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),pr=eB(c$,c$.SUBGROUP_SHUFFLE_UP).setParameterLength(2),pi=eB(c$,c$.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),ps=eB(c$,c$.QUAD_BROADCAST).setParameterLength(1);function pn(e){let t=(n=n||new WeakMap).get(e);return void 0===t&&n.set(e,t={}),t}function pa(e){let t=pn(e);return t.shadowMatrix||(t.shadowMatrix=tU("mat4").setGroup(tL).onRenderUpd
5ate(t=>((!0!==e.castShadow||!1===t.renderer.shadowMap.enabled)&&e.shadow.updateMatrices(e),e.shadow.matrix)))}function po(e,t=s5){let r=pa(e).mul(t);return r.xyz.div(r.w)}function pl(e){let t=pn(e);return t.position||(t.position=tU(new u.Pq0).setGroup(tL).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function pu(e){let t=pn(e);return t.targetPosition||(t.targetPosition=tU(new u.Pq0).setGroup(tL).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function pd(e){let t=pn(e);return t.viewPosition||(t.viewPosition=tU(new u.Pq0).setGroup(tL).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new u.Pq0,r.value.setFromMatrixPosition(e.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}let ph=e=>sL.transformDirection(pl(e).sub(pu(e))),pc=(e,t)=>{for(let r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},pp=new WeakMap,pg=[];class pm extends D{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=e9("vec3","totalDiffuse"),this.totalSpecularNode=e9("vec3","totalSpecular"),this.outgoingLightNode=e9("vec3","outgoingLight"),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 r=e[t];
5if(pg.push(r.id),pg.push(+!!r.castShadow),!0===r.isSpotLight){let e=null!==r.map?r.map.id:-1,t=r.colorNode?r.colorNode.getCacheKey():-1;pg.push(e,t)}}let t=m(pg);return pg.length=0,t}getHash(e){if(null===this._lightNodesHash){null===this._lightNodes&&this.setupLightsNode(e);let t=[];for(let e of this._lightNodes)t.push(e.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){let t=e.getNodeProperties(this);for(let r of t.nodes)r.build(e);t.outputNode.build(e)}setupLightsNode(e){let t=[],r=this._lightNodes,i=this._lights.sort((e,t)=>e.id-t.id),s=e.renderer.library;for(let e of i)if(e.isNode)t.push(eR(e));else{let i=null;if(null!==r&&(i=pc(e.id,r)),null===i){let r=s.getLightNodeClass(e.constructor);if(null===r){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}let i=null;pp.has(e)?i=pp.get(e):(i=eR(new r(e)),pp.set(e,i)),t.push(i)}}this._lightNodes=t}setupDirectLight(e,t,r){let{lightingModel:i,reflectedLight:s}=e.context;i.direct({...r,lightNode:t,reflectedLight:s},e)}setupDirectRectAreaLight(e,t,r){let{lightingModel:i,reflectedLight:s}=e.context;i.directRectArea({...r,lightNode:t,reflectedLight:s},e)}setupLights(e,t){for(let r of t)r.build(e)}getLightNodes(e){return null===this._lightNodes&&this.setupLightsNode(e),this._lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode,i=e.context,s=i.lightingModel,n=e.getNodeProperties(this);if(s){let{totalDiffuseNode:t,totalSpecularNode:a}=this;i.outgoingLight=r,n.nodes=e.addStack().nodes,s.start(e);let{backdrop:o,backdropAlpha:l}=i,{directDiffuse:u,directSpecular:d,indirectDiffuse:h,indirectSpecular:c}=i.reflectedLight,p=u.add(h);null!==o&&(p=null!==l?eX(l.mix(p,o)):eX(o),i.material.transparent=!0),t.assign(p),a.assign(d.add(c)),r.assign(t.add(a)),s.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class pf extends D{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=w.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){py.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||s5)}}let py=e9("vec3","shadowPositionWorld"),pb=new WeakMap,px=eF(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let i=sl(e,t.xy).setName("t_basic");return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)}),pT=eF(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{let s=(t,r)=>{let s=sl(e,t);return e.isArrayTexture&&(s=s.depth(i)),s.compare(r)},n=nP("mapSize","vec2",r).setGroup(tL),a=nP("radius","float",r).setGroup(tL),o=eH(1).div(n),l=o.x.negate().mul(a),u=o.y.negate().mul(a),d=o.x.mul(a),h=o.y.mul(a),c=l.div(2),p=u.div(2),g=d.div(2),m=h.div(2);return tH(s(t.xy.add(eH(l,u)),t.z),s(t.xy.add(eH(0,u)),t.z),s(t.xy.add(eH(d,u)),t.z),s(t.xy.add(eH(c,p)),t.z),s(t.xy.add(eH(0,p)),t.z),s(t.xy.add(eH(g,p)),t.z),s(t.xy.add(eH(l,0)),t.z),s(t.xy.add(eH(c,0)),t.z),s(t.xy,t.z),s(t.xy.add(eH(g,0)),t.z),s(t.xy.add(eH(d,0)),t.z),s(t.xy.add(eH(c,m)),t.z),s(t.xy.add(eH(0,m)),t.z),s(t.xy.add(eH(g,m)),t.z),s(t.xy.add(eH(l,h)),t.z),s(t.xy.add(eH(0,h)),t.z),s(t.xy.add(eH(d,h)),t.z)).mul(1/17)}),p_=eF(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{let s=(t,r)=>{let s=sl(e,t);return e.isArrayTexture&&(s=s.depth(i)),s.compare(r)},n=nP("mapSize","vec2",r).setGroup(tL),a=eH(1).div(n),o=a.x,l=a.y,u=t.xy,d=rS(u.mul(n).add(.5));return u.subAssign(d.mul(a)),tH(s(u,t.z),s(u.add(eH(o,0)),t.z),s(u.add(eH(0,l)),t.z),s(u.add(a),t.z),r5(s(u.add(eH(o.negate(),0)),t.z),s(u.add(eH(o.mul(2),0)),t.z),d.x),r5(s(u.add(eH(o.negate(),l)),t.z),s(u.add(eH(o.mul(2),l)),t.z),d.x),r5(s(u.add(eH(0,l.negate())),t.z),s(u.add(eH(0,l.mul(2))),t.z),d.y),r5(s(u.add(eH(o,l.negate())),t.z),s(u.add(eH(o,l.mul(2))),t.z),d.y),r5(r5(s(u.add(eH(o.negate(),l.negate())),t.z),s(u.add(eH(o.mul(2),l.negate())),t.z),d.x),r5(s(u.add(eH(o.negate(),l.mul(2))),t.z),s(u.add(eH(o.mul(2),l.mul(2))),t.z),d.x),d.y)).mul(1/9)}),pv=eF(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let i=eG(1).toVar(),s=sl(e).sample(t.xy);e.isArrayTexture&&(s=s.depth(r)),s=s.rg;let n=rX(t.z,s.x);return eD(n.notEqual(eG(1)),()=>{let e=t.z.sub(s.x),r=rj(0,s.y.mul(s.y)),a=r.div(r.add(e.mul(e)));a=r9(tW(a,.3).div(.95-.3)),i.assign(r9(rj(n,a)))}),i}),pN=eF(([e,t,r])=>{let i=s5.sub(e).length();return(i=i.sub(t).div(r.sub(t))).saturate()}),pS=e=>{let t=pb.get(e);if(void 0===t){let r=e.isPointLight?(e=>{let t=e.shadow.camera,r=nP("near","float",t).setGroup(tL),i=nP("far","float",t).setGroup(tL);return pN(sk(e),r,i)})(e):null;(t=new o$).colorNode=eZ(0,0,0,1),t.depthNode=r,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,pb.set(e,t)}return t},pR=new u7,pA=[],pE=(e,t,r,i)=>{pA[0]=e,pA[1]=t;let s=pR.get(pA);return(void 0===s||s.shadowType!==r||s.useVelocity!==i)&&((s=(s,n,a,o,l,d,...h)=>{(!0===s.castShadow||s.receiveShadow&&r===u.RyA)&&(i&&(R(s).useVelocity=!0),s.onBeforeShadow(e,s,a,t.camera,o,n.overrideMaterial,d),e.renderObject(s,n,a,o,l,d,...h),s.onAfterShadow(e,s,a,t.camera,o,n.overrideMaterial,d))}).shadowType=r,s.useVelocity=i,pR.set(pA,s)),pA[0]=null,pA[1]=null,s}
5,pC=eF(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:s})=>{let n=eG(0).toVar("meanVertical"),a=eG(0).toVar("squareMeanVertical"),o=e.lessThanEqual(eG(1)).select(eG(0),eG(2).div(e.sub(1))),l=e.lessThanEqual(eG(1)).select(eG(0),eG(-1));or({start:ek(0),end:ek(e),type:"int",condition:"<"},({i:e})=>{let u=l.add(eG(e).mul(o)),d=i.sample(tH(s_.xy,eH(0,u).mul(t)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),d=d.x,n.addAssign(d),a.addAssign(d.mul(d))}),n.divAssign(e),a.divAssign(e);let u=rx(a.sub(n.mul(n)));return eH(n,u)}),pw=eF(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:s})=>{let n=eG(0).toVar("meanHorizontal"),a=eG(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(eG(1)).select(eG(0),eG(2).div(e.sub(1))),l=e.lessThanEqual(eG(1)).select(eG(0),eG(-1));or({start:ek(0),end:ek(e),type:"int",condition:"<"},({i:e})=>{let u=l.add(eG(e).mul(o)),d=i.sample(tH(s_.xy,eH(u,0).mul(t)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),n.addAssign(d.x),a.addAssign(tH(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(e),a.divAssign(e);let u=rx(a.sub(n.mul(n)));return eH(n,u)}),pM=[px,pT,p_,pv],pB=new hT;class pL extends pf{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:r,shadowCoord:i,shadow:s,depthLayer:n}){let a=i.x.greaterThanEqual(0).and(i.x.lessThanEqual(1)).and(i.y.greaterThanEqual(0)).and(i.y.lessThanEqual(1)).and(i.z.lessThanEqual(1)),o=t({depthTexture:r,shadowCoord:i,shadow:s,depthLayer:n});return a.select(o,eG(1))}setupShadowCoord(e,t){let r,{shadow:i}=this,{renderer:s}=e,n=nP("bias","float",i).setGroup(tL),a=t;if(i.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)r=(a=a.xyz.div(a.w)).z,s.coordinateSystem===u.i7u&&(r=r.mul(2).sub(1));else{let e=a.w;a=a.xy.div(e);let t=nP("near","float",i.camera).setGroup(tL),s=nP("far","float",i.camera).setGroup(tL);r=oR(e.negate(),t,s)}return eX(a.x,a.y.oneMinus(),r.add(n))}getShadowFilterFn(e){return pM[e]}setupRenderTarget(e,t){let r=new u.VCu(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=u.vim;let i=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return i.texture.name="ShadowMap",i.texture.type=e.mapType,i.depthTexture=r,{shadowMap:i,depthTexture:r}}setupShadow(e){let{renderer:t}=e,{light:r,shadow:i}=this,s=t.shadowMap.type,{depthTexture:n,shadowMap:a}=this.setupRenderTarget(i,e);if(i.camera.updateProjectionMatrix(),s===u.RyA&&!0!==i.isPointLightShadow){n.compareFunction=null,a.depth>1?(a._vsmShadowMapVertical||(a._vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:u.paN,type:u.ix0,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=a._vsmShadowMapVertical,a._vsmShadowMapHorizontal||(a._vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:u.paN,type:u.ix0,depth:a.depth,depthBuffer:!1}),a._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=a._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:u.paN,type:u.ix0,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(i.mapSize.width,i.mapSize.height,{format:u.paN,type:u.ix0,depthBuffer:!1}));let t=sl(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=sl(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));let s=nP("blurSamples","float",i).setGroup(tL),o=nP("radius","float",i).setGroup(tL),l=nP("mapSize","vec2",i).setGroup(tL),d=this.vsmMaterialVertical||(this.vsmMaterialVertical=new o$);d.fragmentNode=pC({samples:s,radius:o,size:l,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),d.name="VSMVertical",(d=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new o$)).fragmentNode=pw({samples:s,radius:o,size:l,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),d.name="VSMHorizontal"}let o=nP("intensity","float",i).setGroup(tL),l=nP("normalBias","float",i).setGroup(tL),d=pa(r).mul(py.add(nh.mul(l))),h=this.setupShadowCoord(e,d),c=i.filterNode||this.get
5ShadowFilterFn(t.shadowMap.type)||null;if(null===c)throw Error("THREE.WebGPURenderer: Shadow map type not supported yet.");let p=s===u.RyA&&!0!==i.isPointLightShadow?this.vsmShadowMapHorizontal.texture:n,g=this.setupShadowFilter(e,{filterFn:c,shadowTexture:a.texture,depthTexture:p,shadowCoord:h,shadow:i,depthLayer:this.depthLayer}),m=sl(a.texture,h);n.isArrayTexture&&(m=m.depth(this.depthLayer));let f=r5(1,g.rgb.mix(m,1),o.mul(m.a)).toVar();return this.shadowMap=a,this.shadow.map=a,f}setup(e){if(!1!==e.renderer.shadowMap.enabled)return eF(()=>{let t=this._node;return this.setupShadowPosition(e),null===t&&(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:r,light:i}=this,{renderer:s,scene:n}=e;t.updateMatrices(i),r.setSize(t.mapSize.width,t.mapSize.height,r.depth),s.render(n,t.camera)}updateShadow(e){var t,r,i;let{shadowMap:s,light:n,shadow:o}=this,{renderer:l,scene:d,camera:h}=e,c=l.shadowMap.type,p=s.depthTexture.version;this._depthVersionCached=p;let g=o.camera.layers.mask;(0xfffffffe&o.camera.layers.mask)==0&&(o.camera.layers.mask=h.layers.mask);let m=l.getRenderObjectFunction(),f=l.getMRT(),y=!!f&&f.has("velocity");t=function(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 u.Q1f),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}(l,t=a),l.setMRT(null),l.setRenderObjectFunction(null),l.setClearColor(0,1),l.autoClear=!0,r=function(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}(d,r=t),d.background=null,d.backgroundNode=null,d.overrideMaterial=null,a=r,d.overrideMaterial=pS(n),l.setRenderObjectFunction(pE(l,o,c,y)),l.setClearColor(0,0),l.setRenderTarget(s),this.renderShadow(e),l.setRenderObjectFunction(m),c===u.RyA&&!0!==o.isPointLightShadow&&this.vsmPass(l),o.camera.layers.mask=g,l.toneMapping=(i=a).toneMapping,l.toneMappingExposure=i.toneMappingExposure,l.outputColorSpace=i.outputColorSpace,l.setRenderTarget(i.renderTarget,i.activeCubeFace,i.activeMipmapLevel),l.setRenderObjectFunction(i.renderObjectFunction),l.setPixelRatio(i.pixelRatio),l.setMRT(i.mrt),l.setClearColor(i.clearColor,i.clearAlpha),l.autoClear=i.autoClear,l.setScissorTest(i.scissorTest),d.background=i.background,d.backgroundNode=i.backgroundNode,d.overrideMaterial=i.overrideMaterial}vsmPass(e){let{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),pB.material=this.vsmMaterialVertical,pB.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),pB.material=this.vsmMaterialHorizontal,pB.render(e)}dispose(){this.shadowMap.dispose(),this.shadowMap=null,null!==this.vsmShadowMapVertical&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),null!==this.vsmShadowMapHorizontal&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null),super.dispose()}updateBefore(e){let{shadow:t}=this,r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}let pP=(e,t)=>eR(new pL(e,t)),pF=new u.Q1f,pU=eF(([e,t])=>{let r=e.toVar(),i=rB(r),s=tj(1,rj(i.x,rj(i.y,i.z)));i.mulAssign(s),r.mulAssign(s.mul(t.mul(2).oneMinus()));let n=eH(r.xy).toVar(),a=t.mul(1.5).oneMinus();return eD(i.z.greaterThanEqual(a),()=>{eD(r.z.greaterThan(0),()=>{n.x.assign(tW(4,r.x))})}).ElseIf(i.x.greaterThanEqual(a),()=>{let e=rL(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))}).ElseIf(i.y.greaterThanEqual(a),()=>{let e=rL(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))}),eH(.125,.25).mul(n).add(eH(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),pI=eF(({depthTexture:e,bd3D:t,dp:r,texelSize:i})=>sl(e,pU(t,i.y)).compare(r)),pD=eF(({depthTexture:e,bd3D:t,dp:r,texelSize:i,shadow:s})=>{let n=nP("radius","float",s).setGroup(tL),a=eH(-1,1).mul(n).mul(i.y);return sl(e,pU(t.add(a.xyy),i.y)).compare(r).add(sl(e,pU(t.add(a.yyy),i.y)).compare(r)).add(sl(e,pU(t.add(a.xyx),i.y)).compare(r)).add(sl(e,pU(t.add(a.yyx),i.y)).compare(r)).add(sl(e,pU(t,i.y)).compare(r)).add(sl(e,pU(t.add(a.xxy),i.y)).compare(r)).add(sl(e,pU(t.add(a.yxy),i.y)).compare(r)).add(sl(e,pU(t.add(a.xxx),i.y)).compare(r)).add(sl(e,pU(t.add(a.yxx),i.y)).compare(r)).mul(1/9)}),pO=eF(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:i})=>{let s=r.xyz.toVar(),n=s.length(),a=tU("float").setGroup(tL).onRenderUpd
5ate(()=>i.camera.near),o=tU("float").setGroup(tL).onRenderUpdate(()=>i.camera.far),l=nP("bias","float",i).setGroup(tL),u=tU(i.mapSize).setGroup(tL),d=eG(1).toVar();return eD(n.sub(o).lessThanEqual(0).and(n.sub(a).greaterThanEqual(0)),()=>{let r=n.sub(a).div(o.sub(a)).toVar();r.addAssign(l);let h=s.normalize(),c=eH(1).div(u.mul(eH(4,2)));d.assign(e({depthTexture:t,bd3D:h,dp:r,texelSize:c,shadow:i}))}),d}),pV=new u.IUQ,pG=new u.I9Y,pk=new u.I9Y;class pz extends pL{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===u.bTm?pI:pD}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:i,shadowCoord:s,shadow:n}){return pO({filterFn:t,shadowTexture:r,depthTexture:i,shadowCoord:s,shadow:n})}renderShadow(e){let{shadow:t,shadowMap:r,light:i}=this,{renderer:s,scene:n}=e,a=t.getFrameExtents();pk.copy(t.mapSize),pk.multiply(a),r.setSize(pk.width,pk.height),pG.copy(t.mapSize);let o=s.autoClear,l=s.getClearColor(pF),u=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha),s.clear();let d=t.getViewportCount();for(let e=0;e<d;e++){let a=t.getViewport(e),o=pG.x*a.x,l=pk.y-pG.y-pG.y*a.y;pV.set(o,l,pG.x*a.z,pG.y*a.w),r.viewport.copy(pV),t.updateMatrices(i,e),s.render(n,t.camera)}s.autoClear=o,s.setClearColor(l,u)}}let p$=(e,t)=>eR(new pz(e,t));class pH extends ou{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new u.Q1f,this.colorNode=e&&e.colorNode||tU(this.color).setGroup(tL),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=w.FRAME}getHash(){return this.light.uuid}getLightVector(e){return pd(this.light).sub(e.context.positionView||s7)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return pP(this.light)}setupShadow(e){let{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){let e,t=this.light.shadow.shadowNode;e=void 0!==t?eR(t):this.setupShadowNode(),this.shadowNode=e,this.shadowColorNode=r=this.colorNode.mul(e),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);let t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){let{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}let pW=eF(({lightDistance:e,cutoffDistance:t,decayExponent:r})=>{let i=e.pow(r).max(.01).reciprocal();return t.greaterThan(0).select(i.mul(e.div(t).pow4().oneMinus().clamp().pow2()),i)}),pq=({color:e,lightVector:t,cutoffDistance:r,decayExponent:i})=>{let s=t.normalize(),n=pW({lightDistance:t.length(),cutoffDistance:r,decayExponent:i});return{lightDirection:s,lightColor:e.mul(n)}};class pj extends pH{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=tU(0).setGroup(tL),this.decayExponentNode=tU(2).setGroup(tL)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return p$(this.light)}setupDirect(e){return pq({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}let pX=eF(([e=se()])=>{let t=e.mul(2),r=t.x.floor(),i=t.y.floor();return r.add(i).mod(2).sign()}),pK=eF(([e=se()],{renderer:t,material:r})=>{let i,s=r8(e.mul(2).sub(1));if(r.alphaToCoverage&&t.samples>1){let e=eG(s.fwidth()).toVar();i=it(e.oneMinus(),e.add(1),s).oneMinus()}else i=id(s.greaterThan(1),0,1);return i}),pQ=eF(([e,t,r])=>{let i=eG(r).toVar(),s=eG(t).toVar();return id(e$(e).toVar(),s,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),pY=eF(([e,t])=>{let r=e$(t).toVar(),i=eG(e).toVar();return id(r,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),pZ=eF(([e])=>ek(r_(eG(e).toVar()))).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),pJ=eF(([e,t])=>{let r=eG(e).toVar();return t.assign(pZ(r)),r.sub(eG(t))}),p0=d0([eF(([e,t,r,i,s,n])=>{let a=eG(n).toVar(),o=eG(s).toVar(),l=eG(i).toVar(),u=eG(r).toVar(),d=eG(t).toVar(),h=eG(e).toVar(),c=eG(tW(1,o)).toVar();return tW(1,a).mul(h.mul(c).add(d.mul(o))).add(a.mul(u.mul(c).add(l.mul(o))))}).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"}]}),eF(([e,t,r,i,s,n])=>{let a=eG(n).toVar(),o=eG(s).toVar(),l=eX(i).toVar(),u=eX(r).toVar(),d=eX(t).toVar(),h=eX(e).toVar(),c=eG(tW(1,o)).toVar();return tW(1,a).mul(h.mul(c).add(d.mul(o))).add(a.mul(u.mul(c).add(l.mul(o))))}
vendor: 4,297 bytes, line 5
5).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"}]})]),p1=d0([eF(([e,t,r,i,s,n,a,o,l,u,d])=>{let h=eG(d).toVar(),c=eG(u).toVar(),p=eG(l).toVar(),g=eG(o).toVar(),m=eG(a).toVar(),f=eG(n).toVar(),y=eG(s).toVar(),b=eG(i).toVar(),x=eG(r).toVar(),T=eG(t).toVar(),_=eG(e).toVar(),v=eG(tW(1,p)).toVar(),N=eG(tW(1,c)).toVar();return eG(tW(1,h)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(c.mul(x.mul(v).add(b.mul(p))))).add(h.mul(N.mul(y.mul(v).add(f.mul(p))).add(c.mul(m.mul(v).add(g.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"}]}),eF(([e,t,r,i,s,n,a,o,l,u,d])=>{let h=eG(d).toVar(),c=eG(u).toVar(),p=eG(l).toVar(),g=eX(o).toVar(),m=eX(a).toVar(),f=eX(n).toVar(),y=eX(s).toVar(),b=eX(i).toVar(),x=eX(r).toVar(),T=eX(t).toVar(),_=eX(e).toVar(),v=eG(tW(1,p)).toVar(),N=eG(tW(1,c)).toVar();return eG(tW(1,h)).toVar().mul(N.mul(_.mul(v).add(T.mul(p))).add(c.mul(x.mul(v).add(b.mul(p))))).add(h.mul(N.mul(y.mul(v).add(f.mul(p))).add(c.mul(m.mul(v).add(g.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"}]})]),p2=d0([eF(([e,t,r])=>{let i=eG(r).toVar(),s=eG(t).toVar(),n=ez(e).toVar(),a=ez(n.bitAnd(ez(7))).toVar(),o=eG(pQ(a.lessThan(ez(4)),s,i)).toVar(),l=eG(tq(2,pQ(a.lessThan(ez(4)),i,s))).toVar();return pY(o,e$(a.bitAnd(ez(1)))).add(pY(l,e$(a.bitAnd(ez(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),eF(([e,t,r,i])=>{let s=eG(i).toVar(),n=eG(r).toVar(),a=eG(t).toVar(),o=ez(e).toVar(),l=ez(o.bitAnd(ez(15))).toVar(),u=eG(pQ(l.lessThan(ez(8)),a,n)).toVar(),d=eG(pQ(l.lessThan(ez(4)),n,pQ(l.equal(ez(12)).or(l.equal(ez(14))),a,s))).toVar();return pY(u,e$(l.bitAnd(ez(1)))).add(pY(d,e$(l.bitAnd(ez(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"}]})]),p3=d0([eF(([e,t,r])=>{let i=eG(r).toVar(),s=eG(t).toVar(),n=eQ(e).toVar();return eX(p2(n.x,s,i),p2(n.y,s,i),p2(n.z,s,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),eF(([e,t,r,i])=>{let s=eG(i).toVar(),n=eG(r).toVar(),a=eG(t).toVar(),o=eQ(e).toVar();return eX(p2(o.x,a,n,s),p2(o.y,a,n,s),p2(o.z,a,n,s))}).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"}]})]),p4=eF(([e])=>tq(.6616,eG(e).toVar())).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),p6=eF(([e])=>tq(.982,eG(e).toVar())).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),p8=d0([p4,eF(([e])=>tq(.6616,eX(e).toVar())).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),p5=d0([p6,eF(([e])=>tq(.982,eX(e).toVar())).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),p9=eF(([e,t])=>{let r=ek(t).toVar(),i=ez(e).toVar();return i.shiftLeft(r).bitOr(i.shiftRight(ek(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),p7=eF(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(p9(r,ek(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(p9(e,ek(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(p9(t,ek(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(p9(r,ek(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(p9(e,ek(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(p9(t,ek(4))),t.addAssign(e)}),ge=eF(([e,t,r])=>{let i=ez(r).toVar(),s=ez(t).toVar(),n=ez(e).toVar();
5return i.bitXorAssign(s),i.subAssign(p9(s,ek(14))),n.bitXorAssign(i),n.subAssign(p9(i,ek(11))),s.bitXorAssign(n),s.subAssign(p9(n,ek(25))),i.bitXorAssign(s),i.subAssign(p9(s,ek(16))),n.bitXorAssign(i),n.subAssign(p9(i,ek(4))),s.bitXorAssign(n),s.subAssign(p9(n,ek(14))),i.bitXorAssign(s),i.subAssign(p9(s,ek(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),gt=eF(([e])=>eG(ez(e).toVar()).div(eG(ez(ek(0xffffffff))))).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),gr=eF(([e])=>{let t=eG(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"}]}),gi=eF(([e])=>{let t=ek(e).toVar(),r=ez(ez(1)).toVar(),i=ez(ez(ek(0xdeadbeef)).add(r.shiftLeft(ez(2))).add(ez(13))).toVar();return ge(i.add(ez(t)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),gs=eF(([e,t])=>{let r=ek(t).toVar(),i=ek(e).toVar(),s=ez(ez(2)).toVar(),n=ez().toVar(),a=ez().toVar(),o=ez().toVar();return n.assign(a.assign(o.assign(ez(ek(0xdeadbeef)).add(s.shiftLeft(ez(2))).add(ez(13))))),n.addAssign(ez(i)),a.addAssign(ez(r)),ge(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),gn=eF(([e,t,r])=>{let i=ek(r).toVar(),s=ek(t).toVar(),n=ek(e).toVar(),a=ez(ez(3)).toVar(),o=ez().toVar(),l=ez().toVar(),u=ez().toVar();return o.assign(l.assign(u.assign(ez(ek(0xdeadbeef)).add(a.shiftLeft(ez(2))).add(ez(13))))),o.addAssign(ez(n)),l.addAssign(ez(s)),u.addAssign(ez(i)),ge(o,l,u)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ga=d0([gi,gs,gn,eF(([e,t,r,i])=>{let s=ek(i).toVar(),n=ek(r).toVar(),a=ek(t).toVar(),o=ek(e).toVar(),l=ez(ez(4)).toVar(),u=ez().toVar(),d=ez().toVar(),h=ez().toVar();return u.assign(d.assign(h.assign(ez(ek(0xdeadbeef)).add(l.shiftLeft(ez(2))).add(ez(13))))),u.addAssign(ez(o)),d.addAssign(ez(a)),h.addAssign(ez(n)),p7(u,d,h),u.addAssign(ez(s)),ge(u,d,h)}).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"}]}),eF(([e,t,r,i,s])=>{let n=ek(s).toVar(),a=ek(i).toVar(),o=ek(r).toVar(),l=ek(t).toVar(),u=ek(e).toVar(),d=ez(ez(5)).toVar(),h=ez().toVar(),c=ez().toVar(),p=ez().toVar();return h.assign(c.assign(p.assign(ez(ek(0xdeadbeef)).add(d.shiftLeft(ez(2))).add(ez(13))))),h.addAssign(ez(u)),c.addAssign(ez(l)),p.addAssign(ez(o)),p7(h,c,p),h.addAssign(ez(a)),c.addAssign(ez(n)),ge(h,c,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"}]})]),go=d0([eF(([e,t])=>{let r=ek(t).toVar(),i=ez(ga(ek(e).toVar(),r)).toVar(),s=eQ().toVar();return s.x.assign(i.bitAnd(ek(255))),s.y.assign(i.shiftRight(ek(8)).bitAnd(ek(255))),s.z.assign(i.shiftRight(ek(16)).bitAnd(ek(255))),s}
5).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),eF(([e,t,r])=>{let i=ek(r).toVar(),s=ek(t).toVar(),n=ez(ga(ek(e).toVar(),s,i)).toVar(),a=eQ().toVar();return a.x.assign(n.bitAnd(ek(255))),a.y.assign(n.shiftRight(ek(8)).bitAnd(ek(255))),a.z.assign(n.shiftRight(ek(16)).bitAnd(ek(255))),a}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),gl=d0([eF(([e])=>{let t=eH(e).toVar(),r=ek().toVar(),i=ek().toVar(),s=eG(pJ(t.x,r)).toVar(),n=eG(pJ(t.y,i)).toVar(),a=eG(gr(s)).toVar(),o=eG(gr(n)).toVar();return p8(eG(p0(p2(ga(r,i),s,n),p2(ga(r.add(ek(1)),i),s.sub(1),n),p2(ga(r,i.add(ek(1))),s,n.sub(1)),p2(ga(r.add(ek(1)),i.add(ek(1))),s.sub(1),n.sub(1)),a,o)).toVar())}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),eF(([e])=>{let t=eX(e).toVar(),r=ek().toVar(),i=ek().toVar(),s=ek().toVar(),n=eG(pJ(t.x,r)).toVar(),a=eG(pJ(t.y,i)).toVar(),o=eG(pJ(t.z,s)).toVar(),l=eG(gr(n)).toVar(),u=eG(gr(a)).toVar(),d=eG(gr(o)).toVar();return p5(eG(p1(p2(ga(r,i,s),n,a,o),p2(ga(r.add(ek(1)),i,s),n.sub(1),a,o),p2(ga(r,i.add(ek(1)),s),n,a.sub(1),o),p2(ga(r.add(ek(1)),i.add(ek(1)),s),n.sub(1),a.sub(1),o),p2(ga(r,i,s.add(ek(1))),n,a,o.sub(1)),p2(ga(r.add(ek(1)),i,s.add(ek(1))),n.sub(1),a,o.sub(1)),p2(ga(r,i.add(ek(1)),s.add(ek(1))),n,a.sub(1),o.sub(1)),p2(ga(r.add(ek(1)),i.add(ek(1)),s.add(ek(1))),n.sub(1),a.sub(1),o.sub(1)),l,u,d)).toVar())}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),gu=d0([eF(([e])=>{let t=eH(e).toVar(),r=ek().toVar(),i=ek().toVar(),s=eG(pJ(t.x,r)).toVar(),n=eG(pJ(t.y,i)).toVar(),a=eG(gr(s)).toVar(),o=eG(gr(n)).toVar();return p8(eX(p0(p3(go(r,i),s,n),p3(go(r.add(ek(1)),i),s.sub(1),n),p3(go(r,i.add(ek(1))),s,n.sub(1)),p3(go(r.add(ek(1)),i.add(ek(1))),s.sub(1),n.sub(1)),a,o)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),eF(([e])=>{let t=eX(e).toVar(),r=ek().toVar(),i=ek().toVar(),s=ek().toVar(),n=eG(pJ(t.x,r)).toVar(),a=eG(pJ(t.y,i)).toVar(),o=eG(pJ(t.z,s)).toVar(),l=eG(gr(n)).toVar(),u=eG(gr(a)).toVar(),d=eG(gr(o)).toVar();return p5(eX(p1(p3(go(r,i,s),n,a,o),p3(go(r.add(ek(1)),i,s),n.sub(1),a,o),p3(go(r,i.add(ek(1)),s),n,a.sub(1),o),p3(go(r.add(ek(1)),i.add(ek(1)),s),n.sub(1),a.sub(1),o),p3(go(r,i,s.add(ek(1))),n,a,o.sub(1)),p3(go(r.add(ek(1)),i,s.add(ek(1))),n.sub(1),a,o.sub(1)),p3(go(r,i.add(ek(1)),s.add(ek(1))),n,a.sub(1),o.sub(1)),p3(go(r.add(ek(1)),i.add(ek(1)),s.add(ek(1))),n.sub(1),a.sub(1),o.sub(1)),l,u,d)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),gd=eF(([e])=>gt(ga(ek(pZ(eG(e).toVar())).toVar()))).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),gh=eF(([e])=>{let t=eH(e).toVar();return gt(ga(ek(pZ(t.x)).toVar(),ek(pZ(t.y)).toVar()))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),gc=d0([gd,gh,eF(([e])=>{let t=eX(e).toVar(),r=ek(pZ(t.x)).toVar();return gt(ga(r,ek(pZ(t.y)).toVar(),ek(pZ(t.z)).toVar()))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),eF(([e])=>{let t=eZ(e).toVar(),r=ek(pZ(t.x)).toVar(),i=ek(pZ(t.y)).toVar();return gt(ga(r,i,ek(pZ(t.z)).toVar(),ek(pZ(t.w)).toVar()))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),gp=eF(([e])=>{let t=ek(pZ(eG(e).toVar())).toVar();return eX(gt(ga(t,ek(0))),gt(ga(t,ek(1))),gt(ga(t,ek(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),gg=eF(([e])=>{let t=eH(e).toVar(),r=ek(pZ(t.x)).toVar(),i=ek(pZ(t.y)).toVar();return eX(gt(ga(r,i,ek(0))),gt(ga(r,i,ek(1))),gt(ga(r,i,ek(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gm=d0([gp,gg,eF(([e])=>{let t=eX(e).toVar(),r=ek(pZ(t.x)).toVar(),i=ek(pZ(t.y)).toVar(),s=ek(pZ(t.z)).toVar();return eX(gt(ga(r,i,s,ek(0))),gt(ga(r,i,s,ek(1))),gt(ga(r,i,s,ek(2))))}
vendor: 9,482 bytes, line 5
5).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),eF(([e])=>{let t=eZ(e).toVar(),r=ek(pZ(t.x)).toVar(),i=ek(pZ(t.y)).toVar(),s=ek(pZ(t.z)).toVar(),n=ek(pZ(t.w)).toVar();return eX(gt(ga(r,i,s,n,ek(0))),gt(ga(r,i,s,n,ek(1))),gt(ga(r,i,s,n,ek(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),gf=eF(([e,t,r,i])=>{let s=eG(i).toVar(),n=eG(r).toVar(),a=ek(t).toVar(),o=eX(e).toVar(),l=eG(0).toVar(),u=eG(1).toVar();return or(a,()=>{l.addAssign(u.mul(gl(o))),u.mulAssign(s),o.mulAssign(n)}),l}).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"}]}),gy=eF(([e,t,r,i])=>{let s=eG(i).toVar(),n=eG(r).toVar(),a=ek(t).toVar(),o=eX(e).toVar(),l=eX(0).toVar(),u=eG(1).toVar();return or(a,()=>{l.addAssign(u.mul(gu(o))),u.mulAssign(s),o.mulAssign(n)}),l}).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"}]}),gb=eF(([e,t,r,i])=>{let s=eG(i).toVar(),n=eG(r).toVar(),a=ek(t).toVar(),o=eX(e).toVar();return eH(gf(o,a,n,s),gf(o.add(eX(ek(19),ek(193),ek(17))),a,n,s))}).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"}]}),gx=eF(([e,t,r,i])=>{let s=eG(i).toVar(),n=eG(r).toVar(),a=ek(t).toVar(),o=eX(e).toVar();return eZ(eX(gy(o,a,n,s)).toVar(),eG(gf(o.add(eX(ek(19),ek(193),ek(17))),a,n,s)).toVar())}).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"}]}),gT=d0([eF(([e,t,r,i,s,n,a])=>{let o=ek(a).toVar(),l=eG(n).toVar(),u=ek(s).toVar(),d=ek(i).toVar(),h=ek(r).toVar(),c=ek(t).toVar(),p=eH(e).toVar(),g=eX(gm(eH(c.add(d),h.add(u)))).toVar(),m=eH(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(l),m.addAssign(.5);let f=eH(eH(eG(c),eG(h)).add(m)).toVar(),y=eH(f.sub(p)).toVar();return eD(o.equal(ek(2)),()=>rB(y.x).add(rB(y.y))),eD(o.equal(ek(3)),()=>rj(rB(y.x),rB(y.y))),rZ(y,y)}).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"}]}),eF(([e,t,r,i,s,n,a,o,l])=>{let u=ek(l).toVar(),d=eG(o).toVar(),h=ek(a).toVar(),c=ek(n).toVar(),p=ek(s).toVar(),g=ek(i).toVar(),m=ek(r).toVar(),f=ek(t).toVar(),y=eX(e).toVar(),b=eX(gm(eX(f.add(p),m.add(c),g.add(h)))).toVar();b.subAssign(.5),b.mulAssign(d),b.addAssign(.5);let x=eX(eX(eG(f),eG(m),eG(g)).add(b)).toVar(),T=eX(x.sub(y)).toVar();return eD(u.equal(ek(2)),()=>rB(T.x).add(rB(T.y)).add(rB(T.z))),eD(u.equal(ek(3)),()=>rj(rB(T.x),rB(T.y),rB(T.z))),rZ(T,T)}).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"}]})]),g_=eF(([e,t,r])=>{let i=ek(r).toVar(),s=eG(t).toVar(),n=eH(e).toVar(),a=ek().toVar(),o=ek().toVar(),l=eH(pJ(n.x,a),pJ(n.y,o)).toVar(),u=eG(1e6).toVar();return or({start:-1,end:ek(1),name:"x",condition:"<="},({x:e})=>{or({start:-1,end:ek(1),name:"y",condition:"<="},({y:t})=>{let r=eG(gT(l,e,t,a,o,s,i)).toVar();u.assign(rq(u,r))})}),eD(i.equal(ek(0)),()=>{u.assign(rx(u))}),u}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gv=eF(([e,t,r])=>{let i=ek(r).toVar(),s=eG(t).toVar(),n=eH(e).toVar(),a=ek().toVar(),o=ek().toVar(),l=eH(pJ(n.x,a),pJ(n.y,o)).toVar(),u=eH(1e6,1e6).toVar();return or({start:-1,end:ek(1),name:"x",condition:"<="},({x:e})=>{or({start:-1,end:ek(1),name:"y",condition:"<="},({y:t})=>{let r=eG(gT(l,e,t,a,o,s,i)).toVar();eD(r.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(r)}).ElseIf(r.lessThan(u.y),()=>{u.y.assign(r)})})}),eD(i.equal(ek(0)),()=>{u.assign(rx(u))}),u}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gN=eF(([e,t,r])=>{let i=ek(r).toVar(),s=eG(t).toVar(),n=eH(e).toVar(),a=ek().toVar(),o=ek().toVar(),l=eH(pJ(n.x,a),pJ(n.y,o)).toVar(),u=eX(1e6,1e6,1e6).toVar();return or({start:-1,end:ek(1),name:"x",condition:"<="},({x:e})=>{or({start:-1,end:ek(1),name:"y",condition:"<="},({y:t})=>{let r=eG(gT(l,e,t,a,o,s,i)).toVar();eD(r.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(r)}).ElseIf(r.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(r)}).ElseIf(r.lessThan(u.z),()=>{u.z.assign(r)})})}),eD(i.equal(ek(0)),()=>{u.assign(rx(u))}),u}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gS=d0([g_,eF(([e,t,r])=>{let i=ek(r).toVar(),s=eG(t).toVar(),n=eX(e).toVar(),a=ek().toVar(),o=ek().toVar(),l=ek().toVar(),u=eX(pJ(n.x,a),pJ(n.y,o),pJ(n.z,l)).toVar(),d=eG(1e6).toVar();return or({start:-1,end:ek(1),name:"x",condition:"<="},({x:e})=>{or({start:-1,end:ek(1),name:"y",condition:"<="},({y:t})=>{or({start:-1,end:ek(1),name:"z",condition:"<="},({z:r})=>{let n=eG(gT(u,e,t,r,a,o,l,s,i)).toVar();d.assign(rq(d,n))})})}),eD(i.equal(ek(0)),()=>{d.assign(rx(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),gR=d0([gv,eF(([e,t,r])=>{let i=ek(r).toVar(),s=eG(t).toVar(),n=eX(e).toVar(),a=ek().toVar(),o=ek().toVar(),l=ek().toVar(),u=eX(pJ(n.x,a),pJ(n.y,o),pJ(n.z,l)).toVar(),d=eH(1e6,1e6).toVar();return or({start:-1,end:ek(1),name:"x",condition:"<="},({x:e})=>{or({start:-1,end:ek(1),name:"y",condition:"<="},({y:t})=>{or({start:-1,end:ek(1),name:"z",condition:"<="},({z:r})=>{let n=eG(gT(u,e,t,r,a,o,l,s,i)).toVar();eD(n.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.y.assign(n)})})})}),eD(i.equal(ek(0)),()=>{d.assign(rx(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),gA=d0([gN,eF(([e,t,r])=>{let i=ek(r).toVar(),s=eG(t).toVar(),n=eX(e).toVar(),a=ek().toVar(),o=ek().toVar(),l=ek().toVar(),u=eX(pJ(n.x,a),pJ(n.y,o),pJ(n.z,l)).toVar(),d=eX(1e6,1e6,1e6).toVar();return or({start:-1,end:ek(1),name:"x",condition:"<="},({x:e})=>{or({start:-1,end:ek(1),name:"y",condition:"<="},({y:t})=>{or({start:-1,end:ek(1),name:"z",condition:"<="},({z:r})=>{let n=eG(gT(u,e,t,r,a,o,l,s,i)).toVar();eD(n.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(n)}).ElseIf(n.lessThan(d.z),()=>{d.z.assign(n)})})})}),eD(i.equal(ek(0)),()=>{d.assign(rx(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),gE=eF(([e,t,r,i,s,n,a,o,l,u,d])=>{let h=ek(e).toVar(),c=eH(t).toVar(),p=eH(r).toVar(),g=eH(i).toVar(),m=eG(s).toVar(),f=eG(n).toVar(),y=eG(a).toVar(),b=e$(o).toVar(),x=ek(l).toVar(),T=eG(u).toVar(),_=eG(d).toVar(),v=c.mul(p).add(g),N=eG(0).toVar();return eD(h.equal(ek(0)),()=>{N.assign(gu(v))}),eD(h.equal(ek(1)),()=>{N.assign(gm(v))}),eD(h.equal(ek(2)),()=>{N.assign(gA(v,m,ek(0)))}),eD(h.equal(ek(3)),()=>{N.assign(gy(eX(v,0),x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),eD(b,()=>{N.assign(r9(N,f,y))}),N}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gC=eF(([e,t,r,i,s,n,a,o,l,u,d])=>{let h=ek(e).toVar(),c=eX(t).toVar(),p=eX(r).toVar(),g=eX(i).toVar(),m=eG(s).toVar(),f=eG(n).toVar(),y=eG(a).toVar(),b=e$(o).toVar(),x=ek(l).toVar(),T=eG(u).toVar(),_=eG(d).toVar(),v=c.mul(p).add(g),N=eG(0).toVar();return eD(h.equal(ek(0)),()=>{N.assign(gu(v))}),eD(h.equal(ek(1)),()=>{N.assign(gm(v))}),eD(h.equal(ek(2)),()=>{N.assign(gA(v,m,ek(0)))}),eD(h.equal(ek(3)),()=>{N.assign(gy(v,x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),eD(b,()=>{N.assign(r9(N,f,y))}),N}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),gw=eF(([e])=>{let t=e.y,r=e.z,i=eX().toVar();return eD(t.lessThan(1e-4),()=>{i.assign(eX(r,r,r))}).Else(()=>{let s=e.x,n=ek(rG(s=s.sub(r_(s)).mul(6).toVar())),a=s.sub(eG(n)),o=r.mul(t.oneMinus()),l=r.mul(t.mul(a).oneMinus()),u=r.mul(t.mul(a.oneMinus()).oneMinus());eD(n.equal(ek(0)),()=>{i.assign(eX(r,u,o))}).ElseIf(n.equal(ek(1)),()=>{i.assign(eX(l,r,o))}).ElseIf(n.equal(ek(2)),()=>{i.assign(eX(o,r,u))}).ElseIf(n.equal(ek(3)),()=>{i.assign(eX(o,l,r))}).ElseIf(n.equal(ek(4)),()=>{i.assign(eX(u,o,r))}).Else(()=>{i.assign(eX(r,o,l))})}),i}
5).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),gM=eF(([e])=>{let t=eX(e).toVar(),r=eG(t.x).toVar(),i=eG(t.y).toVar(),s=eG(t.z).toVar(),n=eG(rq(r,rq(i,s))).toVar(),a=eG(rj(r,rj(i,s))).toVar(),o=eG(a.sub(n)).toVar(),l=eG().toVar(),u=eG().toVar(),d=eG().toVar();return d.assign(a),eD(a.greaterThan(0),()=>{u.assign(o.div(a))}).Else(()=>{u.assign(0)}),eD(u.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{eD(r.greaterThanEqual(a),()=>{l.assign(i.sub(s).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(tH(2,s.sub(r).div(o)))}).Else(()=>{l.assign(tH(4,r.sub(i).div(o)))}),l.mulAssign(1/6),eD(l.lessThan(0),()=>{l.addAssign(1)})}),eX(l,u,d)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),gB=eF(([e])=>{let t=eX(e).toVar(),r=eY(tZ(t,eX(.04045))).toVar();return r5(eX(t.div(12.92)).toVar(),eX(r0(rj(t.add(eX(.055)),eX(0)).div(1.055),eX(2.4))).toVar(),r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),gL=(e,t)=>{e=eG(e);let r=eH((t=eG(t)).dFdx(),t.dFdy()).length().mul(.7071067811865476);return it(e.sub(r),e.add(r),t)},gP=(e,t,r,i)=>r5(e,t,r[i].clamp()),gF=(e,t,r,i,s)=>r5(e,t,gL(r,i[s])),gU=eF(([e,t,r])=>{let i=rN(e).toVar(),s=tW(eG(.5).mul(t.sub(r)),s5).div(i).toVar(),n=tW(eG(-.5).mul(t.sub(r)),s5).div(i).toVar(),a=eX().toVar();a.x=i.x.greaterThan(eG(0)).select(s.x,n.x),a.y=i.y.greaterThan(eG(0)).select(s.y,n.y),a.z=i.z.greaterThan(eG(0)).select(s.z,n.z);let o=rq(a.x,a.y,a.z).toVar();return s5.add(i.mul(o)).toVar().sub(r)}),gI=eF(([e,t])=>{let r=e.x,i=e.y,s=e.z,n=t.element(0).mul(.886227);return(n=(n=(n=(n=(n=(n=(n=n.add(t.element(1).mul(1.023328).mul(i))).add(t.element(2).mul(1.023328).mul(s))).add(t.element(3).mul(1.023328).mul(r))).add(t.element(4).mul(.858086).mul(r).mul(i))).add(t.element(5).mul(.858086).mul(i).mul(s))).add(t.element(6).mul(s.mul(s).mul(.743125).sub(.247708)))).add(t.element(7).mul(.858086).mul(r).mul(s))).add(t.element(8).mul(.429043).mul(tq(r,r).sub(tq(i,i))))});var gD=Object.freeze({__proto__:null,BRDF_GGX:lx,BRDF_Lambert:ls,BasicPointShadowFilter:pI,BasicShadowFilter:px,Break:oi,Const:iT,Continue:()=>i2("continue").toStack(),DFGApprox:lT,D_GGX:lf,Discard:i3,EPSILON:ro,F_Schlick:li,Fn:eF,INFINITY:rl,If:eD,Loop:or,NodeAccess:M,NodeShaderStage:C,NodeType:{BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},NodeUpdateType:w,OnMaterialUpdate:e=>hw(hC.MATERIAL,e),OnObjectUpdate:e=>hw(hC.OBJECT,e),PCFShadowFilter:pT,PCFSoftShadowFilter:p_,PI:ru,PI2:rd,PointShadowFilter:pD,Return:()=>i2("return").toStack(),Schlick_to_F0:lv,ScriptableNodeResources:cb,ShaderNode:eS,Stack:eO,Switch:(...e)=>Q.Switch(...e),TBNViewMatrix:n6,VSMShadowFilter:pv,V_GGX_SmithCorrelated:lg,Var:ix,VarIntent:i_,abs:rB,acesFilmicToneMapping:cs,acos:rw,add:tH,addMethodChaining:Z,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:cl,all:rh,alphaT:th,and:t1,anisotropy:tc,anisotropyB:tg,anisotropyT:tp,any:rc,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),eO(e)),array:tD,arrayBuffer:e=>eR(new X(e,"ArrayBuffer")),asin:rC,assign:tV,atan:rM,atan2:il,atomicAdd:(e,t)=>cz(cG.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>cz(cG.ATOMIC_AND,e,t),atomicFunc:cz,atomicLoad:e=>cz(cG.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>cz(cG.ATOMIC_MAX,e,t),atomicMin:(e,t)=>cz(cG.ATOMIC_MIN,e,t),atomicOr:(e,t)=>cz(cG.ATOMIC_OR,e,t),atomicStore:(e,t)=>cz(cG.ATOMIC_STORE,e,t),atomicSub:(e,t)=>cz(cG.ATOMIC_SUB,e,t),atomicXor:(e,t)=>cz(cG.ATOMIC_XOR,e,t),attenuationColor:tA,attenuationDistance:tR,attribute:i7,attributeArray:(e,t="float")=>{let r,i;return!0===t.isStruct?(r=t.layout.getLength(),i=_("float")):(r=v(t),i=_(t)),a5(new hB(e,r,i),t,e)},backgroundBlurriness:hD,backgroundIntensity:hO,backgroundRotation:hV,batch:a3,bentNormalView:n5,billboarding:d8,bitAnd:t6,bitNot:t8,bitOr:t5,bitXor:t9,bitangentGeometry:n1,bitangentLocal:n2,bitangentView:n3,bitangentWorld:n4,bitcast:dq,blendBurn:oI,blendColor:oG,blendDodge:oD,blendOverlay:oV,blendScreen:oO,blur:uh,bool:e$,buffer:sh,bufferAttribute:ik,builtin:sf,bumpMap:ai,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),oI(e)),bvec2:ej,bvec3:eY,bvec4:e1,bypass:iY,cache:iK,call:tk,cameraFar:sw,cameraIndex:sE,cameraNear:sC,cameraNormalMatrix:sF,cameraPosition:sU,cameraProjectionMatrix:sM,cameraProjectionMatrixInverse:sB,cameraViewMatrix:sL,cameraViewport:sI,cameraWorldMatrix:sP,cbrt:r6,cdl:h2,ceil:rv,checker:pX,cineonToneMapping:cr,clamp:r9,clearcoat:ts,clearcoatNormalView:nc,clearcoatRoughness:tn,code:ch,color:eV,colorSpaceToWorking:iL,colorToDirection:e=>eR(e).mul(2).sub(1),compute:ij,computeKernel:iq,computeSkinning:(e,t=null)=>{let r=new a7(e);return r.positionNode=a5(new u.uWO(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element
5(aj).toVar(),r.skinIndexNode=a5(new u.uWO(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(aj).toVar(),r.skinWeightNode=a5(new u.uWO(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(aj).toVar(),r.bindMatrixNode=tU(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=tU(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=sh(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,eR(r)},context:ic,convert:e8,convertColorSpace:(e,t,r)=>eR(new iM(eR(e),t,r)),convertToTexture:(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():hN(e,...t),cos:rA,cross:rJ,cubeTexture:nM,cubeTextureBase:nw,cubeToUV:pU,dFdx:rI,dFdy:rD,dashSize:tx,debug:i5,decrement:rs,decrementBefore:rr,defaultBuildStages:L,defaultShaderStages:B,defined:ev,degrees:rg,deltaTime:d2,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),cS(e,cN(t))},densityFogFactor:cN,depth:oE,depthPass:(e,t,r)=>eR(new h9(h9.DEPTH,e,t,r)),determinant:r$,difference:rY,diffuseColor:te,directPointLight:pq,directionToColor:oY,directionToFaceDirection:ns,dispersion:tE,distance:rQ,div:tj,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),oD(e)),dot:rZ,drawIndex:aY,dynamicBufferAttribute:iz,element:e6,emissive:tt,equal:tK,equals:rW,equirectUV:o0,exp:rm,exp2:rf,expression:i2,faceDirection:ni,faceForward:ir,faceforward:ir,float:eG,floatBitsToInt:e=>new dW(e,"int","float"),floatBitsToUint:e=>new dW(e,"uint","float"),floor:r_,fog:cS,fract:rS,frameGroup:tB,frameId:d3,frontFacing:nr,fwidth:rk,gain:(e,t)=>e.lessThan(.5)?dX(e.mul(2),t).div(2):tW(1,dX(tq(tW(1,e),2),t).div(2)),gapSize:tT,getConstNodeType:eN,getCurrentStack:eI,getDirection:uo,getDistanceAttenuation:pW,getGeometryRoughness:lc,getNormalFromDepth:hA,getParallaxCorrectNormal:gU,getRoughness:lp,getScreenPosition:hR,getShIrradianceAt:gI,getShadowMaterial:pS,getShadowRenderObjectFunction:pE,getTextureIndex:dz,getViewPosition:hS,globalId:cP,glsl:(e,t)=>ch(e,t,"glsl"),glslFn:(e,t)=>cp(e,t,"glsl"),grayscale:hY,greaterThan:tZ,greaterThanEqual:t0,hash:dj,highpModelNormalViewMatrix:s3,highpModelViewMatrix:s2,hue:h0,increment:ri,incrementBefore:rt,instance:aJ,instanceIndex:aj,instancedArray:(e,t="float")=>{let r,i;return!0===t.isStruct?(r=t.layout.getLength(),i=_("float")):(r=v(t),i=_(t)),a5(new hM(e,r,i),t,e)},instancedBufferAttribute:i$,instancedDynamicBufferAttribute:iH,instancedMesh:a1,int:ek,intBitsToFloat:e=>new dW(e,"float","int"),inverse:rH,inverseSqrt:rT,inversesqrt:rT,invocationLocalIndex:aQ,invocationSubgroupIndex:aK,ior:tv,iridescence:tl,iridescenceIOR:tu,iridescenceThickness:td,ivec2:eW,ivec3:eK,ivec4:eJ,js:(e,t)=>ch(e,t,"js"),label:im,length:rP,lengthSq:r8,lessThan:tY,lessThanEqual:tJ,lightPosition:pl,lightProjectionUV:po,lightShadowMatrix:pa,lightTargetDirection:ph,lightTargetPosition:pu,lightViewPosition:p
vendor: 4,986 bytes, line 5
5d,lightingContext:oc,lights:(e=[])=>eR(new pm).setLights(e),linearDepth:oC,linearToneMapping:ce,localId:cF,log:ry,log2:rb,logarithmicDepthToViewZ:(e,t,r)=>{let i=e.mul(ry(r.div(t)));return eG(Math.E).pow(i).mul(t).negate()},luminance:h1,mat2:e2,mat3:e3,mat4:e4,matcapUV:uX,materialAO:az,materialAlphaTest:aa,materialAnisotropy:aR,materialAnisotropyVector:a$,materialAttenuationColor:aP,materialAttenuationDistance:aL,materialClearcoat:ax,materialClearcoatNormal:a_,materialClearcoatRoughness:aT,materialColor:ao,materialDispersion:aG,materialEmissive:au,materialEnvIntensity:n_,materialEnvRotation:nv,materialIOR:aB,materialIridescence:aA,materialIridescenceIOR:aE,materialIridescenceThickness:aC,materialLightMap:ak,materialLineDashOffset:aO,materialLineDashSize:aU,materialLineGapSize:aI,materialLineScale:aF,materialLineWidth:aD,materialMetalness:ay,materialNormal:ab,materialOpacity:ad,materialPointSize:aV,materialReference:nI,materialReflectivity:am,materialRefractionRatio:nT,materialRotation:av,materialRoughness:af,materialSheen:aN,materialSheenRoughness:aS,materialShininess:al,materialSpecular:ah,materialSpecularColor:ap,materialSpecularIntensity:ac,materialSpecularStrength:ag,materialThickness:aM,materialTransmission:aw,max:rj,maxMipLevel:ss,mediumpModelViewMatrix:s1,metalness:ti,min:rq,mix:r5,mixElement:is,mod:tX,modInt:rn,modelDirection:sq,modelNormalMatrix:sZ,modelPosition:sX,modelRadius:sY,modelScale:sK,modelViewMatrix:s0,modelViewPosition:sQ,modelViewProjection:aH,modelWorldMatrix:sj,modelWorldMatrixInverse:sJ,morphReference:ol,mrt:dH,mul:tq,mx_aastep:gL,mx_add:(e,t=eG(0))=>tH(e,t),mx_atan2:(e=eG(0),t=eG(1))=>rM(e,t),mx_cell_noise_float:(e=se())=>gc(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>eG(e).sub(r).mul(t).add(r),mx_divide:(e,t=eG(1))=>tj(e,t),mx_fractal_noise_float:(e=se(),t=3,r=2,i=.5,s=1)=>gf(e,ek(t),r,i).mul(s),mx_fractal_noise_vec2:(e=se(),t=3,r=2,i=.5,s=1)=>gb(e,ek(t),r,i).mul(s),mx_fractal_noise_vec3:(e=se(),t=3,r=2,i=.5,s=1)=>gy(e,ek(t),r,i).mul(s),mx_fractal_noise_vec4:(e=se(),t=3,r=2,i=.5,s=1)=>gx(e,ek(t),r,i).mul(s),mx_frame:()=>d3,mx_heighttonormal:(e,t)=>ai(e=eX(e),t=eG(t)),mx_hsvtorgb:gw,mx_ifequal:(e,t,r,i)=>e.equal(t).mix(r,i),mx_ifgreater:(e,t,r,i)=>e.greaterThan(t).mix(r,i),mx_ifgreatereq:(e,t,r,i)=>e.greaterThanEqual(t).mix(r,i),mx_invert:(e,t=eG(1))=>tW(t,e),mx_modulo:(e,t=eG(1))=>tX(e,t),mx_multiply:(e,t=eG(1))=>tq(e,t),mx_noise_float:(e=se(),t=1,r=0)=>gl(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=se(),t=1,r=0)=>gu(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=se(),t=1,r=0)=>eZ(gu(e=e.convert("vec2|vec3")),gl(e.add(eH(19,73)))).mul(t).add(r),mx_place2d:(e,t=eH(.5,.5),r=eH(1,1),i=eG(0),s=eH(0,0))=>{let n=e;if(t&&(n=n.sub(t)),r&&(n=n.mul(r)),i){let e=i.mul(Math.PI/180),t=e.cos(),r=e.sin();n=eH(n.x.mul(t).sub(n.y.mul(r)),n.x.mul(r).add(n.y.mul(t)))}return t&&(n=n.add(t)),s&&(n=n.add(s)),n},mx_power:(e,t=eG(1))=>r0(e,t),mx_ramp4:(e,t,r,i,s=se())=>{let n=s.x.clamp(),a=s.y.clamp(),o=r5(e,t,n),l=r5(r,i,n);return r5(o,l,a)},mx_ramplr:(e,t,r=se())=>gP(e,t,r,"x"),mx_ramptb:(e,t,r=se())=>gP(e,t,r,"y"),mx_rgbtohsv:gM,mx_rotate2d:(e,t)=>uZ(e=eH(e),(t=eG(t)).mul(Math.PI/180)),mx_rotate3d:(e,t,r)=>{e=eX(e),t=eG(t),r=eX(r);let i=t.mul(Math.PI/180),s=r.normalize(),n=i.cos(),a=i.sin(),o=eG(1).sub(n);return e.mul(n).add(s.cross(e).mul(a)).add(s.mul(s.dot(e)).mul(o))},mx_safepower:(e,t=1)=>(e=eG(e)).abs().pow(t).mul(e.sign()),mx_separate:(e,t=null)=>{if("string"==typeof t){let r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},i=t.replace(/^out/,"").toLowerCase();if(void 0!==r[i])return e.element(r[i])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){let r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==r[t])return e.element(r[t])}return e},mx_splitlr:(e,t,r,i=se())=>gF(e,t,r,i,"x"),mx_splittb:(e,t,r,i=se())=>gF(e,t,r,i,"y"),mx_srgb_texture_to_lin_rec709:gB,mx_subtract:(e,t=eG(0))=>tW(e,t),mx_timer:()=>d1,mx_transform_uv:(e=1,t=0,r=se())=>r.mul(e).add(t),mx_unifiednoise2d:(e,t=se(),r=eH(1,1),i=eH(0,0),s=1,n=0,a=1,o=!1,l=1,u=2,d=.5)=>gE(e,t.convert("vec2|vec3"),r,i,s,n,a,o,l,u,d),mx_unifiednoise3d:(e,t=se(),r=eH(1,1),i=eH(0,0),s=1,n=0,a=1,o=!1,l=1,u=2,d=.5)=>gC(e,t.convert("vec2|vec3"),r,i,s,n,a,o,l,u,d),mx_worley_noise_float:(e=se(),t=1)=>gS(e.convert("vec2|vec3"),t,ek(1)),mx_worley_noise_vec2:(e=se(),t=1)=>gR(e.convert("vec2|vec3"),t,ek(1)),mx_worley_noise_vec3:(e=se(),t=1)=>gA(e.convert("vec2|vec3"),t,ek(1)),negate:rF,neutralToneMapping:cu,nodeArray:eC,nodeImmutable:eM,nodeObject:eR,nodeObjectIntent:eA,nodeObjects:eE,nodeProxy:ew,nodeProxyIntent:eB,normalFlat:no,normalGeometry:nn,normalLocal:na,normalMap:n7,normalView:nd,normalViewGeometry:nl,normalWorld:nh,normalWorldGeometry:nu,normalize:rN,not:t3,notEqual:tQ,numWorkgroups:cB,objectDirection:sV,objectGroup:tP,objectPosition:sk,objectRadius:sH,objectScale:sz,objectViewPosition:s$,objectWorldMatrix:sG,oneMinus:rU,or:t2,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=d1)=>
5e.fract(),oscSine:(e=d1)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=d1)=>e.fract().round(),oscTriangle:(e=d1)=>e.add(.5).fract().mul(2).sub(1).abs(),output:tb,outputStruct:dk,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),oV(e)),overloadingFn:d0,parabola:dX,parallaxDirection:n8,parallaxUV:(e,t)=>e.sub(n8.mul(t)),parameter:(e,t)=>eR(new dU(e,t)),pass:(e,t,r)=>eR(new h9(h9.COLOR,e,t,r)),passTexture:(e,t)=>eR(new h8(e,t)),pcurve:(e,t,r)=>r0(tj(r0(e,t),tH(r0(e,t),r0(tW(1,e),r))),1/t),perspectiveDepthToViewZ:oS,pmremTexture:uU,pointShadow:p$,pointUV:hP,pointWidth:t_,positionGeometry:s4,positionLocal:s6,positionPrevious:s8,positionView:s7,positionViewDirection:ne,positionWorld:s5,positionWorldDirection:s9,posterize:h4,pow:r0,pow2:r1,pow3:r2,pow4:r3,premultiplyAlpha:ok,property:e9,quadBroadcast:ps,quadSwapDiagonal:c9,quadSwapX:c8,quadSwapY:c5,radians:rp,rand:ii,range:cC,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),cS(e,cv(t,r))},rangeFogFactor:cv,reciprocal:rV,reference:nP,referenceBuffer:nF,reflect:rK,reflectVector:nR,reflectView:nN,reflector:e=>eR(new hm(e)),refract:ie,refractVector:nA,refractView:nS,reinhardToneMapping:ct,remap:iJ,remapClamp:i0,renderGroup:tL,renderOutput:i6,rendererReference:iI,rotate:uZ,rotateUV:d4,roughness:tr,round:rO,rtt:hN,sRGBTransferEOTF:iE,sRGBTransferOETF:iC,sample:(e,t=null)=>eR(new hE(e,eR(t))),sampler:e=>(!0===e.isNode?e:sl(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:sl(e)).convert("samplerComparison"),saturate:r7,saturation:hZ,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),oO(e)),screenCoordinate:s_,screenDPR:sb,screenSize:sT,screenUV:sx,scriptable:cT,scriptableValue:cm,select:id,setCurrentStack:eU,setName:ig,shaderStages:P,shadow:pP,shadowPositionWorld:py,shapeCircle:pK,sharedUniformGroup:tM,sheen:ta,sheenRoughness:to,shiftLeft:t7,shiftRight:re,shininess:ty,sign:rL,sin:rR,sinc:(e,t)=>rR(ru.mul(t.mul(e).sub(1))).div(ru.mul(t.mul(e).sub(1))),skinning:oe,smoothstep:it,smoothstepElement:ia,specularColor:tm,specularF90:tf,spherizeUV:d6,split:(e,t)=>eR(new $(eR(e),t)),spritesheetUV:d7,sqrt:rx,stack:dD,step:rX,stepElement:io,storage:a5,storageBarrier:()=>cD("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),a5(e,t,r).setPBO(!0)),storageTexture:hk,string:(e="")=>eR(new X(e,"string")),struct:(e,t=null)=>{let r=new dO(e,t),i=(...t)=>{let i=null;if(t.length>0)if(t[0].isNode){i={};let r=Object.keys(e);for(let e=0;e<t.length;e++)i[r[e]]=t[e]}else i=t[0];return eR(new dV(r,i))};return i.layout=r,i.isStruct=!0,i},sub:tW,subBuild:iN,subgroupAdd:cq,subgroupAll:c3,subgroupAnd:cZ,subgroupAny:c4,subgroupBallot:cW,subgroupBroadcast:c7,subgroupBroadcastFirst:c6,subgroupElect:cH,subgroupExclusiveAdd:cX,subgroupExclusiveMul:cY,subgroupInclusiveAdd:cj,subgroupInclusiveMul:cQ,subgroupIndex:aX,subgroupMax:c2,subgroupMin:c1,subgroupMul:cK,subgroupOr:cJ,subgroupShuffle:pe,subgroupShuffleDown:pi,subgroupShuffleUp:pr,subgroupShuffleXor:pt,subgroupSize:cU,subgroupXor:c0,tan:rE,tangentGeometry:nQ,tangentLocal:nY,tangentView:nZ,tangentWorld:nJ,texture:sl,texture3D:hH,textureBarrier:()=>cD("texture").toStack(),textureBicubic:lk,textureBicubicLevel:lG,textureCubeUV:ul,textureLoad:su,textureSize:sr,textureStore:(e,t,r)=>{let i=hk(e,t,r);return null!==r&&i.toStack(),i},thickness:tS,time:d1,toneMapping:iO,toneMappingExposure:iV,toonOutlinePass:(e,t,r=new u.Q1f(0,0,0),i=.003,s=1)=>eR(new h7(e,t,eR(r),eR(i),eR(s))),transformDirection:r4,transformNormal:np,transformNormalToView:ng,transformedClearcoatNormalView:ny,transformedNormalView:nm,transformedNormalWorld:nf,transmission:tN,transpose:rz,triNoise3D:dY,triplanarTexture:(...e)=>he(...e),triplanarTextures:he,trunc:rG,uint:ez,uintBitsToFloat:e=>new dW(e,"float","uint"),uniform:tU,uniformArray:sg,uniformCubeTexture:(e=nE)=>nw(e),uniformFlow:ip,uniformGroup:tw,uniformTexture:(e=sn)=>sl(e),unpremultiplyAlpha:oz,userData:(e,t,r)=>eR(new hW(e,t,r)),uv:se,uvec2:eq,uvec3:eQ,uvec4:e0,varying:iR,varyingProperty:e7,vec2:eH,vec3:eX,vec4:eZ,vectorComponents:F,velocity:hQ,vertexColor:oU,vertexIndex:aq,vertexStage:iA,vibrance:hJ,viewZToLogarithmicDepth:oR,viewZToOrthographicDepth:ov,viewZToPerspectiveDepth:oN,viewport:sv,viewportCoordinate:sS,viewportDepthTexture:oT,viewportLinearDepth:ow,viewportMipTexture:oy,viewportResolution:sA,viewportSafeUV:d5,viewportSharedTexture:oQ,viewportSize:sN,viewportTexture:of,viewportUV:sR,wgsl:(e,t)=>ch(e,t,"wgsl"),wgslFn:(e,t)=>cp(e,t,"wgsl"),workgroupArray:(e,t)=>eR(new cV("Workgroup",e,t)),workgroupBarrier:()=>cD("workgroup").toStack(),workgroupId:cL,workingToColorSpace:iB,xor:t4});let gO=new dF;class gV extends ds{constructor(e,t){super(),this.renderer=e,this.nodes=t}
5update(e,t,r){let i=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background,n=!1;if(null===s)i._clearColor.getRGB(gO),gO.a=i._clearColor.a;else if(!0===s.isColor)s.getRGB(gO),gO.a=1,n=!0;else if(!0===s.isNode){let r=this.get(e);gO.copy(i._clearColor);let n=r.backgroundMesh;if(void 0===n){let e=ic(eZ(s).mul(hO),{getUV:()=>hV.mul(nu),getTextureLevel:()=>hD}),t=aH;t=t.setZ(t.w);let i=new o$;i.name="Background.material",i.side=u.hsX,i.depthTest=!1,i.depthWrite=!1,i.allowOverride=!1,i.fog=!1,i.lights=!1,i.vertexNode=t,i.colorNode=e,r.backgroundMeshNode=e,r.backgroundMesh=n=new u.eaF(new u.Gu$(1,32,32),i),n.frustumCulled=!1,n.name="Background.mesh",n.onBeforeRender=function(e,t,r){this.matrixWorld.copyPosition(r.matrixWorld)},s.addEventListener("dispose",function e(){s.removeEventListener("dispose",e),n.material.dispose(),n.geometry.dispose()})}let a=s.getCacheKey();r.backgroundCacheKey!==a&&(r.backgroundMeshNode.node=eZ(s).mul(hO),r.backgroundMeshNode.needsUpdate=!0,n.material.needsUpdate=!0,r.backgroundCacheKey=a),t.unshift(n,n.geometry,n.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",s);let a=i.xr.getEnvironmentBlendMode();if("additive"===a?gO.set(0,0,0,1):"alpha-blend"===a&&gO.set(0,0,0,0),!0===i.autoClear||!0===n){let e=r.clearColorValue;e.r=gO.r,e.g=gO.g,e.b=gO.b,e.a=gO.a,(!0===i.backend.isWebGLBackend||!0===i.alpha)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),r.depthClearValue=i._clearDepth,r.stencilClearValue=i._clearStencil,r.clearColor=!0===i.autoClearColor,r.clearDepth=!0===i.autoClearDepth,r.clearStencil=!0===i.autoClearStencil}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let gG=0;class gk{constructor(e="",t=[],r=0,i=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=i,this.id=gG++}}class gz{constructor(e,t,r,i,s,n,a,o,l,u=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=u,this.nodeAttributes=i,this.bindings=s,this.updateNodes=n,this.updateBeforeNodes=a,this.updateAfterNodes=o,this.observer=l,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(!0!==t.bindings[0].groupNode.shared){let r=new gk(t.name,[],t.index,t.bindingsReference);for(let i of(e.push(r),t.bindings))r.bindings.push(i.clone())}else e.push(t);return e}}class g${constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class gH{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class gW{constructor(e,t,r=!1,i=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=i}}class gq extends gW{constructor(e,t,r=null,i=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=i}}class gj{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let gX=0;class gK{constructor(e=null){this.id=gX++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class gQ{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class gY{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class gZ extends gY{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class gJ extends gY{constructor(e,t=new u.I9Y){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class g0 extends gY{constructor(e,t=new u.Pq0){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class g1 extends gY{constructor(e,t=new u.IUQ){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class g2 extends gY{constructor(e,t=new u.Q1f){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class g3 extends gY{constructor(e,t=new u.k_V){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class g4 extends gY{constructor(e,t=new u.dwI){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class g6 extends gY{constructor(e,t=new u.kn4){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class g8 extends gZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class g5 extends gJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class g9 extends g0{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class g7 extends g1{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class me extends g2{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class mt extends g3{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class mr extends g4{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class mi extends g6{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let ms=new WeakMap,mn=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),ma=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class mo{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=dD(),this.stacks=[],this.tab="	",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new gK,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.currentStack=null,this.subBuildFn=null}getBindGroupsCache(){let e=ms.get(this.renderer);return void 0===e&&(e=new u7,ms.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new u.O0B(e,t,r)}createCubeRenderTarget(e,t){return new o1(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){let r,i=this.getBindGroupsCache(),s=[],n=!0;for(let e of t)s.push(e),n=n&&!0!==e.groupNode.shared;return n?void 0===(r=i.get(s))&&(r=new gk(e,s,this.bindingsIndexes[e].group,s),i.set(s,r)):r=new gk(e,s,this.bindingsIndexes[e].group,s),r}getBindGroupArray(e,t){let r=this.bindings[t],i=r[e];return void 0===i&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=i=[]),i}getBindings(){let e=this.bindGroups;if(null===e){let t={},r=this.bindings;for(let e of P)for(let i in r[e]){let s=r[e][i];(t[i]||(t[i]=[])).push(...s)}for(let r in e=[],t){let i=t[r],s=this._getBindGroup(r,i);e.push(s)}this.bindGroups=e}return e}sortBindingGroups(){let e=this.getBindings();e.sort((e,t)=>
5e.bindings[0].groupNode.order-t.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){let r=e[t];this.bindingsIndexes[r.name].group=t,r.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){!1===this.nodes.includes(e)&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){!1===this.sequentialNodes.includes(e)&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(let e of this.nodes)e.getUpdateType()!==w.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==w.NONE&&this.updateBeforeNodes.push(e),r!==w.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===u.k6q||e.magFilter===u.kRr||e.magFilter===u.Cfg||e.magFilter===u.$_I||e.minFilter===u.k6q||e.minFilter===u.kRr||e.minFilter===u.Cfg||e.minFilter===u.$_I}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return{...this.context},this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){let r=this.getDataFromNode(e);return void 0===r.cache&&(r.cache=new gK(t?this.getCache():null)),r.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=void 0===t.usageCount?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,r=null){let i=this.generateArrayDeclaration(e,t)+"( ";for(let s=0;s<t;s++){let n=r?r[s]:null;null!==n?i+=n.build(this,e):i+=this.generateConst(e),s<t-1&&(i+=", ")}return i+" )"}generateStruct(e,t,r=null){let i=[];for(let e of t){let{name:t,type:s}=e;r&&r[t]&&r[t].isNode?i.push(r[t].build(this,s)):i.push(this.generateConst(s))}return e+"( "+i.join(", ")+" )"}generateConst(e,t=null){if(null===t&&("float"===e||"int"===e||"uint"===e?t=0:"bool"===e?t=!1:"color"===e?t=new u.Q1f:"vec2"===e?t=new u.I9Y:"vec3"===e?t=new u.Pq0:"vec4"===e&&(t=new u.IUQ)),"float"===e)return ma(t);if("int"===e)return`${Math.round(t)}`;if("uint"===e)return t>=0?`${Math.round(t)}u`:"0u";if("bool"===e)return t?"true":"false";if("color"===e)return`${this.getType("vec3")}( ${ma(t.r)}, ${ma(t.g)}, ${ma(t.b)} )`;let r=this.getTypeLength(e),i=this.getComponentType(e),s=e=>this.generateConst(i,e);if(2===r)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(3===r)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(4===r&&"mat2"!==e)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(r>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(r>4)return`${this.getType(e)}()`;throw Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){let r=this.attributes;for(let t of r)if(t.name===e)return t;let i=new g$(e,t);return this.registerDeclaration(i),r.push(i),i}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"samplerComparison"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){let t=e.type;if(e.isDataTexture){if(t===u.Yuy)return"int";if(t===u.bkx)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;let t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;let r=x.get(e),i="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),i+r}getTypeFromArray(e){return mn.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t,r=e;e.isInterleavedBufferAttribute&&(r=e.data);let i=r.array,s=e.itemSize,n=e.normalized;return e instanceof u.Oax||!0===n||(t=this.getTypeFromArray(i)),this.getTypeFromLength(s,t)}getTypeLength(e){let t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return null!==r?Number(r[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:16*(!0===/mat4/.test(e))}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){let t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){this.stack=dD(this.stack);let e=eI();return this.stacks.push(e),eU(this.stack),this.stack}removeStack(){let e=this.stack;return this.stack=e.parent,eU(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){let i=(r=null===r?e.isGlobal(this)?this.globalCache:this.cache:r).getData(e);void 0===i&&(i={},r.setData(e,i)),void 0===i[t]&&(i[t]={});let s=i[t],n=i.any?i.any.subBuilds:null,a=this.getClosestSubBuild(n);return a&&(void 0===s.subBuildsCache&&(s.subBuildsCache={}),(s=s.subBuildsCache[a]||(s.subBuildsCache[a]={})).subBuilds=n),s}getNodeProperties(e,t="any"){let r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){let r=this.getDataFromNode(e),i=r.bufferAttribute;return void 0===i&&(i=new g$("nodeAttribute"+this.uniforms.index++,t,e),this.bufferAttributes.push(i),r.bufferAttribute=i),i}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,i=this.shaderStage){let s=this.getDataFromNode(e,i,this.globalCache),n=s.structType;if(void 0===n){let a=this.structs.index++;null===r&&(r="StructType"+a),n=new gQ(r,t),this.structs[i].push(n),this.types[i][r]=e,s.structType=n}return n}getOutputStructTypeFromNode(e,t){let r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,i=null){let s=this.getDataFromNode(e,r,this.globalCache),n=s.uniform;if(void 0===n){let a=this.uniforms.index++;n=new gH(i||"nodeUniform"+a,t,e),this.uniforms[r].push(n),this.registerDeclaration(n),s.uniform=n}return n}getVarFromNode(e,t=null,r=e.getNodeType(this),i=this.shaderStage,s=!1){let n=this.getDataFromNode(e,i),a=this.getSubBuildProperty("variable",n.subBuilds),o=n[a];if(void 0===o){let l=s?"_const":"_var",u=this.vars[i]||(this.vars[i]=[]),d=this.vars[l]||(this.vars[l]=0);null===t&&(t=(s?"nodeConst":"nodeVar")+d,this.vars[l]++),"variable"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds));let h=e.getArrayCount(this);o=new gW(t,r,s,h),s||u.push(o),this.registerDeclaration(o),n[a]=o}return o}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode))&&(!e.cNode||this.isDeterministic(e.cNode));if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(!e.bNode||this.isDeterministic(e.bNode));if(e.isArrayNode){if(null!==e.values){for(let t of e.values)if(!this.isDeterministic(t))return!1}return!0}return!!e.isConstNode||!1}getVaryingFromNode(e,t=null,r=e.getNodeType(this),i=null,s=null){let n=this.getDataFromNode(e,"any"),a=this.getSubBuildProperty("varying",n.subBuilds),o=n[a];if(void 0===o){let e=this.varyings,l=e.length;null===t&&(t="nodeVarying"+l),"varying"!==a&&(t=this.getSubBuildProperty(t,n.subBuilds)),o=new gq(t,r,i,s),e.push(o),this.registerDeclaration(o),n[a]=o}return o}registerDeclaration(e){let t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),i=this.getPropertyName(e),s=1,n=i;for(;void 0!==r[n];)n=i+"_"+s++;s>1&&(e.name=n,console.warn(`THREE.TSL: Declaration name '${i}' of '${e.type}' already in use. Renamed to '${n}'.`)),r[n]=e}getCodeFromNode(e,t,r=this.shaderStage){let i=this.getDataFromNode(e),s=i.code;if(void 0===s){let e=this.codes[r]||(this.codes[r]=[]);s=new gj("nodeCode"+e.length,t),e.push(s),i.code=s}return s}addFlowCodeHierarchy(e,t){let{flowCodes:r,flowCodeBlock:i}=this.getDataFromNode(e),s=!0,n=t;for(;n;){if(!0===i.get(n)){s=!1;break}n=this.getDataFromNode(n).parentNodeBlock}if(s)for(let e of r)this.addLineFlowCode(e)}addLineFlowCodeBlock(e,t,r){let i=this.getDataFromNode(e),s=i.flowCodes||(i.flowCodes=[]),n=i.flowCodeBlock||(i.flowCodeBlock=new WeakMap);s.push(t),n.set(r,!0)}addLineFlowCode(e,t=null){return""===e||(null!==t&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="	",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){let t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){let t=new cc,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){let t=e.layout,r={[Symbol.iterator](){let e=0,t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};
5for(let e of t.inputs)r[e.name]=new dU(e.type,e.name);e.layout=null;let i=e.call(r),s=this.flowStagesNode(i,t.type);return e.layout=t,s}flowBuildStage(e,t,r=null){let i=this.getBuildStage();this.setBuildStage(t);let s=e.build(this,r);return this.setBuildStage(i),s}flowStagesNode(e,t=null){let r=this.flow,i=this.vars,s=this.declarations,n=this.cache,a=this.buildStage,o=this.stack,l={code:""};for(let r of(this.flow=l,this.vars={},this.declarations={},this.cache=new gK,this.stack=dD(),L))this.setBuildStage(r),l.result=e.build(this,t);return l.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=i,this.declarations=s,this.cache=n,this.stack=o,this.setBuildStage(a),l}getFunctionOperator(){return null}buildFunctionCode(){console.warn("Abstract function.")}flowChildNode(e,t=null){let r=this.flow,i={code:""};return this.flow=i,i.result=e.build(this,t),this.flow=r,i}flowNodeFromShaderStage(e,t,r=null,i=null){let s=this.tab,n=this.cache,a=this.shaderStage,o=this.context;this.setShaderStage(e);let l={...this.context};delete l.nodeBlock,this.cache=this.globalCache,this.tab="	",this.context=l;let u=null;if("generate"===this.buildStage){let s=this.flowChildNode(t,r);null!==i&&(s.code+=`${this.tab+i} = ${s.result};
6`),this.flowCode[e]=this.flowCode[e]+s.code,u=s}else u=t.build(this);return this.setShaderStage(a),this.cache=n,this.tab=s,this.context=o,u}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="",r=this.vars[e];if(void 0!==r)for(let e of r)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){let t=this.codes[e],r="";if(void 0!==t)for(let e of t)r+=e.code+"\n";return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(!(t=e&&e.isNode?e.isShaderCallNodeInternal?e.shaderNode.subBuilds:e.isStackNode?[e.subBuild]:this.getDataFromNode(e,"any").subBuilds:e instanceof Set?[...e]:e))return null;let r=this.subBuildLayers;for(let e=t.length-1;e>=0;e--){let i=t[e];if(r.includes(i))return i}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r;return(r=null!==t?this.getClosestSubBuild(t):this.subBuildFn)?e?r+"_"+e:r:e}build(){let{object:e,material:t,renderer:r}=this;if(null!==t){let e=r.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new o$),e.build(this)}else this.addFlow("compute",e);for(let e of L)for(let t of(this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex),P))for(let r of(this.setShaderStage(t),this.flowNodes[t]))"generate"===e?this.flowNode(r):r.build(this);return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new g8(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new g5(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new g9(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new g7(e);if("color"===t)return new me(e);if("mat2"===t)return new mt(e);if("mat3"===t)return new mr(e);if("mat4"===t)return new mi(e);throw Error(`Uniform "${t}" not declared.`)}format(e,t,r){if(t=this.getVectorType(t),r=this.getVectorType(r),t===r||null===r||this.isReference(r))return e;let i=this.getTypeLength(t),s=this.getTypeLength(r);return 16===i&&9===s?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:9===i&&4===s?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:i>4||s>4||0===s?e:i===s?`${this.getType(r)}( ${e} )`:i>s?(e="bool"===r?`all( ${e} )`:`${e}.${"xyz".slice(0,s)}`,this.format(e,this.getTypeFromLength(s,this.getComponentType(t)),r)):4===s&&i>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===i?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===i&&s>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${u.sPf} - Node System
7`}}class ml{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return void 0===r&&(r={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,r)),r}updateBeforeNode(e){let t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===w.FRAME){let{frameMap:t}=this._getMaps(this.updateBeforeMap,r);
7t.get(r)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(r,this.frameId)}else if(t===w.RENDER){let{renderMap:t}=this._getMaps(this.updateBeforeMap,r);t.get(r)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(r,this.renderId)}else t===w.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===w.FRAME){let{frameMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(r,this.frameId)}else if(t===w.RENDER){let{renderMap:t}=this._getMaps(this.updateAfterMap,r);t.get(r)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(r,this.renderId)}else t===w.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),r=e.updateReference(this);if(t===w.FRAME){let{frameMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.frameId&&!1!==e.update(this)&&t.set(r,this.frameId)}else if(t===w.RENDER){let{renderMap:t}=this._getMaps(this.updateMap,r);t.get(r)!==this.renderId&&!1!==e.update(this)&&t.set(r,this.renderId)}else t===w.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class mu{constructor(e,t,r=null,i="",s=!1){this.type=e,this.name=t,this.count=r,this.qualifier=i,this.isConst=s}}mu.isNodeFunctionInput=!0;class md extends pH{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:ph(this.light),lightColor:e}}}let mh=new u.kn4,mc=new u.kn4,mp=null;class mg extends pH{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=tU(new u.Pq0).setGroup(tL),this.halfWidth=tU(new u.Pq0).setGroup(tL),this.updateType=w.RENDER}update(e){super.update(e);let{light:t}=this,r=e.camera.matrixWorldInverse;mc.identity(),mh.copy(t.matrixWorld),mh.premultiply(r),mc.extractRotation(mh),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(mc),this.halfHeight.value.applyMatrix4(mc)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=sl(mp.LTC_FLOAT_1),r=sl(mp.LTC_FLOAT_2)):(t=sl(mp.LTC_HALF_1),r=sl(mp.LTC_HALF_2));let{colorNode:i,light:s}=this;return{lightColor:i,lightPosition:pd(s),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){mp=e}}class mm extends pH{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=tU(0).setGroup(tL),this.penumbraCosNode=tU(0).setGroup(tL),this.cutoffDistanceNode=tU(0).setGroup(tL),this.decayExponentNode=tU(0).setGroup(tL),this.colorNode=tU(this.color).setGroup(tL)}update(e){super.update(e);let{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){let{coneCosNode:r,penumbraCosNode:i}=this;return it(r,i,t)}getLightCoord(e){let t=e.getNodeProperties(this),r=t.projectionUV;return void 0===r&&(t.projectionUV=r=po(this.light,e.context.positionWorld)),r}setupDirect(e){let t,r,{colorNode:i,cutoffDistanceNode:s,decayExponentNode:n,light:a}=this,o=this.getLightVector(e),l=o.normalize(),u=l.dot(ph(a)),d=this.getSpotAttenuation(e,u),h=pW({lightDistance:o.length(),cutoffDistance:s,decayExponent:n}),c=i.mul(d).mul(h);return a.colorNode?(r=this.getLightCoord(e),t=a.colorNode(r)):a.map&&(r=this.getLightCoord(e),t=sl(a.map,r.xy).onRenderUpdate(()=>a.map)),t&&(c=r.mul(2).sub(1).abs().lessThan(1).all().select(c.mul(t),c)),{lightColor:c,lightDirection:l}}}class mf extends mm{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){let r=this.light.iesMap;return r&&!0===r.isTexture?sl(r,eH(t.acos().mul(1/Math.PI),0),0).r:super.getSpotAttenuation(t)}}let my=eF(([e,t])=>{let r=e.abs().sub(t);return rP(rj(r,0)).add(rq(rj(r.x,r.y),0))});class mb extends mm{static get type(){return"ProjectorLightNode"}update(e){super.update(e);let t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),null===t.aspect){let e=1;null!==t.map&&(e=t.map.width/t.map.height),t.shadow.aspect=e}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){let t=eG(0),r=this.penumbraCosNode,i=pa(this.light).mul(e.context.positionWorld||s5);return eD(i.w.greaterThan(0),()=>{let e=my(i.xyz.div(i.w).xy.sub(eH(.5)),eH(.5)),s=tj(-1,tW(1,rw(r)).sub(1));t.assign(r7(e.mul(-2).mul(s)))}),t}}class mx extends pH{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class mT extends pH{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=pl(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=tU(new u.Q1f).setGroup(tL)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}
7setup(e){let{colorNode:t,groundColorNode:r,lightDirectionNode:i}=this,s=r5(r,t,nh.dot(i).mul(.5).add(.5));e.context.irradiance.addAssign(s)}}class m_ extends pH{static get type(){return"LightProbeNode"}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new u.Pq0);this.lightProbe=sg(t)}update(e){let{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){let t=gI(nh,this.lightProbe);e.context.irradiance.addAssign(t)}}class mv{parseFunction(){console.warn("Abstract function.")}}class mN{constructor(e,t,r="",i=""){this.type=e,this.inputs=t,this.name=r,this.precision=i}getCode(){console.warn("Abstract function.")}}mN.isNodeFunction=!0;let mS=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,mR=/[a-z_0-9]+/ig,mA="#pragma main";class mE extends mN{constructor(e){let{type:t,inputs:r,name:i,precision:s,inputsCode:n,blockCode:a,headerCode:o}=(e=>{let t=(e=e.trim()).indexOf(mA),r=-1!==t?e.slice(t+mA.length):e,i=r.match(mS);if(null!==i&&5===i.length){let s=i[4],n=[],a=null;for(;null!==(a=mR.exec(s));)n.push(a);let o=[],l=0;for(;l<n.length;){let e="const"===n[l][0];!0===e&&l++;let t=n[l][0];"in"===t||"out"===t||"inout"===t?l++:t="";let r=n[l++][0],i=Number.parseInt(n[l][0]);!1===Number.isNaN(i)?l++:i=null;let s=n[l++][0];o.push(new mu(r,s,i,t,e))}let u=r.substring(i[0].length),d=void 0!==i[3]?i[3]:"",h=i[2];return{type:h,inputs:o,name:d,precision:void 0!==i[1]?i[1]:"",inputsCode:s,blockCode:u,headerCode:-1!==t?e.slice(0,t):""}}throw Error("FunctionNode: Function is not a GLSL code.")})(e);super(t,r,i,s),this.inputsCode=n,this.blockCode=a,this.headerCode=o}getCode(e=this.name){let t,r=this.blockCode;if(""!==r){let{type:i,inputsCode:s,headerCode:n,precision:a}=this,o=`${i} ${e} ( ${s.trim()} )`;""!==a&&(o=`${a} ${o}`),t=n+o+r}else t="";return t}}class mC extends mv{parseFunction(e){return new mE(e)}}let mw=new WeakMap,mM=[],mB=[];class mL extends ds{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new ml,this.nodeBuilderCache=new Map,this.callHashCache=new u7,this.groupsData=new u7,this.cacheLib={}}updateGroup(e){let t=e.groupNode,r=t.name;if(r===tP.name)return!0;if(r===tL.name){let t=this.get(e),r=this.nodeFrame.renderId;return t.renderId!==r&&(t.renderId=r,!0)}if(r===tB.name){let t=this.get(e),r=this.nodeFrame.frameId;return t.frameId!==r&&(t.frameId=r,!0)}mM[0]=t,mM[1]=e;let i=this.groupsData.get(mM);return void 0===i&&this.groupsData.set(mM,i={}),mM.length=0,i.version!==t.version&&(i.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){let t=this.get(e),r=t.nodeBuilderState;if(void 0===r){let{nodeBuilderCache:i}=this,s=this.getForRenderCacheKey(e);if(void 0===(r=i.get(s))){let t=this.backend.createNodeBuilder(e.object,this.renderer);t.scene=e.scene,t.material=e.material,t.camera=e.camera,t.context.material=e.material,t.lightsNode=e.lightsNode,t.environmentNode=this.getEnvironmentNode(e.scene),t.fogNode=this.getFogNode(e.scene),t.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&t.enableMultiview(),t.build(),r=this._createNodeBuilderState(t),i.set(s,r)}r.usedTimes++,t.nodeBuilderState=r}return r}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){let t=this.get(e),r=t.nodeBuilderState;if(void 0===r){let i=this.backend.createNodeBuilder(e,this.renderer);i.build(),t.nodeBuilderState=r=this._createNodeBuilderState(i)}return r}_createNodeBuilderState(e){return new gz(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{let r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}
7getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{let r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){mM[0]=e,mM[1]=t;let r=this.renderer.info.calls,i=this.callHashCache.get(mM)||{};if(i.callId!==r){let s=this.getEnvironmentNode(e),n=this.getFogNode(e);t&&mB.push(t.getCacheKey(!0)),s&&mB.push(s.getCacheKey()),n&&mB.push(n.getCacheKey()),mB.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),mB.push(+!!this.renderer.shadowMap.enabled),i.callId=r,i.cacheKey=m(mB),this.callHashCache.set(mM,i),mB.length=0}return mM.length=0,i.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){let t=this.get(e),r=e.background;if(r){let i=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;(t.background!==r||i)&&(t.backgroundNode=this.getCacheNode("background",r,()=>{if(!0===r.isCubeTexture||r.mapping===u.wfO||r.mapping===u.uV5||r.mapping===u.Om)if(e.backgroundBlurriness>0||r.mapping===u.Om)return uU(r);else return o8(!0===r.isCubeTexture?nM(r):sl(r));if(!0===r.isTexture)return sl(r,sx.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",r)},i),t.background=r,t.backgroundBlurriness=e.backgroundBlurriness)}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,i=!1){let s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap),n=s.get(t);return(void 0===n||i)&&(n=r(),s.set(t,n)),n}updateFog(e){let t=this.get(e),r=e.fog;r?t.fog!==r&&(t.fogNode=this.getCacheNode("fog",r,()=>{if(r.isFogExp2)return cS(nP("color","color",r).setGroup(tL),cN(nP("density","float",r).setGroup(tL)));if(r.isFog){let e=nP("color","color",r).setGroup(tL);return cS(e,cv(nP("near","float",r).setGroup(tL),nP("far","float",r).setGroup(tL)))}console.error("THREE.Renderer: Unsupported fog configuration.",r)}),t.fog=r):(delete t.fogNode,delete t.fog)}updateEnvironment(e){let t=this.get(e),r=e.environment;r?t.environment!==r&&(t.environmentNode=this.getCacheNode("environment",r,()=>!0===r.isCubeTexture?nM(r):!0===r.isTexture?sl(r):void console.error("Nodes: Unsupported environment configuration.",r)),t.environment=r):t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,i=null,s=null){let n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=r,n.camera=i,n.material=s,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){let e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}hasOutputChange(e){return mw.get(e)!==this.getOutputCacheKey()}getOutputNode(e){let t=this.renderer,r=this.getOutputCacheKey(),i=e.isArrayTexture?hH(e,eX(sx,sf("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):sl(e,sx).renderOutput(t.toneMapping,t.currentColorSpace);return mw.set(e,r),i}updateBefore(e){for(let t of e.getNodeBuilderState().updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(t)}updateAfter(e){for(let t of e.getNodeBuilderState().updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(t)}updateForCompute(e){let t=this.getNodeFrame();for(let r of this.getForCompute(e).updateNodes)t.updateNode(r)}updateForRender(e){let t=this.getNodeFrameForRender(e);for(let r of e.getNodeBuilderState().updateNodes)t.updateNode(r)}needsRefresh(e){let t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new ml,this.nodeBuilderCache=new Map,this.cacheLib={}}}let mP=new u.Zcv;class mF{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new u.dwI,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){let i=e.length;for(let s=0;s<i;s++){mP.copy(e[s]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let i=t[r+s],n=mP.normal;i.x=-n.x,i.y=-n.y,i.z=-n.z,i.w=mP.constant}}updateGlobal(e,t){this.shadowPass=null!==e.overrideMaterial&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let r,i,s=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);let n=t.clippingPlanes,a=n.length;if(this.clipIntersection?(r=this.intersectionPlanes,i=e.intersectionPlanes.length):(r=this.unionPlanes,i=e.unionPlanes.length),r.length!==i+a){r.length=i+a;for(let e=0;e<a;e++)r[i+e]=new u.IUQ;s=!0}this.projectPlanes(n,r,i),s&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}
7getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return void 0===t&&(t=new mF(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class mU{constructor(e,t){this.bundleGroup=e,this.camera=t}}let mI=[];class mD{constructor(){this.bundles=new u7}get(e,t){let r=this.bundles;mI[0]=e,mI[1]=t;let i=r.get(mI);return void 0===i&&(i=new mU(e,t),r.set(mI,i)),mI.length=0,i}dispose(){this.bundles=new u7}}class mO{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null,r=this.getMaterialNodeClass(e.type);if(null!==r)for(let i in t=new r,e)t[i]=e[i];return t}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,r){if(r.has(t))return void console.warn(`Redefinition of node ${t}`);if("function"!=typeof e)throw Error(`Node class ${e.name} is not a class.`);if("function"==typeof t||"object"==typeof t)throw Error(`Base class ${t} is not a class.`);r.set(t,e)}addClass(e,t,r){if(r.has(t))return void console.warn(`Redefinition of node ${t.name}`);if("function"!=typeof e)throw Error(`Node class ${e.name} is not a class.`);if("function"!=typeof t)throw Error(`Base class ${t.name} is not a class.`);r.set(t,e)}}let mV=new pm,mG=[];class mk extends u7{constructor(){super()}createNode(e=[]){return new pm().setLights(e)}getNode(e,t){if(e.isQuadMesh)return mV;mG[0]=e,mG[1]=t;let r=this.get(mG);return void 0===r&&(r=this.createNode(),this.set(mG,r)),mG.length=0,r}}class mz extends u.O0B{constructor(e=1,t=1,r={}){super(e,t,r),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}}let m$=new u.Pq0,mH=new u.Pq0;class mW extends u.Qev{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new u.ubm,this._cameraL.viewport=new u.IUQ,this._cameraR=new u.ubm,this._cameraR.viewport=new u.IUQ,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new u.nZQ,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding="undefined"!=typeof XRWebGLBinding,this._frameBufferTargets=null,this._createXRLayer=mQ.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new u.I9Y,this._onSessionEvent=mj.bind(this),this._onSessionEnd=mX.bind(this),this._onInputSourcesChange=mK.bind(this),this._onAnimationFrame=mY.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){if(null!==this._glProjLayer||null!==this._glBaseLayer)return this._foveation}setFoveation(e){this._foveation=e,null!==this._glProjLayer&&(this._glProjLayer.fixedFoveation=e),null!==this._glBaseLayer&&void 0!==this._glBaseLayer.fixedFoveation&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,!0===this.isPresenting&&console.warn("THREE.XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,!0===this.isPresenting&&console.warn("THREE.XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(null!==this._session)return this._session.environmentBlendMode}getBinding(){return null===this._glBinding&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,r,i,s,n,a,o={}){let l=new u.bdM(e,t),d=new mz(s,n,{format:u.GWd,type:u.OUM,depthTexture:new u.VCu(s,n,o.stencil?u.V3x:u.bkx,void 0,void 0,void 0,void 0,void 0,void 0,o.stencil?u.dcC:u.zdS),stencilBuffer:o.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});d._autoAllocateDepthBuffer=!0;let h=new u.V9B({color:0xffffff,side:u.hB5});h.map=d.texture,h.map.offset.y=1,h.map.repeat.y=-1;let c=new u.eaF(l,h);c.position.copy(r),c.quaternion.copy(i);let p={type:"quad",width:e,height:t,translation:r,quaternion:i,pixelwidth:s,pixelheight:n,plane:c,material:h,rendercall:a,renderTarget:d};if(this._layers.push(p),null!==this._session){p.plane.material=new u.V9B({color:0xffffff,side:u.hB5}),p.plane.material.blending=u.bCz,p.plane.material.blendEquation=u.gO9,p.plane.material.blendSrc=u.ojh,p.plane.material.blendDst=u.ojh,p.xrlayer=this._createXRLayer(p);let e=this._session.renderState.layers;e.unshift(p.xrlayer),this._session.updateRenderState({layers:e})}else d.isXRRenderTarget=!1;return c}createCylinderLayer(e,t,r,i,s,n,a,o,l={}){let d=new u.Ho_(e,e,e*t/r,64,64,!0,Math.PI-t/2,t),h=new mz(n,a,{format:u.GWd,type:u.OUM,depthTexture:new u.VCu(n,a,l.stencil?u.V3x:u.bkx,void 0,void 0,void 0,void 0,void 0,void 0,l.stencil?u.dcC:u.zdS),stencilBuffer:l.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});h._autoAllocateDepthBuffer=!0;let c=new u.V9B({color:0xffffff,side:u.hsX});c.map=h.texture,c.map.offset.y=1,c.map.repeat.y=-1;let p=new u.eaF(d,c);p.position.copy(i),p.quaternion.copy(s);
7let g={type:"cylinder",radius:e,centralAngle:t,aspectratio:r,translation:i,quaternion:s,pixelwidth:n,pixelheight:a,plane:p,material:c,rendercall:o,renderTarget:h};if(this._layers.push(g),null!==this._session){g.plane.material=new u.V9B({color:0xffffff,side:u.hsX}),g.plane.material.blending=u.bCz,g.plane.material.blendEquation=u.gO9,g.plane.material.blendSrc=u.ojh,g.plane.material.blendDst=u.ojh,g.xrlayer=this._createXRLayer(g);let e=this._session.renderState.layers;e.unshift(g.xrlayer),this._session.updateRenderState({layers:e})}else h.isXRRenderTarget=!1;return p}renderLayers(){let e=new u.Pq0,t=new u.PTz,r=this._renderer,i=this.isPresenting,s=r.getOutputRenderTarget(),n=r._frameBufferTarget;this.isPresenting=!1;let a=new u.I9Y;r.getSize(a);let o=r._quad;for(let i of this._layers)if(i.renderTarget.isXRRenderTarget=null!==this._session,i.renderTarget._hasExternalTextures=i.renderTarget.isXRRenderTarget,i.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){i.xrlayer.transform=new XRRigidTransform(i.plane.getWorldPosition(e),i.plane.getWorldQuaternion(t));let s=this._glBinding.getSubImage(i.xrlayer,this._xrFrame);r.backend.setXRRenderTargetTextures(i.renderTarget,s.colorTexture,void 0),r._setXRLayerSize(i.renderTarget.width,i.renderTarget.height),r.setOutputRenderTarget(i.renderTarget),r.setRenderTarget(null),r._frameBufferTarget=null,this._frameBufferTargets||(this._frameBufferTargets=new WeakMap);let{frameBufferTarget:n,quad:a}=this._frameBufferTargets.get(i.renderTarget)||{frameBufferTarget:null,quad:null};n?(r._frameBufferTarget=n,r._quad=a):(r._quad=new hT(new o$),this._frameBufferTargets.set(i.renderTarget,{frameBufferTarget:r._getFrameBufferTarget(),quad:r._quad})),i.rendercall(),r._frameBufferTarget=null}else r.setRenderTarget(i.renderTarget),i.rendercall();r.setRenderTarget(null),r.setOutputRenderTarget(s),r._frameBufferTarget=n,r._setXRLayerSize(a.x,a.y),r._quad=o,this.isPresenting=i}getSession(){return this._session}async setSession(e){let t=this._renderer,r=t.backend;this._gl=t.getContext();let i=this._gl,s=i.getContextAttributes();if(this._session=e,null!==e){if(!0===r.isWebGPUBackend)throw Error('THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.');if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),await r.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),!0===this._supportsLayers){let r=null,n=null,a=null;t.depth&&(a=t.stencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24,r=t.stencil?u.dcC:u.zdS,n=t.stencil?u.V3x:u.bkx);let o={colorFormat:i.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(o.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();let l=this._glBinding.createProjectionLayer(o),d=[l];this._glProjLayer=l,t.setPixelRatio(1),t._setXRLayerSize(l.textureWidth,l.textureHeight);let h=this._useMultiview?2:1,c=new u.VCu(l.textureWidth,l.textureHeight,n,void 0,void 0,void 0,void 0,void 0,void 0,r,h);if(this._xrRenderTarget=new mz(l.textureWidth,l.textureHeight,{format:u.GWd,type:u.OUM,colorSpace:t.outputColorSpace,depthTexture:c,stencilBuffer:t.stencil,samples:4*!!s.antialias,resolveDepthBuffer:!1===l.ignoreDepthValues,resolveStencilBuffer:!1===l.ignoreDepthValues,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let e of this._layers)e.plane.material=new u.V9B({color:0xffffff,side:"cylinder"===e.type?u.hsX:u.hB5}),e.plane.material.blending=u.bCz,e.plane.material.blendEquation=u.gO9,e.plane.material.blendSrc=u.ojh,e.plane.material.blendDst=u.ojh,e.xrlayer=this._createXRLayer(e),d.unshift(e.xrlayer);e.updateRenderState({layers:d})}else{let r=new XRWebGLLayer(e,i,{antialias:t.samples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()});this._glBaseLayer=r,e.updateRenderState({baseLayer:r}),t.setPixelRatio(1),t._setXRLayerSize(r.framebufferWidth,r.framebufferHeight),this._xrRenderTarget=new mz(r.framebufferWidth,r.framebufferHeight,{format:u.GWd,type:u.OUM,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===r.ignoreDepthValues,resolveStencilBuffer:!1===r.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){var t,r,i;let s=this._session;if(null===s)return;let n=e.near,a=e.far,o=this._cameraXR,l=this._cameraL,d=this._cameraR;o.near=d.near=l.near=n,o.far=d.far=l.far=a,o.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==o.near||this._currentDepthFar!==o.far)&&(s.updateRenderState({depthNear:o.near,depthFar:o.far}),this._currentDepthNear=o.near,this._currentDepthFar=o.far),o.layers.mask=6|e.layers.mask,l.layers.mask=3&o.layers.mask,d.layers.mask=5&o.layers.mask;let h=e.parent,c=o.cameras;mq(o,h);for(let e=0;e<c.length;e++)mq(c[e],h);2===c.length?function(e,t,r){m$.setFromMatrixPosition(t.matrixWorld),mH.setFromMatrixPosition(r.matrixWorld);let i=m$.distanceTo(mH),s=t.projectionMatrix.elements,n=r.projectionMatrix.elements,a=s[14]/(s[10]-1),o=s[14]/(s[10]+1),l=(s[9]+1)/s[5],u=(s[9]-1)/s[5],d=(s[8]-1)/s[0],h=(n[8]+1)/n[0],c=i/(-d+h),p=-(c*d);if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(p),e.translateZ(c),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),-1===s[10])e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=a+c,r=o+c;e.projectionMatrix.makePerspective(a*d-p,a*h+(i-p),l*o/r*t,u*o/r*t,t,r),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(o,l,d):o.projectionMatrix.copy(l.projectionMatrix),t=e,r=o,null===(i=h)?t.matrix.copy(r.matrixWorld):(t.matrix.copy(i.matrixWorld),t.matrix.invert(),t.matrix.multiply(r.matrixWorld)),t.matrix.decompose(t.position,t.quaternion,t.scale),t.updateMatrixWorld(!0),t.projectionMatrix.copy(r.projectionMatrix),t.projectionMatrixInverse.copy(r.projectionMatrixInverse),t.isPerspectiveCamera&&(t.fov=2*u.a55*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}_getController(e){let t=this._controllers[e];return void 0===t&&(t=new u.R3r,this._controllers[e]=t),t}}function mq(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function mj(e){let t=this._controllerInputSources.indexOf(e.inputSource);if(-1===t)return;let r=this._controllers[t];if(void 0!==r){let t=this.getReferenceSpace();r.update(e.inputSource,e.frame,t),r.dispatchEvent({type:e.type,data:e.inputSource})}}function mX(){let e=this._session,t=this._renderer;e.removeEventListener("select",this._onSessionEvent),e.removeEventListener("selectstart",this._onSessionEvent),e.removeEventListener("selectend",this._onSessionEvent),e.removeEventListener("squeeze",this._onSessionEvent),e.removeEventListener("squeezestart",this._onSessionEvent),e.removeEventListener("squeezeend",this._onSessionEvent),e.removeEventListener("end",this._onSessionEnd),e.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let e=0;e<this._controllers.length;e++){let t=this._controllerInputSources[e];null!==t&&(this._controllerInputSources[e]=null,this._controllers[e].disconnect(t))}if(this._currentDepthNear=null,this._currentDepthFar=null,t._resetXRState(),this._session=null,this._xrRenderTarget=null,!0===this._sessionUsesLayers)for(let e of this._layers)e.renderTarget=new mz(e.pixelwidth,e.pixelheight,{format:u.GWd,type:u.OUM,depthTexture:new u.VCu(e.pixelwidth,e.pixelheight,e.stencilBuffer?u.V3x:u.bkx,void 0,void 0,void 0,void 0,void 0,void 0,e.stencilBuffer?u.dcC:u.zdS),stencilBuffer:e.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),e.renderTarget.isXRRenderTarget=!1,e.plane.material=e.material,e.material.map=e.renderTarget.texture,e.material.map.offset.y=1,e.material.map.repeat.y=-1,delete e.xrlayer;this.isPresenting=!1,this._useMultiview=!1,t._animation.stop(),t._animation.setAnimationLoop(this._currentAnimationLoop),t._animation.setContext(this._currentAnimationContext),t._animation.start(),t.setPixelRatio(this._currentPixelRatio),t.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:"sessionend"})}function mK(e){let t=this._controllers,r=this._controllerInputSources;for(let i=0;i<e.removed.length;i++){let s=e.removed[i],n=r.indexOf(s);n>=0&&(r[n]=null,t[n].disconnect(s))}for(let i=0;i<e.added.length;i++){let s=e.added[i],n=r.indexOf(s);if(-1===n){for(let e=0;e<t.length;e++)if(e>=r.length){r.push(s),n=e;break}else if(null===r[e]){r[e]=s,n=e;break}if(-1===n)break}let a=t[n];a&&a.connect(s)}}function mQ(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space
7:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(e.translation,e.quaternion),radius:e.radius,centralAngle:e.centralAngle,aspectRatio:e.aspectRatio,space:this._referenceSpace,viewPixelWidth:e.pixelwidth,viewPixelHeight:e.pixelheight,clearOnAccess:!1})}function mY(e,t){if(void 0===t)return;let r=this._cameraXR,i=this._renderer,s=i.backend,n=this._glBaseLayer,a=this.getReferenceSpace(),o=t.getViewerPose(a);if(this._xrFrame=t,null!==o){let e=o.views;null!==this._glBaseLayer&&s.setXRTarget(n.framebuffer);let t=!1;e.length!==r.cameras.length&&(r.cameras.length=0,t=!0);for(let i=0;i<e.length;i++){let a,o=e[i];if(!0===this._supportsLayers){let e=this._glBinding.getViewSubImage(this._glProjLayer,o);a=e.viewport,0===i&&s.setXRRenderTargetTextures(this._xrRenderTarget,e.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:e.depthStencilTexture)}else a=n.getViewport(o);let l=this._cameras[i];void 0===l&&((l=new u.ubm).layers.enable(i),l.viewport=new u.IUQ,this._cameras[i]=l),l.matrix.fromArray(o.transform.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.projectionMatrix.fromArray(o.projectionMatrix),l.projectionMatrixInverse.copy(l.projectionMatrix).invert(),l.viewport.set(a.x,a.y,a.width,a.height),0===i&&(r.matrix.copy(l.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)),!0===t&&r.cameras.push(l)}i.setOutputRenderTarget(this._xrRenderTarget)}for(let e=0;e<this._controllers.length;e++){let r=this._controllerInputSources[e],i=this._controllers[e];null!==r&&void 0!==i&&i.update(r,t,a)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:t}),this._xrFrame=null}let mZ=new u.Z58,mJ=new u.I9Y,m0=new u.IUQ,m1=new u.PPD,m2=new u.uf3,m3=new u.kn4,m4=new u.IUQ;class m6{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:r=!1,alpha:i=!0,depth:s=!0,stencil:n=!1,antialias:a=!1,samples:o=0,getFallback:l=null,colorBufferType:d=u.ix0,multiview:h=!1}=t;this.domElement=e.getDomElement(),this.backend=e,this.samples=o||!0===a?4:0,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=i,this.logarithmicDepthBuffer=r,this.outputColorSpace=u.er$,this.toneMapping=u.y_p,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=s,this.stencil=n,this.info=new dh,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new mO,this.lighting=new mk,this._getFallback=l,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new u.IUQ(0,0,this._width,this._height),this._scissor=new u.IUQ(0,0,this._width,this._height),this._scissorTest=!1,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new hT(new o$),this._quad.material.name="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;let c=+(!0!==this.alpha);this._clearColor=new dF(0,0,0,c),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._colorBufferType=d,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:u.QP0},this.xr=new mW(this,h),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,r)=>{await this.compileAsync(e,t);let i=this._renderLists.get(e,t),s=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||r.material,{fragmentShader:a,vertexShader:o}=this._objects.get(r,n,e,t,i.lightsNode,s,s.clippingContext).getNodeBuilderState();return{fragmentShader:a,vertexShader:o}}}}
7async init(){if(this._initialized)throw Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=r=this._getFallback(e),await r.init(this)}catch(e){t(e);return}}this._nodes=new mL(this,r),this._animation=new u9(this._nodes,this.info),this._attributes=new da(r),this._background=new gV(this,this._nodes),this._geometries=new dd(this._attributes,this.info),this._textures=new dP(this,r,this.info),this._pipelines=new dy(r,this._nodes),this._bindings=new db(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new di(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new dS(this.lighting),this._bundles=new mD,this._renderContexts=new dB,this._animation.start(),this._initialized=!0,e(this)})),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(!0===this._isDeviceLost)return;!1===this._initialized&&await this.init();let i=this._nodes.nodeFrame,s=i.renderId,n=this._currentRenderContext,a=this._currentRenderObjectFunction,o=this._compilationPromises,l=!0===e.isScene?e:mZ;null===r&&(r=e);let u=this._renderTarget,d=this._renderContexts.get(r,t,u),h=this._activeMipmapLevel,c=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=c,i.renderId++,i.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new mF),d.clippingContext.updateGlobal(l,t),l.onBeforeRender(this,e,t,u);let p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p,d.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)}),p.finish(),null!==u){this._textures.updateRenderTarget(u,h);let e=this._textures.get(u);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;this._background.update(l,p,d);let g=p.opaque,m=p.transparent,f=p.transparentDoublePass,y=p.lightsNode;!0===this.opaque&&g.length>0&&this._renderObjects(g,t,l,y),!0===this.transparent&&m.length>0&&this._renderTransparents(m,f,t,l,y),i.renderId=s,this._currentRenderContext=n,this._currentRenderObjectFunction=a,this._compilationPromises=o,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(c)}async renderAsync(e,t){!1===this._initialized&&await this.init(),this._renderScene(e,t)}async waitForGPU(){await this.backend.waitForGPU()}set highPrecision(e){!0===e?(this.overrideNodes.modelViewMatrix=s2,this.overrideNodes.modelNormalViewMatrix=s3):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===s2&&this.overrideNodes.modelNormalViewMatrix===s3}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
8
9Message: ${e.message}`;e.reason&&(t+=`
10Reason: ${e.reason}`),console.error(t),this._isDeviceLost=!0}_renderBundle(e,t,r){let{bundleGroup:i,camera:s,renderList:n}=e,a=this._currentRenderContext,o=this._bundles.get(i,s),l=this.backend.get(o);void 0===l.renderContexts&&(l.renderContexts=new Set);let u=i.version!==l.version,d=!1===l.renderContexts.has(a)||u;if(l.renderContexts.add(a),d){this.backend.beginBundle(a),(void 0===l.renderObjects||u)&&(l.renderObjects=[]),this._currentRenderBundle=o;let{transparentDoublePass:e,transparent:d,opaque:h}=n;!0===this.opaque&&h.length>0&&this._renderObjects(h,s,t,r),!0===this.transparent&&d.length>0&&this._renderTransparents(d,e,s,t,r),this._currentRenderBundle=null,this.backend.finishBundle(a,o),l.version=i.version}else{let{renderObjects:e}=l;for(let t=0,r=e.length;t<r;t++){let r=e[t];this._nodes.needsRefresh(r)&&(this._nodes.updateBefore(r),this._nodes.updateForRender(r),this._bindings.updateForRender(r),this._nodes.updateAfter(r))}}this.backend.addBundle(a,o)}render(e,t){if(!1===this._initialized)return console.warn("THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead."),this.renderAsync(e,t);this._renderScene(e,t)}_getFrameBufferTarget(){let{currentToneMapping:e,currentColorSpace:t}=this,r=e!==u.y_p,i=t!==u.ppV.workingColorSpace;if(!1===r&&!1===i)return null;let{width:s,height:n}=this.getDrawingBufferSize(mJ),{depth:a,stencil:o}=this,l=this._frameBufferTarget;
10null===l&&((l=new u.O0B(s,n,{depthBuffer:a,stencilBuffer:o,type:this._colorBufferType,format:u.GWd,colorSpace:u.ppV.workingColorSpace,generateMipmaps:!1,minFilter:u.k6q,magFilter:u.k6q,samples:this.samples})).isPostProcessingRenderTarget=!0,this._frameBufferTarget=l);let d=this.getOutputRenderTarget();return l.depthBuffer=a,l.stencilBuffer=o,null!==d?l.setSize(d.width,d.height,d.depth):l.setSize(s,n,1),l.viewport.copy(this._viewport),l.scissor.copy(this._scissor),l.viewport.multiplyScalar(this._pixelRatio),l.scissor.multiplyScalar(this._pixelRatio),l.scissorTest=this._scissorTest,l.multiview=null!==d&&d.multiview,l.resolveDepthBuffer=null===d||d.resolveDepthBuffer,l._autoAllocateDepthBuffer=null!==d&&d._autoAllocateDepthBuffer,l}_renderScene(e,t,r=!0){let i;if(!0===this._isDeviceLost)return;let s=r?this._getFrameBufferTarget():null,n=this._nodes.nodeFrame,a=n.renderId,o=this._currentRenderContext,l=this._currentRenderObjectFunction,u=!0===e.isScene?e:mZ,d=this._renderTarget||this._outputRenderTarget,h=this._activeCubeFace,c=this._activeMipmapLevel;null!==s?(i=s,this.setRenderTarget(i)):i=d;let p=this._renderContexts.get(e,t,i);this._currentRenderContext=p,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,n.renderId=this.info.calls;let g=this.coordinateSystem,m=this.xr;if(t.coordinateSystem!==g&&!1===m.isPresenting&&(t.coordinateSystem=g,t.updateProjectionMatrix(),t.isArrayCamera))for(let e of t.cameras)e.coordinateSystem=g,e.updateProjectionMatrix();!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===m.enabled&&!0===m.isPresenting&&(!0===m.cameraAutoUpdate&&m.updateCamera(t),t=m.getCamera());let f=this._viewport,y=this._scissor,b=this._pixelRatio;null!==i&&(f=i.viewport,y=i.scissor,b=1),this.getDrawingBufferSize(mJ),m0.set(0,0,mJ.width,mJ.height);let x=void 0===f.minDepth?0:f.minDepth,T=void 0===f.maxDepth?1:f.maxDepth;p.viewportValue.copy(f).multiplyScalar(b).floor(),p.viewportValue.width>>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=x,p.viewportValue.maxDepth=T,p.viewport=!1===p.viewportValue.equals(m0),p.scissorValue.copy(y).multiplyScalar(b).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(m0),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new mF),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,i);let _=t.isArrayCamera?m2:m1;t.isArrayCamera||(m3.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(m3,t.coordinateSystem,t.reversedDepth));let v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,p.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==i){this._textures.updateRenderTarget(i,c);let e=this._textures.get(i);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=i,p.depth=i.depthBuffer,p.stencil=i.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=mJ.width,p.height=mJ.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=h,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,p.scissorValue.max(m4.set(0,0,0,0)),p.scissorValue.x+p.scissorValue.width>p.width&&(p.scissorValue.width=Math.max(p.width-p.scissorValue.x,0)),p.scissorValue.y+p.scissorValue.height>p.height&&(p.scissorValue.height=Math.max(p.height-p.scissorValue.y,0)),this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);let{bundles:N,lightsNode:S,transparentDoublePass:R,transparent:A,opaque:E}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&E.length>0&&this._renderObjects(E,t,u,S),!0===this.transparent&&A.length>0&&this._renderTransparents(A,R,t,u,S),this.backend.finishRender(p),n.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=l,null!==s&&(this.setRenderTarget(d,h,c),this._renderOutput(i)),u.onAfterRender(this,e,t,i),p}_setXRLayerSize(e,t){this._width=e,this._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);let r=this.autoClear,i=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=i}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===r&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}
10setScissor(e,t,r,i){let s=this._scissor;e.isVector4?s.copy(e):s.set(e,t,r,i)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,i,s=0,n=1){let a=this._viewport;e.isVector4?a.copy(e):a.set(e,t,r,i),a.minDepth=s,a.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){let t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,r);let i=this._renderTarget||this._getFrameBufferTarget(),s=null;if(null!==i){this._textures.updateRenderTarget(i);let e=this._textures.get(i);(s=this._renderContexts.getForClear(i)).textures=e.textures,s.depthTexture=e.depthTexture,s.width=e.width,s.height=e.height,s.renderTarget=i,s.depth=i.depthBuffer,s.stencil=i.stencilBuffer,s.clearColorValue=this.backend.getClearColor(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,s),null!==i&&null===this._renderTarget&&this._renderOutput(i)}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){!1===this._initialized&&await this.init(),this.clear(e,t,r)}async clearColorAsync(){this.clearAsync(!0,!1,!1)}async clearDepthAsync(){this.clearAsync(!1,!0,!1)}async clearStencilAsync(){this.clearAsync(!1,!1,!0)}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:u.y_p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:u.ppV.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||null===this._renderTarget}dispose(){!0===this._initialized&&(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),null!==this._frameBufferTarget&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{null!==e&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);let r=this._nodes.nodeFrame,i=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls;let s=this.backend,n=this._pipelines,a=this._bindings,o=this._nodes,l=Array.isArray(e)?e:[e];if(void 0===l[0]||!0!==l[0].isComputeNode)throw Error("THREE.Renderer: .compute() expects a ComputeNode.");for(let r of(s.beginCompute(e),l)){if(!1===n.has(r)){let e=()=>{r.removeEventListener("dispose",e),n.delete(r),a.delete(r),o.delete(r)};r.addEventListener("dispose",e);let t=r.onInitFunction;null!==t&&t.call(r,{renderer:this})}o.updateForCompute(r),a.updateForCompute(r);let i=a.getForCompute(r),l=n.getForCompute(r,i);s.compute(e,r,i,l,t)}s.finishCompute(e),r.renderId=i}async computeAsync(e,t=null){!1===this._initialized&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){!1===this._initialized&&await this.init(),this._textures.updateTexture(e)}initTexture(e){!1===this._initialized&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}
10copyFramebufferToTexture(e,t=null){let r;if(null!==t)if(t.isVector2)t=m4.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");t=m4.copy(t).floor()}else t=m4.set(0,0,e.image.width,e.image.height);let i=this._currentRenderContext;null!==i?r=i.renderTarget:null!==(r=this._renderTarget||this._getFrameBufferTarget())&&(this._textures.updateRenderTarget(r),i=this._textures.get(r)),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,i,t)}copyTextureToTexture(e,t,r=null,i=null,s=0,n=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,i,s,n)}async readRenderTargetPixelsAsync(e,t,r,i,s,n=0,a=0){return this.backend.copyTextureToBuffer(e.textures[n],t,r,i,s,a)}_projectObject(e,t,r,i,s){if(!1===e.visible)return;if(e.layers.test(t.layers)){if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)i.pushLight(e);else if(e.isSprite){let n=t.isArrayCamera?m2:m1;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&m4.setFromMatrixPosition(e.matrixWorld).applyMatrix4(m3);let{geometry:t,material:n}=e;n.visible&&i.push(e,t,n,r,m4.z,null,s)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){let n=t.isArrayCamera?m2:m1;if(!e.frustumCulled||n.intersectsObject(e,t)){let{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),m4.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(m3)),Array.isArray(n)){let a=t.groups;for(let o=0,l=a.length;o<l;o++){let l=a[o],u=n[l.materialIndex];u&&u.visible&&i.push(e,t,u,r,m4.z,l,s)}}else n.visible&&i.push(e,t,n,r,m4.z,null,s)}}}if(!0===e.isBundleGroup&&void 0!==this.backend.beginBundle){let r=i;(i=this._renderLists.get(e,t)).begin(),r.pushBundle({bundleGroup:e,camera:t,renderList:i}),i.finish()}let n=e.children;for(let e=0,a=n.length;e<a;e++)this._projectObject(n[e],t,r,i,s)}_renderBundles(e,t,r){for(let i of e)this._renderBundle(i,t,r)}_renderTransparents(e,t,r,i,s){if(t.length>0){for(let{material:e}of t)e.side=u.hsX;for(let{material:e}of(this._renderObjects(t,r,i,s,"backSide"),t))e.side=u.hB5;for(let{material:n}of(this._renderObjects(e,r,i,s),t))n.side=u.$EB}else this._renderObjects(e,r,i,s)}_renderObjects(e,t,r,i,s=null){for(let n=0,a=e.length;n<a;n++){let{object:a,geometry:o,material:l,group:u,clippingContext:d}=e[n];this._currentRenderObjectFunction(a,r,t,o,l,u,i,d,s)}}renderObject(e,t,r,i,s,n,a,o=null,l=null){let d,h,c;if(e.onBeforeRender(this,t,r,i,s,n),!0===s.allowOverride&&null!==t.overrideMaterial){let e=t.overrideMaterial;s.positionNode&&s.positionNode.isNode&&(d=e.positionNode,e.positionNode=s.positionNode),e.alphaTest=s.alphaTest,e.alphaMap=s.alphaMap,e.transparent=s.transparent||s.transmission>0,e.isShadowPassMaterial&&(e.side=null===s.shadowSide?s.side:s.shadowSide,s.depthNode&&s.depthNode.isNode&&(c=e.depthNode,e.depthNode=s.depthNode),s.castShadowNode&&s.castShadowNode.isNode&&(h=e.colorNode,e.colorNode=s.castShadowNode),s.castShadowPositionNode&&s.castShadowPositionNode.isNode&&(d=e.positionNode,e.positionNode=s.castShadowPositionNode)),s=e}!0===s.transparent&&s.side===u.$EB&&!1===s.forceSinglePass?(s.side=u.hsX,this._handleObjectFunction(e,s,t,r,a,n,o,"backSide"),s.side=u.hB5,this._handleObjectFunction(e,s,t,r,a,n,o,l),s.side=u.$EB):this._handleObjectFunction(e,s,t,r,a,n,o,l),void 0!==d&&(t.overrideMaterial.positionNode=d),void 0!==c&&(t.overrideMaterial.depthNode=c),void 0!==h&&(t.overrideMaterial.colorNode=h),e.onAfterRender(this,t,r,i,s,n)}_renderObjectDirect(e,t,r,i,s,n,a,o){let l=this._objects.get(e,t,r,i,s,this._currentRenderContext,a,o);l.drawRange=e.geometry.drawRange,l.group=n;let u=this._nodes.needsRefresh(l);u&&(this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l)),this._pipelines.updateForRender(l),null!==this._currentRenderBundle&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(l,this.info),u&&this._nodes.updateAfter(l)}_createObjectPipeline(e,t,r,i,s,n,a,o){let l=this._objects.get(e,t,r,i,s,this._currentRenderContext,a,o);l.drawRange=e.geometry.drawRange,l.group=n,this._nodes.updateBefore(l),this._geometries.updateForRender(l),this._nodes.updateForRender(l),this._bindings.updateForRender(l),this._pipelines.getForRender(l,this._compilationPromises),this._nodes.updateAfter(l)}get compile(){return this.compileAsync}}class m8{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class m5 extends m8{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){var e;return(e=this._buffer.byteLength)+(16-e%16)%16}get buffer(){return this._buffer}update(){return!0}}class m9 extends m5{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let m7=0;class fe extends m9{constructor(e,t){super("UniformBuffer_"+m7++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class ft extends m9{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){let t=this.uniforms.indexOf(e);return -1!==t&&this.uniforms.splice(t,1),this}get values(){return null===this._values&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;return null===e&&(e=new Float32Array(new ArrayBuffer(this.byteLength)),this._buffer=e),e}get byteLength(){let e=this.bytesPerElement,t=0;for(let r=0,i=this.uniforms.length;r<i;r++){let i=this.uniforms[r],s=i.boundary,n=i.itemSize*e,a=t%16,o=a%s,l=a+o;t+=o,0!==l&&16-l<n&&(t+=16-l),i.offset=t/e,t+=n}return 16*Math.ceil(t/16)}update(){let e=!1;for(let t of this.uniforms)!0===this.updateByType(t)&&(e=!0);return e}updateByType(e){return e.isNumberUniform?this.updateNumber(e):e.isVector2Uniform?this.updateVector2(e):e.isVector3Uniform?this.updateVector3(e):e.isVector4Uniform?this.updateVector4(e):e.isColorUniform?this.updateColor(e):e.isMatrix3Uniform?this.updateMatrix3(e):e.isMatrix4Uniform?this.updateMatrix4(e):void console.error("THREE.WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset,n=e.getType();return r[s]!==i&&(this._getBufferForType(n)[s]=r[s]=i,t=!0),t}updateVector2(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset,n=e.getType();if(r[s+0]!==i.x||r[s+1]!==i.y){let e=this._getBufferForType(n);e[s+0]=r[s+0]=i.x,e[s+1]=r[s+1]=i.y,t=!0}return t}updateVector3(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset,n=e.getType();if(r[s+0]!==i.x||r[s+1]!==i.y||r[s+2]!==i.z){let e=this._getBufferForType(n);e[s+0]=r[s+0]=i.x,e[s+1]=r[s+1]=i.y,e[s+2]=r[s+2]=i.z,t=!0}return t}updateVector4(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset,n=e.getType();if(r[s+0]!==i.x||r[s+1]!==i.y||r[s+2]!==i.z||r[s+4]!==i.w){let e=this._getBufferForType(n);e[s+0]=r[s+0]=i.x,e[s+1]=r[s+1]=i.y,e[s+2]=r[s+2]=i.z,e[s+3]=r[s+3]=i.w,t=!0}return t}updateColor(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset;if(r[s+0]!==i.r||r[s+1]!==i.g||r[s+2]!==i.b){let e=this.buffer;e[s+0]=r[s+0]=i.r,e[s+1]=r[s+1]=i.g,e[s+2]=r[s+2]=i.b,t=!0}return t}updateMatrix3(e){let t=!1,r=this.values,i=e.getValue().elements,s=e.offset;if(r[s+0]!==i[0]||r[s+1]!==i[1]||r[s+2]!==i[2]||r[s+4]!==i[3]||r[s+5]!==i[4]||r[s+6]!==i[5
10]||r[s+8]!==i[6]||r[s+9]!==i[7]||r[s+10]!==i[8]){let e=this.buffer;e[s+0]=r[s+0]=i[0],e[s+1]=r[s+1]=i[1],e[s+2]=r[s+2]=i[2],e[s+4]=r[s+4]=i[3],e[s+5]=r[s+5]=i[4],e[s+6]=r[s+6]=i[5],e[s+8]=r[s+8]=i[6],e[s+9]=r[s+9]=i[7],e[s+10]=r[s+10]=i[8],t=!0}return t}updateMatrix4(e){let t=!1,r=this.values,i=e.getValue().elements,s=e.offset;return!1===function(e,t,r){for(let i=0,s=t.length;i<s;i++)if(e[r+i]!==t[i])return!1;return!0}(r,i,s)&&(this.buffer.set(i,s),function(e,t,r){for(let i=0,s=t.length;i<s;i++)e[r+i]=t[i]}(r,i,s),t=!0),t}_getBufferForType(e){return"int"===e||"ivec2"===e||"ivec3"===e||"ivec4"===e?new Int32Array(this.buffer.buffer):"uint"===e||"uvec2"===e||"uvec3"===e||"uvec4"===e?new Uint32Array(this.buffer.buffer):this.buffer}}let fr=0;class fi extends ft{constructor(e,t){super(e),this.id=fr++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class fs extends m8{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.generation=null,this.isSampler=!0}set texture(e){if(this._texture===e)return;let t=()=>{this._texture=null,this.generation=null,this.version=0};this._texture&&this._texture.removeEventListener("dispose",t),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",t)}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}clone(){let e=super.clone();return e._texture=null,e.texture=this.texture,e}}let fn=0;class fa extends fs{constructor(e,t){super(e,t),this.id=fn++,this.store=!1,this.isSampledTexture=!0}}class fo extends fa{constructor(e,t,r,i=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r,this.access=i}update(){let{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class fl extends fo{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledCubeTexture=!0}}class fu extends fo{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledTexture3D=!0}}let fd={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint"},fh={low:"lowp",medium:"mediump",high:"highp"},fc={swizzleAssign:!0,storageBuffer:!1},fp={perspective:"smooth",linear:"noperspective"},fg={centroid:"centroid"},fm=`
11precision highp float;
12precision highp int;
13precision highp sampler2D;
14precision highp sampler3D;
15precision highp samplerCube;
16precision highp sampler2DArray;
17
18precision highp usampler2D;
19precision highp usampler3D;
20precision highp usamplerCube;
21precision highp usampler2DArray;
22
23precision highp isampler2D;
24precision highp isampler3D;
25precision highp isamplerCube;
26precision highp isampler2DArray;
27
28precision lowp sampler2DShadow;
29precision lowp sampler2DArrayShadow;
30precision lowp samplerCubeShadow;
31`;class ff extends mo{constructor(e,t){super(e,t,new mC),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==u.jf0}getMethod(e){return fd[e]||e}getBitcastMethod(e,t){return fd[`bitcast_${t}_${e}`]}getTernary(e,t,r){return`${e} ? ${t} : ${r}`}getOutputStructName(){return""}buildFunctionCode(e){let t=e.layout,r=this.flowShaderNode(e),i=[];for(let e of t.inputs)i.push(this.getType(e.type)+" "+e.name);return`${this.getType(t.type)} ${t.name}( ${i.join(", ")} ) {
32
33	${r.vars}
34
35${r.code}
36	return ${r.result};
37
38}`}setupPBO(e){let t=e.value;if(void 0===t.pbo){let e=t.array,r=t.count*t.itemSize,{itemSize:i}=t,s=t.array.constructor.name.toLowerCase().includes("int"),n=s?u.ZQM:u.VT0;2===i?n=s?u.TkQ:u.paN:3===i?n=s?u.VGF:u.HIg:4===i&&(n=s?u.c90:u.GWd);let a={Float32Array:u.RQf,Uint8Array:u.OUM,Uint16Array:u.cHt,Uint32Array:u.bkx,Int8Array:u.tJf,Int16Array:u.fBL,Int32Array:u.Yuy,Uint8ClampedArray:u.OUM},o=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(r/i)))),l=Math.ceil(r/i/o);o*l*i<r&&l++;let d=o*l*i,h=new e.constructor(d);h.set(e,0),t.array=h;let c=new u.GYF(t.array,o,l,n,a[t.array.constructor.name]||u.RQf);c.needsUpdate=!0,c.isPBOTexture=!0;
38let p=new sa(c,null,null);p.setPrecision("high"),t.pboNode=p,t.pbo=p.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&!0!==e.node.isTextureNode&&!0!==e.node.isBufferNode?t.charAt(0)+"_"+e.name:super.getPropertyName(e,t)}generatePBO(e){let{node:t,indexNode:r}=e,i=t.value;this.renderer.backend.has(i)&&(this.renderer.backend.get(i).pbo=i.pbo);let s=this.getUniformFromNode(i.pboNode,"texture",this.shaderStage,this.context.nodeName),n=this.getPropertyName(s);this.increaseUsage(r);let a=r.build(this,"uint"),o=this.getDataFromNode(e),l=o.propertyName;if(void 0===l){let r=this.getVarFromNode(e);l=this.getPropertyName(r);let s=this.getDataFromNode(t),d=s.propertySizeName;void 0===d&&(d=l+"Size",this.getVarFromNode(t,d,"uint"),this.addLineFlowCode(`${d} = uint( textureSize( ${n}, 0 ).x )`,e),s.propertySizeName=d);let{itemSize:h}=i,c="."+F.join("").slice(0,h),p=`ivec2(${a} % ${d}, ${a} / ${d})`,g=this.generateTextureLoad(null,n,p,null,null,"0"),m="vec4";i.pbo.type===u.bkx?m="uvec4":i.pbo.type===u.Yuy&&(m="ivec4"),this.addLineFlowCode(`${l} = ${m}(${g})${c}`,e),o.propertyName=l}return l}generateTextureLoad(e,t,r,i,s,n="0"){let a;return a=i?s?`texelFetchOffset( ${t}, ivec3( ${r}, ${i} ), ${n}, ${s} )`:`texelFetch( ${t}, ivec3( ${r}, ${i} ), ${n} )`:s?`texelFetchOffset( ${t}, ${r}, ${n}, ${s} )`:`texelFetch( ${t}, ${r}, ${n} )`,null!==e&&e.isDepthTexture&&(a+=".x"),a}generateTexture(e,t,r,i,s){return(i&&(r=`vec3( ${r}, ${i} )`),e.isDepthTexture)?s?`textureOffset( ${t}, ${r}, ${s} ).x`:`texture( ${t}, ${r} ).x`:s?`textureOffset( ${t}, ${r}, ${s} )`:`texture( ${t}, ${r} )`}generateTextureLevel(e,t,r,i,s){return s?`textureLodOffset( ${t}, ${r}, ${i}, ${s} )`:`textureLod( ${t}, ${r}, ${i} )`}generateTextureBias(e,t,r,i,s){return s?`textureOffset( ${t}, ${r}, ${s}, ${i} )`:`texture( ${t}, ${r}, ${i} )`}generateTextureGrad(e,t,r,i,s){return s?`textureGradOffset( ${t}, ${r}, ${i[0]}, ${i[1]}, ${s} )`:`textureGrad( ${t}, ${r}, ${i[0]}, ${i[1]} )`}generateTextureCompare(e,t,r,i,s,n,a=this.shaderStage){if("fragment"===a)return s?n?`textureOffset( ${t}, vec4( ${r}, ${s}, ${i} ), ${n} )`:`texture( ${t}, vec4( ${r}, ${s}, ${i} ) )`:n?`textureOffset( ${t}, vec3( ${r}, ${i} ), ${n} )`:`texture( ${t}, vec3( ${r}, ${i} ) )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}getVars(e){let t=[],r=this.vars[e];if(void 0!==r)for(let e of r)t.push(`${this.getVar(e.type,e.name,e.count)};`);return t.join("\n	")}getUniforms(e){let t=this.uniforms[e],r=[],i={};for(let s of t){let t=null,n=!1;if("texture"===s.type||"texture3D"===s.type){let e=s.node.value,r="";(!0===e.isDataTexture||!0===e.isData3DTexture)&&(e.type===u.bkx?r="u":e.type===u.Yuy&&(r="i")),t="texture3D"===s.type&&!1===e.isArrayTexture?`${r}sampler3D ${s.name};`:e.compareFunction?!0===e.isArrayTexture?`sampler2DArrayShadow ${s.name};`:`sampler2DShadow ${s.name};`:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?`${r}sampler2DArray ${s.name};`:`${r}sampler2D ${s.name};`}else if("cubeTexture"===s.type)t=`samplerCube ${s.name};`;else if("buffer"===s.type){let e=s.node,r=this.getType(e.bufferType),i=e.bufferCount,n=i>0?i:"";t=`${e.name} {
39	${r} ${s.name}[${n}];
40};
41`}else{let r=this.getVectorType(s.type);t=`${r} ${this.getPropertyName(s,e)};`,n=!0}let a=s.node.precision;if(null!==a&&(t=fh[a]+" "+t),n){t="	"+t;let e=s.groupNode.name;(i[e]||(i[e]=[])).push(t)}else t="uniform "+t,r.push(t)}let s="";for(let t in i){let r=i[t];s+=this._getGLSLUniformStruct(e+"_"+t,r.join("\n"))+"\n"}return s+r.join("\n")}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==u.Yuy){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);let i=r.array;!1==(i instanceof Uint32Array||i instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){let e=this.getAttributesArray(),r=0;for(let i of e)t+=`layout( location = ${r++} ) in ${i.type} ${i.name};
42`}return t}getStructMembers(e){let t=[];for(let r of e.members)t.push(`	${r.type} ${r.name};`);return t.join("\n")}getStructs(e){let t=[],r=this.structs[e],i=[];for(let e of r)if(e.output)for(let t of e.members)i.push(`layout( location = ${t.index} ) out ${t.type} ${t.name};`);else{let r="struct "+e.name+" {\n";r+=this.getStructMembers(e),r+="\n};\n",t.push(r)}return 0===i.length&&i.push("layout( location = 0 ) out vec4 fragColor;"),"\n"+i.join("\n")+"\n\n"+t.join("\n")}getVaryings(e){let t="",r=this.varyings;if("vertex"===e||"compute"===e)for(let i of r){"compute"===e&&(i.needsInterpolation=!0);let r=this.getType(i.type);if(i.needsInterpolation)if(i.interpolationType){let e=fp[i.interpolationType]||i.interpolationType,s=fg[i.interpolationSampling]||"";t+=`${e} ${s} out ${r} ${i.name};
43`}else{let e=r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":"";t+=`${e}out ${r} ${i.name};
44`}else t+=`${r} ${i.name};
45`}else if("fragment"===e){for(let e of r)if(e.needsInterpolation){let r=this.getType(e.type);if(e.interpolationType){let i=fp[e.interpolationType]||e.interpolationType,s=fg[e.interpolationSampling]||"";t+=`${i} ${s} in ${r} ${e.name};
46`}else{let i=r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":"";t+=`${i}in ${r} ${e.name};
47`}}}for(let r of this.builtins[e])t+=`${r};
48`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){let e=this.object.workgroupSize.reduce((e,t)=>
48e*t,1);return`uint( gl_InstanceID ) % ${e}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){let i=this.extensions[r]||(this.extensions[r]=new Map);!1===i.has(e)&&i.set(e,{name:e,behavior:t})}getExtensions(e){let t=[];if("vertex"===e){let t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}let r=this.extensions[e];if(void 0!==r)for(let{name:e,behavior:i}of r.values())t.push(`#extension ${e} : ${i}`);return t.join("\n")}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=fc[e];if(void 0===t){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance"}if(void 0!==r){let e=this.renderer.backend.extensions;e.has(r)&&(e.get(r),t=!0)}fc[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}
48enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){let e=this.transforms,t="";for(let r=0;r<e.length;r++){let i=e[r],s=this.getPropertyName(i.attributeNode);s&&(t+=`${i.varyingName} = ${s};
49	`)}return t}_getGLSLUniformStruct(e,t){return`
50layout( std140 ) uniform ${e} {
51${t}
52};`}_getGLSLVertexCode(e){return`#version 300 es
53
54${this.getSignature()}
55
56// extensions
57${e.extensions}
58
59// precision
60${fm}
61
62// uniforms
63${e.uniforms}
64
65// varyings
66${e.varyings}
67
68// attributes
69${e.attributes}
70
71// codes
72${e.codes}
73
74void main() {
75
76	// vars
77	${e.vars}
78
79	// transforms
80	${e.transforms}
81
82	// flow
83	${e.flow}
84
85	gl_PointSize = 1.0;
86
87}
88`}_getGLSLFragmentCode(e){return`#version 300 es
89
90${this.getSignature()}
91
92// extensions
93${e.extensions}
94
95// precision
96${fm}
97
98// uniforms
99${e.uniforms}
100
101// varyings
102${e.varyings}
103
104// codes
105${e.codes}
106
107// structs
108${e.structs}
109
110void main() {
111
112	// vars
113	${e.vars}
114
115	// flow
116	${e.flow}
117
118}
119`}buildCode(){let e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};for(let t in this.sortBindingGroups(),e){let r="// code\n\n";r+=this.flowCode[t];let i=this.flowNodes[t],s=i[i.length-1];for(let e of i){let i=this.getFlowData(e),n=e.name;n&&(r.length>0&&(r+="\n"),r+=`	// flow -> ${n}
120	`),r+=`${i.code}
121	`,e===s&&"compute"!==t&&(r+="// result\n	","vertex"===t?(r+="gl_Position = ",r+=`${i.result};`):"fragment"!==t||e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${i.result};`))}let n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=r}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,i=null){let s=super.getUniformFromNode(e,t,r,i),n=this.getDataFromNode(e,r,this.globalCache),a=n.uniformGPU;if(void 0===a){let i=e.groupNode,o=i.name,l=this.getBindGroupArray(o,r);if("texture"===t)a=new fo(s.name,s.node,i),l.push(a);else if("cubeTexture"===t)a=new fl(s.name,s.node,i),l.push(a);else if("texture3D"===t)a=new fu(s.name,s.node,i),l.push(a);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,s.name=`buffer${e.id}`;let t=new fe(e,i);t.name=e.name,l.push(t),a=t}else{let e=this.uniformGroups[r]||(this.uniformGroups[r]={}),n=e[o];void 0===n&&(n=new fi(r+"_"+o,i),e[o]=n,l.push(n)),a=this.getNodeUniform(s,t),n.addUniform(a)}n.uniformGPU=a}return s}}let fy=null,fb=null;class fx{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}getTimestampUID(e){let t=this.get(e),r=!0===e.isComputeNode?"c":"r";return r+(":"+t.frameCalls+":"+e.id)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp)return void(0,u.mcG)("WebGPURenderer: Timestamp tracking is disabled.");let t=this.timestampQueryPool[e];if(!t)return void(0,u.mcG)(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);let r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async waitForGPU(){}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return fy=fy||new u.I9Y,this.renderer.getDrawingBufferSize(fy)}setScissorTest(){}getClearColor(){let e=this.renderer;return fb=fb||new dF,e.getClearColor(fb),fb.getRGB(fb),fb}getDomElement(){let e=this.domElement;return null===e&&("setAttribute"in(e=void 0!==this.parameters.canvas?this.parameters.canvas:(0,u.lPF)())&&e.setAttribute("data-engine",`three.js r${u.sPf} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let fT=0;class f_{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class fv{constructor(e){this.backend=e}createAttribute(e,t){let r,i=this.backend,{gl:s}=i,n=e.array,a=e.usage||s.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,l=i.get(o),d=l.bufferGPU;if(void 0===d&&(l.bufferGPU=d=this._createBuffer(s,t,n,a),l.bufferType=t,l.version=o.version),n instanceof Float32Array)r=s.FLOAT;else if("undefined"!=typeof Float16Array&&n instanceof Float16Array)r=s.HALF_FLOAT;else if(n instanceof Uint16Array)r=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(n instanceof Int16Array)r=s.SHORT;else if(n instanceof Uint32Array)r=s.UNSIGNED_INT;else if(n instanceof Int32Array)r=s.INT;else if(n instanceof Int8Array)r=s.BYTE;else if(n instanceof Uint8Array)r=s.UNSIGNED_BYTE;else if(n instanceof Uint8ClampedArray)r=s.UNSIGNED_BYTE;else throw Error("THREE.WebGLBackend: Unsupported buffer data format: "+n);let h={bufferGPU:d,bufferType:t,type:r,byteLength:n.byteLength,bytesPerElement:n.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:r===s.INT||r===s.UNSIGNED_INT||e.gpuType===u.Yuy,id:fT++};(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(h=new f_(h,this._createBuffer(s,t,n,a))),i.set(e,h)}updateAttribute(e){let t=this.backend,{gl:r}=t,i=e.array,s=e.isInterleavedBufferAttribute?e.data:e,n=t.get(s),a=n.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(a,n.bufferGPU),0===o.length)r.bufferSubData(a,0,i);else{for(let e=0,t=o.length;e<t;
121e++){let t=o[e];r.bufferSubData(a,t.start*i.BYTES_PER_ELEMENT,i,t.start,t.count)}s.clearUpdateRanges()}r.bindBuffer(a,null),n.version=s.version}destroyAttribute(e){let t=this.backend,{gl:r}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);let i=t.get(e);r.deleteBuffer(i.bufferGPU),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,{gl:r}=t,i=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:s}=t.get(i),n=e.array,a=n.byteLength;r.bindBuffer(r.COPY_READ_BUFFER,s);let o=r.createBuffer();r.bindBuffer(r.COPY_WRITE_BUFFER,o),r.bufferData(r.COPY_WRITE_BUFFER,a,r.STREAM_READ),r.copyBufferSubData(r.COPY_READ_BUFFER,r.COPY_WRITE_BUFFER,0,0,a),await t.utils._clientWaitAsync();let l=new e.array.constructor(n.length);return r.bindBuffer(r.COPY_WRITE_BUFFER,o),r.getBufferSubData(r.COPY_WRITE_BUFFER,0,l),r.deleteBuffer(o),r.bindBuffer(r.COPY_READ_BUFFER,null),r.bindBuffer(r.COPY_WRITE_BUFFER,null),l.buffer}_createBuffer(e,t,r,i){let s=e.createBuffer();return e.bindBuffer(t,s),e.bufferData(t,r,i),e.bindBuffer(t,null),s}}class fN{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){let e=this.gl;o={[u.gO9]:e.FUNC_ADD,[u.FXf]:e.FUNC_SUBTRACT,[u.nST]:e.FUNC_REVERSE_SUBTRACT},l={[u.ojh]:e.ZERO,[u.qad]:e.ONE,[u.f4X]:e.SRC_COLOR,[u.ie2]:e.SRC_ALPHA,[u.hgQ]:e.SRC_ALPHA_SATURATE,[u.wn6]:e.DST_COLOR,[u.hdd]:e.DST_ALPHA,[u.LiQ]:e.ONE_MINUS_SRC_COLOR,[u.OuU]:e.ONE_MINUS_SRC_ALPHA,[u.aEY]:e.ONE_MINUS_DST_COLOR,[u.Nt7]:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=new u.IUQ().fromArray(t),this.currentViewport=new u.IUQ().fromArray(r),this._tempVec4=new u.IUQ}enable(e){let{enabled:t}=this;!0!==t[e]&&(this.gl.enable(e),t[e]=!0)}disable(e){let{enabled:t}=this;!1!==t[e]&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){let{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){let{gl:t}=this;e!==u.WNZ?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===u.Vb5?t.cullFace(t.BACK):e===u.Jnc?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){let{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setBlending(e,t,r,i,s,n,a,d){let{gl:h}=this;if(e===u.XIg){!0===this.currentBlendingEnabled&&(this.disable(h.BLEND),this.currentBlendingEnabled=!1);return}if(!1===this.currentBlendingEnabled&&(this.enable(h.BLEND),this.currentBlendingEnabled=!0),e!==u.bCz){if(e!==this.currentBlending||d!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==u.gO9||this.currentBlendEquationAlpha!==u.gO9)&&(h.blendEquation(h.FUNC_ADD),this.currentBlendEquation=u.gO9,this.currentBlendEquationAlpha=u.gO9),d)switch(e){case u.NTi:h.blendFuncSeparate(h.ONE,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA);break;case u.EZo:h.blendFunc(h.ONE,h.ONE);break;case u.Kwu:h.blendFuncSeparate(h.ZERO,h.ONE_MINUS_SRC_COLOR,h.ZERO,h.ONE);break;case u.EdD:h.blendFuncSeparate(h.DST_COLOR,h.ONE_MINUS_SRC_ALPHA,h.ZERO,h.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case u.NTi:h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA);break;case u.EZo:h.blendFuncSeparate(h.SRC_ALPHA,h.ONE,h.ONE,h.ONE);break;case u.Kwu:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case u.EdD:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=d}return}s=s||t,n=n||r,a=a||i,(t!==this.currentBlendEquation||s!==this.currentBlendEquationAlpha)&&(h.blendEquationSeparate(o[t],o[s]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=s),(r!==this.currentBlendSrc||i!==this.currentBlendDst||n!==this.currentBlendSrcAlpha||a!==this.currentBlendDstAlpha)&&(h.blendFuncSeparate(l[r],l[i],l[n],l[a]),this.currentBlendSrc=r,this.currentBlendDst=i,this.currentBlendSrcAlpha=n,this.currentBlendDstAlpha=a),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){let{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthFunc!==e){let{gl:t}=this;switch(e){case u.eHc:t.depthFunc(t.NEVER);break;case u.lGu:t.depthFunc(t.ALWAYS);break;case u.brA:t.depthFunc(t.LESS);break;case u.xSv:t.depthFunc(t.LEQUAL);break;case u.U3G:t.depthFunc(t.EQUAL);break;case u.Gwm:t.depthFunc(t.GEQUAL);break;case u.K52:t.depthFunc(t.GREATER);break;case u.bw0:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}
121scissor(e,t,r,i){let s=this._tempVec4.set(e,t,r,i);if(!1===this.currentScissor.equals(s)){let{gl:e}=this;e.scissor(s.x,s.y,s.z,s.w),this.currentScissor.copy(s)}}viewport(e,t,r,i){let s=this._tempVec4.set(e,t,r,i);if(!1===this.currentViewport.equals(s)){let{gl:e}=this;e.viewport(s.x,s.y,s.z,s.w),this.currentViewport.copy(s)}}setScissorTest(e){let t=this.gl;e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST)}setStencilTest(e){let{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,r){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==r)&&(this.gl.stencilFunc(e,t,r),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=r)}setStencilOp(e,t,r){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==r)&&(this.gl.stencilOp(e,t,r),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=r)}setMaterial(e,t,r){let{gl:i}=this;e.side===u.$EB?this.disable(i.CULL_FACE):this.enable(i.CULL_FACE);let s=e.side===u.hsX;t&&(s=!s),this.setFlipSided(s),e.blending===u.NTi&&!1===e.transparent?this.setBlending(u.XIg):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);let n=e.stencilWrite;if(this.setStencilTest(n),n&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage&&this.backend.renderer.samples>1?this.enable(i.SAMPLE_ALPHA_TO_COVERAGE):this.disable(i.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r)for(let e=0;e<8;e++)e<r?this.enable(12288+e):this.disable(12288+e)}setPolygonOffset(e,t,r){let{gl:i}=this;e?(this.enable(i.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==r)&&(i.polygonOffset(t,r),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=r)):this.disable(i.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e&&(this.gl.useProgram(e),this.currentProgram=e,!0)}setVertexState(e,t=null){let r=this.gl;return(this.currentVAO!==e||this.currentIndex!==t)&&(r.bindVertexArray(e),null!==t&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0)}resetVertexState(){let e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){let{gl:r,currentBoundFramebuffers:i}=this;return i[e]!==t&&(r.bindFramebuffer(e,t),i[e]=t,e===r.DRAW_FRAMEBUFFER&&(i[r.FRAMEBUFFER]=t),e===r.FRAMEBUFFER&&(i[r.DRAW_FRAMEBUFFER]=t),!0)}drawBuffers(e,t){let{gl:r}=this,i=[],s=!1;if(null!==e.textures){void 0===(i=this.currentDrawbuffers.get(t))&&(i=[],this.currentDrawbuffers.set(t,i));let n=e.textures;if(i.length!==n.length||i[0]!==r.COLOR_ATTACHMENT0){for(let e=0,t=n.length;e<t;e++)i[e]=r.COLOR_ATTACHMENT0+e;i.length=n.length,s=!0}}else i[0]!==r.BACK&&(i[0]=r.BACK,s=!0);s&&r.drawBuffers(i)}activeTexture(e){let{gl:t,currentTextureSlot:r,maxTextures:i}=this;void 0===e&&(e=t.TEXTURE0+i-1),r!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,r){let{gl:i,currentTextureSlot:s,currentBoundTextures:n,maxTextures:a}=this;void 0===r&&(r=null===s?i.TEXTURE0+a-1:s);let o=n[r];void 0===o&&(o={type:void 0,texture:void 0},n[r]=o),(o.type!==e||o.texture!==t)&&(s!==r&&(i.activeTexture(r),this.currentTextureSlot=r),i.bindTexture(e,t),o.type=e,o.texture=t)}bindBufferBase(e,t,r){let{gl:i}=this,s=`${e}-${t}`;return this.currentBoundBufferBases[s]!==r&&(i.bindBufferBase(e,t,r),this.currentBoundBufferBases[s]=r,!0)}unbindTexture(){let{gl:e,currentTextureSlot:t,currentBoundTextures:r}=this,i=r[t];void 0!==i&&void 0!==i.type&&(e.bindTexture(i.type,null),i.type=void 0,i.texture=void 0)}}class fS{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=u.jf0){let r,{gl:i,extensions:s}=this,n=u.ppV.getTransfer(t);if(e===u.OUM)return i.UNSIGNED_BYTE;if(e===u.Wew)return i.UNSIGNED_SHORT_4_4_4_4;if(e===u.gJ2)return i.UNSIGNED_SHORT_5_5_5_1;if(e===u.Dmk)return i.UNSIGNED_INT_5_9_9_9_REV;if(e===u.yT7)return i.UNSIGNED_INT_10F_11F_11F_REV;if(e===u.tJf)return i.BYTE;if(e===u.fBL)return i.SHORT;if(e===u.cHt)return i.UNSIGNED_SHORT;if(e===u.Yuy)return i.INT;if(e===u.bkx)return i.UNSIGNED_INT;if(e===u.RQf)return i.FLOAT;if(e===u.ix0)return i.HALF_FLOAT;if(e===u.wrO)return i.ALPHA;if(e===u.HIg)return i.RGB;if(e===u.GWd)return i.RGBA;if(e===u.zdS)return i.DEPTH_COMPONENT;if(e===u.dcC)return i.DEPTH_STENCIL;if(e===u.VT0)return i.RED;if(e===u.ZQM)return i.RED_INTEGER;if(e===u.paN)return i.RG;if(e===u.TkQ)return i.RG_INTEGER;if(e===u.c90)return i.RGBA_INTEGER;if(e===u.IE4||e===u.Nz6||e===u.jR7||e===u.BXX)if(n===u.KLL){if(null===(r=s.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(e===u.IE4)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===u.Nz6)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===u.jR7)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===u.BXX)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(r=s.get("WEBGL_compressed_texture_s3tc")))return null;if(e===u.IE4)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===u.Nz6)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===u.jR7)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===u.BXX)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===u.k6Q||e===u.kTp||e===u.HXV||e===u.pBf){if(null===(r=s.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===u.k6Q)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===u.kTp)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===u.HXV)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===u.pBf)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===u.CVz||e===u.Riy||e===u.KDk){if(null===(r=s.get("WEBGL_compressed_texture_etc")))return null;if(e===u.CVz||e===u.Riy)return n===u.KLL?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(e===u.KDk)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(e===u.qa3||e===u.B_h||e===u.czI||e===u.rSH||e===u.Qrf||e===u.psI||e===u.a5J||e===u._QJ||e===u.uB5||e===u.lyL||e===u.bC7||e===u.y3Z||e===u.ojs||e===u.S$4){if(null===(r=s.get("WEBGL_compressed_texture_astc")))return null;if(e===u.qa3)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===u.B_h)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===u.czI)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===u.rSH)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===u.Qrf)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===u.psI)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===u.a5J)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===u._QJ)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===u.uB5)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===u.lyL)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===u.bC7)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===u.y3Z)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===u.ojs)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===u.S$4)return n===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(e===u.Fn){if(null===(r=s.get("EXT_texture_compression_bptc")))return null;if(e===u.Fn)return n===u.KLL?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(e===u.Kef||e===u.XG_||e===u.HO_||e===u.CWW){if(null===(r=s.get("EXT_texture_compression_rgtc")))return null;
121if(e===u.Kef)return r.COMPRESSED_RED_RGTC1_EXT;if(e===u.XG_)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===u.HO_)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===u.CWW)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return e===u.V3x?i.UNSIGNED_INT_24_8:void 0!==i[e]?i[e]:null}_clientWaitAsync(){let{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((r,i)=>{!function s(){let n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED){e.deleteSync(t),i();return}if(n===e.TIMEOUT_EXPIRED)return void requestAnimationFrame(s);e.deleteSync(t),r()}()})}}let fR=!1,fA,fE,fC;class fw{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===fR&&(this._init(),fR=!0)}_init(){let e=this.gl;fA={[u.GJx]:e.REPEAT,[u.ghU]:e.CLAMP_TO_EDGE,[u.kTW]:e.MIRRORED_REPEAT},fE={[u.hxR]:e.NEAREST,[u.pHI]:e.NEAREST_MIPMAP_NEAREST,[u.Cfg]:e.NEAREST_MIPMAP_LINEAR,[u.k6q]:e.LINEAR,[u.kRr]:e.LINEAR_MIPMAP_NEAREST,[u.$_I]:e.LINEAR_MIPMAP_LINEAR},fC={[u.amv]:e.NEVER,[u.FFZ]:e.ALWAYS,[u.vim]:e.LESS,[u.TiK]:e.LEQUAL,[u.kO0]:e.EQUAL,[u.gWB]:e.GEQUAL,[u.eoi]:e.GREATER,[u.jzd]:e.NOTEQUAL}}getGLTextureType(e){let{gl:t}=this;return!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isArrayTexture||!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D}getInternalFormat(e,t,r,i,s=!1){let{gl:n,extensions:a}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let o=t;if(t===n.RED&&(r===n.FLOAT&&(o=n.R32F),r===n.HALF_FLOAT&&(o=n.R16F),r===n.UNSIGNED_BYTE&&(o=n.R8),r===n.UNSIGNED_SHORT&&(o=n.R16),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.R8UI),r===n.UNSIGNED_SHORT&&(o=n.R16UI),r===n.UNSIGNED_INT&&(o=n.R32UI),r===n.BYTE&&(o=n.R8I),r===n.SHORT&&(o=n.R16I),r===n.INT&&(o=n.R32I)),t===n.RG&&(r===n.FLOAT&&(o=n.RG32F),r===n.HALF_FLOAT&&(o=n.RG16F),r===n.UNSIGNED_BYTE&&(o=n.RG8),r===n.UNSIGNED_SHORT&&(o=n.RG16),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RG8UI),r===n.UNSIGNED_SHORT&&(o=n.RG16UI),r===n.UNSIGNED_INT&&(o=n.RG32UI),r===n.BYTE&&(o=n.RG8I),r===n.SHORT&&(o=n.RG16I),r===n.INT&&(o=n.RG32I)),t===n.RGB){let e=s?u.VxR:u.ppV.getTransfer(i);r===n.FLOAT&&(o=n.RGB32F),r===n.HALF_FLOAT&&(o=n.RGB16F),r===n.UNSIGNED_BYTE&&(o=n.RGB8),r===n.UNSIGNED_SHORT&&(o=n.RGB16),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I),r===n.UNSIGNED_BYTE&&(o=e===u.KLL?n.SRGB8:n.RGB8),r===n.UNSIGNED_SHORT_5_6_5&&(o=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(o=n.RGB9_E5),r===n.UNSIGNED_INT_10F_11F_11F_REV&&(o=n.R11F_G11F_B10F)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGB8UI),r===n.UNSIGNED_SHORT&&(o=n.RGB16UI),r===n.UNSIGNED_INT&&(o=n.RGB32UI),r===n.BYTE&&(o=n.RGB8I),r===n.SHORT&&(o=n.RGB16I),r===n.INT&&(o=n.RGB32I)),t===n.RGBA){let e=s?u.VxR:u.ppV.getTransfer(i);r===n.FLOAT&&(o=n.RGBA32F),r===n.HALF_FLOAT&&(o=n.RGBA16F),r===n.UNSIGNED_BYTE&&(o=n.RGBA8),r===n.UNSIGNED_SHORT&&(o=n.RGBA16),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I),r===n.UNSIGNED_BYTE&&(o=e===u.KLL?n.SRGB8_ALPHA8:n.RGBA8),r===n.UNSIGNED_SHORT_4_4_4_4&&(o=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(o=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(o=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(o=n.RGBA16UI),r===n.UNSIGNED_INT&&(o=n.RGBA32UI),r===n.BYTE&&(o=n.RGBA8I),r===n.SHORT&&(o=n.RGBA16I),r===n.INT&&(o=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(o=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(o=n.DEPTH_COMPONENT24),r===n.FLOAT&&(o=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(o=n.DEPTH24_STENCIL8),(o===n.R16F||o===n.R32F||o===n.RG16F||o===n.RG32F||o===n.RGBA16F||o===n.RGBA32F)&&a.get("EXT_color_buffer_float"),o}setTextureParameters(e,t){let{gl:r,extensions:i,backend:s}=this,n=u.ppV.getPrimaries(u.ppV.workingColorSpace),a=t.colorSpace
121===u.jf0?null:u.ppV.getPrimaries(t.colorSpace),o=t.colorSpace===u.jf0||n===a?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,o),r.texParameteri(e,r.TEXTURE_WRAP_S,fA[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,fA[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,fA[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,fE[t.magFilter]);let l=void 0!==t.mipmaps&&t.mipmaps.length>0,d=t.minFilter===u.k6q&&l?u.$_I:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,fE[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,fC[t.compareFunction])),!0===i.has("EXT_texture_filter_anisotropic")){if(t.magFilter===u.hxR||t.minFilter!==u.Cfg&&t.minFilter!==u.$_I||t.type===u.RQf&&!1===i.has("OES_texture_float_linear"))return;if(t.anisotropy>1){let n=i.get("EXT_texture_filter_anisotropic");r.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:r,defaultTextures:i}=this,s=this.getGLTextureType(e),n=i[s];void 0===n&&(n=t.createTexture(),r.state.bindTexture(s,n),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),i[s]=n),r.set(e,{textureGPU:n,glTextureType:s,isDefault:!0})}createTexture(e,t){let{gl:r,backend:i}=this,{levels:s,width:n,height:a,depth:o}=t,l=i.utils.convert(e.format,e.colorSpace),u=i.utils.convert(e.type),d=this.getInternalFormat(e.internalFormat,l,u,e.colorSpace,e.isVideoTexture),h=r.createTexture(),c=this.getGLTextureType(e);i.state.bindTexture(c,h),this.setTextureParameters(c,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,s,d,n,a,o):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,s,d,n,a,o):e.isVideoTexture||r.texStorage2D(c,s,d,n,a),i.set(e,{textureGPU:h,glTextureType:c,glFormat:l,glType:u,glInternalFormat:d})}copyBufferToTexture(e,t){let{gl:r,backend:i}=this,{textureGPU:s,glTextureType:n,glFormat:a,glType:o}=i.get(t),{width:l,height:u}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),i.state.bindTexture(n,s),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,l,u,a,o,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),i.state.unbindTexture()}updateTexture(e,t){let{gl:r}=this,{width:i,height:s}=t,{textureGPU:n,glTextureType:a,glFormat:o,glType:l,glInternalFormat:d}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==n)if(this.backend.state.bindTexture(a,n),this.setTextureParameters(a,e),e.isCompressedTexture){let i=e.mipmaps,s=t.image;for(let t=0;t<i.length;t++){let n=i[t];e.isCompressedArrayTexture?e.format!==r.RGBA?null!==o?r.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,t,0,0,0,n.width,n.height,s.depth,o,n.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texSubImage3D(r.TEXTURE_2D_ARRAY,t,0,0,0,n.width,n.height,s.depth,o,l,n.data):null!==o?r.compressedTexSubImage2D(r.TEXTURE_2D,t,0,0,n.width,n.height,o,n.data):console.warn("Unsupported compressed texture format")}}else if(e.isCubeTexture){let n=t.images,a=e.mipmaps;for(let e=0;e<6;e++){let t=fM(n[e]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,i,s,o,l,t);for(let t=0;t<a.length;t++){let i=fM(a[t].images[e]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,t+1,0,0,i.width,i.height,o,l,i)}}}else if(e.isDataArrayTexture||e.isArrayTexture){let i=t.image;if(e.layerUpdates.size>0){let t=(0,u.Nex)(i.width,i.height,e.format,e.type);for(let s of e.layerUpdates){let e=i.data.subarray(s*t/i.data.BYTES_PER_ELEMENT,(s+1)*t/i.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,s,i.width,i.height,1,o,l,e)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,i.width,i.height,i.depth,o,l,i.data)}else if(e.isData3DTexture){let e=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,o,l,e.data)}
vendor: 4,812 bytes, line 121
121else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,d,o,l,t.image);else{let n=e.mipmaps;if(n.length>0)for(let e=0,t=n.length;e<t;e++){let t=n[e],i=fM(t);r.texSubImage2D(a,e,0,0,t.width,t.height,o,l,i)}else{let e=fM(t.image);r.texSubImage2D(a,0,0,0,i,s,o,l,e)}}}generateMipmaps(e){let{gl:t,backend:r}=this,{textureGPU:i,glTextureType:s}=r.get(e);r.state.bindTexture(s,i),t.generateMipmap(s)}deallocateRenderBuffers(e){let{gl:t,backend:r}=this;if(e){let i=r.get(e);if(i.renderBufferStorageSetup=void 0,i.framebuffers){for(let e in i.framebuffers)t.deleteFramebuffer(i.framebuffers[e]);delete i.framebuffers}if(i.depthRenderbuffer&&(t.deleteRenderbuffer(i.depthRenderbuffer),delete i.depthRenderbuffer),i.stencilRenderbuffer&&(t.deleteRenderbuffer(i.stencilRenderbuffer),delete i.stencilRenderbuffer),i.msaaFrameBuffer&&(t.deleteFramebuffer(i.msaaFrameBuffer),delete i.msaaFrameBuffer),i.msaaRenderbuffers){for(let e=0;e<i.msaaRenderbuffers.length;e++)t.deleteRenderbuffer(i.msaaRenderbuffers[e]);delete i.msaaRenderbuffers}}}destroyTexture(e){let{gl:t,backend:r}=this,{textureGPU:i,renderTarget:s}=r.get(e);this.deallocateRenderBuffers(s),t.deleteTexture(i),r.delete(e)}copyTextureToTexture(e,t,r=null,i=null,s=0,n=0){let a,o,l,u,d,h,c,p,g,{gl:m,backend:f}=this,{state:y}=this.backend,{textureGPU:b,glTextureType:x,glType:T,glFormat:_}=f.get(t);y.bindTexture(x,b);let v=e.isCompressedTexture?e.mipmaps[n]:e.image;if(null!==r)a=r.max.x-r.min.x,o=r.max.y-r.min.y,l=r.isBox3?r.max.z-r.min.z:1,u=r.min.x,d=r.min.y,h=r.isBox3?r.min.z:0;else{let t=Math.pow(2,-s);a=Math.floor(v.width*t),o=Math.floor(v.height*t),l=e.isDataArrayTexture||e.isArrayTexture?v.depth:e.isData3DTexture?Math.floor(v.depth*t):1,u=0,d=0,h=0}null!==i?(c=i.x,p=i.y,g=i.z):(c=0,p=0,g=0),m.pixelStorei(m.UNPACK_FLIP_Y_WEBGL,t.flipY),m.pixelStorei(m.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),m.pixelStorei(m.UNPACK_ALIGNMENT,t.unpackAlignment);let N=m.getParameter(m.UNPACK_ROW_LENGTH),S=m.getParameter(m.UNPACK_IMAGE_HEIGHT),R=m.getParameter(m.UNPACK_SKIP_PIXELS),A=m.getParameter(m.UNPACK_SKIP_ROWS),E=m.getParameter(m.UNPACK_SKIP_IMAGES);m.pixelStorei(m.UNPACK_ROW_LENGTH,v.width),m.pixelStorei(m.UNPACK_IMAGE_HEIGHT,v.height),m.pixelStorei(m.UNPACK_SKIP_PIXELS,u),m.pixelStorei(m.UNPACK_SKIP_ROWS,d),m.pixelStorei(m.UNPACK_SKIP_IMAGES,h);let C=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isRenderTargetTexture||e.isDepthTexture){let r=f.get(e),i=f.get(t),s=f.get(r.renderTarget),n=f.get(i.renderTarget),l=s.framebuffers[r.cacheKey],h=n.framebuffers[i.cacheKey];y.bindFramebuffer(m.READ_FRAMEBUFFER,l),y.bindFramebuffer(m.DRAW_FRAMEBUFFER,h);let g=m.COLOR_BUFFER_BIT;e.isDepthTexture&&(g=m.DEPTH_BUFFER_BIT),m.blitFramebuffer(u,d,a,o,c,p,a,o,g,m.NEAREST),y.bindFramebuffer(m.READ_FRAMEBUFFER,null),y.bindFramebuffer(m.DRAW_FRAMEBUFFER,null)}else C?e.isDataTexture||e.isData3DTexture?m.texSubImage3D(x,n,c,p,g,a,o,l,_,T,v.data):t.isCompressedArrayTexture?m.compressedTexSubImage3D(x,n,c,p,g,a,o,l,_,v.data):m.texSubImage3D(x,n,c,p,g,a,o,l,_,T,v):e.isDataTexture?m.texSubImage2D(x,n,c,p,a,o,_,T,v.data):e.isCompressedTexture?m.compressedTexSubImage2D(x,n,c,p,v.width,v.height,_,v.data):m.texSubImage2D(x,n,c,p,a,o,_,T,v);m.pixelStorei(m.UNPACK_ROW_LENGTH,N),m.pixelStorei(m.UNPACK_IMAGE_HEIGHT,S),m.pixelStorei(m.UNPACK_SKIP_PIXELS,R),m.pixelStorei(m.UNPACK_SKIP_ROWS,A),m.pixelStorei(m.UNPACK_SKIP_IMAGES,E),0===n&&t.generateMipmaps&&m.generateMipmap(x),y.unbindTexture()}copyFramebufferToTexture(e,t,r){let{gl:i}=this,{state:s}=this.backend,{textureGPU:n}=this.backend.get(e),{x:a,y:o,z:l,w:u}=r,d=!0===e.isDepthTexture||t.renderTarget&&t.renderTarget.samples>0,h=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){let r,d,c=0!==a||0!==o;if(!0===e.isDepthTexture?(r=i.DEPTH_BUFFER_BIT,d=i.DEPTH_ATTACHMENT,t.stencil&&(r|=i.STENCIL_BUFFER_BIT)):(r=i.COLOR_BUFFER_BIT,d=i.COLOR_ATTACHMENT0),c){let e=this.backend.get(t.renderTarget),d=e.framebuffers[t.getCacheKey()],c=e.msaaFrameBuffer;s.bindFramebuffer(i.DRAW_FRAMEBUFFER,d),s.bindFramebuffer(i.READ_FRAMEBUFFER,c);let p=h-o-u;i.blitFramebuffer(a,p,a+l,p+u,a,p,a+l,p+u,r,i.NEAREST),s.bindFramebuffer(i.READ_FRAMEBUFFER,d),s.bindTexture(i.TEXTURE_2D,n),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,a,p,l,u),s.unbindTexture()}else{let e=i.createFramebuffer();s.bindFramebuffer(i.DRAW_FRAMEBUFFER,e),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,d,i.TEXTURE_2D,n,0),i.blitFramebuffer(0,0,l,u,0,0,l,u,r,i.NEAREST),i.deleteFramebuffer(e)}}else s.bindTexture(i.TEXTURE_2D,n),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,a,h-u-o,l,u),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,i=!1){let{gl:s}=this,n=t.renderTarget,{depthTexture:a,depthBuffer:o,stencilBuffer:l,width:u,height:d}=n;
vendor: 1,583 bytes, line 121
121if(s.bindRenderbuffer(s.RENDERBUFFER,e),o&&!l){let t=s.DEPTH_COMPONENT24;!0===i?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(s.RENDERBUFFER,n.samples,t,u,d):r>0?(a&&a.isDepthTexture&&a.type===s.FLOAT&&(t=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,r,t,u,d)):s.renderbufferStorage(s.RENDERBUFFER,t,u,d),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else o&&l&&(r>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,r,s.DEPTH24_STENCIL8,u,d):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,u,d),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e));s.bindRenderbuffer(s.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,i,s,n){let{backend:a,gl:o}=this,{textureGPU:l,glFormat:u,glType:d}=this.backend.get(e),h=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,h);let c=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+n:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,l,0);let p=this._getTypedArrayType(d),g=i*s*this._getBytesPerTexel(d,u),m=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.bufferData(o.PIXEL_PACK_BUFFER,g,o.STREAM_READ),o.readPixels(t,r,i,s,u,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await a.utils._clientWaitAsync();let f=new p(g/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,m),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(h),f}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;
121if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){let{gl:r}=this,i=0;return(e===r.UNSIGNED_BYTE&&(i=1),(e===r.UNSIGNED_SHORT_4_4_4_4||e===r.UNSIGNED_SHORT_5_5_5_1||e===r.UNSIGNED_SHORT_5_6_5||e===r.UNSIGNED_SHORT||e===r.HALF_FLOAT)&&(i=2),(e===r.UNSIGNED_INT||e===r.FLOAT)&&(i=4),t===r.RGBA)?4*i:t===r.RGB?3*i:t===r.ALPHA?i:void 0}}function fM(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class fB{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class fL{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;let e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){let r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}let fP={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class fF{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){let{gl:r,mode:i,object:s,type:n,info:a,index:o}=this;0!==o?r.drawElements(i,t,n,e):r.drawArrays(i,e,t),a.update(s,t,1)}renderInstances(e,t,r){let{gl:i,mode:s,type:n,index:a,object:o,info:l}=this;0!==r&&(0!==a?i.drawElementsInstanced(s,t,n,e,r):i.drawArraysInstanced(s,e,t,r),l.update(o,t,r))}renderMultiDraw(e,t,r){let{extensions:i,mode:s,object:n,info:a}=this;if(0===r)return;let o=i.get("WEBGL_multi_draw");if(null===o)for(let i=0;i<r;i++)this.render(e[i],t[i]);else{0!==this.index?o.multiDrawElementsWEBGL(s,t,0,this.type,e,0,r):o.multiDrawArraysWEBGL(s,e,0,t,0,r);let i=0;for(let e=0;e<r;e++)i+=t[e];a.update(n,i,1)}}renderMultiDrawInstances(e,t,r,i){let{extensions:s,mode:n,object:a,info:o}=this;if(0===r)return;let l=s.get("WEBGL_multi_draw");if(null===l)for(let s=0;s<r;s++)this.renderInstances(e[s],t[s],i[s]);else{0!==this.index?l.multiDrawElementsInstancedWEBGL(n,t,0,this.type,e,0,i,0,r):l.multiDrawArraysInstancedWE
121BGL(n,e,0,t,0,i,0,r);let s=0;for(let e=0;e<r;e++)s+=t[e]*i[e];o.update(a,s,1)}}}class fU{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.pendingResolve=!1}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}}class fI extends fU{constructor(e,t,r=2048){if(super(r),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){console.warn("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let t=0;t<this.maxQueries;t++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return(0,u.mcG)(`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.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(null==t||null!==this.activeQuery)return;let r=this.queries[t];if(r)try{"inactive"===this.queryStates.get(t)&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(e){console.error("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){console.error("Error in endQuery:",e),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{let e=[];for(let[t,r]of this.queryStates)if("ended"===r){let r=this.queries[t];e.push(this.resolveQuery(r))}if(0===e.length)return this.lastValue;let t=(await Promise.all(e)).reduce((e,t)=>e+t,0);return this.lastValue=t,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,t}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{let r;if(this.isDisposed)return void t(this.lastValue);let i=!1,s=e=>{i||(i=!0,r&&(clearTimeout(r),r=null),t(e))},n=()=>
121{if(this.isDisposed)return void s(this.lastValue);try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT))return void s(this.lastValue);if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){r=setTimeout(n,1);return}let i=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(i)/1e6)}catch(e){console.error("Error checking query:",e),t(this.lastValue)}};n()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,this.trackTimestamp)){for(let e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class fD extends fx{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,r={antialias:e.samples>0,alpha:!0,depth:e.depth,stencil:e.stencil},i=void 0!==t.context?t.context:e.domElement.getContext("webgl2",r);function s(t){t.preventDefault();let r={api:"WebGL",message:t.statusMessage||"Unknown reason",reason:null,originalEvent:t};e.onDeviceLost(r)}this._onContextLost=s,e.domElement.addEventListener("webglcontextlost",s,!1),this.gl=i,this.extensions=new fB(this),this.capabilities=new fL(this),this.attributeUtils=new fv(this),this.textureUtils=new fw(this),this.bufferRenderer=new fF(this),this.state=new fN(this),this.utils=new fS(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return u.TdN}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}async waitForGPU(){await this.utils._clientWaitAsync()}async makeXRCompatible(){!0!==this.gl.getContextAttributes().xrCompatible&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){let i=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:i.RGBA8}),null!==r){let t=e.stencilBuffer?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:t}),!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!0===e._autoAllocateDepthBuffer&&!1===e.multiview&&console.warn("THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new fI(this.gl,e,2048));let r=this.timestampQueryPool[e];null!==r.allocateQueriesForContext(t)&&r.beginQuery(t)}prepareTimestampBuffer(e,t){this.disjoint&&this.trackTimestamp&&this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,r=this.get(e);if(r.frameCalls=this.renderer.info.render.frameCalls,e.viewport)this.updateViewport(e);else{let{width:e,height:r}=this.getDrawingBufferSize();t.viewport(0,0,e,r)}if(e.scissor){let{x:r,y:i,width:s,height:n}=e.scissorValue;t.scissor(r,e.height-n-i,s,n)}this.initTimestampQuery(u.v9J.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let i=e.occlusionQueryCount;i>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=Array(i),r.occlusionQueryObjects=Array(i),r.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:r}=this,i=this.get(e),s=i.previousContext;r.resetVertexState();let n=e.occlusionQueryCount;n>0&&(n>i.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let a=e.textures;if(null!==a)for(let e=0;e<a.length;e++){let t=a[e];t.generateMipmaps&&this.generateMipmaps(t)}if(this._currentContext=s,this._resolveRenderTarget(e),null!==s)if(this._setFramebuffer(s),s.viewport)this.updateViewport(s);else{let{width:e,height:t}=this.getDrawingBufferSize();r.viewport(0,0,e,t)}this.prepareTimestampBuffer(u.v9J.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueries:r,currentOcclusionQueryObjects:i}=t;if(r&&i){let e=new WeakSet,{gl:s}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;let n=()=>{let a=0;for(let t=0;t<r.length;t++){let n=r[t];null!==n&&s.getQueryParameter(n,s.QUERY_RESULT_AVAILABLE)&&(0===s.getQueryParameter(n,s.QUERY_RESULT)&&e.add(i[t]),r[t]=null,s.deleteQuery(n),a++)}a<r.length?requestAnimationFrame(n):t.occluded=e};n()}}isOccluded(e,t){let r=this.get(e);return r.occluded&&r.occluded.has(t)}updateViewport(e){let{state:t}=this,{x:r,y:i,width:s,height:n}=e.viewportValue;t.viewport(r,e.height-n-i,s,n)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){let e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}
121clear(e,t,r,i=null,s=!0,n=!0){let{gl:a,renderer:o}=this;null===i&&(i={textures:null,clearColorValue:this.getClearColor()});let l=0;if(e&&(l|=a.COLOR_BUFFER_BIT),t&&(l|=a.DEPTH_BUFFER_BIT),r&&(l|=a.STENCIL_BUFFER_BIT),0!==l){let u;u=i.clearColorValue?i.clearColorValue:this.getClearColor();let d=o.getClearDepth(),h=o.getClearStencil();if(t&&this.state.setDepthMask(!0),null===i.textures)a.clearColor(u.r,u.g,u.b,u.a),a.clear(l);else{if(s&&this._setFramebuffer(i),e)for(let e=0;e<i.textures.length;e++)0===e?a.clearBufferfv(a.COLOR,e,[u.r,u.g,u.b,u.a]):a.clearBufferfv(a.COLOR,e,[0,0,0,1]);t&&r?a.clearBufferfi(a.DEPTH_STENCIL,0,d,h):t?a.clearBufferfv(a.DEPTH,0,[d]):r&&a.clearBufferiv(a.STENCIL,0,[h]),s&&n&&this._resolveRenderTarget(i)}}}beginCompute(e){let{state:t,gl:r}=this;this.get(e).frameCalls=this.renderer.info.compute.frameCalls,t.bindFramebuffer(r.FRAMEBUFFER,null),this.initTimestampQuery(u.v9J.COMPUTE,this.getTimestampUID(e))}compute(e,t,r,i,s=null){let{state:n,gl:a}=this;!1===this.discard&&(a.enable(a.RASTERIZER_DISCARD),this.discard=!0);let{programGPU:o,transformBuffers:l,attributes:d}=this.get(i),h=this._getVaoKey(d),c=this.vaoCache[h];void 0===c?this.vaoCache[h]=this._createVao(d):n.setVertexState(c),n.useProgram(o),this._bindUniforms(r);let p=this._getTransformFeedback(l);a.bindTransformFeedback(a.TRANSFORM_FEEDBACK,p),a.beginTransformFeedback(a.POINTS),Array.isArray(s=null!==s?s:t.count)&&((0,u.mcG)("WebGLBackend.compute(): The count parameter must be a single number, not an array."),s=s[0]),d[0].isStorageInstancedBufferAttribute?a.drawArraysInstanced(a.POINTS,0,1,s):a.drawArrays(a.POINTS,0,s),a.endTransformFeedback(),a.bindTransformFeedback(a.TRANSFORM_FEEDBACK,null);for(let e=0;e<l.length;e++){let t=l[e];t.pbo&&this.has(t.pbo)&&this.textureUtils.copyBufferToTexture(t.transformBuffer,t.pbo),t.switchBuffers()}}finishCompute(e){let t=this.gl;this.discard=!1,t.disable(t.RASTERIZER_DISCARD),this.prepareTimestampBuffer(u.v9J.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){let{object:t,pipeline:r,material:i,context:s,hardwareClippingPlanes:n}=e,{programGPU:a}=this.get(r),{gl:o,state:l}=this,d=this.get(s),h=e.getDrawParameters();if(null===h)return;this._bindUniforms(e.getBindings());let c=t.isMesh&&0>t.matrixWorld.determinant();l.setMaterial(i,c,n),l.useProgram(a);let p=e.getAttributes(),g=this.get(p),m=g.vaoGPU;if(void 0===m){let e=this._getVaoKey(p);void 0===(m=this.vaoCache[e])&&(m=this._createVao(p),this.vaoCache[e]=m,g.vaoGPU=m)}let f=e.getIndex(),y=null!==f?this.get(f).bufferGPU:null;l.setVertexState(m,y);let b=d.lastOcclusionObject;if(b!==t&&void 0!==b){if(null!==b&&!0===b.occlusionTest&&(o.endQuery(o.ANY_SAMPLES_PASSED),d.occlusionQueryIndex++),!0===t.occlusionTest){let e=o.createQuery();o.beginQuery(o.ANY_SAMPLES_PASSED,e),d.occlusionQueries[d.occlusionQueryIndex]=e,d.occlusionQueryObjects[d.occlusionQueryIndex]=t}d.lastOcclusionObject=t}let x=this.bufferRenderer;t.isPoints?x.mode=o.POINTS:t.isLineSegments?x.mode=o.LINES:t.isLine?x.mode=o.LINE_STRIP:t.isLineLoop?x.mode=o.LINE_LOOP:!0===i.wireframe?(l.setLineWidth(i.wireframeLinewidth*this.renderer.getPixelRatio()),x.mode=o.LINES):x.mode=o.TRIANGLES;let{vertexCount:T,instanceCount:_}=h,{firstVertex:v}=h;if(x.object=t,null!==f){v*=f.array.BYTES_PER_ELEMENT;let e=this.get(f);x.index=f.count,x.type=e.type}else x.index=0;let N=()=>{t.isBatchedMesh?null!==t._multiDrawInstances?((0,u.mcG)("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),x.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?x.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):(0,u.mcG)("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):_>1?x.renderInstances(v,T,_):x.render(v,T)};if(!0===e.camera.isArrayCamera&&e.camera.cameras.length>0&&!1===e.camera.isMultiViewCamera){let r=this.get(e.camera),i=e.camera.cameras,s=e.getBindingGroup("cameraIndex").bindings[0];if(void 0===r.indexesGPU||r.indexesGPU.length!==i.length){let e=new Uint32Array([0,0,0,0]),t=[];for(let r=0,s=i.length;r<s;r++){let i=o.createBuffer();e[0]=r,o.bindBuffer(o.UNIFORM_BUFFER,i),o.bufferData(o.UNIFORM_BUFFER,e,o.STATIC_DRAW),t.push(i)}r.indexesGPU=t}let n=this.get(s),a=this.renderer.getPixelRatio(),u=this._currentContext.renderTarget,d=this._isRenderCameraDepthArray(this._currentContext),h=this._currentContext.activeCubeFace;if(d){let e=this.get(u.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:t}=u;for(let e=0,r=i.length;e<r;e++)this.renderer._activeCubeFace=e,this._currentContext.activeCubeFace=e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,t,this._currentContext,!1,!1);this.renderer._activeCubeFace=h,this._currentContext.activeCubeFace=h}}for(let s=0,u=i.length;s<u;s++){let u=i[s];
121if(t.layers.test(u.layers)){d&&(this.renderer._activeCubeFace=s,this._currentContext.activeCubeFace=s,this._setFramebuffer(this._currentContext));let t=u.viewport;if(void 0!==t){let r=t.x*a,i=t.y*a,s=t.width*a,n=t.height*a;l.viewport(Math.floor(r),Math.floor(e.context.height-n-i),Math.floor(s),Math.floor(n))}l.bindBufferBase(o.UNIFORM_BUFFER,n.index,r.indexesGPU[s]),N()}this._currentContext.activeCubeFace=h,this.renderer._activeCubeFace=h}}else N()}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}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,r,i,s,n){return this.textureUtils.copyTextureToBuffer(e,t,r,i,s,n)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new ff(e,t)}createProgram(e){let t=this.gl,{stage:r,code:i}=e,s="fragment"===r?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(s,i),t.compileShader(s),this.set(e,{shaderGPU:s})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){let r=this.gl,i=e.pipeline,{fragmentProgram:s,vertexProgram:n}=i,a=r.createProgram(),o=this.get(s).shaderGPU,l=this.get(n).shaderGPU;if(r.attachShader(a,o),r.attachShader(a,l),r.linkProgram(a),this.set(i,{programGPU:a,fragmentShader:o,vertexShader:l}),null!==t&&this.parallel){let s=new Promise(t=>{let s=this.parallel,n=()=>{r.getProgramParameter(a,s.COMPLETION_STATUS_KHR)?(this._completeCompile(e,i),t()):requestAnimationFrame(n)};n()});t.push(s);return}this._completeCompile(e,i)}_handleSource(e,t){let r=e.split("\n"),i=[],s=Math.max(t-6,0),n=Math.min(t+6,r.length);for(let e=s;e<n;e++){let s=e+1;i.push(`${s===t?">":" "} ${s}: ${r[e]}`)}return i.join("\n")}_getShaderErrors(e,t,r){let i=e.getShaderParameter(t,e.COMPILE_STATUS),s=(e.getShaderInfoLog(t)||"").trim();if(i&&""===s)return"";let n=/ERROR: 0:(\d+)/.exec(s);if(!n)return s;{let i=parseInt(n[1]);return r.toUpperCase()+"\n\n"+s+"\n\n"+this._handleSource(e.getShaderSource(t),i)}}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){let i=this.gl,s=(i.getProgramInfoLog(e)||"").trim();if(!1===i.getProgramParameter(e,i.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(i,e,r,t);else{let n=this._getShaderErrors(i,r,"vertex"),a=this._getShaderErrors(i,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(e,i.VALIDATE_STATUS)+"\n\nProgram Info Log: "+s+"\n"+n+"\n"+a)}else""!==s&&console.warn("THREE.WebGLProgram: Program Info Log:",s)}}_completeCompile(e,t){let{state:r,gl:i}=this,{programGPU:s,fragmentShader:n,vertexShader:a}=this.get(t);!1===i.getProgramParameter(s,i.LINK_STATUS)&&this._logProgramError(s,n,a),r.useProgram(s);let o=e.getBindings();this._setupBindings(o,s),this.set(t,{programGPU:s})}createComputePipeline(e,t){let{state:r,gl:i}=this,s={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(s);let{computeProgram:n}=e,a=i.createProgram(),o=this.get(s).shaderGPU,l=this.get(n).shaderGPU,u=n.transforms,d=[],h=[];for(let e=0;e<u.length;e++){let t=u[e];d.push(t.varyingName),h.push(t.attributeNode)}i.attachShader(a,o),i.attachShader(a,l),i.transformFeedbackVaryings(a,d,i.SEPARATE_ATTRIBS),i.linkProgram(a),!1===i.getProgramParameter(a,i.LINK_STATUS)&&this._logProgramError(a,o,l),r.useProgram(a),this._setupBindings(t,a);let c=n.attributes,p=[],g=[];for(let e=0;e<c.length;e++){let t=c[e].node.attribute;p.push(t),this.has(t)||this.attributeUtils.createAttribute(t,i.ARRAY_BUFFER)}for(let e=0;e<h.length;e++){let t=h[e].attribute;this.has(t)||this.attributeUtils.createAttribute(t,i.ARRAY_BUFFER);let r=this.get(t);g.push(r)}this.set(e,{programGPU:a,transformBuffers:g,attributes:p})}createBindings(e,t){if(!1===this._knownBindings.has(t)){this._knownBindings.add(t);let e=0,r=0;for(let i of t)for(let t of(this.set(i,{textures:r,uniformBuffers:e}),i.bindings))t.isUniformBuffer&&e++,t.isSampledTexture&&r++}this.updateBindings(e,t)}updateBindings(e){let{gl:t}=this,r=this.get(e),i=r.uniformBuffers,s=r.textures;for(let r of e.bindings){let e=this.get(r);if(r.isUniformsGroup||r.isUniformBuffer){let s=r.buffer,{bufferGPU:n}=this.get(s);void 0===n?(n=t.createBuffer(),t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferData(t.UNIFORM_BUFFER,s,t.DYNAMIC_DRAW),this.set(s,{bufferGPU:n})):(t.bindBuffer(t.UNIFORM_BUFFER,n),t.bufferSubData(t.UNIFORM_BUFFER,0,s)),e.index=i++,e.bufferGPU=n,this.set(r,e)}else if(r.isSampledTexture){let{textureGPU:t,glTextureType:i}=this.get(r.texture);e.index=s++,e.textureGPU=t,e.glTextureType=i,this.set(r,e)}}}updateBinding(e){let t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){let r=this.get(e).bufferGPU,i=e.buffer;t.bindBuffer(t.UNIFORM_BUFFER,r),t.bufferData(t.UNIFORM_BUFFER,i,t.DYNAMIC_DRAW)}}createIndexAttribute(e){let t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;let t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){let t=Object.keys(fP).filter(t=>fP[t]===e),r=this.extensions;for(let e=0;e<t.length;e++)if(r.has(t[e]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}
vendor: 14,188 bytes, line 121
121copyTextureToTexture(e,t,r=null,i=null,s=0,n=0){this.textureUtils.copyTextureToTexture(e,t,r,i,s,n)}copyFramebufferToTexture(e,t,r){this.textureUtils.copyFramebufferToTexture(e,t,r)}_setFramebuffer(e){let{gl:t,state:r}=this,i=null;if(null!==e.textures){let s,n=e.renderTarget,a=this.get(n),{samples:o,depthBuffer:l,stencilBuffer:u}=n,d=!0===n.isWebGLCubeRenderTarget,h=!0===n.isRenderTarget3D,c=n.depth>1,p=!0===n.isXRRenderTarget,g=!0===p&&!0===n._hasExternalTextures,m=a.msaaFrameBuffer,f=a.depthRenderbuffer,y=this.extensions.get("WEBGL_multisampled_render_to_texture"),b=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(n),T=dE(e);if(d?(a.cubeFramebuffers||(a.cubeFramebuffers={}),s=a.cubeFramebuffers[T]):p&&!1===g?s=this._xrFramebuffer:(a.framebuffers||(a.framebuffers={}),s=a.framebuffers[T]),void 0===s){s=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,s);let i=e.textures,l=[];if(d){a.cubeFramebuffers[T]=s;let{textureGPU:e}=this.get(i[0]),r=this.renderer._activeCubeFace,n=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,n)}else{a.framebuffers[T]=s;for(let r=0;r<i.length;r++){let s=i[r],a=this.get(s);a.renderTarget=e.renderTarget,a.cacheKey=T;let l=t.COLOR_ATTACHMENT0+r;if(n.multiview)b.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,l,a.textureGPU,0,o,0,2);else if(h||c){let e=this.renderer._activeCubeFace,r=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,l,a.textureGPU,r,e)}else if(x)y.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,t.TEXTURE_2D,a.textureGPU,0,o);else{let e=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,l,t.TEXTURE_2D,a.textureGPU,e)}}}let p=u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(!0===n._autoAllocateDepthBuffer){let r=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(r,e,0,x),a.xrDepthRenderbuffer=r,l.push(u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,p,t.RENDERBUFFER,r)}else if(null!==e.depthTexture){l.push(u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);let r=this.get(e.depthTexture);if(r.renderTarget=e.renderTarget,r.cacheKey=T,n.multiview)b.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,p,r.textureGPU,0,o,0,2);else if(g&&x)y.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,t.TEXTURE_2D,r.textureGPU,0,o);else if(e.depthTexture.isArrayTexture){let e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,p,r.textureGPU,0,e)}else t.framebufferTexture2D(t.FRAMEBUFFER,p,t.TEXTURE_2D,r.textureGPU,0)}a.depthInvalidationArray=l}else{if(this._isRenderCameraDepthArray(e)){r.bindFramebuffer(t.FRAMEBUFFER,s);let i=this.renderer._activeCubeFace,n=this.get(e.depthTexture),a=u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,a,n.textureGPU,0,i)}if((p||x||n.multiview)&&!0!==n._isOpaqueFramebuffer){r.bindFramebuffer(t.FRAMEBUFFER,s);let i=this.get(e.textures[0]);n.multiview?b.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,i.textureGPU,0,o,0,2):x?y.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i.textureGPU,0);let l=u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(!0===n._autoAllocateDepthBuffer){let e=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,e),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{let r=this.get(e.depthTexture);n.multiview?b.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,l,r.textureGPU,0,o,0,2):x?y.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,t.TEXTURE_2D,r.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,l,t.TEXTURE_2D,r.textureGPU,0)}}}if(o>0&&!1===x&&!n.multiview){if(void 0===m){let i=[];m=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,m);let s=[],n=e.textures;for(let r=0;r<n.length;r++){s[r]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,s[r]),i.push(t.COLOR_ATTACHMENT0+r);let n=e.textures[r],a=this.get(n);t.renderbufferStorageMultisample(t.RENDERBUFFER,o,a.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+r,t.RENDERBUFFER,s[r])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),a.msaaFrameBuffer=m,a.msaaRenderbuffers=s,l&&void 0===f){f=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(f,e,o),a.depthRenderbuffer=f;let r=u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;i.push(r)}a.invalidationArray=i}i=a.msaaFrameBuffer}else i=s;r.drawBuffers(e,s)}r.bindFramebuffer(t.FRAMEBUFFER,i)}_getVaoKey(e){let t="";for(let r=0;r<e.length;r++)t+=":"+this.get(e[r]).id;return t}_createVao(e){let{gl:t}=this,r=t.createVertexArray();t.bindVertexArray(r);for(let r=0;r<e.length;r++){let i,s,n=e[r],a=this.get(n);t.bindBuffer(t.ARRAY_BUFFER,a.bufferGPU),t.enableVertexAttribArray(r),!0===n.isInterleavedBufferAttribute?(i=n.data.stride*a.bytesPerElement,s=n.offset*a.bytesPerElement):(i=0,s=0),a.isInteger?t.vertexAttribIPointer(r,n.itemSize,a.type,i,s):t.vertexAttribPointer(r,n.itemSize,a.type,n.normalized,i,s),n.isInstancedBufferAttribute&&!n.isInterleavedBufferAttribute?t.vertexAttribDivisor(r,n.meshPerAttribute):n.isInterleavedBufferAttribute&&n.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(r,n.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),r}_getTransformFeedback(e){let t="";for(let r=0;r<e.length;r++)t+=":"+e[r].id;let r=this.transformFeedbackCache[t];if(void 0!==r)return r;let{gl:i}=this;r=i.createTransformFeedback(),i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,r);for(let t=0;t<e.length;t++){let r=e[t];i.bindBufferBase(i.TRANSFORM_FEEDBACK_BUFFER,t,r.transformBuffer)}return i.bindTransformFeedback(i.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=r,r}_setupBindings(e,t){let r=this.gl;for(let i of e)for(let e of i.bindings){let i=this.get(e).index;if(e.isUniformsGroup||e.isUniformBuffer){let s=r.getUniformBlockIndex(t,e.name);r.uniformBlockBinding(t,s,i)}else if(e.isSampledTexture){let s=r.getUniformLocation(t,e.name);r.uniform1i(s,i)}}}_bindUniforms(e){let{gl:t,state:r}=this;for(let i of e)for(let e of i.bindings){let i=this.get(e),s=i.index;e.isUniformsGroup||e.isUniformBuffer?r.bindBufferBase(t.UNIFORM_BUFFER,s,i.bufferGPU):e.isSampledTexture&&r.bindTexture(i.glTextureType,i.textureGPU,t.TEXTURE0+s)}}_resolveRenderTarget(e){let{gl:t,state:r}=this,i=e.renderTarget;if(null!==e.textures&&i){let s=this.get(i);if(i.samples>0&&!1===this._useMultisampledExtension(i)){let n=s.framebuffers[e.getCacheKey()],a=t.COLOR_BUFFER_BIT;i.resolveDepthBuffer&&(i.depthBuffer&&(a|=t.DEPTH_BUFFER_BIT),i.stencilBuffer&&i.resolveStencilBuffer&&(a|=t.STENCIL_BUFFER_BIT));let o=s.msaaFrameBuffer,l=s.msaaRenderbuffers,u=e.textures,d=u.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,o),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,n),d)for(let e=0;e<u.length;e++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,null,0);for(let r=0;r<u.length;r++){if(d){let{textureGPU:e}=this.get(u[r]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,l[r]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0)}if(e.scissor){let{x:r,y:i,width:s,height:n}=e.scissorValue,o=e.height-n-i;t.blitFramebuffer(r,o,r+s,o+n,r,o,r+s,o+n,a,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,a,t.NEAREST)}if(d)for(let e=0;e<u.length;e++){let{textureGPU:r}=this.get(u[e]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.RENDERBUFFER,l[e]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+e,t.TEXTURE_2D,r,0)}!0===this._supportsInvalidateFramebuffer&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,s.invalidationArray)}else if(!1===i.resolveDepthBuffer&&s.framebuffers){let i=s.framebuffers[e.getCacheKey()];r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,s.depthInvalidationArray)}}}_useMultisampledExtension(e){return!0===e.multiview||e.samples>0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){let e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}let fO={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},fV={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},fG={Store:"store"},fk={Load:"load",Clear:"clear"},fz={CCW:"ccw",CW:"cw"},f$={None:"none",Back:"back"},fH={Uint16:"uint16",Uint32:"uint32"},fW={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},fq={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},fj={Linear:"linear",Nearest:"nearest"},fX={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},fK={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},fQ={None:0,All:15},fY={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},fZ={Storage:"storage",ReadOnlyStorage:"read-only-storage"},fJ={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},f0={NonFiltering:"non-filtering",Comparison:"comparison"},f1={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},f2={TwoD:"2d",ThreeD:"3d"},f3={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},f4={All:"all"},f6={Vertex:"vertex",Instance:"instance"},f8={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"};class f5 extends fs{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class f9 extends m5{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let f7=0;class ye extends f9{constructor(e,t){super("StorageBuffer_"+f7++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:M.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class yt extends ds{constructor(e){super(),this.device=e;let t=`
122struct VarysStruct {
123	@builtin( position ) Position: vec4<f32>,
124	@location( 0 ) vTex : vec2<f32>
125};
126
127@vertex
128fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
129
130	var Varys : VarysStruct;
131
132	var pos = array< vec2<f32>, 4 >(
133		vec2<f32>( -1.0,  1.0 ),
134		vec2<f32>(  1.0,  1.0 ),
135		vec2<f32>( -1.0, -1.0 ),
136		vec2<f32>(  1.0, -1.0 )
137	);
138
139	var tex = array< vec2<f32>, 4 >(
140		vec2<f32>( 0.0, 0.0 ),
141		vec2<f32>( 1.0, 0.0 ),
142		vec2<f32>( 0.0, 1.0 ),
143		vec2<f32>( 1.0, 1.0 )
144	);
145
146	Varys.vTex = tex[ vertexIndex ];
147	Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
148
149	return Varys;
150
151}
152`,r=`
153@group( 0 ) @binding( 0 )
154var imgSampler : sampler;
155
156@group( 0 ) @binding( 1 )
157var img : texture_2d<f32>;
158
159@fragment
160fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
161
162	return textureSample( img, imgSampler, vTex );
163
164}
165`,i=`
166@group( 0 ) @binding( 0 )
167var imgSampler : sampler;
168
169@group( 0 ) @binding( 1 )
170var img : texture_2d<f32>;
171
172@fragment
173fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
174
175	return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );
176
177}
178`;this.mipmapSampler=e.createSampler({minFilter:fj.Linear}),this.flipYSampler=e.createSampler({minFilter:fj.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:r}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:i})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:fO.TriangleStrip,stripIndexFormat:fH.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:fO.TriangleStrip,stripIndexFormat:fH.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){let i=t.format,{width:s,height:n}=t.size,a=this.getTransferPipeline(i),o=this.getFlipYPipeline(i),l=this.device.createTexture({size:{width:s,height:n,depthOrArrayLayers:1},format:i,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),u=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:f3.TwoD,baseArrayLayer:r}),d=l.createView({baseMipLevel:0,mipLevelCount:1,dimension:f3.TwoD,baseArrayLayer:0}),h=this.device.createCommandEncoder({}),c=(e,t,r)=>{let i=e.getBindGroupLayout(0),s=this.device.createBindGroup({layout:i,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=h.beginRenderPass({colorAttachments:[{view:r,loadOp:fk.Clear,storeOp:fG.Store,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,s),n.draw(4,1,0,0),n.end()};c(a,u,d),c(o,d,u),this.device.queue.submit([h.finish()]),l.destroy()}generateMipmaps(e,t,r=0){let i=this.get(e);void 0===i.useCount&&(i.useCount=0,i.layers=[]);let s=i.layers[r]||this._mipmapCreateBundles(e,t,r),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,s),this.device.queue.submit([n.finish()]),0!==i.useCount&&(i.layers[r]=s),i.useCount++}_mipmapCreateBundles(e,t,r){let i=this.getTransferPipeline(t.format),s=i.getBindGroupLayout(0),n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:f3.TwoD,baseArrayLayer:r}),a=[];for(let o=1;o<t.mipLevelCount;o++){let l=this.device.createBindGroup({layout:s,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:n}]}),u=e.createView({baseMipLevel:o,mipLevelCount:1,dimension:f3.TwoD,baseArrayLayer:r}),d={colorAttachments:[{view:u,loadOp:fk.Clear,storeOp:fG.Store,clearValue:[0,0,0,0]}]},h=this.device.createRenderBundleEncoder({colorFormats:[t.format]});h.setPipeline(i),h.setBindGroup(0,l),h.draw(4,1,0,0),a.push({renderBundles:[h.finish()],passDescriptor:d}),n=u}return a}_mipmapRunBundles(e,t){let r=t.length;for(let i=0;i<r;i++){let r=t[i],s=e.beginRenderPass(r.passDescriptor);s.executeBundles(r.renderBundles),s.end()}}}let yr={[u.amv]:"never",[u.vim]:"less",[u.kO0]:"equal",[u.TiK]:"less-equal",[u.eoi]:"greater",[u.gWB]:"greater-equal",[u.FFZ]:"always",[u.jzd]:"not-equal"},yi=[0,1,3,2,4,5];class ys{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new u.VCu,this.depthTexture.name="depthBuffer"}createSampler(e){let t=this.backend,r=t.device,i=t.get(e),s={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};s.magFilter===fj.Linear&&s.minFilter===fj.Linear&&s.mipmapFilter===fj.Linear&&(s.maxAnisotropy=e.anisotropy),e.isDepthTexture&&null!==e.compareFunction&&(s.compare=yr[e.compareFunction]),i.sampler=r.createSampler(s)}createDefaultTexture(e){let t,r=yn(e);t=e.isCubeTexture?this._getDefaultCubeTextureGPU(r):this._getDefaultTextureGPU(r),this.backend.get(e).texture=t}
178createTexture(e,t={}){let r=this.backend,i=r.get(e);if(i.initialized)throw Error("WebGPUTextureUtils: Texture already initialized.");if(e.isExternalTexture){i.texture=e.sourceTexture,i.initialized=!0;return}void 0===t.needsMipmaps&&(t.needsMipmaps=!1),void 0===t.levels&&(t.levels=1),void 0===t.depth&&(t.depth=1);let{width:s,height:n,depth:a,levels:o}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());let l=this._getDimension(e),u=e.internalFormat||t.format||yn(e,r.device);i.format=u;let{samples:d,primarySamples:h,isMSAA:c}=r.utils.getTextureSampleData(e),p=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;!0===e.isStorageTexture&&(p|=GPUTextureUsage.STORAGE_BINDING),!0!==e.isCompressedTexture&&!0!==e.isCompressedArrayTexture&&u!==fW.RGB9E5UFloat&&(p|=GPUTextureUsage.RENDER_ATTACHMENT);let g={label:e.name,size:{width:s,height:n,depthOrArrayLayers:a},mipLevelCount:o,sampleCount:h,dimension:l,format:u,usage:p};if(void 0===u){console.warn("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}if(e.isCubeTexture&&(g.textureBindingViewDimension=f3.Cube),i.texture=r.device.createTexture(g),c){let e=Object.assign({},g);e.label=e.label+"-msaa",e.sampleCount=d,e.mipLevelCount=1,i.msaaTexture=r.device.createTexture(e)}i.initialized=!0,i.textureDescriptorGPU=g}destroyTexture(e){let t=this.backend,r=t.get(e);void 0!==r.texture&&r.texture.destroy(),void 0!==r.msaaTexture&&r.msaaTexture.destroy(),t.delete(e)}destroySampler(e){let t=this.backend.get(e);delete t.sampler}generateMipmaps(e){let t=this.backend.get(e);if(e.isCubeTexture)for(let e=0;e<6;e++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,e);else{let r=e.image.depth||1;for(let e=0;e<r;e++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,e)}}getColorBuffer(){this.colorBuffer&&this.colorBuffer.destroy();let e=this.backend,{width:t,height:r}=e.getDrawingBufferSize();return this.colorBuffer=e.device.createTexture({label:"colorBuffer",size:{width:t,height:r,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.samples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),this.colorBuffer}getDepthBuffer(e=!0,t=!1){let r,i,s=this.backend,{width:n,height:a}=s.getDrawingBufferSize(),o=this.depthTexture,l=s.get(o).texture;if(t?(r=u.dcC,i=u.V3x):e&&(r=u.zdS,i=u.bkx),void 0!==l){if(o.image.width===n&&o.image.height===a&&o.format===r&&o.type===i)return l;this.destroyTexture(o)}return o.name="depthBuffer",o.format=r,o.type=i,o.image.width=n,o.image.height=a,this.createTexture(o,{width:n,height:a}),s.get(o).texture}updateTexture(e,t){let r=this.backend.get(e),i=e.mipmaps,{textureDescriptorGPU:s}=r;if(!e.isRenderTargetTexture&&void 0!==s){if(e.isDataTexture)if(i.length>0)for(let t=0,n=i.length;t<n;t++){let n=i[t];this._copyBufferToTexture(n,r.texture,s,0,e.flipY,0,t)}else this._copyBufferToTexture(t.image,r.texture,s,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let i=0;i<t.image.depth;i++)this._copyBufferToTexture(t.image,r.texture,s,i,e.flipY,i);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,r.texture,s);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,s);else if(i.length>0)for(let t=0,n=i.length;t<n;t++){let n=i[t];this._copyImageToTexture(n,r.texture,s,0,e.flipY,e.premultiplyAlpha,t)}else this._copyImageToTexture(t.image,r.texture,s,0,e.flipY,e.premultiplyAlpha);r.version=e.version}}async copyTextureToBuffer(e,t,r,i,s,n){let a=this.backend.device,o=this.backend.get(e),l=o.texture,u=o.textureDescriptorGPU.format,d=this._getBytesPerTexel(u),h=i*d;h=256*Math.ceil(h/256);let c=a.createBuffer({size:(s-1)*h+i*d,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),p=a.createCommandEncoder();p.copyTextureToBuffer({texture:l,origin:{x:t,y:r,z:n}},{buffer:c,bytesPerRow:h},{width:i,height:s});let g=this._getTypedArrayType(u);return a.queue.submit([p.finish()]),await c.mapAsync(GPUMapMode.READ),new g(c.getMappedRange())}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(void 0===t){let r=new u.gPd;r.minFilter=u.hxR,r.magFilter=u.hxR,this.createTexture(r,{width:1,height:1,format:e}),this.defaultTexture[e]=t=r}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultTexture[e];if(void 0===t){let r=new u.b4q;r.minFilter=u.hxR,r.magFilter=u.hxR,this.createTexture(r,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=r}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,r){let i=e.images,s=e.mipmaps;for(let n=0;n<6;n++){let a=i[n],o=!0===e.flipY?yi[n]:n;a.isDataTexture?this._copyBufferToTexture(a.image,t,r,o,e.flipY):this._copyImageToTexture(a,t,r,o,e.flipY,e.premultiplyAlpha);for(let i=0;i<s.length;i++){let a=s[i].images[n];a.isDataTexture?this._copyBufferToTexture(a.image,t,r,o,e.flipY,0,i+1):this._copyImageToTexture(a,t,r,o,e.flipY,e.premultiplyAlpha,i+1)}}}_copyImageToTexture(e,t,r,i,s,n,a=0){let o=this.backend.device,l=a>0?e.width:r.size.width,u=a>0?e.height:r.size.height;o.queue.copyExternalImageToTexture({source:e,flipY:s},{texture:t,mipLevel:a,origin:{x:0,y:0,z:i},premultipliedAlpha:n},{width:l,height:u,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new yt(this.backend.device)),e}_generateMipmaps(e,t,r=0){this._getPassUtils().generateMipmaps(e,t,r)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,i,s,n=0,a=0){let o=this.backend.device,l=e.data,u=this._getBytesPerTexel(r.format),d=e.width*u;o.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:i}},l,{offset:e.width*e.height*u*n,bytesPerRow:d},{width:e.width,height:e.height,depthOrArrayLayers:1}),!0===s&&this._flipY(t,r,i)}_copyCompressedBufferToTexture(e,t,r){let i=this.backend.device,s=this._getBlockData(r.format),n=r.size.depthOrArrayLayers>1;for(let a=0;a<e.length;a++){let o=e[a],l=o.width,u=o.height,d=n?r.size.depthOrArrayLayers:1,h=Math.ceil(l/s.width)*s.byteLength,c=h*Math.ceil(u/s.height);for(let e=0;e<d;e++)i.queue.writeTexture({texture:t,mipLevel:a,origin:{x:0,y:0,z:e}},o.data,{offset:e*c,bytesPerRow:h,rowsPerImage:Math.ceil(u/s.height)},{width:Math.ceil(l/s.width)*s.width,height:Math.ceil(u/s.height)*s.height,depthOrArrayLayers:1})}}_getBlockData(e){return e===fW.BC1RGBAUnorm||e===fW.BC1RGBAUnormSRGB?{byteLength:8,width:4,height:4}:e===fW.BC2RGBAUnorm||e===fW.BC2RGBAUnormSRGB||e===fW.BC3RGBAUnorm||e===fW.BC3RGBAUnormSRGB?{byteLength:16,width:4,height:4}:e===fW.BC4RUnorm||e===fW.BC4RSnorm?{byteLength:8,width:4,height:4}:e===fW.BC5RGUnorm||e===fW.BC5RGSnorm||e===fW.BC6HRGBUFloat||e===fW.BC6HRGBFloat||e===fW.BC7RGBAUnorm||e===fW.BC7RGBAUnormSRGB?{byteLength:16,width:4,height:4}:e===fW.ETC2RGB8Unorm||e===fW.ETC2RGB8UnormSRGB||e===fW.ETC2RGB8A1Unorm||e===fW.ETC2RGB8A1UnormSRGB?{byteLength:8,width:4,height:4}:e===fW.ETC2RGBA8Unorm||e===fW.ETC2RGBA8UnormSRGB?{byteLength:16,width:4,height:4}:e===fW.EACR11Unorm||e===fW.EACR11Snorm?{byteLength:8,width:4,height:4}:e===fW.EACRG11Unorm||e===fW.EACRG11Snorm||e===fW.ASTC4x4Unorm||e===fW.ASTC4x4UnormSRGB?{byteLength:16,width:4,height:4}:e===fW.ASTC5x4Unorm||e===fW.ASTC5x4UnormSRGB?{byteLength:16,width:5,height:4}:e===fW.ASTC5x5Unorm||e===fW.ASTC5x5UnormSRGB?{byteLength:16,width:5,height:5}:e===fW.ASTC6x5Unorm||e===fW.ASTC6x5UnormSRGB?{byteLength:16,width:6,height:5}:e===fW.ASTC6x6Unorm||e===fW.ASTC6x6UnormSRGB?{byteLength:16,width:6,height:6}:e===fW.ASTC8x5Unorm||e===fW.ASTC8x5UnormSRGB?{byteLength:16,width:8,height:5}:e===fW.ASTC8x6Unorm||e===fW.ASTC8x6UnormSRGB?{byteLength:16,width:8,height:6}:e===fW.ASTC8x8Unorm||e===fW.ASTC8x8UnormSRGB?{byteLength:16,width:8,height:8}:e===fW.ASTC10x5Unorm||e===fW.ASTC10x5UnormSRGB?{byteLength:16,width:10,height:5}:e===fW.ASTC10x6Unorm||e===fW.ASTC10x6UnormSRGB?{byteLength:16,width:10,height:6}:e===fW.ASTC10x8Unorm||e===fW.ASTC10x8UnormSRGB?{byteLength:16,width:10,height:8}:e===fW.ASTC10x10Unorm||e===fW.ASTC10x10UnormSRGB?{byteLength:16,width:10,height:10}:e===fW.ASTC12x10Unorm||e===fW.ASTC12x10UnormSRGB?{byteLength:16,width:12,height:10}:e===fW.ASTC12x12Unorm||e===fW.ASTC12x12UnormSRGB?{byteLength:16,width:12,height:12}:void 0}_convertAddressMode(e){let t=fq.ClampToEdge;return e===u.GJx?t=fq.Repeat:e===u.kTW&&(t=fq.MirrorRepeat),t}_convertFilterMode(e){let t=fj.Linear;return(e===u.hxR||e===u.pHI||e===u.Cfg)&&(t=fj.Nearest),t}_getBytesPerTexel(e){return e===fW.R8Unorm||e===fW.R8Snorm||e===fW.R8Uint||e===fW.R8Sint?1:e===fW.R16Uint||e===fW.R16Sint||e===fW.R16Float||e===fW.RG8Unorm||e===fW.RG8Snorm||e===fW.RG8Uint||e===fW.RG8Sint?2:e===fW.R32Uint||e===fW.R32Sint||e===fW.R32Float||e===fW.RG16Uint||e===fW.RG16Sint||e===fW.RG16Float||e===fW.RGBA8Unorm||e===fW.RGBA8UnormSRGB||e===fW.RGBA8Snorm||e===fW.RGBA8Uint||e===fW.RGBA8Sint||e===fW.BGRA8Unorm||e===fW.BGRA8UnormSRGB||e===fW.RGB9E5UFloat||e===fW.RGB10A2Unorm||e===fW.RG11B10UFloat||e===fW.Depth32Float||e===fW.Depth24Plus||e===fW.Depth24PlusStencil8||e===fW.Depth32FloatStencil8?4:e===fW.RG32Uint||e===fW.RG32Sint||e===fW.RG32Float||e===fW.RGBA16Uint||e===fW.RGBA16Sint||e===fW.RGBA16Float?8:e===fW.RGBA32Uint||e===fW.RGBA32Sint||e===fW.RGBA32Float?16:void 0}_getTypedArrayType(e){return e===fW.R8Uint?Uint8Array:e===fW.R8Sint?Int8Array:e===fW.R8Unorm?Uint8Array:e===fW.R8Snorm?Int8Array:e===fW.RG8Uint?Uint8Array:e===fW.RG8Sint?Int8Array:e===fW.RG8Unorm?Uint8Array:e===fW.RG8Snorm?Int8Array:e===fW.RGBA8Uint?Uint8Array:e===fW.RGBA8Sint?Int8Array:e===fW.RGBA8Unorm||e===fW.RGBA8UnormSRGB?Uint8Array:e===fW.RGBA8Snorm?Int8Array:e===fW.R16Uint?Uint16Array:e===fW.R16Sint?Int16Array:e===fW.RG16Uint?Uint16Array:e===fW.RG16Sint?Int16Array:e===fW.RGBA16Uint?Uint16Array:e===fW.RGBA16Sint?Int16Array:e===fW.R16Float||e===fW.RG16Float||e===fW.RGBA16Float?Uint16Array:e===fW.R32Uint?Uint32Array:e===fW.R32Sint?Int32Array:e===fW.R32Float?Float32Array:e===fW.RG32Uint?Uint32Array:e===fW.RG32Sint?Int32Array:e===fW.RG32Float?Float32Array:e===fW.RGBA32Uint?Uint32Array:e===fW.RGBA32Sint?Int32Array:e===fW.RGBA32Float?Float32Array:e===fW.BGRA8Unorm||e===fW.BGRA8UnormSRGB?Uint8Array:e===fW.RGB10A2Unorm||e===fW.RGB9E5UFloat||e===fW.RG11B10UFloat?Uint32Array:e===fW.Depth32Float?Float32Array:e===fW.Depth24Plus||e===fW.Depth24PlusStencil8?Uint32Array:e===fW.Depth32FloatStencil8?Float32Array:void 0}_getDimension(e){return e.is3DTexture||e.isData3DTexture?f2.ThreeD:f2.TwoD}}function yn(e,t=null){let r,i=e.format,s=e.type,n=e.colorSpace,a=u.ppV.getTransfer(n);if(!0===e.isCompressedTexture||!0===e.isCompressedArrayTexture)switch(i){case u.IE4:case u.Nz6:r=a===u.KLL?fW.BC1RGBAUnormSRGB:fW.BC1RGBAUnorm;break;case u.jR7:r=a===u.KLL?fW.BC2RGBAUnormSRGB:fW.BC2RGBAUnorm;break;case u.BXX:r=a===u.KLL?fW.BC3RGBAUnormSRGB:fW.BC3RGBAUnorm;break;case u.Kef:r=fW.BC4RUnorm;break;case u.XG_:r=fW.BC4RSnorm;break;case u.HO_:r=fW.BC5RGUnorm;break;case u.CWW:r=fW.BC5RGSnorm;break;case u.Fn:r=a===u.KLL?fW.BC7RGBAUnormSRGB:fW.BC7RGBAUnorm;break;case u.Riy:case u.CVz:r=a===u.KLL?fW.ETC2RGB8UnormSRGB:fW.ETC2RGB8Unorm;break;case u.KDk:r=a===u.KLL?fW.ETC2RGBA8UnormSRGB:fW.ETC2RGBA8Unorm;break;case u.qa3:r=a===u.KLL?fW.ASTC4x4UnormSRGB:fW.ASTC4x4Unorm;break;case u.B_h:r=a===u.KLL?fW.ASTC5x4UnormSRGB:fW.ASTC5x4Unorm;break;case u.czI:r=a===u.KLL?fW.ASTC5x5UnormSRGB:fW.ASTC5x5Unorm;break;case u.rSH:r=a===u.KLL?fW.ASTC6x5UnormSRGB:fW.ASTC6x5Unorm;break;case u.Qrf:r=a===u.KLL?fW.ASTC6x6UnormSRGB:fW.ASTC6x6Unorm;break;case u.psI:r=a===u.KLL?fW.ASTC8x5UnormSRGB:fW.ASTC8x5Unorm;break;case u.a5J:r=a===u.KLL?fW.ASTC8x6UnormSRGB:fW.ASTC8x6Unorm;break;case u._QJ:r=a===u.KLL?fW.ASTC8x8UnormSRGB:fW.ASTC8x8Unorm;break;case u.uB5:r=a===u.KLL?fW.ASTC10x5UnormSRGB:fW.ASTC10x5Unorm;break;case u.lyL:r=a===u.KLL?fW.ASTC10x6UnormSRGB:fW.ASTC10x6Unorm;break;case u.bC7:r=a===u.KLL?fW.ASTC10x8UnormSRGB:fW.ASTC10x8Unorm;break;case u.y3Z:r=a===u.KLL?fW.ASTC10x10UnormSRGB:fW.ASTC10x10Unorm;break;case u.ojs:r=a===u.KLL?fW.ASTC12x10UnormSRGB:fW.ASTC12x10Unorm;break;case u.S$4:r=a===u.KLL?fW.ASTC12x12UnormSRGB:fW.ASTC12x12Unorm;break;case u.GWd:r=a===u.KLL?fW.RGBA8UnormSRGB:fW.RGBA8Unorm;break;default:console.error("WebGPURenderer: Unsupported texture format.",i)}else switch(i){case u.GWd:switch(s){case u.tJf:r=fW.RGBA8Snorm;break;case u.fBL:r=fW.RGBA16Sint;break;case u.cHt:r=fW.RGBA16Uint;break;case u.bkx:r=fW.RGBA32Uint;break;case u.Yuy:r=fW.RGBA32Sint;break;case u.OUM:r=a===u.KLL?fW.RGBA8UnormSRGB:fW.RGBA8Unorm;break;case u.ix0:r=fW.RGBA16Float;break;case u.RQf:r=fW.RGBA32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case u.HIg:switch(s){case u.Dmk:r=fW.RGB9E5UFloat;break;case u.yT7:r=fW.RG11B10UFloat;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case u.VT0:switch(s){case u.tJf:r=fW.R8Snorm;break;case u.fBL:r=fW.R16Sint;break;case u.cHt:r=fW.R16Uint;break;case u.bkx:r=fW.R32Uint;break;case u.Yuy:r=fW.R32Sint;break;case u.OUM:r=fW.R8Unorm;break;case u.ix0:r=fW.R16Float;break;case u.RQf:r=fW.R32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case u.paN:switch(s){case u.tJf:r=fW.RG8Snorm;break;case u.fBL:r=fW.RG16Sint;break;case u.cHt:r=fW.RG16Uint;break;case u.bkx:r=fW.RG32Uint;break;case u.Yuy:r=fW.RG32Sint;break;case u.OUM:r=fW.RG8Unorm;break;case u.ix0:r=fW.RG16Float;break;case u.RQf:r=fW.RG32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case u.zdS:switch(s){case u.cHt:r=fW.Depth16Unorm;break;case u.bkx:r=fW.Depth24Plus;break;case u.RQf:r=fW.Depth32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case u.dcC:switch(s){case u.V3x:r=fW.Depth24PlusStencil8;break;case u.RQf:t&&!1===t.features.has(f8.Depth32FloatStencil8)&&console.error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),r=fW.Depth32FloatStencil8;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case u.ZQM:switch(s){case u.Yuy:r=fW.R32Sint;break;case u.bkx:r=fW.R32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case u.TkQ:switch(s){case u.Yuy:r=fW.RG32Sint;break;case u.bkx:r=fW.RG32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case u.c90:switch(s){case u.Yuy:r=fW.RGBA32Sint;break;case u.bkx:r=fW.RGBA32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:console.error("WebGPURenderer: Unsupported texture format.",i)}return r}let ya=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,yo=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,yl={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>
178":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class yu extends mN{constructor(e){let{type:t,inputs:r,name:i,inputsCode:s,blockCode:n,outputType:a}=(e=>{let t=(e=e.trim()).match(ya);if(null!==t&&4===t.length){let r=t[2],i=[],s=null;for(;null!==(s=yo.exec(r));)i.push({name:s[1],type:s[2]});let n=[];for(let e=0;e<i.length;e++){let{name:t,type:r}=i[e],s=r;s.startsWith("ptr")?s="pointer":(s.startsWith("texture")&&(s=r.split("<")[0]),s=yl[s]),n.push(new mu(s,t))}let a=e.substring(t[0].length),o=t[3]||"void",l=void 0!==t[1]?t[1]:"";
178return{type:yl[o]||o,inputs:n,name:l,inputsCode:r,blockCode:a,outputType:o}}throw Error("FunctionNode: Function is not a WGSL code.")})(e);super(t,r,i),this.inputsCode=s,this.blockCode=n,this.outputType=a}getCode(e=this.name){let t="void"!==this.outputType?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class yd extends mv{parseFunction(e){return new yu(e)}}let yh="undefined"!=typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},yc={[M.READ_ONLY]:"read",[M.WRITE_ONLY]:"write",[M.READ_WRITE]:"read_write"},yp={[u.GJx]:"repeat",[u.ghU]:"clamp",[u.kTW]:"mirror"},yg={vertex:yh?yh.VERTEX:1,fragment:yh?yh.FRAGMENT:2,compute:yh?yh.COMPUTE:4},ym={instance:!0,swizzleAssign:!1,storageBuffer:!0},yf={"^^":"tsl_xor"},yy={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},yb={},yx={tsl_xor:new cd("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new cd("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new cd("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new cd("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new cd("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new cd("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new cd("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new cd("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 cd("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 cd("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new cd("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 cd("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new cd(`
179fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
180
181	let res = vec2f( iRes );
182
183	let uvScaled = coord * res;
184	let uvWrapping = ( ( uvScaled % res ) + res ) % res;
185
186	// https://www.shadertoy.com/view/WtyXRy
187
188	let uv = uvWrapping - 0.5;
189	let iuv = floor( uv );
190	let f = fract( uv );
191
192	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
193	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
194	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
195	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
196
197	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
198
199}
200`)},yT={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>"},y_="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(y_+="diagnostic( off, derivative_uniformity );\n");class yv extends mo{constructor(e,t){super(e,t,new yd),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,r,i,s,n=this.shaderStage){return"fragment"!==n?this.generateTextureSampleLevel(e,t,r,"0",i):i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`}generateTextureSampleLevel(e,t,r,i,s,n){return!1===this.isUnfilterable(e)?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,i):this.generateTextureLod(e,t,r,s,n,i)}generateWrapFunction(e){let t=`tsl_coord_${yp[e.wrapS]}S_${yp[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`,r=yb[t];if(void 0===r){let i=[],s=e.isData3DTexture?"vec3f":"vec2f",n=`fn ${t}( coord : ${s} ) -> ${s} {
201
202	return ${s}(
203`,a=(e,t)=>{e===u.GJx?(i.push(yx.repeatWrapping_float),n+=`		tsl_repeatWrapping_float( coord.${t}
203 )`):e===u.ghU?(i.push(yx.clampWrapping_float),n+=`		tsl_clampWrapping_float( coord.${t} )`):e===u.kTW?(i.push(yx.mirrorWrapping_float),n+=`		tsl_mirrorWrapping_float( coord.${t} )`):(n+=`		coord.${t}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};a(e.wrapS,"x"),n+=",\n",a(e.wrapT,"y"),e.isData3DTexture&&(n+=",\n",a(e.wrapR,"z")),n+="\n	);\n\n}\n",yb[t]=r=new cd(n,i)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){let i=this.getDataFromNode(e,this.shaderStage,this.globalCache);void 0===i.dimensionsSnippet&&(i.dimensionsSnippet={});let s=i.dimensionsSnippet[r];if(void 0===i.dimensionsSnippet[r]){let n,a,{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e);a=e.isData3DTexture?"vec3<u32>":"vec2<u32>",n=o>1||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,s=new iy(new i1(`textureDimensions( ${n} )`,a)),i.dimensionsSnippet[r]=s,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(i.arrayLayerCount=new iy(new i1(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(i.cubeFaceCount=new iy(new i1("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,r,i,s="0u"){this._include("biquadraticTexture");let n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,s);return i&&(r=`${r} + vec2<f32>(${i}) / ${a}`),`tsl_biquadraticTexture( ${t}, ${n}( ${r} ), ${a}, u32( ${s} ) )`}generateTextureLod(e,t,r,i,s,n="0u"){let a=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,n),l=e.isData3DTexture?"vec3":"vec2";s&&(r=`${r} + ${l}<f32>(${s}) / ${l}<f32>( ${o} )`);let u=`${l}<u32>( ${a}( ${r} ) * ${l}<f32>( ${o} ) )`;return this.generateTextureLoad(e,t,u,i,null,n)}generateTextureLoad(e,t,r,i,s,n="0u"){let a;return s&&(r=`${r} + ${s}`),i?a=`textureLoad( ${t}, ${r}, ${i}, u32( ${n} ) )`:(a=`textureLoad( ${t}, ${r}, u32( ${n} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(a+=".x")),a}generateTextureStore(e,t,r,i,s){return i?`textureStore( ${t}, ${r}, ${i}, ${s} )`:`textureStore( ${t}, ${r}, ${s} )`}isSampleCompare(e){return!0===e.isDepthTexture&&null!==e.compareFunction}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===u.RQf||!1===this.isSampleCompare(e)&&e.minFilter===u.hxR&&e.magFilter===u.hxR||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,i,s,n=this.shaderStage){return this.isUnfilterable(e)?this.generateTextureLod(e,t,r,i,s,"0",n):this._generateTextureSample(e,t,r,i,s,n)}generateTextureGrad(e,t,r,i,s,n,a=this.shaderStage){if("fragment"===a)return n?`textureSampleGrad( ${t}, ${t}_sampler, ${r},  ${i[0]}, ${i[1]}, ${n} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r},  ${i[0]}, ${i[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${a} shader.`)}generateTextureCompare(e,t,r,i,s,n,a=this.shaderStage){if("fragment"===a)return!0===e.isDepthTexture&&!0===e.isArrayTexture?n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:n?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${a} shader.`)}generateTextureLevel(e,t,r,i,s,n){return!1===this.isUnfilterable(e)?n?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,n,i):this.generateTextureLod(e,t,r,s,n,i)}generateTextureBias(e,t,r,i,s,n,a=this.shaderStage){if("fragment"===a)return n?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${n} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${a} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){let t=e.name,r=e.type;return"texture"===r||"cubeTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"!==r&&"storageBuffer"!==r&&"indirectStorageBuffer"!==r?e.groupNode.name+"."+t:this.isCu
vendor: 6,128 bytes, lines 203-210
203stomStruct(e)?t:t+".value"}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){let t=yf[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?(console.warn("WebGPURenderer: Atomic operations are only supported in compute shaders."),M.READ_WRITE):M.READ_ONLY:e.access}getStorageAccess(e,t){return yc[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,i=null){let s=super.getUniformFromNode(e,t,r,i),n=this.getDataFromNode(e,r,this.globalCache);if(void 0===n.uniformGPU){let a,o=e.groupNode,l=o.name,u=this.getBindGroupArray(l,r);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let i=null,n=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?i=!0===e.value.is3DTexture?new fu(s.name,s.node,o,n):new fo(s.name,s.node,o,n):"cubeTexture"===t?i=new fl(s.name,s.node,o,n):"texture3D"===t&&(i=new fu(s.name,s.node,o,n)),i.store=!0===e.isStorageTextureNode,i.setVisibility(yg[r]),!1===this.isUnfilterable(e.value)&&!1===i.store){let e=new f5(`${s.name}_sampler`,s.node,o);e.setVisibility(yg[r]),u.push(e,i),a=[e,i]}else u.push(i),a=[i]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){let n=new("buffer"===t?fe:ye)(e,o);n.setVisibility(yg[r]),u.push(n),a=n,s.name=i||"NodeBuffer_"+s.id}else{let e=this.uniformGroups[r]||(this.uniformGroups[r]={}),i=e[l];void 0===i&&((i=new fi(l,o)).setVisibility(yg[r]),e[l]=i,u.push(i)),a=this.getNodeUniform(s,t),i.addUniform(a)}n.uniformGPU=a}return s}getBuiltin(e,t,r,i=this.shaderStage){let s=this.builtins[i]||(this.builtins[i]=new Map);return!1===s.has(e)&&s.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return void 0!==this.builtins[t]&&this.builtins[t].has(e)}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){let t=e.layout,r=this.flowShaderNode(e),i=[];for(let e of t.inputs)i.push(e.name+" : "+this.getType(e.type));let s=`fn ${t.name}( ${i.join(", ")} ) -> ${this.getType(t.type)} {
204${r.vars}
205${r.code}
206`;return r.result&&(s+=`	return ${r.result};
207`),s+="\n}\n"}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){let t=[],r=this.directives[e];if(void 0!==r)for(let e of r)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){let t=[],r=this.builtins[e];if(void 0!==r)for(let{name:e,property:i,type:s}of r.values())t.push(`@builtin( ${e} ) ${i} : ${s}`);return t.join(",\n	")}getScopedArray(e,t,r,i){return!1===this.scopedArrays.has(e)&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:i}),e}getScopedArrays(e){if("compute"!==e)return;let t=[];for(let{name:e,scope:r,bufferType:i,bufferCount:s}of this.scopedArrays.values()){let n=this.getType(i);t.push(`var<${r}> ${e}: array< ${n}, ${s} >;`)}return t.join("\n")}getAttributes(e){let t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),"vertex"===e||"compute"===e){let e=this.getBuiltins("attribute");e&&t.push(e);let r=this.getAttributesArray();for(let e=0,i=r.length;e<i;e++){let i=r[e],s=i.name,n=this.getType(i.type);t.push(`@location( ${e} ) ${s} : ${n}`)}}return t.join(",\n	")}getStructMembers(e){let t=[];for(let r of e.members){let i=e.output?"@location( "+r.index+" ) ":"",s=this.getType(r.type);r.atomic&&(s="atomic< "+s+" >"),t.push(`	${i+r.name} : ${s}`)}return e.output&&t.push(`	${this.getBuiltins("output")}`),t.join(",\n")}getStructs(e){let t="",r=this.structs[e];if(r.length>0){let e=[];for(let t of r){let r=`struct ${t.name} {
208`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null){let i=`var ${t} : `;return null!==r?i+=this.generateArrayDeclaration(e,r):i+=this.getType(e),i}getVars(e){let t=[],r=this.vars[e];if(void 0!==r)for(let e of r)t.push(`	${this.getVar(e.type,e.name,e.count)};`);return`
209${t.join("\n")}
210`}getVaryings(e){let t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),"vertex"===e||"fragment"===e){let r=this.varyings,i=this.vars[e];for(let s=0;s<r.length;s++){let n=r[s];if(n.needsInterpolation){let e=`@location( ${s} )`;if(n.interpolationType){let t=null!==n.interpolationSampling?`, ${n.interpolationSampling} )`:" )";e+=` @interpolate( ${n.interpolationType}${t}`}
210else/^(int|uint|ivec|uvec)/.test(n.type)&&(e+=` @interpolate( ${this.renderer.backend.compatibilityMode?"flat, either":"flat"} )`);t.push(`${e} ${n.name} : ${this.getType(n.type)}`)}else"vertex"===e&&!1===i.includes(n)&&i.push(n)}}let r=this.getBuiltins(e);r&&t.push(r);let i=t.join(",\n	");return"vertex"===e?this._getWGSLStruct("VaryingsStruct","	"+i):i}isCustomStruct(e){let t=e.value,r=e.node,i=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&null!==r.structTypeNode,s=r.value&&r.value.array&&"number"==typeof r.value.itemSize&&r.value.array.length>r.value.itemSize;return i&&!s}getUniforms(e){let t=this.uniforms[e],r=[],i=[],s=[],n={};for(let s of t){let t=s.groupNode.name,a=this.bindingsIndexes[t];if("texture"===s.type||"cubeTexture"===s.type||"storageTexture"===s.type||"texture3D"===s.type){let t,i=s.node.value;!1===this.isUnfilterable(i)&&!0!==s.node.isStorageTextureNode&&(this.isSampleCompare(i)?r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${s.name}_sampler : sampler_comparison;`):r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${s.name}_sampler : sampler;`));let n="",{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(i);if(o>1&&(n="_multisampled"),!0===i.isCubeTexture)t="texture_cube<f32>";else if(!0===i.isDepthTexture)t=this.renderer.backend.compatibilityMode&&null===i.compareFunction?`texture${n}_2d<f32>`:`texture_depth${n}_2d${!0===i.isArrayTexture?"_array":""}`;else if(!0===s.node.isStorageTextureNode){let r=yn(i),n=this.getStorageAccess(s.node,e),a=s.node.value.is3DTexture,o=s.node.value.isArrayTexture,l=a?"3d":`2d${o?"_array":""}`;t=`texture_storage_${l}<${r}, ${n}>`}else if(!0===i.isArrayTexture||!0===i.isDataArrayTexture||!0===i.isCompressedArrayTexture)t="texture_2d_array<f32>";else if(!0===i.is3DTexture||!0===i.isData3DTexture)t="texture_3d<f32>";else{let e=this.getComponentTypeFromTexture(i).charAt(0);t=`texture${n}_2d<${e}32>`}r.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var ${s.name} : ${t};`)}else if("buffer"===s.type||"storageBuffer"===s.type||"indirectStorageBuffer"===s.type){let t=s.node,r=this.getType(t.getNodeType(this)),n=t.bufferCount,o=n>0&&"buffer"===s.type?", "+n:"",l=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(s))i.push(`@binding( ${a.binding++} ) @group( ${a.group} ) var<${l}> ${s.name} : ${r};`);else{let e=t.isAtomic?`atomic<${r}>`:`${r}`,n=`	value : array< ${e}${o} >`;i.push(this._getWGSLStructBinding(s.name,n,l,a.binding++,a.group))}}else{let e=this.getType(this.getVectorType(s.type)),t=s.groupNode.name;(n[t]||(n[t]={index:a.binding++,id:a.group,snippets:[]})).snippets.push(`	${s.name} : ${e}`)}}for(let e in n){let t=n[e];s.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let a=r.join("\n");return a+=i.join("\n"),a+=s.join("\n")}buildCode(){let e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};for(let t in this.sortBindingGroups(),e){this.shaderStage=t;let r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let i="// code\n\n";i+=this.flowCode[t];let s=this.flowNodes[t],n=s[s.length-1],a=n.outputNode,o=void 0!==a&&!0===a.isOutputStructNode;for(let e of s){let s=this.getFlowData(e),l=e.name;if(l&&(i.length>0&&(i+="\n"),i+=`	// flow -> ${l}
211`),i+=`${s.code}
212	`,e===n&&"compute"!==t){if(i+="// result\n\n	","vertex"===t)i+=`varyings.Vertex = ${s.result};`;else if("fragment"===t)if(o)r.returnType=a.getNodeType(this),r.structs+="var<private> output : "+r.returnType+";",i+=`return ${s.result};`;else{let e="	@location(0) color: vec4<f32>",t=this.getBuiltins("output");t&&(e+=",\n	"+t),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",e),r.structs+="\nvar<private> output : OutputStruct;",i+=`output.color = ${s.result};
213
214	return output;`}}}r.flow=i}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){let t=this.getType(e);return`bitcast<${t}>`}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return yy[e]||e}isAvailable(e){let t=ym[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),ym[e]=t),t}_getWGSLMethod(e){return void 0!==yx[e]&&this._include(e),yT[e]}_include(e){let t=yx[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}
214_getWGSLVertexCode(e){return`${this.getSignature()}
215// directives
216${e.directives}
217
218// structs
219${e.structs}
220
221// uniforms
222${e.uniforms}
223
224// varyings
225${e.varyings}
226var<private> varyings : VaryingsStruct;
227
228// codes
229${e.codes}
230
231@vertex
232fn main( ${e.attributes} ) -> VaryingsStruct {
233
234	// vars
235	${e.vars}
236
237	// flow
238	${e.flow}
239
240	return varyings;
241
242}
243`}_getWGSLFragmentCode(e){return`${this.getSignature()}
244// global
245${y_}
246
247// structs
248${e.structs}
249
250// uniforms
251${e.uniforms}
252
253// codes
254${e.codes}
255
256@fragment
257fn main( ${e.varyings} ) -> ${e.returnType} {
258
259	// vars
260	${e.vars}
261
262	// flow
263	${e.flow}
264
265}
266`}_getWGSLComputeCode(e,t){let[r,i,s]=t;return`${this.getSignature()}
267// directives
268${e.directives}
269
270// system
271var<private> instanceIndex : u32;
272
273// locals
274${e.scopedArrays}
275
276// structs
277${e.structs}
278
279// uniforms
280${e.uniforms}
281
282// codes
283${e.codes}
284
285@compute @workgroup_size( ${r}, ${i}, ${s} )
286fn main( ${e.attributes} ) {
287
288	// system
289	instanceIndex = globalId.x
290		+ globalId.y * ( ${r} * numWorkgroups.x )
291		+ globalId.z * ( ${r} * numWorkgroups.x ) * ( ${i} * numWorkgroups.y );
292
293	// vars
294	${e.vars}
295
296	// flow
297	${e.flow}
298
299}
300`}_getWGSLStruct(e,t){return`
301struct ${e} {
302${t}
303};`}_getWGSLStructBinding(e,t,r,i=0,s=0){let n=e+"Struct",a=this._getWGSLStruct(n,t);return`${a}
304@binding( ${i} ) @group( ${s} )
305var<${r}> ${e} : ${n};`}}class yN{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=fW.Depth24PlusStencil8:e.depth&&(t=fW.Depth24Plus),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,r=e.getRenderTarget();t=r?r.samples:e.samples}else e.renderTarget&&(t=e.renderTarget.samples);let r=(t=t||1)>1&&null!==e.renderTarget&&!0!==e.isDepthTexture&&!0!==e.isFramebufferTexture,i=r?1:t;return{samples:t,primarySamples:i,isMSAA:r}}getCurrentColorFormat(e){return null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat()}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?fO.PointList:e.isLineSegments||e.isMesh&&!0===t.wireframe?fO.LineList:e.isLine?fO.LineStrip:e.isMesh?fO.TriangleList:void 0}getSampleCount(e){return e>=4?4:1}
305getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(void 0===e)return navigator.gpu.getPreferredCanvasFormat();if(e===u.OUM)return fW.BGRA8Unorm;if(e===u.ix0)return fW.RGBA16Float;throw Error("Unsupported outputType")}}let yS=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);"undefined"!=typeof Float16Array&&yS.set(Float16Array,["float16"]);let yR=new Map([[u.Oax,["float16"]]]),yA=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class yE{constructor(e){this.backend=e}createAttribute(e,t){let r=this._getBufferAttribute(e),i=this.backend,s=i.get(r),n=s.buffer;if(void 0===n){let a=i.device,o=r.array;if(!1===e.normalized){if(o.constructor===Int16Array||o.constructor===Int8Array)o=new Int32Array(o);else if((o.constructor===Uint16Array||o.constructor===Uint8Array)&&(o=new Uint32Array(o),t&GPUBufferUsage.INDEX))for(let e=0;e<o.length;e++)65535===o[e]&&(o[e]=0xffffffff)}if(r.array=o,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&3===r.itemSize){o=new o.constructor(4*r.count);for(let e=0;e<r.count;e++)o.set(r.array.subarray(3*e,3*e+3),4*e);r.itemSize=4,r.array=o,s._force3to4BytesAlignment=!0}let l=o.byteLength;n=a.createBuffer({label:r.name,size:l+(4-l%4)%4,usage:t,mappedAtCreation:!0}),new o.constructor(n.getMappedRange()).set(o),n.unmap(),s.buffer=n}}updateAttribute(e){let t=this._getBufferAttribute(e),r=this.backend,i=r.device,s=r.get(t),n=r.get(t).buffer,a=t.array;if(!0===s._force3to4BytesAlignment){a=new a.constructor(4*t.count);for(let e=0;e<t.count;e++)a.set(t.array.subarray(3*e,3*e+3),4*e);t.array=a}let o=this._isTypedArray(a),l=t.updateRanges;if(0===l.length)i.queue.writeBuffer(n,0,a,0);else{let e=o?1:a.BYTES_PER_ELEMENT;for(let t=0,r=l.length;t<r;t++){let r,u,d=l[t];if(!0===s._force3to4BytesAlignment){let t=Math.floor(d.start/3),i=Math.ceil(d.count/3);r=4*t*e,u=4*i*e}else r=d.start*e,u=d.count*e;let h=r*(o?a.BYTES_PER_ELEMENT:1);i.queue.writeBuffer(n,h,a,r,u)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){let t=e.getAttributes(),r=new Map;for(let e=0;e<t.length;e++){let i=t[e],s=i.array.BYTES_PER_ELEMENT,n=this._getBufferAttribute(i),a=r.get(n);if(void 0===a){let e,t;!0===i.isInterleavedBufferAttribute?(e=i.data.stride*s,t=i.data.isInstancedInterleavedBuffer?f6.Instance:f6.Vertex):(e=i.itemSize*s,t=i.isInstancedBufferAttribute?f6.Instance:f6.Vertex),!1===i.normalized&&(i.array.constructor===Int16Array||i.array.constructor===Uint16Array)&&(e=4),a={arrayStride:e,attributes:[],stepMode:t},r.set(n,a)}let o=this._getVertexFormat(i),l=!0===i.isInterleavedBufferAttribute?i.offset*s:0;a.attributes.push({shaderLocation:e,offset:l,format:o})}return Array.from(r.values())}destroyAttribute(e){let t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e){let t=this.backend,r=t.device,i=t.get(this._getBufferAttribute(e)).buffer,s=i.size,n=r.createBuffer({label:`${e.name}_readback`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),a=r.createCommandEncoder({label:`readback_encoder_${e.name}`});a.copyBufferToBuffer(i,0,n,0,s);let o=a.finish();r.queue.submit([o]),await n.mapAsync(GPUMapMode.READ);let l=n.getMappedRange(),u=new e.array.constructor(l.slice(0));return n.unmap(),u.buffer}_getVertexFormat(e){let t,{itemSize:r,normalized:i}=e,s=e.array.constructor,n=e.constructor;if(1===r)t=yA.get(s);else{let e=(yR.get(n)||yS.get(s))[+!!i];if(e){let i=4*Math.floor((s.BYTES_PER_ELEMENT*r+3)/4)/s.BYTES_PER_ELEMENT;if(i%1)throw Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");t=`${e}x${i}`}}return t||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),t}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class yC{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){let t=this.backend,r=t.device,i=[],s=0;for(let r of e.bindings){let e={binding:s++,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){let t={};r.isStorageBuffer&&(4&r.visibility&&(r.access===M.READ_WRITE||r.access===M.WRITE_ONLY)?t.type=fZ.Storage:t.type=fZ.ReadOnlyStorage),e.buffer=t}else if(r.isSampledTexture&&r.store){let t={};t.format=this.backend.get(r.texture).texture.format;let i=r.access;i===M.READ_WRITE?t.access=fJ.ReadWrite:i===M.WRITE_ONLY?t.access=fJ.WriteOnly:t.access=fJ.ReadOnly,r.texture.isArrayTexture?t.viewDimension=f3.TwoDArray:r.texture.is3DTexture&&(t.viewDimension=f3.ThreeD),e.storageTexture=t}else if(r.isSampledTexture){let i={},{primarySamples:s}=t.utils.getTextureSampleData(r.texture);if(s>1&&(i.multisampled=!0,r.texture.isDepthTexture||(i.sampleType=f1.UnfilterableFloat)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?i.sampleType=f1.UnfilterableFloat:i.sampleType=f1.Depth;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){let e=r.texture.type;e===u.Yuy?i.sampleType=f1.SInt:e===u.bkx?i.sampleType=f1.UInt:e===u.RQf&&(this.backend.hasFeature("float32-filterable")?i.sampleType=f1.Float:i.sampleType=f1.UnfilterableFloat)}r.isSampledCubeTexture?i.viewDimension=f3.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?i.viewDimension=f3.TwoDArray:r.isSampledTexture3D&&(i.viewDimension=f3.ThreeD),e.texture=i}else if(r.isSampler){let i={};r.texture.isDepthTexture&&(null!==r.texture.compareFunction?i.type=f0.Comparison:t.compatibilityMode&&(i.type=f0.NonFiltering)),e.sampler=i}else console.error(`WebGPUBindingUtils: Unsupported binding "${r}".`);i.push(e)}return r.createBindGroupLayout({entries:i})}createBindings(e,t,r,i=0){let s,{backend:n,bindGroupLayoutCache:a}=this,o=n.get(e),l=a.get(e.bindingsReference);void 0===l&&(l=this.createBindingsLayout(e),a.set(e.bindingsReference,l)),r>0&&(void 0===o.groups&&(o.groups=[],o.versions=[]),o.versions[r]===i&&(s=o.groups[r])),void 0===s&&(s=this.createBindGroup(e,l),r>0&&(o.groups[r]=s,o.versions[r]=i)),o.group=s,o.layout=l}updateBinding(e){let t=this.backend,r=t.device,i=e.buffer,s=t.get(e).buffer;r.queue.writeBuffer(s,0,i,0)}createBindGroupIndex(e,t){let r=this.backend.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=e[0],n=r.createBuffer({label:"bindingCameraIndex_"+s,size:16,usage:i});r.queue.writeBuffer(n,0,e,0);let a=[{binding:0,resource:{buffer:n}
305}];return r.createBindGroup({label:"bindGroupCameraIndex_"+s,layout:t,entries:a})}createBindGroup(e,t){let r=this.backend,i=r.device,s=0,n=[];for(let t of e.bindings){if(t.isUniformBuffer){let e=r.get(t);if(void 0===e.buffer){let r=t.byteLength,s=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST;e.buffer=i.createBuffer({label:"bindingBuffer_"+t.name,size:r,usage:s})}n.push({binding:s,resource:{buffer:e.buffer}})}else if(t.isStorageBuffer){let e=r.get(t);if(void 0===e.buffer){let i=t.attribute;e.buffer=r.get(i).buffer}n.push({binding:s,resource:{buffer:e.buffer}})}else if(t.isSampledTexture){let e,a=r.get(t.texture);if(void 0!==a.externalTexture)e=i.importExternalTexture({source:a.externalTexture});else{let r=t.store?1:a.texture.mipLevelCount,i=`view-${a.texture.width}-${a.texture.height}`;if(a.texture.depthOrArrayLayers>1&&(i+=`-${a.texture.depthOrArrayLayers}`),i+=`-${r}`,void 0===(e=a[i])){let s,n=f4.All;s=t.isSampledCubeTexture?f3.Cube:t.isSampledTexture3D?f3.ThreeD:t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?f3.TwoDArray:f3.TwoD,e=a[i]=a.texture.createView({aspect:n,dimension:s,mipLevelCount:r})}}n.push({binding:s,resource:e})}else if(t.isSampler){let e=r.get(t.texture);n.push({binding:s,resource:e.sampler})}s++}return i.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:n})}}class yw{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let r,{object:i,material:s,geometry:n,pipeline:a}=e,{vertexProgram:o,fragmentProgram:l}=a,d=this.backend,h=d.device,c=d.utils,p=d.get(a),g=[];for(let t of e.getBindings()){let e=d.get(t);g.push(e.layout)}let m=d.attributeUtils.createShaderVertexBuffers(e);s.blending!==u.XIg&&(s.blending!==u.NTi||!1!==s.transparent)&&(r=this._getBlending(s));let f={};!0===s.stencilWrite&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});let y=this._getColorWriteMask(s),b=[];if(null!==e.context.textures){let t=e.context.textures;for(let e=0;e<t.length;e++){let i=c.getTextureFormatGPU(t[e]);b.push({format:i,blend:r,writeMask:y})}}else{let t=c.getCurrentColorFormat(e.context);b.push({format:t,blend:r,writeMask:y})}let x=d.get(o).module,T=d.get(l).module,_=this._getPrimitiveState(i,n,s),v=this._getDepthCompare(s),N=c.getCurrentDepthStencilFormat(e.context),S=this._getSampleCount(e.context),R={label:`renderPipeline_${s.name||s.type}_${s.id}`,vertex:Object.assign({},x,{buffers:m}),fragment:Object.assign({},T,{targets:b}),primitive:_,multisample:{count:S,alphaToCoverageEnabled:s.alphaToCoverage&&S>1},layout:h.createPipelineLayout({bindGroupLayouts:g})},A={},E=e.context.depth,C=e.context.stencil;if((!0===E||!0===C)&&(!0===E&&(A.format=N,A.depthWriteEnabled=s.depthWrite,A.depthCompare=v),!0===C&&(A.stencilFront=f,A.stencilBack={},A.stencilReadMask=s.stencilFuncMask,A.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(A.depthBias=s.polygonOffsetUnits,A.depthBiasSlopeScale=s.polygonOffsetFactor,A.depthBiasClamp=0),R.depthStencil=A),null===t)p.pipeline=h.createRenderPipeline(R);else{let e=new Promise(e=>{h.createRenderPipelineAsync(R).then(t=>{p.pipeline=t,e()})});t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){let{utils:r,device:i}=this.backend,s=r.getCurrentDepthStencilFormat(e),n=r.getCurrentColorFormat(e),a=this._getSampleCount(e);return i.createRenderBundleEncoder({label:t,colorFormats:[n],depthStencilFormat:s,sampleCount:a})}createComputePipeline(e,t){let r=this.backend,i=r.device,s=r.get(e.computeProgram).module,n=r.get(e),a=[];for(let e of t){let t=r.get(e);a.push(t.layout)}n.pipeline=i.createComputePipeline({compute:s,layout:i.createPipelineLayout({bindGroupLayouts:a})})}_getBlending(e){let t,r,i=e.blending,s=e.blendSrc,n=e.blendDst,a=e.blendEquation;if(i===u.bCz){let i=null!==e.blendSrcAlpha?e.blendSrcAlpha:s,o=null!==e.blendDstAlpha?e.blendDstAlpha:n,l=null!==e.blendEquationAlpha?e.blendEquationAlpha:a;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(a)},r={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(l)}}else{let s=e.premultipliedAlpha,n=(e,i,s,n)=>{t={srcFactor:e,dstFactor:i,operation:fK.Add},r={srcFactor:s,dstFactor:n,operation:fK.Add}};if(s)switch(i){case u.NTi:n(fX.One,fX.OneMinusSrcAlpha,fX.One,fX.OneMinusSrcAlpha);break;case u.EZo:n(fX.One,fX.One,fX.One,fX.One);break;case u.Kwu:n(fX.Zero,fX.OneMinusSrc,fX.Zero,fX.One);break;case u.EdD:n(fX.Dst,fX.OneMinusSrcAlpha,fX.Zero,fX.One)}else switch(i){case u.NTi:n(fX.SrcAlpha,fX.OneMinusSrcAlpha,fX.One,fX.OneMinusSrcAlpha);break;case u.EZo:n(fX.SrcAlpha,fX.One,fX.One,fX.One);break;case u.Kwu:console.error("THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case u.EdD:console.error("THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true")}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};console.error("THREE.WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;
305switch(e){case u.ojh:t=fX.Zero;break;case u.qad:t=fX.One;break;case u.f4X:t=fX.Src;break;case u.LiQ:t=fX.OneMinusSrc;break;case u.ie2:t=fX.SrcAlpha;break;case u.OuU:t=fX.OneMinusSrcAlpha;break;case u.wn6:t=fX.Dst;break;case u.aEY:t=fX.OneMinusDst;break;case u.hdd:t=fX.DstAlpha;break;case u.Nt7:t=fX.OneMinusDstAlpha;break;case u.hgQ:t=fX.SrcAlphaSaturated;break;case 211:t=fX.Constant;break;case 212:t=fX.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t,r=e.stencilFunc;switch(r){case u.HPb:t=fV.Never;break;case u.sKt:t=fV.Always;break;case u.kYr:t=fV.Less;break;case u.CR7:t=fV.LessEqual;break;case u.jsO:t=fV.Equal;break;case u.TMh:t=fV.GreaterEqual;break;case u.RcT:t=fV.Greater;break;case u.klZ:t=fV.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case u.VVr:t=fY.Keep;break;case u.kqe:t=fY.Zero;break;case u.kG0:t=fY.Replace;break;case u.oVO:t=fY.Invert;break;case u.HLH:t=fY.IncrementClamp;break;case u.ROr:t=fY.DecrementClamp;break;case u.Ru$:t=fY.IncrementWrap;break;case u.fJr:t=fY.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case u.gO9:t=fK.Add;break;case u.FXf:t=fK.Subtract;break;
305case u.nST:t=fK.ReverseSubtract;break;case u.znC:t=fK.Min;break;case u.$ei:t=fK.Max;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){let i={};i.topology=this.backend.utils.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?fH.Uint16:fH.Uint32);let s=r.side===u.hsX;return e.isMesh&&0>e.matrixWorld.determinant()&&(s=!s),i.frontFace=!0===s?fz.CW:fz.CCW,i.cullMode=r.side===u.$EB?f$.None:f$.Back,i}_getColorWriteMask(e){return!0===e.colorWrite?fQ.All:fQ.None}_getDepthCompare(e){let t;if(!1===e.depthTest)t=fV.Always;else{let r=e.depthFunc;switch(r){case u.eHc:t=fV.Never;break;case u.lGu:t=fV.Always;break;case u.brA:t=fV.Less;break;case u.xSv:t=fV.LessEqual;break;case u.U3G:t=fV.Equal;break;case u.Gwm:t=fV.GreaterEqual;break;case u.K52:t=fV.Greater;break;case u.bw0:t=fV.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class yM extends fU{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});let i=8*this.maxQueries;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return(0,u.mcG)(`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,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();let i=this.device.createCommandEncoder();i.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),i.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);let s=i.finish();if(this.device.queue.submit([s]),"unmapped"!==this.resultBuffer.mapState)return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return"mapped"===this.resultBuffer.mapState&&this.resultBuffer.unmap(),this.lastValue;let n=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),a=0;for(let[,t]of e){let e=n[t],r=n[t+1],i=Number(r-e)/1e6;a+=i}return this.resultBuffer.unmap(),this.lastValue=a,a}catch(e){return console.error("Error resolving queries:",e),"mapped"===this.resultBuffer.mapState&&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&&"mapped"===this.resultBuffer.mapState)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}}}class yB extends fx{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.compatibilityMode=void 0!==e.compatibilityMode&&e.compatibilityMode,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new yN(this),this.attributeUtils=new yE(this),this.bindingUtils=new yC(this),this.pipelineUtils=new yw(this),this.textureUtils=new ys(this),this.occludedResolveCache=new Map}async init(e){let t;await super.init(e);let r=this.parameters;if(void 0===r.device){let e={powerPreference:r.powerPreference,featureLevel:r.compatibilityMode?"compatibility":void 0},i="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===i)throw Error("WebGPUBackend: Unable to create WebGPU adapter.");let s=Object.values(f8),n=[];for(let e of s)i.features.has(e)&&n.push(e);let a={requiredFeatures:n,requiredLimits:r.requiredLimits};t=await i.requestDevice(a)}else t=r.device;t.lost.then(t=>{let r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)});let i=void 0!==r.context?r.context:e.domElement.getContext("webgpu");this.device=t,this.context=i;let s=r.alpha?"premultiplied":"opaque",n=u.ppV.getToneMappingMode(this.renderer.outputColorSpace);this.context.configure({device:this.device,format:this.utils.getPreferredCanvasF
305ormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,toneMapping:{mode:n}}),this.trackTimestamp=this.trackTimestamp&&this.hasFeature(f8.TimestampQuery),this.updateSize()}get coordinateSystem(){return u.i7u}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){let t=this.renderer;e={colorAttachments:[{view:null}]},(!0===this.renderer.depth||!0===this.renderer.stencil)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()});let r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.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 r=e.renderTarget,i=this.get(r),s=i.descriptors;(void 0===s||i.width!==r.width||i.height!==r.height||i.samples!==r.samples)&&(i.descriptors=s={});let n=e.getCacheKey(),a=s[n];if(void 0===a){let t,o=e.textures,l=[],u=this._isRenderCameraDepthArray(e);for(let i=0;i<o.length;i++){let s=this.get(o[i]),n={label:`colorAttachment_${i}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:f3.TwoD};if(r.isRenderTarget3D)t=e.activeCubeFace,n.baseArrayLayer=0,n.dimension=f3.ThreeD,n.depthOrArrayLayers=o[i].image.depth;else if(r.isRenderTarget&&o[i].image.depth>1)if(!0===u){let t=e.camera.cameras;for(let e=0;e<t.length;e++){let t={...n,baseArrayLayer:e,arrayLayerCount:1,dimension:f3.TwoD},r=s.texture.createView(t);l.push({view:r,resolveTarget:void 0,depthSlice:void 0})}}else n.dimension=f3.TwoDArray,n.depthOrArrayLayers=o[i].image.depth;if(!0!==u){let e,r,i=s.texture.createView(n);void 0!==s.msaaTexture?(e=s.msaaTexture.createView(),r=i):(e=i,r=void 0),l.push({view:e,resolveTarget:r,depthSlice:t})}}if(a={textureViews:l},e.depth){let t=this.get(e.depthTexture),r={};e.depthTexture.isArrayTexture&&(r.dimension=f3.TwoD,r.arrayLayerCount=1,r.baseArrayLayer=e.activeCubeFace),a.depthStencilView=t.texture.createView(r)}s[n]=a,i.width=r.width,i.height=r.height,i.samples=r.samples,i.activeMipmapLevel=e.activeMipmapLevel,i.activeCubeFace=e.activeCubeFace}let o={colorAttachments:[]};for(let e=0;e<a.textureViews.length;e++){let r=a.textureViews[e],i={r:0,g:0,b:0,a:1};0===e&&t.clearValue&&(i=t.clearValue),o.colorAttachments.push({view:r.view,depthSlice:r.depthSlice,resolveTarget:r.resolveTarget,loadOp:t.loadOp||fk.Load,storeOp:t.storeOp||fG.Store,clearValue:i})}return a.depthStencilView&&(o.depthStencilAttachment={view:a.depthStencilView}),o}beginRender(e){let t,r,i=this.get(e);i.frameCalls=this.renderer.info.render.frameCalls;let s=this.device,n=e.occlusionQueryCount;n>0&&(i.currentOcclusionQuerySet&&i.currentOcclusionQuerySet.destroy(),i.currentOcclusionQueryBuffer&&i.currentOcclusionQueryBuffer.destroy(),i.currentOcclusionQuerySet=i.occlusionQuerySet,i.currentOcclusionQueryBuffer=i.occlusionQueryBuffer,i.currentOcclusionQueryObjects=i.occlusionQueryObjects,i.occlusionQuerySet=t=s.createQuerySet({type:"occlusion",count:n,label:`occlusionQuerySet_${e.id}`}),i.occlusionQueryIndex=0,i.occlusionQueryObjects=Array(n),i.lastOcclusionObject=null),r=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:fk.Load}),this.initTimestampQuery(u.v9J.RENDER,this.getTimestampUID(e),r),r.occlusionQuerySet=t;let a=r.depthStencilAttachment;if(null!==e.textures){let t=r.colorAttachments;for(let r=0;r<t.length;r++){let i=t[r];e.clearColor?(i.clearValue=0===r?e.clearColorValue:{r:0,g:0,b:0,a:1},i.loadOp=fk.Clear):i.loadOp=fk.Load,i.storeOp=fG.Store}}else{let t=r.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=fk.Clear):t.loadOp=fk.Load,t.storeOp=fG.Store}e.depth&&(e.clearDepth?(a.depthClearValue=e.clearDepthValue,a.depthLoadOp=fk.Clear):a.depthLoadOp=fk.Load,a.depthStoreOp=fG.Store),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=fk.Clear):a.stencilLoadOp=fk.Load,a.stencilStoreOp=fG.Store);let o=s.createCommandEncoder({label:"renderContext_"+e.id});if(!0===this._isRenderCameraDepthArray(e)){let t=e.camera.cameras;i.layerDescriptors&&i.layerDescriptors.length===t.length?this._updateDepthLayerDescriptors(e,i,t):this._createDepthLayerDescriptors(e,i,r,t),i.bundleEncoders=[],i.bundleSets=[];for(let r=0;r<t.length;r++){let t=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+r),s={attributes:{},bindingGroups:[],pipeline:null,index:null};i.bundleEncoders.push(t),i.bundleSets.push(s)}i.currentPass=null}else{let t=o.beginRenderPass(r);if(i.currentPass=t,e.viewport&&this.updateViewport(e),e.scissor){let{x:r,y:i,width:s,height:n}=e.scissorValue;
305t.setScissorRect(r,i,s,n)}}i.descriptor=r,i.encoder=o,i.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},i.renderBundles=[]}_createDepthLayerDescriptors(e,t,r,i){let s=r.depthStencilAttachment;t.layerDescriptors=[];let n=this.get(e.depthTexture);n.viewCache||(n.viewCache=[]);for(let a=0;a<i.length;a++){let i={...r,colorAttachments:[{...r.colorAttachments[0],view:r.colorAttachments[a].view}]};if(r.depthStencilAttachment){let t=a;n.viewCache[t]||(n.viewCache[t]=n.texture.createView({dimension:f3.TwoD,baseArrayLayer:a,arrayLayerCount:1})),i.depthStencilAttachment={view:n.viewCache[t],depthLoadOp:s.depthLoadOp||fk.Clear,depthStoreOp:s.depthStoreOp||fG.Store,depthClearValue:s.depthClearValue||1},e.stencil&&(i.depthStencilAttachment.stencilLoadOp=s.stencilLoadOp,i.depthStencilAttachment.stencilStoreOp=s.stencilStoreOp,i.depthStencilAttachment.stencilClearValue=s.stencilClearValue)}else i.depthStencilAttachment={...s};t.layerDescriptors.push(i)}}_updateDepthLayerDescriptors(e,t,r){for(let i=0;i<r.length;i++){let r=t.layerDescriptors[i];if(r.depthStencilAttachment){let t=r.depthStencilAttachment;e.depth&&(e.clearDepth?(t.depthClearValue=e.clearDepthValue,t.depthLoadOp=fk.Clear):t.depthLoadOp=fk.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=fk.Clear):t.stencilLoadOp=fk.Load)}}}finishRender(e){let t=this.get(e),r=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let i=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){let r=[];for(let e=0;e<t.bundleEncoders.length;e++){let i=t.bundleEncoders[e];r.push(i.finish())}for(let s=0;s<t.layerDescriptors.length;s++)if(s<r.length){let n=t.layerDescriptors[s],a=i.beginRenderPass(n);if(e.viewport){let{x:t,y:r,width:i,height:s,minDepth:n,maxDepth:o}=e.viewportValue;a.setViewport(t,r,i,s,n,o)}if(e.scissor){let{x:t,y:r,width:i,height:s}=e.scissorValue;a.setScissorRect(t,r,i,s)}a.executeBundles([r[s]]),a.end()}}else t.currentPass&&t.currentPass.end();if(r>0){let i=8*r,s=this.occludedResolveCache.get(i);void 0===s&&(s=this.device.createBuffer({size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(i,s));let n=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,s,0),t.encoder.copyBufferToBuffer(s,0,n,0,i),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),null!==e.textures){let t=e.textures;for(let e=0;e<t.length;e++){let r=t[e];!0===r.generateMipmaps&&this.textureUtils.generateMipmaps(r)}}}isOccluded(e,t){let r=this.get(e);return r.occluded&&r.occluded.has(t)}async resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueryBuffer:r,currentOcclusionQueryObjects:i}=t;if(r&&i){let e=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,await r.mapAsync(GPUMapMode.READ);let s=new BigUint64Array(r.getMappedRange());for(let t=0;t<i.length;t++)s[t]===BigInt(0)&&e.add(i[t]);r.destroy(),t.occluded=e}}updateViewport(e){let{currentPass:t}=this.get(e),{x:r,y:i,width:s,height:n,minDepth:a,maxDepth:o}=e.viewportValue;t.setViewport(r,i,s,n,a,o)}getClearColor(){let e=super.getClearColor();return!0===this.renderer.alpha&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,r,i=null){let s,n,a,o,l=this.device,u=this.renderer,d=[];if(e){let e=this.getClearColor();n={r:e.r,g:e.g,b:e.b,a:e.a}}if(null===i){a=u.depth,o=u.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){let e=(d=t.colorAttachments)[0];e.clearValue=n,e.loadOp=fk.Clear,e.storeOp=fG.Store}(a||o)&&(s=t.depthStencilAttachment)}else{a=i.depth,o=i.stencil;let l={loadOp:e?fk.Clear:fk.Load,clearValue:e?n:void 0};a&&(l.depthLoadOp=t?fk.Clear:fk.Load,l.depthClearValue=t?u.getClearDepth():void 0,l.depthStoreOp=fG.Store),o&&(l.stencilLoadOp=r?fk.Clear:fk.Load,l.stencilClearValue=r?u.getClearStencil():void 0,l.stencilStoreOp=fG.Store);let h=this._getRenderPassDescriptor(i,l);d=h.colorAttachments,s=h.depthStencilAttachment}a&&s&&(t?(s.depthLoadOp=fk.Clear,s.depthClearValue=u.getClearDepth()):s.depthLoadOp=fk.Load,s.depthStoreOp=fG.Store),o&&s&&(r?(s.stencilLoadOp=fk.Clear,s.stencilClearValue=u.getClearStencil()):s.stencilLoadOp=fk.Load,s.stencilStoreOp=fG.Store);let h=l.createCommandEncoder({label:"clear"});h.beginRenderPass({colorAttachments:d,depthStencilAttachment:s}).end(),l.queue.submit([h.finish()])}beginCompute(e){let t=this.get(e);t.frameCalls=this.renderer.info.compute.frameCalls;let r={label:"computeGroup_"+e.id};this.initTimestampQuery(u.v9J.COMPUTE,this.getTimestampUID(e),r),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(r)}compute(e,t,r,i,s=null){let n,a=this.get(t),{passEncoderGPU:o}=this.get(e),l=this.get(i).pipeline;this.pipelineUtils.setPipeline(o,l);for(let e=0,t=r.length;e<t;e++){let t=r[e],i=this.get(t);o.setBindGroup(e,i.group)}if(null===s&&(s=t.count),"number"==typeof s){let e=s;if(void 0===a.dispatchSize||a.count!==e){a.dispatchSize=[0,1,1],a.count=e;let r=t.workgroupSize,i=r[0];for(let e=1;e<r.length;e++)i*=r[e];let s=Math.ceil(e/i),o=this.device.limits.maxComputeWorkgroupsPerDimension;n=[s,1,1],s>o&&(n[0]=Math.min(s,o),n[1]=Math.ceil(s/o)),a.dispatchSize=n}n=a.dispatchSize}else n=s;o.dispatchWorkgroups(n[0],n[1]||1,n[2]||1)}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:r,material:i,context:s,pipeline:n}=e,a=e.getBindings(),o=this.get(s),l=this.get(n).pipeline,d=e.getIndex(),h=null!==d,c=e.getDrawParameters();if(null===c)return;let p=(t,r)=>{this.pipelineUtils.setPipeline(t,l),r.pipeline=l;let n=r.bindingGroups;for(let e=0,r=a.length;e<r;e++){let r=a[e],i=this.get(r);n[r.index]!==r.id&&(t.setBindGroup(r.index,i.group),n[r.index]=r.id)}if(!0===h&&r.index!==d){let e=this.get(d).buffer,i=d.array instanceof Uint16Array?fH.Uint16:fH.Uint32;t.setIndexBuffer(e,i),r.index=d}let u=e.getVertexBuffers();for(let e=0,i=u.length;e<i;e++){let i=u[e];
305if(r.attributes[e]!==i){let s=this.get(i).buffer;t.setVertexBuffer(e,s),r.attributes[e]=i}}!0===s.stencil&&!0===i.stencilWrite&&o.currentStencilRef!==i.stencilRef&&(t.setStencilReference(i.stencilRef),o.currentStencilRef=i.stencilRef)},g=(i,s)=>{if(p(i,s),!0===r.isBatchedMesh){let e=r._multiDrawStarts,s=r._multiDrawCounts,n=r._multiDrawCount,a=r._multiDrawInstances;null!==a&&(0,u.mcG)("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let o=0;o<n;o++){let n=a?a[o]:1,l=n>1?0:o;!0===h?i.drawIndexed(s[o],n,e[o]/d.array.BYTES_PER_ELEMENT,0,l):i.draw(s[o],n,e[o],l),t.update(r,s[o],n)}}else if(!0===h){let{vertexCount:s,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){let e=this.get(o).buffer;i.drawIndexedIndirect(e,0)}else i.drawIndexed(s,n,a,0,0);t.update(r,s,n)}else{let{vertexCount:s,instanceCount:n,firstVertex:a}=c,o=e.getIndirect();if(null!==o){let e=this.get(o).buffer;i.drawIndirect(e,0)}else i.draw(s,n,a,0);t.update(r,s,n)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let t=this.get(e.camera),i=e.camera.cameras,n=e.getBindingGroup("cameraIndex");if(void 0===t.indexesGPU||t.indexesGPU.length!==i.length){let e=this.get(n),r=[],s=new Uint32Array([0,0,0,0]);for(let t=0,n=i.length;t<n;t++){s[0]=t;let i=this.bindingUtils.createBindGroupIndex(s,e.layout);r.push(i)}t.indexesGPU=r}let a=this.renderer.getPixelRatio();for(let e=0,l=i.length;e<l;e++){let l=i[e];if(r.layers.test(l.layers)){let r=l.viewport,i=o.currentPass,u=o.currentSets;if(o.bundleEncoders){let t=o.bundleEncoders[e],r=o.bundleSets[e];i=t,u=r}r&&i.setViewport(Math.floor(r.x*a),Math.floor(r.y*a),Math.floor(r.width*a),Math.floor(r.height*a),s.viewportValue.minDepth,s.viewportValue.maxDepth),n&&t.indexesGPU&&(i.setBindGroup(n.index,t.indexesGPU[e]),u.bindingGroups[n.index]=n.id),g(i,u)}}}else if(o.currentPass){if(void 0!==o.occlusionQuerySet){let e=o.lastOcclusionObject;e!==r&&(null!==e&&!0===e.occlusionTest&&(o.currentPass.endOcclusionQuery(),o.occlusionQueryIndex++),!0===r.occlusionTest&&(o.currentPass.beginOcclusionQuery(o.occlusionQueryIndex),o.occlusionQueryObjects[o.occlusionQueryIndex]=r),o.lastOcclusionObject=r)}g(o.currentPass,o.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:r,material:i}=e,s=this.utils,n=s.getSampleCountRenderContext(e.context),a=s.getCurrentColorSpace(e.context),o=s.getCurrentColorFormat(e.context),l=s.getCurrentDepthStencilFormat(e.context),u=s.getPrimitiveTopology(r,i),d=!1;return(t.material!==i||t.materialVersion!==i.version||t.transparent!==i.transparent||t.blending!==i.blending||t.premultipliedAlpha!==i.premultipliedAlpha||t.blendSrc!==i.blendSrc||t.blendDst!==i.blendDst||t.blendEquation!==i.blendEquation||t.blendSrcAlpha!==i.blendSrcAlpha||t.blendDstAlpha!==i.blendDstAlpha||t.blendEquationAlpha!==i.blendEquationAlpha||t.colorWrite!==i.colorWrite||t.depthWrite!==i.depthWrite||t.depthTest!==i.depthTest||t.depthFunc!==i.depthFunc||t.stencilWrite!==i.stencilWrite||t.stencilFunc!==i.stencilFunc||t.stencilFail!==i.stencilFail||t.stencilZFail!==i.stencilZFail||t.stencilZPass!==i.stencilZPass||t.stencilFuncMask!==i.stencilFuncMask||t.stencilWriteMask!==i.stencilWriteMask||t.side!==i.side||t.alphaToCoverage!==i.alphaToCoverage||t.sampleCount!==n||t.colorSpace!==a||t.colorFormat!==o||t.depthStencilFormat!==l||t.primitiveTopology!==u||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=i,t.materialVersion=i.version,t.transparent=i.transparent,t.blending=i.blending,t.premultipliedAlpha=i.premultipliedAlpha,t.blendSrc=i.blendSrc,t.blendDst=i.blendDst,t.blendEquation=i.blendEquation,t.blendSrcAlpha=i.blendSrcAlpha,t.blendDstAlpha=i.blendDstAlpha,t.blendEquationAlpha=i.blendEquationAlpha,t.colorWrite=i.colorWrite,t.depthWrite=i.depthWrite,t.depthTest=i.depthTest,t.depthFunc=i.depthFunc,t.stencilWrite=i.stencilWrite,t.stencilFunc=i.stencilFunc,t.stencilFail=i.stencilFail,t.stencilZFail=i.stencilZFail,t.stencilZPass=i.stencilZPass,t.stencilFuncMask=i.stencilFuncMask,t.stencilWriteMask=i.stencilWriteMask,t.side=i.side,t.alphaToCoverage=i.alphaToCoverage,t.sampleC
305ount=n,t.colorSpace=a,t.colorFormat=o,t.depthStencilFormat=l,t.primitiveTopology=u,t.clippingContextCacheKey=e.clippingContextCacheKey,d=!0),d}getRenderCacheKey(e){let{object:t,material:r}=e,i=this.utils,s=e.context,n=t.isMesh&&0>t.matrixWorld.determinant();return[r.transparent,r.blending,r.premultipliedAlpha,r.blendSrc,r.blendDst,r.blendEquation,r.blendSrcAlpha,r.blendDstAlpha,r.blendEquationAlpha,r.colorWrite,r.depthWrite,r.depthTest,r.depthFunc,r.stencilWrite,r.stencilFunc,r.stencilFail,r.stencilZFail,r.stencilZPass,r.stencilFuncMask,r.stencilWriteMask,r.side,n,i.getSampleCountRenderContext(s),i.getCurrentColorSpace(s),i.getCurrentColorFormat(s),i.getCurrentDepthStencilFormat(s),i.getPrimitiveTopology(t,r),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,r,i,s,n){return this.textureUtils.copyTextureToBuffer(e,t,r,i,s,n)}initTimestampQuery(e,t,r){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new yM(this.device,e,2048));let i=this.timestampQueryPool[e],s=i.allocateQueriesForContext(t);r.timestampWrites={querySet:i.querySet,beginningOfPassWriteIndex:s,endOfPassWriteIndex:s+1}}createNodeBuilder(e,t){return new yv(e,t)}createProgram(e){this.get(e).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 r=this.get(e),i=r.currentPass.finish();this.get(t).bundleGPU=i,r.currentSets=r._currentSets,r.currentPass=r._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,r,i){this.bindingUtils.createBindings(e,t,r,i)}updateBindings(e,t,r,i){this.bindingUtils.createBindings(e,t,r,i)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}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,r=null,i=null,s=0,n=0){let a=0,o=0,l=0,u=0,d=0,h=0,c=e.image.width,p=e.image.height,g=1;null!==r&&(!0===r.isBox3?(u=r.min.x,d=r.min.y,h=r.min.z,c=r.max.x-r.min.x,p=r.max.y-r.min.y,g=r.max.z-r.min.z):(u=r.min.x,d=r.min.y,c=r.max.x-r.min.x,p=r.max.y-r.min.y,g=1)),null!==i&&(a=i.x,o=i.y,l=i.z||0);let m=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),f=this.get(e).texture,y=this.get(t).texture;m.copyTextureToTexture({texture:f,mipLevel:s,origin:{x:u,y:d,z:h}},{texture:y,mipLevel:n,origin:{x:a,y:o,z:l}},[c,p,g]),this.device.queue.submit([m.finish()]),0===n&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,r){let i,s=this.get(t),n=null;n=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(n.format!==a.format)return void console.error("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",n.format,a.format);if(s.currentPass?(s.currentPass.end(),i=s.encoder):i=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),i.copyTextureToTexture({texture:n,origin:[r.x,r.y,0]},{texture:a},[r.z,r.w]),s.currentPass){let{descriptor:e}=s;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=fk.Load;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=fk.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=fk.Load),s.currentPass=i.beginRenderPass(e),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){let{x:e,y:r,width:i,height:n}=t.scissorValue;
305s.currentPass.setScissorRect(e,r,i,n)}}else this.device.queue.submit([i.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}}class yL extends u.nCl{constructor(e,t,r,i,s,n){super(e,t,r,i,s,n),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class yP extends u.nCl{constructor(e,t,r,i,s,n){super(e,t,r,i,s,n),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class yF extends mO{constructor(){super(),this.addMaterial(lh,"MeshPhongMaterial"),this.addMaterial(uk,"MeshStandardMaterial"),this.addMaterial(u$,"MeshPhysicalMaterial"),this.addMaterial(uj,"MeshToonMaterial"),this.addMaterial(lr,"MeshBasicMaterial"),this.addMaterial(lu,"MeshLambertMaterial"),this.addMaterial(oJ,"MeshNormalMaterial"),this.addMaterial(uQ,"MeshMatcapMaterial"),this.addMaterial(oW,"LineBasicMaterial"),this.addMaterial(oj,"LineDashedMaterial"),this.addMaterial(u3,"PointsMaterial"),this.addMaterial(u0,"SpriteMaterial"),this.addMaterial(u5,"ShadowMaterial"),this.addLight(pj,u.HiM),this.addLight(md,u.ZyN),this.addLight(mg,u.ure),this.addLight(mm,u.nCl),this.addLight(mx,u.$p8),this.addLight(mT,u.dth),this.addLight(m_,u.FZo),this.addLight(mf,yL),this.addLight(mb,yP),this.addToneMapping(ce,u.kyO),this.addToneMapping(ct,u.Mjd),this.addToneMapping(cr,u.nNL),this.addToneMapping(cs,u.FV),this.addToneMapping(cl,u.LAk),this.addToneMapping(cu,u.aJ8)}}class yU extends m6{constructor(e={}){let t;e.forceWebGL?t=fD:(t=yB,e.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new fD(e))),super(new t(e),e),this.library=new yF,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}u.YJl,u.gPd,u.gPd,u.gPd,u.aHM,u.jut,u.XTe,u.YJl}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.