PageSourceSearch

https://exchange24.pro/_next/static/chunks/97fc0e3d.be473c716160ead8.js

js exchange24.pro collected 2026-10-09 21:39:55 UTC 531,078 bytes, 305 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7218],{68e3:(e,t,r)=>{let i,s,n,a,o,l;r.d(t,{Z$U:()=>hy,uV1:()=>ba,uuE:()=>p1});var u=r(92731);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=[];for(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)}function g(e,t=!1){let r=[];for(let{property:i,childNode:s}of(!0===e.isNode&&(r.push(e.id),e=e.getSelf()),m(e)))r.push(p(i.slice(0,-4)),s.getCacheKey(t));return p(r)}function*m(e,t=!1){for(let r in 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 f=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),y=new WeakMap;function b(e){if(/[iu]?vec\d/.test(e))return e.startsWith("ivec")?Int32Array:e.startsWith("uvec")?Uint32Array:Float32Array;
1if(/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 x(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 T(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 _(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 S(t[0]);return null}function v(e){let t=y.get(e);return void 0===t&&(t={},y.set(e,t)),t}function N(e){let t="",r=new Uint8Array(e);for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return btoa(t)}function S(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0)).buffer}let E={VERTEX:"vertex",FRAGMENT:"fragment"},R={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},A={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},w=["fragment","vertex"],C=["setup","analyze","generate"],M=[...w,"compute"],L=["x","y","z","w"],P={analyze:"setup",generate:"analyze"},B=0;class F extends u.Qev{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=R.NONE,this.updateBeforeType=R.NONE,this.updateAfterType=R.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:B++})}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.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,R.FRAME)}onRenderUpdate(e){return this.onUpdate(e,R.RENDER)}onObjectUpdate(e){return this.onUpdate(e,R.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of m(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=((...e)=>p(e))(g(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=P[e.buildStage];if(s&&!0!==i.buildStages[s]){let t=e.getBuildStage();
1e.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)||"";return e.removeChain(this),e.addSequentialNode(this),n}getSerializeChildren(){return m(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 I extends F{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 F{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 D extends F{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 O extends D{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(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);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);let d=e.getComponentType(l);d!==n&&(s=e.format(s,d,n)),a.push(s)}let l=`${e.getType(r)}( ${a.join(", ")} )`;return e.format(l,r,t)}}let U=L.join("");class k extends F{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(L.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){let 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===U.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 G extends D{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=L[e];t===r[0]?(d.push(o),e+=r.length-1):d.push(l+"."+t)}return`${e.getType(s)}( ${d.join(", ")} )`}}class z extends D{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}
1generate(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=L[e];r===t[u]?(l.push("1.0 - "+a+"."+r),u++):l.push(a+"."+r)}return`${e.getType(i)}( ${l.join(", ")} )`}}class $ extends F{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?T(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=T(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=N(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?_(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 H=/float|u?int/;class W extends ${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 H.test(r)&&H.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class q extends F{static get type(){return"MemberNode"}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}}let j=null,X=new Map;function K(e,t){if(X.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`);X.set(e,t)}let Q=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Y=e=>Q(e).split("").sort().join(""),Z={setup:(e,t)=>e(e_(t.shift()),...t),get(e,t,r){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(j.assign(r,...e),r);else if(X.has(t)){let i=X.get(t);return e.isStackNode?(...e)=>r.add(i(...e)):(...e)=>i(r,...e)}else if("toVarIntent"===t)return()=>r;else if("self"===t)return e;else if(t.endsWith("Assign")&&X.has(t.slice(0,t.length-6))){let i=X.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>r.assign(e[0],i(...e)):(...e)=>r.assign(i(r,...e))}else if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return ex(new k(r,t=Q(t)));else if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=Y(t.slice(3).toLowerCase()),r=>ex(new G(e,t,ex(r)));else if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=Y(t.slice(4).toLowerCase()),()=>ex(new z(ex(e),t));else if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),ex(new k(e,t));else if(!0===/^\d+$/.test(t))return ex(new I(r,new W(Number(t),"uint")));else if(!0===/^get$/.test(t))return e=>ex(new q(r,e))}return Reflect.get(e,t,r)},set:(e,t,r,i)=>"string"==typeof t&&void 0===e[t]&&(!0===/^[xyzwrgbastpq]{1,4}$/.test(t)||"width"===t||"height"===t||"depth"===t||!0===/^\d+$/.test(t))?(i[t].assign(r),!0):Reflect.set(e,t,r,i)},J=new WeakMap,ee=new WeakMap,et=function(e,t=null){let r=T(e);if("node"===r){let t=J.get(e);return void 0===t&&(t=new Proxy(e,Z),J.set(e,t),J.set(t,t)),t}return null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r?ex(eg(e,t)):"shader"===r?e.
1isFn?e:eA(e):e},er=function(e,t=null){for(let r in e)e[r]=ex(e[r],t);return e},ei=function(e,t=null){let r=e.length;for(let i=0;i<r;i++)e[i]=ex(e[i],t);return e},es=function(e,t=null,r=null,i=null){function s(e){return null!==i?(e=ex(Object.assign(e,i)),!0===i.intent&&(e=e.toVarIntent())):e=ex(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(...ev(u(t)))):null!==r?(r=ex(r),n=(...i)=>s(new e(t,...ev(u(i)),r))):n=(...r)=>s(new e(t,...ev(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},en=function(e,...t){return ex(new e(...ev(t)))};class ea extends F{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){let{shaderNode:t,inputNodes:r}=this,i=e.getNodeProperties(t),s=e.getClosestSubBuild(t.subBuilds)||"",n=s||"default";if(i[n])return i[n];let a=e.subBuildFn;e.subBuildFn=s;let o=null;if(t.layout){let i=ee.get(e.constructor);void 0===i&&(i=new WeakMap,ee.set(e.constructor,i));let s=i.get(t);void 0===s&&(s=ex(e.buildFunctionNode(t)),i.set(t,s)),e.addInclude(s),o=ex(s.call(r))}else{let i=r;if(Array.isArray(i)){let e=0;i=new Proxy(i,{get:(t,r,i)=>void 0===t[r]?t[e++]:Reflect.get(t,r,i)})}let s=t.jsFunc;o=ex(null!==i||s.length>1?s(i||[],e):s(e))}return e.subBuildFn=a,t.once&&(i[n]=o),o}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 eo extends F{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 e_(e),ex(new ea(this,e))}setup(){return this.call()}}let el=[.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],eu=new Map;for(let e of[!1,!0])eu.set(e,new W(e));let ed=new Map;for(let e of[0,1,2,3])ed.set(e,new W(e,"uint"));let eh=new Map([...ed].map(e=>new W(e.value,"int")));for(let e of[-1,-2])eh.set(e,new W(e,"int"));let ec=new Map([...eh].map(e=>new W(e.value)));for(let e of el)ec.set(e,new W(e));for(let e of el)ec.set(-e,new W(-e));let ep=new Map([...eu,...ec]),eg=(e,t)=>ep.has(e)?ep.get(e):!0===e.isNode?e:new W(e,t),em=function(e,t=null){return(...r)=>{if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every(e=>"object"!=typeof e))&&(r=[_(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return eT(t.get(r[0]));if(1===r.length){let t=eg(r[0],e);return t.nodeType===e?eT(t):eT(new V(t,e))}return eT(new O(r.map(e=>eg(e)),e))}},ef=e=>"object"==typeof e&&null!==e?e.value:e,ey=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function eb(e,t){return new Proxy(new eo(e,t),Z)}let ex=(e,t=null)=>et(e,t),eT=(e,t=null)=>ex(e,t).toVarIntent(),e_=(e,t=null)=>new er(e,t),ev=(e,t=null)=>new ei(e,t),eN=(e,t=null,r=null,i=null)=>new es(e,t,r,i),eS=(e,...t)=>new en(e,...t),eE=(e,t=null,r=null,i={})=>new es(e,t,r,{intent:!0,...i}),eR=0,eA=(e,t=null)=>{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));let i=new eb(e,r),s=(...e)=>{let t;e_(e),t=e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)?[...e]:e[0];let s=i.call(t);
1return"void"===r&&s.toStack(),s.toVarIntent()};if(s.shaderNode=i,s.id=i.id,s.isFn=!0,s.getNodeType=(...e)=>i.getNodeType(...e),s.getCacheKey=(...e)=>i.getCacheKey(...e),s.setLayout=e=>(i.setLayout(e),s),s.once=(e=null)=>(i.once=!0,i.subBuilds=e,s),null!==t){if("object"!=typeof t.inputs){let e={name:"fn"+eR++,type:r,inputs:[]};for(let r in t)"return"!==r&&e.inputs.push({name:r,type:t[r]});t=e}s.setLayout(t)}return s},ew=e=>{j=e},eC=()=>j,eM=(...e)=>j.If(...e);function eL(e){return j&&j.add(e),e}K("toStack",eL);let eP=new em("color"),eB=new em("float",ec),eF=new em("int",eh),eI=new em("uint",ed),eV=new em("bool",eu),eD=new em("vec2"),eO=new em("ivec2"),eU=new em("uvec2"),ek=new em("bvec2"),eG=new em("vec3"),ez=new em("ivec3"),e$=new em("uvec3"),eH=new em("bvec3"),eW=new em("vec4"),eq=new em("ivec4"),ej=new em("uvec4"),eX=new em("bvec4"),eK=new em("mat2"),eQ=new em("mat3"),eY=new em("mat4");K("toColor",eP),K("toFloat",eB),K("toInt",eF),K("toUint",eI),K("toBool",eV),K("toVec2",eD),K("toIVec2",eO),K("toUVec2",eU),K("toBVec2",ek),K("toVec3",eG),K("toIVec3",ez),K("toUVec3",e$),K("toBVec3",eH),K("toVec4",eW),K("toIVec4",eq),K("toUVec4",ej),K("toBVec4",eX),K("toMat2",eK),K("toMat3",eQ),K("toMat4",eY);let eZ=eN(I).setParameterLength(2),eJ=(e,t)=>ex(new V(ex(e),t));K("element",eZ),K("convert",eJ),K("append",e=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),eL(e)));class e0 extends F{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 e1=(e,t)=>ex(new e0(e,t)),e2=(e,t)=>ex(new e0(e,t,!0)),e3=eS(e0,"vec4","DiffuseColor"),e4=eS(e0,"vec3","EmissiveColor"),e6=eS(e0,"float","Roughness"),e5=eS(e0,"float","Metalness"),e8=eS(e0,"float","Clearcoat"),e9=eS(e0,"float","ClearcoatRoughness"),e7=eS(e0,"vec3","Sheen"),te=eS(e0,"float","SheenRoughness"),tt=eS(e0,"float","Iridescence"),tr=eS(e0,"float","IridescenceIOR"),ti=eS(e0,"float","IridescenceThickness"),ts=eS(e0,"float","AlphaT"),tn=eS(e0,"float","Anisotropy"),ta=eS(e0,"vec3","AnisotropyT"),to=eS(e0,"vec3","AnisotropyB"),tl=eS(e0,"color","SpecularColor"),tu=eS(e0,"float","SpecularF90"),td=eS(e0,"float","Shininess"),th=eS(e0,"vec4","Output"),tc=eS(e0,"float","dashSize"),tp=eS(e0,"float","gapSize"),tg=eS(e0,"float","pointWidth"),tm=eS(e0,"float","IOR"),tf=eS(e0,"float","Transmission"),ty=eS(e0,"float","Thickness"),tb=eS(e0,"float","AttenuationDistance"),tx=eS(e0,"color","AttenuationColor"),tT=eS(e0,"float","Dispersion");class t_ extends F{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 tv=e=>new t_(e),tN=(e,t=0)=>new t_(e,!0,t),tS=tN("frame"),tE=tN("render"),tR=tv("object");class tA extends ${static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=tR}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){let r=this.getSelf();return e=e.bind(r),super.onUpdate(t=>{let i=e(t,r);void 0!==i&&(this.value=i)},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 tw=(e,t)=>{let r=ey(t||e);return ex(new tA(e&&!0===e.isNode?e.node&&e.node.value||e.value:e,r))};class tC extends D{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 tM=(...e)=>{let t;if(1===e.length){let r=e[0];t=new tC(null,r.length,r)}else t=new tC(e[0],e[1]);return ex(t)};K("toArray",(e,t)=>tM(Array(t).fill(e)));class tL extends D{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 L.join("").slice(0,r)!==t.components}return!1}setup(e){let{targetNode:t,sourceNode:r}=this;e.getNodeProperties(t).assign=!0;let i=e.getNodeProperties(this);i.sourceNode=r,i.targetNode=t.context({assign:!0})}generate(e,t){let r,{targetNode:i,sourceNode:s}=e.getNodeProperties(this),n=this.needsSplitAssign(e),a=i.getNodeType(e),o=i.build(e),l=s.build(e,a),u=s.getNodeType(e),d=e.getDataFromNode(this);if(!0===d.initialized)"void"!==t&&(r=o);else if(n){let s=e.getVarFromNode(this,null,a),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=o)}else r=`${o} = ${l}`,("void"===t||"void"===u)&&(e.addLineFlowCode(r,this),"void"!==t&&(r=o));return d.initialized=!0,e.format(r,a,t)}}let tP=eN(tL).setParameterLength(2);K("assign",tP);class tB extends D{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){let t=[],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(eB(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(eB(0),e)))}let a=r.build(e,"property");return`${a}( ${t.join(", ")} )`}}let tF=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?ev(t):e_(t[0]),ex(new tB(ex(e),t)));K("call",tF);let tI={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class tV extends D{static get type(){return"OperatorNode"}constructor(e,t,r,...i){if(super(),i.length>0){let s=new tV(e,t,r);for(let t=0;t<i.length-1;t++)s=new tV(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(tI[this.op],t)}getNodeType(e){let t=this.op,r=this.aNode,i=this.bNode,s=r.getNodeType(e),n=i?i.getNodeType(e):null;if("void"===s||"void"===n)return"void";if("%"===t)return s;if("~"===t||"&"===t||"|"===t||"^"===t||">>"===t||"<<"===t)return e.getIntegerType(s);if("!"===t||"&&"===t||"||"===t||"^^"===t)return"bool";if("=="===t||"!="===t||"<"===t||">"===t||"<="===t||">="===t){let t=Math.max(e.getTypeLength(s),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}else{if(e.isMatrix(s)){if("float"===n)return s;else if(e.isVector(n))return e.getVectorFromMatrix(s);else if(e.isMatrix(n))return s}else if(e.isMatrix(n)){if("float"===s)return n;else if(e.isVector(s))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(s)?n:s}}generate(e,t){let r=this.op,{aNode:i,bNode:s}=this,n=this.getNodeType(e),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 tD=eE(tV,"+").setParameterLength(2,1/0).setName("add"),tO=eE(tV,"-").setParameterLength(2,1/0).setName("sub"),tU=eE(tV,"*").setParameterLength(2,1/0).setName("mul"),tk=eE(tV,"/").setParameterLength(2,1/0).setName("div"),tG=eE(tV,"%").setParameterLength(2).setName("mod"),tz=eE(tV,"==").setParameterLength(2).setName("equal"),t$=eE(tV,"!=").setParameterLength(2).setName("notEqual"),tH=eE(tV,"<").setParameterLength(2).setName("lessThan"),tW=eE(tV,">").setParameterLength(2).setName("greaterThan"),tq=eE(tV,"<=").setParameterLength(2).setName("lessThanEqual"),tj=eE(tV,">=").setParameterLength(2).setName("greaterThanEqual"),tX=eE(tV,"&&").setParameterLength(2,1/0).setName("and"),tK=eE(tV,"||").setParameterLength(2,1/0).setName("or"),tQ=eE(tV,"!").setParameterLength(1).setName("not"),tY=eE(tV,"^^").setParameterLength(2).setName("xor"),tZ=eE(tV,"&").setParameterLength(2).setName("bitAnd"),tJ=eE(tV,"~").setParameterLength(2).setName("bitNot"),t0=eE(tV,"|").setParameterLength(2).setName("bitOr"),t1=eE(tV,"^").setParameterLength(2).setName("bitXor"),t2=eE(tV,"<<").setParameterLength(2).setName("shiftLeft"),t3=eE(tV,">>").setParameterLength(2).setName("shiftRight"),t4=eA(([e])=>(e.addAssign(1),e)),t6=eA(([e])=>(e.subAssign(1),e)),t5=eA(([e])=>{let t=eF(e).toConst();return e.addAssign(1),t}),t8=eA(([e])=>{let t=eF(e).toConst();return e.subAssign(1),t});K("add",tD),K("sub",tO),K("mul",tU),K("div",tk),K("mod",tG),K("equal",tz),K("notEqual",t$),K("lessThan",tH),K("greaterThan",tW),K("lessThanEqual",tq),K("greaterThanEqual",tj),K("and",tX),K("or",tK),K("not",tQ),K("xor",tY),K("bitAnd",tZ),K("bitNot",tJ),K("bitOr",t0),K("bit
1Xor",t1),K("shiftLeft",t2),K("shiftRight",t3),K("incrementBefore",t4),K("decrementBefore",t6),K("increment",t5),K("decrement",t8);let t9=(e,t)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),tG(eF(e),eF(t)));K("modInt",t9);class t7 extends D{static get type(){return"MathNode"}constructor(e,t,r=null,i=null){if(super(),(e===t7.MAX||e===t7.MIN)&&arguments.length>3){let s=new t7(e,t,r);for(let t=2;t<arguments.length-1;t++)s=new t7(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===t7.LENGTH||t===t7.DISTANCE||t===t7.DOT?"float":t===t7.CROSS?"vec3":t===t7.ALL||t===t7.ANY?"bool":t===t7.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===t7.ONE_MINUS)s=tO(1,t);else if(i===t7.RECIPROCAL)s=tk(1,t);else if(i===t7.DIFFERENCE)s=rS(tO(t,r));else if(i===t7.TRANSFORM_DIRECTION){let i=t,n=r;e.isMatrix(i.getNodeType(e))?n=eW(eG(n),0):i=eW(eG(i),0),s=rf(tU(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===t7.NEGATE)return e.format("( - "+n.build(e,s)+" )",i,t);{let d=[];return r===t7.CROSS?d.push(n.build(e,i),a.build(e,i)):l===u.TdN&&r===t7.STEP?d.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":s),a.build(e,s)):l===u.TdN&&(r===t7.MIN||r===t7.MAX)?d.push(n.build(e,s),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":s)):r===t7.REFRACT?d.push(n.build(e,s),a.build(e,s),o.build(e,"float")):r===t7.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===t7.ATAN&&null!==a&&(r="atan2"),"fragment"!==e.shaderStage&&(r===t7.DFDX||r===t7.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}}t7.ALL="all",t7.ANY="any",t7.RADIANS="radians",t7.DEGREES="degrees",t7.EXP="exp",t7.EXP2="exp2",t7.LOG="log",t7.LOG2="log2",t7.SQRT="sqrt",t7.INVERSE_SQRT="inversesqrt",t7.FLOOR="floor",t7.CEIL="ceil",t7.NORMALIZE="normalize",t7.FRACT="fract",t7.SIN="sin",t7.COS="cos",t7.TAN="tan",t7.ASIN="asin",t7.ACOS="acos",t7.ATAN="atan",t7.ABS="abs",t7.SIGN="sign",t7.LENGTH="length",t7.NEGATE="negate",t7.ONE_MINUS="oneMinus",t7.DFDX="dFdx",t7.DFDY="dFdy",t7.ROUND="round",t7.RECIPROCAL="reciprocal",t7.TRUNC="trunc",t7.FWIDTH="fwidth",t7.TRANSPOSE="transpose",t7.DETERMINANT="determinant",t7.INVERSE="inverse",t7.BITCAST="bitcast",t7.EQUALS="equals",t7.MIN="min",t7.MAX="max",t7.STEP="step",t7.REFLECT="reflect",t7.DISTANCE="distance",t7.DIFFERENCE="difference",t7.DOT="dot",t7.CROSS="cross",t7.POW="pow",t7.TRANSFORM_DIRECTION="transformDirection",t7.MIX="mix",t7.CLAMP="clamp",t7.REFRACT="refract",t7.SMOOTHSTEP="smoothstep",t7.FACEFORWARD="faceforward";let re=eB(1e-6),rt=eB(1e6),rr=eB(Math.PI),ri=eB(2*Math.PI),rs=eE(t7,t7.ALL).setParameterLength(1),rn=eE(t7,t7.ANY).setParameterLength(1),ra=eE(t7,t7.RADIANS).setParameterLength(1),ro=eE(t7,t7.DEGREES).setParameterLength(1),rl=eE(t7,t7.EXP).setParameterLength(1),ru=eE(t7,t7.EXP2).setParameterLength(1),rd=eE(t7,t7.LOG).setParameterLength(1),rh=eE(t7,t7.LOG2).setParameterLength(1),rc=eE(t7,t7.SQRT).setParameterLength(1),rp=eE(t7,t7.INVERSE_SQRT).setParameterLength(1),rg=eE(t7,t7.FLOOR).setParameterLength(1),rm=eE(t7,t7.CEIL).setParameterLength(1),rf=eE(t7,t7.NORMALIZE).setParameterLength(1),ry=eE(t7,t7.FRACT).setParameterLength(1),rb=eE(t7,t7.S
1IN).setParameterLength(1),rx=eE(t7,t7.COS).setParameterLength(1),rT=eE(t7,t7.TAN).setParameterLength(1),r_=eE(t7,t7.ASIN).setParameterLength(1),rv=eE(t7,t7.ACOS).setParameterLength(1),rN=eE(t7,t7.ATAN).setParameterLength(1,2),rS=eE(t7,t7.ABS).setParameterLength(1),rE=eE(t7,t7.SIGN).setParameterLength(1),rR=eE(t7,t7.LENGTH).setParameterLength(1),rA=eE(t7,t7.NEGATE).setParameterLength(1),rw=eE(t7,t7.ONE_MINUS).setParameterLength(1),rC=eE(t7,t7.DFDX).setParameterLength(1),rM=eE(t7,t7.DFDY).setParameterLength(1),rL=eE(t7,t7.ROUND).setParameterLength(1),rP=eE(t7,t7.RECIPROCAL).setParameterLength(1),rB=eE(t7,t7.TRUNC).setParameterLength(1),rF=eE(t7,t7.FWIDTH).setParameterLength(1),rI=eE(t7,t7.TRANSPOSE).setParameterLength(1),rV=eE(t7,t7.DETERMINANT).setParameterLength(1),rD=eE(t7,t7.INVERSE).setParameterLength(1),rO=eE(t7,t7.BITCAST).setParameterLength(2),rU=(e,t)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),tz(e,t)),rk=eE(t7,t7.MIN).setParameterLength(2,1/0),rG=eE(t7,t7.MAX).setParameterLength(2,1/0),rz=eE(t7,t7.STEP).setParameterLength(2),r$=eE(t7,t7.REFLECT).setParameterLength(2),rH=eE(t7,t7.DISTANCE).setParameterLength(2),rW=eE(t7,t7.DIFFERENCE).setParameterLength(2),rq=eE(t7,t7.DOT).setParameterLength(2),rj=eE(t7,t7.CROSS).setParameterLength(2),rX=eE(t7,t7.POW).setParameterLength(2),rK=eE(t7,t7.POW,2).setParameterLength(1),rQ=eE(t7,t7.POW,3).setParameterLength(1),rY=eE(t7,t7.POW,4).setParameterLength(1),rZ=eE(t7,t7.TRANSFORM_DIRECTION).setParameterLength(2),rJ=e=>tU(rE(e),rX(rS(e),1/3)),r0=e=>rq(e,e),r1=eE(t7,t7.MIX).setParameterLength(3),r2=(e,t=0,r=1)=>ex(new t7(t7.CLAMP,ex(e),ex(t),ex(r))),r3=e=>r2(e),r4=eE(t7,t7.REFRACT).setParameterLength(3),r6=eE(t7,t7.SMOOTHSTEP).setParameterLength(3),r5=eE(t7,t7.FACEFORWARD).setParameterLength(3),r8=eA(([e])=>ry(rb(tG(rq(e.xy,eD(12.9898,78.233)),rr)).mul(43758.5453))),r9=(e,t,r)=>r1(t,r,e),r7=(e,t,r)=>r6(t,r,e),ie=(e,t)=>rz(t,e),it=(e,t)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),rN(e,t));K("all",rs),K("any",rn),K("equals",rU),K("radians",ra),K("degrees",ro),K("exp",rl),K("exp2",ru),K("log",rd),K("log2",rh),K("sqrt",rc),K("inverseSqrt",rp),K("floor",rg),K("ceil",rm),K("normalize",rf),K("fract",ry),K("sin",rb),K("cos",rx),K("tan",rT),K("asin",r_),K("acos",rv),K("atan",rN),K("abs",rS),K("sign",rE),K("length",rR),K("lengthSq",r0),K("negate",rA),K("oneMinus",rw),K("dFdx",rC),K("dFdy",rM),K("round",rL),K("reciprocal",rP),K("trunc",rB),K("fwidth",rF),K("atan2",it),K("min",rk),K("max",rG),K("step",ie),K("reflect",r$),K("distance",rH),K("dot",rq),K("cross",rj),K("pow",rX),K("pow2",rK),K("pow3",rQ),K("pow4",rY),K("transformDirection",rZ),K("mix",r9),K("clamp",r2),K("refract",r4),K("smoothstep",r7),K("faceForward",r5),K("difference",rW),K("saturate",r3),K("cbrt",rJ),K("transpose",rI),K("determinant",rV),K("inverse",rD),K("rand",r8);class ir extends F{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}setup(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.getNodeProperties(this);n.condNode=t,n.ifNode=r.context({nodeBlock:r}),n.elseNode=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?e1(r).build(e):"";i.nodeProperty=u;let d=s.build(e,"bool");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 ii=eN(ir).setParameterLength(2,3);K("select",ii);class is extends F{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){let t=e.getContext();e.setContext({...e.context,...this.value}),this.node.build(e),e.setContext(t)}
4setup(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 ia=eN(is).setParameterLength(1,2),io=(e,t)=>ia(e,{nodeName:t});function il(e,t){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),io(e,t)}K("context",ia),K("label",il),K("setName",io);class iu extends F{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 id=eN(iu),ih=(e,t=null)=>id(e,t).toStack(),ic=(e,t=null)=>id(e,t,!0).toStack(),ip=e=>null===eC()?e:id(e).setIntent(!0).toStack();K("toVar",ih),K("toConst",ic),K("toVarIntent",ip);let ig=e=>(console.warn('TSL: "temp( node )" is deprecated. Use "Var( node )" or "node.toVar()" instead.'),id(e));K("temp",ig);class im extends F{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 iy=(e,t,r=null)=>ex(new im(ex(e),t,r));class ib extends F{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=iy(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(E.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(E.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,E.VERTEX);e.flowNodeFromShaderStage(E.VERTEX,r.node,s,n),r[t]=n}return e.getPropertyName(i)}}let ix=eN(ib).setParameterLength(1,2),iT=e=>ix(e);K("toVarying",ix),K("toVertexStage",iT),K("varying",(...e)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),ix(...e))),K("vertexStage",(...e)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),ix(...e)));let i_=eA(([e])=>r1(e.mul(.9478672986).add(.0521327014).pow(2.4),e.mul(.0773993808),e.lessThanEqual(.04045))).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),iv=eA(([e])=>r1(e.pow(.41666).mul(1.055).sub(.055),e.mul(12.92),e.lessThanEqual(.0031308))).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),iN="WorkingColorSpace";class iS extends D{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===iN?u.ppV.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}
4setup(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=eW(i_(s.rgb),s.a)),u.ppV.getPrimaries(r)!==u.ppV.getPrimaries(i)&&(s=eW(eQ(u.ppV._getMatrix(new u.dwI,r,i)).mul(s.rgb),s.a)),u.ppV.getTransfer(i)===u.KLL&&(s=eW(iv(s.rgb),s.a))),s}}let iE=(e,t)=>ex(new iS(ex(e),iN,t)),iR=(e,t)=>ex(new iS(ex(e),t,iN));K("workingToColorSpace",iE),K("colorSpaceToWorking",iR);let iA=class extends I{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 iw extends F{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=R.OBJECT}setGroup(e){return this.group=e,this}element(e){return ex(new iA(this,ex(e)))}setNodeType(e){let t=tw(null,e).getSelf();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 iC extends iw{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(tE)}updateReference(e){return this.reference=null!==this.renderer?this.renderer:e.renderer,this.reference}}let iM=(e,t,r=null)=>ex(new iC(e,t,r));class iL extends D{static get type(){return"ToneMappingNode"}constructor(e,t=iB,r=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return((...e)=>p(e))(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=eW(s(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=t),i}}let iP=(e,t,r)=>ex(new iL(e,ex(t),ex(r))),iB=iM("toneMappingExposure","float");K("toneMapping",(e,t,r)=>iP(t,r,e));class iF extends ${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=ix(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 iI=(e,t=null,r=0,i=0)=>ex(new iF(e,t,r,i)),iV=(e,t=null,r=0,i=0)=>iI(e,t,r,i).setUsage(u.Vnu),iD=(e,t=null,r=0,i=0)=>iI(e,t,r,i).setInstanced(!0),iO=(e,t=null,r=0,i=0)=>iV(e,t,r,i).setInstanced(!0);K("toAttribute",e=>iI(e.value));class iU extends F{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=R.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 ik=(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 ex(new iU(ex(e),t))},iG=(e,t,r)=>ik(e,r).setCount(t);K("compute",iG),K("computeKernel",ik);class iz extends F{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNo
4de=!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 i$=(e,t)=>ex(new iz(ex(e),t));K("cache",i$);class iH extends F{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 iW=eN(iH).setParameterLength(2);K("bypass",iW);class iq extends F{static get type(){return"RemapNode"}constructor(e,t,r,i=eB(0),s=eB(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=eN(iq,null,null,{doClamp:!1}).setParameterLength(3,5),iX=eN(iq).setParameterLength(3,5);K("remap",ij),K("remapClamp",iX);class iK extends F{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 iQ=eN(iK).setParameterLength(1,2),iY=e=>(e?ii(e,iQ("discard")):iQ("discard")).toStack();K("discard",iY);class iZ extends D{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 iJ=(e,t=null,r=null)=>ex(new iZ(ex(e),t,r));K("renderOutput",iJ);class i0 extends D{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 i1=(e,t=null)=>ex(new i0(ex(e),t)).toStack();K("debug",i1);class i2 extends F{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);if(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):ix(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 i3=(e,t=null)=>ex(new i2(e,t)),i4=(e=0)=>i3("uv"+(e>0?e:""),"vec2");class i6 extends F{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 i5=eN(i6).setParameterLength(1,2);class i8 extends tA{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=R.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 i9=eN(i8).setParameterLength(1),i7=new u.gPd;class se extends tA{static get type(){return"TextureNode"}constructor(e=i7,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.sampler=!0,this.updateMatrix=!1,this.updateType=R.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 i4(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=tw(this.value.matrix)),this._matrixUniform.mul(eG(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?R.OBJECT:R.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(eF(i5(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}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,r,i,s,n,a,o){let l=this.value;return i?e.generateTextureLevel(l,t,r,i,n):s?e.generateTextureBias(l,t,r,s,n):o?e.generateTextureGrad(l,t,r,o,n):a?e.generateTextureCompare(l,t,r,a,n):!1===this.sampler?e.generateTextureLoad(l,t,r,n):e.generateTexture(l,t,r,n)}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}=i,h=this.generateUV(e,t),c=r?r.build(e,"float"):null,p=o?o.build(e,"float"):null,g=u?u.build(e,"int"):null,m=l?l.build(e,"float"):null,f=d?[d[0].build(e,"vec2"),d[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);a=e.getPropertyName(y);let b=this.generateSnippet(e,s,h,c,p,g,m,f);e.addLineFlowCode(`${a} = ${b}`,this),n.snippet=b,n.propertyName=a}let o=a,l=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(o=iR(iQ(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=ex(e),t.referenceNode=this.getSelf(),ex(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=ex(e).mul(i9(t)),t.referenceNode=this.getSelf();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),ex(t)}level(e){let t=this.clone();return t.levelNode=ex(e),t.referenceNode=this.getSelf(),ex(t)}size(e){return i5(this,e)}bias(e){let t=this.clone();return t.biasNode=ex(e),t.referenceNode=this.getSelf(),ex(t)}compare(e){let t=this.clone();return t.compareNode=ex(e),t.referenceNode=this.getSelf(),ex(t)}grad(e,t){let r=this.clone();return r.gradNode=[ex(e),ex(t)],r.referenceNode=this.getSelf(),ex(r)}
4depth(e){let t=this.clone();return t.depthNode=ex(e),t.referenceNode=this.getSelf(),ex(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}}let st=eN(se).setParameterLength(1,4).setName("texture"),sr=(e=i7,t=null,r=null,i=null)=>{let s;return e&&!0===e.isTextureNode?((s=ex(e.clone())).referenceNode=e.getSelf(),null!==t&&(s.uvNode=ex(t)),null!==r&&(s.levelNode=ex(r)),null!==i&&(s.biasNode=ex(i))):s=st(e,t,r,i),s},si=(...e)=>sr(...e).setSampler(!1);class ss extends tA{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 sn=(e,t,r)=>ex(new ss(e,t,r));class sa extends I{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 so extends ss{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?T(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=R.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 ex(new sa(this,ex(e)))}}let sl=(e,t)=>ex(new so(e,t));class su extends F{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}let sd=eN(su).setParameterLength(1),sh=tw(0,"uint").setName("u_cameraIndex").setGroup(tN("cameraIndex")).toVarying("v_cameraIndex"),sc=tw("float").setName("cameraNear").setGroup(tE).onRenderUpdate(({camera:e})=>e.near),sp=tw("float").setName("cameraFar").setGroup(tE).onRenderUpdate(({camera:e})=>e.far),sg=eA(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.projectionMatrix);t=sl(r).setGroup(tE).setName("cameraProjectionMatrices").element(e.isMultiViewCamera?sd("gl_ViewID_OVR"):sh).toVar("cameraProjectionMatrix")}else t=tw("mat4").setName("cameraProjectionMatrix").setGroup(tE).onRenderUpdate(({camera:e})=>e.projectionMatrix);return t}).once()(),sm=eA(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.projectionMatrixInverse);t=sl(r).setGroup(tE).setName("cameraProjectionMatricesInverse").element
4(e.isMultiViewCamera?sd("gl_ViewID_OVR"):sh).toVar("cameraProjectionMatrixInverse")}else t=tw("mat4").setName("cameraProjectionMatrixInverse").setGroup(tE).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse);return t}).once()(),sf=eA(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.matrixWorldInverse);t=sl(r).setGroup(tE).setName("cameraViewMatrices").element(e.isMultiViewCamera?sd("gl_ViewID_OVR"):sh).toVar("cameraViewMatrix")}else t=tw("mat4").setName("cameraViewMatrix").setGroup(tE).onRenderUpdate(({camera:e})=>e.matrixWorldInverse);return t}).once()(),sy=tw("mat4").setName("cameraWorldMatrix").setGroup(tE).onRenderUpdate(({camera:e})=>e.matrixWorld),sb=tw("mat3").setName("cameraNormalMatrix").setGroup(tE).onRenderUpdate(({camera:e})=>e.normalMatrix),sx=tw(new u.Pq0).setName("cameraPosition").setGroup(tE).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)),sT=new u.iyt;class s_ extends F{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=R.OBJECT,this.uniformNode=new tA(null)}getNodeType(){let e=this.scope;return e===s_.WORLD_MATRIX?"mat4":e===s_.POSITION||e===s_.VIEW_POSITION||e===s_.DIRECTION||e===s_.SCALE?"vec3":e===s_.RADIUS?"float":void 0}update(e){let t=this.object3d,r=this.uniformNode,i=this.scope;if(i===s_.WORLD_MATRIX)r.value=t.matrixWorld;else if(i===s_.POSITION)r.value=r.value||new u.Pq0,r.value.setFromMatrixPosition(t.matrixWorld);else if(i===s_.SCALE)r.value=r.value||new u.Pq0,r.value.setFromMatrixScale(t.matrixWorld);else if(i===s_.DIRECTION)r.value=r.value||new u.Pq0,t.getWorldDirection(r.value);else if(i===s_.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===s_.RADIUS){let i=e.object.geometry;null===i.boundingSphere&&i.computeBoundingSphere(),sT.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),r.value=sT.radius}}generate(e){let t=this.scope;return t===s_.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===s_.POSITION||t===s_.VIEW_POSITION||t===s_.DIRECTION||t===s_.SCALE?this.uniformNode.nodeType="vec3":t===s_.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}}s_.WORLD_MATRIX="worldMatrix",s_.POSITION="position",s_.SCALE="scale",s_.VIEW_POSITION="viewPosition",s_.DIRECTION="direction",s_.RADIUS="radius";let sv=eN(s_,s_.DIRECTION).setParameterLength(1),sN=eN(s_,s_.WORLD_MATRIX).setParameterLength(1),sS=eN(s_,s_.POSITION).setParameterLength(1),sE=eN(s_,s_.SCALE).setParameterLength(1),sR=eN(s_,s_.VIEW_POSITION).setParameterLength(1),sA=eN(s_,s_.RADIUS).setParameterLength(1);class sw extends s_{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}let sC=eS(sw,sw.DIRECTION),sM=eS(sw,sw.WORLD_MATRIX),sL=eS(sw,sw.POSITION),sP=eS(sw,sw.SCALE),sB=eS(sw,sw.VIEW_POSITION),sF=eS(sw,sw.RADIUS),sI=tw(new u.dwI).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),sV=tw(new u.kn4).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),sD=eA(e=>e.renderer.overrideNodes.modelViewMatrix||sO).once()().toVar("modelViewMatrix"),sO=sf.mul(sM),sU=eA(e=>
4(e.context.isHighPrecisionModelViewMatrix=!0,tw("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),sk=eA(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return tw("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),sG=i3("position","vec3"),sz=sG.toVarying("positionLocal"),s$=sG.toVarying("positionPrevious"),sH=eA(e=>sM.mul(sz).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),sW=eA(()=>sz.transformDirection(sM).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),sq=eA(e=>e.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),sj=sq.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class sX extends F{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";let{renderer:t,material:r}=e;return t.coordinateSystem===u.TdN&&r.side===u.hsX?"false":e.getFrontFacing()}}let sK=eS(sX),sQ=eB(sK).mul(2).sub(1),sY=eA(([e],{material:t})=>{let r=t.side;return r===u.hsX?e=e.mul(-1):r===u.$EB&&(e=e.mul(sQ)),e}),sZ=i3("normal","vec3"),sJ=eA(e=>!1===e.geometry.hasAttribute("normal")?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),eG(0,1,0)):sZ,"vec3").once()().toVar("normalLocal"),s0=sq.dFdx().cross(sq.dFdy()).normalize().toVar("normalFlat"),s1=eA(e=>!0===e.material.flatShading?s0:s8(sJ).toVarying("v_normalViewGeometry").normalize(),"vec3").once()().toVar("normalViewGeometry"),s2=eA(e=>{let t=s1.transformDirection(sf);return!0!==e.material.flatShading&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),s3=eA(({subBuildFn:e,material:t,context:r})=>{let i;return"NORMAL"===e||"VERTEX"===e?(i=s1,!0!==t.flatShading&&(i=sY(i))):i=r.setupNormal().context({getUV:null}),i},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),s4=s3.transformDirection(sf).toVar("normalWorld"),s6=eA(({subBuildFn:e,context:t})=>"NORMAL"===e||"VERTEX"===e?s3:t.setupClearcoatNormal().context({getUV:null}),"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),s5=eA(([e,t=sM])=>{let r=eQ(t),i=e.div(eG(r[0].dot(r[0]),r[1].dot(r[1]),r[2].dot(r[2])));return r.mul(i).xyz}),s8=eA(([e],t)=>{let r=t.renderer.overrideNodes.modelNormalViewMatrix;if(null!==r)return r.transformDirection(e);let i=sI.mul(e);return sf.transformDirection(i)}),s9=eA(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),s3)).once(["NORMAL","VERTEX"])(),s7=eA(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),s4)).once(["NORMAL","VERTEX"])(),ne=eA(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),s6)).once(["NORMAL","VERTEX"])(),nt=new u.O9p,nr=new u.kn4,ni=tw(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),ns=tw(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),nn=tw(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?(nt.copy(r),nr.makeRotationFromEuler(nt)):nr.identity(),nr}),na=sj.negate().reflect(s3),no=sj.negate().refract(s3,ni),nl=na.transformDirection(sf).toVar("reflectVector"),nu=no.transformDirection(sf).toVar("reflectVector"),nd=new u.b4q;class nh extends se{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?nl:e.mapping===u.xFO?nu:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),eG(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let r=this.value;return e.renderer.coordinateSystem!==u.i7u&&r.isRenderTargetTexture||(t=eG(t.x.negate(),t.yz)),nn.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}let nc=eN(nh).setParameterLength(1,4).setName("cubeTexture"),np=(e=nd,t=null,r=null,i=null)=>{let s;return e&&!0===e.isCubeTextureNode?((s=ex(e.clone())).referenceNode=e.getSelf(),null!==t&&(s.uvNode=ex(t)),null!==r&&(s.levelNode=ex(r)),null!==i&&(s.biasNode=ex(i))):s=nc(e,t,r,i),s};
4class ng extends I{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 nm extends F{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=R.OBJECT}element(e){return ex(new ng(this,ex(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?sn(null,e,this.count):Array.isArray(this.getValueFromReference())?sl(null,e):"texture"===e?sr(null):"cubeTexture"===e?np(null):tw(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t.getSelf()}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 nf=(e,t,r)=>ex(new nm(e,t,r)),ny=(e,t,r,i)=>ex(new nm(e,t,i,r));class nb extends nm{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 nx=(e,t,r=null)=>ex(new nb(e,t,r)),nT=i4(),n_=sq.dFdx(),nv=sq.dFdy(),nN=nT.dFdx(),nS=nT.dFdy(),nE=nv.cross(s3),nR=s3.cross(n_),nA=nE.mul(nN.x).add(nR.mul(nS.x)),nw=nE.mul(nN.y).add(nR.mul(nS.y)),nC=nA.dot(nA).max(nw.dot(nw)),nM=nC.equal(0).select(0,nC.inverseSqrt()),nL=nA.mul(nM).toVar("tangentViewFrame"),nP=nw.mul(nM).toVar("bitangentViewFrame"),nB=eA(e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),i3("tangent","vec4")))(),nF=nB.xyz.toVar("tangentLocal"),nI=eA(({subBuildFn:e,geometry:t,material:r})=>{let i;return i="VERTEX"===e||t.hasAttribute("tangent")?sD.mul(eW(nF,0)).xyz.toVarying("v_tangentView").normalize():nL,!0!==r.flatShading&&(i=sY(i)),i},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),nV=nI.transformDirection(sf).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),nD=eA(([e,t],{subBuildFn:r,material:i})=>{let s=e.mul(nB.w).xyz;return"NORMAL"===r&&!0!==i.flatShading&&(s=s.toVarying(t)),s}).once(["NORMAL"]),nO=nD(sZ.cross(nB),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),nU=nD(sJ.cross(nF),"v_bitangentLocal").normalize().toVar("bitangentLocal"),nk=eA(({subBuildFn:e,geometry:t,material:r})=>{let i;return i="VERTEX"===e||t.hasAttribute("tangent")?nD(s3.cross(nI),"v_bitangentView").normalize():nP,!0!==r.flatShading&&(i=sY(i)),i},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),nG=nD(s4.cross(nV),"v_bitangentWorld").normalize().toVar("bitangentWorld"),nz=eQ(nI,nk,s3).toVar("TBNViewMatrix"),n$=sj.mul(nz),nH=eA(()=>{let e=to.cross(sj);return r1(e=e.cross(to).normalize(),s3,tn.mul(e6.oneMinus()).oneMinus().pow2().pow2()).normalize()}).once()();class nW extends D{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=sY(t)),i=eG(i.xy.mul(t),i.z)}let s=null;return t===u.vyJ?s=s8(i):t===u.bI3?s=nz.mul(i).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),s=s3),s}}let nq=eN(nW).setParameterLength(1,2),nj=eA(({textureNode:e,bumpScale:t})=>{let r=t=>e.cache().context({getUV:e=>t(e.uvNode||i4()),forceUVContext:!0}),i=eB(r(e=>e));return eD(eB(r(e=>e.add(e.dFdx()))).sub(i),eB(r(e=>e.add(e.dFdy()))).sub(i)).mul(t)}
4),nX=eA(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(sQ),l=o.sign().mul(i.x.mul(n).add(i.y.mul(a)));return o.abs().mul(r).sub(l).normalize()});class nK extends D{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 nX({surf_pos:sq,surf_norm:s3,dHdxy:nj({textureNode:this.textureNode,bumpScale:e})})}}let nQ=eN(nK).setParameterLength(1,2),nY=new Map;class nZ extends F{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=nY.get(e);return void 0===r&&(r=nx(e,t),nY.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===nZ.COLOR){let e=void 0!==t.color?this.getColor(r):eG();i=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===nZ.OPACITY){let e=this.getFloat(r);i=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===nZ.SPECULAR_STRENGTH)i=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:eB(1);else if(r===nZ.SPECULAR_INTENSITY){let e=this.getFloat(r);i=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===nZ.SPECULAR_COLOR){let e=this.getColor(r);i=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===nZ.ROUGHNESS){let e=this.getFloat(r);i=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===nZ.METALNESS){let e=this.getFloat(r);i=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===nZ.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===nZ.NORMAL)t.normalMap?(i=nq(this.getTexture("normal"),this.getCache("normalScale","vec2"))).normalMapType=t.normalMapType:i=t.bumpMap?nQ(this.getTexture("bump").r,this.getFloat("bumpScale")):s3;else if(r===nZ.CLEARCOAT){let e=this.getFloat(r);i=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===nZ.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===nZ.CLEARCOAT_NORMAL)i=t.clearcoatNormalMap?nq(this.getTexture(r),this.getCache(r+"Scale","vec2")):s3;else if(r===nZ.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===nZ.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===nZ.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){let e=this.getTexture(r);i=eK(aR.x,aR.y,aR.y.negate(),aR.x).mul(e.rg.mul(2).sub(eD(1)).normalize().mul(e.b))}else i=aR;else if(r===nZ.IRIDESCENCE_THICKNESS){let e=nf("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){let s=nf("0","float",t.iridescenceThicknessRange);i=e.sub(s).mul(this.getTexture(r).g).add(s)}else i=e}else if(r===nZ.TRANSMISSION){let e=this.getFloat(r);i=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===nZ.THICKNESS){let e=this.getFloat(r);i=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===nZ.IOR)i=this.getFloat(r);else if(r===nZ.LIGHT_MAP)i=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===nZ.AO)i=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===nZ.LINE_DASH_OFFSET)i=t.dashOffset?this.getFloat(r):eB(0);else{let t=this.getNodeType(e);i=this.getCache(r,t)}return i}}nZ.ALPHA_TEST="alphaTest",nZ.COLOR="color",nZ.OPACITY="opacity",nZ.SHININESS="shininess",nZ.SPECULAR="specular",nZ.SPECULAR_STRENGTH="specularStrength",nZ.SPECULAR_INTENSITY="specularIntensity",nZ.SPECULAR_COLOR="specularColor",nZ.REFLECTIVITY="reflectivity",nZ.ROUGHNESS="roughness",nZ.METALNESS="metalness",nZ.NORMAL="normal",nZ.CLEARCOAT="clearcoat",nZ.CLEARCOAT_ROUGHNESS="clearcoatRoughness",nZ.CLEARCOAT_NORMAL="clearcoatNormal",nZ.EMISSIVE="emissive",nZ.ROTATION="rotation",nZ.SHEEN="sheen",nZ.SHEEN_ROUGHNESS="sheenRoughness",nZ.ANISOTROPY="anisotropy",nZ.IRIDESCENCE="iridescence",nZ.IRIDESCENCE_IOR="iridescenceIOR",nZ.IRIDESCENCE_THICKNESS="iridescenceThickness",nZ.IOR="ior",nZ.TRANSMISSION="transmission",
4nZ.THICKNESS="thickness",nZ.ATTENUATION_DISTANCE="attenuationDistance",nZ.ATTENUATION_COLOR="attenuationColor",nZ.LINE_SCALE="scale",nZ.LINE_DASH_SIZE="dashSize",nZ.LINE_GAP_SIZE="gapSize",nZ.LINE_WIDTH="linewidth",nZ.LINE_DASH_OFFSET="dashOffset",nZ.POINT_SIZE="size",nZ.DISPERSION="dispersion",nZ.LIGHT_MAP="light",nZ.AO="ao";let nJ=eS(nZ,nZ.ALPHA_TEST),n0=eS(nZ,nZ.COLOR),n1=eS(nZ,nZ.SHININESS),n2=eS(nZ,nZ.EMISSIVE),n3=eS(nZ,nZ.OPACITY),n4=eS(nZ,nZ.SPECULAR),n6=eS(nZ,nZ.SPECULAR_INTENSITY),n5=eS(nZ,nZ.SPECULAR_COLOR),n8=eS(nZ,nZ.SPECULAR_STRENGTH),n9=eS(nZ,nZ.REFLECTIVITY),n7=eS(nZ,nZ.ROUGHNESS),ae=eS(nZ,nZ.METALNESS),at=eS(nZ,nZ.NORMAL),ar=eS(nZ,nZ.CLEARCOAT),ai=eS(nZ,nZ.CLEARCOAT_ROUGHNESS),as=eS(nZ,nZ.CLEARCOAT_NORMAL),an=eS(nZ,nZ.ROTATION),aa=eS(nZ,nZ.SHEEN),ao=eS(nZ,nZ.SHEEN_ROUGHNESS),al=eS(nZ,nZ.ANISOTROPY),au=eS(nZ,nZ.IRIDESCENCE),ad=eS(nZ,nZ.IRIDESCENCE_IOR),ah=eS(nZ,nZ.IRIDESCENCE_THICKNESS),ac=eS(nZ,nZ.TRANSMISSION),ap=eS(nZ,nZ.THICKNESS),ag=eS(nZ,nZ.IOR),am=eS(nZ,nZ.ATTENUATION_DISTANCE),af=eS(nZ,nZ.ATTENUATION_COLOR),ay=eS(nZ,nZ.LINE_SCALE),ab=eS(nZ,nZ.LINE_DASH_SIZE),ax=eS(nZ,nZ.LINE_GAP_SIZE),aT=eS(nZ,nZ.LINE_WIDTH),a_=eS(nZ,nZ.LINE_DASH_OFFSET),av=eS(nZ,nZ.POINT_SIZE),aN=eS(n
4Z,nZ.DISPERSION),aS=eS(nZ,nZ.LIGHT_MAP),aE=eS(nZ,nZ.AO),aR=tw(new u.I9Y).onReference(function(e){return e.material}).onRenderUpdate(function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}),aA=eA(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class aw extends F{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:ix(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 aC=eS(aw,aw.VERTEX),aM=eS(aw,aw.INSTANCE),aL=eS(aw,aw.SUBGROUP),aP=eS(aw,aw.INVOCATION_SUBGROUP),aB=eS(aw,aw.INVOCATION_LOCAL),aF=eS(aw,aw.DRAW);class aI extends F{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=R.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let{count:t,instanceMatrix:r,instanceColor:i}=this,{instanceMatrixNode:s,instanceColorNode:n}=this;if(null===s){if(t<=1e3)s=sn(r.array,"mat4",Math.max(t,1)).element(aM);else{let e=new u.LuO(r.array,16,1);this.buffer=e;let t=r.usage===u.Vnu?iO:iD;s=eY(t(e,"vec4",16,0),t(e,"vec4",16,4),t(e,"vec4",16,8),t(e,"vec4",16,12))}this.instanceMatrixNode=s}if(i&&null===n){let e=new u.uWO(i.array,3),t=i.usage===u.Vnu?iO:iD;this.bufferColor=e,n=eG(t(e,"vec3",3,0)),this.instanceColorNode=n}let a=s.mul(sz).xyz;if(sz.assign(a),e.hasGeometryAttribute("normal")){let e=s5(sJ,s);sJ.assign(e)}null!==this.instanceColorNode&&e2("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 aV=eN(aI).setParameterLength(2,3);class aD extends aI{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:i}=e;super(t,r,i),this.instancedMesh=e}}let aO=eN(aD).setParameterLength(1);class aU extends F{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=aM:this.batchingIdNode=aF);let t=eA(([e])=>{let t=eF(i5(si(this.batchMesh._indirectTexture),0).x),r=eF(e).mod(t),i=eF(e).div(t);return si(this.batchMesh._indirectTexture,eO(r,i)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(eF(this.batchingIdNode)),r=this.batchMesh._matricesTexture,i=eF(i5(si(r),0).x),s=eB(t).mul(4).toInt().toVar(),n=s.mod(i),a=s.div(i),o=eY(si(r,eO(n,a)),si(r,eO(n.add(1),a)),si(r,eO(n.add(2),a)),si(r,eO(n.add(3),a))),l=this.batchMesh._colorsTexture;if(null!==l){let e=eA(([e])=>{let t=eF(i5(si(l),0).x);return si(l,eO(e.mod(t),e.div(t))).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(t);e2("vec3","vBatchColor").assign(e)}let u=eQ(o);sz.assign(o.mul(sz));let d=sJ.div(eG(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),h=u.mul(d).xyz;sJ.assign(h),e.hasGeometryAttribute("tangent")&&nF.mulAssign(u)}}let ak=eN(aU).setParameterLength(1);class aG extends I{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 az=eN(aG).setParameterLength(2);class a$ extends ss{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let i,s=null;t&&t.isStruct?(i="struct",s=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(i=function(e){return f.get(e)}(e.itemSize),r=e.count):i=t,super(e,i,r),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=A.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 az(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(A.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=iI(this.value),this._varying=ix(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 aH=(e,t=null,r=0)=>ex(new a$(e,t,r)),aW=new WeakMap;class aq extends F{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=R.OBJECT,this.skinIndexNode=i3("skinIndex","uvec4"),this.skinWeightNode=i3("skinWeight","vec4"),this.bindMatrixNode=nf("bindMatrix","mat4"),this.bindMatrixInverseNo
4de=nf("bindMatrixInverse","mat4"),this.boneMatricesNode=ny("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=sz,this.toPositionNode=sz,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=tD(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=sJ){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=tD(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=ny("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,s$)}needsPreviousBoneMatrices(e){let t=e.renderer.getMRT();return t&&t.has("velocity")||!0===v(e.object).useVelocity}setup(e){this.needsPreviousBoneMatrices(e)&&s$.assign(this.getPreviousSkinnedPosition(e));let t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){let t=this.getSkinnedNormal();sJ.assign(t),e.hasGeometryAttribute("tangent")&&nF.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;aW.get(t)!==e.frameId&&(aW.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}let aj=e=>ex(new aq(e));class aX extends F{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]=iQ(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=eA(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 aK=(...e)=>ex(new aX(ev(e,"int"))).toStack(),aQ=()=>iQ("break").toStack(),aY=new WeakMap,aZ=new u.IUQ,aJ=eA(({bufferMap:e,influence:t,stride:r,width:i,depth:s,offset:n})=>{let a=eF(aC).mul(r).add(n),o=a.div(i);return si(e,eO(a.sub(o.mul(i)),o)).depth(s).xyz.mul(t)});class a0 extends F{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=tw(1),this.updateType=R.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=aY.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&&(aZ.fromBufferAttribute(n,e),p[d+s+0]=aZ.x,p[d+s+1]=aZ.y,p[d+s+2]=aZ.z,p[d+s+3]=0),!0===r&&(aZ.fromBufferAttribute(a,e),p[d+s+4]=aZ.x,p[d+s+5]=aZ.y,p[d+s+6]=aZ.z,p[d+s+7]=0),!0===i&&(aZ.fromBufferAttribute(u,e),p[d+s+8]=aZ.x,p[d+s+9]=aZ.y,p[d+s+10]=aZ.z,p[d+s+11]=4===u.itemSize?aZ.w:1)}}a={count:n,texture:g,stride:d,size:new u.I9Y(h,c)},aY.set(e,a),e.addEventListener("dispose",function t(){g.dispose(),aY.delete(e),e.removeEventListener("dispose",t)})}return a}(t);!0===r&&sz.mulAssign(this.morphBaseInfluence),!0===i&&sJ.mulAssign(this.morphBaseInfluence);let d=eF(l.width);aK(n,({i:e})=>{let t=eB(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(si(this.mesh.morphTexture,eO(eF(e).add(1),eF(aM))).r):t.assign(nf("morphTargetInfluences","float").element
4(e).toVar()),eM(t.notEqual(0),()=>{!0===r&&sz.addAssign(aJ({bufferMap:a,influence:t,stride:o,width:d,depth:e,offset:eF(0)})),!0===i&&sJ.addAssign(aJ({bufferMap:a,influence:t,stride:o,width:d,depth:e,offset:eF(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 a1=eN(a0).setParameterLength(1);class a2 extends F{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class a3 extends a2{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class a4 extends is{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=eG().toVar("directDiffuse"),i=eG().toVar("directSpecular"),s=eG().toVar("indirectDiffuse"),n=eG().toVar("indirectSpecular");return{radiance:eG().toVar("radiance"),irradiance:eG().toVar("irradiance"),iblIrradiance:eG().toVar("iblIrradiance"),ambientOcclusion:eB(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 a6=eN(a4);class a5 extends a2{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}class a8 extends F{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===a8.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=R.NONE;return(this.scope===a8.SIZE||this.scope===a8.VIEWPORT)&&(e=R.RENDER),this.updateType=e,e}update({renderer:e}){let t=e.getRenderTarget();this.scope===a8.VIEWPORT?null!==t?s.copy(t.viewport):(e.getViewport(s),s.multiplyScalar(e.getPixelRatio())):null!==t?(i.width=t.width,i.height=t.height):e.getDrawingBufferSize(i)}setup(){let e=this.scope;return e===a8.SIZE?tw(i||(i=new u.I9Y)):e===a8.VIEWPORT?tw(s||(s=new u.IUQ)):eD(oe.div(a7))}generate(e){if(this.scope===a8.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){let r=e.getNodeProperties(a7).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}a8.COORDINATE="coordinate",a8.VIEWPORT="viewport",a8.SIZE="size",a8.UV="uv";let a9=eS(a8,a8.UV),a7=eS(a8,a8.SIZE),oe=eS(a8,a8.COORDINATE),ot=eS(a8,a8.VIEWPORT),or=ot.zw,oi=oe.sub(ot.xy),os=oi.div(or),on=eA(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),a7),"vec2").once()(),oa=new u.I9Y;class oo extends se{static get type(){return"ViewportTextureNode"}constructor(e=a9,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=R.RENDER,this._textures=new WeakMap}getFrameBufferTexture(e=null){let t=this.referenceNode?this.referenceNode.defaultFramebuffer:this.defaultFramebuffer;if(null===e)return t;if(!1===this._textures.has(e)){let r=t.clone();this._textures.set(e,r)}return this._textures.get(e)}updateBefore(e){let t=e.renderer,r=t.getRenderTarget();null===r?t.getDrawingBufferSize(oa):oa.set(r.width,r.height);let i=this.getFrameBufferTexture(r);(i.image.width!==oa.width||i.image.height!==oa.height)&&(i.image.width=oa.width,i.image.height=oa.height,i.needsUpdate=!0);let s=i.generateMipmaps;i.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(i),i.generateMipmaps=s,this.value=i}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}let ol=eN(oo).setParameterLength(0,3),ou=eN(oo,null,null,{generateMipmaps:!0}).setParameterLength(0,3),od=null;class oh extends oo{static get type(){return"ViewportDepthTextureNode"}constructor(e=a9,t=null){null===od&&(od=new u.VCu),super(e,t,od)}}let oc=eN(oh).setParameterLength(0,2);class op extends F{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===op.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){let{scope:t}=this,r=this.valueNode,i=null;return t===op.DEPTH_BASE?null!==r&&(i=ob().assign(r)):t===op.DEPTH?i=e.isPerspectiveCamera?om(sq.z,sc,sp):og(sq.z,sc,sp):t===op.LINEAR_DEPTH&&(i=null!==r?e.
4isPerspectiveCamera?og(of(r,sc,sp),sc,sp):r:og(sq.z,sc,sp)),i}}op.DEPTH_BASE="depthBase",op.DEPTH="depth",op.LINEAR_DEPTH="linearDepth";let og=(e,t,r)=>e.add(t).div(t.sub(r)),om=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),of=(e,t,r)=>t.mul(r).div(r.sub(t).mul(e).sub(r)),oy=(e,t,r)=>{t=t.max(1e-6).toVar();let i=rh(e.negate().div(t)),s=rh(r.div(t));return i.div(s)},ob=eN(op,op.DEPTH_BASE),ox=eS(op,op.DEPTH),oT=eN(op,op.LINEAR_DEPTH).setParameterLength(0,1),o_=oT(oc());ox.assign=e=>ob(e);class ov extends F{static get type(){return"ClippingNode"}constructor(e=ov.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===ov.ALPHA_TO_COVERAGE)?this.setupAlphaToCoverage(t,r):this.scope===ov.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(t,r)}setupAlphaToCoverage(e,t){return eA(()=>{let r=eB().toVar("distanceToPlane"),i=eB().toVar("distanceToGradient"),s=eB(1).toVar("clipOpacity"),n=t.length;if(!1===this.hardwareClipping&&n>0){let e=sl(t);aK(n,({i:t})=>{let n=e.element(t);r.assign(sq.dot(n.xyz).negate().add(n.w)),i.assign(r.fwidth().div(2)),s.mulAssign(r6(i.negate(),i,r))})}let a=e.length;if(a>0){let t=sl(e),n=eB(1).toVar("intersectionClipOpacity");aK(a,({i:e})=>{let s=t.element(e);r.assign(sq.dot(s.xyz).negate().add(s.w)),i.assign(r.fwidth().div(2)),n.mulAssign(r6(i.negate(),i,r).oneMinus())}),s.mulAssign(n.oneMinus())}e3.a.mulAssign(s),e3.a.equal(0).discard()})()}setupDefault(e,t){return eA(()=>{let r=t.length;if(!1===this.hardwareClipping&&r>0){let e=sl(t);aK(r,({i:t})=>{let r=e.element(t);sq.dot(r.xyz).greaterThan(r.w).discard()})}let i=e.length;if(i>0){let t=sl(e),r=eV(!0).toVar("clipped");aK(i,({i:e})=>{let i=t.element(e);r.assign(sq.dot(i.xyz).greaterThan(i.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){let r=e.length;return t.enableHardwareClipping(r),eA(()=>{let i=sl(e),s=sd(t.getClipDistance());aK(r,({i:e})=>{let t=i.element(e),r=sq.dot(t.xyz).sub(t.w).negate();
4s.element(e).assign(r)})})()}}ov.ALPHA_TO_COVERAGE="alphaToCoverage",ov.DEFAULT="default",ov.HARDWARE="hardware";let oN=eA(([e])=>ry(tU(1e4,rb(tU(17,e.x).add(tU(.1,e.y)))).mul(tD(.1,rS(rb(tU(13,e.y).add(e.x))))))),oS=eA(([e])=>oN(eD(oN(e.xy),e.z))),oE=eA(([e])=>{let t=rG(rR(rC(e.xyz)),rR(rM(e.xyz))),r=eB(1).div(eB(.05).mul(t)).toVar("pixScale"),i=eD(ru(rg(rh(r))),ru(rm(rh(r)))),s=eD(oS(rg(i.x.mul(e.xyz))),oS(rg(i.y.mul(e.xyz)))),n=ry(rh(r)),a=tD(tU(n.oneMinus(),s.x),tU(n,s.y)),o=rk(n,n.oneMinus()),l=eG(a.mul(a).div(tU(2,o).mul(tO(1,o))),a.sub(tU(.5,o)).div(tO(1,o)),tO(1,tO(1,a).mul(tO(1,a)).div(tU(2,o).mul(tO(1,o)))));return r2(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 oR extends i2{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 oA=(e=0)=>ex(new oR(e)),ow=eA(([e,t])=>rk(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oC=eA(([e,t])=>rk(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oM=eA(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oL=eA(([e,t])=>r1(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),rz(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),oP=eA(([e,t])=>{let r=t.a.add(e.a.mul(t.a.oneMinus()));return eW(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"}]}),oB=eA(([e])=>eW(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),oF=eA(([e])=>(eM(e.a.equal(0),()=>eW(0)),eW(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class oI 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+g(this)}build(e){this.setup(e)}setupObserver(e){return new c(e)}setup(e){let t;e.context.setupNormal=()=>iy(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=iy(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=eW(s,e3.a).max(0);t=this.setupOutput(e,n),th.assign(t);let o=null!==this.outputNode;
4if(o&&(t=this.outputNode),null!==i){let e=r.getMRT(),i=this.mrtNode;null!==e?(o&&th.assign(t),t=e,null!==i&&(t=e.merge(i))):null!==i&&(t=i)}}else{let r=this.fragmentNode;!0!==r.isOutputStructNode&&(r=eW(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=ex(new ov(ov.ALPHA_TO_COVERAGE)):e.stack.add(ex(new ov))}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(ex(new ov(ov.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?oy(sq.z,sc,sp):og(sq.z,sc,sp))}null!==i&&ox.assign(i).toStack()}setupPositionView(){return sD.mul(sz).xyz}setupModelViewProjection(){return sg.mul(sq)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),aA}setupPosition(e){let{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&a1(t).toStack(),!0===t.isSkinnedMesh&&aj(t).toStack(),this.displacementMap){let e=nx("displacementMap","texture"),t=nx("displacementScale","float"),r=nx("displacementBias","float");sz.addAssign(sJ.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&ak(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&aO(t).toStack(),null!==this.positionNode&&sz.assign(iy(this.positionNode,"POSITION","vec3")),sz}setupDiffuseColor({object:e,geometry:t}){null!==this.maskNode&&eV(this.maskNode).not().discard();let r=this.colorNode?eW(this.colorNode):n0;!0===this.vertexColors&&t.hasAttribute("color")&&(r=r.mul(oA())),e.instanceColor&&(r=e2("vec3","vInstanceColor").mul(r)),e.isBatchedMesh&&e._colorsTexture&&(r=e2("vec3","vBatchColor").mul(r)),e3.assign(r);let i=this.opacityNode?eB(this.opacityNode):n3;e3.a.assign(e3.a.mul(i));let s=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(s=null!==this.alphaTestNode?eB(this.alphaTestNode):nJ,e3.a.lessThanEqual(s).discard()),!0===this.alphaHash&&e3.a.lessThan(oE(sz)).discard(),!1===this.transparent&&this.blending===u.NTi&&!1===this.alphaToCoverage?e3.a.assign(1):null===s&&e3.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return!0===this.lights?eG(0):e3.rgb}setupNormal(){return this.normalNode?eG(this.normalNode):at}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?nx("envMap","cubeTexture"):nx("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new a5(aS)),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:aE;t.push(new a3(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=a6(n,this.setupLightingModel(e)||null,r,i):null!==r&&(a=eG(null!==i?r1(a,r,i):r)),(s&&!0===s.isNode||t.emissive&&!0===t.emissive.isColor)&&(e4.assign(eG(s||n2)),a=a.add(e4)),a}setupFog(e,t){let r=e.fogNode;return r&&(th.assign(t),t=eW(r.toVar())),t}setupPremultipliedAlpha(e,t){return oB(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=m(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 oV=new u.mrM;class oD extends oI{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(oV),this.setValues(e)}}let oO=new u.Fvt;class oU extends oI{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(oO),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?eB(this.offsetNode):a_,t=this.dashScaleNode?eB(this.dashScaleNode):ay,r=this.dashSizeNode?eB(this.dashSizeNode):ab,i=this.gapSizeNode?eB(this.gapSizeNode):ax;tc.assign(r),tp.assign(i);let s=ix(i3("lineDistance").mul(t));(e?s.add(e):s).mod(tc.add(tp)).greaterThan(tc).discard()}}let ok=null;class oG extends oo{static get type(){return"ViewportSharedTextureNode"}constructor(e=a9,t=null){null===ok&&(ok=new u.Pem),super(e,t,ok)}updateReference(){return this}}let oz=eN(oG).setParameterLength(0,2),o$=e=>ex(e).mul(.5).add(.5),oH=new u.qBx;class oW extends oI{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(oH),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?eB(this.opacityNode):n3;e3.assign(iR(eW(o$(s3),e),u.er$))}}let oq=eA(([e=sW])=>eD(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 oj 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=oq(sW),a=new oI;a.colorNode=sr(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 oX=new WeakMap;class oK extends D{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=np(null);const t=new u.b4q;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=R.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(oX.has(e)){let t=oX.get(e);oY(t,e.mapping),this._cubeTexture=t}else{var s;let r=e.image;if(null!=(s=r)&&s.height>0){let i=new oj(r.height);i.fromEquirectangularTexture(t,e),oY(i.texture,e.mapping),this._cubeTexture=i.texture,oX.set(e,i.texture),e.addEventListener("dispose",oQ)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function oQ(e){let t=e.target;t.removeEventListener("dispose",oQ);let r=oX.get(t);void 0!==r&&(oX.delete(t),r.dispose())}function oY(e,t){t===u.wfO?e.mapping=u.hy7:t===u.uV5&&(e.mapping=u.xFO)}let oZ=eN(oK).setParameterLength(1);class oJ extends a2{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=oZ(this.envNode)}}class o0 extends a2{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=eB(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class o1{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class o2 extends o1{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,r=e.reflectedLight,i=e.irradianceLightMap;r.indirectDiffuse.assign(eW(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign(eW(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(e3.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(r1(i.rgb,i.rgb.mul(s.rgb),n8.mul(n9)));break;case u.KRh:i.rgb.assign(r1(i.rgb,s.rgb,n8.mul(n9)));break;case u.XrR:i.rgb.addAssign(s.rgb.mul(n8.mul(n9)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine)}}}let o3=new u.V9B;class o4 extends oI{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(o3),this.setValues(e)}setupNormal(){return sY(s1)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new oJ(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new o0(aS)),t}setupOutgoingLight(){return e3.rgb}setupLightingModel(){return new o2}}let o6=eA(({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))}),o5=eA(e=>e.diffuseColor.mul(1/Math.PI)),o8=eA(({dotNH:e})=>td.mul(eB(.5)).add(1).mul(eB(1/Math.PI)).mul(e.pow(td))),o9=eA(({lightDirection:e})=>{let t=e.add(sj).normalize(),r=s3.dot(t).clamp(),i=o6({f0:tl,f90:1,dotVH:sj.dot(t).clamp()}),s=eB(.25),n=o8({dotNH:r});return i.mul(s).mul(n)});class o7 extends o2{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){let i=s3.dot(e).clamp().mul(t);r.directDiffuse.addAssign(i.mul(o5({diffuseColor:e3.rgb}))),!0===this.specular&&r.directSpecular.addAssign(i.mul(o9({lightDirection:e})).mul(n8))}indirect(e){let{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;
4i.indirectDiffuse.addAssign(r.mul(o5({diffuseColor:e3}))),i.indirectDiffuse.mulAssign(t)}}let le=new u.G_z;class lt extends oI{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(le),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new oJ(t):null}setupLightingModel(){return new o7(!1)}}let lr=new u.tXL;class li extends oI{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(lr),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new oJ(t):null}setupLightingModel(){return new o7}setupVariants(){let e=(this.shininessNode?eB(this.shininessNode):n1).max(1e-4);td.assign(e);let t=this.specularNode||n4;tl.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}let ls=eA(e=>{if(!1===e.geometry.hasAttribute("normal"))return eB(0);let t=s1.dFdx().abs().max(s1.dFdy().abs());return t.x.max(t.y).max(t.z)}),ln=eA(e=>{let{roughness:t}=e,r=ls(),i=t.max(.0525);return(i=i.add(r)).min(1)}),la=eA(({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 tk(.5,s.add(n).max(re))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),lo=eA(({alphaT:e,alphaB:t,dotTV:r,dotBV:i,dotTL:s,dotBL:n,dotNV:a,dotNL:o})=>{let l=o.mul(eG(e.mul(r),t.mul(i),a).length()),u=a.mul(eG(e.mul(s),t.mul(n),o).length());return tk(.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"}]}),ll=eA(({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"}]}),lu=eB(1/Math.PI),ld=eA(({alphaT:e,alphaB:t,dotNH:r,dotTH:i,dotBH:s})=>{let n=e.mul(t),a=eG(t.mul(i),e.mul(s),n.mul(r)),o=a.dot(a),l=n.div(o);return lu.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"}]}),lh=eA(({lightDirection:e,f0:t,f90:r,roughness:i,f:s,normalView:n=s3,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{let l,u,d=i.pow2(),h=e.add(sj).normalize(),c=n.dot(e).clamp(),p=n.dot(sj).clamp(),g=n.dot(h).clamp(),m=o6({f0:t,f90:r,dotVH:sj.dot(h).clamp()});if(ef(a)&&(m=tt.mix(m,s)),ef(o)){let t=ta.dot(e),r=ta.dot(sj),i=ta.dot(h),s=to.dot(e),n=to.dot(sj),a=to.dot(h);l=lo({alphaT:ts,alphaB:d,dotTV:r,dotBV:n,dotTL:t,dotBL:s,dotNV:p,dotNL:c}),u=ld({alphaT:ts,alphaB:d,dotNH:g,dotTH:i,dotBH:a})}else l=la({alpha:d,dotNL:c,dotNV:p}),u=ll({alpha:d,dotNH:g});return m.mul(l).mul(u)}),lc=eA(({roughness:e,dotNV:t})=>{let r=eW(-1,-.0275,-.572,.022),i=eW(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 eD(-1.04,1.04).mul(n).add(s.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),lp=eA(e=>{let{dotNV:t,specularColor:r,specularF90:i,roughness:s}=e,n=lc({dotNV:t,roughness:s});return r.mul(n.x).add(i.mul(n.y))}),lg=eA(({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(eG(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"}]}),lm=eA(({roughness:e,dotNH:t})=>{let r=e.pow2(),i=eB(1).div(r),s=t.pow2().oneMinus().max(.0078125);return eB(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"}]}),lf=eA(({dotNV:e,dotNL:t})=>eB(1).div(eB(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),ly=eA(({lightDirection:e})=>{let t=e.add(sj).normalize(),r=s3.dot(e).clamp(),i=s3.dot(sj).clamp(),s=lm({roughness:te,dotNH:s3.dot(t).clamp()}),n=lf({dotNV:i,dotNL:r});return e7.mul(s).mul(n)}),lb=eA(({N:e,V:t,roughness:r})=>{let i=eD(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"}]}),lx=eA(({f:e})=>{let t=e.length();return rG(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),lT=eA(({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,rG(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"}]}),l_=eA(({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=eG().toVar();return eM(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(eQ(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=eG(0).toVar();f.addAssign(lT({v1:c,v2:p})),f.addAssign(lT({v1:p,v2:g})),f.addAssign(lT({v1:g,v2:m})),f.addAssign(lT({v1:m,v2:c})),h.assign(eG(lx({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"}]}),lv=1/6,lN=e=>tU(lv,tU(e,tU(e,e.negate().add(3)).sub(3)).add(1)),lS=e=>tU(lv,tU(e,tU(e,tU(3,e).sub(6))).add(4)),lE=e=>tU(lv,tU(e,tU(e,tU(-3,e).add(3)).add(3)).add(1)),lR=e=>tU(lv,rX(e,3)),lA=e=>lN(e).add(lS(e)),lw=e=>lE(e).add(lR(e)),lC=e=>tD(-1,lS(e).div(lN(e).add(lS(e)))),lM=e=>tD(1,lR(e).div(lE(e).add(lR(e)))),lL=(e,t,r)=>{let i=tU(e.uvNode,t.zw).add(.5),s=rg(i),n=ry(i),a=lA(n.x),o=lw(n.x),l=lC(n.x),u=lM(n.x),d=lC(n.y),h=lM(n.y),c=eD(s.x.add(l),s.y.add(d)).sub(.5).mul(t.xy),p=eD(s.x.add(u),s.y.add(d)).sub(.5).mul(t.xy),g=eD(s.x.add(l),s.y.add(h)).sub(.5).mul(t.xy),m=eD(s.x.add(u),s.y.add(h)).sub(.5).mul(t.xy),f=lA(n.y).mul(tD(a.mul(e.sample(c).level(r)),o.mul(e.sample(p).level(r)))),y=lw(n.y).mul(tD(a.mul(e.sample(g).level(r)),o.mul(e.sample(m).level(r))));return f.add(y)},lP=eA(([e,t])=>{let r=eD(e.size(eF(t))),i=eD(e.size(eF(t.add(1)))),s=tk(1,r),n=tk(1,i),a=lL(e,eW(s,r),rg(t)),o=lL(e,eW(n,i),rm(t));return ry(t).mix(a,o)}),lB=eA(([e,t])=>{let r=t.mul(i9(e));return lP(e,r)}),lF=eA(([e,t,r,i,s])=>{let n=eG(r4(t.negate(),rf(e),tk(1,i))),a=eG(rR(s[0].xyz),rR(s[1].xyz),rR(s[2].xyz));return rf(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"}]}),lI=eA(([e,t])=>e.mul(r2(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),lV=ou(),lD=ou(),lO=eA(([e,t,r],{material:i})=>lP((i.side===u.hsX?lV:lD).sample(e),rh(a7.x).mul(lI(t,r)))),lU=eA(([e,t,r])=>(eM(r.notEqual(0),()=>rl(rd(t).negate().div(r).negate().mul(e))),eG(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),lk=eA(([e,t,r,i,s,n,a,o,l,u,d,h,c,p,g])=>{let m,f;if(g){m=eW().toVar(),f=eG().toVar();let s=d.sub(1).mul(g.mul(.025)),n=eG(d.sub(s),d,d.add(s));aK({start:0,end:3},({i:s})=>
4{let d=n.element(s),g=lF(e,t,h,d,o),y=a.add(g),b=u.mul(l.mul(eW(y,1))),x=eD(b.xy.div(b.w)).toVar();x.addAssign(1),x.divAssign(2),x.assign(eD(x.x,x.y.oneMinus()));let T=lO(x,r,d);m.element(s).assign(T.element(s)),m.a.addAssign(T.a),f.element(s).assign(i.element(s).mul(lU(rR(g),c,p).element(s)))}),m.a.divAssign(3)}else{let s=lF(e,t,h,d,o),n=a.add(s),g=u.mul(l.mul(eW(n,1))),y=eD(g.xy.div(g.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(eD(y.x,y.y.oneMinus())),m=lO(y,r,d),f=i.mul(lU(rR(s),c,p))}let y=f.rgb.mul(m.rgb),b=eG(lp({dotNV:e.dot(t).clamp(),specularColor:s,specularF90:n,roughness:r})),x=f.r.add(f.g,f.b).div(3);return eW(b.oneMinus().mul(y),m.a.oneMinus().mul(x).oneMinus())}),lG=eQ(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),lz=(e,t)=>e.sub(t).div(e.add(t)).pow2(),l$=eA(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:i,baseF0:s})=>{let n,a=r1(e,t,r6(0,.03,i)),o=e.div(a).pow2().mul(r.pow2().oneMinus()).oneMinus();eM(o.lessThan(0),()=>eG(1));let l=o.sqrt(),u=o6({f0:lz(a,e),f90:1,dotVH:r}),d=u.oneMinus(),h=a.lessThan(e).select(Math.PI,0),c=eB(Math.PI).sub(h),p=(n=s.clamp(0,.9999).sqrt(),eG(1).add(n).div(eG(1).sub(n))),g=o6({f0:lz(p,a.toVec3()),f90:1,dotVH:l}),m=eG(p.x.lessThan(a).select(Math.PI,0),p.y.lessThan(a).select(Math.PI,0),p.z.lessThan(a).select(Math.PI,0)),f=a.mul(i,l,2),y=eG(c).add(m),b=u.mul(g).clamp(1e-5,.9999),x=b.sqrt(),T=d.pow2().mul(g).div(eG(1).sub(b)),_=u.add(T).toVar(),v=T.sub(d).toVar();return aK({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{var t,r;let i,s,n,a,o,l;v.mulAssign(x);let u=(t=eB(e).mul(f),r=eB(e).mul(y),i=t.mul(2*Math.PI*1e-9),s=eG(54856e-17,44201e-17,52481e-17),n=eG(1681e3,1795300,2208400),a=eG(43278e5,93046e5,66121e5),o=eB(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(i.mul(2239900).add(r.x).cos()).mul(i.pow2().mul(-45282e5).exp()),l=eG((l=s.mul(a.mul(2*Math.PI).sqrt()).mul(n.mul(i).add(r).cos()).mul(i.pow2().negate().mul(a).exp())).x.add(o),l.y,l.z).div(10685e-11),lG.mul(l)).mul(2);_.addAssign(v.mul(u))}),_.max(eG(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"}]}),lH=eA(({normal:e,viewDir:t,roughness:r})=>{let i=e.dot(t).saturate(),s=r.pow2(),n=ii(r.lessThan(.25),eB(-339.2).mul(s).add(eB(161.4).mul(r)).sub(25.9),eB(-8.48).mul(s).add(eB(14.3).mul(r)).sub(9.95)),a=ii(r.lessThan(.25),eB(44).mul(s).sub(eB(23.7).mul(r)).add(3.26),eB(1.97).mul(s).sub(eB(3.27).mul(r)).add(.72));return ii(r.lessThan(.25),0,eB(.1).mul(r).sub(.025)).add(n.mul(i).add(a).exp()).mul(1/Math.PI).saturate()}),lW=eG(.04),lq=eB(1);class lj extends o1{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=eG().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=eG().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=eG().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=eG().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=eG().toVar("sheenSpecularIndirect")),!0===this.iridescence){let e=s3.dot(sj).clamp();this.iridescenceFresnel=l$({outsideIOR:eB(1),eta2:tr,cosTheta1:e,thinFilmThickness:ti,baseF0:tl}),this.iridescenceF0=lg({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){let t=sx.sub(sH).normalize(),r=e.context;r.backdrop=lk(s4,t,e6,e3,tl,tu,sH,sM,sf,sg,tm,ty,tx,tb,this.dispersion?tT:null),r.backdropAlpha=tf,e3.a.mulAssign(r1(1,r.backdrop.a,tf))}super.start(e)}computeMultiscattering(e,t,r){let i=lc({roughness:e6,dotNV:s3.dot(sj).clamp()}),s=(this.iridescenceF0?tt.mix(tl,this.iridescenceF0):tl).mul(i.x).add(r.mul(i.y)),n=i.x.add(i.y).oneMinus(),a=tl.add(tl.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=s3.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(i.mul(ly({lightDirection:e}))),!0===this.clearcoat){let r=s6.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(lh({lightDirection:e,f0:lW,f90:lq,roughness:e9,normalView:s6})))}r.directDiffuse.addAssign(i.mul(o5({diffuseColor:e3.rgb}))),r.directSpecular.addAssign(i.mul(lh({lightDirection:e,f0:tl,f90:1,roughness:e6,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=sq.toVar(),c=lb({N:s3,V:sj,roughness:e6}
vendor: 4,308 bytes, line 4
4),p=n.sample(c).toVar(),g=a.sample(c).toVar(),m=eQ(eG(p.x,0,p.y),eG(0,1,0),eG(p.z,0,p.w)).toVar(),f=tl.mul(g.x).add(tl.oneMinus().mul(g.y)).toVar();s.directSpecular.addAssign(e.mul(f).mul(l_({N:s3,V:sj,P:h,mInv:m,p0:o,p1:l,p2:u,p3:d}))),s.directDiffuse.addAssign(e.mul(e3).mul(l_({N:s3,V:sj,P:h,mInv:eQ(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(o5({diffuseColor:e3})))}indirectSpecular(e){let{radiance:t,iblIrradiance:r,reflectedLight:i}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(e7,lH({normal:s3,viewDir:sj,roughness:te}))),!0===this.clearcoat){let e=lp({dotNV:s6.dot(sj).clamp(),specularColor:lW,specularF90:lq,roughness:e9});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let s=eG().toVar("singleScattering"),n=eG().toVar("multiScattering"),a=r.mul(1/Math.PI);this.computeMultiscattering(s,n,tu);let o=s.add(n),l=e3.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=s3.dot(sj).clamp().add(t),s=e6.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=o6({dotVH:s6.dot(sj).clamp(),f0:lW,f90:lq}),r=t.mul(e8.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(e8));t.assign(r)}if(!0===this.sheen){let e=e7.r.max(e7.g).max(e7.b).mul(.157).oneMinus(),r=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}let lX=eB(1),lK=eB(-2),lQ=eB(.8),lY=eB(-1),lZ=eB(.4),lJ=eB(2),l0=eB(.305),l1=eB(3),l2=eB(.21),l3=eB(4),l4=eB(4),l6=eB(16),l5=eA(([e])=>{let t=eG(rS(e)).toVar(),r=eB(-1).toVar();return eM(t.x.greaterThan(t.z),()=>{eM(t.x.greaterThan(t.y),()=>{r.assign(ii(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(ii(e.y.greaterThan(0),1,4))})}).Else(()=>{eM(t.z.greaterThan(t.y),()=>{r.assign(ii(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(ii(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),l8=eA(([e,t])=>{let r=eD().toVar();return eM(t.equal(0),()=>{r.assign(eD(e.z,e.y).div(rS(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(eD(e.x.negate(),e.z.negate()).div(rS(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(eD(e.x.negate(),e.y).div(rS(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(eD(e.z.negate(),e.y).div(rS(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(eD(e.x.negate(),e.z).div(rS(e.y)))}).Else(()=>{r.assign(eD(e.x,e.y).div(rS(e.z)))}),tU(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),l9=eA(([e])=>{let t=eB(0).toVar();return eM(e.greaterThanEqual(lQ),()=>{t.assign(lX.sub(e).mul(lY.sub(lK)).div(lX.sub(lQ)).add(lK))}).ElseIf(e.greaterThanEqual(lZ),()=>{t.assign(lQ.sub(e).mul(lJ.sub(lY)).div(lQ.sub(lZ)).add(lY))}).ElseIf(e.greaterThanEqual(l0),()=>{t.assign(lZ.sub(e).mul(l1.sub(lJ)).div(lZ.sub(l0)).add(lJ))}).ElseIf(e.greaterThanEqual(l2),()=>{t.assign(l0.sub(e).mul(l3.sub(l1)).div(l0.sub(l2)).add(l1))}).Else(()=>{t.assign(eB(-2).mul(rh(tU(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),l7=eA(([e,t])=>{let r=e.toVar();r.assign(tU(2,r).sub(1));let i=eG(r,1).toVar();return eM(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"}]}),ue=eA(([e,t,r,i,s,n])=>{let a=eB(r),o=eG(t),l=r2(l9(a),lK,n),u=ry(l),d=rg(l),h=eG(ut(e,o,d,i,s,n)).toVar();return eM(u.notEqual(0),()=>{let t=eG(ut(e,o,d.add(1),i,s,n)).toVar();
4h.assign(r1(h,t,u))}),h}),ut=eA(([e,t,r,i,s,n])=>{let a=eB(r).toVar(),o=eG(t),l=eB(l5(o)).toVar(),u=eB(rG(l4.sub(a),0)).toVar();a.assign(rG(a,l4));let d=eB(ru(a)).toVar(),h=eD(l8(o,l).mul(d.sub(2)).add(1)).toVar();return eM(l.greaterThan(2),()=>{h.y.addAssign(d),l.subAssign(3)}),h.x.addAssign(l.mul(d)),h.x.addAssign(u.mul(tU(3,l6))),h.y.addAssign(tU(4,ru(n).sub(d))),h.x.mulAssign(i),h.y.mulAssign(s),e.sample(h).grad(eD(),eD())}),ur=eA(({envMap:e,mipInt:t,outputDirection:r,theta:i,axis:s,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{let l=rx(i);return ut(e,r.mul(l).add(s.cross(r).mul(rb(i))).add(s.mul(s.dot(r).mul(l.oneMinus()))),t,n,a,o)}),ui=eA(({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=eG(ii(t,r,rj(r,i))).toVar();eM(c.equal(eG(0)),()=>{c.assign(eG(i.z,0,i.x.negate()))}),c.assign(rf(c));let p=eG().toVar();return p.addAssign(s.element(0).mul(ur({theta:0,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),aK({start:eF(1),end:e},({i:e})=>{eM(e.greaterThanEqual(n),()=>{aQ()});let t=eB(a.mul(eB(e))).toVar();p.addAssign(s.element(e).mul(ur({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(ur({theta:t,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})))}),eW(p,1)}),us=[.125,.215,.35,.446,.526,.582],un=new u.qUd(-1,1,1,-1,0,1),ua=new u.ubm(90,1),uo=new u.Q1f,ul=null,uu=0,ud=0,uh=(1+Math.sqrt(5))/2,uc=1/uh,up=[new u.Pq0(-uh,uc,0),new u.Pq0(uh,uc,0),new u.Pq0(-uc,0,uh),new u.Pq0(uc,0,uh),new u.Pq0(0,uh,-uc),new u.Pq0(0,uh,uc),new u.Pq0(-1,1,-1),new u.Pq0(1,1,-1),new u.Pq0(-1,1,1),new u.Pq0(1,1,1)],ug=new u.Pq0,um=new WeakMap,uf=[3,1,5,0,4,2],uy=l7(i4(),i3("faceIndex")).normalize(),ub=eG(uy.x,uy.y,uy.z);class ux{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=ug,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}ul=this._renderer.getRenderTarget(),uu=this._renderer.getActiveCubeFace(),ud=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=uN(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=uS(),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(ul,uu,ud),e.scissorTest=!1,u_(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),ul=this._renderer.getRenderTarget(),uu=this._renderer.getActiveCubeFace(),ud=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 uT(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){var t,r,i;let s,n,a,o,l,d,h,c,p,g;null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=uT(e.width,e.height);let{_lodMax:m}=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+us.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=us[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=uf[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}}(m)),this._blurMaterial=(t=m,r=e.width,i=e.height,s=sl(Array(20).fill(0)),n=tw(new u.Pq0(0,1,0)),a=tw(0),o=eB(20),l=tw(0),d=tw(1),h=sr(null),c=tw(0),p={n:o,latitudinal:l,weights:s,poleAxis:n,outputDirection:ub,dTheta:a,samples:d,envMap:h,mipInt:c,CUBEUV_TEXEL_WIDTH:eB(1/r),CUBEUV_TEXEL_HEIGHT:eB(1/i),CUBEUV_MAX_MIP:eB(t)},(g=uv("blur")).fragmentNode=ui({...p,latitudinal:l.equal(1)}),um.set(g,p),g)}}async _compileMaterial(e){let t=new u.eaF(this._lodPlanes[0],e);await this._renderer.compile(t,un)}_sceneToCubeUV(e,t,r,i,s){ua.near=t,ua.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(uo),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(uo),h=!0),o.setRenderTarget(i),o.clear(),h&&o.render(d,ua);for(let t=0;t<6;t++){let r=t%3;0===r?(ua.up.set(0,n[t],0),ua.position.set(s.x,s.y,s.z),ua.lookAt(s.x+a[t],s.y,s.z)):1===r?(ua.up.set(0,0,n[t]),ua.position.set(s.x,s.y,s.z),ua.lookAt(s.x,s.y+a[t],s.z)):(ua.up.set(0,n[t],0),ua.position.set(s.x,s.y,s.z),ua.lookAt(s.x,s.y,s.z+a[t]));let l=this._cubeSize;u_(i,r*l,t>2?l:0,l,l),o.render(e,ua)}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=uN(e)):null===this._equirectMaterial&&(this._equirectMaterial=uS(e));let s=i?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;let n=this._lodMeshes[0];n.material=s;let a=this._cubeSize;u_(t,0,0,3*a,2*a),r.setRenderTarget(t),r.render(n,un)}_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=up[(i-t-1)%up.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=um.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);u_(t,3*b*(i>y-4?i-y+4:0),x,3*b,2*b),o.setRenderTarget(t),o.render(u,un)}}function uT(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 u_(e,t,r,i,s){e.viewport.set(t,r,i,s),e.scissor.set(t,r,i,s)}function uv(e){let t=new oI;return t.depthTest=!1,t.depthWrite=!1,t.blending=u.XIg,t.name=`PMREM_${e}`,t}function uN(e){let t=uv("cubemap");return t.fragmentNode=np(e,ub),t}function uS(e){let t=uv("equirect");return t.fragmentNode=sr(e,oq(ub),0),t}let uE=new WeakMap;class uR extends D{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;const i=new u.gPd;i.isRenderTargetTexture=!0,this._texture=sr(i),this._width=tw(0),this._height=tw(0),this._maxMip=tw(0),this.updateBeforeType=R.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){var t;let r,i={texelWidth:1/(3*Math.max(Math.pow(2,r=Math.log2(t=e.image.height)-2),112)),texelHeight:1/t,maxMip:r};this._texture.value=e,this._width.value=i.texelWidth,this._height.value=i.texelHeight,this._maxMip.value=i.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=uE.get(i))&&(n=new WeakMap,uE.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 ux(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this)),t=nn.mul(eG(t.x,t.y.negate(),t.z));let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),ue(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}let uA=eN(uR).setParameterLength(1,3),uw=new WeakMap;class uC extends a2{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=uw.get(e);void 0===i&&(i=uA(e),uw.set(e,i)),r=i}let i=!0===t.useAnisotropy||t.anisotropy>0?nH:s3,s=r.context(uM(e6,i)).mul(ns),n=r.context(uL(s4)).mul(Math.PI).mul(ns),a=i$(s),o=i$(n);
4e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(o);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=i$(r.context(uM(e9,s6)).mul(ns));l.addAssign(e)}}}let uM=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=sj.negate().reflect(t),r=(r=e.mul(e).mix(r,t).normalize()).transformDirection(sf)),r),getTextureLevel:()=>e}},uL=e=>({getUV:()=>e,getTextureLevel:()=>eB(1)}),uP=new u._4j;class uB extends oI{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(uP),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new uC(t):null}setupLightingModel(){return new lj}setupSpecular(){let e=r1(eG(.04),e3.rgb,e5);tl.assign(e),tu.assign(1)}setupVariants(){let e=this.metalnessNode?eB(this.metalnessNode):ae;e5.assign(e);let t=this.roughnessNode?eB(this.roughnessNode):n7;t=ln({roughness:t}),e6.assign(t),this.setupSpecular(),e3.assign(eW(e3.rgb.mul(e.oneMinus()),e3.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}let uF=new u.uSd;class uI extends uB{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(uF),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?eB(this.iorNode):ag;tm.assign(e),tl.assign(r1(rk(rK(tm.sub(1).div(tm.add(1))).mul(n5),eG(1)).mul(n6),e3.rgb,e5)),tu.assign(r1(n6,1,e5))}setupLightingModel(){return new lj(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?eB(this.clearcoatNode):ar,t=this.clearcoatRoughnessNode?eB(this.clearcoatRoughnessNode):ai;e8.assign(e),e9.assign(ln({roughness:t}))}if(this.useSheen){let e=this.sheenNode?eG(this.sheenNode):aa,t=this.sheenRoughnessNode?eB(this.sheenRoughnessNode):ao;e7.assign(e),te.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?eB(this.iridescenceNode):au,t=this.iridescenceIORNode?eB(this.iridescenceIORNode):ad,r=this.iridescenceThicknessNode?eB(this.iridescenceThicknessNode):ah;tt.assign(e),tr.assign(t),ti.assign(r)}if(this.useAnisotropy){let e=(this.anisotropyNode?eD(this.anisotropyNode):al).toVar();tn.assign(e.length()),eM(tn.equal(0),()=>{e.assign(eD(1,0))}).Else(()=>{e.divAssign(eD(tn)),tn.assign(tn.saturate())}),ts.assign(tn.pow2().mix(e6.pow2(),1)),ta.assign(nz[0].mul(e.x).add(nz[1].mul(e.y))),to.assign(nz[1].mul(e.x).sub(nz[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?eB(this.transmissionNode):ac,t=this.thicknessNode?eB(this.thicknessNode):ap,r=this.attenuationDistanceNode?eB(this.attenuationDistanceNode):am,i=this.attenuationColorNode?eG(this.attenuationColorNode):af;if(tf.assign(e),ty.assign(t),tb.assign(r),tx.assign(i),this.useDispersion){let e=this.dispersionNode?eB(this.dispersionNode):aN;tT.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?eG(this.clearcoatNormalNode):as}setup(e){e.context.setupClearcoatNormal=()=>iy(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 uV=eA(({normal:e,lightDirection:t,builder:r})=>{let i=eD(e.dot(t).mul(.5).add(.5),0);if(r.material.gradientMap)return eG(nx("gradientMap","texture").context({getUV:()=>i}).r);{let e=i.fwidth().mul(.5);return r1(eG(.7),eG(1),r6(eB(.7).sub(e.x),eB(.7).add(e.x),i.x))}});class uD extends o1{direct({lightDirection:e,lightColor:t,reflectedLight:r},i){let s=uV({normal:sZ,lightDirection:e,builder:i}).mul(t);r.directDiffuse.addAssign(s.mul(o5({diffuseColor:e3.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(o5({diffuseColor:e3}))),i.indirectDiffuse.mulAssign(t)}}let uO=new u.Df;class uU extends oI{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(uO),this.setValues(e)}setupLightingModel(){return new uD}}let uk=eA(()=>{let e=eG(sj.z,0,sj.x.negate()).normalize(),t=sj.cross(e);return eD(e.dot(s3),t.dot(s3)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),uG=new u.FNr;class uz extends oI{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(uG),this.setValues(e)}setupVariants(e){let t;t=e.material.matcap?nx("matcap","texture").context({getUV:()=>uk}):eG(r1(.2,.8,uk.y)),e3.rgb.mulAssign(t.rgb)}}class u$ extends D{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 eK(e,i,i.negate(),e).mul(r)}{let e=eY(eW(1,0,0,0),eW(0,rx(t.x),rb(t.x).negate(),0),eW(0,rb(t.x),rx(t.x),0),eW(0,0,0,1)),i=eY(eW(rx(t.y),0,rb(t.y),0),eW(0,1,0,0),eW(rb(t.y).negate(),0,rx(t.y),0),eW(0,0,0,1)),s=eY(eW(rx(t.z),rb(t.z).negate(),0,0),eW(rb(t.z),rx(t.z),0,0),eW(0,0,1,0),eW(0,0,0,1));return e.mul(i).mul(s).mul(eW(r,1)).xyz}}}let uH=eN(u$).setParameterLength(2),uW=new u.RoJ;class uq extends oI{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(uW),this.setValues(e)}setupPositionView(e){let{object:t,camera:r}=e,i=this.sizeAttenuation,{positionNode:s,rotationNode:n,scaleNode:a}=this,o=sD.mul(eG(s||0)),l=eD(sM[0].xyz.length(),sM[1].xyz.length());if(null!==a&&(l=l.mul(eD(a))),!1===i)if(r.isPerspectiveCamera)l=l.mul(o.z.negate());else{let e=eB(2).div(sg.element(1).element(1));l=l.mul(e.mul(2))}let u=sG.xy;if(t.center&&!0===t.center.isVector2){let e=ex(new iw("center","vec2",t));u=u.sub(e.sub(.5))}let d=uH(u=u.mul(l),eB(n||an));return eW(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 uj=new u.BH$;class uX extends uq{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(uj),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return sD.mul(eG(e||sz)).xyz}setupVertex(e){let t=super.setupVertex(e);if(!0!==e.material.isNodeMaterial)return t;let{rotationNode:r,scaleNode:i,sizeNode:s}=this,n=sG.xy.toVar(),a=ot.z.div(ot.w);if(r&&r.isNode){let e=eB(r);n.assign(uH(n,e))}let o=null!==s?eD(s):av;return!0===this.sizeAttenuation&&(o=o.mul(o.div(sq.z.negate()))),i&&i.isNode&&(o=o.mul(eD(i))),n.mulAssign(o.mul(2)),n.assign(n.div(ot.z)),n.y.assign(n.y.mul(a)),n.assign(n.mul(t.w)),t.addAssign(eW(n,0,0)),t}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}class uK extends o1{constructor(){super(),this.shadowNode=eB(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){e3.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(e3.rgb)}}let uQ=new u.q2;class uY extends oI{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(uQ),this.setValues(e)}setupLightingModel(){return new uK}}e1("vec3"),e1("vec3"),e1("vec3");class uZ{constructor(e,t){this.nodes=e,this.info=t,this._context="u">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 uJ{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 u0=0;class u1{constructor(e,t,r,i,s,n,a,o,l,u){this.id=u0++,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}=this,r=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 i;if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;let s=t[e];if(null!==s){let e=typeof s;"number"===e?i=0!==s?"1":"0":"object"===e?(i="{",s.isTexture&&(i+=s.mapping),i+="}"):i=String(s)}else i=String(s);r+=i+","}return r+=this.clippingContextCacheKey+",",e.geometry&&(r+=this.getGeometryCacheKey()),e.skeleton&&(r+=e.skeleton.bones.length+","),e.isBatchedMesh&&(r+=e._matricesTexture.uuid+",",null!==e._colorsTexture&&(r+=e._colorsTexture.uuid+",")),e.count>1&&(r+=e.uuid+","),p(r+=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=((...e)=>p(e))(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=((...e)=>p(e))(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 u2=[];class u3{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);u2[0]=e,u2[1]=t,u2[2]=n,u2[3]=s;let u=l.get(u2);return void 0===u?(u=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,i,s,n,a,o),l.set(u2,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)),u2.length=0,u}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new uJ)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,i,s,n,a,o,l,u,d){let h=this.getChainMap(d),c=new u1(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 u4{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}}class u6 extends u4{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)1===t?this.backend.createAttribute(e):2===t?this.backend.createIndexAttribute(e):3===t?this.backend.createStorageAttribute(e):4===t&&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 u5(e){return null!==e.index?e.index.version:e.attributes.position.version}function u8(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=u5(e),s}class u9 extends u4{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,3):this.updateAttribute(t,1);let t=this.getIndex(e);null!==t&&this.updateAttribute(t,2);let r=e.geometry.indirect;null!==r&&this.updateAttribute(r,4)}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=u8(t),e.set(t,r)):r.version!==u5(t)&&(this.attributes.delete(r),r=u8(t),e.set(t,r)),i=r}return i}}class u7{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 de{constructor(e){this.cacheKey=e,this.usedTimes=0}}class dt extends de{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class dr extends de{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let di=0;
4class ds{constructor(e,t,r,i=null,s=null){this.id=di++,this.code=e,this.stage=t,this.name=r,this.transforms=i,this.attributes=s,this.usedTimes=0}}class dn extends u4{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 ds(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 ds(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 ds(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 dr(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 dt(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 da extends u4{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?4:3;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?4:3;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)),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 dl(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 du(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 dd(e){return(e.transmission>0||e.transmissionNode)&&e.side===u.$EB&&!1===e.forceSinglePass}class dh{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?(dd(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?(dd(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||dl),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||du),this.transparent.length>1&&this.transparent.sort(t||du)}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 dc=[];class dp{constructor(e){this.lighting=e,this.lists=new uJ}get(e,t){let r=this.lists;dc[0]=e,dc[1]=t;let i=r.get(dc);return void 0===i&&(i=new dh(this.lighting,e,t),r.set(dc,i)),dc.length=0,i}dispose(){this.lists=new uJ}}let dg=0;class dm{constructor(){this.id=dg++,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 df(this)}}function df(e){let{textures:t,activeCubeFace:r}=e,i=[r];for(let e of t)i.push(e.id);return p(i)}let dy=[],db=new u.Z58,dx=new u.i7d;class dT{constructor(){this.chainMaps={}}get(e,t,r=null){let i;if(dy[0]=e,dy[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(dy);return void 0===n&&(n=new dm,s.set(dy,n)),dy.length=0,null!==r&&(n.sampleCount=0===r.samples?1:r.samples),n}getForClear(e=null){return this.get(db,dx,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new uJ)}dispose(){this.chainMaps={}}}let d_=new u.Pq0;class dv extends u4{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)};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,i||!0===e.isStorageTexture)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)}}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++;let t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e)};e.addEventListener("dispose",t)}r.version=e.version}getSize(e,t=d_){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),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.isCompressedTexture?e.mipmaps?e.mipmaps.length:1:Math.floor(Math.log2(Math.max(t,r)))+1}needsMipmaps(e){return!0===e.isCompressedTexture||e.generateMipmaps}_destroyTexture(e){!0===this.has(e)&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class dN 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 dS extends e0{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}class dE extends F{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}add(e){return this.nodes.push(e),this}If(e,t){let r=new eb(t);return this._currentCond=ii(e,r),this.add(this._currentCond)}ElseIf(e,t){let r=ii(e,new eb(t));return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new eb(e),this}Switch(e){return this._expressionNode=ex(e),this}Case(...e){let t=[];if(e.length>=2)for(let r=0;r<e.length-1;r++)t.push(this._expressionNode.equal(ex(e[r])));else throw Error("TSL: Invalid parameter length. Case() requires at least two parameters.");let r=new eb(e[e.length-1]),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let s=ii(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}build(e,...t){let r=e.currentStack,i=eC();ew(this),e.currentStack=this;let s=e.buildStage;
4for(let t of this.nodes)if(!t.isVarNode||!0!==t.intent||!0===e.getNodeProperties(t).assign){if("setup"===s)t.build(e);else if("analyze"===s)t.build(e,this);else if("generate"===s){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")}}let n=this.outputNode?this.outputNode.build(e,...t):super.build(e,...t);return ew(i),e.currentStack=r,n}}let dR=eN(dE).setParameterLength(0,1);class dA extends F{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=function(e){return Object.entries(e).map(([e,t])=>"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}(e),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.addInclude(this)}generate(e){return this.getNodeType(e)}}class dw extends F{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structLayoutNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structLayoutNode.getNodeType(e)}getMemberType(e,t){return this.structLayoutNode.getMemberType(e,t)}generate(e){let t=e.getVarFromNode(this),r=t.type,i=e.getPropertyName(t);return e.addLineFlowCode(`${i} = ${e.generateStruct(r,this.structLayoutNode.membersLayout,this.values)}`,this),t.name}}class dC extends F{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 dM=eN(dC);function dL(e,t){for(let r=0;r<e.length;r++)if(e[r].name===t)return r;return -1}class dP extends dC{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 dB({...this.outputNodes,...e.outputNodes})}setup(e){let t=this.outputNodes,r=e.renderer.getRenderTarget(),i=[],s=r.textures;for(let e in t)i[dL(s,e)]=eW(t[e]);return this.members=i,super.setup(e)}}let dB=eN(dP),dF=eA(([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)}),dI=(e,t)=>rX(tU(4,e.mul(tO(1,e))),t),dV=eA(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),dD=eA(([e])=>eG(dV(e.z.add(dV(e.y.mul(1)))),dV(e.z.add(dV(e.x.mul(1)))),dV(e.y.add(dV(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),dO=eA(([e,t,r])=>{let i=eG(e).toVar(),s=eB(1.4).toVar(),n=eB(0).toVar(),a=eG(i).toVar();return aK({start:eB(0),end:eB(3),type:"float",condition:"<="},()=>{let e=eG(dD(a.mul(2))).toVar();i.addAssign(e.add(r.mul(eB(.1).mul(t)))),a.mulAssign(1.8),s.mulAssign(1.5),i.mulAssign(1.2);let o=eB(dV(i.z.add(dV(i.x.add(dV(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 dU extends F{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;
4for(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 dk=eN(dU),dG=e=>(...t)=>dk(e,...t),dz=tw(0).setGroup(tE).onRenderUpdate(e=>e.time),d$=tw(0).setGroup(tE).onRenderUpdate(e=>e.deltaTime),dH=tw(0,"uint").setGroup(tE).onRenderUpdate(e=>e.frameId),dW=eA(([e,t,r=eD(.5)])=>uH(e.sub(r),t).add(r)),dq=eA(([e,t,r=eD(.5)])=>{let i=e.sub(r),s=i.dot(i),n=s.mul(s).mul(t);return e.add(i.mul(n))}),dj=eA(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let i;null!==e?((i=sM.toVar())[3][0]=e.x,i[3][1]=e.y,i[3][2]=e.z):i=sM;let s=sf.mul(i);return ef(t)&&(s[0][0]=sM[0].length(),s[0][1]=0,s[0][2]=0),ef(r)&&(s[1][0]=0,s[1][1]=sM[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,sg.mul(s).mul(sz)}),dX=eA(([e=null])=>{let t=oT();return oT(oc(e)).sub(t).lessThan(0).select(a9,e)});class dK extends F{static get type(){return"SpriteSheetUVNode"}constructor(e,t=i4(),r=eB(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=eD(a,o);return t.add(u).mul(l)}}let dQ=eN(dK).setParameterLength(3),dY=eA(([e,t=null,r=null,i=eB(1),s=sz,n=sJ])=>{let a=n.abs().normalize();a=a.div(a.dot(eG(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;return tD(sr(d,o).mul(a.x),sr(h,l).mul(a.y),sr(c,u).mul(a.z))}),dZ=new u.Zcv,dJ=new u.Pq0,d0=new u.Pq0,d1=new u.Pq0,d2=new u.kn4,d3=new u.Pq0(0,0,-1),d4=new u.IUQ,d6=new u.Pq0,d5=new u.Pq0,d8=new u.IUQ,d9=new u.I9Y,d7=new u.O0B,he=a9.flipX();d7.depthTexture=new u.VCu(1,1);let ht=!1;class hr extends se{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||d7.texture,he),this._reflectorBaseNode=e.reflector||new hi(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=ex(new hr({defaultTexture:d7.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 hi extends F{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new u.B69,resolution:i=1,generateMipmaps:s=!1,bounces:n=!0,depth:a=!1}=t;this.textureNode=e,this.target=r,this.resolution=i,this.generateMipmaps=s,this.bounces=n,this.depth=a,this.updateBeforeType=n?R.RENDER:R.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let r=this.resolution;t.getDrawingBufferSize(d9),e.setSize(Math.round(d9.width*r),Math.round(d9.height*r))}setup(e){return this._updateResolution(d7,e.renderer),super.setup(e)}dispose(){for(let e of(super.dispose(),this.renderTargets.values()))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}),!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&&ht)return!1;ht=!0;let{scene:t,camera:r,renderer:i,material:s}=e,{target:n}=this,a=this.getVirtualCamera(r),o=this.getRenderTarget(a);i.getDrawingBufferSize(d9),this._updateResolution(o,i),d0.setFromMatrixPosition(n.matrixWorld),d1.setFromMatrixPosition(r.matrixWorld),d2.extractRotation(n.matrixWorld),dJ.set(0,0,1),dJ.applyM
4atrix4(d2),d6.subVectors(d0,d1);let l=d6.dot(dJ)>0,d=!1;if(!0===l&&!1===this.forceUpdate){if(!1===this.hasOutput){ht=!1;return}d=!0}d6.reflect(dJ).negate(),d6.add(d0),d2.extractRotation(r.matrixWorld),d3.set(0,0,-1),d3.applyMatrix4(d2),d3.add(d1),d5.subVectors(d0,d3),d5.reflect(dJ).negate(),d5.add(d0),a.coordinateSystem=r.coordinateSystem,a.position.copy(d6),a.up.set(0,1,0),a.up.applyMatrix4(d2),a.up.reflect(dJ),a.lookAt(d5),a.near=r.near,a.far=r.far,a.updateMatrixWorld(),a.projectionMatrix.copy(r.projectionMatrix),dZ.setFromNormalAndCoplanarPoint(dJ,d0),dZ.applyMatrix4(a.matrixWorldInverse),d4.set(dZ.normal.x,dZ.normal.y,dZ.normal.z,dZ.constant);let h=a.projectionMatrix;d8.x=(Math.sign(d4.x)+h.elements[8])/h.elements[0],d8.y=(Math.sign(d4.y)+h.elements[9])/h.elements[5],d8.z=-1,d8.w=(1+h.elements[10])/h.elements[14],d4.multiplyScalar(1/d4.dot(d8)),h.elements[2]=d4.x,h.elements[6]=d4.y,h.elements[10]=i.coordinateSystem===u.i7u?d4.z-0:d4.z+1-0,h.elements[14]=d4.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,ht=!1,this.forceUpdate=!1}}let hs=new u.qUd(-1,1,1,-1,0,1);class hn 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 ha=new hn;class ho extends u.eaF{constructor(e=null){super(ha,e),this.camera=hs,this.isQuadMesh=!0}async renderAsync(e){return e.renderAsync(this,hs)}render(e){e.render(this,hs)}}let hl=new u.I9Y;class hu extends se{static get type(){return"RTTNode"}constructor(e,t=null,r=null,i={type:u.ix0}){const s=new u.O0B(t,r,i);super(s.texture,i4()),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 ho(new oI),this.updateBeforeType=R.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(hl),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 se(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}let hd=(e,...t)=>ex(new hu(ex(e),...t)),hh=eA(([e,t,r],i)=>{let s;s=i.renderer.coordinateSystem===u.i7u?eW(eG(e=eD(e.x,e.y.oneMinus()).mul(2).sub(1),t),1):eW(eG(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let n=eW(r.mul(s));return n.xyz.div(n.w)}),hc=eA(([e,t])=>{let r=t.mul(eW(e,1)),i=r.xy.div(r.w).mul(.5).add(.5).toVar();return eD(i.x,i.y.oneMinus())}),hp=eA(([e,t,r])=>{let i=i5(si(t)),s=eO(e.mul(i)).toVar(),n=si(t,s).toVar(),a=si(t,s.sub(eO(2,0))).toVar(),o=si(t,s.sub(eO(1,0))).toVar(),l=si(t,s.add(eO(1,0))).toVar(),u=si(t,s.add(eO(2,0))).toVar(),d=si(t,s.add(eO(0,2))).toVar(),h=si(t,s.add(eO(0,1))).toVar(),c=si(t,s.sub(eO(0,1))).toVar(),p=si(t,s.sub(eO(0,2))).toVar(),g=rS(tO(eB(2).mul(o).sub(a),n)).toVar(),m=rS(tO(eB(2).mul(l).sub(u),n)).toVar(),f=rS(tO(eB(2).mul(h).sub(d),n)).toVar(),y=rS(tO(eB(2).mul(c).sub(p),n)).toVar(),b=hh(e,n,r).toVar();return rf(rj(g.lessThan(m).select(b.sub(hh(e.sub(eD(eB(1).div(i.x),0)),o,r)),b.negate().add(hh(e.add(eD(eB(1).div(i.x),0)),l,r))),f.lessThan(y).select(b.sub(hh(e.add(eD(0,eB(1).div(i.y))),h,r)),b.negate().add(hh(e.sub(eD(0,eB(1).div(i.y))),c,r)))))});class hg extends F{static get type(){return"SampleNode"}constructor(e){super(),this.callback=e,this.isSampleNode=!0}setup(){return this.sample(i4())}sample(e){return this.callback(e)}}class hm extends F{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===hm.OBJECT?this.updateType=R.OBJECT:e===hm.MATERIAL&&(this.updateType=R.RENDER)}update(e){this.callback(e)}}hm.OBJECT="object",hm.MATERIAL="material";let hf=(e,t)=>
4ex(new hm(e,t)).toStack();class hy 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 hx extends F{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}let hT=eS(hx),h_=new u.O9p,hv=new u.kn4;class hN extends F{static get type(){return"SceneNode"}constructor(e=hN.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===hN.BACKGROUND_BLURRINESS?t=nf("backgroundBlurriness","float",i):r===hN.BACKGROUND_INTENSITY?t=nf("backgroundIntensity","float",i):r===hN.BACKGROUND_ROTATION?t=tw("mat4").setName("backgroundRotation").setGroup(tE).onRenderUpdate(()=>{let e=i.background;return null!==e&&e.isTexture&&e.mapping!==u.UTZ?(h_.copy(i.backgroundRotation),h_.x*=-1,h_.y*=-1,h_.z*=-1,hv.makeRotationFromEuler(h_)):hv.identity(),hv}):console.error("THREE.SceneNode: Unknown scope:",r),t}}hN.BACKGROUND_BLURRINESS="backgroundBlurriness",hN.BACKGROUND_INTENSITY="backgroundIntensity",hN.BACKGROUND_ROTATION="backgroundRotation";let hS=eS(hN,hN.BACKGROUND_BLURRINESS),hE=eS(hN,hN.BACKGROUND_INTENSITY),hR=eS(hN,hN.BACKGROUND_ROTATION);class hA extends se{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.isStorageTextureNode=!0,this.access=A.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(A.READ_WRITE)}toReadOnly(){return this.setAccess(A.READ_ONLY)}toWriteOnly(){return this.setAccess(A.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 hw=eN(hA).setParameterLength(1,3),hC=eA(({texture:e,uv:t})=>{let r=eG().toVar();return eM(t.x.lessThan(1e-4),()=>{r.assign(eG(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{r.assign(eG(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{r.assign(eG(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{r.assign(eG(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{r.assign(eG(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{r.assign(eG(0,0,-1))}).Else(()=>{let i=e.sample(t.add(eG(-.01,0,0))).r.sub(e.sample(t.add(eG(.01,0,0))).r),s=e.sample(t.add(eG(0,-.01,0))).r.sub(e.sample(t.add(eG(0,.01,0))).r),n=e.sample(t.add(eG(0,0,-.01))).r.sub(e.sample(t.add(eG(0,0,.01))).r);r.assign(eG(i,s,n))}),r.normalize()});class hM extends se{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return eG(.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(eF(i5(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return hC({texture:this,uv:e})}}let hL=eN(hM).setParameterLength(1,3);class hP extends nm{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 hB=new WeakMap;class hF extends D{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=R.OBJECT,this.updateAfterType=R.OBJECT,this.previousModelWorldMatrix=tw(new u.kn4),this.previousProjectionMatrix=tw(new u.kn4).setGroup(tE),this.previousCameraViewMatrix=tw(new u.kn4)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){let i=hV(r);this.previousModelWorldMatrix.value.copy(i);let s=hI(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}){hV(e).copy(e.matrixWorld)}setup(){let e=null===this.projectionMatrix?sg:tw(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(sD).mul(sz),i=this.previousProjectionMatrix.mul(t).mul(s$);return tO(r.xy.div(r.w),i.xy.div(i.w))}}function hI(e){let t=hB.get(e);return void 0===t&&(t={},hB.set(e,t)),t}function hV(e,t=0){let r=hI(e),i=r[t];return void 0===i&&(r[t]=i=new u.kn4,r[t].copy(e.matrixWorld)),i}let hD=eS(hF),hO=eA(([e])=>hz(e.rgb)),hU=eA(([e,t=eB(1)])=>t.mix(hz(e.rgb),e.rgb)),hk=eA(([e,t=eB(1)])=>{let r=tD(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 r1(e.rgb,i,s)}),hG=eA(([e,t=eB(1)])=>{let r=eG(.57735,.57735,.57735),i=t.cos();return eG(e.rgb.mul(i).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(rq(r,e.rgb).mul(i.oneMinus())))))}),hz=(e,t=eG(u.ppV.getLuminanceCoefficients(new u.Pq0)))=>rq(e,t),h$=eA(([e,t=eG(1),r=eG(0),i=eG(1),s=eB(1),n=eG(u.ppV.getLuminanceCoefficients(new u.Pq0,u.Zr2))])=>{let a=e.rgb.dot(eG(n)),o=rG(e.rgb.mul(t).add(r),0).toVar(),l=o.pow(i).toVar();return eM(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),eM(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),eM(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(s))),eW(o.rgb,e.a)});class hH extends D{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 hW=eN(hH).setParameterLength(2),hq=new u.I9Y;class hj extends se{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 hX extends hj{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 hK extends D{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;const s=new u.VCu;s.isRenderTargetTexture=!0,s.name="depth";const 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=tw(0),this._cameraFar=tw(0),this._mrt=null,this._layers=null,this._resolution=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=R.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=ex(new hX(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=ex(new hX(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=of(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=og(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===hK.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),hq.set(n.width,n.height)):(t=this.camera,r=i.getPixelRatio(),i.getSize(hq)),this._pixelRatio=r,this.setSize(hq.width,hq.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()}}hK.COLOR="color",hK.DEPTH="depth";class hQ extends hK{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,i,s){super(hK.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 oI;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=u.hsX;let t=sJ.negate(),r=sg.mul(sD),i=eB(1),s=r.mul(eW(sz,1)),n=r.mul(eW(sz.add(t),1)),a=rf(s.sub(n));return e.vertexNode=s.add(a.mul(this.thicknessNode).mul(s.w).mul(i)),e.colorNode=eW(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 hY=eA(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),hZ=eA(([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"}]}),hJ=eA(([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"}]}),h0=eA(([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)}),h1=eA(([e,t])=>{let r=eQ(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=eQ(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=h0(e=r.mul(e)),(e=i.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),h2=eQ(eG(1.6605,-.1246,-.0182),eG(-.5876,1.1329,-.1006),eG(-.0728,-.0083,1.1187)),h3=eQ(eG(.6274,.0691,.0164),eG(.3293,.9195,.088),eG(.0433,.0113,.8956)),h4=eA(([e])=>{let t=eG(e).toVar(),r=eG(t.mul(t)).toVar(),i=eG(r.mul(r)).toVar();return eB(15.5).mul(i.mul(r)).sub(tU(40.14,i.mul(t))).add(tU(31.96,i).sub(tU(6.868,r.mul(t))).add(tU(.4298,r).add(tU(.1191,t).sub(.00232))))}),h6=eA(([e,t])=>{let r=eG(e).toVar(),i=eQ(eG(.856627153315983,.137318972929847,.11189821299995),eG(.0951212405381588,.761241990602591,.0767994186031903),eG(.0482516061458583,.101439036467562,.811302368396859)),s=eQ(eG(1.1271005818144368,-.1413297634984383,-.14132976349843826),eG(-.11060664309660323,1.157823702216272,-.11060664309660294),eG(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=eB(-12.47393),a=eB(4.026069);return r.mulAssign(t),r.assign(h3.mul(r)),r.assign(i.mul(r)),r.assign(rG(r,1e-10)),r.assign(rh(r)),r.assign(r.sub(n).div(a.sub(n))),r.assign(r2(r,0,1)),r.assign(h4(r)),r.assign(s.mul(r)),r.assign(rX(rG(eG(0),r),eG(2.2))),r.assign(h2.mul(r)),r.assign(r2(r,0,1)),r}
4).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),h5=eA(([e,t])=>{let r=eB(.76),i=eB(.15),s=rk((e=e.mul(t)).r,rk(e.g,e.b)),n=ii(s.lessThan(.08),s.sub(tU(6.25,s.mul(s))),.04);e.subAssign(n);let a=rG(e.r,rG(e.g,e.b));eM(a.lessThan(r),()=>e);let o=tO(1,r),l=tO(1,o.mul(o).div(a.add(o.sub(r))));e.mulAssign(l.div(a));let u=tO(1,tk(1,i.mul(a.sub(l)).add(1)));return r1(e,eG(l),u)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class h8 extends F{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}}let h9=eN(h8).setParameterLength(1,3);class h7 extends h8{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}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 ce=(e,t=[],r="")=>{for(let e=0;e<t.length;e++){let r=t[e];"function"==typeof r&&(t[e]=r.functionNode)}let i=ex(new h7(e,t,r)),s=(...e)=>i.call(...e);return s.functionNode=i,s};class ct extends F{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:eB()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=N(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?S(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 cr=eN(ct).setParameterLength(1);class ci 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 cs{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 cn=new ci;class ca extends F{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new ci,this._output=cr(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}
4get 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]=cr(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]=cr(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 cs(this),i=cn.get("THREE"),s=cn.get("TSL"),n=this.getMethod(),a=[r,this._local,cn,e,t,i,s];this._object=n(...a);let o=this._object.layout;if(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:eB()}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=[p(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(let r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return p(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 co=eN(ca).setParameterLength(1,2);function cl(e){let t,r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||sq.z).negate()}let cu=eA(([e,t],r)=>r6(e,t,cl(r))),cd=eA(([e],t)=>{let r=cl(t);return e.mul(e,r,r).negate().exp().oneMinus()}),ch=eA(([e,t])=>eW(t.toFloat().mix(th.rgb,e.toVec3()),th.a)),cc=null,cp=null;class cg extends F{static get type(){return"RangeNode"}constructor(e=eB(),t=eB()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=e.getTypeLength(T(this.minNode.value)),r=e.getTypeLength(T(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(T(i)),a=e.getTypeLength(T(s));cc=cc||new u.IUQ,cp=cp||new u.IUQ,cc.setScalar(0),cp.setScalar(0),1===n?cc.setScalar(i):i.isColor?cc.set(i.r,i.g,i.b,1):cc.set(i.x,i.y,i.z||0,i.w||0),1===a?cp.setScalar(s):s.isColor?cp.set(s.r,s.g,s.b,1):cp.set(s.x,s.y,s.z||0,s.w||0);
4let o=4*t.count,l=new Float32Array(o);for(let e=0;e<o;e++){let t=e%4,r=cc.getComponent(t),i=cp.getComponent(t);l[e]=u.cj9.lerp(r,i,Math.random())}let d=this.getNodeType(e);if(t.count<=4096)r=sn(l,"vec4",t.count).element(aM).convert(d);else{let t=new u.uWO(l,4);e.geometry.setAttribute("__range"+this.id,t),r=iD(t).convert(d)}}else r=eB(0);return r}}let cm=eN(cg).setParameterLength(2);class cf extends F{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 cy=(e,t)=>ex(new cf(e,t)),cb=cy("numWorkgroups","uvec3"),cx=cy("workgroupId","uvec3"),cT=cy("globalId","uvec3"),c_=cy("localId","uvec3"),cv=cy("subgroupSize","uint");class cN extends F{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 cS=eN(cN);class cE extends I{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 cR extends F{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(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 ex(new cE(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 cA extends F{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=iQ(u,s).toConst()),t.constNode.build(e);e.addLineFlowCode(u,this)}}cA.ATOMIC_LOAD="atomicLoad",cA.ATOMIC_STORE="atomicStore",cA.ATOMIC_ADD="atomicAdd",cA.ATOMIC_SUB="atomicSub",cA.ATOMIC_MAX="atomicMax",cA.ATOMIC_MIN="atomicMin",cA.ATOMIC_AND="atomicAnd",cA.ATOMIC_OR="atomicOr",cA.ATOMIC_XOR="atomicXor";let cw=eN(cA),cC=(e,t,r)=>cw(e,t,r).toStack();function cM(e){let t=(n=n||new WeakMap).get(e);return void 0===t&&n.set(e,t={}),t}function cL(e){let t=cM(e);return t.shadowMatrix||(t.shadowMatrix=tw("mat4").setGroup(tE).onRenderUpdate(t=>((!0!==e.castShadow||!1===t.renderer.shadowMap.enabled)&&e.shadow.updateMatrices(e),e.shadow.matrix)))}function cP(e,t=sH){let r=cL(e).mul(t);return r.xyz.div(r.w)}function cB(e){let t=cM(e);return t.position||(t.position=tw(new u.Pq0).setGroup(tE).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function cF(e){let t=cM(e);return t.targetPosition||(t.targetPosition=tw(new u.Pq0).setGroup(tE).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function cI(e){let t=cM(e);return t.viewPosition||(t.viewPosition=tw(new u.Pq0).setGroup(tE).onRenderUpd
5ate(({camera:t},r)=>{r.value=r.value||new u.Pq0,r.value.setFromMatrixPosition(e.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}let cV=e=>sf.transformDirection(cB(e).sub(cF(e))),cD=(e,t)=>{for(let r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},cO=new WeakMap,cU=[];class ck extends F{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=e1("vec3","totalDiffuse"),this.totalSpecularNode=e1("vec3","totalSpecular"),this.outgoingLightNode=e1("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];if(cU.push(r.id),cU.push(+!!r.castShadow),!0===r.isSpotLight){let e=null!==r.map?r.map.id:-1,t=r.colorNode?r.colorNode.getCacheKey():-1;cU.push(e,t)}}let t=p(cU);return cU.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.getSelf().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(ex(e));else{let i=null;if(null!==r&&(i=cD(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;cO.has(e)?i=cO.get(e):(i=ex(new r(e)),cO.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?eG(l.mix(p,o)):eG(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 cG extends F{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=R.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){cz.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||sH)}}let cz=e1("vec3","shadowPositionWorld"),c$=new WeakMap,cH=eA(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let i=sr(e,t.xy).setName("t_basic");return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)}
5),cW=eA(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{let s=(t,r)=>{let s=sr(e,t);return e.isArrayTexture&&(s=s.depth(i)),s.compare(r)},n=nf("mapSize","vec2",r).setGroup(tE),a=nf("radius","float",r).setGroup(tE),o=eD(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 tD(s(t.xy.add(eD(l,u)),t.z),s(t.xy.add(eD(0,u)),t.z),s(t.xy.add(eD(d,u)),t.z),s(t.xy.add(eD(c,p)),t.z),s(t.xy.add(eD(0,p)),t.z),s(t.xy.add(eD(g,p)),t.z),s(t.xy.add(eD(l,0)),t.z),s(t.xy.add(eD(c,0)),t.z),s(t.xy,t.z),s(t.xy.add(eD(g,0)),t.z),s(t.xy.add(eD(d,0)),t.z),s(t.xy.add(eD(c,m)),t.z),s(t.xy.add(eD(0,m)),t.z),s(t.xy.add(eD(g,m)),t.z),s(t.xy.add(eD(l,h)),t.z),s(t.xy.add(eD(0,h)),t.z),s(t.xy.add(eD(d,h)),t.z)).mul(1/17)}),cq=eA(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{let s=(t,r)=>{let s=sr(e,t);return e.isArrayTexture&&(s=s.depth(i)),s.compare(r)},n=nf("mapSize","vec2",r).setGroup(tE),a=eD(1).div(n),o=a.x,l=a.y,u=t.xy,d=ry(u.mul(n).add(.5));return u.subAssign(d.mul(a)),tD(s(u,t.z),s(u.add(eD(o,0)),t.z),s(u.add(eD(0,l)),t.z),s(u.add(a),t.z),r1(s(u.add(eD(o.negate(),0)),t.z),s(u.add(eD(o.mul(2),0)),t.z),d.x),r1(s(u.add(eD(o.negate(),l)),t.z),s(u.add(eD(o.mul(2),l)),t.z),d.x),r1(s(u.add(eD(0,l.negate())),t.z),s(u.add(eD(0,l.mul(2))),t.z),d.y),r1(s(u.add(eD(o,l.negate())),t.z),s(u.add(eD(o,l.mul(2))),t.z),d.y),r1(r1(s(u.add(eD(o.negate(),l.negate())),t.z),s(u.add(eD(o.mul(2),l.negate())),t.z),d.x),r1(s(u.add(eD(o.negate(),l.mul(2))),t.z),s(u.add(eD(o.mul(2),l.mul(2))),t.z),d.x),d.y)).mul(1/9)}),cj=eA(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let i=eB(1).toVar(),s=sr(e).sample(t.xy);e.isArrayTexture&&(s=s.depth(r)),s=s.rg;let n=rz(t.z,s.x);return eM(n.notEqual(eB(1)),()=>{let e=t.z.sub(s.x),r=rG(0,s.y.mul(s.y)),a=r.div(r.add(e.mul(e)));a=r2(tO(a,.3).div(.95-.3)),i.assign(r2(rG(n,a)))}),i}),cX=eA(([e,t,r])=>{let i=sH.sub(e).length();return(i=i.sub(t).div(r.sub(t))).saturate()}),cK=e=>{let t=c$.get(e);if(void 0===t){let r,i,s,n=e.isPointLight?(i=nf("near","float",r=e.shadow.camera).setGroup(tE),s=nf("far","float",r).setGroup(tE),cX(sS(e),i,s)):null;(t=new oI).colorNode=eW(0,0,0,1),t.depthNode=n,t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.fog=!1,c$.set(e,t)}return t},cQ=new uJ,cY=[],cZ=(e,t,r,i)=>{cY[0]=e,cY[1]=t;let s=cQ.get(cY);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&&(v(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,cQ.set(cY,s)),cY[0]=null,cY[1]=null,s},cJ=eA(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:s})=>{let n=eB(0).toVar("meanVertical"),a=eB(0).toVar("squareMeanVertical"),o=e.lessThanEqual(eB(1)).select(eB(0),eB(2).div(e.sub(1))),l=e.lessThanEqual(eB(1)).select(eB(0),eB(-1));aK({start:eF(0),end:eF(e),type:"int",condition:"<"},({i:e})=>{let u=l.add(eB(e).mul(o)),d=i.sample(tD(oe.xy,eD(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=rc(a.sub(n.mul(n)));return eD(n,u)}),c0=eA(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:s})=>{let n=eB(0).toVar("meanHorizontal"),a=eB(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(eB(1)).select(eB(0),eB(2).div(e.sub(1))),l=e.lessThanEqual(eB(1)).select(eB(0),eB(-1));aK({start:eF(0),end:eF(e),type:"int",condition:"<"},({i:e})=>{let u=l.add(eB(e).mul(o)),d=i.sample(tD(oe.xy,eD(u,0).mul(t)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),n.addAssign(d.x),a.addAssign(tD(d.y.mul(d.y),d.x.mul(d.x)))}),n.divAssign(e),a.divAssign(e);let u=rc(a.sub(n.mul(n)));return eD(n,u)}),c1=[cH,cW,cq,cj],c2=new ho;class c3 extends cG{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,eB(1))}setupShadowCoord(e,t){let r,{shadow:i}=this,{renderer:s}=e,n=nf("bias","float",i).setGroup(tE),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=nf("near","float",i.camera).setGroup(tE),s=nf("far","float",i.camera).setGroup(tE);r=oy(e.negate(),t,s)}return eG(a.x,a.y.oneMinus(),r.add(n))}getShadowFilterFn(e){return c1[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=sr(n);n.isArrayTexture&&(t=t.depth(this.depthLayer));let r=sr(this.vsmShadowMapVertical.texture);n.isArrayTexture&&(r=r.depth(this.depthLayer));let s=nf("blurSamples","float",i).setGroup(tE),o=nf("radius","float",i).setGroup(tE),l=nf("mapSize","vec2",i).setGroup(tE),d=this.vsmMaterialVertical||(this.vsmMaterialVertical=new oI);d.fragmentNode=cJ({samples:s,radius:o,size:l,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),d.name="VSMVertical",(d=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new oI)).fragmentNode=c0({samples:s,radius:o,size:l,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),d.name="VSMHorizontal"}let o=nf("intensity","float",i).setGroup(tE),l=nf("normalBias","float",i).setGroup(tE),d=cL(r).mul(cz.add(s4.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=sr(a.texture,h);n.isArrayTexture&&(m=m.depth(this.depthLayer));let f=r1(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 eA(()=>{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=cK(n),l.setRenderObjectFunction(cZ(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),c2.material=this.vsmMaterialVertical,c2.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),c2.material=this.vsmMaterialHorizontal,c2.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 c4=(e,t)=>ex(new c3(e,t)),c6=new u.Q1f,c5=eA(([e,t])=>{let r=e.toVar(),i=rS(r),s=tk(1,rG(i.x,rG(i.y,i.z)));i.mulAssign(s),r.mulAssign(s.mul(t.mul(2).oneMinus()));let n=eD(r.xy).toVar(),a=t.mul(1.5).oneMinus();return eM(i.z.greaterThanEqual(a),()=>{eM(r.z.greaterThan(0),()=>{n.x.assign(tO(4,r.x))})}).ElseIf(i.x.greaterThanEqual(a),()=>{let e=rE(r.x);n.x.assign(r.z.mul(e).add(e.mul(2)))}).ElseIf(i.y.greaterThanEqual(a),()=>{let e=rE(r.y);n.x.assign(r.x.add(e.mul(2)).add(2)),n.y.assign(r.z.mul(e).sub(2))}),eD(.125,.25).mul(n).add(eD(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),c8=eA(({depthTexture:e,bd3D:t,dp:r,texelSize:i})=>sr(e,c5(t,i.y)).compare(r)),c9=eA(({depthTexture:e,bd3D:t,dp:r,texelSize:i,shadow:s})=>{let n=nf("radius","float",s).setGroup(tE),a=eD(-1,1).mul(n).mul(i.y);return sr(e,c5(t.add(a.xyy),i.y)).compare(r).add(sr(e,c5(t.add(a.yyy),i.y)).compare(r)).add(sr(e,c5(t.add(a.xyx),i.y)).compare(r)).add(sr(e,c5(t.add(a.yyx),i.y)).compare(r)).add(sr(e,c5(t,i.y)).compare(r)).add(sr(e,c5(t.add(a.xxy),i.y)).compare(r)).add(sr(e,c5(t.add(a.yxy),i.y)).compare(r)).add(sr(e,c5(t.add(a.xxx),i.y)).compare(r)).add(sr(e,c5(t.add(a.yxx),i.y)).compare(r)).mul(1/9)}),c7=eA(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:i})=>{let s=r.xyz.toVar(),n=s.length(),a=tw("float").setGroup(tE).onRenderUpd
5ate(()=>i.camera.near),o=tw("float").setGroup(tE).onRenderUpdate(()=>i.camera.far),l=nf("bias","float",i).setGroup(tE),u=tw(i.mapSize).setGroup(tE),d=eB(1).toVar();return eM(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=eD(1).div(u.mul(eD(4,2)));d.assign(e({depthTexture:t,bd3D:h,dp:r,texelSize:c,shadow:i}))}),d}),pe=new u.IUQ,pt=new u.I9Y,pr=new u.I9Y;class pi extends c3{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===u.bTm?c8:c9}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:i,shadowCoord:s,shadow:n}){return c7({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();pr.copy(t.mapSize),pr.multiply(a),r.setSize(pr.width,pr.height),pt.copy(t.mapSize);let o=s.autoClear,l=s.getClearColor(c6),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=pt.x*a.x,l=pr.y-pt.y-pt.y*a.y;pe.set(o,l,pt.x*a.z,pt.y*a.w),r.viewport.copy(pe),t.updateMatrices(i,e),s.render(n,t.camera)}s.autoClear=o,s.setClearColor(l,u)}}let ps=(e,t)=>ex(new pi(e,t));class pn extends a2{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new u.Q1f,this.colorNode=e&&e.colorNode||tw(this.color).setGroup(tE),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=R.FRAME}getHash(){return this.light.uuid}getLightVector(e){return cI(this.light).sub(e.context.positionView||sq)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return c4(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?ex(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 pa=eA(({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)}),po=({color:e,lightVector:t,cutoffDistance:r,decayExponent:i})=>{let s=t.normalize(),n=pa({lightDistance:t.length(),cutoffDistance:r,decayExponent:i});return{lightDirection:s,lightColor:e.mul(n)}};class pl extends pn{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=tw(0).setGroup(tE),this.decayExponentNode=tw(2).setGroup(tE)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return ps(this.light)}setupDirect(e){return po({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}let pu=eA(([e=i4()])=>{let t=e.mul(2),r=t.x.floor(),i=t.y.floor();return r.add(i).mod(2).sign()}),pd=eA(([e=i4()],{renderer:t,material:r})=>{let i,s=r0(e.mul(2).sub(1));if(r.alphaToCoverage&&t.samples>1){let e=eB(s.fwidth()).toVar();i=r6(e.oneMinus(),e.add(1),s).oneMinus()}else i=ii(s.greaterThan(1),0,1);return i}),ph=eA(([e,t,r])=>{let i=eB(r).toVar(),s=eB(t).toVar();return ii(eV(e).toVar(),s,i)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),pc=eA(([e,t])=>{let r=eV(t).toVar(),i=eB(e).toVar();return ii(r,i.negate(),i)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),pp=eA(([e])=>eF(rg(eB(e).toVar()))).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),pg=eA(([e,t])=>{let r=eB(e).toVar();return t.assign(pp(r)),r.sub(eB(t))}),pm=dG([eA(([e,t,r,i,s,n])=>{let a=eB(n).toVar(),o=eB(s).toVar(),l=eB(i).toVar(),u=eB(r).toVar(),d=eB(t).toVar(),h=eB(e).toVar(),c=eB(tO(1,o)).toVar();return tO(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"}]}),eA(([e,t,r,i,s,n])=>{let a=eB(n).toVar(),o=eB(s).toVar(),l=eG(i).toVar(),u=eG(r).toVar(),d=eG(t).toVar(),h=eG(e).toVar(),c=eB(tO(1,o)).toVar();return tO(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"}]})]),pf=dG([eA(([e,t,r,i,s,n,a,o,l,u,d])=>{let h=eB(d).toVar(),c=eB(u).toVar(),p=eB(l).toVar(),g=eB(o).toVar(),m=eB(a).toVar(),f=eB(n).toVar(),y=eB(s).toVar(),b=eB(i).toVar(),x=eB(r).toVar(),T=eB(t).toVar(),_=eB(e).toVar(),v=eB(tO(1,p)).toVar(),N=eB(tO(1,c)).toVar();return eB(tO(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"}]}),eA(([e,t,r,i,s,n,a,o,l,u,d])=>{let h=eB(d).toVar(),c=eB(u).toVar(),p=eB(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=eB(tO(1,p)).toVar(),N=eB(tO(1,c)).toVar();return eB(tO(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"}]})]),py=dG([eA(([e,t,r])=>{let i=eB(r).toVar(),s=eB(t).toVar(),n=eI(e).toVar(),a=eI(n.bitAnd(eI(7))).toVar(),o=eB(ph(a.lessThan(eI(4)),s,i)).toVar(),l=eB(tU(2,ph(a.lessThan(eI(4)),i,s))).toVar();return pc(o,eV(a.bitAnd(eI(1)))).add(pc(l,eV(a.bitAnd(eI(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),eA(([e,t,r,i])=>{let s=eB(i).toVar(),n=eB(r).toVar(),a=eB(t).toVar(),o=eI(e).toVar(),l=eI(o.bitAnd(eI(15))).toVar(),u=eB(ph(l.lessThan(eI(8)),a,n)).toVar(),d=eB(ph(l.lessThan(eI(4)),n,ph(l.equal(eI(12)).or(l.equal(eI(14))),a,s))).toVar();return pc(u,eV(l.bitAnd(eI(1)))).add(pc(d,eV(l.bitAnd(eI(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"}]})]),pb=dG([eA(([e,t,r])=>{let i=eB(r).toVar(),s=eB(t).toVar(),n=e$(e).toVar();return eG(py(n.x,s,i),py(n.y,s,i),py(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"}]}),eA(([e,t,r,i])=>{let s=eB(i).toVar(),n=eB(r).toVar(),a=eB(t).toVar(),o=e$(e).toVar();return eG(py(o.x,a,n,s),py(o.y,a,n,s),py(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"}]})]),px=eA(([e])=>tU(.6616,eB(e).toVar())).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),pT=eA(([e])=>tU(.982,eB(e).toVar())).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),p_=dG([px,eA(([e])=>tU(.6616,eG(e).toVar())).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),pv=dG([pT,eA(([e])=>tU(.982,eG(e).toVar())).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),pN=eA(([e,t])=>{let r=eF(t).toVar(),i=eI(e).toVar();return i.shiftLeft(r).bitOr(i.shiftRight(eF(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),pS=eA(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(pN(r,eF(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(pN(e,eF(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(pN(t,eF(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(pN(r,eF(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(pN(e,eF(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(pN(t,eF(4))),t.addAssign(e)}),pE=eA(([e,t,r])=>{let i=eI(r).toVar(),s=eI(t).toVar(),n=eI(e).toVar();
5return i.bitXorAssign(s),i.subAssign(pN(s,eF(14))),n.bitXorAssign(i),n.subAssign(pN(i,eF(11))),s.bitXorAssign(n),s.subAssign(pN(n,eF(25))),i.bitXorAssign(s),i.subAssign(pN(s,eF(16))),n.bitXorAssign(i),n.subAssign(pN(i,eF(4))),s.bitXorAssign(n),s.subAssign(pN(n,eF(14))),i.bitXorAssign(s),i.subAssign(pN(s,eF(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),pR=eA(([e])=>eB(eI(e).toVar()).div(eB(eI(eF(0xffffffff))))).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),pA=eA(([e])=>{let t=eB(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"}]}),pw=dG([eA(([e])=>{let t=eF(e).toVar(),r=eI(eI(1)).toVar(),i=eI(eI(eF(0xdeadbeef)).add(r.shiftLeft(eI(2))).add(eI(13))).toVar();return pE(i.add(eI(t)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),eA(([e,t])=>{let r=eF(t).toVar(),i=eF(e).toVar(),s=eI(eI(2)).toVar(),n=eI().toVar(),a=eI().toVar(),o=eI().toVar();return n.assign(a.assign(o.assign(eI(eF(0xdeadbeef)).add(s.shiftLeft(eI(2))).add(eI(13))))),n.addAssign(eI(i)),a.addAssign(eI(r)),pE(n,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),eA(([e,t,r])=>{let i=eF(r).toVar(),s=eF(t).toVar(),n=eF(e).toVar(),a=eI(eI(3)).toVar(),o=eI().toVar(),l=eI().toVar(),u=eI().toVar();return o.assign(l.assign(u.assign(eI(eF(0xdeadbeef)).add(a.shiftLeft(eI(2))).add(eI(13))))),o.addAssign(eI(n)),l.addAssign(eI(s)),u.addAssign(eI(i)),pE(o,l,u)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),eA(([e,t,r,i])=>{let s=eF(i).toVar(),n=eF(r).toVar(),a=eF(t).toVar(),o=eF(e).toVar(),l=eI(eI(4)).toVar(),u=eI().toVar(),d=eI().toVar(),h=eI().toVar();return u.assign(d.assign(h.assign(eI(eF(0xdeadbeef)).add(l.shiftLeft(eI(2))).add(eI(13))))),u.addAssign(eI(o)),d.addAssign(eI(a)),h.addAssign(eI(n)),pS(u,d,h),u.addAssign(eI(s)),pE(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"}]}),eA(([e,t,r,i,s])=>{let n=eF(s).toVar(),a=eF(i).toVar(),o=eF(r).toVar(),l=eF(t).toVar(),u=eF(e).toVar(),d=eI(eI(5)).toVar(),h=eI().toVar(),c=eI().toVar(),p=eI().toVar();return h.assign(c.assign(p.assign(eI(eF(0xdeadbeef)).add(d.shiftLeft(eI(2))).add(eI(13))))),h.addAssign(eI(u)),c.addAssign(eI(l)),p.addAssign(eI(o)),pS(h,c,p),h.addAssign(eI(a)),c.addAssign(eI(n)),pE(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"}]})]),pC=dG([eA(([e,t])=>{let r=eF(t).toVar(),i=eI(pw(eF(e).toVar(),r)).toVar(),s=e$().toVar();return s.x.assign(i.bitAnd(eF(255))),s.y.assign(i.shiftRight(eF(8)).bitAnd(eF(255))),s.z.assign(i.shiftRight(eF(16)).bitAnd(eF(255))),s}
5).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),eA(([e,t,r])=>{let i=eF(r).toVar(),s=eF(t).toVar(),n=eI(pw(eF(e).toVar(),s,i)).toVar(),a=e$().toVar();return a.x.assign(n.bitAnd(eF(255))),a.y.assign(n.shiftRight(eF(8)).bitAnd(eF(255))),a.z.assign(n.shiftRight(eF(16)).bitAnd(eF(255))),a}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),pM=dG([eA(([e])=>{let t=eD(e).toVar(),r=eF().toVar(),i=eF().toVar(),s=eB(pg(t.x,r)).toVar(),n=eB(pg(t.y,i)).toVar(),a=eB(pA(s)).toVar(),o=eB(pA(n)).toVar();return p_(eB(pm(py(pw(r,i),s,n),py(pw(r.add(eF(1)),i),s.sub(1),n),py(pw(r,i.add(eF(1))),s,n.sub(1)),py(pw(r.add(eF(1)),i.add(eF(1))),s.sub(1),n.sub(1)),a,o)).toVar())}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),eA(([e])=>{let t=eG(e).toVar(),r=eF().toVar(),i=eF().toVar(),s=eF().toVar(),n=eB(pg(t.x,r)).toVar(),a=eB(pg(t.y,i)).toVar(),o=eB(pg(t.z,s)).toVar(),l=eB(pA(n)).toVar(),u=eB(pA(a)).toVar(),d=eB(pA(o)).toVar();return pv(eB(pf(py(pw(r,i,s),n,a,o),py(pw(r.add(eF(1)),i,s),n.sub(1),a,o),py(pw(r,i.add(eF(1)),s),n,a.sub(1),o),py(pw(r.add(eF(1)),i.add(eF(1)),s),n.sub(1),a.sub(1),o),py(pw(r,i,s.add(eF(1))),n,a,o.sub(1)),py(pw(r.add(eF(1)),i,s.add(eF(1))),n.sub(1),a,o.sub(1)),py(pw(r,i.add(eF(1)),s.add(eF(1))),n,a.sub(1),o.sub(1)),py(pw(r.add(eF(1)),i.add(eF(1)),s.add(eF(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"}]})]),pL=dG([eA(([e])=>{let t=eD(e).toVar(),r=eF().toVar(),i=eF().toVar(),s=eB(pg(t.x,r)).toVar(),n=eB(pg(t.y,i)).toVar(),a=eB(pA(s)).toVar(),o=eB(pA(n)).toVar();return p_(eG(pm(pb(pC(r,i),s,n),pb(pC(r.add(eF(1)),i),s.sub(1),n),pb(pC(r,i.add(eF(1))),s,n.sub(1)),pb(pC(r.add(eF(1)),i.add(eF(1))),s.sub(1),n.sub(1)),a,o)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),eA(([e])=>{let t=eG(e).toVar(),r=eF().toVar(),i=eF().toVar(),s=eF().toVar(),n=eB(pg(t.x,r)).toVar(),a=eB(pg(t.y,i)).toVar(),o=eB(pg(t.z,s)).toVar(),l=eB(pA(n)).toVar(),u=eB(pA(a)).toVar(),d=eB(pA(o)).toVar();return pv(eG(pf(pb(pC(r,i,s),n,a,o),pb(pC(r.add(eF(1)),i,s),n.sub(1),a,o),pb(pC(r,i.add(eF(1)),s),n,a.sub(1),o),pb(pC(r.add(eF(1)),i.add(eF(1)),s),n.sub(1),a.sub(1),o),pb(pC(r,i,s.add(eF(1))),n,a,o.sub(1)),pb(pC(r.add(eF(1)),i,s.add(eF(1))),n.sub(1),a,o.sub(1)),pb(pC(r,i.add(eF(1)),s.add(eF(1))),n,a.sub(1),o.sub(1)),pb(pC(r.add(eF(1)),i.add(eF(1)),s.add(eF(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"}]})]),pP=dG([eA(([e])=>pR(pw(eF(pp(eB(e).toVar())).toVar()))).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),eA(([e])=>{let t=eD(e).toVar();return pR(pw(eF(pp(t.x)).toVar(),eF(pp(t.y)).toVar()))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),eA(([e])=>{let t=eG(e).toVar();return pR(pw(eF(pp(t.x)).toVar(),eF(pp(t.y)).toVar(),eF(pp(t.z)).toVar()))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),eA(([e])=>{let t=eW(e).toVar();return pR(pw(eF(pp(t.x)).toVar(),eF(pp(t.y)).toVar(),eF(pp(t.z)).toVar(),eF(pp(t.w)).toVar()))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),pB=dG([eA(([e])=>{let t=eF(pp(eB(e).toVar())).toVar();return eG(pR(pw(t,eF(0))),pR(pw(t,eF(1))),pR(pw(t,eF(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),eA(([e])=>{let t=eD(e).toVar(),r=eF(pp(t.x)).toVar(),i=eF(pp(t.y)).toVar();return eG(pR(pw(r,i,eF(0))),pR(pw(r,i,eF(1))),pR(pw(r,i,eF(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),eA(([e])=>{let t=eG(e).toVar(),r=eF(pp(t.x)).toVar(),i=eF(pp(t.y)).toVar(),s=eF(pp(t.z)).toVar();return eG(pR(pw(r,i,s,eF(0))),pR(pw(r,i,s,eF(1))),pR(pw(r,i,s,eF(2))))}
vendor: 9,482 bytes, line 5
5).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),eA(([e])=>{let t=eW(e).toVar(),r=eF(pp(t.x)).toVar(),i=eF(pp(t.y)).toVar(),s=eF(pp(t.z)).toVar(),n=eF(pp(t.w)).toVar();return eG(pR(pw(r,i,s,n,eF(0))),pR(pw(r,i,s,n,eF(1))),pR(pw(r,i,s,n,eF(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),pF=eA(([e,t,r,i])=>{let s=eB(i).toVar(),n=eB(r).toVar(),a=eF(t).toVar(),o=eG(e).toVar(),l=eB(0).toVar(),u=eB(1).toVar();return aK(a,()=>{l.addAssign(u.mul(pM(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"}]}),pI=eA(([e,t,r,i])=>{let s=eB(i).toVar(),n=eB(r).toVar(),a=eF(t).toVar(),o=eG(e).toVar(),l=eG(0).toVar(),u=eB(1).toVar();return aK(a,()=>{l.addAssign(u.mul(pL(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"}]}),pV=eA(([e,t,r,i])=>{let s=eB(i).toVar(),n=eB(r).toVar(),a=eF(t).toVar(),o=eG(e).toVar();return eD(pF(o,a,n,s),pF(o.add(eG(eF(19),eF(193),eF(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"}]}),pD=eA(([e,t,r,i])=>{let s=eB(i).toVar(),n=eB(r).toVar(),a=eF(t).toVar(),o=eG(e).toVar();return eW(eG(pI(o,a,n,s)).toVar(),eB(pF(o.add(eG(eF(19),eF(193),eF(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"}]}),pO=dG([eA(([e,t,r,i,s,n,a])=>{let o=eF(a).toVar(),l=eB(n).toVar(),u=eF(s).toVar(),d=eF(i).toVar(),h=eF(r).toVar(),c=eF(t).toVar(),p=eD(e).toVar(),g=eG(pB(eD(c.add(d),h.add(u)))).toVar(),m=eD(g.x,g.y).toVar();m.subAssign(.5),m.mulAssign(l),m.addAssign(.5);let f=eD(eD(eB(c),eB(h)).add(m)).toVar(),y=eD(f.sub(p)).toVar();return eM(o.equal(eF(2)),()=>rS(y.x).add(rS(y.y))),eM(o.equal(eF(3)),()=>rG(rS(y.x),rS(y.y))),rq(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"}]}),eA(([e,t,r,i,s,n,a,o,l])=>{let u=eF(l).toVar(),d=eB(o).toVar(),h=eF(a).toVar(),c=eF(n).toVar(),p=eF(s).toVar(),g=eF(i).toVar(),m=eF(r).toVar(),f=eF(t).toVar(),y=eG(e).toVar(),b=eG(pB(eG(f.add(p),m.add(c),g.add(h)))).toVar();b.subAssign(.5),b.mulAssign(d),b.addAssign(.5);let x=eG(eG(eB(f),eB(m),eB(g)).add(b)).toVar(),T=eG(x.sub(y)).toVar();return eM(u.equal(eF(2)),()=>rS(T.x).add(rS(T.y)).add(rS(T.z))),eM(u.equal(eF(3)),()=>rG(rS(T.x),rS(T.y),rS(T.z))),rq(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"}]})]),pU=eA(([e,t,r])=>{let i=eF(r).toVar(),s=eB(t).toVar(),n=eD(e).toVar(),a=eF().toVar(),o=eF().toVar(),l=eD(pg(n.x,a),pg(n.y,o)).toVar(),u=eB(1e6).toVar();return aK({start:-1,end:eF(1),name:"x",condition:"<="},({x:e})=>{aK({start:-1,end:eF(1),name:"y",condition:"<="},({y:t})=>{let r=eB(pO(l,e,t,a,o,s,i)).toVar();u.assign(rk(u,r))})}),eM(i.equal(eF(0)),()=>{u.assign(rc(u))}),u}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),pk=eA(([e,t,r])=>{let i=eF(r).toVar(),s=eB(t).toVar(),n=eD(e).toVar(),a=eF().toVar(),o=eF().toVar(),l=eD(pg(n.x,a),pg(n.y,o)).toVar(),u=eD(1e6,1e6).toVar();return aK({start:-1,end:eF(1),name:"x",condition:"<="},({x:e})=>{aK({start:-1,end:eF(1),name:"y",condition:"<="},({y:t})=>{let r=eB(pO(l,e,t,a,o,s,i)).toVar();eM(r.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(r)}).ElseIf(r.lessThan(u.y),()=>{u.y.assign(r)})})}),eM(i.equal(eF(0)),()=>{u.assign(rc(u))}),u}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),pG=eA(([e,t,r])=>{let i=eF(r).toVar(),s=eB(t).toVar(),n=eD(e).toVar(),a=eF().toVar(),o=eF().toVar(),l=eD(pg(n.x,a),pg(n.y,o)).toVar(),u=eG(1e6,1e6,1e6).toVar();return aK({start:-1,end:eF(1),name:"x",condition:"<="},({x:e})=>{aK({start:-1,end:eF(1),name:"y",condition:"<="},({y:t})=>{let r=eB(pO(l,e,t,a,o,s,i)).toVar();eM(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)})})}),eM(i.equal(eF(0)),()=>{u.assign(rc(u))}),u}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),pz=dG([pU,eA(([e,t,r])=>{let i=eF(r).toVar(),s=eB(t).toVar(),n=eG(e).toVar(),a=eF().toVar(),o=eF().toVar(),l=eF().toVar(),u=eG(pg(n.x,a),pg(n.y,o),pg(n.z,l)).toVar(),d=eB(1e6).toVar();return aK({start:-1,end:eF(1),name:"x",condition:"<="},({x:e})=>{aK({start:-1,end:eF(1),name:"y",condition:"<="},({y:t})=>{aK({start:-1,end:eF(1),name:"z",condition:"<="},({z:r})=>{let n=eB(pO(u,e,t,r,a,o,l,s,i)).toVar();d.assign(rk(d,n))})})}),eM(i.equal(eF(0)),()=>{d.assign(rc(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),p$=dG([pk,eA(([e,t,r])=>{let i=eF(r).toVar(),s=eB(t).toVar(),n=eG(e).toVar(),a=eF().toVar(),o=eF().toVar(),l=eF().toVar(),u=eG(pg(n.x,a),pg(n.y,o),pg(n.z,l)).toVar(),d=eD(1e6,1e6).toVar();return aK({start:-1,end:eF(1),name:"x",condition:"<="},({x:e})=>{aK({start:-1,end:eF(1),name:"y",condition:"<="},({y:t})=>{aK({start:-1,end:eF(1),name:"z",condition:"<="},({z:r})=>{let n=eB(pO(u,e,t,r,a,o,l,s,i)).toVar();eM(n.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(n)}).ElseIf(n.lessThan(d.y),()=>{d.y.assign(n)})})})}),eM(i.equal(eF(0)),()=>{d.assign(rc(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),pH=dG([pG,eA(([e,t,r])=>{let i=eF(r).toVar(),s=eB(t).toVar(),n=eG(e).toVar(),a=eF().toVar(),o=eF().toVar(),l=eF().toVar(),u=eG(pg(n.x,a),pg(n.y,o),pg(n.z,l)).toVar(),d=eG(1e6,1e6,1e6).toVar();return aK({start:-1,end:eF(1),name:"x",condition:"<="},({x:e})=>{aK({start:-1,end:eF(1),name:"y",condition:"<="},({y:t})=>{aK({start:-1,end:eF(1),name:"z",condition:"<="},({z:r})=>{let n=eB(pO(u,e,t,r,a,o,l,s,i)).toVar();eM(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)})})})}),eM(i.equal(eF(0)),()=>{d.assign(rc(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),pW=eA(([e,t,r,i,s,n,a,o,l,u,d])=>{let h=eF(e).toVar(),c=eD(t).toVar(),p=eD(r).toVar(),g=eD(i).toVar(),m=eB(s).toVar(),f=eB(n).toVar(),y=eB(a).toVar(),b=eV(o).toVar(),x=eF(l).toVar(),T=eB(u).toVar(),_=eB(d).toVar(),v=c.mul(p).add(g),N=eB(0).toVar();return eM(h.equal(eF(0)),()=>{N.assign(pL(v))}),eM(h.equal(eF(1)),()=>{N.assign(pB(v))}),eM(h.equal(eF(2)),()=>{N.assign(pH(v,m,eF(0)))}),eM(h.equal(eF(3)),()=>{N.assign(pI(eG(v,0),x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),eM(b,()=>{N.assign(r2(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"}]}),pq=eA(([e,t,r,i,s,n,a,o,l,u,d])=>{let h=eF(e).toVar(),c=eG(t).toVar(),p=eG(r).toVar(),g=eG(i).toVar(),m=eB(s).toVar(),f=eB(n).toVar(),y=eB(a).toVar(),b=eV(o).toVar(),x=eF(l).toVar(),T=eB(u).toVar(),_=eB(d).toVar(),v=c.mul(p).add(g),N=eB(0).toVar();return eM(h.equal(eF(0)),()=>{N.assign(pL(v))}),eM(h.equal(eF(1)),()=>{N.assign(pB(v))}),eM(h.equal(eF(2)),()=>{N.assign(pH(v,m,eF(0)))}),eM(h.equal(eF(3)),()=>{N.assign(pI(v,x,T,_))}),N.assign(N.mul(y.sub(f)).add(f)),eM(b,()=>{N.assign(r2(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"}]}),pj=eA(([e])=>{let t=e.y,r=e.z,i=eG().toVar();return eM(t.lessThan(1e-4),()=>{i.assign(eG(r,r,r))}).Else(()=>{let s=e.x,n=eF(rB(s=s.sub(rg(s)).mul(6).toVar())),a=s.sub(eB(n)),o=r.mul(t.oneMinus()),l=r.mul(t.mul(a).oneMinus()),u=r.mul(t.mul(a.oneMinus()).oneMinus());eM(n.equal(eF(0)),()=>{i.assign(eG(r,u,o))}).ElseIf(n.equal(eF(1)),()=>{i.assign(eG(l,r,o))}).ElseIf(n.equal(eF(2)),()=>{i.assign(eG(o,r,u))}).ElseIf(n.equal(eF(3)),()=>{i.assign(eG(o,l,r))}).ElseIf(n.equal(eF(4)),()=>{i.assign(eG(u,o,r))}).Else(()=>{i.assign(eG(r,o,l))})}),i}
5).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),pX=eA(([e])=>{let t=eG(e).toVar(),r=eB(t.x).toVar(),i=eB(t.y).toVar(),s=eB(t.z).toVar(),n=eB(rk(r,rk(i,s))).toVar(),a=eB(rG(r,rG(i,s))).toVar(),o=eB(a.sub(n)).toVar(),l=eB().toVar(),u=eB().toVar(),d=eB().toVar();return d.assign(a),eM(a.greaterThan(0),()=>{u.assign(o.div(a))}).Else(()=>{u.assign(0)}),eM(u.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{eM(r.greaterThanEqual(a),()=>{l.assign(i.sub(s).div(o))}).ElseIf(i.greaterThanEqual(a),()=>{l.assign(tD(2,s.sub(r).div(o)))}).Else(()=>{l.assign(tD(4,r.sub(i).div(o)))}),l.mulAssign(1/6),eM(l.lessThan(0),()=>{l.addAssign(1)})}),eG(l,u,d)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),pK=eA(([e])=>{let t=eG(e).toVar(),r=eH(tW(t,eG(.04045))).toVar();return r1(eG(t.div(12.92)).toVar(),eG(rX(rG(t.add(eG(.055)),eG(0)).div(1.055),eG(2.4))).toVar(),r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),pQ=(e,t)=>{e=eB(e);let r=eD((t=eB(t)).dFdx(),t.dFdy()).length().mul(.7071067811865476);return r6(e.sub(r),e.add(r),t)},pY=(e,t,r,i)=>r1(e,t,r[i].clamp()),pZ=(e,t,r,i,s)=>r1(e,t,pQ(r,i[s])),pJ=eA(([e,t,r])=>{let i=rf(e).toVar(),s=tO(eB(.5).mul(t.sub(r)),sH).div(i).toVar(),n=tO(eB(-.5).mul(t.sub(r)),sH).div(i).toVar(),a=eG().toVar();a.x=i.x.greaterThan(eB(0)).select(s.x,n.x),a.y=i.y.greaterThan(eB(0)).select(s.y,n.y),a.z=i.z.greaterThan(eB(0)).select(s.z,n.z);let o=rk(a.x,a.y,a.z).toVar();return sH.add(i.mul(o)).toVar().sub(r)}),p0=eA(([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(tU(r,r).sub(tU(i,i))))});var p1=Object.freeze({__proto__:null,BRDF_GGX:lh,BRDF_Lambert:o5,BasicPointShadowFilter:c8,BasicShadowFilter:cH,Break:aQ,Const:ic,Continue:()=>iQ("continue").toStack(),DFGApprox:lc,D_GGX:ll,Discard:iY,EPSILON:re,F_Schlick:o6,Fn:eA,INFINITY:rt,If:eM,Loop:aK,NodeAccess:A,NodeShaderStage:E,NodeType:{BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},NodeUpdateType:R,OnMaterialUpdate:e=>hf(hm.MATERIAL,e),OnObjectUpdate:e=>hf(hm.OBJECT,e),PCFShadowFilter:cW,PCFSoftShadowFilter:cq,PI:rr,PI2:ri,PointShadowFilter:c9,Return:()=>iQ("return").toStack(),Schlick_to_F0:lg,ScriptableNodeResources:cn,ShaderNode:eb,Stack:eL,Switch:(...e)=>j.Switch(...e),TBNViewMatrix:nz,VSMShadowFilter:cj,V_GGX_SmithCorrelated:la,Var:ih,VarIntent:ip,abs:rS,acesFilmicToneMapping:h1,acos:rv,add:tD,addMethodChaining:K,addNodeElement:function(e){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:h6,all:rs,alphaT:ts,and:tX,anisotropy:tn,anisotropyB:to,anisotropyT:ta,any:rn,append:e=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),eL(e)),array:tM,arrayBuffer:e=>ex(new W(e,"ArrayBuffer")),asin:r_,assign:tP,atan:rN,atan2:it,atomicAdd:(e,t)=>cC(cA.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>cC(cA.ATOMIC_AND,e,t),atomicFunc:cC,atomicLoad:e=>cC(cA.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>cC(cA.ATOMIC_MAX,e,t),atomicMin:(e,t)=>cC(cA.ATOMIC_MIN,e,t),atomicOr:(e,t)=>cC(cA.ATOMIC_OR,e,t),atomicStore:(e,t)=>cC(cA.ATOMIC_STORE,e,t),atomicSub:(e,t)=>cC(cA.ATOMIC_SUB,e,t),atomicXor:(e,t)=>cC(cA.ATOMIC_XOR,e,t),attenuationColor:tx,attenuationDistance:tb,attribute:i3,attributeArray:(e,t="float")=>{let r,i;return!0===t.isStruct?(r=t.layout.getLength(),i=b("float")):(r=x(t),i=b(t)),aH(new hb(e,r,i),t,e)},backgroundBlurriness:hS,backgroundIntensity:hE,backgroundRotation:hR,batch:ak,bentNormalView:nH,billboarding:dj,bitAnd:tZ,bitNot:tJ,bitOr:t0,bitXor:t1,bitangentGeometry:nO,bitangentLocal:nU,bitangentView:nk,bitangentWorld:nG,bitcast:rO,blendBurn:ow,blendColor:oP,blendDodge:oC,blendOverlay:oL,blendScreen:oM,blur:ui,bool:eV,buffer:sn,bufferAttribute:iI,bumpMap:nQ,burn:(...e)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),ow(e)),bvec2:ek,bvec3:eH,bvec4:eX,bypass:iW,cache:i$,call:tF,cameraFar:sp,cameraIndex:sh,cameraNear:sc,cameraNormalMatrix:sb,cameraPosition:sx,c
5ameraProjectionMatrix:sg,cameraProjectionMatrixInverse:sm,cameraViewMatrix:sf,cameraWorldMatrix:sy,cbrt:rJ,cdl:h$,ceil:rm,checker:pu,cineonToneMapping:hJ,clamp:r2,clearcoat:e8,clearcoatNormalView:s6,clearcoatRoughness:e9,code:h9,color:eP,colorSpaceToWorking:iR,colorToDirection:e=>ex(e).mul(2).sub(1),compute:iG,computeKernel:ik,computeSkinning:(e,t=null)=>{let r=new aq(e);return r.positionNode=aH(new u.uWO(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(aM).toVar(),r.skinIndexNode=aH(new u.uWO(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(aM).toVar(),r.skinWeightNode=aH(new u.uWO(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(aM).toVar(),r.bindMatrixNode=tw(e.bindMatrix,"mat4"),r.bindMatrixInverseNode=tw(e.bindMatrixInverse,"mat4"),r.boneMatricesNode=sn(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),r.toPositionNode=t,ex(r)},context:ia,convert:eJ,convertColorSpace:(e,t,r)=>ex(new iS(ex(e),t,r)),convertToTexture:(e,...t)=>e.isTextureNode?e:e.isPassNode?e.getTextureNode():hd(e,...t),cos:rx,cross:rj,cubeTexture:np,cubeTextureBase:nc,cubeToUV:c5,dFdx:rC,dFdy:rM,dashSize:tc,debug:i1,decrement:t8,decrementBefore:t6,defaultBuildStages:C,defaultShaderStages:w,defined:ef,degrees:ro,deltaTime:d$,densityFog:function(e,t){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),ch(e,cd(t))},densityFogFactor:cd,depth:ox,depthPass:(e,t,r)=>ex(new hK(hK.DEPTH,e,t,r)),determinant:rV,difference:rW,diffuseColor:e3,directPointLight:po,directionToColor:o$,directionToFaceDirection:sY,dispersion:tT,distance:rH,div:tk,dodge:(...e)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),oC(e)),dot:rq,drawIndex:aF,dynamicBufferAttribute:iV,element:eZ,emissive:e4,equal:tz,equals:rU,equirectUV:oq,exp:rl,exp2:ru,expression:iQ,faceDirection:sQ,faceForward:r5,faceforward:r5,float:eB,floor:rg,fog:ch,fract:ry,frameGroup:tS,frameId:dH,frontFacing:sK,fwidth:rF,gain:(e,t)=>e.lessThan(.5)?dI(e.mul(2),t).div(2):tO(1,dI(tU(tO(1,e),2),t).div(2)),gapSize:tp,getConstNodeType:ey,getCurrentStack:eC,getDirection:l7,getDistanceAttenuation:pa,getGeometryRoughness:ls,getNormalFromDepth:hp,getParallaxCorrectNormal:pJ,getRoughness:ln,getScreenPosition:hc,getShIrradianceAt:p0,getShadowMaterial:cK,getShadowRenderObjectFunction:cZ,getTextureIndex:dL,getViewPosition:hh,globalId:cT,glsl:(e,t)=>h9(e,t,"glsl"),glslFn:(e,t)=>ce(e,t,"glsl"),grayscale:hO,greaterThan:tW,greaterThanEqual:tj,hash:dF,highpModelNormalViewMatrix:sk,highpModelViewMatrix:sU,hue:hG,increment:t5,incrementBefore:t4,instance:aV,instanceIndex:aM,instancedArray:(e,t="float")=>{let r,i;return!0===t.isStruct?(r=t.layout.getLength(),i=b("float")):(r=x(t),i=b(t)),aH(new hy(e,r,i),t,e)},instancedBufferAttribute:iD,instancedDynamicBufferAttribute:iO,instancedMesh:aO,int:eF,inverse:rD,inverseSqrt:rp,inversesqrt:rp,invocationLocalIndex:aB,invocationSubgroupIndex:aP,ior:tm,iridescence:tt,iridescenceIOR:tr,iridescenceThickness:ti,ivec2:eO,ivec3:ez,ivec4:eq,js:(e,t)=>h9(e,t,"js"),label:il,length:rR,lengthSq:r0,lessThan:tH,lessThanEqual:tq,lightPosition:cB,lightProjectionUV:cP,lightShadowMatrix:cL,lightTargetDirection:cV,lightTargetPosition:cF,lightViewPosition:cI,lightingContext:a6,lights:(e=[])=>ex(new ck).setLights(e),linearDepth:oT,linearToneMapping:hY,localId:c_,log:rd,log2:rh,logarithmicDepthToViewZ:(e,t,r)=>{let i=e.mul(rd(r.div(t)));return eB(Math.E).pow(i).mul(t).negate()},luminance:hz,mat2:eK,mat3:eQ,mat4:eY,matcapUV:uk,materialAO:aE,materialAlphaTest:nJ,materialAnisotropy:al,materialAnisotropyVector:aR,materialAttenuationColor:af,materialAttenuationDistance:am,materialClearcoat:ar,materialClearcoatNormal:as,materialClearcoatRoughness:ai,materialColor:n0,materialDispersion:aN,materialEmissive:n2,materialEnvIntensity:ns,materialEnvRotation:nn,materialIOR:ag,materialIridescence:au,materialIridescenceIOR:ad,materialIridescenceThickness:ah,materialLightMap:aS,materialLineDashOffset:a_,materialLineDashSize:ab,materialLineGapSize:ax,materialLineScale:ay,materialLineWidth:aT,materialMetalness:ae,materialNormal:at,materialOpacity:n3,materialPointSize:av,materialReference:nx,materialReflectivity:n9,materialRefractionRatio:ni,materialRotation:an,materialRoughness:n7,materialSheen:aa,materialSheenRoughness:ao,materialShininess:n1,materialSpecular:n4,materialSpecularColor:n5,materialSpecularIntensity:n6,materialSpecularStrength:n8,materialThickness:ap,materialTransmission:ac,max:rG,maxMipLevel:i9,mediumpModelViewMatrix:sO,metalness:e5,min:rk,mix:r1,mixElement:r9,mod:tG,modInt:t9,modelDirection:sC,modelNormalMatrix:sI,modelPosition:sL,modelRadius:sF,modelScale:sP,modelViewMatrix:sD,modelViewPosition:sB,modelViewProjection:aA,modelWorldMatrix:sM,modelWorldMatrixInverse:sV,morphReference:a1,mrt:dB,mul:tU,mx_aastep:pQ,mx_add:(e,t=eB(0))=>tD(e,t),mx_atan2:(e=eB(0),t=eB(1))=>rN(e,t),mx_cell_noise_float:(e=i4())=>
5pP(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>eB(e).sub(r).mul(t).add(r),mx_divide:(e,t=eB(1))=>tk(e,t),mx_fractal_noise_float:(e=i4(),t=3,r=2,i=.5,s=1)=>pF(e,eF(t),r,i).mul(s),mx_fractal_noise_vec2:(e=i4(),t=3,r=2,i=.5,s=1)=>pV(e,eF(t),r,i).mul(s),mx_fractal_noise_vec3:(e=i4(),t=3,r=2,i=.5,s=1)=>pI(e,eF(t),r,i).mul(s),mx_fractal_noise_vec4:(e=i4(),t=3,r=2,i=.5,s=1)=>pD(e,eF(t),r,i).mul(s),mx_frame:()=>dH,mx_heighttonormal:(e,t)=>nQ(e=eG(e),t=eB(t)),mx_hsvtorgb:pj,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=eB(1))=>tO(t,e),mx_modulo:(e,t=eB(1))=>tG(e,t),mx_multiply:(e,t=eB(1))=>tU(e,t),mx_noise_float:(e=i4(),t=1,r=0)=>pM(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=i4(),t=1,r=0)=>pL(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=i4(),t=1,r=0)=>eW(pL(e=e.convert("vec2|vec3")),pM(e.add(eD(19,73)))).mul(t).add(r),mx_place2d:(e,t=eD(.5,.5),r=eD(1,1),i=eB(0),s=eD(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=eD(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=eB(1))=>rX(e,t),mx_ramp4:(e,t,r,i,s=i4())=>{let n=s.x.clamp(),a=s.y.clamp(),o=r1(e,t,n),l=r1(r,i,n);return r1(o,l,a)},mx_ramplr:(e,t,r=i4())=>pY(e,t,r,"x"),mx_ramptb:(e,t,r=i4())=>pY(e,t,r,"y"),mx_rgbtohsv:pX,mx_rotate2d:(e,t)=>uH(e=eD(e),(t=eB(t)).mul(Math.PI/180)),mx_rotate3d:(e,t,r)=>{e=eG(e),t=eB(t),r=eG(r);let i=t.mul(Math.PI/180),s=r.normalize(),n=i.cos(),a=i.sin(),o=eB(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=eB(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=i4())=>pZ(e,t,r,i,"x"),mx_splittb:(e,t,r,i=i4())=>pZ(e,t,r,i,"y"),mx_srgb_texture_to_lin_rec709:pK,mx_subtract:(e,t=eB(0))=>tO(e,t),mx_timer:()=>dz,mx_transform_uv:(e=1,t=0,r=i4())=>r.mul(e).add(t),mx_unifiednoise2d:(e,t=i4(),r=eD(1,1),i=eD(0,0),s=1,n=0,a=1,o=!1,l=1,u=2,d=.5)=>pW(e,t.convert("vec2|vec3"),r,i,s,n,a,o,l,u,d),mx_unifiednoise3d:(e,t=i4(),r=eD(1,1),i=eD(0,0),s=1,n=0,a=1,o=!1,l=1,u=2,d=.5)=>pq(e,t.convert("vec2|vec3"),r,i,s,n,a,o,l,u,d),mx_worley_noise_float:(e=i4(),t=1)=>pz(e.convert("vec2|vec3"),t,eF(1)),mx_worley_noise_vec2:(e=i4(),t=1)=>p$(e.convert("vec2|vec3"),t,eF(1)),mx_worley_noise_vec3:(e=i4(),t=1)=>pH(e.convert("vec2|vec3"),t,eF(1)),negate:rA,neutralToneMapping:h5,nodeArray:ev,nodeImmutable:eS,nodeObject:ex,nodeObjectIntent:eT,nodeObjects:e_,nodeProxy:eN,nodeProxyIntent:eE,normalFlat:s0,normalGeometry:sZ,normalLocal:sJ,normalMap:nq,normalView:s3,normalViewGeometry:s1,normalWorld:s4,normalWorldGeometry:s2,normalize:rf,not:tQ,notEqual:t$,numWorkgroups:cb,objectDirection:sv,objectGroup:tR,objectPosition:sS,objectRadius:sA,objectScale:sE,objectViewPosition:sR,objectWorldMatrix:sN,oneMinus:rw,or:tK,orthographicDepthToViewZ:(e,t,r)=>t.sub(r).mul(e).sub(t),oscSawtooth:(e=dz)=>e.fract(),oscSine:(e=dz)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=dz)=>e.fract().round(),oscTriangle:(e=dz)=>e.add(.5).fract().mul(2).sub(1).abs(),output:th,outputStruct:dM,overlay:(...e)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),oL(e)),overloadingFn:dG,parabola:dI,parallaxDirection:n$,parallaxUV:(e,t)=>e.sub(n$.mul(t)),parameter:(e,t)=>ex(new dS(e,t)),pass:(e,t,r)=>ex(new hK(hK.COLOR,e,t,r)),passTexture:(e,t)=>ex(new hj(e,t)),pcurve:(e,t,r)=>rX(tk(rX(e,t),tD(rX(e,t),rX(tO(1,e),r))),1/t),perspectiveDepthToViewZ:of,pmremTexture:uA,pointShadow:ps,pointUV:hT,pointWidth:tg,positionGeometry:sG,positionLocal:sz,positionPrevious:s$,positionView:sq,positionViewDirection:sj,positionWorld:sH,positionWorldDirection:sW,posterize:hW,pow:rX,pow2:rK,pow3:rQ,pow4:rY,premultiplyAlpha:oB,property:e1,radians:ra,rand:r8,range:cm,rangeFog:function(e,t,r){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),ch(e,cu(t,r))},rangeFogFactor:cu,reciprocal:rP,reference:nf,referenceBuffer:ny,reflect:r$,reflectVector:nl,reflectView:na,reflector:e=>ex(new hr(e)),refract:r4,refractVector:nu,refractView:no,reinhardToneMapping:hZ,remap:ij,remapClamp:iX,renderGroup:tE,renderOutput:iJ,rendererReference:iM,rotate:uH,rotateUV:dW,roughness:e6,round:rL,rtt:hd,sRGBTransferEOTF:i_,sRGBTransferOETF:iv,sample:e=>ex(new hg(e)),sampler:e=>(!0===e.isNode?e:sr(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:sr(e)).convert("samplerComparison"),saturate:r3,saturation:hU,screen:(...e)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),oM(e)),screenCoordinate:oe,screenSize:a7,screenUV:a9,scriptable:co,scriptableValue:cr,select:ii,setCurrentStack:ew,setName:io,shaderStages:M,shadow:c4,shadowPositionWorld:cz,shapeCircle:pd,sharedUniformGroup:tN,sheen:e7,sheenRoughness:te,shiftLeft:t2,shiftRight:t3,shininess:td,sign:rE,sin:rb,sinc:(e,t)=>rb(rr.mul(t.mul(e).sub(1))).div(rr.mul(t.mul(e).sub(1))),skinning:aj,smoothstep:r6,smoothstepElement:r7,specularColor:tl,
5specularF90:tu,spherizeUV:dq,split:(e,t)=>ex(new k(ex(e),t)),spritesheetUV:dQ,sqrt:rc,stack:dR,step:rz,stepElement:ie,storage:aH,storageBarrier:()=>cS("storage").toStack(),storageObject:(e,t,r)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),aH(e,t,r).setPBO(!0)),storageTexture:hw,string:(e="")=>ex(new W(e,"string")),struct:(e,t=null)=>{let r=new dA(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 ex(new dw(r,i))};return i.layout=r,i.isStruct=!0,i},sub:tO,subBuild:iy,subgroupIndex:aL,subgroupSize:cv,tan:rT,tangentGeometry:nB,tangentLocal:nF,tangentView:nI,tangentWorld:nV,temp:ig,texture:sr,texture3D:hL,textureBarrier:()=>cS("texture").toStack(),textureBicubic:lB,textureBicubicLevel:lP,textureCubeUV:ue,textureLoad:si,textureSize:i5,textureStore:(e,t,r)=>{let i=hw(e,t,r);return null!==r&&i.toStack(),i},thickness:ty,time:dz,timerDelta:(e=1)=>(console.warn('TSL: timerDelta() is deprecated. Use "deltaTime" instead.'),d$.mul(e)),timerGlobal:(e=1)=>(console.warn('TSL: timerGlobal() is deprecated. Use "time" instead.'),dz.mul(e)),timerLocal:(e=1)=>(console.warn('TSL: timerLocal() is deprecated. Use "time" instead.'),dz.mul(e)),toneMapping:iP,toneMappingExposure:iB,toonOutlinePass:(e,t,r=new u.Q1f(0,0,0),i=.003,s=1)=>ex(new hQ(e,t,ex(r),ex(i),ex(s))),transformDirection:rZ,transformNormal:s5,transformNormalToView:s8,transformedClearcoatNormalView:ne,transformedNormalView:s9,transformedNormalWorld:s7,transmission:tf,transpose:rI,triNoise3D:dO,triplanarTexture:(...e)=>dY(...e),triplanarTextures:dY,trunc:rB,uint:eI,uniform:tw,uniformArray:sl,uniformCubeTexture:(e=nd)=>nc(e),uniformGroup:tv,uniformTexture:(e=i7)=>sr(e),unpremultiplyAlpha:oF,userData:(e,t,r)=>ex(new hP(e,t,r)),uv:i4,uvec2:eU,uvec3:e$,uvec4:ej,varying:ix,varyingProperty:e2,vec2:eD,vec3:eG,vec4:eW,vectorComponents:L,velocity:hD,vertexColor:oA,vertexIndex:aC,vertexStage:iT,vibrance:hk,viewZToLogarithmicDepth:oy,viewZToOrthographicDepth:og,viewZToPerspectiveDepth:om,viewport:ot,viewportCoordinate:oi,viewportDepthTexture:oc,viewportLinearDepth:o_,viewportMipTexture:ou,viewportResolution:on,viewportSafeUV:dX,viewportSharedTexture:oz,viewportSize:or,viewportTexture:ol,viewportUV:os,wgsl:(e,t)=>h9(e,t,"wgsl"),wgslFn:(e,t)=>ce(e,t,"wgsl"),workgroupArray:(e,t)=>ex(new cR("Workgroup",e,t)),workgroupBarrier:()=>cS("workgroup").toStack(),workgroupId:cx,workingToColorSpace:iE,xor:tY});let p2=new dN;class p3 extends u4{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){let i=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background,n=!1;if(null===s)i._clearColor.getRGB(p2),p2.a=i._clearColor.a;else if(!0===s.isColor)s.getRGB(p2),p2.a=1,n=!0;else if(!0===s.isNode){let r=this.get(e);p2.copy(i._clearColor);let n=r.backgroundMesh;if(void 0===n){let e=ia(eW(s).mul(hE),{getUV:()=>hR.mul(s2),getTextureLevel:()=>hS}),t=aA;t=t.setZ(t.w);let i=new oI;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=eW(s).mul(hE),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?p2.set(0,0,0,1):"alpha-blend"===a&&p2.set(0,0,0,0),!0===i.autoClear||!0===n){let e=r.clearColorValue;e.r=p2.r,e.g=p2.g,e.b=p2.b,e.a=p2.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 p4=0;class p6{constructor(e="",t=[],r=0,i=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=i,this.id=p4++}}class p5{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 p6(t.name,[],t.index,t);for(let i of(e.push(r),t.bindings))r.bindings.push(i.clone())}else e.push(t);return e}}class p8{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class p9{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r.getSelf()}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}}
5class p7{constructor(e,t,r=!1,i=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=i}}class ge extends p7{constructor(e,t,r=null,i=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=i}}class gt{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let gr=0;class gi{constructor(e=null){this.id=gr++,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 gs{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class gn{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 ga extends gn{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class go extends gn{constructor(e,t=new u.I9Y){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class gl extends gn{constructor(e,t=new u.Pq0){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class gu extends gn{constructor(e,t=new u.IUQ){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class gd extends gn{constructor(e,t=new u.Q1f){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class gh extends gn{constructor(e,t=new u.k_V){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class gc extends gn{constructor(e,t=new u.dwI){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class gp extends gn{constructor(e,t=new u.kn4){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class gg extends ga{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class gm extends go{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class gf extends gl{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class gy extends gu{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class gb extends gd{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class gx extends gh{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class gT extends gc{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class g_ extends gp{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let gv=new WeakMap,gN=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),gS=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0");class gE{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.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=dR(),this.stacks=[],this.tab="	",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new gi,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=gv.get(this.renderer);return void 0===e&&(e=new uJ,gv.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new u.O0B(e,t,r)}createCubeRenderTarget(e,t){return new oj(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 p6(e,s,this.bindingsIndexes[e].group,s),i.set(s,r)):r=new p6(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 M)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()!==R.NONE&&this.updateNodes.push(e.getSelf());for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==R.NONE&&this.updateBeforeNodes.push(e.getSelf()),r!==R.NONE&&this.updateAfterNodes.push(e.getSelf())}}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}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 gi(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 gS(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")}( ${gS(t.r)}, ${gS(t.g)}, ${gS(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 p8(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=f.get(e),i="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),i+r}getTypeFromArray(e){return gN.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(){return this.stack=dR(this.stack),this.stacks.push(eC()||this.stack),ew(this.stack),this.stack}removeStack(){let e=this.stack;return this.stack=e.parent,ew(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 p8("nodeAttribute"+this.uniforms.index++,t,e),this.bufferAttributes.push(i),r.bufferAttribute=i),i}getStructTypeFromNode(e,t,r=null,i=this.shaderStage){let s=this.getDataFromNode(e,i,this.globalCache),n=s.structType;if(void 0===n){let e=this.structs.index++;null===r&&(r="StructType"+e),n=new gs(r,t),this.structs[i].push(n),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 p9(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 p7(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 ge(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 gt("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 h7,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 dS(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 gi,this.stack=dR(),C))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 oI),e.build(this)}else this.addFlow("compute",e);for(let e of C)for(let t of(this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex),M))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 gg(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new gm(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new gf(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new gy(e);if("color"===t)return new gb(e);if("mat2"===t)return new gx(e);if("mat3"===t)return new gT(e);if("mat4"===t)return new g_(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`}*[Symbol.iterator](){}}class gR{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===R.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===R.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===R.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===R.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===R.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===R.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),r=e.updateReference(this);if(t===R.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===R.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===R.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 gA{constructor(e,t,r=null,i="",s=!1){this.type=e,this.name=t,this.count=r,this.qualifier=i,this.isConst=s}}gA.isNodeFunctionInput=!0;class gw extends pn{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:cV(this.light),lightColor:e}}}let gC=new u.kn4,gM=new u.kn4,gL=null;class gP extends pn{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=tw(new u.Pq0).setGroup(tE),this.halfWidth=tw(new u.Pq0).setGroup(tE),this.updateType=R.RENDER}update(e){super.update(e);let{light:t}=this,r=e.camera.matrixWorldInverse;gM.identity(),gC.copy(t.matrixWorld),gC.premultiply(r),gM.extractRotation(gC),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(gM),this.halfHeight.value.applyMatrix4(gM)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=sr(gL.LTC_FLOAT_1),r=sr(gL.LTC_FLOAT_2)):(t=sr(gL.LTC_HALF_1),r=sr(gL.LTC_HALF_2));let{colorNode:i,light:s}=this;return{lightColor:i,lightPosition:cI(s),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){gL=e}}class gB extends pn{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=tw(0).setGroup(tE),this.penumbraCosNode=tw(0).setGroup(tE),this.cutoffDistanceNode=tw(0).setGroup(tE),this.decayExponentNode=tw(0).setGroup(tE),this.colorNode=tw(this.color).setGroup(tE)}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 r6(r,i,t)}getLightCoord(e){let t=e.getNodeProperties(this),r=t.projectionUV;return void 0===r&&(t.projectionUV=r=cP(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(cV(a)),d=this.getSpotAttenuation(e,u),h=pa({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=sr(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 gF extends gB{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){let r=this.light.iesMap;return r&&!0===r.isTexture?sr(r,eD(t.acos().mul(1/Math.PI),0),0).r:super.getSpotAttenuation(t)}}let gI=eA(([e,t])=>{let r=e.abs().sub(t);return rR(rG(r,0)).add(rk(rG(r.x,r.y),0))});class gV extends gB{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=eB(0),r=this.penumbraCosNode,i=cL(this.light).mul(e.context.positionWorld||sH);return eM(i.w.greaterThan(0),()=>{let e=gI(i.xyz.div(i.w).xy.sub(eD(.5)),eD(.5)),s=tk(-1,tO(1,rv(r)).sub(1));t.assign(r3(e.mul(-2).mul(s)))}),t}}class gD extends pn{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class gO extends pn{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=cB(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=tw(new u.Q1f).setGroup(tE)}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=r1(r,t,s4.dot(i).mul(.5).add(.5));e.context.irradiance.addAssign(s)}}class gU extends pn{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new u.Pq0);this.lightProbe=sl(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=p0(s4,this.lightProbe);e.context.irradiance.addAssign(t)}}class gk{parseFunction(){console.warn("Abstract function.")}}class gG{constructor(e,t,r="",i=""){this.type=e,this.inputs=t,this.name=r,this.precision=i}getCode(){console.warn("Abstract function.")}}gG.isNodeFunction=!0;let gz=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,g$=/[a-z_0-9]+/ig,gH="#pragma main";class gW extends gG{constructor(e){const{type:t,inputs:r,name:i,precision:s,inputsCode:n,blockCode:a,headerCode:o}=(e=>{let t=(e=e.trim()).indexOf(gH),r=-1!==t?e.slice(t+gH.length):e,i=r.match(gz);if(null!==i&&5===i.length){let s=i[4],n=[],a=null;for(;null!==(a=g$.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 gA(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 gq extends gk{parseFunction(e){return new gW(e)}}let gj=new WeakMap,gX=[],gK=[];class gQ extends u4{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new gR,this.nodeBuilderCache=new Map,this.callHashCache=new uJ,this.groupsData=new uJ,this.cacheLib={}}updateGroup(e){let t=e.groupNode,r=t.name;if(r===tR.name)return!0;if(r===tE.name){let t=this.get(e),r=this.nodeFrame.renderId;return t.renderId!==r&&(t.renderId=r,!0)}if(r===tS.name){let t=this.get(e),r=this.nodeFrame.frameId;return t.frameId!==r&&(t.frameId=r,!0)}gX[0]=t,gX[1]=e;let i=this.groupsData.get(gX);return void 0===i&&this.groupsData.set(gX,i={}),gX.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 p5(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){gX[0]=e,gX[1]=t;let r=this.renderer.info.calls,i=this.callHashCache.get(gX)||{};if(i.callId!==r){let s=this.getEnvironmentNode(e),n=this.getFogNode(e);t&&gK.push(t.getCacheKey(!0)),s&&gK.push(s.getCacheKey()),n&&gK.push(n.getCacheKey()),gK.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),gK.push(+!!this.renderer.shadowMap.enabled),i.callId=r,i.cacheKey=p(gK),this.callHashCache.set(gX,i),gK.length=0}return gX.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 uA(r);else return oZ(!0===r.isCubeTexture?np(r):sr(r));if(!0===r.isTexture)return sr(r,a9.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,()=>r.isFogExp2?ch(nf("color","color",r).setGroup(tE),cd(nf("density","float",r).setGroup(tE))):r.isFog?ch(nf("color","color",r).setGroup(tE),cu(nf("near","float",r).setGroup(tE),nf("far","float",r).setGroup(tE))):void 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?np(r):!0===r.isTexture?sr(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 gj.get(e)!==this.getOutputCacheKey()}getOutputNode(e){let t=this.renderer,r=this.getOutputCacheKey(),i=e.isArrayTexture?hL(e,eG(a9,sd("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):sr(e,a9).renderOutput(t.toneMapping,t.currentColorSpace);return gj.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 gR,this.nodeBuilderCache=new Map,this.cacheLib={}}}let gY=new u.Zcv;class gZ{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++){gY.copy(e[s]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let i=t[r+s],n=gY.normal;i.x=-n.x,i.y=-n.y,i.z=-n.z,i.w=gY.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 gZ(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class gJ{constructor(e,t){this.bundleGroup=e,this.camera=t}}let g0=[];class g1{constructor(){this.bundles=new uJ}get(e,t){let r=this.bundles;g0[0]=e,g0[1]=t;let i=r.get(g0);return void 0===i&&(i=new gJ(e,t),r.set(g0,i)),g0.length=0,i}dispose(){this.bundles=new uJ}}class g2{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 g3=new ck,g4=[];class g6 extends uJ{constructor(){super()}createNode(e=[]){return new ck().setLights(e)}getNode(e,t){if(e.isQuadMesh)return g3;g4[0]=e,g4[1]=t;let r=this.get(g4);return void 0===r&&(r=this.createNode(),this.set(g4,r)),g4.length=0,r}}class g5 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 g8=new u.Pq0,g9=new u.Pq0;class g7 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._supportsLayers=!1,this._supportsGlBinding="u">typeof XRWebGLBinding,this._frameBufferTargets=null,this._createXRLayer=ms.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new u.I9Y,this._onSessionEvent=mt.bind(this),this._onSessionEnd=mr.bind(this),this._onInputSourcesChange=mi.bind(this),this._onAnimationFrame=mn.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._useLayers=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}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 g5(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 g5(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._supportsLayers){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 ho(new oI),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(),this._supportsGlBinding){let t=new XRWebGLBinding(e,i);this._glBinding=t}if(!0===this._useLayers){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);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 g5(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
7:1,this._supportsLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._supportsLayers)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 g5(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;me(o,h);for(let e=0;e<c.length;e++)me(c[e],h);2===c.length?function(e,t,r){g8.setFromMatrixPosition(t.matrixWorld),g9.setFromMatrixPosition(r.matrixWorld);let i=g8.distanceTo(g9),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 me(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function mt(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 mr(){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._supportsLayers)for(let e of this._layers)e.renderTarget=new g5(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 mi(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 ms(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 mn(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._useLayers){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 ma=new u.Z58,mo=new u.I9Y,ml=new u.IUQ,mu=new u.PPD,md=new u.uf3,mh=new u.kn4,mc=new u.IUQ;class mp{constructor(e,t={}){this.isRenderer=!0;const{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 u7,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new g2,this.lighting=new g6,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 ho(new oI),this._quad.material.name="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const c=+(!0!==this.alpha);this._clearColor=new dN(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 g7(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 gQ(this,r),this._animation=new uZ(this._nodes,this.info),this._attributes=new u6(r),this._background=new p3(this,this._nodes),this._geometries=new u9(this._attributes,this.info),this._textures=new dv(this,r,this.info),this._pipelines=new dn(r,this._nodes),this._bindings=new da(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new u3(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new dp(this.lighting),this._bundles=new g1,this._renderContexts=new dT,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:ma;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 gZ),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=sU,this.overrideNodes.modelNormalViewMatrix=sk):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===sU&&this.overrideNodes.modelNormalViewMatrix===sk}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(mo),{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:ma,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(mo),ml.set(0,0,mo.width,mo.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(ml),p.scissorValue.copy(y).multiplyScalar(b).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(ml),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new gZ),p.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,i);let _=t.isArrayCamera?md:mu;t.isArrayCamera||(mh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(mh,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=this.domElement.width,p.height=this.domElement.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,this._background.update(u,v,p),p.camera=t,this.backend.beginRender(p);let{bundles:N,lightsNode:S,transparentDoublePass:E,transparent:R,opaque:A}=v;return N.length>0&&this._renderBundles(N,u,S),!0===this.opaque&&A.length>0&&this._renderObjects(A,t,u,S),!0===this.transparent&&R.length>0&&this._renderTransparents(R,E,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(){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=mc.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=mc.copy(t).floor()}else t=mc.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?md:mu;if(!e.frustumCulled||n.intersectsSprite(e,t)){!0===this.sortObjects&&mc.setFromMatrixPosition(e.matrixWorld).applyMatrix4(mh);let{geometry:t,material:n}=e;n.visible&&i.push(e,t,n,r,mc.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?md:mu;if(!e.frustumCulled||n.intersectsObject(e,t)){let{geometry:t,material:n}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),mc.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(mh)),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,mc.z,l,s)}}else n.visible&&i.push(e,t,n,r,mc.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}}
10class mg{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}class mm extends mg{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 mf extends mm{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let my=0;class mb extends mf{constructor(e,t){super("UniformBuffer_"+my++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class mx extends mf{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]||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 mT=0;class m_ extends mx{constructor(e,t){super(e),this.id=mT++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class mv extends mg{constructor(e,t){super(e),this._onDisposeTexture=()=>{this.texture=null},this.texture=t,this.version=t?t.version:0,this.generation=null,this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture&&this._texture.removeEventListener("dispose",this._onDisposeTexture),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",this._onDisposeTexture))}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}}let mN=0;class mS extends mv{constructor(e,t){super(e,t),this.id=mN++,this.store=!1,this.isSampledTexture=!0}}class mE extends mS{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(
10)}}class mR extends mE{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledCubeTexture=!0}}class mA extends mE{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledTexture3D=!0}}let mw={textureDimensions:"textureSize",equals:"equal"},mC={low:"lowp",medium:"mediump",high:"highp"},mM={swizzleAssign:!0,storageBuffer:!1},mL={perspective:"smooth",linear:"noperspective"},mP={centroid:"centroid"},mB=`
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 mF extends gE{constructor(e,t){super(e,t,new gq),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==u.jf0}getMethod(e){return mw[e]||e}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;let p=new se(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="."+L.join("").slice(0,h),p=`ivec2(${a} % ${d}, ${a} / ${d})`,g=this.generateTextureLoad(null,n,p,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="0"){return i?`texelFetch( ${t}, ivec3( ${r}, ${i} ), ${s} )`:`texelFetch( ${t}, ${r}, ${s} )`}generateTexture(e,t,r,i){return e.isDepthTexture?(i&&(r=`vec4( ${r}, ${i} )`),`texture( ${t}, ${r} ).x`):(i&&(r=`vec3( ${r}, ${i} )`),`texture( ${t}, ${r} )`)}generateTextureLevel(e,t,r,i){return`textureLod( ${t}, ${r}, ${i} )`}generateTextureBias(e,t,r,i){return`texture( ${t}, ${r}, ${i} )`}generateTextureGrad(e,t,r,i){return`textureGrad( ${t}, ${r}, ${i[0]}, ${i[1]} )`}generateTextureCompare(e,t,r,i,s,n=this.shaderStage){if("fragment"===n)return s?`texture( ${t}, vec4( ${r}, ${s}, ${i} ) )`:`texture( ${t}, vec3( ${r}, ${i} ) )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} 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=mC[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);
41if(/^[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=mL[i.interpolationType]||i.interpolationType,s=mP[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=mL[e.interpolationType]||e.interpolationType,s=mP[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)=>e*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=mM[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)}mM[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${mB}
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${mB}
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 mE(s.name,s.node,i),l.push(a);else if("cubeTexture"===t)a=new mR(s.name,s.node,i),l.push(a);else if("texture3D"===t)a=new mA(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 mb(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 m_(r+"_"+o,i),e[o]=n,l.push(n)),a=this.getNodeUniform(s,t),n.addUniform(a)}n.uniformGPU=a}return s}}let mI=null,mV=null;class mD{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(){}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 mI=mI||new u.I9Y,this.renderer.getDrawingBufferSize(mI)}setScissorTest(){}getClearColor(){let e=this.renderer;
121return mV=mV||new dN,e.getClearColor(mV),mV.getRGB(mV),mV}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 mO=0;class mU{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 mk{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("u">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:mO++};(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(h=new mU(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;e++){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 mG{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 mz{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.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.Fn)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}n===e.TIMEOUT_EXPIRED?requestAnimationFrame(s):(e.deleteSync(t),r())}()})}}let m$=!1,mH,mW,mq;class mj{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===m$&&(this._init(),m$=!0)}_init(){let e=this.gl;mH={[u.GJx]:e.REPEAT,[u.ghU]:e.CLAMP_TO_EDGE,[u.kTW]:e.MIRRORED_REPEAT},mW={[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},mq={[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)}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,mH[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,mH[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,mH[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,mW[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,mW[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,mq[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:u}=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 e=t.images;for(let t=0;t<6;t++){let n=mX(e[t]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,i,s,o,l,n)}}else if(e.isDataArrayTexture||e.isArrayTexture){let e=t.image;r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,e.width,e.height,e.depth,o,l,e.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,677 bytes, line 121
121else if(e.isVideoTexture)e.update(),r.texImage2D(a,0,u,o,l,t.image);else{let e=mX(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),E=m.getParameter(m.UNPACK_SKIP_PIXELS),R=m.getParameter(m.UNPACK_SKIP_ROWS),A=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 w=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 w?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,E),m.pixelStorei(m.UNPACK_SKIP_ROWS,R),m.pixelStorei(m.UNPACK_SKIP_IMAGES,A),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 mX(e){return e.isDataTexture?e.image.data:"u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class mK{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 mQ{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 mY={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 mZ{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 mJ{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 m0 extends mJ{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.id,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e.id);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.id);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 m1 extends mD{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="u">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 mK(this),this.capabilities=new mQ(this),this.attributeUtils=new mk(this),this.textureUtils=new mj(this),this.bufferRenderer=new mZ(this),this.state=new mG(this),this.utils=new mz(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){if(!this.disjoint||!this.trackTimestamp)return;let t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t]||(this.timestampQueryPool[t]=new m0(this.gl,t,2048));let r=this.timestampQueryPool[t];null!==r.allocateQueriesForContext(e)&&r.beginQuery(e)}prepareTimestampBuffer(e){if(!this.disjoint||!this.trackTimestamp)return;let t=e.isComputeNode?"compute":"render";this.timestampQueryPool[t].endQuery(e)}getContext(){return this.gl}beginRender(e){let{state:t}=this,r=this.get(e);if(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(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)}this._currentContext=s;let o=e.renderTarget;if(null!==e.textures&&o){let i=this.get(o);if(o.samples>0&&!1===this._useMultisampledExtension(o)){let s=i.framebuffers[e.getCacheKey()],n=t.COLOR_BUFFER_BIT;o.resolveDepthBuffer&&(o.depthBuffer&&(n|=t.DEPTH_BUFFER_BIT),o.stencilBuffer&&o.resolveStencilBuffer&&(n|=t.STENCIL_BUFFER_BIT));let a=i.msaaFrameBuffer,l=i.msaaRenderbuffers,u=e.textures,d=u.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,a),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,s),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:a}=e.scissorValue,o=e.height-a-i;t.blitFramebuffer(r,o,r+s,o+a,r,o,r+s,o+a,n,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,n,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,i.invalidationArray)}else if(!1===o.resolveDepthBuffer&&i.framebuffers){let s=i.framebuffers[e.getCacheKey()];r.bindFramebuffer(t.DRAW_FRAMEBUFFER,s),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,i.depthInvalidationArray)}}if(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(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){let{gl:n,renderer:a}=this;null===i&&(i={textures:null,clearColorValue:this.getClearColor()});let o=0;if(e&&(o|=n.COLOR_BUFFER_BIT),t&&(o|=n.DEPTH_BUFFER_BIT),r&&(o|=n.STENCIL_BUFFER_BIT),0!==o){let l;l=i.clearColorValue?i.clearColorValue:this.getClearColor();let u=a.getClearDepth(),d=a.getClearStencil();if(t&&this.state.setDepthMask(!0),null===i.textures)n.clearColor(l.r,l.g,l.b,l.a),n.clear(o);else{if(s&&this._setFramebuffer(i),e)for(let e=0;e<i.textures.length;e++)0===e?n.clearBufferfv(n.COLOR,e,[l.r,l.g,l.b,l.a]):n.clearBufferfv(n.COLOR,e,[0,0,0,1]);t&&r?n.clearBufferfi(n.DEPTH_STENCIL,0,u,d):t?n.clearBufferfv(n.DEPTH,0,[u]):r&&n.clearBufferiv(n.STENCIL,0,[d])}}}beginCompute(e){let{state:t,gl:r}=this;t.bindFramebuffer(r.FRAMEBUFFER,null),this.initTimestampQuery(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(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);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 mF(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)if(r.isUniformsGroup||r.isUniformBuffer){let e=r.buffer,s=t.createBuffer();t.bindBuffer(t.UNIFORM_BUFFER,s),t.bufferData(t.UNIFORM_BUFFER,e,t.DYNAMIC_DRAW),this.set(r,{index:i++,bufferGPU:s})}else if(r.isSampledTexture){let{textureGPU:e,glTextureType:t}=this.get(r.texture);this.set(r,{index:s++,textureGPU:e,glTextureType:t})}}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(mY).filter(t=>mY[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: 4,507 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=df(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;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,0)}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;t.framebufferTextureLayer(t.FRAMEBUFFER,l,a.textureGPU,0,e)}else x?y.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,t.TEXTURE_2D,a.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,l,t.TEXTURE_2D,a.textureGPU,0)}}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;
121r.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)}}_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 m2="triangle-strip",m3="never",m4="less",m6="equal",m5="less-equal",m8="greater",m9="not-equal",m7="greater-equal",fe="always",ft="store",fr="load",fi="clear",fs="uint16",fn="uint32",fa="r8unorm",fo="r8snorm",fl="r8uint",fu="r8sint",fd="r16uint",fh="r16sint",fc="r16float",fp="rg8unorm",fg="rg8snorm",fm="rg8uint",ff="rg8sint",fy="r32uint",fb="r32sint",fx="r32float",fT="rg16uint",f_="rg16sint",fv="rg16float",fN="rgba8unorm",fS="rgba8unorm-srgb",fE="rgba8snorm",fR="rgba8uint",fA="rgba8sint",fw="bgra8unorm",fC="bgra8unorm-srgb",fM="rgb9e5ufloat",fL="rgb10a2unorm",fP="rgb10a2unorm",fB="rg32uint",fF="rg32sint",fI="rg32float",fV="rgba16uint",fD="rgba16sint",fO="rgba16float",fU="rgba32uint",fk="rgba32sint",fG="rgba32float",fz="depth24plus",f$="depth24plus-stencil8",fH="depth32float",fW="depth32float-stencil8",fq="bc1-rgba-unorm",fj="bc1-rgba-unorm-srgb",fX="bc2-rgba-unorm",fK="bc2-rgba-unorm-srgb",fQ="bc3-rgba-unorm",fY="bc3-rgba-unorm-srgb",fZ="etc2-rgb8unorm",fJ="etc2-rgb8unorm-srgb",f0="etc2-rgba8unorm",f1="etc2-rgba8unorm-srgb",f2="astc-4x4-unorm",f3="astc-4x4-unorm-srgb",f4="astc-5x4-unorm",f6="astc-5x4-unorm-srgb",f5="astc-5x5-unorm",f8="astc-5x5-unorm-srgb",f9="astc-6x5-unorm",f7="astc-6x5-unorm-srgb",ye="astc-6x6-unorm",yt="astc-6x6-unorm-srgb",yr="astc-8x5-unorm",yi="astc-8x5-unorm-srgb",ys="astc-8x6-unorm",yn="astc-8x6-unorm-srgb",ya="astc-8x8-unorm",yo="astc-8x8-unorm-srgb",yl="astc-10x5-unorm",yu="astc-10x5-unorm-srgb",yd="astc-10x6-unorm",yh="astc-10x6-unorm-srgb",yc="astc-10x8-unorm",yp="astc-10x8-unorm-srgb",yg="astc-10x10-unorm",ym="astc-10x10-unorm-srgb",yf="astc-12x10-unorm",yy="astc-12x10-unorm-srgb",yb="astc-12x12-unorm",yx="astc-12x12-unorm-srgb",yT="linear",y_="nearest",yv="zero",yN="one-minus-src",yS="src-alpha",yE="one-minus-src-alpha",yR="unfilterable-float",yA="2d-array",yw="cube",yC="vertex",yM="instance",yL={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 yP extends mv{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){this.texture=this.textureNode.value}}class yB extends mm{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let yF=0;
121class yI extends yB{constructor(e,t){super("StorageBuffer_"+yF++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:A.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class yV extends u4{constructor(e){super(),this.device=e;const 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:yT}),this.flipYSampler=e.createSampler({minFilter:y_}),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:m2,stripIndexFormat:fn},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:m2,stripIndexFormat:fn},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:"2d",baseArrayLayer:r}),d=l.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",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:fi,storeOp:ft,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:"2d",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:"2d",baseArrayLayer:r}),d={colorAttachments:[{view:u,loadOp:fi,storeOp:ft,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 yD={[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"},yO=[0,1,3,2,4,5];class yU{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===yT&&s.minFilter===yT&&s.mipmapFilter===yT&&(s.maxAnisotropy=e.anisotropy),e.isDepthTexture&&null!==e.compareFunction&&(s.compare=yD[e.compareFunction]),i.sampler=r.createSampler(s)}createDefaultTexture(e){let t,r=yk(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.");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||yk(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&&(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=yw),i.texture=r.device.createTexture(g),c){let e=Object.assign({},g);e.label=e.label+"-msaa",e.sampleCount=d,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),{textureDescriptorGPU:i}=r;if(!e.isRenderTargetTexture&&void 0!==i){if(e.isDataTexture)this._copyBufferToTexture(t.image,r.texture,i,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let s=0;s<t.image.depth;s++)this._copyBufferToTexture(t.image,r.texture,i,s,e.flipY,s);else e.isCompressedTexture||e.isCompressedArrayTexture?this._copyCompressedBufferToTexture(e.mipmaps,r.texture,i):e.isCubeTexture?this._copyCubeMapToTexture(t.images,r.texture,i,e.flipY,e.premultiplyAlpha):this._copyImageToTexture(t.image,r.texture,i,0,e.flipY,e.premultiplyAlpha);r.version=e.version,e.onUpdate&&e.onUpdate(e)}}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:i*s*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,i,s){for(let n=0;n<6;n++){let a=e[n],o=!0===i?yO[n]:n;a.isDataTexture?this._copyBufferToTexture(a.image,t,r,o,i):this._copyImageToTexture(a,t,r,o,i,s)}}_copyImageToTexture(e,t,r,i,s,n){this.backend.device.queue.copyExternalImageToTexture({source:e,flipY:s},{texture:t,mipLevel:0,origin:{x:0,y:0,z:i},premultipliedAlpha:n},{width:r.size.width,height:r.size.height,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new yV(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){let a=this.backend.device,o=e.data,l=this._getBytesPerTexel(r.format),u=e.width*l;a.queue.writeTexture({texture:t,mipLevel:0,origin:{x:0,y:0,z:i}},o,{offset:e.width*e.height*l*n,bytesPerRow:u},{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===fq||e===fj?{byteLength:8,width:4,height:4}:e===fX||e===fK||e===fQ||e===fY?{byteLength:16,width:4,height:4}:"bc4-r-unorm"===e||"bc4-r-snorm"===e?{byteLength:8,width:4,height:4}:"bc5-rg-unorm"===e||"bc5-rg-snorm"===e||"bc6h-rgb-ufloat"===e||"bc6h-rgb-float"===e||"bc7-rgba-unorm"===e||"bc7-rgba-srgb"===e?{byteLength:16,width:4,height:4}:e===fZ||e===fJ||"etc2-rgb8a1unorm"===e||"etc2-rgb8a1unorm-srgb"===e?{byteLength:8,width:4,height:4}:e===f0||e===f1?{byteLength:16,width:4,height:4}:"eac-r11unorm"===e||"eac-r11snorm"===e?{byteLength:8,width:4,height:4}:"eac-rg11unorm"===e||"eac-rg11snorm"===e||e===f2||e===f3?{byteLength:16,width:4,height:4}:e===f4||e===f6?{byteLength:16,width:5,height:4}:e===f5||e===f8?{byteLength:16,width:5,height:5}:e===f9||e===f7?{byteLength:16,width:6,height:5}:e===ye||e===yt?{byteLength:16,width:6,height:6}:e===yr||e===yi?{byteLength:16,width:8,height:5}:e===ys||e===yn?{byteLength:16,width:8,height:6}:e===ya||e===yo?{byteLength:16,width:8,height:8}:e===yl||e===yu?{byteLength:16,width:10,height:5}:e===yd||e===yh?{byteLength:16,width:10,height:6}:e===yc||e===yp?{byteLength:16,width:10,height:8}:e===yg||e===ym?{byteLength:16,width:10,height:10}:e===yf||e===yy?{byteLength:16,width:12,height:10}:e===yb||e===yx?{byteLength:16,width:12,height:12}:void 0}_convertAddressMode(e){let t="clamp-to-edge";return e===u.GJx?t="repeat":e===u.kTW&&(t="mirror-repeat"),t}_convertFilterMode(e){let t=yT;return(e===u.hxR||e===u.pHI||e===u.Cfg)&&(t=y_),t}_getBytesPerTexel(e){return e===fa||e===fo||e===fl||e===fu?1:e===fd||e===fh||e===fc||e===fp||e===fg||e===fm||e===ff?2:e===fy||e===fb||e===fx||e===fT||e===f_||e===fv||e===fN||e===fS||e===fE||e===fR||e===fA||e===fw||e===fC||e===fM||e===fL||e===fP||e===fH||e===fz||e===f$||e===fW?4:e===fB||e===fF||e===fI||e===fV||e===fD||e===fO?8:e===fU||e===fk||e===fG?16:void 0}_getTypedArrayType(e){return e===fl?Uint8Array:e===fu?Int8Array:e===fa?Uint8Array:e===fo?Int8Array:e===fm?Uint8Array:e===ff?Int8Array:e===fp?Uint8Array:e===fg?Int8Array:e===fR?Uint8Array:e===fA?Int8Array:e===fN?Uint8Array:e===fE?Int8Array:e===fd?Uint16Array:e===fh?Int16Array:e===fT?Uint16Array:e===f_?Int16Array:e===fV?Uint16Array:e===fD?Int16Array:e===fc||e===fv||e===fO?Uint16Array:e===fy?Uint32Array:e===fb?Int32Array:e===fx?Float32Array:e===fB?Uint32Array:e===fF?Int32Array:e===fI?Float32Array:e===fU?Uint32Array:e===fk?Int32Array:e===fG?Float32Array:e===fw||e===fC?Uint8Array:e===fL||e===fM||e===fP?Uint32Array:e===fH?Float32Array:e===fz||e===f$?Uint32Array:e===fW?Float32Array:void 0}_getDimension(e){return e.is3DTexture||e.isData3DTexture?"3d":"2d"}}function yk(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.Nz6:r=a===u.KLL?fj:fq;break;case u.jR7:r=a===u.KLL?fK:fX;break;case u.BXX:r=a===u.KLL?fY:fQ;break;case u.Riy:r=a===u.KLL?fJ:fZ;break;case u.KDk:r=a===u.KLL?f1:f0;break;case u.qa3:r=a===u.KLL?f3:f2;break;case u.B_h:r=a===u.KLL?f6:f4;break;case u.czI:r=a===u.KLL?f8:f5;break;case u.rSH:r=a===u.KLL?f7:f9;break;case u.Qrf:r=a===u.KLL?yt:ye;break;case u.psI:r=a===u.KLL?yi:yr;break;case u.a5J:r=a===u.KLL?yn:ys;break;case u._QJ:r=a===u.KLL?yo:ya;break;case u.uB5:r=a===u.KLL?yu:yl;break;case u.lyL:r=a===u.KLL?yh:yd;break;case u.bC7:r=a===u.KLL?yp:yc;break;case u.y3Z:r=a===u.KLL?ym:yg;break;case u.ojs:r=a===u.KLL?yy:yf;break;case u.S$4:r=a===u.KLL?yx:yb;break;case u.GWd:r=a===u.KLL?fS:fN;break;default:console.error("WebGPURenderer: Unsupported texture format.",i)}else switch(i){case u.GWd:switch(s){case u.tJf:r=fE;break;case u.fBL:r=fD;break;case u.cHt:r=fV;break;case u.bkx:r=fU;break;case u.Yuy:r=fk;break;case u.OUM:r=a===u.KLL?fS:fN;break;case u.ix0:r=fO;break;case u.RQf:r=fG;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case u.HIg:s===u.Dmk?r=fM:console.error("WebGPURenderer: Unsupported texture type with RGBFormat.",s);break;case u.VT0:switch(s){case u.tJf:r=fo;break;case u.fBL:r=fh;break;case u.cHt:r=fd;break;case u.bkx:r=fy;break;case u.Yuy:r=fb;break;case u.OUM:r=fa;break;
178case u.ix0:r=fc;break;case u.RQf:r=fx;break;default:console.error("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case u.paN:switch(s){case u.tJf:r=fg;break;case u.fBL:r=f_;break;case u.cHt:r=fT;break;case u.bkx:r=fB;break;case u.Yuy:r=fF;break;case u.OUM:r=fp;break;case u.ix0:r=fv;break;case u.RQf:r=fI;break;default:console.error("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case u.zdS:switch(s){case u.cHt:r="depth16unorm";break;case u.bkx:r=fz;break;case u.RQf:r=fH;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case u.dcC:switch(s){case u.V3x:r=f$;break;case u.RQf:t&&!1===t.features.has(yL.Depth32FloatStencil8)&&console.error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),r=fW;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case u.ZQM:switch(s){case u.Yuy:r=fb;break;case u.bkx:r=fy;break;default:console.error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case u.TkQ:switch(s){case u.Yuy:r=fF;break;case u.bkx:r=fB;break;default:console.error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case u.c90:switch(s){case u.Yuy:r=fk;break;case u.bkx:r=fU;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:console.error("WebGPURenderer: Unsupported texture format.",i)}return r}let yG=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,yz=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,y$={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>":"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 yH extends gG{constructor(e){const{type:t,inputs:r,name:i,inputsCode:s,blockCode:n,outputType:a}=(e=>{let t=(e=e.trim()).match(yG);if(null!==t&&4===t.length){let r=t[2],i=[],s=null;for(;null!==(s=yz.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=y$[s]),n.push(new gA(s,t))}let a=e.substring(t[0].length),o=t[3]||"void",l=void 0!==t[1]?t[1]:"";
178return{type:y$[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 yW extends gk{parseFunction(e){return new yH(e)}}let yq="u">typeof self?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},yj={[A.READ_ONLY]:"read",[A.WRITE_ONLY]:"write",[A.READ_WRITE]:"read_write"},yX={[u.GJx]:"repeat",[u.ghU]:"clamp",[u.kTW]:"mirror"},yK={vertex:yq?yq.VERTEX:1,fragment:yq?yq.FRAGMENT:2,compute:yq?yq.COMPUTE:4},yQ={instance:!0,swizzleAssign:!1,storageBuffer:!0},yY={"^^":"tsl_xor"},yZ={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>"},yJ={},y0={tsl_xor:new h8("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new h8("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new h8("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new h8("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new h8("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new h8("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new h8("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new h8("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 h8("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 h8("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new h8("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 h8("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new h8(`
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`)},y1={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>"};"u">typeof navigator&&/Windows/g.test(navigator.userAgent)&&(y0.pow_float=new h8("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),y0.pow_vec2=new h8("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[y0.pow_float]),y0.pow_vec3=new h8("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[y0.pow_float]),y0.pow_vec4=new h8("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[y0.pow_float]),y1.pow_float="tsl_pow_float",y1.pow_vec2="tsl_pow_vec2",y1.pow_vec3="tsl_pow_vec3",y1.pow_vec4="tsl_pow_vec4");let y2="";!0!==("u">typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(y2+="diagnostic( off, derivative_uniformity );\n");class y3 extends gE{constructor(e,t){super(e,t,new yW),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,r,i,s=this.shaderStage){return"fragment"!==s?this.generateTextureSampleLevel(e,t,r,"0",i):i?`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`}generateTextureSampleLevel(e,t,r,i,s){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,i
200):this.generateTextureLod(e,t,r,s,i)}generateWrapFunction(e){let t=`tsl_coord_${yX[e.wrapS]}S_${yX[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`,r=yJ[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(y0.repeatWrapping_float),n+=`		tsl_repeatWrapping_float( coord.${t} )`):e===u.ghU?(i.push(y0.clampWrapping_float),n+=`		tsl_clampWrapping_float( coord.${t} )`):e===u.kTW?(i.push(y0.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",yJ[t]=r=new h8(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 iu(new iK(`textureDimensions( ${n} )`,a)),i.dimensionsSnippet[r]=s,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(i.arrayLayerCount=new iu(new iK(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(i.cubeFaceCount=new iu(new iK("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,r,i="0u"){this._include("biquadraticTexture");let s=this.generateWrapFunction(e),n=this.generateTextureDimension(e,t,i);return`tsl_biquadraticTexture( ${t}, ${s}( ${r} ), ${n}, u32( ${i} ) )`}generateTextureLod(e,t,r,i,s="0u"){let n=this.generateWrapFunction(e),a=this.generateTextureDimension(e,t,s),o=e.isData3DTexture?"vec3":"vec2",l=`${o}<u32>( ${n}( ${r} ) * ${o}<f32>( ${a} ) )`;return this.generateTextureLoad(e,t,l,i,s)}generateTextureLoad(e,t,r,i,s="0u"){let n;return i?n=`textureLoad( ${t}, ${r}, ${i}, u32( ${s} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(n+=".x")),n}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=this.shaderStage){return this.isUnfilterable(e)?this.generateTextureLod(e,t,r,i,"0",s):this._generateTextureSample(e,t,r,i,s)}generateTextureGrad(e,t,r,i,s,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${r},  ${i[0]}, ${i[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,i,s,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,r,i,s){return!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,i):this.generateTextureLod(e,t,r,s,i)}generateTextureBias(e,t,r,i,s,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} 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
203stomStruct(e)?t:t+".value"}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){let t=yY[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."),A.READ_WRITE):A.READ_ONLY:e.access}getStorageAccess(e,t){return yj[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 mA(s.name,s.node,o,n):new mE(s.name,s.node,o,n):"cubeTexture"===t?i=new mR(s.name,s.node,o,n):"texture3D"===t&&(i=new mA(s.name,s.node,o,n)),i.store=!0===e.isStorageTextureNode,i.setVisibility(yK[r]),!1===this.isUnfilterable(e.value)&&!1===i.store){let e=new yP(`${s.name}_sampler`,s.node,o);e.setVisibility(yK[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?mb:yI)(e,o);n.setVisibility(yK[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 m_(l,o)).setVisibility(yK[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=yk(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}getType(e){return yZ[e]||e}isAvailable(e){let t=yQ[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),yQ[e]=t),t}_getWGSLMethod(e){return void 0!==y0[e]&&this._include(e),y1[e]}_include(e){let t=y0[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${y2}
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 y4{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=f$:e.depth&&(t=fz),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?"point-list":e.isLineSegments||e.isMesh&&!0===t.wireframe?"line-list":e.isLine?"line-strip":e.isMesh?"triangle-list":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;if(e===u.ix0)return fO;throw Error("Unsupported outputType")}}let y6=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);"u">typeof Float16Array&&y6.set(Float16Array,["float16"]);let y5=new Map([[u.Oax,["float16"]]]),y8=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class y9{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?yM:yC):(e=i.itemSize*s,t=i.isInstancedBufferAttribute?yM:yC),!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=y8.get(s);else{let e=(y5.get(n)||y6.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 y7{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===A.READ_WRITE||r.access===A.WRITE_ONLY)?t.type="storage":t.type="read-only-storage"),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===A.READ_WRITE?t.access="read-write":i===A.WRITE_ONLY?t.access="write-only":t.access="read-only",r.texture.isArrayTexture?t.viewDimension=yA:r.texture.is3DTexture&&(t.viewDimension="3d"),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=yR)),r.texture.isDepthTexture)t.compatibilityMode&&null===r.texture.compareFunction?i.sampleType=yR:i.sampleType="depth";else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){let e=r.texture.type;e===u.Yuy?i.sampleType="sint":e===u.bkx?i.sampleType="uint":e===u.RQf&&(this.backend.hasFeature("float32-filterable")?i.sampleType="float":i.sampleType=yR)}
305r.isSampledCubeTexture?i.viewDimension=yw:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?i.viewDimension=yA:r.isSampledTexture3D&&(i.viewDimension="3d"),e.texture=i}else if(r.isSampler){let i={};r.texture.isDepthTexture&&(null!==r.texture.compareFunction?i.type="comparison":t.compatibilityMode&&(i.type="non-filtering")),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}}];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;s=t.isSampledCubeTexture?yw:t.isSampledTexture3D?"3d":t.texture.isArrayTexture||t.texture.isDataArrayTexture||t.texture.isCompressedArrayTexture?yA:"2d",e=a[i]=a.texture.createView({aspect:"all",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 be{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),E={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})},R={},A=e.context.depth,w=e.context.stencil;if((!0===A||!0===w)&&(!0===A&&(R.format=N,R.depthWriteEnabled=s.depthWrite,R.depthCompare=v),!0===w&&(R.stencilFront=f,R.stencilBack={},R.stencilReadMask=s.stencilFuncMask,R.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&(R.depthBias=s.polygonOffsetUnits,R.depthBiasSlopeScale=s.polygonOffsetFactor,R.depthBiasClamp=0),E.depthStencil=R),null===t)p.pipeline=h.createRenderPipeline(E);else{let e=new Promise(e=>{h.createRenderPipelineAsync(E).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._getSampleC
305ount(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:"add"},r={srcFactor:s,dstFactor:n,operation:"add"}};if(s)switch(i){case u.NTi:n("one",yE,"one",yE);break;case u.EZo:n("one","one","one","one");break;case u.Kwu:n(yv,yN,yv,"one");break;case u.EdD:n("dst",yE,yv,"one")}else switch(i){case u.NTi:n(yS,yE,"one",yE);break;case u.EZo:n(yS,"one","one","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;switch(e){case u.ojh:t=yv;break;case u.qad:t="one";break;case u.f4X:t="src";break;case u.LiQ:t=yN;break;case u.ie2:t=yS;break;case u.OuU:t=yE;break;case u.wn6:t="dst";break;case u.aEY:t="one-minus-dst";break;case u.hdd:t="dst-alpha";break;case u.Nt7:t="one-minus-dst-alpha";break;case u.hgQ:t="src-alpha-saturated";break;case 211:t="constant";break;case 212:t="one-minus-constant";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=m3;break;case u.sKt:t=fe;break;case u.kYr:t=m4;break;case u.CR7:t=m5;break;case u.jsO:t=m6;break;case u.TMh:t=m7;break;case u.RcT:t=m8;break;case u.klZ:t=m9;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case u.VVr:t="keep";break;case u.kqe:t="zero";break;case u.kG0:t="replace";break;case u.oVO:t="invert";break;case u.HLH:t="increment-clamp";break;case u.ROr:t="decrement-clamp";break;case u.Ru$:t="increment-wrap";break;case u.fJr:t="decrement-wrap";break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case u.gO9:t="add";break;case u.FXf:t="subtract";break;case u.nST:t="reverse-subtract";break;case u.znC:t="min";break;case u.$ei:t="max";break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){let i={};switch(i.topology=this.backend.utils.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?fs:fn),r.side){case u.hB5:i.frontFace="ccw",i.cullMode="back";break;case u.hsX:i.frontFace="ccw",i.cullMode="front";break;case u.$EB:i.frontFace="ccw",i.cullMode="none";break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",r.side)}return i}_getColorWriteMask(e){return 15*(!0===e.colorWrite)}_getDepthCompare(e){let t;if(!1===e.depthTest)t=fe;else{let r=e.depthFunc;switch(r){case u.eHc:t=m3;break;case u.lGu:t=fe;break;case u.brA:t=m4;break;case u.xSv:t=m5;break;case u.U3G:t=m6;break;case u.Gwm:t=m7;break;case u.K52:t=m8;break;case u.bw0:t=m9;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class bt extends mJ{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}`});const 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.id,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 br extends mD{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 y4(this),this.attributeUtils=new y9(this),this.bindingUtils=new y7(this),this.pipelineUtils=new be(this),this.textureUtils=new yU(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="u">typeof navigator?await navigator.gpu.requestAdapter(e):null;if(null===i)throw Error("WebGPUBackend: Unable to create WebGPU adapter.");let s=Object.values(yL),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";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(yL.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasF
305ormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s}),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;if(void 0===s||i.width!==r.width||i.height!==r.height||i.dimensions!==r.dimensions||i.activeMipmapLevel!==e.activeMipmapLevel||i.activeCubeFace!==e.activeCubeFace||i.samples!==r.samples){i.descriptors=s={};let e=()=>{r.removeEventListener("dispose",e),this.delete(r)};!1===r.hasEventListener("dispose",e)&&r.addEventListener("dispose",e)}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:"2d"};if(r.isRenderTarget3D)t=e.activeCubeFace,n.baseArrayLayer=0,n.dimension="3d",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:"2d"},r=s.texture.createView(t);l.push({view:r,resolveTarget:void 0,depthSlice:void 0})}}else n.dimension=yA,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="2d",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,i.dimensions=r.dimensions}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||fr,storeOp:t.storeOp||ft,clearValue:i})}return a.depthStencilView&&(o.depthStencilAttachment={view:a.depthStencilView}),o}beginRender(e){let t,r,i=this.get(e),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:fr}),this.initTimestampQuery(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=fi):i.loadOp=fr,i.storeOp=ft}}else{let t=r.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=fi):t.loadOp=fr,t.storeOp=ft}e.depth&&(e.clearDepth?(a.depthClearValue=e.clearDepthValue,a.depthLoadOp=fi):a.depthLoadOp=fr,a.depthStoreOp=ft),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=fi):a.stencilLoadOp=fr,a.stencilStoreOp=ft);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:"2d",baseArrayLayer:a,arrayLayerCount:1})),i.depthStencilAttachment={view:n.viewCache[t],depthLoadOp:s.depthLoadOp||fi,depthStoreOp:s.depthStoreOp||ft,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=fi):t.depthLoadOp=fr),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=fi):t.stencilLoadOp=fr)}}}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=fi,e.storeOp=ft}(a||o)&&(s=t.depthStencilAttachment)}else{a=i.depth,o=i.stencil;let l={loadOp:e?fi:fr,clearValue:e?n:void 0};a&&(l.depthLoadOp=t?fi:fr,l.depthClearValue=t?u.getClearDepth():void 0,l.depthStoreOp=ft),o&&(l.stencilLoadOp=r?fi:fr,l.stencilClearValue=r?u.getClearStencil():void 0,l.stencilStoreOp=ft);let h=this._getRenderPassDescriptor(i,l);d=h.colorAttachments,s=h.depthStencilAttachment}a&&s&&(t?(s.depthLoadOp=fi,s.depthClearValue=u.getClearDepth()):s.depthLoadOp=fr,s.depthStoreOp=ft),o&&s&&(r?(s.stencilLoadOp=fi,s.stencilClearValue=u.getClearStencil()):s.stencilLoadOp=fr,s.stencilStoreOp=ft);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),r={label:"computeGroup_"+e.id};this.initTimestampQuery(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?fs:fn;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;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,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){if(!this.trackTimestamp)return;let r=e.isComputeNode?"compute":"render";this.timestampQueryPool[r]||(this.timestampQueryPool[r]=new bt(this.device,r,2048));let i=this.timestampQueryPool[r],s=i.allocateQueriesForContext(e);t.timestampWrites={querySet:i.querySet,beginningOfPassWriteIndex:s,endOfPassWriteIndex:s+1}}createNodeBuilder(e,t){return new y3(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=fr;if(t.depth&&(e.depthStencilAttachment.depthLoadOp=fr),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=fr),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 bi 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 bs 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 bn extends g2{constructor(){super(),this.addMaterial(li,"MeshPhongMaterial"),this.addMaterial(uB,"MeshStandardMaterial"),this.addMaterial(uI,"MeshPhysicalMaterial"),this.addMaterial(uU,"MeshToonMaterial"),this.addMaterial(o4,"MeshBasicMaterial"),this.addMaterial(lt,"MeshLambertMaterial"),this.addMaterial(oW,"MeshNormalMaterial"),this.addMaterial(uz,"MeshMatcapMaterial"),this.addMaterial(oD,"LineBasicMaterial"),this.addMaterial(oU,"LineDashedMaterial"),this.addMaterial(uX,"PointsMaterial"),this.addMaterial(uq,"SpriteMaterial"),this.addMaterial(uY,"ShadowMaterial"),this.addLight(pl,u.HiM),this.addLight(gw,u.ZyN),this.addLight(gP,u.ure),this.addLight(gB,u.nCl),this.addLight(gD,u.$p8),this.addLight(gO,u.dth),this.addLight(gU,u.FZo),this.addLight(gF,bi),this.addLight(gV,bs),this.addToneMapping(hY,u.kyO),this.addToneMapping(hZ,u.Mjd),this.addToneMapping(hJ,u.nNL),this.addToneMapping(h1,u.FV),this.addToneMapping(h6,u.LAk),this.addToneMapping(h5,u.aJ8)}}class ba extends mp{constructor(e={}){let t;e.forceWebGL?t=m1:(t=br,e.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new m1(e))),super(new t(e),e),this.library=new bn,this.isWebGPURenderer=!0,"u">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.