PageSourceSearch

https://silversurfers.ai/_next/static/chunks/d98c7304.bc59867906746e88.js

js silversurfers.ai collected 2026-10-05 15:50:54 UTC 641,012 bytes, 485 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3787],{6033:(e,t,r)=>{let i,s,a,n,o,l;r.d(t,{Z$U:()=>cV,uV1:()=>Ta,uuE:()=>gJ});var u=r(8217);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","envMapRotation","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,c=new WeakMap,p=new WeakMap;class m{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,object:i}=e;if(t={geometryId:r.id,worldMatrix:i.matrixWorld.clone()},i.center&&(t.center=i.center.clone()),i.morphTargetInfluences&&(t.morphTargetInfluences=i.morphTargetInfluences.slice()),null!==e.bundle&&(t.version=e.bundle.version),e.material.transmission>0){let{width:r,height:i}=e.context;t.bufferWidth=r,t.bufferHeight=i}let{environmentIntensity:s,environmentRotation:a}=e.scene;t.environmentIntensity=s,t.environmentRotation=a.clone(),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]={id:i.isInterleavedBufferAttribute?i.data.uuid:i.id,version:i.isInterleavedBufferAttribute?i.data.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!!e.context.modelViewMatrix||!!e.context.modelNormalViewMatrix||!!e.context.getAO||!!e.context.getShadow}getGeometryData(e){let t=p.get(e);return void 0===t&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},p.set(e,t)),t}getMaterialData(e){let t=c.get(e);if(void 0===t){for(let r of(t={_renderId:-1,_equal:!1},this.refreshUniforms)){let i=e[r];null!=i&&("object"==typeof i&&void 0!==i.clone?!0===i.isTexture?t[r]={id:i.id,version:0}:t[r]=i.clone():t[r]=i)}c.set(e,t)}return t}equals(e,t,r){let{object:i,material:s,geometry:a}=e,n=this.getRenderObjectData(e);if(!0!==n.worldMatrix.equals(i.matrixWorld))return n.worldMatrix.copy(i.matrixWorld),!1;let o=this.getMaterialData(e.material);if(o._renderId!==r){for(let e in o._renderId=r,o){let t=o[e],r=s[e];if("_renderId"!==e&&"_equal"!==e){if(void 0!==t.equals){if(!1===t.equals(r))return t.copy(r),o._equal=!1,!1}else if(!0===r.isTexture){if(t.id!==r.id||t.version!==r.version)return t.id=r.id,t.version=r.version,o._equal=!1,!1}else if(t!==r)return o[e]=r,o._equal=!1,!1}}if(o.transmission>0){let{width:t,height:r}=e.context;if(n.bufferWidth!==t||n.bufferHeight!==r)return n.bufferWidth=t,n.bufferHeight=r,o._equal=!1,!1}o._equal=!0}else if(!1===o._equal)return!1;if(n.geometryId!==a.id)return n.geometryId=a.id,!1;let l=this.getGeometryData(e.geometry);if(l._renderId!==r){l._renderId=r;let e=a.attributes,t=l.attributes,i=0,s=0;for(let t in e)i++;for(let r in t){s++;let i=t[r],a=e[r];if(void 0===a)return delete t[r],l._equal=!1,!1;let n=a.isInterleavedBufferAttribute?a.data.uuid:a.id,o=a.isInterleavedBufferAttribute?a.data.version:a.version;if(i.id!==n||i.version!==o)return i.id=n,i.version=o,l._equal=!1,!1}if(s!==i)return l.attributes=this.getAttributesData(e),l._equal=!1,!1;
1let n=a.index,o=l.indexId,u=l.indexVersion,d=n?n.id:null,h=n?n.version:null;if(o!==d||u!==h)return l.indexId=d,l.indexVersion=h,l._equal=!1,!1;if(l.drawRange.start!==a.drawRange.start||l.drawRange.count!==a.drawRange.count)return l.drawRange.start=a.drawRange.start,l.drawRange.count=a.drawRange.count,l._equal=!1,!1;l._equal=!0}else if(!1===l._equal)return!1;if(n.morphTargetInfluences){let e=!1;for(let t=0;t<n.morphTargetInfluences.length;t++)n.morphTargetInfluences[t]!==i.morphTargetInfluences[t]&&(n.morphTargetInfluences[t]=i.morphTargetInfluences[t],e=!0);if(e)return!1}if(n.lights){for(let e=0;e<t.length;e++)if(n.lights[e].map!==t[e].map)return!1}let u=e.scene;return null!==u.environment&&null===s.envMap&&(n.environmentIntensity!==u.environmentIntensity||!1===n.environmentRotation.equals(u.environmentRotation))?(n.environmentIntensity=u.environmentIntensity,n.environmentRotation.copy(u.environmentRotation),!1):n.center&&!1===n.center.equals(i.center)?(n.center.copy(i.center),!1):(null!==e.bundle&&(n.version=e.bundle.version),!0)}getLightsData(e,t){for(let r of(t.length=0,e))!0===r.isSpotLight&&null!==r.map&&t.push({map:r.map.version});return t}getLights(e,t){let r=h.get(e);return void 0===r&&(r={renderId:-1,lightsData:[]},h.set(e,r)),r.renderId===t||(r.renderId=t,this.getLightsData(e.getLights(),r.lightsData)),r.lightsData}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 a=this.getLights(e.lightsNode,r);return!0!==this.equals(e,a,r)}}let g=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];class f{constructor(e=null){this.isStackTrace=!0,this.stack=function(e){let t=/(?:at\s+(.+?)\s+\()?(?:(.+?)@)?([^@\s()]+):(\d+):(\d+)/;return e.split("\n").map(e=>{let r=e.match(t);if(!r)return null;let i=r[1]||r[2]||"",s=r[3].split("?")[0],a=parseInt(r[4],10),n=parseInt(r[5],10);return{fn:i,file:s.split("/").pop(),line:a,column:n}}).filter(e=>e&&!g.some(t=>t.test(e.file)))}(e||Error().stack)}getLocation(){if(0===this.stack.length)return"[Unknown location]";let e=this.stack[0],t=e.fn,r=t?`"${t}()" at `:"";return`${r}"${e.file}:${e.line}"`}getError(e){if(0===this.stack.length)return e;let t=this.stack.map(e=>{let t=`${e.file}:${e.line}:${e.column}`;return e.fn?`    at ${e.fn} (${t})`:`    at ${t}`}).join("\n");return`${e}
2${t}`}}function b(e,t=0){let r=0xdeadbeef^t,i=0x41c6ce57^t;if(Array.isArray(e))for(let t=0,s;t<e.length;t++)r=Math.imul(r^(s=e[t]),0x9e3779b1),i=Math.imul(i^s,0x5f356495);else for(let t=0,s;t<e.length;t++)r=Math.imul(r^(s=e.charCodeAt(t)),0x9e3779b1),i=Math.imul(i^s,0x5f356495);return r=Math.imul(r^r>>>16,0x85ebca6b)^Math.imul(i^i>>>13,0xc2b2ae35),0x100000000*(2097151&(i=Math.imul(i^i>>>16,0x85ebca6b)^Math.imul(r^r>>>13,0xc2b2ae35)))+(r>>>0)}let y=e=>b(e),x=e=>b(e),T=(...e)=>b(e),_=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),v=new WeakMap;function S(e){if(/[iu]?vec\d/.test(e))return e.startsWith("ivec")?Int32Array:e.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(e)||/float/.test(e))return Float32Array;if(/uint/.test(e))return Uint32Array;if(/int/.test(e))return Int32Array;throw Error(`THREE.NodeUtils: Unsupported type: ${e}`)}function N(e){return/float|int|uint|bool/.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(0,u.z3S)(`TSL: Unsupported type: ${e}`,new f)}function R(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 A(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){var i;return i=t[0],Uint8Array.from(atob(i),e=>e.charCodeAt(0)).buffer}return null}function E(e){let t=v.get(e);return void 0===t&&(t={},v.set(e,t)),t}let C={VERTEX:"vertex",FRAGMENT:"fragment"},w={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},M={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},B=["fragment","vertex"],U=["setup","analyze","generate"],F=[...B,"compute"],L=["x","y","z","w"],P={analyze:"setup",generate:"analyze"},D=0;class O extends u.Qev{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=w.NONE,this.updateBeforeType=w.NONE,this.updateAfterType=w.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=D++,this.stackTrace=null,!0===O.captureStackTrace&&(this.stackTrace=new f)}set needsUpdate(e){!0===e&&this.version++}get uuid(){return null===this._uuid&&(this._uuid=u.cj9.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,w.FRAME)}
2onRenderUpdate(e){return this.onUpdate(e,w.RENDER)}onObjectUpdate(e){return this.onUpdate(e,w.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(let{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){for(let t of(e(this),this.getChildren()))t.traverse(e)}_getChildren(e=new Set){let t=[];for(let r of(e.add(this),Object.getOwnPropertyNames(this))){let i=this[r];if(!(!0===r.startsWith("_")||e.has(i))){if(!0===Array.isArray(i))for(let e=0;e<i.length;e++){let s=i[e];s&&!0===s.isNode&&t.push({property:r,index:e,childNode:s})}else if(i&&!0===i.isNode)t.push({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.push({property:r,index:e,childNode:s})}}}return t}getCacheKey(e=!1,t=null){if(!0===(e=e||this.version!==this._cacheKeyVersion)||null===this._cacheKey){null===t&&(t=new Set);let r=[];for(let{property:i,childNode:s}of this._getChildren(t))r.push(y(i.slice(0,-4)),s.getCacheKey(e,t));this._cacheKey=T(x(r),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}getHash(){return String(this.id)}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,t=null){let r,i=e.getDataFromNode(this);return null!==t?(i.typeFromOutput=i.typeFromOutput||{},void 0===(r=i.typeFromOutput[t])&&(r=this.generateNodeType(e,t),i.typeFromOutput[t]=r)):void 0===(r=i.type)&&(i.type=r=this.generateNodeType(e)),r}generateNodeType(e,t=null){let r=e.getNodeProperties(this);return r.outputNode?r.outputNode.getNodeType(e,t):this.nodeType}getShared(e){let t=this.getHash(e),r=e.getNodeFromHash(t),i=null;if(r&&r!==this)i=r;else if(e.context.overrideNodes){let t=e.context.overrideNodes.get(this);if(t){let r=e.getDataFromNode(this);!0!==r.isOverwritten?(r.isOverwritten=!0,r.sharedNode=i=t(e).overrideNode(this,null)):i=r.sharedNode}}return i||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(){(0,u.R8M)("Abstract function.")}updateAfter(){(0,u.R8M)("Abstract function.")}update(){(0,u.R8M)("Abstract function.")}before(e){return null===this._beforeNodes&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){let r=this.getShared(e);if(this!==r)return r.build(e,t);if(null!==this._beforeNodes){let r=this._beforeNodes;for(let i of(this._beforeNodes=null,r))i.build(e,t);this._beforeNodes=r}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();e.setBuildStage(s),this.build(e),e.setBuildStage(t)}e.addChain(this);let a=null,n=e.getBuildStage();if("setup"===n){e.addNode(this),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)}e.addSequentialNode(this)}a=t.outputNode}else if("analyze"===n)this.analyze(e,t);else if("generate"===n){if(this.generate.length<2){let r=this.getNodeType(e),i=e.getDataFromNode(this);void 0===(a=i.snippet)?void 0===i.generated?(i.generated=!0,i.snippet=a=this.generate(e)||""):((0,u.R8M)("Node: Recursion detected.",this),a="/* Recursion detected. */"):void 0!==i.flowCodes&&void 0!==e.context.nodeBlock&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,r,t)}else a=this.generate(e,t)||"";""===a&&null!==t&&"void"!==t&&"OutputType"!==t&&((0,u.z3S)(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){let t=this.getSerializeChildren(),r={};for(let{property:i,index:s,childNode:a}of t)void 0!==s?(void 0===r[i]&&(r[i]=Number.isInteger(s)?[]:{}),r[i][s]=a.toJSON(e.meta).uuid):r[i]=a.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 a=e.inputNodes[r][s];i[s]=t[a]}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 a(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=a(e.textures),r=a(e.images),i=a(e.nodes);t.length>0&&(s.textures=t),r.length>0&&(s.images=r),i.length>0&&(s.nodes=i)}return s}}O.captureStackTrace=!1;class I extends O{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}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 O{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){let t=this.node.getNodeType(e),r=null;for(let i of this.convertTo.split("|"))(null===r||e.getTypeLength(t)===e.getTypeLength(i))&&(r=i);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){let r=this.node,i=this.getNodeType(e),s=r.build(e,i);return e.format(s,i,t)}}class G extends O{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),a=e.getVarFromNode(this,null,r),n=e.getPropertyName(a);return e.addLineFlowCode(`${n} = ${s}`,this),i.snippet=s,i.propertyName=n,e.format(i.propertyName,r,t)}}return super.build(e,t)}}class k extends G{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(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,a=e.getComponentType(r),n=[],o=0;for(let t of s){let s;if(o>=i){(0,u.z3S)(`TSL: Length of parameters exceeds maximum length of function '${r}()' type.`,this.stackTrace);break}let l=t.getNodeType(e),d=e.getTypeLength(l);if(o+d>i&&((0,u.z3S)(`TSL: Length of '${r}()' data exceeds maximum length of output type.`,this.stackTrace),d=i-o,l=e.getTypeFromLength(d)),o+=d,s=t.build(e,l),e.getComponentType(l)!==a){let t=e.getTypeFromLength(d,a);s=e.format(s,l,t)}n.push(s)}let l=`${e.getType(r)}( ${n.join(", ")} )`;return e.format(l,r,t)}}let z=L.join("");class $ extends O{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))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){let r=this.node,i=e.getTypeLength(r.getNodeType(e)),s=null;if(i>1){let a=null;this.getVectorLength()>=i&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let n=r.build(e,a);s=this.components.length===i&&this.components===z.slice(0,this.components.length)?e.format(n,a,t):e.format(`${n}.${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 W extends G{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{sourceNode:t,components:r,targetNode:i}=this,s=this.getNodeType(e),a=e.getComponentType(i.getNodeType(e)),n=e.getTypeFromLength(r.length,a),o=i.build(e,n),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 H extends G{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}generateNodeType(e){return this.sourceNode.getNodeType(e)}
2generate(e){let{components:t,sourceNode:r}=this,i=this.getNodeType(e),s=r.build(e),a=e.getVarFromNode(this),n=e.getPropertyName(a);e.addLineFlowCode(n+" = "+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 - "+n+"."+r),u++):l.push(n+"."+r)}return`${e.getType(i)}( ${l.join(", ")} )`}}class q extends O{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}generateNodeType(){return null===this.nodeType?R(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=R(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=function(e){let t="",r=new Uint8Array(e);for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return btoa(t)}(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?A(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){(0,u.R8M)("Abstract function.")}}let j=/float|u?int/;class X extends q{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){let r=this.getNodeType(e);return j.test(r)&&j.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class Q extends O{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return(!this.structNode.isMemberNode||!1!==this.structNode.hasMember(e))&&"void"!==this.structNode.getMemberType(e,this.property)}generateNodeType(e){return!1===this.hasMember(e)?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(!1===this.hasMember(e))return"float";let r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}generate(e){if(!1===this.hasMember(e)){(0,u.R8M)(`TSL: Member "${this.property}" does not exist in struct.`,this.stackTrace);let t=this.getNodeType(e);return e.generateConst(t)}return this.structNode.build(e)+"."+this.property}}let K=null,Y=new Map;function Z(e,t){if(Y.has(e))return void(0,u.R8M)(`TSL: Redefinition of method chaining '${e}'.`);if("function"!=typeof t)throw Error(`THREE.TSL: Node element ${e} is not a function`);Y.set(e,t),"assign"!==e&&(O.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},O.prototype[e+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}let J=e=>e.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w").split("").sort().join("");O.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==K?K.assign(this,...e):(0,u.z3S)("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new f),this;{let t=Y.get("assign");return this.addToStack(t(...e))}},O.prototype.toVarIntent=function(){return this},O.prototype.get=function(e){return new Q(this,e)};let ee={};function et(e,t,r){ee[e]=ee[t]=ee[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new $(this,e),this._cache[e]=t),t},set(t){this[e].assign(eR(t))}};let i=e.toUpperCase(),s=t.toUpperCase(),a=r.toUpperCase();O.prototype["set"+i]=O.prototype["set"+s]=O.prototype["set"+a]=function(t){return new W(this,J(e),eR(t))},O.prototype["flip"+i]=O.prototype["flip"+s]=O.prototype["flip"+a]=function(){return new H(this,J(e))}}let er=["x","y","z","w"],ei=["r","g","b","a"],es=["s","t","p","q"];for(let e=0;e<4;e++){let t=er[e],r=ei[e],i=es[e];et(t,r,i);for(let s=0;s<4;s++){t=er[e]+er[s],et(t,r=ei[e]+ei[s],i=es[e]+es[s]);for(let a=0;a<4;a++){t=er[e]+er[s]+er[a],et(t,r=ei[e]+ei[s]+ei[a],i=es[e]+es[s]+es[a]);for(let n=0;n<4;n++)t=er[e]+er[s]+er[a]+er[n],et(t,r=ei[e]+ei[s]+ei[a]+ei[n],i=es[e]+es[s]+es[a]+es[n])}}}for(let e=0;e<32;e++)ee[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new I(this,new X(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(eR(t))}};Object.defineProperties(O.prototype,ee);let ea=function(e,t=null){let r=R(e);if("node"===r);else if(null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r)return eR(eT(e,t));else if("shader"===r)return e.isFn?e:eP(e);return e},en=function(e,t=null){for(let r in e)e[r]=eR(e[r],t);return e},eo=function(e,t=null){let r=e.length;for(let i=0;i<r;i++)e[i]=eR(e[i],t);return e},el=function(e,t=null,r=null,i=null){function s(e){return null!==i?(e=eR(Object.assign(e,i)),!0===i.intent&&(e=e.toVarIntent
2())):e=eR(e),e}let a,n=t,o,l;function d(t){let r;return(r=n?/[a-z]/i.test(n)?n+"()":n:e.type,void 0!==o&&t.length<o)?((0,u.z3S)(`TSL: "${r}" parameter length is less than minimum required.`,new f),t.concat(Array(o-t.length).fill(0))):void 0!==l&&t.length>l?((0,u.z3S)(`TSL: "${r}" parameter length exceeds limit.`,new f),t.slice(0,l)):t}return null===t?a=(...t)=>s(new e(...eC(d(t)))):null!==r?(r=eR(r),a=(...i)=>s(new e(t,...eC(d(i)),r))):a=(...r)=>s(new e(t,...eC(d(r)))),a.setParameterLength=(...e)=>(1===e.length?o=l=e[0]:2===e.length&&([o,l]=e),a),a.setName=e=>(n=e,a),a},eu=function(e,...t){return new e(...eC(t))};class ed extends O{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){var t,r;let{shaderNode:i,rawInputs:s}=this,a=e.getNodeProperties(i),n=e.getClosestSubBuild(i.subBuilds)||"",o=n||"default";if(a[o])return a[o];let l=e.subBuildFn,u=e.fnCall;e.subBuildFn=n,e.fnCall=this;let d=null;if(i.layout){if(s){let t=i.layout.inputs;if(eh(s))for(let r=0;r<t.length;r++){let t=s[r];t&&t.isNode&&t.build(e)}else{let r=s[0];for(let i of t){let t=r[i.name];t&&t.isNode&&t.build(e)}}}let r=e.buildFunctionNode(i);e.addInclude(r);let a=s?(eE(t=s),eh(t)?[...t]:t[0]):null;d=r.call(a)}else{let t,a=new Proxy(e,{get:(e,t,r)=>Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r)}),n=s?(t=0,eE(r=s),new Proxy(r,{get:(e,i,s)=>{let a;if("length"===i)return r.length;if(Symbol.iterator===i)a=function*(){for(let e of r)yield eR(e)};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){let e=r[0];a=void 0===e[i]?e[t++]:Reflect.get(e,i,s)}else r[0]instanceof O&&(a=void 0===r[i]?r[t++]:Reflect.get(r,i,s));else a=Reflect.get(e,i,s);a=eR(a)}return a}})):null,o=Array.isArray(s)?s.length>0:null!==s,l=i.jsFunc;d=eR(o||l.length>1?l(n,a):l(a))}return e.subBuildFn=l,e.fnCall=u,i.once&&(a[o]=d),d}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),a=e.getSubBuildOutput(this),n=this.getOutputNode(e),o=e.fnCall;if(e.fnCall=this,"setup"===i){let t=e.getSubBuildProperty("initialized",this);if(!0!==s[t]&&(s[t]=!0,s[a]=this.getOutputNode(e),s[a].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[a]}else"analyze"===i?n.build(e,t):"generate"===i&&(r=n.build(e,t)||"");return e.fnCall=o,r}}function eh(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}class ec extends O{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new ed(this,e)}setup(){return this.call()}}let ep=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],em=new Map;for(let e of[!1,!0])em.set(e,new X(e));let eg=new Map;for(let e of[0,1,2,3])eg.set(e,new X(e,"uint"));let ef=new Map([...eg].map(e=>new X(e.value,"int")));for(let e of[-1,-2])ef.set(e,new X(e,"int"));let eb=new Map([...ef].map(e=>new X(e.value)));for(let e of ep)eb.set(e,new X(e));for(let e of ep)eb.set(-e,new X(-e));let ey={bool:em,uint:eg,ints:ef,float:eb},ex=new Map([...em,...eb]),eT=(e,t)=>ex.has(e)?ex.get(e):!0===e.isNode?e:new X(e,t),e_=function(e,t=null){return(...r)=>{for(let t of r)if(void 0===t)return(0,u.z3S)(`TSL: Invalid parameter for the type "${e}".`,new f),new X(0,e);if((0===r.length||!["bool","float","int","uint"].includes(e)&&r.every(e=>{let t=typeof e;return"object"!==t&&"function"!==t}))&&(r=[A(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return eA(t.get(r[0]));if(1===r.length){let t=eT(r[0],e);return t.nodeType===e?eA(t):eA(new V(t,e))}return eA(new k(r.map(e=>eT(e)),e))}};function ev(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),!!e}let eS=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function eN(e,t){return new ec(e,t)}let eR=(e,t=null)=>ea(e,t),eA=(e,t=null)=>
2eR(e,t).toVarIntent(),eE=(e,t=null)=>new en(e,t),eC=(e,t=null)=>new eo(e,t),ew=(e,t=null,r=null,i=null)=>new el(e,t,r,i),eM=(e,...t)=>new eu(e,...t),eB=(e,t=null,r=null,i={})=>new el(e,t,r,{...i,intent:!0}),eU=(e,t)=>new Proxy(e,{get:(e,r,i)=>Reflect.get(t,r,i),set:(e,r,i)=>Reflect.set(t,r,i)}),eF=0;class eL extends O{constructor(e,t=null){super();let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:(0,u.z3S)("TSL: Invalid layout type.",new f),t=null)),this.shaderNode=new eN(e,r),null!==t&&this.setLayout(t),this.isFn=!0}setLayout(e){let t=this.shaderNode.nodeType;if("object"!=typeof e.inputs){let r={name:"fn"+eF++,type:t,inputs:[]};for(let t in e)"return"!==t&&r.inputs.push({name:t,type:e[t]});e=r}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){let t=this.shaderNode.call(e);return"void"===this.shaderNode.nodeType&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){let t=this.getNodeType(e);return(0,u.z3S)('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function eP(e,t=null){let r=new eL(e,t);return new Proxy(()=>{},{apply:(e,t,i)=>r.call(...i),get:(e,t,i)=>Reflect.get(r,t,i),set:(e,t,i,s)=>Reflect.set(r,t,i,s)})}let eD=e=>{K=e},eO=()=>K,eI=(...e)=>K.If(...e);function eV(e){return K&&K.addToStack(e),e}Z("toStack",eV);let eG=new e_("color"),ek=new e_("float",ey.float),ez=new e_("int",ey.ints),e$=new e_("uint",ey.uint),eW=new e_("bool",ey.bool),eH=new e_("vec2"),eq=new e_("ivec2"),ej=new e_("uvec2"),eX=new e_("bvec2"),eQ=new e_("vec3"),eK=new e_("ivec3"),eY=new e_("uvec3"),eZ=new e_("bvec3"),eJ=new e_("vec4"),e0=new e_("ivec4"),e1=new e_("uvec4"),e2=new e_("bvec4"),e3=new e_("mat2"),e4=new e_("mat3"),e5=new e_("mat4");Z("toColor",eG),Z("toFloat",ek),Z("toInt",ez),Z("toUint",e$),Z("toBool",eW),Z("toVec2",eH),Z("toIVec2",eq),Z("toUVec2",ej),Z("toBVec2",eX),Z("toVec3",eQ),Z("toIVec3",eK),Z("toUVec3",eY),Z("toBVec3",eZ),Z("toVec4",eJ),Z("toIVec4",e0),Z("toUVec4",e1),Z("toBVec4",e2),Z("toMat2",e3),Z("toMat3",e4),Z("toMat4",e5);let e6=ew(I).setParameterLength(2),e8=(e,t)=>new V(eR(e),t);Z("element",e6),Z("convert",e8),Z("append",e=>((0,u.R8M)("TSL: .append() has been renamed to .toStack().",new f),eV(e)));class e9 extends O{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1,i=null){super(e),this.name=t,this.varying=r,this.placeholderNode=eR(i),this.isPropertyNode=!0,this.global=!0}getNodeType(e){let t=super.getNodeType(e);return"output"===t?e.getOutputType():t}customCacheKey(){return y(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(!0===this.varying)(t=e.getVaryingFromNode(this,this.name)).needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),null!==this.placeholderNode&&!1===e.hasWriteUsage(this)){let r=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${r}`,this)}return e.getPropertyName(t)}}let e7=(e,t,r=null)=>new e9(e,t,!1,r),te=(e,t,r=null)=>new e9(e,t,!0,r),tt=eM(e9,"vec4","DiffuseColor"),tr=eM(e9,"vec3","DiffuseContribution"),ti=eM(e9,"vec3","EmissiveColor"),ts=eM(e9,"float","Roughness"),ta=eM(e9,"float","Metalness"),tn=eM(e9,"float","Clearcoat"),to=eM(e9,"float","ClearcoatRoughness"),tl=eM(e9,"vec3","Sheen"),tu=eM(e9,"float","SheenRoughness"),td=eM(e9,"float","Iridescence"),th=eM(e9,"float","IridescenceIOR"),tc=eM(e9,"float","IridescenceThickness"),tp=eM(e9,"float","AlphaT"),tm=eM(e9,"float","Anisotropy"),tg=eM(e9,"vec3","AnisotropyT"),tf=eM(e9,"vec3","AnisotropyB"),tb=eM(e9,"color","SpecularColor"),ty=eM(e9,"color","SpecularColorBlended"),tx=eM(e9,"float","SpecularF90"),tT=eM(e9,"float","Shininess"),t_=eM(e9,"output","Output"),tv=eM(e9,"float","dashSize"),tS=eM(e9,"float","gapSize"),tN=eM(e9,"float","pointWidth"),tR=eM(e9,"float","IOR"),tA=eM(e9,"float","Transmission"),tE=eM(e9,"float","Thickness"),tC=eM(e9,"float","AttenuationDistance"),tw=eM(e9,"color","AttenuationColor"),tM=eM(e9,"float","Dispersion"),tB=eM(e9,"float","AmbientOcclusion",!1,1);class tU extends O{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1,i=null){super("string"),this.name=e,this.shared=t,this.order=r,this.updateType=i,this.isUniformGroup=!0}
2update(){this.needsUpdate=!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 tF=(e,t=1,r=null)=>new tU(e,!1,t,r),tL=(e,t=0,r=null)=>new tU(e,!0,t,r),tP=tL("frame",0,w.FRAME),tD=tL("render",0,w.RENDER),tO=tF("object",1,w.OBJECT);class tI extends q{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=tO}setName(e){return this.name=e,this}label(e){return(0,u.R8M)('TSL: "label()" has been deprecated. Use "setName()" instead.',new f),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(t=>{let r=e(t,this);void 0!==r&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return"bool"===t&&(t="uint"),t}generate(e,t){let r=this.getNodeType(e),i=this.getUniformHash(e),s=e.getNodeFromHash(i);void 0===s&&(e.setHashNode(this,i),s=this);let a=s.getInputType(e),n=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.nodeName),o=e.getPropertyName(n);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,a,r),e.addLineFlowCode(`${i} = ${l}`,this)}l=i}return e.format(l,r,t)}}let tV=(e,t)=>{let r=eS(t||e);if(r===e&&(e=A(r)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new tI(e,r)};class tG extends G{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return null===this.nodeType?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return null===this.nodeType?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){let t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}let tk=(...e)=>{let t;if(1===e.length){let r=e[0];t=new tG(null,r.length,r)}else t=new tG(e[0],e[1]);return eR(t)};Z("toArray",(e,t)=>tk(Array(t).fill(e)));class tz extends G{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(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,i=t.getScope();e.getDataFromNode(i).assign=!0;let s=e.getNodeProperties(this);s.sourceNode=r,s.targetNode=t.context({assign:!0})}generate(e,t){let r,{targetNode:i,sourceNode:s}=e.getNodeProperties(this),a=this.needsSplitAssign(e),n=i.build(e),o=i.getNodeType(e),l=s.build(e,o),u=s.getNodeType(e),d=e.getDataFromNode(this);if(!0===d.initialized)"void"!==t&&(r=n);else if(a){let s=e.getVarFromNode(this,null,o),a=e.getPropertyName(s);e.addLineFlowCode(`${a} = ${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} = ${a}[ ${t} ]`,this)}"void"!==t&&(r=n)}else r=`${n} = ${l}`,("void"===t||"void"===u)&&(e.addLineFlowCode(r,this),"void"!==t&&(r=n));return d.initialized=!0,e.format(r,o,t)}}let t$=ew(tz).setParameterLength(2);Z("assign",t$);class tW extends G{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}generateNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){let t=[],r=this.functionNode,i=r.getInputs(e),s=this.parameters,a=(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)(0,u.z3S)("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((0,u.z3S)("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");s.length<i.length;)s.push(ek(0));for(let e=0;e<s.length;e++)t.push(a(s[e],i[e]))}else for(let e of i){let r=s[e.name];void 0!==r?t.push(a(r,e)):((0,u.z3S)(`TSL: Input '${e.name}' not found in 'Fn()'.`),t.push(a(ek(0),e)))}let n=r.build(e,"property");return`${n}( ${t.join(", ")} )`}}let tH=(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?eC(t):eE(t[0]),new tW(eR(e),t));Z("call",tH);let tq={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class tj extends G{static get type(){return"OperatorNode"}constructor(e,t,r,...i){if(super(),i.length>0){let s=new tj(e,t,r);for(let t=0;t<i.length-1;t++)s=new tj(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(tq[this.op],t)}generateNodeType(e,t=null){let r=this.op,i=this.aNode,s=this.bNode,a=i.getNodeType(e),n=s?s.getNodeType(e):null;if("void"===a||"void"===n)return t||"void";if("%"===r)return a;
2if("~"===r||"&"===r||"|"===r||"^"===r||">>"===r||"<<"===r)return e.getIntegerType(a);if("&&"===r||"||"===r||"^^"===r)return"bool";if("!"===r){let t=e.getTypeLength(a);return t>1?`bvec${t}`:"bool"}else if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r){let t=Math.max(e.getTypeLength(a),e.getTypeLength(n));return t>1?`bvec${t}`:"bool"}else{if(e.isMatrix(a)){if("float"===n)return a;else if(e.isVector(n))return e.getVectorFromMatrix(a);else if(e.isMatrix(n))return a}else if(e.isMatrix(n)){if("float"===a)return n;else if(e.isVector(a))return e.getVectorFromMatrix(n)}return e.getTypeLength(n)>e.getTypeLength(a)?n:a}}generate(e,t){let r=this.op,{aNode:i,bNode:s}=this,a=this.getNodeType(e,t),n=null,o=null;"void"!==a?(n=i.getNodeType(e),o=s?s.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(n)?o=n:e.isVector(o)?n=o:n!==o&&(n=o="float"):">>"===r||"<<"===r?(n=a,o=e.changeComponentType(o,"uint")):"%"===r?(n=a,o=e.isInteger(n)&&e.isInteger(o)?o:n):e.isMatrix(n)?"float"===o?o="float":e.isVector(o)?o=e.getVectorFromMatrix(n):e.isMatrix(o)||(n=o=a):n=e.isMatrix(o)?"float"===n?"float":e.isVector(n)?e.getVectorFromMatrix(o):o=a:o=a):n=o=a;let l=i.build(e,n),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} )`,a,t);else if(e.isVector(n))return e.format(`${this.getOperatorMethod(e,t)}( ${l}, ${d} )`,a,t);else return e.format(`( ${l} ${r} ${d} )`,a,t);if("%"===r)if(e.isInteger(o))return e.format(`( ${l} % ${d} )`,a,t);else return e.format(`${this.getOperatorMethod(e,a)}( ${l}, ${d} )`,a,t);if("!"===r)if(i&&e.isVector(n))return e.format(`not( ${l} )`,t);else return e.format(`( ${r} ${l} )`,n,t);else{if("~"===r)return e.format(`( ${r} ${l} )`,n,t);if(h)return e.format(`${h}( ${l}, ${d} )`,a,t);if(e.isMatrix(n)&&"float"===o)return e.format(`( ${d} ${r} ${l} )`,a,t);if("float"===n&&e.isMatrix(o))return e.format(`${l} ${r} ${d}`,a,t);let s=`( ${l} ${r} ${d} )`;return!i&&"bool"===a&&e.isVector(n)&&e.isVector(o)&&(s=`all${s}`),e.format(s,a,t)}}if("void"!==n)if(h)return e.format(`${h}( ${l}, ${d} )`,a,t);else if(e.isMatrix(n)&&"float"===o)return e.format(`${d} ${r} ${l}`,a,t);else return e.format(`${l} ${r} ${d}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}let tX=eB(tj,"+").setParameterLength(2,1/0).setName("add"),tQ=eB(tj,"-").setParameterLength(2,1/0).setName("sub"),tK=eB(tj,"*").setParameterLength(2,1/0).setName("mul"),tY=eB(tj,"/").setParameterLength(2,1/0).setName("div"),tZ=eB(tj,"%").setParameterLength(2).setName("mod"),tJ=eB(tj,"==").setParameterLength(2).setName("equal"),t0=eB(tj,"!=").setParameterLength(2).setName("notEqual"),t1=eB(tj,"<").setParameterLength(2).setName("lessThan"),t2=eB(tj,">").setParameterLength(2).setName("greaterThan"),t3=eB(tj,"<=").setParameterLength(2).setName("lessThanEqual"),t4=eB(tj,">=").setParameterLength(2).setName("greaterThanEqual"),t5=eB(tj,"&&").setParameterLength(2,1/0).setName("and"),t6=eB(tj,"||").setParameterLength(2,1/0).setName("or"),t8=eB(tj,"!").setParameterLength(1).setName("not"),t9=eB(tj,"^^").setParameterLength(2).setName("xor"),t7=eB(tj,"&").setParameterLength(2).setName("bitAnd"),re=eB(tj,"~").setParameterLength(1).setName("bitNot"),rt=eB(tj,"|").setParameterLength(2).setName("bitOr"),rr=eB(tj,"^").setParameterLength(2).setName("bitXor"),ri=eB(tj,"<<").setParameterLength(2).setName("shiftLeft"),rs=eB(tj,">>").setParameterLength(2).setName("shiftRight"),ra=eP(([e])=>(e.addAssign(1),e)),rn=eP(([e])=>(e.subAssign(1),e)),ro=eP(([e])=>{let t=ez(e).toConst();return e.addAssign(1),t}),rl=eP(([e])=>{let t=ez(e).toConst();return e.subAssign(1),t});Z("add",tX),Z("sub",tQ),Z("mul",tK),Z("div",tY),Z("mod",tZ),Z("equal",tJ),Z("notEqual",t0),Z("lessThan",t1),Z("greaterThan",t2),Z("lessThanEqual",t3),Z("greaterThanEqual",t4),Z("and",t5),Z("or",t6),Z("not",t8),Z("xor",t9),Z("bitAnd",t7),Z("bitNot",re),Z("bitOr",rt),Z("bitXor",rr),Z("shiftLeft",ri),Z("shiftRight",rs),Z("incrementBefore",ra),Z("decrementBefore",rn),Z("increment",ro),Z("decrement",rl);class ru extends G{static get type(){return"MathNode"}constructor(e,t,r=null,i=null){if(super(),(e===ru.MAX||e===ru.MIN)&&arguments.length>3){let s=new ru(e,t,r);for(let t=3;t<arguments.length-1;t++)s=new ru(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),a=e.isMatrix(r)?0:e.getTypeLength(r),n=e.isMatrix(i)?0:e.getTypeLength(i);if(s>a&&s>n);else if(a>n)return r;else if(n>s)return i;return t}generateNodeType(e){let t=this.method;return t===ru.LENGTH||t===ru.DISTANCE||t===ru.DOT?"float":t===ru.CROSS?"vec3":t===ru.ALL||t===ru.ANY?"bool":t===ru.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===ru.ONE_MINUS)s=tQ(1,t);else if(i===ru.RECIPROCAL)s=tY(1,t);else if(i===ru.DIFFERENCE)s=rz(tQ(t,r));else if(i===ru.TRANSFORM_DIRECTION){let i,a;e.isMatrix(t.getNodeType(e))?(i=t,a=r):(i=r,a=t),s=rC(tK(i,eJ(eQ(a),0)).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),a=this.aNode,n=this.bNode,o=this.cNode,l=e.renderer.coordinateSystem;if(r===ru.NEGATE)return e.format("( - "+a.build(e,s)+" )",i,t);{let d=[];return r===ru.CROSS?d.push(a.build(e,i),n.build(e,i)):l===u.TdN&&r===ru.STEP?d.push(a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":s),n.build(e,s)):l===u.TdN&&(r===ru.MIN||r===ru.MAX)?d.push(a.build(e,s),n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":s)):r===ru.REFRACT?d.push(a.build(e,s),n.build(e,s),o.build(e,"float")):r===ru.MIX?d.push(a.build(e,s),n.build(e,s),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":s)):(l===u.i7u&&r===ru.ATAN&&null!==n&&(r="atan2"),"fragment"!==e.shaderStage&&(r===ru.DFDX||r===ru.DFDY)&&((0,u.R8M)(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),r="/*"+r+"*/"),d.push(a.build(e,s)),null!==n&&d.push(n.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}}ru.ALL="all",ru.ANY="any",ru.RADIANS="radians",ru.DEGREES="degrees",ru.EXP="exp",ru.EXP2="exp2",ru.LOG="log",ru.LOG2
2="log2",ru.SQRT="sqrt",ru.INVERSE_SQRT="inversesqrt",ru.FLOOR="floor",ru.CEIL="ceil",ru.NORMALIZE="normalize",ru.FRACT="fract",ru.SIN="sin",ru.SINH="sinh",ru.COS="cos",ru.COSH="cosh",ru.TAN="tan",ru.TANH="tanh",ru.ASIN="asin",ru.ASINH="asinh",ru.ACOS="acos",ru.ACOSH="acosh",ru.ATAN="atan",ru.ATANH="atanh",ru.ABS="abs",ru.SIGN="sign",ru.LENGTH="length",ru.NEGATE="negate",ru.ONE_MINUS="oneMinus",ru.DFDX="dFdx",ru.DFDY="dFdy",ru.ROUND="round",ru.RECIPROCAL="reciprocal",ru.TRUNC="trunc",ru.FWIDTH="fwidth",ru.TRANSPOSE="transpose",ru.DETERMINANT="determinant",ru.INVERSE="inverse",ru.EQUALS="equals",ru.MIN="min",ru.MAX="max",ru.STEP="step",ru.REFLECT="reflect",ru.DISTANCE="distance",ru.DIFFERENCE="difference",ru.DOT="dot",ru.CROSS="cross",ru.POW="pow",ru.TRANSFORM_DIRECTION="transformDirection",ru.MIX="mix",ru.CLAMP="clamp",ru.REFRACT="refract",ru.SMOOTHSTEP="smoothstep",ru.FACEFORWARD="faceforward";let rd=ek(1e-6),rh=ek(1e6),rc=ek(Math.PI),rp=ek(2*Math.PI),rm=ek(2*Math.PI),rg=ek(.5*Math.PI),rf=eB(ru,ru.ALL).setParameterLength(1),rb=eB(ru,ru.ANY).setParameterLength(1),ry=eB(ru,ru.RADIANS).setParameterLength(1),rx=eB(ru,ru.DEGREES).setParameterLength(1),rT=eB(ru,ru.EXP).setParameterLength(1),r_=eB(ru,ru.EXP2).setParameterLength(1),rv=eB(ru,ru.LOG).setParameterLength(1),rS=eB(ru,ru.LOG2).setParameterLength(1),rN=eB(ru,ru.SQRT).setParameterLength(1),rR=eB(ru,ru.INVERSE_SQRT).setParameterLength(1),rA=eB(ru,ru.FLOOR).setParameterLength(1),rE=eB(ru,ru.CEIL).setParameterLength(1),rC=eB(ru,ru.NORMALIZE).setParameterLength(1),rw=eB(ru,ru.FRACT).setParameterLength(1),rM=eB(ru,ru.SIN).setParameterLength(1),rB=eB(ru,ru.SINH).setParameterLength(1),rU=eB(ru,ru.COS).setParameterLength(1),rF=eB(ru,ru.COSH).setParameterLength(1),rL=eB(ru,ru.TAN).setParameterLength(1),rP=eB(ru,ru.TANH).setParameterLength(1),rD=eB(ru,ru.ASIN).setParameterLength(1),rO=eB(ru,ru.ASINH).setParameterLength(1),rI=eB(ru,ru.ACOS).setParameterLength(1),rV=eB(ru,ru.ACOSH).setParameterLength(1),rG=eB(ru,ru.ATAN).setParameterLength(1,2),rk=eB(ru,ru.ATANH).setParameterLength(1),rz=eB(ru,ru.ABS).setParameterLength(1),r$=eB(ru,ru.SIGN).setParameterLength(1),rW=eB(ru,ru.LENGTH).setParameterLength(1),rH=eB(ru,ru.NEGATE).setParameterLength(1),rq=eB(ru,ru.ONE_MINUS).setParameterLength(1),rj=eB(ru,ru.DFDX).setParameterLength(1),rX=eB(ru,ru.DFDY).setParameterLength(1),rQ=eB(ru,ru.ROUND).setParameterLength(1),rK=eB(ru,ru.RECIPROCAL).setParameterLength(1),rY=eB(ru,ru.TRUNC).setParameterLength(1),rZ=eB(ru,ru.FWIDTH).setParameterLength(1),rJ=eB(ru,ru.TRANSPOSE).setParameterLength(1),r0=eB(ru,ru.DETERMINANT).setParameterLength(1),r1=eB(ru,ru.INVERSE).setParameterLength(1),r2=eB(ru,ru.MIN).setParameterLength(2,1/0),r3=eB(ru,ru.MAX).setParameterLength(2,1/0),r4=eB(ru,ru.STEP).setParameterLength(2),r5=eB(ru,ru.REFLECT).setParameterLength(2),r6=eB(ru,ru.DISTANCE).setParameterLength(2),r8=eB(ru,ru.DIFFERENCE).setParameterLength(2),r9=eB(ru,ru.DOT).setParameterLength(2),r7=eB(ru,ru.CROSS).setParameterLength(2),ie=eB(ru,ru.POW).setParameterLength(2),it=e=>tK(e,e),ir=e=>tK(e,e,e),ii=e=>tK(e,e,e,e),is=eB(ru,ru.TRANSFORM_DIRECTION).setParameterLength(2),ia=(e,t)=>rC(tK(t,eJ(eQ(e),0)).xyz),io=(e,t)=>rC(eJ(eQ(e),0).mul(t).xyz),il=e=>tK(r$(e),ie(rz(e),1/3)),iu=e=>r9(e,e),id=eB(ru,ru.MIX).setParameterLength(3),ih=(e,t=0,r=1)=>new ru(ru.CLAMP,eR(e),eR(t),eR(r)),ic=e=>ih(e),ip=eB(ru,ru.REFRACT).setParameterLength(3),im=eB(ru,ru.SMOOTHSTEP).setParameterLength(3),ig=eB(ru,ru.FACEFORWARD).setParameterLength(3),ib=eP(([e])=>rw(rM(tZ(r9(e.xy,eH(12.9898,78.233)),rc)).mul(43758.5453))),iy=(e,t,r)=>id(t,r,e),ix=(e,t,r)=>im(t,r,e),iT=(e,t)=>r4(t,e);Z("all",rf),Z("any",rb),Z("radians",ry),Z("degrees",rx),Z("exp",rT),Z("exp2",r_),Z("log",rv),Z("log2",rS),Z("sqrt",rN),Z("inverseSqrt",rR),Z("floor",rA),Z("ceil",rE),Z("normalize",rC),Z("fract",rw),Z("sin",rM),Z("sinh",rB),Z("cos",rU),Z("cosh",rF),Z("tan",rL),Z("tanh",rP),Z("asin",rD),Z("asinh",rO),Z("acos",rI),Z("acosh",rV),Z("atan",rG),Z("atanh",rk),Z("abs",rz),Z("sign",r$),Z("length",rW),Z("lengthSq",iu),Z("negate",rH),Z("oneMinus",rq),Z("dFdx",rj),Z("dFdy",rX),Z("round",rQ),Z("reciprocal",rK),Z("trunc",rY),Z("fwidth",rZ),Z("min",r2),Z("max",r3),Z("step",iT),Z("reflect",r5),Z("distance",r6),Z("dot",r9),Z("cross",r7),Z("pow",ie),Z("pow2",it),Z("pow3",ir),Z("pow4",ii),Z("transformDirection",is),Z("transformNormalByViewMatrix",ia),Z("transformNormalByInverseViewMatrix",io),Z("mix",iy),Z("clamp",ih),Z("refract",ip),Z("smoothstep",ix
vendor: 4,441 bytes, lines 2-5
2),Z("faceForward",ig),Z("difference",r8),Z("saturate",ic),Z("cbrt",il),Z("transpose",rJ),Z("determinant",r0),Z("inverse",r1),Z("rand",ib);class i_ extends O{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}generateNodeType(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,r=this.ifNode.isolate(),i=this.elseNode?this.elseNode.isolate():null,s=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=s,null!==i&&(e.getDataFromNode(i).parentNodeBlock=s);let a=e.context.uniformFlow,n=e.getNodeProperties(this);n.condNode=t,n.ifNode=a?r:r.context({nodeBlock:r}),n.elseNode=i?a?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:a,elseNode:n}=e.getNodeProperties(this),o=e.currentFunctionNode,l="void"!==t,d=l?e7(r).build(e):"";i.nodeProperty=d;let h=s.build(e,"bool");if(e.context.uniformFlow&&null!==n){let i=a.build(e,r),s=n.build(e,r),o=e.getTernary(h,i,s);return e.format(o,r,t)}e.addFlowCode(`
3${e.tab}if ( ${h} ) {
4
5`).addFlowTab();let c=a.build(e,r);if(c&&(l?c=d+" = "+c+";":(c="return "+c+";",null===o&&((0,u.R8M)("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),c="// "+c))),e.removeFlowTab().addFlowCode(e.tab+"	"+c+"\n\n"+e.tab+"}"),null!==n){e.addFlowCode(" else {\n\n").addFlowTab();let t=n.build(e,r);t&&(l?t=d+" = "+t+";":(t="return "+t+";",null===o&&((0,u.R8M)("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),t="// "+t))),e.removeFlowTab().addFlowCode(e.tab+"	"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(d,r,t)}}let iv=ew(i_).setParameterLength(2,3);Z("select",iv);class iS extends O{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){let e=[];return this.traverse(t=>{!0===t.isContextNode&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){let t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){let r=e.addContext(this.value),i=this.node.build(e,t);return e.setContext(r),i}}let iN=(e=null,t={})=>{let r=e;return(null===r||!0!==r.isNode)&&(t=r||t,r=null),new iS(r,t)},iR=e=>iN(e,{uniformFlow:!0}),iA=(e,t)=>iN(e,{nodeName:t});function iE(e,t,r=null){return iN(r,{getShadow:({light:r,shadowColorNode:i})=>t===r?i.mul(e):i})}function iC(e,t=null){return iN(t,{getAO:(t,{material:r})=>!0===r.transparent?t:null!==t?t.mul(e):e})}function iw(e,t){return(0,u.R8M)('TSL: "label()" has been deprecated. Use "setName()" instead.'),iA(e,t)}Z("context",iN),Z("label",iw),Z("uniformFlow",iR),Z("setName",iA),Z("builtinShadowContext",(e,t,r)=>iE(t,r,e)),Z("builtinAOContext",(e,t)=>iC(t,e));class iM extends O{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}isIntent(e){return!0!==e.getDataFromNode(this).forceDeclaration&&this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){let t=e[0],r=this.getShared(t);if(this!==r)return r.build(...e);if(!1===this._hasStack(t)&&"setup"===t.buildStage&&(t.context.nodeLoop||t.context.nodeBlock)){let e=!1;this.node.isShaderCallNodeInternal&&null===this.node.shaderNode.getLayout()&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop&&(t.getDataFromNode(this).forceDeclaration=!0,e=!0);let r=t.getBaseStack();e?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&!0!==this.isAssign(t)?this.node.build(...e):super.build(...e)}
5generate(e){let{node:t,name:r,readOnly:i}=this,{renderer:s}=e,a=!0===s.backend.isWebGPUBackend,n=!1,o=!1;i&&(n=e.isDeterministic(t),o=a?i:n);let l=this.getNodeType(e);if("void"==l)return!0!==this.isIntent(e)&&(0,u.z3S)('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);let d=e.getVectorType(l),h=t.build(e,d),c=e.getVarFromNode(this,r,d,void 0,o),p=e.getPropertyName(c),m=p;if(o)if(a)m=n?`const ${p}`:`let ${p}`;else{let r=t.getArrayCount(e);m=`const ${e.getVar(c.type,p,r)}`}return e.addLineFlowCode(`${m} = ${h}`,this),p}_hasStack(e){return void 0!==e.getDataFromNode(this).stack}}let iB=ew(iM),iU=(e,t=null)=>iB(e,t).toStack(),iF=(e,t=null)=>iB(e,t,!0).toStack(),iL=e=>iB(e).setIntent(!0).toStack();Z("toVar",iU),Z("toConst",iF),Z("toVarIntent",iL);class iP extends O{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(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 iD=(e,t,r=null)=>new iP(eR(e),t,r);class iO extends O{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=iD(e,"VERTEX"),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)}generateNodeType(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),a=this.interpolationType,n=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,i,s,a,n),t.node=iD(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(C.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(C.VERTEX,this.node)}generate(e){let t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),i=this.setupVarying(e);if(void 0===r[t]){let s=this.getNodeType(e),a=e.getPropertyName(i,C.VERTEX);if(e.shaderStage===C.VERTEX){let t=r.node.build(e,s);e.addLineFlowCode(`${a} = ${t}`,this)}else e.flowNodeFromShaderStage(C.VERTEX,r.node,s,a);r[t]=a}return e.getPropertyName(i)}}let iI=ew(iO).setParameterLength(1,2),iV=e=>iI(e);Z("toVarying",iI),Z("toVertexStage",iV);let iG=eP(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4);return id(t,e.mul(.0773993808),e.lessThanEqual(.04045))}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),ik=eP(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055);return id(t,e.mul(12.92),e.lessThanEqual(.0031308))}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),iz="WorkingColorSpace";class i$ extends G{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===iz?u.ppV.workingColorSpace:"OutputColorSpace"===t?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){let{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),i=this.resolveColorSpace(e,this.target),s=t;return!1!==u.ppV.enabled&&r!==i&&r&&i&&(u.ppV.getTransfer(r)===u.KLL&&(s=eJ(iG(s.rgb),s.a)),u.ppV.getPrimaries(r)!==u.ppV.getPrimaries(i)&&(s=eJ(e4(u.ppV._getMatrix(new u.dwI,r,i)).mul(s.rgb),s.a)),u.ppV.getTransfer(i)===u.KLL&&(s=eJ(ik(s.rgb),s.a))),s}}let iW=(e,t)=>new i$(eR(e),iz,t),iH=(e,t)=>new i$(eR(e),t,iz);Z("workingToColorSpace",iW),Z("colorSpaceToWorking",iH);let iq=class extends I{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){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 ij extends O{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,i=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=i,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=w.OBJECT}setGroup(e){return this.group=e,this}element(e){return new iq(this,eR(e))}setNodeType(e){let t=tV(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateV
5alue()),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 iX extends ij{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(tD)}updateReference(e){return this.reference=null!==this.renderer?this.renderer:e.renderer,this.reference}}let iQ=(e,t,r=null)=>new iX(e,t,r);class iK extends G{static get type(){return"ToneMappingNode"}constructor(e,t=iZ,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return T(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return 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=eJ(s(t.rgb,this.exposureNode),t.a):((0,u.z3S)("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=t),i}}let iY=(e,t,r)=>new iK(e,eR(t),eR(r)),iZ=iQ("toneMappingExposure","float");Z("toneMapping",(e,t,r)=>iY(t,r,e));let iJ=new WeakMap;function i0(e,t){let r=iJ.get(e);return void 0===r&&(r=new u.eB$(e,t),iJ.set(e,r)),r}class i1 extends q{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=i,this.usage=u.agE,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(0===this.bufferStride&&0===this.bufferOffset){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}generateNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){let t;if(null!==this.attribute)return;let r=this.getNodeType(e),i=e.getTypeLength(r),s=this.value,a=this.bufferStride||i,n=this.bufferOffset;t=!0===s.isInterleavedBuffer?s:!0===s.isBufferAttribute?i0(s.array,a):i0(s,a);let o=new u.eHs(t,i,n);t.setUsage(this.usage),this.attribute=o,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){let t=this.getNodeType(e),r=e.context.nodeName;void 0!==r&&delete e.context.nodeName;let i=e.getBufferAttributeFromNode(this,t,r),s=e.getPropertyName(i),a=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,a=s;else{let i;r&&(i=r+"Varying"),a=iI(this,i).build(e,t)}return a}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}}function i2(e,t=null,r=0,i=0,s=u.agE,a=!1){return"mat3"===t||null===t&&9===e.itemSize?e4(new i1(e,"vec3",9,0).setUsage(s).setInstanced(a),new i1(e,"vec3",9,3).setUsage(s).setInstanced(a),new i1(e,"vec3",9,6).setUsage(s).setInstanced(a)):"mat4"===t||null===t&&16===e.itemSize?e5(new i1(e,"vec4",16,0).setUsage(s).setInstanced(a),new i1(e,"vec4",16,4).setUsage(s).setInstanced(a),new i1(e,"vec4",16,8).setUsage(s).setInstanced(a),new i1(e,"vec4",16,12).setUsage(s).setInstanced(a)):new i1(e,t,r,i).setUsage(s)}let i3=(e,t=null,r=0,i=0)=>i2(e,t,r,i),i4=(e,t=null,r=0,i=0)=>i2(e,t,r,i,u.agE,!0),i5=(e,t=null,r=0,i=0)=>i2(e,t,r,i,u.Vnu,!0);Z("toAttribute",e=>i3(e.value));class i6 extends O{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===i6.VERTEX)t=e.getVertexIndex();else if(i===i6.INSTANCE)t=e.getInstanceIndex();else if(i===i6.DRAW)t=e.getDrawIndex();else if(i===i6.INVOCATION_LOCAL)t=e.getInvocationLocalIndex();
5else if(i===i6.INVOCATION_SUBGROUP)t=e.getInvocationSubgroupIndex();else if(i===i6.SUBGROUP)t=e.getSubgroupIndex();else throw Error("THREE.IndexNode: Unknown scope: "+i);return"vertex"===e.shaderStage||"compute"===e.shaderStage?t:iI(this).build(e,r)}}i6.VERTEX="vertex",i6.INSTANCE="instance",i6.SUBGROUP="subgroup",i6.INVOCATION_LOCAL="invocationLocal",i6.INVOCATION_SUBGROUP="invocationSubgroup",i6.DRAW="draw";let i8=eM(i6,i6.VERTEX),i9=eM(i6,i6.INSTANCE),i7=eM(i6,i6.SUBGROUP),se=eM(i6,i6.INVOCATION_SUBGROUP),st=eM(i6,i6.INVOCATION_LOCAL),sr=eM(i6,i6.DRAW);class si extends O{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=w.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return(0,u.R8M)('TSL: "label()" has been deprecated. Use "setName()" instead.',new f),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){null!==this.count&&null===this.countNode&&(this.countNode=tV(this.count,"uint").onObjectUpdate(()=>this.count));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");if(""!==t&&e.addLineFlowCode(t,this),null!==this.count&&!0===e.allowEarlyReturns){let t=this.countNode.build(e,"uint"),r=i9.build(e,"uint");e.flow.code=`${e.tab}if ( ${r} >= ${t} ) { return; }
6
7${e.flow.code}`}}else{let r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}let ss=(e,t=[64])=>{(0===t.length||t.length>3)&&(0,u.z3S)("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new f);for(let e=0;e<t.length;e++){let r=t[e];("number"!=typeof r||r<=0||!Number.isInteger(r))&&(0,u.z3S)(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new f)}for(;t.length<3;)t.push(1);return new si(eR(e),t)},sa=(e,t,r)=>{let i=ss(e,r);return"number"==typeof t?i.count=t:i.dispatchSize=t,i};Z("compute",sa),Z("computeKernel",ss);class sn extends O{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(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}setParent(e){return this.parent=e,this}getParent(){return this.parent}}let so=e=>new sn(eR(e));function sl(e,t=!0){return(0,u.R8M)('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),so(e).setParent(t)}Z("cache",sl),Z("isolate",so);class su extends O{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(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 sd=ew(su).setParameterLength(2);Z("bypass",sd);let sh=eP(([e,t,r,i=ek(0),s=ek(1),a=eW(!1)])=>{let n=e.sub(t).div(r.sub(t));return ev(a)&&(n=n.clamp()),n.mul(s.sub(i)).add(i)});function sc(e,t,r,i=ek(0),s=ek(1)){return sh(e,t,r,i,s,!0)}Z("remap",sh),Z("remapClamp",sc);class sp extends O{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 sm=ew(sp).setParameterLength(1,2),sg=e=>(e?iv(e,sm("discard")):sm("discard")).toStack();Z("discard",sg);let sf=eP(([e])=>eJ(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),sb=eP(([e])=>e.a.equal(0).select(eJ(0),eJ(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"});class sy extends G{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace
7=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=sb(t=eJ(t.rgb,t.a.clamp(0,1)));let 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=sf(t)}}let sx=(e,t=null,r=null)=>new sy(eR(e),t,r);Z("renderOutput",sx);class sT extends G{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(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);if(null!==t)t(e,r);else{let t="--- TSL debug - "+e.shaderStage+" shader ---",i="-".repeat(t.length),s="";s+="// #"+t+"#\n"+e.flow.code.replace(/^\t/mg,"")+"\n"+("/* ... */ "+r)+" /* ... */\n"+("// #"+i)+"#\n",(0,u.Rm2)(s)}return r}}let s_=(e,t=null)=>new sT(eR(e),t).toStack();Z("debug",s_);class sv extends u.Qev{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class sS extends O{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=w.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;
7return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==sv&&(0,u.mcG)('TSL: ".toInspector()" is only available with WebGPU.'),t}}function sN(e,t="",r=null){return(e=eR(e)).before(new sS(e,t,r))}Z("toInspector",sN);class sR extends O{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(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(0,u.R8M)(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r);{let i=e.geometry.getAttribute(t),s=e.getTypeFromAttribute(i),a=e.getAttribute(t,s);return"vertex"===e.shaderStage?e.format(a.name,s,r):iI(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 sA=(e,t=null)=>new sR(e,t),sE=(e=0)=>sA("uv"+(e>0?e:""),"vec2");class sC extends O{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 sw=ew(sC).setParameterLength(1,2);class sM extends tI{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=w.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){let e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&void 0!==r.width){let{width:e,height:t}=r;this.value=Math.log2(Math.max(e,t))}}}let sB=ew(sM).setParameterLength(1);class sU extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}let sF=new u.gPd;class sL extends tI{static get type(){return"TextureNode"}constructor(e=sF,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.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=w.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=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}generateNodeType(){return!0===this.value.isDepthTexture?null===this.gatherNode?"float":"vec4":this.value.type===u.bkx?"uvec4":this.value.type===u.Yuy?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return sE(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=tV(this.value.matrix)),this._matrixUniform.mul(eQ(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=tV(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY(ez(sw(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){let t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let r=this.value;if(!r||!0!==r.isTexture)throw new sU("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let i=eP(()=>{let t=this.uvNode;return(null===t||!0===e.context.forceUVContext)&&e.context.getUV&&(t=e.context.getUV(this,e)),t||(t=this.getDefaultUV()),!0===this.updateMatrix&&(t=this.getTransformedUV(t)),t=this.setupUV(e,t),this.updateType=null!==this._matrixUniform||null!==this._flipYUniform?w.OBJECT:w.NONE,t})(),s=this.levelNode;null===s&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this));let a=null,n=null;if(null!==this.compareNode)if(e.renderer.hasCompatibility(u.x$Y.TEXTURE_COMPARE))a=this.compareNode;else{let e=r.compareFunction;null===e||e===u.vim||e===u.TiK||e===u.eoi||e===u.gWB?n=this.compareNode:(a=this.compareNode,(0,u.mcG)('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=i,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=n,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,i,s,a,n,o,l,u,d){let h=this.value;return s?e.generateTextureBias(h,t,r,s,a,u):o?e.generateTextureGrad(h,t,r,o,a,u):l?n?e.generateTextureGatherCompare(h,t,r,n,a,u,d):e.generateTextureGather(h,t,r,l,a,u,d):n?e.generateTextureCompare(h,t,r,n,a,u):!1===this.sampler?e.generateTextureLoad(h,t,r,i,a,u):i?e.generateTextureLevel(h,t,r,i,a,u):e.generateTexture(h,t,r,a,u)}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 a=e.getDataFromNode(this),n=this.getNodeType(e),o=a.propertyName;if(void 0===o){let{uvNode:t,levelNode:l,biasNode:d,compareNode:h,compareStepNode:c,depthNode:p,gradNode:m,gatherNode:g,offsetNode:f}=i,b=this.generateUV(e,t),y=l?l.build(e,"float"):null,x=d?d.build(e,"float"):null,T=p?p.build(e,"int"):null,_=h?h.build(e,"float"):null,v=c?c.build(e,"float"):null,S=m?[m[0].build(e,"vec2"),m[1].build(e,"vec2")]:null,N=g?g.build(e,"int"):null,R=f?this.generateOffset(e,f):null,A=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;N&&(n="vec4");let E=T;null===E&&r.isArrayTexture&&!0!==this.isTexture3DNode&&(E="0");let C=e.getVarFromNode(this);o=e.getPropertyName(C);let w=this.generateSnippet(e,s,b,y,x,E,_,S,N,R,A);if(null!==v){let t=r.compareFunction;w=t===u.eoi||t===u.gWB?r4(sm(w,n),sm(v,"float")).build(e,n):r4(sm(v,"float"),sm(w,n)).build(e,n)}e.addLineFlowCode(`${o} = ${w}`,this),a.snippet=w,a.propertyName=o}let l=o;return e.needsToWorkingColorSpace(r)&&(l=iH(sm(l,n),r.colorSpace).setup(e).build(e,n)),e.format(l,n,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=eR(e),t.referenceNode=this.getBase(),eR(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=eR(e).mul(sB(t)),t.referenceNode=this.getBase();let r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===u.hxR||r.magFilter===u.hxR)&&((0,u.R8M)("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),eR(t)}level(e){let t=this.clone();return t.levelNode=eR(e),t.referenceNode=this.getBase(),eR(t)}size(e){return sw(this,e)}bias(e){let t=this.clone();return t.biasNode=eR(e),t.referenceNode=this.getBase(),eR(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=eR(e),t.referenceNode=this.getBase(),eR(t)}grad(e,t){let r=this.clone();return r.gradNode=[eR(e),eR(t)],r.referenceNode=this.getBase(),eR(r)}gather(e=0){let t=this.clone();return t.gatherNode=eR(e),t.referenceNode=this.getBase(),eR(t)}
7depth(e){let t=this.clone();return t.depthNode=eR(e),t.referenceNode=this.getBase(),eR(t)}offset(e){let t=this.clone();return t.offsetNode=eR(e),t.referenceNode=this.getBase(),eR(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){let e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix();let r=this._flipYUniform;null!==r&&(r.value=e.image instanceof ImageBitmap&&!0===e.flipY||!0===e.isRenderTargetTexture||!0===e.isFramebufferTexture||!0===e.isDepthTexture)}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.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}let sP=ew(sL).setParameterLength(1,4).setName("texture"),sD=(e=sF,t=null,r=null,i=null)=>{let s;return e&&!0===e.isTextureNode?((s=eR(e.clone())).referenceNode=e.getBase(),null!==t&&(s.uvNode=eR(t)),null!==r&&(s.levelNode=eR(r)),null!==i&&(s.biasNode=eR(i))):s=sP(e,t,r,i),s},sO=(...e)=>sD(...e).setSampler(!1);class sI extends tI{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}let sV=(e,t,r)=>new sI(e,t,r);class sG 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(e),i=this.node.getPaddedType();return e.format(t,i,r)}}class sk extends sI{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?R(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=w.RENDER,this.isArrayBufferNode=!0}generateNodeType(){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,a=e.getTypeLength(s);return"i"===r.charAt(0)&&(i=Int32Array),"u"===r.charAt(0)&&(i=Uint32Array),this.value=new i(t*a),this.bufferCount=t,this.bufferType=s,this.update(),super.setup(e)}element(e){return new sG(this,eR(e))}}let sz=(e,t)=>new sk(e,t);class s$ extends O{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}let sW=ew(s$).setParameterLength(1);class sH extends O{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===sH.DPR?"float":this.scope===sH.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=w.NONE;return(this.scope===sH.SIZE||this.scope===sH.VIEWPORT||this.scope===sH.DPR)&&(e=w.RENDER),this.updateType=e,e}update({renderer:e}){let t=e.getRenderTarget();this.scope===sH.VIEWPORT?null!==t?s.copy(t.viewport):(e.getViewport(s),s.multiplyScalar(e.getPixelRatio())):this.scope===sH.DPR?this._output.value=e.getPixelRatio():null!==t?(i.width=t.width,i.height=t.height):e.getDrawingBufferSize(i)}setup(){let e=this.scope,t=null;return t=e===sH.SIZE?tV(i||(i=new u.I9Y)):e===sH.VIEWPORT?tV(s||(s=new u.IUQ)):e===sH.DPR?tV(1):eH(sQ.div(sX)),this._output=t,t}generate(e){if(this.scope===sH.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){let r=e.getNodeProperties(sX).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}sH.COORDINATE="coordinate",sH.VIEWPORT="viewport",sH.SIZE="size",sH.UV="uv",sH.DPR="dpr";let sq=eM(sH,sH.DPR),sj=eM(sH,sH.UV),sX=eM(sH,sH.SIZE),sQ=eM(sH,sH.COORDINATE),sK=eM(sH,sH.VIEWPORT),sY=sK.zw,sZ=sQ.sub(sK.xy),sJ=sZ.div(sY),s0=eP(()=>((0,u.R8M)('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new f),sX),"vec2").once()(),s1=null,s2=null,s3=null,s4=null,s5=null,s6=null,s8=null,s9=null,s7=null,ae=null,at=null,ar=null,ai=null,as=null,aa=tV(0,"uint").setName("u_cameraIndex").setGroup(tL("cameraIndex")).toVarying("v_cameraIndex"),an=tV("float").setName("cameraNear").setGroup(tD).onRenderUpd
7ate(({camera:e})=>e.near),ao=tV("float").setName("cameraFar").setGroup(tD).onRenderUpdate(({camera:e})=>e.far),al=eP(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.projectionMatrix);null===s2?s2=sz(r).setGroup(tD).setName("cameraProjectionMatrices"):s2.array=r,t=s2.element(e.isMultiViewCamera?sW("gl_ViewID_OVR"):aa)}else null===s1&&(s1=tV(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(tD).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=s1;return t}).once()(),au=eP(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.projectionMatrixInverse);null===s4?s4=sz(r).setGroup(tD).setName("cameraProjectionMatricesInverse"):s4.array=r,t=s4.element(e.isMultiViewCamera?sW("gl_ViewID_OVR"):aa)}else null===s3&&(s3=tV(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(tD).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=s3;return t}).once()(),ad=eP(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.matrixWorldInverse);null===s6?s6=sz(r).setGroup(tD).setName("cameraViewMatrices"):s6.array=r,t=s6.element(e.isMultiViewCamera?sW("gl_ViewID_OVR"):aa)}else null===s5&&(s5=tV(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(tD).onRenderUpdate(({camera:e})=>e.matrixWorldInverse)),t=s5;return t}).once()(),ah=eP(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.matrixWorld);null===s9?s9=sz(r).setGroup(tD).setName("cameraWorldMatrices"):s9.array=r,t=s9.element(e.isMultiViewCamera?sW("gl_ViewID_OVR"):aa)}else null===s8&&(s8=tV(e.matrixWorld).setName("cameraWorldMatrix").setGroup(tD).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=s8;return t}).once()(),ac=eP(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.normalMatrix);null===ae?ae=sz(r).setGroup(tD).setName("cameraNormalMatrices"):ae.array=r,t=ae.element(e.isMultiViewCamera?sW("gl_ViewID_OVR"):aa)}else null===s7&&(s7=tV(e.normalMatrix).setName("cameraNormalMatrix").setGroup(tD).onRenderUpdate(({camera:e})=>e.normalMatrix)),t=s7;return t}).once()(),ap=eP(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t=0,i=e.cameras.length;t<i;t++)r.push(new u.Pq0);null===ar?ar=sz(r).setGroup(tD).setName("cameraPositions").onRenderUpdate(({camera:e},t)=>{let r=e.cameras,i=t.array;for(let e=0,t=r.length;e<t;e++)i[e].setFromMatrixPosition(r[e].matrixWorld)}):ar.array=r,t=ar.element(e.isMultiViewCamera?sW("gl_ViewID_OVR"):aa)}else null===at&&(at=tV(new u.Pq0).setName("cameraPosition").setGroup(tD).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),t=at;return t}).once()(),am=eP(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.viewport);null===as?as=sz(r,"vec4").setGroup(tD).setName("cameraViewports"):as.array=r,t=as.element(aa)}else null===ai&&(ai=eJ(0,0,sX.x,sX.y).toConst("cameraViewport")),t=ai;return t}).once()(),ag=new u.iyt;class af extends O{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=w.OBJECT,this.uniformNode=new tI(null)}generateNodeType(){let e=this.scope;return e===af.WORLD_MATRIX?"mat4":e===af.POSITION||e===af.VIEW_POSITION||e===af.DIRECTION||e===af.SCALE?"vec3":e===af.RADIUS?"float":void 0}update(e){let t=this.object3d,r=this.uniformNode,i=this.scope;if(i===af.WORLD_MATRIX)r.value=t.matrixWorld;else if(i===af.POSITION)r.value=r.value||new u.Pq0,r.value.setFromMatrixPosition(t.matrixWorld);else if(i===af.SCALE)r.value=r.value||new u.Pq0,r.value.setFromMatrixScale(t.matrixWorld);else if(i===af.DIRECTION)r.value=r.value||new u.Pq0,t.getWorldDirection(r.value);else if(i===af.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===af.RADIUS){let i=e.object.geometry;null===i.boundingSphere&&i.computeBoundingSphere(),ag.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),r.value=ag.radius}}generate(e){let t=this.scope;return t===af.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===af.POSITION||t===af.VIEW_POSITION||t===af.DIRECTION||t===af.SCALE?this.uniformNode.nodeType="vec3":t===af.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}}af.WORLD_MATRIX="worldMatrix",af.POSITION="position",af.SCALE="scale",af.VIEW_POSITION="viewPosition",af.DIRECTION="direction",af.RADIUS="radius";let ab=ew(af,af.DIRECTION).setParameterLength(1),ay=ew(af,af.WORLD_MATRIX).setParameterLength(1),ax=ew(af,af.POSITION).setParameterLength(1),aT=ew(af,af.SCALE).setParameterLength(1),a_=ew(af,af.VIEW_POSITION).setParameterLength(1),av=ew(af,af.RADIUS).setParameterLength(1);class aS extends af{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}let aN=eM(aS,aS.DIRECTION),aR=eM(aS,aS.WORLD_MATRIX),aA=eM(aS,aS.PO
7SITION),aE=eM(aS,aS.SCALE),aC=eM(aS,aS.VIEW_POSITION),aw=eM(aS,aS.RADIUS),aM=tV(new u.dwI).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),aB=tV(new u.kn4).onObjectUpdate(({object:e},t)=>t.value.copy(e.matrixWorld).invert()),aU=eP(e=>e.context.modelViewMatrix||aF).once()().toVar("modelViewMatrix"),aF=ad.mul(aR),aL=eP(e=>(e.context.isHighPrecisionModelViewMatrix=!0,tV("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),aP=eP(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return tV("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),aD=eP(e=>"fragment"!==e.shaderStage?((0,u.mcG)("TSL: `clipSpace` is only available in fragment stage."),eJ()):e.context.clipSpace.toVarying("v_clipSpace")).once()(),aO=sA("position","vec3"),aI=aO.toVarying("positionLocal"),aV=aO.toVarying("positionPrevious"),aG=eP(e=>aR.mul(aI).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),ak=eP(()=>aI.transformDirection(aR).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),az=eP(e=>{if("fragment"===e.shaderStage&&e.material.vertexNode){let e=au.mul(aD);return e.xyz.div(e.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),a$=eP(e=>(e.camera.isOrthographicCamera?eQ(0,0,1):az.negate().toVarying("v_positionViewDirection").normalize()).toVar("positionViewDirection"),"vec3").once(["POSITION"])();class aW extends O{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if("fragment"!==e.shaderStage)return"true";let{material:t}=e;return t.side===u.hsX?"false":e.getFrontFacing()}}let aH=eM(aW),aq=ek(aH).mul(2).sub(1),aj=eP(([e],{material:t})=>{let r=t.side;return r===u.hsX?e=e.mul(-1):r===u.$EB&&(e=e.mul(aq)),e}),aX=sA("normal","vec3"),aQ=eP(e=>!1===e.geometry.hasAttribute("normal")?((0,u.R8M)('TSL: Vertex attribute "normal" not found on geometry.'),eQ(0,1,0)):aX,"vec3").once()().toVar("normalLocal"),aK=az.dFdx().cross(az.dFdy()).normalize().toVar("normalFlat"),aY=eP(e=>e.isFlatShading()?aK:a3(aQ).toVarying("v_normalViewGeometry").normalize(),"vec3").once()().toVar("normalViewGeometry"),aZ=eP(e=>{let t=aY.transformNormalByInverseViewMatrix(ad);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),aJ=eP(e=>{let t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=aY,!0!==e.isFlatShading()&&(t=aj(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),a0=aJ.transformNormalByInverseViewMatrix(ad).toVar("normalWorld"),a1=eP(({subBuildFn:e,context:t})=>"NORMAL"===e||"VERTEX"===e?aJ:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),a2=eP(([e,t=aR])=>e4(t).inverse().transpose().mul(e).normalize());Z("transformNormal",a2);let a3=eP(([e],t)=>{let r=t.context.modelNormalViewMatrix;return r?e.transformNormalByViewMatrix(r):aM.mul(e).transformNormalByViewMatrix(ad)}),a4=eP(()=>((0,u.R8M)('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),aJ)).once(["NORMAL","VERTEX"])(),a5=eP(()=>((0,u.R8M)('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),a0)).once(["NORMAL","VERTEX"])(),a6=eP(()=>((0,u.R8M)('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),a1)).once(["NORMAL","VERTEX"])(),a8=new u.kn4,a9=tV(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),a7=tV(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),ne=tV(new u.kn4).onReference(function(e){return e.material}).onObjectUpdate(function({material:e,scene:t}){let r=(null!==t.environment||t.environmentNode&&t.environmentNode.isNode)&&null===e.envMap?t.environmentRotation:e.envMapRotation;return r?a8.makeRotationFromEuler(r).transpose():a8.identity(),a8}),nt=a$.negate().reflect(aJ),nr=a$.negate().refract(aJ,a9),ni=nt.transformDirection(ah).toVar("reflectVector"),ns=nr.transformDirection(ah).toVar("refractVector"),na=new u.b4q;class nn extends sL{static get type(){return"CubeTextureNode"}
7constructor(e,t=null,r=null,i=null){super(e,t,r,i),this.isCubeTextureNode=!0}getInputType(){return!0===this.value.isDepthTexture?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){let e=this.value;return e.mapping===u.hy7?ni:e.mapping===u.xFO?ns:((0,u.z3S)('CubeTextureNode: Mapping "%s" not supported.',e.mapping),eQ(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let r=this.value;return!0===r.isDepthTexture?e.renderer.coordinateSystem===u.i7u?eQ(t.x,t.y.negate(),t.z):t:(t=ne.mul(t),e.renderer.coordinateSystem!==u.i7u&&r.isRenderTargetTexture||(t=eQ(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}let no=ew(nn).setParameterLength(1,4).setName("cubeTexture"),nl=(e=na,t=null,r=null,i=null)=>{let s;return e&&!0===e.isCubeTextureNode?((s=eR(e.clone())).referenceNode=e,null!==t&&(s.uvNode=eR(t)),null!==r&&(s.levelNode=eR(r)),null!==i&&(s.biasNode=eR(i))):s=no(e,t,r,i),s};class nu extends I{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){let t=super.generate(e),r=this.referenceNode.getNodeType(e),i=this.getNodeType(e);return e.format(t,r,i)}}class nd extends O{static get type(){return"ReferenceNode"}constructor(e,t,r=null,i=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=i,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=w.OBJECT}element(e){return new nu(this,eR(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return(0,u.R8M)('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;null!==this.count?t=sV(null,e,this.count):Array.isArray(this.getValueFromReference())?(t=sz(null,e)).updateType=w.OBJECT:t="texture"===e?sD(null):"cubeTexture"===e?nl(null):tV(null,e),null!==this.group&&t.setGroup(this.group),null!==this.name&&t.setName(this.name),this.node=t}generateNodeType(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 nh=(e,t,r)=>new nd(e,t,r),nc=(e,t,r,i)=>new nd(e,t,i,r);class np extends nd{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 nm=(e,t,r=null)=>new np(e,t,r),ng=sE(),nf=az.dFdx(),nb=az.dFdy(),ny=ng.dFdx(),nx=ng.dFdy(),nT=nb.cross(aJ),n_=aJ.cross(nf),nv=nT.mul(ny.x).add(n_.mul(nx.x)),nS=nT.mul(ny.y).add(n_.mul(nx.y)),nN=nv.dot(nv).max(nS.dot(nS)),nR=nN.equal(0).select(0,nN.inverseSqrt()),nA=nv.mul(nR).toVar("tangentViewFrame"),nE=nS.mul(nR).toVar("bitangentViewFrame"),nC=sA("tangent","vec4"),nw=nC.xyz.toVar("tangentLocal"),nM=eP(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?aU.mul(eJ(nw,0)).xyz.toVarying("v_tangentView").normalize():nA,!0!==e.isFlatShading()&&(t=aj(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),nB=nM.transformDirection(ah).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),nU=eP(([e,t],r)=>{let i=e.mul(nC.w).xyz;return"NORMAL"===r.subBuildFn&&!0!==r.isFlatShading()&&(i=i.toVarying(t)),i}).once(["NORMAL"]),nF=nU(aX.cross(nC),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),nL=nU(aQ.cross(nw),"v_bitangentLocal").normalize().toVar("bitangentLocal"),nP=eP(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?nU(aJ.cross(nM),"v_bitangentView").normalize():nE,!0!==e.isFlatShading()&&(t=aj(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),nD=nU(a0.cross(nB),"v_bitangentWorld").normalize().toVar("bitangentWorld"),nO=e4(nM,nP,aJ).toVar("TBNViewMatrix"),nI=a$.mul(nO),nV=eP(()=>{let e=tf.cross(a$);return id(e=e.cross(tf).normalize(),aJ,tm.mul(ts.oneMinus()).oneMinus().pow2().pow2()).normalize()}).once()(),nG=e=>eR(e).mul(.5).add(.5),nk=e=>eR(e).mul(2).sub(1),nz=e=>eQ(e,rN(ic(ek(1).sub(r9(e,e)))));
7class n$ extends G{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=u.bI3,this.unpackNormalMode=u.AZd}setup(e){let{normalMapType:t,scaleNode:r,unpackNormalMode:i}=this,s=this.node.mul(2).sub(1);if(t===u.bI3?i===u.IjV?s=nz(s.xy):i===u.pO5?s=nz(s.yw):i!==u.AZd&&(0,u.z3S)(`THREE.NodeMaterial: Unexpected unpack normal mode: ${i}`):i!==u.AZd&&(0,u.z3S)(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${i}'`),null!==r){let t=r;!0===e.isFlatShading()&&(t=aj(t)),s=eQ(s.xy.mul(t),s.z)}let a=null;return t===u.vyJ?a=a3(s):t===u.bI3?a=nO.mul(s).normalize():((0,u.z3S)(`NodeMaterial: Unsupported normal map type: ${t}`),a=aJ),a}}let nW=ew(n$).setParameterLength(1,2),nH=eP(({textureNode:e,bumpScale:t})=>{let r=t=>e.isolate().context({getUV:e=>t(e.uvNode||sE()),forceUVContext:!0}),i=ek(r(e=>e));return eH(ek(r(e=>e.add(e.dFdx()))).sub(i),ek(r(e=>e.add(e.dFdy()))).sub(i)).mul(t)}),nq=eP(e=>{let{surf_pos:t,surf_norm:r,dHdxy:i}=e,s=t.dFdx().normalize(),a=t.dFdy().normalize().cross(r),n=r.cross(s),o=s.dot(a).mul(aq),l=o.sign().mul(i.x.mul(a).add(i.y.mul(n)));return o.abs().mul(r).sub(l).normalize()});
7class nj extends G{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(e){if(!0===e.material.wireframe)return aJ;let t=null!==this.scaleNode?this.scaleNode:1;return nq({surf_pos:az,surf_norm:aJ,dHdxy:nH({textureNode:this.textureNode,bumpScale:t})})}}let nX=ew(nj).setParameterLength(1,2),nQ=new Map;class nK extends O{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=nQ.get(e);return void 0===r&&(r=nm(e,t),nQ.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===nK.COLOR){let e=void 0!==t.color?this.getColor(r):eQ();i=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===nK.OPACITY){let e=this.getFloat(r);i=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===nK.SPECULAR_STRENGTH)i=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:ek(1);else if(r===nK.SPECULAR_INTENSITY){let e=this.getFloat(r);i=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===nK.SPECULAR_COLOR){let e=this.getColor(r);i=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===nK.ROUGHNESS){let e=this.getFloat(r);i=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===nK.METALNESS){let e=this.getFloat(r);i=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===nK.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===nK.NORMAL)t.normalMap?((i=nW(this.getTexture("normal"),this.getCache("normalScale","vec2"))).normalMapType=t.normalMapType,(t.normalMap.format==u.paN||t.normalMap.format==u.HO_||t.normalMap.format==u.OtU)&&(i.unpackNormalMode=u.IjV)):i=t.bumpMap?nX(this.getTexture("bump").r,this.getFloat("bumpScale")):aJ;else if(r===nK.CLEARCOAT){let e=this.getFloat(r);i=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===nK.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===nK.CLEARCOAT_NORMAL)i=t.clearcoatNormalMap?nW(this.getTexture(r),this.getCache(r+"Scale","vec2")):aJ;else if(r===nK.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===nK.SHEEN_ROUGHNESS){let e=this.getFloat(r);i=(i=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(r).a):e).clamp(1e-4,1)}else if(r===nK.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){let e=this.getTexture(r);i=e3(oN.x,oN.y,oN.y.negate(),oN.x).mul(e.rg.mul(2).sub(eH(1)).normalize().mul(e.b))}else i=oN;else if(r===nK.IRIDESCENCE_THICKNESS){let e=nh("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){let s=nh("0","float",t.iridescenceThicknessRange);i=e.sub(s).mul(this.getTexture(r).g).add(s)}else i=e}else if(r===nK.TRANSMISSION){let e=this.getFloat(r);i=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===nK.THICKNESS){let e=this.getFloat(r);i=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===nK.IOR)i=this.getFloat(r);else if(r===nK.LIGHT_MAP)i=t.lightMap?this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity")):eQ(0);else if(r===nK.AO)i=t.aoMap?this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1):ek(1);else if(r===nK.LINE_DASH_OFFSET)i=t.dashOffset?this.getFloat(r):ek(0);else{let t=this.getNodeType(e);i=this.getCache(r,t)}return i}}nK.ALPHA_TEST="alphaTest",nK.COLOR="color",nK.OPACITY="opacity",nK.SHININESS="shininess",nK.SPECULAR="specular",nK.SPECULAR_STRENGTH="specularStrength",nK.SPECULAR_INTENSITY="specularIntensity",nK.SPECULAR_COLOR="specularColor",nK.REFLECTIVITY="reflectivity",nK.ROUGHNESS="roughness",nK.METALNESS="metalness",nK.NORMAL="normal",nK.CLEARCOAT="clearcoat",nK.CLEARCOAT_ROUGHNESS="clearcoatRoughness",nK.CLEARCOAT_NORMAL="clearcoatNormal",nK.EMISSIVE="emissive",nK.ROTATION="rotation",nK.SHEEN="sheen",nK.SHEEN_ROUGHNESS="sheenRoughness",nK.ANISOTROPY="anisotropy",nK.IRIDESCENCE="iridescence",nK.IRIDESCENCE_IOR="iridescenceIOR",nK.IRIDESCENCE_THICKNESS="iridescenceThickness",nK.IOR="ior",nK.TRANSMISSION="transmission",
7nK.THICKNESS="thickness",nK.ATTENUATION_DISTANCE="attenuationDistance",nK.ATTENUATION_COLOR="attenuationColor",nK.LINE_SCALE="scale",nK.LINE_DASH_SIZE="dashSize",nK.LINE_GAP_SIZE="gapSize",nK.LINE_WIDTH="linewidth",nK.LINE_DASH_OFFSET="dashOffset",nK.POINT_SIZE="size",nK.DISPERSION="dispersion",nK.LIGHT_MAP="light",nK.AO="ao";let nY=eM(nK,nK.ALPHA_TEST),nZ=eM(nK,nK.COLOR),nJ=eM(nK,nK.SHININESS),n0=eM(nK,nK.EMISSIVE),n1=eM(nK,nK.OPACITY),n2=eM(nK,nK.SPECULAR),n3=eM(nK,nK.SPECULAR_INTENSITY),n4=eM(nK,nK.SPECULAR_COLOR),n5=eM(nK,nK.SPECULAR_STRENGTH),n6=eM(nK,nK.REFLECTIVITY),n8=eM(nK,nK.ROUGHNESS),n9=eM(nK,nK.METALNESS),n7=eM(nK,nK.NORMAL),oe=eM(nK,nK.CLEARCOAT),ot=eM(nK,nK.CLEARCOAT_ROUGHNESS),or=eM(nK,nK.CLEARCOAT_NORMAL),oi=eM(nK,nK.ROTATION),os=eM(nK,nK.SHEEN),oa=eM(nK,nK.SHEEN_ROUGHNESS),on=eM(nK,nK.ANISOTROPY),oo=eM(nK,nK.IRIDESCENCE),ol=eM(nK,nK.IRIDESCENCE_IOR),ou=eM(nK,nK.IRIDESCENCE_THICKNESS),od=eM(nK,nK.TRANSMISSION),oh=eM(nK,nK.THICKNESS),oc=eM(nK,nK.IOR),op=eM(nK,nK.ATTENUATION_DISTANCE),om=eM(nK,nK.ATTENUATION_COLOR),og=eM(nK,nK.LINE_SCALE),of=eM(nK,nK.LINE_DASH_SIZE),ob=eM(nK,nK.LINE_GAP_SIZE),oy=eM(nK,nK.LINE_WIDTH),ox=eM(nK,nK.LINE_DASH_OFFSET),oT=eM(nK,nK.POINT_SIZE),o_=eM(nK,nK.DISPERSION),ov=eM(nK,nK.LIGHT_MAP),oS=eM(nK,nK.AO),oN=tV(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))}),oR=eP(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class oA extends O{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===oA.OBJECT?this.updateType=w.OBJECT:e===oA.MATERIAL?this.updateType=w.RENDER:e===oA.FRAME?this.updateType=w.FRAME:e===oA.BEFORE_OBJECT?this.updateBeforeType=w.OBJECT:e===oA.BEFORE_MATERIAL?this.updateBeforeType=w.RENDER:e===oA.BEFORE_FRAME&&(this.updateBeforeType=w.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}oA.OBJECT="object",oA.MATERIAL="material",oA.FRAME="frame",oA.BEFORE_OBJECT="beforeObject",oA.BEFORE_MATERIAL="beforeMaterial",oA.BEFORE_FRAME="beforeFrame";let oE=(e,t)=>new oA(e,t).toStack(),oC=e=>oE(oA.OBJECT,e),ow=e=>oE(oA.FRAME,e);class oM 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.isContextAssign();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 oB=ew(oM).setParameterLength(2);class oU extends sI{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let i,s=null;if(t&&t.isStructTypeNode)i="struct",s=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count);else if(null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)){var a;a=e.itemSize,i=_.get(a),r=e.count}else i=t;super(e,i,r),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=M.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(0===this.bufferCount){let r=e.globalCache.getData(this.value);void 0===r&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return oB(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(M.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=i3(this.value),this._varying=iI(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(null!==this.structTypeNode)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(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 oF=(e,t=null,r=0)=>new oU(e,t,r),oL=new WeakMap,oP=new WeakMap,oD=new WeakMap;function oO(e,t){let r,i=Math.max(t.count,1);if(!0===t.isStorageInstancedBufferAttribute)r=oF(t,"mat4",i).element
7(i9);else if(16*i*4<=e.getUniformBufferLimit())r=sV(t.array,"mat4",i).element(i9);else{let e=oL.get(t);e||(e=new u.LuO(t.array,16,1),oL.set(t,e));let i=t.usage===u.Vnu?i5:i4;r=e5(i(e,"vec4",16,0),i(e,"vec4",16,4),i(e,"vec4",16,8),i(e,"vec4",16,12))}return r}let oI=te("vec3","vInstanceColor"),oV=eP(([e,t=null],r)=>{let i=!0===e.isStorageInstancedBufferAttribute,s=t&&!0===t.isStorageInstancedBufferAttribute,a=oO(r,e),n=null;!i&&16*Math.max(e.count,1)*4>r.getUniformBufferLimit()&&(n=oL.get(e));let o=null,l=null;if(t)if(s)o=oF(t,"vec3",Math.max(t.count,1)).element(i9);else{let e=oP.get(t);e||(e=new u.uWO(t.array,3),oP.set(t,e)),l=e,o=eQ((t.usage===u.Vnu?i5:i4)(e,"vec3",3,0))}(null!==n||null!==l)&&ow(()=>{null!==n&&(n.clearUpdateRanges(),n.updateRanges.push(...e.updateRanges),e.version!==n.version&&(n.version=e.version)),t&&null!==l&&(l.clearUpdateRanges(),l.updateRanges.push(...t.updateRanges),t.version!==l.version&&(l.version=t.version))});let d=a.mul(aI).xyz;if(aI.assign(d),r.needsPreviousData()){let t=r.object;oC(({object:t})=>{oD.get(t).previousInstanceMatrix.array.set(e.array)});let i=function(e,t,r){let i=oD.get(e);if(void 0===i){let s=t.clone();i={previousInstanceMatrix:s,node:oO(r,s)},oD.set(e,i)}return i.node}(t,e,r);aV.assign(i.mul(aV).xyz)}if(r.hasGeometryAttribute("normal")){let e=a2(aQ,a);aQ.assign(e)}null!==o&&oI.assign(o)},"void"),oG=eP(([e])=>{let{instanceMatrix:t,instanceColor:r}=e;oV(t,r)},"void"),ok=eP(([e,t])=>{let r=ez(sw(sO(e),0).x).toConst(),i=ez(t);return sO(e,eq(i.mod(r).toConst(),i.div(r).toConst()))}),oz=eP(([e,t])=>{let r=ez(sw(sO(e),0).x).toConst();return sO(e,eq(ez(t).mod(r).toConst(),ez(t).div(r).toConst())).x}),o$=te("vec4","vBatchColor"),oW=eP(([e],t)=>{let r=null===t.getDrawIndex()?i9:sr,i=oz(e._indirectTexture,ez(r)),s=e._matricesTexture,a=ez(sw(sO(s),0).x).toConst(),n=ek(i).mul(4).toInt().toConst(),o=n.mod(a).toConst(),l=n.div(a).toConst(),u=e5(sO(s,eq(o,l)),sO(s,eq(o.add(1),l)),sO(s,eq(o.add(2),l)),sO(s,eq(o.add(3),l))),d=e._colorsTexture;if(null!==d){let e=ok(d,i);o$.assign(e)}let h=e4(u);aI.assign(u.mul(aI));let c=aQ.div(eQ(h[0].dot(h[0]),h[1].dot(h[1]),h[2].dot(h[2]))),p=h.mul(c).xyz;aQ.assign(p),t.hasGeometryAttribute("tangent")&&nw.mulAssign(h)},"void"),oH=new WeakMap,oq=new WeakMap;function oj(e,t,r,i,s,a){let n=e.element(s.x),o=e.element(s.y),l=e.element(s.z),u=e.element(s.w),d=r.mul(t),h=tX(n.mul(a.x).mul(d),o.mul(a.y).mul(d),l.mul(a.z).mul(d),u.mul(a.w).mul(d));return i.mul(h).xyz}function oX(e,t,r,i,s,a,n){let o=e.element(a.x),l=e.element(a.y),u=e.element(a.z),d=e.element(a.w),h=tX(n.x.mul(o),n.y.mul(l),n.z.mul(u),n.w.mul(d));return{skinNormal:(h=s.mul(h).mul(i)).transformDirection(t).xyz,skinTangent:h.transformDirection(r).xyz}}function oQ(e,t,r,i,s){let a=e.skeleton,n=oq.get(a);if(void 0===n){a.update();let e=new Float32Array(a.boneMatrices);n={previousBoneMatrices:e,node:sV(e,"mat4",a.bones.length)},oq.set(a,n)}return oj(n.node,aV,t,r,i,s)}let oK=eP(([e],t)=>{let r=sA("skinIndex","uvec4"),i=sA("skinWeight","vec4"),s=nh("bindMatrix","mat4"),a=nh("bindMatrixInverse","mat4"),n=nc("skeleton.boneMatrices","mat4",e.skeleton.bones.length);if(oC(({object:e,frameId:t})=>{let r=e.skeleton;if(oH.get(r)!==t){oH.set(r,t);let e=oq.get(r);void 0!==e&&e.previousBoneMatrices.set(r.boneMatrices),r.update()}}
7),t.needsPreviousData()){let t=oQ(e,s,a,r,i);aV.assign(t)}let o=oj(n,aI,s,a,r,i);if(aI.assign(o),t.hasGeometryAttribute("normal")){let{skinNormal:e,skinTangent:o}=oX(n,aQ,nw,s,a,r,i);aQ.assign(e),t.hasGeometryAttribute("tangent")&&nw.assign(o)}},"void"),oY=eP(([e,t=null],r)=>{let i=oF(new u.uWO(e.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(i9).toVar(),s=oF(new u.uWO(new Uint32Array(e.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(i9).toVar(),a=oF(new u.uWO(e.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(i9).toVar(),n=tV(e.bindMatrix,"mat4"),o=tV(e.bindMatrixInverse,"mat4"),l=sV(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length),d=e.skeleton;if(oC(({frameId:e})=>{if(oH.get(d)!==e){oH.set(d,e);let t=oq.get(d);void 0!==t&&t.previousBoneMatrices.set(d.boneMatrices),d.update()}}),r.needsPreviousData()){let t=oQ(e,n,o,s,a);aV.assign(t)}let h=oj(l,i,n,o,s,a);if(null!==t&&t.assign(h),r.hasGeometryAttribute("normal")){let{skinNormal:e,skinTangent:t}=oX(l,aQ,nw,n,o,s,a);aQ.assign(e),r.hasGeometryAttribute("tangent")&&nw.assign(t)}return h});class oZ extends O{static get type(){return"LoopNode"}constructor(e=[]){super("void"),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]=sm(i,s)}let i=e.addStack(),s=this.params[this.params.length-1](r);t.returnsNode=s.context({nodeLoop:s}),t.stackNode=i;let a=this.params[0];if(!0!==a.isNode&&"function"==typeof a.update){let e=eP(this.params[0].update)(r);t.updateNode=e.context({nodeLoop:e})}return e.removeStack(),t}setup(e){this.getProperties(e),e.fnCall&&(e.getDataFromNode(e.fnCall.shaderNode).hasLoop=!0)}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,a=r[i],n=!1,o=null,l=null,d=null,h=null,c=null,p=null;if(a.isNode?"bool"===a.getNodeType(e)?(n=!0,h="bool",l=a.build(e,h)):(h="int",d=this.getVarName(i),o="0",l=a.build(e,h),c="<"):(h=a.type||"int",d=a.name||this.getVarName(i),o=a.start,l=a.end,c=a.condition,p=a.update,"number"==typeof o?o=e.generateConst(h,o):o&&o.isNode&&(o=o.build(e,h)),"number"==typeof l?l=e.generateConst(h,l):l&&l.isNode&&(l=l.build(e,h)),void 0!==o&&void 0===l?(o+=" - 1",l="0",c=">="):void 0!==l&&void 0===o&&(o="0",c="<"),void 0===c&&(c=Number(o)>Number(l)?">=":"<")),n)s=`while ( ${l} )`;else{let r,i=o,a=l,n=()=>c.includes("<")?"+=":"-=";if(null!=p)switch(typeof p){case"function":r=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":r=d+" "+n()+" "+e.generateConst(h,p);break;case"string":r=d+" "+p;break;default:p.isNode?r=d+" "+n()+" "+p.build(e):((0,u.z3S)("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),r="break /* invalid update */")}else r=d+" "+(p="int"===h||"uint"===h?c.includes("<")?"++":"--":n()+" 1.");let m=e.getVar(h,d)+" = "+i,g=d+" "+c+" "+a;s=`for ( ${m}; ${g}; ${r} )`}e.addFlowCode((0===i?"\n":"")+e.tab+s+" {\n\n").addFlowTab()}let s=i.build(e,"void");t.returnsNode.build(e,"void"),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();e.addFlowTab()}}let oJ=(...e)=>new oZ(eC(e,"int")).toStack(),o0=()=>sm("break").toStack(),o1=new WeakMap,o2=new u.IUQ,o3=new WeakMap,o4=eP(({bufferMap:e,influence:t,stride:r,width:i,depth:s,offset:a})=>{let n=ez(i8).mul(r).add(a),o=n.div(i);return sO(e,eq(n.sub(o.mul(i)),o)).depth(s).xyz.mul(t)}),o5=eP(([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,a=void 0!==s?s.length:0;if(0===a)return;let n=o3.get(e);(void 0===n||n.count!==a)&&(n={base:tV(1),influences:e.morphTargetInfluences?sz(e.morphTargetInfluences,"float"):null,count:a},o3.set(e,n));let{base:o,influences:l}=n,{texture:d,stride:h,size:c}=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,a=void 0!==s?s.length:0,n=o1.get(e);if(void 0===n||n.count!==a){void 0!==n&&n.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*a),m=new u.rFo(p,h,c,a);m.type=u.RQf,m.needsUpdate=!0;let g=4*d;for(let e=0;e<a;e++){let a=s[e],n=o[e],u=l[e],d=h*c*4*e;for(let e=0;e<a.count;e++){let s=e*g;!0===t&&(o2.fromBufferAttribute(a,e),p[d+s+0]=o2.x,p[d+s+1]=o2.y,p[d+s+2]=o2.z,p[d+s+3]=0),!0===r&&(o2.fromBufferAttribute(n,e),p[d+s+4]=o2.x,p[d+s+5]=o2.y,p[d+s+6]=o2.z,p[d+s+7]=0),!0===i&&(o2.fromBufferAttribute(u,e),p[d+s+8]=o2.x,p[d+s+9]=o2.y,p[d+s+10]=o2.z,p[d+s+11]=4===u.itemSize?o2.w:1)}}n={count:a,texture:m,stride:d,size:new u.I9Y(h,c)},o1.set(e,n),e.addEventListener("dispose",function t(){m.dispose(),o1.delete(e),e.removeEventListener("dispose",t)})}return n}(t);!0===r&&aI.mulAssign(o),!0===i&&aQ.mulAssign(o);let p=ez(c.width);oJ(a,({i:t})=>{let s=ek(0).toVar();e.count>1&&null!==e.morphTexture&&void 0!==e.morphTexture?s.assign(sO(e.morphTexture,eq(ez(t).add(1),ez(i9))).r):s.assign(l.element(t).toVar()),eI(s.notEqual(0),()=>{!0===r&&aI.addAssign(o4({bufferMap:d,influence:s,stride:h,width:p,depth:t,offset:ez(0)})),!0===i&&aQ.addAssign(o4({bufferMap:d,influence:s,stride:h,width:p,depth:t,offset:ez(1)}))})}),oC(({object:e})=>{let{base:t,influences:r}=n;e.geometry.morphTargetsRelative?t.value=1:t.value=1-e.morphTargetInfluences.reduce((e,t)=>
7e+t,0),r&&(r.array=e.morphTargetInfluences,r.update())})},"void");class o6 extends O{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class o8 extends o6{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class o9 extends iS{static get type(){return"LightingContextNode"}constructor(e,t=null,r=[],i=null,s=null){super(e),this.lightingModel=t,this.materialLightings=r,this.backdropNode=i,this.backdropAlphaNode=s,this._value=null}getContext(){let{materialLightings:e,backdropNode:t,backdropAlphaNode:r}=this,i=eQ().toVar("directDiffuse"),s=eQ().toVar("directSpecular"),a=eQ().toVar("indirectDiffuse"),n=eQ().toVar("indirectSpecular");return{radiance:eQ().toVar("radiance"),irradiance:eQ().toVar("irradiance"),iblIrradiance:eQ().toVar("iblIrradiance"),ambientOcclusion:ek(1).toVar("ambientOcclusion"),reflectedLight:{directDiffuse:i,directSpecular:s,indirectDiffuse:a,indirectSpecular:n},materialLightings:e,backdrop:t,backdropAlpha:r}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}let o7=ew(o9);class le extends o6{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let lt=new u.I9Y;class lr extends sL{static get type(){return"ViewportTextureNode"}constructor(e=sj,t=null,r=null){let i=null;null===r?((i=new u.Pem).minFilter=u.$_I,r=i):i=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=i,this.isOutputTextureNode=!0,this.updateBeforeType=w.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),null===e)return t;if(!1===r.has(e)){let i=t.clone();r.set(e,i)}return r.get(e)}updateReference(e){let t=e.renderer,r=t.getRenderTarget(),i=t.getCanvasTarget();return this.value=this.getTextureForReference(r||i),this.value}updateBefore(e){let t=e.renderer,r=t.getRenderTarget(),i=t.getCanvasTarget(),s=r||i;null===s?t.getDrawingBufferSize(lt):s.getDrawingBufferSize?s.getDrawingBufferSize(lt):lt.set(s.width,s.height);let a=this.getTextureForReference(s);(a.image.width!==lt.width||a.image.height!==lt.height)&&(a.image.width=lt.width,a.image.height=lt.height,a.needsUpdate=!0);let n=a.generateMipmaps;a.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(a),a.generateMipmaps=n}clone(){let e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}let li=ew(lr).setParameterLength(0,3),ls=ew(lr,null,null,{generateMipmaps:!0}).setParameterLength(0,3),la=ls(),ln=(e=sj,t=null)=>la.sample(e,t),lo=null;class ll extends lr{static get type(){return"ViewportDepthTextureNode"}constructor(e=sj,t=null,r=null){null===r&&(null===lo&&(lo=new u.VCu),r=lo),super(e,t,r)}}let lu=ew(ll).setParameterLength(0,3);class ld extends O{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===ld.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){let{scope:t}=this,r=this.valueNode,i=null;return t===ld.DEPTH_BASE?null!==r&&(i=lb().assign(r)):t===ld.DEPTH?i=e.isPerspectiveCamera?lp(az.z,an,ao):lh(az.z,an,ao):t===ld.LINEAR_DEPTH&&(i=null!==r?e.isPerspectiveCamera?lh(lg(r,an,ao),an,ao):r:lh(az.z,an,ao)),i}}ld.DEPTH_BASE="depthBase",ld.DEPTH="depth",ld.LINEAR_DEPTH="linearDepth";let lh=(e,t,r)=>e.add(t).div(t.sub(r)),lc=eP(([e,t,r],i)=>!0===i.renderer.reversedDepthBuffer?r.sub(t).mul(e).sub(r):t.sub(r).mul(e).sub(t)),lp=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),lm=(e,t,r)=>t.mul(e.add(r)).div(e.mul(t.sub(r))),lg=eP(([e,t,r],i)=>!0===i.renderer.reversedDepthBuffer?t.mul(r).div(t.sub(r).mul(e).sub(t)):t.mul(r).div(r.sub(t).mul(e).sub(r))),lf=(e,t,r)=>{t=t.max(1e-6).toVar();let i=rS(e.negate().div(t)),s=rS(r.div(t));return i.div(s)},lb=ew(ld,ld.DEPTH_BASE),ly=eM(ld,ld.DEPTH),lx=ew(ld,ld.LINEAR_DEPTH).setParameterLength(0,1),lT=lx(lu());ly.assign=e=>lb(e);class l_ extends O{static get type(){return"ClippingNode"}constructor(e=l_.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);let{intersectionPlanes:t,unionPlanes:r}=e.clippingContext;return(this.hardwareClipping=e.hardwareClipping,this.scope===l_.ALPHA_TO_COVERAGE)?this.setupAlphaToCoverage(t,r):this.scope===l_.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(t,r)}setupAlphaToCoverage(e,t){return eP(()=>{let r=ek().toVar("distanceToPlane"),i=ek().toVar("distanceToGradient"),s=ek(1).toVar("clipOpacity"),a=t.length;if(!1===this.hardwareClipping&&a>0){let e=sz(t).setGroup(tD);oJ(a,({i:t})=>{let a=e.element(t);r.assign(az.dot(a.xyz).negate().add(a.w)),i.assign(r.fwidth().div(2)),s.mulAssign(im(i.negate(),i,r))})}let n=e.length;if(n>0){let t=sz(e).setGroup(tD),a=ek(1).toVar("intersectionClipOpacity");oJ(n,({i:e})=>{let s=t.element(e);r.assign(az.dot(s.xyz).negate().add(s.w)),i.assign(r.fwidth().div(2)),a.mulAssign(im(i.negate(),i,r).oneMinus())}),s.mulAssign(a.oneMinus())}tt.a.mulAssign(s),tt.a.equal(0).discard()})()}setupDefault(e,t){return eP(()=>{let r=t.length;if(!1===this.hardwareClipping&&r>0){let e=sz(t).setGroup(tD);oJ(r,({i:t})=>{let r=e.element(t);az.dot(r.xyz).greaterThan(r.w).discard()})}let i=e.length;if(i>0){let t=sz(e).setGroup(tD),r=eW(!0).toVar("clipped");oJ(i,({i:e})=>{let i=t.element(e);r.assign(az.dot(i.xyz).greaterThan(i.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){let r=e.length;return t.enableHardwareClipping(r),eP(()=>{let i=sz(e).setGroup(tD),s=sW(t.getClipDistance());oJ(r,({i:e})=>
vendor: 5,533 bytes, line 7
7{let t=i.element(e),r=az.dot(t.xyz).sub(t.w).negate();s.element(e).assign(r)})})()}}l_.ALPHA_TO_COVERAGE="alphaToCoverage",l_.DEFAULT="default",l_.HARDWARE="hardware";let lv=eP(([e])=>rw(tK(1e4,rM(tK(17,e.x).add(tK(.1,e.y)))).mul(tX(.1,rz(rM(tK(13,e.y).add(e.x))))))),lS=eP(([e])=>lv(eH(lv(e.xy),e.z))),lN=eP(([e])=>{let t=r3(rW(rj(e.xyz)),rW(rX(e.xyz))),r=ek(1).div(ek(.05).mul(t)).toVar("pixScale"),i=eH(r_(rA(rS(r))),r_(rE(rS(r)))),s=eH(lS(rA(i.x.mul(e.xyz))),lS(rA(i.y.mul(e.xyz)))),a=rw(rS(r)),n=tX(tK(a.oneMinus(),s.x),tK(a,s.y)),o=r2(a,a.oneMinus()),l=eQ(n.mul(n).div(tK(2,o).mul(tQ(1,o))),n.sub(tK(.5,o)).div(tQ(1,o)),tQ(1,tQ(1,n).mul(tQ(1,n)).div(tK(2,o).mul(tQ(1,o)))));return ih(n.lessThan(o.oneMinus()).select(n.lessThan(o).select(l.x,l.y),l.z),1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class lR extends sR{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 lA=(e=0)=>new lR(e);class lE 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.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.maskShadowNode=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,this.contextNode=null}_getNodeChildren(){let e=[];for(let t of Object.getOwnPropertyNames(this)){if(!0===t.startsWith("_"))continue;let r=this[t];r&&!0===r.isNode&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){let e=[];for(let{property:t,childNode:r}of this._getNodeChildren())e.push(y(t.slice(0,-4)),r.getCacheKey());return this.type+x(e)}build(e){this.setup(e)}setupObserver(e){return new m(e)}setup(e){let t;e.context.setupNormal=()=>iD(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=this.setupVertex(e),a=iD(this.vertexNode||s,"VERTEX");e.context.clipSpace=a,e.stack.outputNode=a,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let n=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.setupAmbientOcclusion(e),this.setupVariants(e);let s=this.setupLighting(e);null!==n&&e.stack.addToStack(n);let a=eJ(s,tt.a).max(0);t=this.setupOutput(e,a),t_.assign(t);let o=null!==this.outputNode;if(o&&(t=this.outputNode),e.context.getOutput&&(t=e.context.getOutput(t,e)),null!==i){let e=r.getMRT(),i=this.mrtNode;null!==e?(o&&t_.assign(t),t=e,null!==i&&(t=e.merge(i))):null!==i&&(t=i)}}else{let r=this.fragmentNode;!0!==r.isOutputStructNode&&(r=r.convert(e.getOutputType())),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.currentSamples;this.alphaToCoverage&&t>1?i=new l_(l_.ALPHA_TO_COVERAGE):e.stack.addToStack(new l_)}return i}setupHardwareClipping(e){if(e.hardwareClipping=!1,null===e.clippingContext)return;let t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(new l_(l_.HARDWARE)),e.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?lf(az.z,an,ao):lh(az.z,an,ao))}null!==i&&ly.assign(i).toStack()}setupPositionView(){return aU.mul(aI).xyz}setupModelViewProjection(){return al.mul(az)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),oR}setupPosition(e){let{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&o5(t),!0===t.isSkinnedMesh&&oK(t),this.displacementMap){let e=nm("displacementMap","texture"),t=nm("displacementScale","float"),r=nm("displacementBias","float");aI.addAssign(aQ.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&oW(t),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&oG(t),null!==this.positionNode&&aI.assign(iD(this.positionNode,"POSITION","vec3")),aI}setupDiffuseColor(e){let{object:t,geometry:r}=e;null!==this.maskNode&&eW(this.maskNode).not().discard();let i=this.colorNode?eJ(this.colorNode):nZ;!0===this.vertexColors&&r.hasAttribute("color")&&(i=i.mul(lA())),t.instanceColor&&(i=oI.mul(i)),t.isBatchedMesh&&t._
7colorsTexture&&(i=o$.mul(i)),tt.assign(i);let s=this.opacityNode?ek(this.opacityNode):n1;tt.a.assign(tt.a.mul(s));let a=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(a=null!==this.alphaTestNode?ek(this.alphaTestNode):nY,!0===this.alphaToCoverage?(tt.a=im(a,a.add(rZ(tt.a)),tt.a),tt.a.lessThanEqual(0).discard()):tt.a.lessThanEqual(a).discard()),!0===this.alphaHash&&tt.a.lessThan(lN(aI)).discard(),e.isOpaque()&&tt.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?eQ(0):tt.rgb}setupNormal(){return this.normalNode?eQ(this.normalNode):n7}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?nm("envMap","cubeTexture"):nm("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new le(ov)),t}setupMaterialLightings(e){let t=[];if(!1===e.renderer.lighting.enabled)return t;let r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);let i=this.setupLightMap(e);return i&&i.isLightingNode&&t.push(i),e.context.ambientOcclusion&&t.push(new o8(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;null===t&&e.material.aoMap&&(t=oS),e.context.getAO&&(t=e.context.getAO(t,e)),null!==t&&(tB.assign(t),e.context.ambientOcclusion=tB)}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:r,backdropAlphaNode:i,emissiveNode:s}=this,a=!0===this.lights||null!==this.lightsNode,n=!0===this.lights?this.setupMaterialLightings(e):[],o=a?this.lightsNode||e.lightsNode:null,l=this.setupOutgoingLight(e);return o&&(n.length>0||o.getScope().hasLights)?l=o7(o,this.setupLightingModel(e)||null,n,r,i):null!==r&&(l=eQ(null!==i?id(l,r,i):r)),(s&&!0===s.isNode||t.emissive&&!0===t.emissive.isColor)&&(ti.assign(eQ(s||n0)),l=l.add(ti)),l}setupFog(e,t){let r=e.fogNode;return r&&(t_.assign(t),t=eJ(r.toVar())),t}setupPremultipliedAlpha(e,t){return sf(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);for(let{property:t,childNode:i}of(r.inputNodes={},this._getNodeChildren()))r.inputNodes[t]=i.toJSON(e).uuid;function i(e){let t=[];for(let r in e){let i=e[r];delete i.metadata,t.push(i)}return t}if(t){let t=i(e.textures),s=i(e.images),a=i(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),a.length>0&&(r.nodes=a)}return r}copy(e){let t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(let r in t)if(void 0!==t[r].set&&void 0!==e[r]){let t=e[r];this[r]&&void 0!==this[r].copy?this[r].copy(t):this[r]=t}for(let t in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(t)&&void 0!==this[t]&&void 0!==e[t]){let r=e[t];this[t]&&void 0!==this[t].copy?this[t].copy(r):this[t]=r}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(e=>e.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}}let lC=new u.mrM;class lw extends lE{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(lC),this.setValues(e)}}let lM=new u.Fvt;class lB extends lE{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(lM),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?ek(this.offsetNode):ox,t=this.dashScaleNode?ek(this.dashScaleNode):og,r=this.dashSizeNode?ek(this.dashSizeNode):of,i=this.gapSizeNode?ek(this.gapSizeNode):ob;tv.assign(r),tS.assign(i);let s=iI(sA("lineDistance").mul(t));(e?s.add(e):s).mod(tv.add(tS)).greaterThan(tv).discard()}}let lU=te("vec3","worldStart"),lF=te("vec3","worldEnd"),lL=te("float","lineDistance"),lP=te("vec4","worldPos"),lD=eP(({start:e,end:t})=>
7{let r=al.element(2).element(2),i=al.element(3).element(2);return r.greaterThan(0).select(i.negate().div(r.add(1)),i.mul(-.5).div(r)).sub(e.z).div(t.z.sub(e.z))},{start:"vec4",end:"vec4",return:"float"}),lO=eP(({p1:e,p2:t,p3:r,p4:i})=>{let s=e.sub(r),a=i.sub(r),n=t.sub(e),o=s.dot(a),l=a.dot(n),u=s.dot(n),d=a.dot(a),h=n.dot(n).mul(d).sub(l.mul(l)),c=o.mul(l).sub(u.mul(d)).div(h).clamp(),p=o.add(l.mul(c)).div(d).clamp();return eH(c,p)},{p1:"vec3",p2:"vec3",p3:"vec3",p4:"vec3",return:"vec2"});eP(({material:e})=>{let t,r,i=e._useDash,s=e._useWorldUnits,a=sA("instanceStart"),n=sA("instanceEnd"),o=eJ(aU.mul(eJ(a,1))).toVar("start"),l=eJ(aU.mul(eJ(n,1))).toVar("end");i&&(t=ek(sA("instanceDistanceStart")).toVar("distanceStart"),r=ek(sA("instanceDistanceEnd")).toVar("distanceEnd")),s&&(lU.assign(o.xyz),lF.assign(l.xyz));let u=sK.z.div(sK.w);if(eI(al.element(2).element(3).equal(-1),()=>{eI(o.z.lessThan(0).and(l.z.greaterThan(0)),()=>{let e=lD({start:o,end:l});l.assign(eJ(id(o.xyz,l.xyz,e),l.w)),i&&r.assign(id(t,r,e))}).ElseIf(l.z.lessThan(0).and(o.z.greaterThanEqual(0)),()=>{let e=lD({start:l,end:o});o.assign(eJ(id(l.xyz,o.xyz,e),o.w)),i&&t.assign(id(r,t,e))})}),i){let i=e.dashScaleNode?ek(e.dashScaleNode):og,s=e.offsetNode?ek(e.offsetNode):ox,a=aO.y.lessThan(.5).select(i.mul(t),i.mul(r));a=a.add(s),lL.assign(a)}let d=al.mul(o),h=al.mul(l),c=d.xyz.div(d.w),p=h.xyz.div(h.w),m=p.xy.sub(c.xy).toVar();m.x.assign(m.x.mul(u)),m.assign(m.normalize());let g=eJ().toVar();if(s){let e=l.xyz.sub(o.xyz).normalize(),t=id(o.xyz,l.xyz,.5).normalize(),r=e.cross(t).normalize(),s=e.cross(r);lP.assign(aO.y.lessThan(.5).select(o,l));let a=oy.mul(.5);lP.addAssign(eJ(aO.x.lessThan(0).select(r.mul(a),r.mul(a).negate()),0)),i||(lP.addAssign(eJ(aO.y.lessThan(.5).select(e.mul(a).negate(),e.mul(a)),0)),lP.addAssign(eJ(s.mul(a),0)),eI(aO.y.greaterThan(1).or(aO.y.lessThan(0)),()=>{lP.subAssign(eJ(s.mul(2).mul(a),0))})),g.assign(al.mul(lP));let n=eQ().toVar();n.assign(aO.y.lessThan(.5).select(c,p)),g.z.assign(n.z.mul(g.w))}else{let e=eH(m.y,m.x.negate()).toVar("offset");m.x.assign(m.x.div(u)),e.x.assign(e.x.div(u)),e.assign(aO.x.lessThan(0).select(e.negate(),e)),eI(aO.y.lessThan(0),()=>{e.assign(e.sub(m))}).ElseIf(aO.y.greaterThan(1),()=>{e.assign(e.add(m))}),e.assign(e.mul(oy)),e.assign(e.div(sK.w.div(sq))),g.assign(aO.y.lessThan(.5).select(d,h)),e.assign(e.mul(g.w)),g.assign(g.add(eJ(e,0,0)))}return g})(),eP(({material:e,renderer:t})=>{let r=e._useAlphaToCoverage,i=e._useDash,s=e._useWorldUnits,a=sE();if(i){let t=e.dashSizeNode?ek(e.dashSizeNode):of,r=e.gapSizeNode?ek(e.gapSizeNode):ob;tv.assign(t),tS.assign(r),a.y.lessThan(-1).or(a.y.greaterThan(1)).discard(),lL.mod(tv.add(tS)).greaterThan(tv).discard()}let n=ek(1).toVar("alpha");if(s){let e=lP.xyz.normalize().mul(1e5),s=lF.sub(lU),a=lO({p1:lU,p2:lF,p3:eQ(0,0,0),p4:e}),o=lU.add(s.mul(a.x)),l=e.mul(a.y),u=o.sub(l).length().div(oy);if(!i)if(r&&t.currentSamples>0){let e=u.fwidth();n.assign(im(e.negate().add(.5),e.add(.5),u).oneMinus())}else u.greaterThan(.5).discard()}else if(r&&t.currentSamples>0){let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1)),r=e.mul(e).add(t.mul(t)),i=ek(r.fwidth()).toVar("dlen");eI(a.y.abs().greaterThan(1),()=>{n.assign(im(i.oneMinus(),i.add(1),r).oneMinus())})}else eI(a.y.abs().greaterThan(1),()=>{let e=a.x,t=a.y.greaterThan(0).select(a.y.sub(1),a.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()});return n})();let lI=new u.qBx;class lV extends lE{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(lI),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?ek(this.opacityNode):n1;tt.assign(iH(eJ(nG(aJ),e),u.er$))}}let lG=eP(([e=ak])=>eH(e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5))),lk=eP(([e=sE()])=>{let t=e.x.sub(.5).mul(2*Math.PI),r=e.y.sub(.5).mul(Math.PI),i=r.cos(),s=i.mul(t.cos());return eQ(s,r.sin(),i.mul(t.sin()))});class lz extends u.O0B{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;let r={width:e,height:e,depth:1};this.texture=new u.b4q([r,r,r,r,r,r]),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){let r=t.minFilter,i=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace
7=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),a=lG(ak),n=new lE;n.colorNode=sD(t,a,0),n.side=u.hsX,n.blending=u.XIg;let o=new u.eaF(s,n),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.generateMipmaps=i,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,r=!0,i=!0){let s=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,r,i);e.setRenderTarget(s)}}let l$=new WeakMap;class lW extends G{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=nl(null);let t=new u.b4q;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=w.RENDER}updateBefore(e){let{renderer:t,material:r}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){let e=i.isTextureNode?i.value:r[i.property];if(e&&e.isTexture){let r=e.mapping;if(r===u.wfO||r===u.uV5){if(l$.has(e)){let t=l$.get(e);lq(t,e.mapping),this._cubeTexture=t}else{var s;let r=e.image;if(null!=(s=r)&&s.height>0){let i=new lz(r.height);i.fromEquirectangularTexture(t,e),lq(i.texture,e.mapping),this._cubeTexture=i.texture,l$.set(e,i.texture),e.addEventListener("dispose",lH)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function lH(e){let t=e.target;t.removeEventListener("dispose",lH);let r=l$.get(t);void 0!==r&&(l$.delete(t),r.dispose())}function lq(e,t){t===u.wfO?e.mapping=u.hy7:t===u.uV5&&(e.mapping=u.xFO)}let lj=ew(lW).setParameterLength(1);class lX extends o6{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=lj(this.envNode)}}class lQ extends o6{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=ek(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class lK{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class lY extends lK{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,r=e.reflectedLight,i=e.irradianceLightMap;r.indirectDiffuse.assign(eJ(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign(eJ(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(tt.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(id(i.rgb,i.rgb.mul(s.rgb),n5.mul(n6)));break;case u.KRh:i.rgb.assign(id(i.rgb,s.rgb,n5.mul(n6)));break;case u.XrR:i.rgb.addAssign(s.rgb.mul(n5.mul(n6)));break;default:(0,u.R8M)("BasicLightingModel: Unsupported .combine value:",t.combine)}}}let lZ=new u.V9B;class lJ extends lE{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lZ),this.setValues(e)}setupNormal(){return aj(aY)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new lX(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lQ(ov)),t}setupOutgoingLight(){return tt.rgb}setupLightingModel(){return new lY}}let l0=eP(({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))}),l1=eP(e=>e.diffuseColor.mul(1/Math.PI)),l2=eP(({dotNH:e})=>tT.mul(ek(.5)).add(1).mul(ek(1/Math.PI)).mul(e.pow(tT))),l3=eP(({lightDirection:e})=>{let t=e.add(a$).normalize(),r=aJ.dot(t).clamp(),i=l0({f0:tb,f90:1,dotVH:a$.dot(t).clamp()}),s=ek(.25),a=l2({dotNH:r});return i.mul(s).mul(a)});class l4 extends lY{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){let i=aJ.dot(e).clamp().mul(t);r.directDiffuse.addAssign(i.mul(l1({diffuseColor:tt.rgb}))),!0===this.specular&&r.directSpecular.addAssign(i.mul(l3({lightDirection:e})).mul(n5))}indirect(e){let{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(l1({diffuseColor:tt}))),i.indirectDiffuse.mulAssign(t)}}let l5=new u.G_z;class l6 extends lE{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(l5),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new lX(t):null}setupLightingModel(){return new l4(!1)}}let l8=new u.tXL;class l9 extends lE{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(l8),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new lX(t):null}setupLightingModel(){return new l4}setupVariants(){let e=(this.shininessNode?ek(this.shininessNode):nJ).max(1e-4);tT.assign(e);let t=this.specularNode||n2;tb.assign(t)}}let l7=eP(e=>{if(!1===e.geometry.hasAttribute("normal"))return ek(0);let t=aY.dFdx().abs().max(aY.dFdy().abs());return t.x.max(t.y).max(t.z)}),ue=eP(e=>{let{roughness:t}=e,r=l7(),i=t.max(.0525);return(i=i.add(r)).min(1)}),ut=eP(({alpha:e,dotNL:t,dotNV:r})=>{let i=e.pow2(),s=t.mul(i.add(i.oneMinus().mul(r.pow2())).sqrt()),a=r.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt());return tY(.5,s.add(a).max(rd))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),ur=eP(({alphaT:e,alphaB:t,dotTV:r,dotBV:i,dotTL:s,dotBL:a,dotNV:n,dotNL:o})=>{let l=o.mul(eQ(e.mul(r),t.mul(i),n).length()),u=n.mul(eQ(e.mul(s),t.mul(a),o).length());return tY(.5,l.add(u).max(rd))}).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"}]}),ui=eP(({alpha:e,dotNH:t})=>{let r=e.pow2(),i=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(i.pow2()).mul(1/Math.PI)}
vendor: 2,185 bytes, line 7
7).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),us=ek(1/Math.PI),ua=eP(({alphaT:e,alphaB:t,dotNH:r,dotTH:i,dotBH:s})=>{let a=e.mul(t),n=eQ(t.mul(i),e.mul(s),a.mul(r)),o=n.dot(n),l=a.div(o);return us.mul(a.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"}]}),un=eP(({lightDirection:e,f0:t,f90:r,roughness:i,f:s,normalView:a=aJ,USE_IRIDESCENCE:n,USE_ANISOTROPY:o})=>{let l,u,d=i.pow2(),h=e.add(a$).normalize(),c=a.dot(e).clamp(),p=a.dot(a$).clamp(),m=a.dot(h).clamp(),g=l0({f0:t,f90:r,dotVH:a$.dot(h).clamp()});if(ev(n)&&(g=td.mix(g,s)),ev(o)){let t=tg.dot(e),r=tg.dot(a$),i=tg.dot(h),s=tf.dot(e),a=tf.dot(a$),n=tf.dot(h);l=ur({alphaT:tp,alphaB:d,dotTV:r,dotBV:a,dotTL:t,dotBL:s,dotNV:p,dotNL:c}),u=ua({alphaT:tp,alphaB:d,dotNH:m,dotTH:i,dotBH:n})}else l=ut({alpha:d,dotNL:c,dotNV:p}),u=ui({alpha:d,dotNH:m});return g.mul(l).mul(u)}),uo=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,
vendor: 3,209 bytes, line 7
714942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),ul=null,uu=eP(({roughness:e,dotNV:t})=>{null===ul&&((ul=new u.GYF(uo,16,16,u.paN,u.ix0)).name="DFG_LUT",ul.minFilter=u.k6q,ul.magFilter=u.k6q,ul.wrapS=u.ghU,ul.wrapT=u.ghU,ul.generateMipmaps=!1,ul.needsUpdate=!0);let r=eH(e,t);return sD(ul,r).rg}),ud=eP(({lightDirection:e,f0:t,f90:r,roughness:i,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:n})=>{let o=un({lightDirection:e,f0:t,f90:r,roughness:i,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:n}),l=aJ.dot(e).clamp(),u=uu({roughness:i,dotNV:aJ.dot(a$).clamp()}),d=uu({roughness:i,dotNV:l}),h=t.mul(u.x).add(r.mul(u.y)),c=t.mul(d.x).add(r.mul(d.y)),p=u.x.add(u.y),m=d.x.add(d.y),g=ek(1).sub(p),f=ek(1).sub(m),b=t.add(t.oneMinus().mul(.047619)),y=h.mul(c).mul(b).div(ek(1).sub(g.mul(f).mul(b).mul(b)).add(rd)),x=g.mul(f),T=y.mul(x);return o.add(T)}),uh=eP(e=>{let{dotNV:t,specularColor:r,specularF90:i,roughness:s}=e,a=uu({dotNV:t,roughness:s});return r.mul(a.x).add(i.mul(a.y))}),uc=eP(({f:e,f90:t,dotVH:r})=>{let i=r.oneMinus().saturate(),s=i.mul(i),a=i.mul(s,s).clamp(0,.9999);return e.sub(eQ(t).mul(a)).div(a.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),up=eP(({roughness:e,dotNH:t})=>{let r=e.pow2(),i=ek(1).div(r),s=t.pow2().oneMinus().max(.0078125);return ek(2).add(i).mul(s.pow(i.mul(.5))).div(2*Math.PI)}
vendor: 4,203 bytes, line 7
7).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),um=eP(({dotNV:e,dotNL:t})=>ek(1).div(ek(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),ug=eP(({lightDirection:e})=>{let t=e.add(a$).normalize(),r=aJ.dot(e).clamp(),i=aJ.dot(a$).clamp(),s=up({roughness:tu,dotNH:aJ.dot(t).clamp()}),a=um({dotNV:i,dotNL:r});return tl.mul(s).mul(a)}),uf=eP(({N:e,V:t,roughness:r})=>{let i=eH(r,e.dot(t).saturate().oneMinus().sqrt());return i.assign(i.mul(.984375).add(.0078125)),i}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),ub=eP(({f:e})=>{let t=e.length();return r3(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),uy=eP(({v1:e,v2:t})=>{let r=e.dot(t),i=r.abs().toVar(),s=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),a=i.add(4.1616724).mul(i).add(3.417594).toVar(),n=s.div(a),o=r.greaterThan(0).select(n,r3(r.mul(r).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(n));return e.cross(t).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),ux=eP(({N:e,V:t,P:r,mInv:i,p0:s,p1:a,p2:n,p3:o})=>{let l=a.sub(s).toVar(),u=o.sub(s).toVar(),d=l.cross(u),h=eQ().toVar();return eI(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(e4(l,u,e).transpose()).toVar(),c=d.mul(s.sub(r)).normalize().toVar(),p=d.mul(a.sub(r)).normalize().toVar(),m=d.mul(n.sub(r)).normalize().toVar(),g=d.mul(o.sub(r)).normalize().toVar(),f=eQ(0).toVar();f.addAssign(uy({v1:c,v2:p})),f.addAssign(uy({v1:p,v2:m})),f.addAssign(uy({v1:m,v2:g})),f.addAssign(uy({v1:g,v2:c})),h.assign(eQ(ub({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"}]}),uT=1/6,u_=e=>tK(uT,tK(e,tK(e,e.negate().add(3)).sub(3)).add(1)),uv=e=>tK(uT,tK(e,tK(e,tK(3,e).sub(6))).add(4)),uS=e=>tK(uT,tK(e,tK(e,tK(-3,e).add(3)).add(3)).add(1)),uN=e=>tK(uT,ie(e,3)),uR=e=>u_(e).add(uv(e)),uA=e=>uS(e).add(uN(e)),uE=e=>tX(-1,uv(e).div(u_(e).add(uv(e)))),uC=e=>tX(1,uN(e).div(uS(e).add(uN(e)))),uw=(e,t,r)=>{let i=tK(e.uvNode,t.zw).add(.5),s=rA(i),a=rw(i),n=uR(a.x),o=uA(a.x),l=uE(a.x),u=uC(a.x),d=uE(a.y),h=uC(a.y),c=eH(s.x.add(l),s.y.add(d)).sub(.5).mul(t.xy),p=eH(s.x.add(u),s.y.add(d)).sub(.5).mul(t.xy),m=eH(s.x.add(l),s.y.add(h)).sub(.5).mul(t.xy),g=eH(s.x.add(u),s.y.add(h)).sub(.5).mul(t.xy),f=uR(a.y).mul(tX(n.mul(e.sample(c).level(r)),o.mul(e.sample(p).level(r)))),b=uA(a.y).mul(tX(n.mul(e.sample(m).level(r)),o.mul(e.sample(g).level(r))));return f.add(b)},uM=eP(([e,t])=>{let r=eH(e.size(ez(t))),i=eH(e.size(ez(t.add(1)))),s=tY(1,r),a=tY(1,i),n=uw(e,eJ(s,r),rA(t)),o=uw(e,eJ(a,i),rE(t));return rw(t).mix(n,o)}),uB=eP(([e,t])=>{let r=t.mul(sB(e));return uM(e,r)}),uU=eP(([e,t,r,i,s])=>{let a=eQ(ip(t.negate(),rC(e),tY(1,i))),n=eQ(rW(s[0].xyz),rW(s[1].xyz),rW(s[2].xyz));return rC(a).mul(r.mul(n))}).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"}]}),uF=eP(([e,t])=>e.mul(ih(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),uL=ls(),uP=ln(),uD=eP(([e,t,r],{material:i})=>uM((i.side===u.hsX?uL:uP).sample(e),rS(sX.x).mul(uF(t,r)))),uO=eP(([e,t,r])=>(eI(r.notEqual(0),()=>rT(rv(t).negate().div(r).negate().mul(e))),eQ(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),uI=eP(([e,t,r,i,s,a,n,o,l,u,d,h,c,p,m])=>{let g,f;if(m){g=eJ().toVar(),f=eQ().toVar();let s=d.sub(1).mul(m.mul(.025)),a=eQ(d.sub(s),d,d.add(s));oJ({start:0,end:3},({i:s})=>
vendor: 9,837 bytes, line 7
7{let d=a.element(s),m=uU(e,t,h,d,o),b=n.add(m),y=u.mul(l.mul(eJ(b,1))),x=eH(y.xy.div(y.w)).toVar();x.addAssign(1),x.divAssign(2),x.assign(eH(x.x,x.y.oneMinus()));let T=uD(x,r,d);g.element(s).assign(T.element(s)),g.a.addAssign(T.a),f.element(s).assign(i.element(s).mul(uO(rW(m),c,p).element(s)))}),g.a.divAssign(3)}else{let s=uU(e,t,h,d,o),a=n.add(s),m=u.mul(l.mul(eJ(a,1))),b=eH(m.xy.div(m.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(eH(b.x,b.y.oneMinus())),g=uD(b,r,d),f=i.mul(uO(rW(s),c,p))}let b=f.rgb.mul(g.rgb),y=eQ(uh({dotNV:e.dot(t).clamp(),specularColor:s,specularF90:a,roughness:r})),x=f.r.add(f.g,f.b).div(3);return eJ(y.oneMinus().mul(b),g.a.oneMinus().mul(x).oneMinus())}),uV=e4(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),uG=(e,t)=>e.sub(t).div(e.add(t)).pow2(),uk=eP(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:i,baseF0:s})=>{let a=id(e,t,im(0,.03,i)),n=e.div(a).pow2().mul(r.pow2().oneMinus()).oneMinus();eI(n.lessThan(0),()=>eQ(1));let o=n.sqrt(),l=l0({f0:uG(a,e),f90:1,dotVH:r}),u=l.oneMinus(),d=a.lessThan(e).select(Math.PI,0),h=ek(Math.PI).sub(d),c=(e=>{let t=e.sqrt();return eQ(1).add(t).div(eQ(1).sub(t))})(s.clamp(0,.9999)),p=l0({f0:uG(c,a.toVec3()),f90:1,dotVH:o}),m=eQ(c.x.lessThan(a).select(Math.PI,0),c.y.lessThan(a).select(Math.PI,0),c.z.lessThan(a).select(Math.PI,0)),g=a.mul(i,o,2),f=eQ(h).add(m),b=l.mul(p).clamp(1e-5,.9999),y=b.sqrt(),x=u.pow2().mul(p).div(eQ(1).sub(b)),T=l.add(x).toVar(),_=x.sub(u).toVar();return oJ({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{_.mulAssign(y);let t=((e,t)=>{let r=e.mul(2*Math.PI*1e-9),i=eQ(54856e-17,44201e-17,52481e-17),s=eQ(1681e3,1795300,2208400),a=eQ(43278e5,93046e5,66121e5),n=ek(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(r.mul(2239900).add(t.x).cos()).mul(r.pow2().mul(-45282e5).exp()),o=i.mul(a.mul(2*Math.PI).sqrt()).mul(s.mul(r).add(t).cos()).mul(r.pow2().negate().mul(a).exp());return o=eQ(o.x.add(n),o.y,o.z).div(10685e-11),uV.mul(o)})(ek(e).mul(g),ek(e).mul(f)).mul(2);T.addAssign(_.mul(t))}),T.max(eQ(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"}]}),uz=eP(({normal:e,viewDir:t,roughness:r})=>{let i=e.dot(t).saturate(),s=r.mul(r),a=r.add(.1).reciprocal(),n=ek(-1.9362).add(r.mul(1.0678)).add(s.mul(.4573)).sub(a.mul(.8469)),o=ek(-.6014).add(r.mul(.5538)).sub(s.mul(.467)).sub(a.mul(.1255));return n.mul(i).add(o).exp().saturate()}),u$=eQ(.04),uW=ek(1);class uH extends lK{constructor(e=!1,t=!1,r=!1,i=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=i,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=eQ().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=eQ().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=eQ().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=eQ().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=eQ().toVar("sheenSpecularIndirect")),!0===this.iridescence){let e=aJ.dot(a$).clamp(),t=uk({outsideIOR:ek(1),eta2:th,cosTheta1:e,thinFilmThickness:tc,baseF0:tb}),r=uk({outsideIOR:ek(1),eta2:th,cosTheta1:e,thinFilmThickness:tc,baseF0:tt.rgb});this.iridescenceFresnel=id(t,r,ta),this.iridescenceF0Dielectric=uc({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=uc({f:r,f90:1,dotVH:e}),this.iridescenceF0=id(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,ta)}if(!0===this.transmission){let t=ap.sub(aG).normalize(),r=e.context;r.backdrop=uI(a0,t,ts,tr,ty,tx,aG,aR,ad,al,tR,tE,tw,tC,this.dispersion?tM:null),r.backdropAlpha=tA,tt.a.mulAssign(id(1,r.backdrop.a,tA))}super.start(e)}computeMultiscattering(e,t,r,i,s=null){let a=uu({roughness:ts,dotNV:aJ.dot(a$).clamp()}),n=s?td.mix(i,s):i,o=n.mul(a.x).add(r.mul(a.y)),l=a.x.add(a.y).oneMinus(),u=n.add(n.oneMinus().mul(.047619)),d=o.mul(u).div(l.mul(u).oneMinus());e.addAssign(o),t.addAssign(d.mul(l))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){let i=aJ.dot(e).clamp().mul(t).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(i.mul(ug({lightDirection:e})));let t=uz({normal:aJ,viewDir:a$,roughness:tu}),r=uz({normal:aJ,viewDir:e,roughness:tu}),s=tl.r.max(tl.g).max(tl.b).mul(t.max(r)).oneMinus();i.mulAssign(s)}if(!0===this.clearcoat){let r=a1.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul(un({lightDirection:e,f0:u$,f90:uW,roughness:to,normalView:a1})))}r.directDiffuse.addAssign(i.mul(l1({diffuseColor:tr}))),r.directSpecular.addAssign(i.mul(ud({lightDirection:e,f0:ty,f90:1,roughness:ts,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:i,reflectedLight:s,ltc_1:a,ltc_2:n}){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=az.toVar(),c=uf({N:aJ,V:a$,roughness:ts}),p=a.sample(c).toVar(),m=n.sample(c).toVar(),g=e4(eQ(p.x,0,p.y),eQ(0,1,0),eQ(p.z,0,p.w)).toVar(),f=ty.mul(m.x).add(tx.sub(ty).mul(m.y)).toVar();if(s.directSpecular.addAssign(e.mul(f).mul(ux({N:aJ,V:a$,P:h,mInv:g,p0:o,p1:l,p2:u,p3:d}))),s.directDiffuse.addAssign(e.mul(tr).mul(ux({N:aJ,V:a$,P:h,mInv:e4(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:u,p3:d}))),!0===this.clearcoat){let t=uf({N:a1,V:a$,roughness:to}),r=a.sample(t),i=n.sample(t),s=e4(eQ(r.x,0,r.y),eQ(0,1,0),eQ(r.z,0,r.w)),c=u$.mul(i.x).add(uW.sub(u$).mul(i.y));this.clearcoatSpecularDirect.addAssign(e.mul(c).mul(ux({N:a1,V:a$,P:h,mInv:s,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,i=t.mul(l1({diffuseColor:tr})).toVar();if(!0===this.sheen){let e=uz({normal:aJ,viewDir:a$,roughness:tu}),t=tl.r.max(tl.g).max(tl.b).mul(e).oneMinus();i.mulAssign(t)}r.indirectDiffuse.addAssign(i)}indirectSpecular(e){let{radiance:t,iblIrradiance:r,reflectedLight:i}=e.context;if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(r.mul(tl,uz({normal:aJ,viewDir:a$,roughness:tu}))),!0===this.clearcoat){let e=uh({dotNV:a1.dot(a$).clamp(),specularColor:u$,specularF90:uW,roughness:to});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let s=eQ().toVar("singleScatteringDielectric"),a=eQ().toVar("multiScatteringDielectric"),n=eQ().toVar("singleScatteringMetallic"),o=eQ().toVar("multiScatteringMetallic");this.computeMultiscattering(s,a,tx,tb,this.iridescenceF0Dielectric),this.computeMultiscattering(n,o,tx,tt.rgb,this.iridescenceF0Metallic);let l=id(s,n,ta),u=id(a,o,ta),d=s.add(a),h=tr.mul(d.oneMinus()),c=r.mul(1/Math.PI),p=t.mul(l).add(u.mul(c)).toVar(),m=h.mul(c).toVar();if(!0===this.sheen){let e=uz({normal:aJ,viewDir:a$,roughness:tu}),t=tl.r.max(tl.g).max(tl.b).mul(e).oneMinus();p.mulAssign(t),m.mulAssign(t)}i.indirectSpecular.addAssign(p),i.indirectDiffuse.addAssign(m)}ambientOcclusion(e){let{ambientOcclusion:t,reflectedLight:r}=e.context,i=aJ.dot(a$).clamp().add(t),s=ts.mul(-16).oneMinus().negate().exp2(),a=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(a)}finish({context:e}){let{outgoingLight:t}=e;if(!0===this.clearcoat){let e=l0({dotVH:a1.dot(a$).clamp(),f0:u$,f90:uW}),r=t.mul(tn.mul(e).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(tn));t.assign(r)}if(!0===this.sheen){let e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}}let uq=ek(1),uj=ek(-2),uX=ek(.8),uQ=ek(-1),uK=ek(.4),uY=ek(2),uZ=ek(.305),uJ=ek(3),u0=ek(.21),u1=ek(4),u2=ek(4),u3=ek(16),u4=eP(([e])=>{let t=eQ(rz(e)).toVar(),r=ek(-1).toVar();return eI(t.x.greaterThan(t.z),()=>{eI(t.x.greaterThan(t.y),()=>{r.assign(iv(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign(iv(e.y.greaterThan(0),1,4))})}).Else(()=>{eI(t.z.greaterThan(t.y),()=>{r.assign(iv(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign(iv(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),u5=eP(([e,t])=>{let r=eH().toVar();return eI(t.equal(0),()=>{r.assign(eH(e.z,e.y).div(rz(e.x)))}).ElseIf(t.equal(1),()=>{r.assign(eH(e.x.negate(),e.z.negate()).div(rz(e.y)))}).ElseIf(t.equal(2),()=>{r.assign(eH(e.x.negate(),e.y).div(rz(e.z)))}).ElseIf(t.equal(3),()=>{r.assign(eH(e.z.negate(),e.y).div(rz(e.x)))}).ElseIf(t.equal(4),()=>{r.assign(eH(e.x.negate(),e.z).div(rz(e.y)))}).Else(()=>{r.assign(eH(e.x,e.y).div(rz(e.z)))}),tK(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),u6=eP(([e])=>{let t=ek(0).toVar();return eI(e.greaterThanEqual(uX),()=>{t.assign(uq.sub(e).mul(uQ.sub(uj)).div(uq.sub(uX)).add(uj))}).ElseIf(e.greaterThanEqual(uK),()=>{t.assign(uX.sub(e).mul(uY.sub(uQ)).div(uX.sub(uK)).add(uQ))}).ElseIf(e.greaterThanEqual(uZ),()=>{t.assign(uK.sub(e).mul(uJ.sub(uY)).div(uK.sub(uZ)).add(uY))}).ElseIf(e.greaterThanEqual(u0),()=>{t.assign(uZ.sub(e).mul(u1.sub(uJ)).div(uZ.sub(u0)).add(uJ))}).Else(()=>{t.assign(ek(-2).mul(rS(tK(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),u8=eP(([e,t])=>{let r=e.toVar();r.assign(tK(2,r).sub(1));let i=eQ(r,1).toVar();return eI(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)}
vendor: 4,234 bytes, line 7
7).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"}]}),u9=eP(([e,t,r,i,s,a])=>{let n=ek(r),o=eQ(t),l=ih(u6(n),uj,a),u=rw(l),d=rA(l),h=eQ(u7(e,o,d,i,s,a)).toVar();return eI(u.notEqual(0),()=>{let t=eQ(u7(e,o,d.add(1),i,s,a)).toVar();h.assign(id(h,t,u))}),h}),u7=eP(([e,t,r,i,s,a])=>{let n=ek(r).toVar(),o=eQ(t),l=ek(u4(o)).toVar(),u=ek(r3(u2.sub(n),0)).toVar();n.assign(r3(n,u2));let d=ek(r_(n)).toVar(),h=eH(u5(o,l).mul(d.sub(2)).add(1)).toVar();return eI(l.greaterThan(2),()=>{h.y.addAssign(d),l.subAssign(3)}),h.x.addAssign(l.mul(d)),h.x.addAssign(u.mul(tK(3,u3))),h.y.addAssign(tK(4,r_(a).sub(d))),h.x.mulAssign(i),h.y.mulAssign(s),e.sample(h).grad(eH(),eH())}),de=eP(({envMap:e,mipInt:t,outputDirection:r,theta:i,axis:s,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:n,CUBEUV_MAX_MIP:o})=>{let l=rU(i);return u7(e,r.mul(l).add(s.cross(r).mul(rM(i))).add(s.mul(s.dot(r).mul(l.oneMinus()))),t,a,n,o)}),dt=eP(({n:e,latitudinal:t,poleAxis:r,outputDirection:i,weights:s,samples:a,dTheta:n,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})=>{let c=eQ(iv(t,r,r7(r,i))).toVar();eI(c.equal(eQ(0)),()=>{c.assign(eQ(i.z,0,i.x.negate()))}),c.assign(rC(c));let p=eQ().toVar();return p.addAssign(s.element(0).mul(de({theta:0,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h}))),oJ({start:ez(1),end:e},({i:e})=>{eI(e.greaterThanEqual(a),()=>{o0()});let t=ek(n.mul(ek(e))).toVar();p.addAssign(s.element(e).mul(de({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(de({theta:t,axis:c,outputDirection:i,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:h})))}),eJ(p,1)}),dr=eP(([e])=>{let t=e$(e).toVar();return t.assign(t.shiftLeft(e$(16)).bitOr(t.shiftRight(e$(16)))),t.assign(t.bitAnd(e$(0x55555555)).shiftLeft(e$(1)).bitOr(t.bitAnd(e$(0xaaaaaaaa)).shiftRight(e$(1)))),t.assign(t.bitAnd(e$(0x33333333)).shiftLeft(e$(2)).bitOr(t.bitAnd(e$(0xcccccccc)).shiftRight(e$(2)))),t.assign(t.bitAnd(e$(0xf0f0f0f)).shiftLeft(e$(4)).bitOr(t.bitAnd(e$(0xf0f0f0f0)).shiftRight(e$(4)))),t.assign(t.bitAnd(e$(0xff00ff)).shiftLeft(e$(8)).bitOr(t.bitAnd(e$(0xff00ff00)).shiftRight(e$(8)))),ek(t).mul(23283064365386963e-26)}),di=eP(([e,t])=>eH(ek(e).div(ek(t)),dr(e))),ds=eP(([e,t,r])=>{let i=r.mul(r).toConst(),s=eQ(1,0,0).toConst(),a=r7(t,s).toConst(),n=rN(e.x).toConst(),o=tK(2,3.14159265359).mul(e.y).toConst(),l=n.mul(rU(o)).toConst(),u=n.mul(rM(o)).toVar(),d=tK(.5,t.z.add(1)).toConst();u.assign(d.oneMinus().mul(rN(l.mul(l).oneMinus())).add(d.mul(u)));let h=s.mul(l).add(a.mul(u)).add(t.mul(rN(r3(0,l.mul(l).add(u.mul(u)).oneMinus()))));return rC(eQ(i.mul(h.x),i.mul(h.y),r3(0,h.z)))}),da=eP(({roughness:e,mipInt:t,envMap:r,N_immutable:i,GGX_SAMPLES:s,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:n,CUBEUV_MAX_MIP:o})=>{let l=eQ(i).toVar(),u=eQ(0).toVar(),d=ek(0).toVar();return eI(e.lessThan(.001),()=>{u.assign(u7(r,l,t,a,n,o))}).Else(()=>{let i=rC(r7(iv(rz(l.z).lessThan(.999),eQ(0,0,1),eQ(1,0,0)),l)).toVar(),h=r7(l,i).toVar();oJ({start:e$(0),end:s},({i:c})=>{let p=ds(di(c,s),eQ(0,0,1),e),m=rC(i.mul(p.x).add(h.mul(p.y)).add(l.mul(p.z))),g=rC(m.mul(r9(l,m).mul(2)).sub(l)),f=r3(r9(l,g),0);eI(f.greaterThan(0),()=>{let e=u7(r,g,t,a,n,o);u.addAssign(e.mul(f)),d.addAssign(f)})}),eI(d.greaterThan(0),()=>{u.assign(u.div(d))})}),eJ(u,1)}),dn=[.125,.215,.35,.446,.526,.582],dl=new u.qUd(-1,1,1,-1,0,1),du=new u.ubm(90,1),dd=new u.Q1f,dh=null,dc=0,dp=0,dm=new u.Pq0,dg=new WeakMap,df=[3,1,5,0,4,2],db=u8(sE(),sA("faceIndex")).normalize(),dy=eQ(db.x,db.y,db.z);class dx{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=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={}
7){let{size:a=256,position:n=dm,renderTarget:o=null}=s;if(this._setSize(a),!1===this._hasInitialized)throw Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');dh=this._renderer.getRenderTarget(),dc=this._renderer.getActiveCubeFace(),dp=this._renderer.getActiveMipmapLevel();let l=o||this._allocateTarget(!0);return this._init(l),this._sceneToCubeUV(e,r,i,l,n),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(0,u.mcG)('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,i,s)}fromEquirectangular(e,t=null){if(!1===this._hasInitialized)throw Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return(0,u.mcG)('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(!1===this._hasInitialized)throw Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return(0,u.mcG)('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=dv(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=dS(),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._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(dh,dc,dp),e.scissorTest=!1,this._setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),dh=this._renderer.getRenderTarget(),dc=this._renderer.getActiveCubeFace(),dp=this._renderer.getActiveMipmapLevel();let r=t||this._allocateTarget(!1);return this._init(r),this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTarget(e){return dT(3*Math.max(this._cubeSize,112),4*this._cubeSize,e)}_init(e){if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=dT(e.width,e.height);let{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){let t=[],r=[],i=[],s=e,a=e-4+1+dn.length;for(let n=0;n<a;n++){let a=Math.pow(2,s);t.push(a);let o=1/a;n>e-4?o=dn[n-e+4-1]:0===n&&(o=0),r.push(o);let l=1/(a-2),d=-l,h=1+l,c=[d,d,h,d,h,h,d,d,h,h,d,h],p=new Float32Array(108),m=new Float32Array(72),g=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=df[e];p.set(i,18*s),m.set(c,12*s);let a=[s,s,s,s,s,s];g.set(a,6*s)}let f=new u.LoY;f.setAttribute("position",new u.THS(p,3)),f.setAttribute("uv",new u.THS(m,2)),f.setAttribute("faceIndex",new u.THS(g,1)),i.push(new u.eaF(f,null)),s>4&&s--}return{lodMeshes:i,sizeLods:t,sigmas:r}}(t)),this._blurMaterial=function(e,t,r){let i=sz(Array(20).fill(0)),s=tV(new u.Pq0(0,1,0)),a=tV(0),n=ek(20),o=tV(0),l=tV(1),d=sD(),h=tV(0),c=ek(1/t),p={n,latitudinal:o,weights:i,poleAxis:s,outputDirection:dy,dTheta:a,samples:l,envMap:d,mipInt:h,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:ek(1/r),CUBEUV_MAX_MIP:ek(e)},m=d_("blur");return m.fragmentNode=dt({...p,latitudinal:o.equal(1)}),dg.set(m,p),m}(t,e.width,e.height),this._ggxMaterial=function(e,t,r){let i=sD(),s=tV(0),a=tV(0),n=ek(1/t),o={envMap:i,roughness:s,mipInt:a,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:ek(1/r),CUBEUV_MAX_MIP:ek(e)},l=d_("ggx");return l.fragmentNode=da({...o,N_immutable:dy,GGX_SAMPLES:e$(512)}),dg.set(l,o),l}(t,e.width,e.height)}}async _compileMaterial(e){let t=new u.eaF(new u.LoY,e);await this._renderer.compile(t,dl)}_sceneToCubeUV(e,t,r,i,s){du.near=t,du.far=r;let a=[1,1,1,1,-1,1],n=[1,-1,1,-1,1,-1],o=this._renderer,l=o.autoClear;o.getClearColor(dd),o.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new u.eaF(new u.iNn,new u.V9B({n
7ame:"PMREM.Background",side:u.hsX,depthWrite:!1,depthTest:!1})));let d=this._backgroundBox,h=d.material,c=!1,p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,c=!0):(h.color.copy(dd),c=!0),o.setRenderTarget(i),o.clear(),c&&o.render(d,du);for(let t=0;t<6;t++){let r=t%3;0===r?(du.up.set(0,a[t],0),du.position.set(s.x,s.y,s.z),du.lookAt(s.x+n[t],s.y,s.z)):1===r?(du.up.set(0,0,a[t]),du.position.set(s.x,s.y,s.z),du.lookAt(s.x,s.y+n[t],s.z)):(du.up.set(0,a[t],0),du.position.set(s.x,s.y,s.z),du.lookAt(s.x,s.y,s.z+n[t]));let l=this._cubeSize;this._setViewport(i,r*l,t>2?l:0,l,l),o.render(e,du)}o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let r=this._renderer,i=e.mapping===u.hy7||e.mapping===u.xFO;i?null===this._cubemapMaterial&&(this._cubemapMaterial=dv(e)):null===this._equirectMaterial&&(this._equirectMaterial=dS(e));let s=i?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;let a=this._lodMeshes[0];a.material=s;let n=this._cubeSize;this._setViewport(t,0,0,3*n,2*n),r.setRenderTarget(t),r.render(a,dl)}_applyPMREM(e){let t=this._renderer,r=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let t=1;t<i;t++)this._applyGGXFilter(e,t-1,t);t.autoClear=r}_applyGGXFilter(e,t,r){let i=this._renderer,s=this._pingPongRenderTarget,a=this._ggxMaterial,n=this._lodMeshes[r];n.material=a;let o=dg.get(a),l=r/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),d=Math.sqrt(l*l-u*u),{_lodMax:h}=this,c=this._sizeLods[r],p=3*c*(r>h-4?r-h+4:0),m=4*(this._cubeSize-c);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=d*(0+1.25*l),o.mipInt.value=h-t,this._setViewport(s,p,m,3*c,2*c),i.setRenderTarget(s),i.render(n,dl),s.texture.frame=(s.texture.frame||0)+1,o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=h-r,this._setViewport(e,p,m,3*c,2*c),i.setRenderTarget(e),i.render(n,dl)}_blur(e,t,r,i,s){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,t,r,i,s,a,n){let o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&(0,u.z3S)("blur direction must be either latitudinal or longitudinal!");let d=this._lodMeshes[i];d.material=l;let h=dg.get(l),c=this._sizeLods[r]-1,p=isFinite(s)?Math.PI/(2*c):2*Math.PI/39,m=s/p,g=isFinite(s)?1+Math.floor(3*m):20;g>20&&(0,u.R8M)(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to 20`);let f=[],b=0;for(let e=0;e<20;++e){let t=e/m,r=Math.exp(-t*t/2);f.push(r),0===e?b+=r:e<g&&(b+=2*r)}for(let e=0;e<f.length;e++)f[e]=f[e]/b;e.texture.frame=(e.texture.frame||0)+1,h.envMap.value=e.texture,h.samples.value=g,h.weights.array=f,h.latitudinal.value=+("latitudinal"===a),n&&(h.poleAxis.value=n);let{_lodMax:y}=this;h.dTheta.value=p,h.mipInt.value=y-r;let x=this._sizeLods[i],T=4*(this._cubeSize-x);this._setViewport(t,3*x*(i>y-4?i-y+4:0),T,3*x,2*x),o.setRenderTarget(t),o.render(d,dl)}_setViewport(e,t,r,i,s){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-s-r,i,s),e.scissor.set(t,e.height-s-r,i,s)):(e.viewport.set(t,r,i,s),e.scissor.set(t,r,i,s))}}function dT(e,t,r){let i={magFilter:u.k6q,minFilter:u.k6q,generateMipmaps:!1,type:u.ix0,format:u.GWd,colorSpace:u.Zr2,depthBuffer:r},s=new u.O0B(e,t,i);return s.texture.mapping=u.Om,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function d_(e){let t=new lE;return t.depthTest=!1,t.depthWrite=!1,t.blending=u.XIg,t.name=`PMREM_${e}`,t}function dv(e){let t=d_("cubemap");return t.fragmentNode=nl(e,dy),t}function dS(e){let t=d_("equirect");return t.fragmentNode=sD(e,lG(dy),0),t}let dN=new WeakMap;class dR extends G{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;let i=new u.gPd;i.isRenderTargetTexture=!0,this._texture=sD(i),this._width=tV(0),this._height=tV(0),this._maxMip=tV(0),this.updateBeforeType=w.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){let t=function(e){let t=Math.log2(e)-2;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:1/e,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem,r=t?t.pmremVersion:-1,i=this._value;r!==i.pmremVersion&&null!==(t=!0===i.isPMREMTexture||i.mapping===u.Om?i:function(e,t,r){var i,s;let a,n=(i=t,void 0===(a=dN.get(i))&&(a=new WeakMap,dN.set(i,a)),a),o=n.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)}if(o.pmremVersion=e.pmremVersion,!1===n.has(e)){let t=()=>{e.removeEventListener("dispose",t);let r=n.get(e);void 0!==r&&(r.dispose(),n.delete(e))};e.addEventListener("dispose",t)}n.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 dx(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?ne.mul(eQ(t.x,t.y.negate(),t.z)):ne.mul(t);let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),u9(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}let dA=ew(dR).setParameterLength(1,3),dE=new WeakMap;class dC extends o6{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 i=r.isTextureNode?r.value:t[r.property],s=this._getPMREMNodeCache(e.renderer),a=s.get(i);void 0===a&&(a=dA(i),s.set(i,a)),r=a}let i=!0===t.useAnisotropy||t.anisotropy>0?nV:aJ,s=r.context(dw(ts,i)).mul(a7),a=r.context(dM(a0)).mul(Math.PI).mul(a7),n=so(s),o=so(a);
7e.context.radiance.addAssign(n),e.context.iblIrradiance.addAssign(o);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=so(r.context(dw(to,a1)).mul(a7));l.addAssign(e)}}_getPMREMNodeCache(e){let t=dE.get(e);return void 0===t&&(t=new WeakMap,dE.set(e,t)),t}}let dw=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=a$.negate().reflect(t),r=(r=ii(e).mix(r,t).normalize()).transformDirection(ah)),r),getTextureLevel:()=>e}},dM=e=>({getUV:()=>e,getTextureLevel:()=>ek(1)}),dB=new u._4j;class dU extends lE{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(dB),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new dC(t):null}setupLightingModel(){return new uH}setupSpecular(){let e=id(eQ(.04),tt.rgb,ta);tb.assign(eQ(.04)),ty.assign(e),tx.assign(1)}setupVariants(){let e=this.metalnessNode?ek(this.metalnessNode):n9;ta.assign(e);let t=this.roughnessNode?ek(this.roughnessNode):n8;t=ue({roughness:t}),ts.assign(t),this.setupSpecular(),tr.assign(tt.rgb.mul(e.oneMinus()))}}let dF=new u.uSd;class dL extends dU{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(dF),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?ek(this.iorNode):oc;tR.assign(e),tb.assign(r2(it(tR.sub(1).div(tR.add(1))).mul(n4),eQ(1)).mul(n3)),ty.assign(id(tb,tt.rgb,ta)),tx.assign(id(n3,1,ta))}setupLightingModel(){return new uH(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?ek(this.clearcoatNode):oe,t=this.clearcoatRoughnessNode?ek(this.clearcoatRoughnessNode):ot;tn.assign(e),to.assign(ue({roughness:t}))}if(this.useSheen){let e=this.sheenNode?eQ(this.sheenNode):os,t=this.sheenRoughnessNode?ek(this.sheenRoughnessNode):oa;tl.assign(e),tu.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?ek(this.iridescenceNode):oo,t=this.iridescenceIORNode?ek(this.iridescenceIORNode):ol,r=this.iridescenceThicknessNode?ek(this.iridescenceThicknessNode):ou;td.assign(e),th.assign(t),tc.assign(r)}if(this.useAnisotropy){let e=(this.anisotropyNode?eH(this.anisotropyNode):on).toVar();tm.assign(e.length()),eI(tm.equal(0),()=>{e.assign(eH(1,0))}).Else(()=>{e.divAssign(eH(tm)),tm.assign(tm.saturate())}),tp.assign(tm.pow2().mix(ts.pow2(),1)),tg.assign(nO[0].mul(e.x).add(nO[1].mul(e.y))),tf.assign(nO[1].mul(e.x).sub(nO[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?ek(this.transmissionNode):od,t=this.thicknessNode?ek(this.thicknessNode):oh,r=this.attenuationDistanceNode?ek(this.attenuationDistanceNode):op,i=this.attenuationColorNode?eQ(this.attenuationColorNode):om;if(tA.assign(e),tE.assign(t),tC.assign(r),tw.assign(i),this.useDispersion){let e=this.dispersionNode?ek(this.dispersionNode):o_;tM.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?eQ(this.clearcoatNormalNode):or}setup(e){e.context.setupClearcoatNormal=()=>iD(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}}let dP=eP(({normal:e,lightDirection:t,builder:r})=>
7{let i=eH(e.dot(t).mul(.5).add(.5),0);if(r.material.gradientMap)return eQ(nm("gradientMap","texture").context({getUV:()=>i}).r);{let e=i.fwidth().mul(.5);return id(eQ(.7),eQ(1),im(ek(.7).sub(e.x),ek(.7).add(e.x),i.x))}});class dD extends lK{direct({lightDirection:e,lightColor:t,reflectedLight:r},i){let s=dP({normal:aX,lightDirection:e,builder:i}).mul(t);r.directDiffuse.addAssign(s.mul(l1({diffuseColor:tt.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(l1({diffuseColor:tt}))),i.indirectDiffuse.mulAssign(t)}}let dO=new u.Df;class dI extends lE{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(dO),this.setValues(e)}setupLightingModel(){return new dD}}let dV=eP(()=>{let e=eQ(a$.z,0,a$.x.negate()).normalize(),t=a$.cross(e);return eH(e.dot(aJ),t.dot(aJ)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),dG=new u.FNr;class dk extends lE{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(dG),this.setValues(e)}setupVariants(e){let t;t=e.material.matcap?nm("matcap","texture").context({getUV:()=>dV}):eQ(id(.2,.8,dV.y)),tt.rgb.mulAssign(t.rgb)}}class dz extends G{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(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 e3(e,i,i.negate(),e).mul(r)}{let e=e5(eJ(1,0,0,0),eJ(0,rU(t.x),rM(t.x).negate(),0),eJ(0,rM(t.x),rU(t.x),0),eJ(0,0,0,1)),i=e5(eJ(rU(t.y),0,rM(t.y),0),eJ(0,1,0,0),eJ(rM(t.y).negate(),0,rU(t.y),0),eJ(0,0,0,1)),s=e5(eJ(rU(t.z),rM(t.z).negate(),0,0),eJ(rM(t.z),rU(t.z),0,0),eJ(0,0,1,0),eJ(0,0,0,1));return e.mul(i).mul(s).mul(eJ(r,1)).xyz}}}let d$=ew(dz).setParameterLength(2),dW=new u.RoJ;class dH extends lE{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(dW),this.setValues(e)}setupPositionView(e){let{object:t,camera:r}=e,{positionNode:i,rotationNode:s,scaleNode:a,sizeAttenuation:n}=this,o=aU.mul(eQ(i||0)),l=eH(aR[0].xyz.length(),aR[1].xyz.length());null!==a&&(l=l.mul(eH(a))),r.isPerspectiveCamera&&!1===n&&(l=l.mul(o.z.negate()));let u=aO.xy;if(t.center&&!0===t.center.isVector2){let e=new ij("center","vec2",t);u=u.sub(e.sub(.5))}let d=d$(u=u.mul(l),ek(s||oi));return eJ(o.xy.add(d),o.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}let dq=new u.BH$,dj=new u.I9Y;class dX extends dH{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(dq),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return aU.mul(eQ(e||aI)).xyz}setupVertexSprite(e){let{material:t,camera:r}=e,{rotationNode:i,scaleNode:s,sizeNode:a,sizeAttenuation:n}=this,o=super.setupVertex(e);if(!0!==t.isNodeMaterial)return o;let l=null!==a?eH(a):oT;l=l.mul(sq),r.isPerspectiveCamera&&!0===n&&(l=l.mul(dQ.div(az.z.negate()))),s&&s.isNode&&(l=l.mul(eH(s)));let u=aO.xy;return i&&i.isNode&&(u=d$(u,ek(i))),u=(u=(u=u.mul(l)).div(sY.div(2))).mul(o.w),o=o.add(eJ(u,0,0))}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}let dQ=tV(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(dj);this.value=.5*t.y});class dK extends lK{constructor(){super(),this.shadowNode=ek(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){tt.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(tt.rgb)}}let dY=new u.q2;class dZ extends lE{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(dY),this.setValues(e)}setupLightingModel(){return new dK}}e7("vec3"),e7("vec3"),e7("vec3");class dJ{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context="undefined"!=typeof self?self:null,this._animationLoop=null,this._requestId=null}start(){let e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(
7),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),null!==this._animationLoop&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){null!==this._context&&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 d0{constructor(){this.weakMaps={}}_getWeakMap(e){let t=e.length,r=this.weakMaps[t];return void 0===r&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);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._getWeakMap(e);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._getWeakMap(e);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 d1=0,d2=new WeakMap;class d3{constructor(e,t,r,i,s,a,n,o,l,u){this.id=d1++,this._nodes=e,this._geometries=t,this.renderer=r,this.object=i,this.material=s,this.scene=a,this.camera=n,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._sourceMaterial=r._currentSourceMaterial,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),null!==this._sourceMaterial&&this._sourceMaterial.addEventListener("dispose",this.onMaterialDispose)}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.getNodeBuilderState().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)}getIndirectOffset(){return this._geometries.getIndirectOffset(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 a of e){let e;if(a.node&&a.node.attribute?e=a.node.attribute:void 0!==(e=t.getAttribute(a.name))&&(e.isInterleavedBufferAttribute?s[a.name]=e.data.uuid:s[a.name]=e.id),void 0===e)continue;r.push(e);let n=e.isInterleavedBufferAttribute?e.data:e;i.add(n)}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,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),n=this.getIndex(),o=null!==n,l=1;if(!0===r.isInstancedBufferGeometry?l=r.instanceCount:void 0!==e.count&&(l=Math.max(0,e.count)),0===l)return null;if(a.instanceCount=l,!0===e.isBatchedMesh)return a;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=n.count:null!=c&&(p=c.count),d=Math.max(d,0);let m=(h=Math.min(h,p))-d;
7return m<0||m===1/0?null:(a.vertexCount=m,a.firstVertex=d,a)}getGeometryCacheKey(){let{geometry:e}=this,t="";for(let r of Object.keys(e.attributes).sort()){let i=e.attributes[r];t+=r+",",i.data&&(t+=i.data.stride+","),i.offset&&(t+=i.offset+","),i.itemSize&&(t+=i.itemSize+","),i.normalized&&(t+="n,")}for(let r of Object.keys(e.morphAttributes).sort()){let i=e.morphAttributes[r];t+="morph-"+r+",";for(let e=0,r=i.length;e<r;e++)t+=i[e].id+","}return e.index&&(t+="index,"),t}getMaterialCacheKey(){let{object:e,material:t,renderer:r}=this,i=t.customProgramCacheKey();for(let e of function(e){let t=Object.keys(e),r=d2.get(e.constructor);if(void 0===r){r=[];let t=Object.getPrototypeOf(e);for(;t;){let e=Object.getOwnPropertyDescriptors(t);for(let t in e){let i=e[t];i&&"function"==typeof i.get&&r.push(t)}t=Object.getPrototypeOf(t)}d2.set(e.constructor,r)}for(let e=0;e<r.length;e++)t.push(r[e]);return t}(t)){let s;if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;let a=t[e];if(null!==a){let t=typeof a;"number"===t?s="side"===e?String(a):0!==a?"1":"0":"object"===t?(s="{",a.isTexture&&(s+=a.mapping,!0===r.backend.isWebGPUBackend&&(s+=a.magFilter,s+=a.minFilter,s+=a.wrapS,s+=a.wrapT,s+=a.wrapR)),s+="}"):s=String(a)}else s=String(a);i+=s+","}return i+=this.clippingContextCacheKey+",",e.geometry&&(i+=this.getGeometryCacheKey()),e.skeleton&&(i+=e.skeleton.bones.length+","),e.isBatchedMesh&&(i+=e._matricesTexture.uuid+",",null!==e._colorsTexture&&(i+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1)&&(i+=e.uuid+","),i+=this.context.id+",",y(i+=e.receiveShadow+",")}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(null!==this.attributes){let e=this.attributesId;for(let t in e){let r=this.geometry.getAttribute(t);if(void 0===r)return!0;let i=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==i)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=T(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=T(e,1)),e=T(e,this.renderer.contextNode.id,this.renderer.contextNode.version)}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),null!==this._sourceMaterial&&this._sourceMaterial.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}let d4=[];class d5{constructor(e,t,r,i,s,a){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=i,this.bindings=s,this.info=a,this.chainMaps={}}get(e,t,r,i,s,a,n,o){let l=this.getChainMap(o);d4[0]=e,d4[1]=t,d4[2]=a,d4[3]=s;let u=l.get(d4);return void 0===u?(u=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,i,s,a,n,o),l.set(d4,u)):(u.camera=i,u.updateClipping(n),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,a,n,o)):u.version=t.version)),d4[0]=null,d4[1]=null,d4[2]=null,d4[3]=null,u}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new d0)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,i,s,a,n,o,l,u,d){let h=this.getChainMap(d),c=new d3(e,t,r,i,s,a,n,o,l,u);return c.onDispose=()=>{this.pipelines.delete(c),this.bindings.deleteForRender(c),this.nodes.delete(c),h.delete(c.getChainArray())},c}}class d6{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}let d8={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4};class d9 extends d6{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){let t=super.delete(e);return null!==t&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){let r=this.get(e);if(void 0===r.version)t===d8.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===d8.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===d8.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===d8.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.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 d7(e){return null!==e.index?e.index.version:e.attributes.position.version}function he(e){return null!==e.index?e.index.id:e.attributes.position.id}function ht(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],a=e[r+2];t.push(i,s,s,a,a,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(i.count>=65535?u.MW4:u.A$4)(t,1);return s.version=d7(e),s.__id=he(e),s}class hr extends d6{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}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 a=this.wireframes.get(t);void 0!==a&&this.attributes.delete(a),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){for(let t of e.getAttributes())t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute?this.updateAttribute(t,d8.STORAGE):this.updateAttribute(t,d8.VERTEX);let t=this.getIndex(e);null!==t&&this.updateAttribute(t,d8.INDEX);let r=e.geometry.indirect;null!==r&&this.updateAttribute(r,d8.INDIRECT)}updateAttribute(e,t){let r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}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=ht(t),e.set(t,r)):(r.version!==d7(t)||r.__id!==he(t))&&(this.attributes.delete(r),r=ht(t),e.set(t,r)),i=r}return i}dispose(){for(let[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class hi{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={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}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):(0,u.z3S)("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(){for(let e in this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){let t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){let r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){let t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){let{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){let t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){let t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){let t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){let t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===u.tJf||e.type===u.OUM?t=1:e.type===u.fBL||e.type===u.cHt||e.type===u.ix0?t=2:(e.type===u.Yuy||e.type===u.bkx||e.type===u.RQf)&&(t=4);let r=4;e.format===u.wrO||e.format===u.VT0||e.format===u.ZQM||e.format===u.zdS||e.format===u.dcC?r=1:e.format===u.paN||e.format===u.TkQ?r=2:(e.format===u.HIg||e.format===u.VGF)&&(r=3);let i=t*r;e.type===u.Wew||e.type===u.gJ2?i=2:(e.type===u.V3x||e.type===u.Dmk||e.type===u.yT7)&&(i=4);let s=e.width||1,a=e.height||1,n=e.isCubeTexture?6:e.depth||1,o=s*a*n*i,l=e.mipmaps;if(l&&l.length>0){let e=0;for(let t=0;t<l.length;t++){let r=l[t];r.data?e+=r.data.byteLength:e+=(r.width||Math.max(1,s>>t))*(r.height||Math.max(1,a>>t))*n*i}o+=e}else e.generateMipmaps&&(o*=1.333);return Math.round(o)}_getAttributeMemorySize(e){return(e.isInterleavedBufferAttribute&&(e=e.data),e.array)?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}class hs{constructor(e){this.cacheKey=e,this.usedTimes=0}}class ha extends hs{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class hn extends hs{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let ho=0;
7class hl{constructor(e,t,r,i=null,s=null){this.id=ho++,this.code=e,this.stage=t,this.name=r,this.transforms=i,this.attributes=s,this.usedTimes=0}}class hu extends d6{constructor(e,t,r){super(),this.backend=e,this.nodes=t,this.info=r,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 a=this.nodes.getForCompute(e),n=this.programs.compute.get(a.computeShader);void 0===n&&(s&&0===s.computeProgram.usedTimes&&this._releaseProgram(s.computeProgram),n=new hl(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,n),r.createProgram(n),this.info.createProgram(n));let o=this._getComputeCacheKey(e,n),l=this.caches.get(o);void 0===l&&(s&&0===s.usedTimes&&this._releasePipeline(s),l=this._getComputePipeline(e,n,o,t)),l.usedTimes++,n.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 a=e.getNodeBuilderState(),n=e.material?e.material.name:"",o=this.programs.vertex.get(a.vertexShader);void 0===o&&(s&&0===s.vertexProgram.usedTimes&&this._releaseProgram(s.vertexProgram),o=new hl(a.vertexShader,"vertex",n),this.programs.vertex.set(a.vertexShader,o),r.createProgram(o),this.info.createProgram(o));let l=this.programs.fragment.get(a.fragmentShader);void 0===l&&(s&&0===s.fragmentProgram.usedTimes&&this._releaseProgram(s.fragmentProgram),l=new hl(a.fragmentShader,"fragment",n),this.programs.fragment.set(a.fragmentShader,l),r.createProgram(l),this.info.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}isReady(e){let t=this.get(e).pipeline;if(void 0===t)return!1;let r=this.backend.get(t);return void 0!==r.pipeline&&null!==r.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 hn(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 a=this.caches.get(i);return void 0===a&&(a=new ha(i,t,r),this.caches.set(i,a),e.pipeline=a,this.backend.createRenderPipeline(e,s)),a}_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),this.info.destroyProgram(e)}_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 hd extends d6{constructor(e,t,r,i,s,a){super(),this.backend=e,this.textures=r,this.pipelines=s,this.attributes=i,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){let t=e.getBindings(),r=this.get(e);return!0!==r.initialized&&(this._createBindings(t),r.initialized=!0),t}getForCompute(e){let t=this.nodes.getForCompute(e).bindings,r=this.get(e);return(!0!==r.initialized||r.bindings!==t)&&(void 0!==r.bindings&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){let t=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(t),this.delete(e)}deleteForRender(e){let t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(let t of e){let r=this.get(t);if(void 0===r.bindGroup){for(let e of t.bindings)if(e.isUniformBuffer)this.backend.createUniformBuffer(e),this.info.createUniformBuffer(e);else if(e.isSampledTexture)this.textures.updateTexture(e.texture);else if(e.isSampler)this.textures.updateSampler(e);else if(e.isStorageBuffer){let t=e.attribute,r=t.isIndirectStorageBufferAttribute?d8.INDIRECT:d8.STORAGE;this.attributes.update(t,r)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}
7}_destroyBindings(e){for(let t of e){let e=this.get(t);if(e.usedTimes--,0===e.usedTimes){for(let e of t.bindings)e.isUniformBuffer?(this.backend.destroyUniformBuffer(e),this.info.destroyUniformBuffer(e),e.release()):e.isSampler&&(!0!==e.isSampledTexture&&this.backend.destroySampler(e),e.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(let t of e)this._update(t,e)}_update(e,t){let{backend:r}=this,i=!1,s=!0,a=0,n=0;for(let t of e.bindings)if(!1!==this.nodes.updateGroup(t)){if(t.isStorageBuffer){let e=t.attribute,s=e.isIndirectStorageBufferAttribute?d8.INDIRECT:d8.STORAGE,a=r.get(t);this.attributes.update(e,s),a.attribute!==e&&(a.attribute=e,i=!0)}if(t.isUniformBuffer)t.update()&&r.updateBinding(t);else if(t.isSampledTexture){let o=t.update(),l=t.texture,u=this.textures.get(l);if(o&&(this.textures.updateTexture(l),t.generation!==u.generation&&(t.generation=u.generation,i=!0),u.bindGroups.add(e)),void 0!==r.get(l).externalTexture||u.isDefaultTexture?s=!1:(a=10*a+l.id,n+=l.version),!0===l.isStorageTexture&&!0===l.mipmapsAutoUpdate){let e=this.get(l);!0===t.store?e.needsMipmap=!0:this.textures.needsMipmaps(l)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(l),e.needsMipmap=!1)}}else if(t.isSampler&&t.update()){let e=this.textures.updateSampler(t);t.samplerKey!==e&&(t.samplerKey=e,i=!0)}t.isBuffer&&t.updateRanges.length>0&&t.clearUpdateRanges()}!0===i&&this.backend.updateBindings(e,t,s?a:0,n)}}let hh=Object.freeze([]);function hc(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 hp(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 hm(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===u.$EB&&!1===e.forceSinglePass}class hg{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0,this._lastOcclusionObject=null}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,a,n){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:a,clippingContext:n},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=a,o.clippingContext=n),this.renderItemsIndex++,o}push(e,t,r,i,s,a,n){let o=this.getNextRenderItem(e,t,r,i,s,a,n);!0===e.occlusionTest&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(hm(r)&&this.transparentDoublePass.push(o),this.transparent.push(o)):this.opaque.push(o)}unshift(e,t,r,i,s,a,n){let o=this.getNextRenderItem(e,t,r,i,s,a,n);!0===r.transparent||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(hm(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,r){this.opaque.length>1&&this.opaque.sort(e||hc),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||hp),this.transparent.length>1&&this.transparent.sort(t||hp),r&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:hh);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}this._lastOcclusionObject=null}}let hf=[];class hb{constructor(e){this.lighting=e,this.lists=new d0}get(e,t){let r=this.lists;hf[0]=e,hf[1]=t;let i=r.get(hf);return void 0===i&&(i=new hg(this.lighting,e,t),r.set(hf,i)),hf[0]=null,hf[1]=null,i}dispose(){this.lists=new d0}}let hy=0;class hx{constructor(){this.id=hy++,this.mrt=null,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.camera=null,this.isRenderContext=!0}getCacheKey(){return hT(this)}}function hT(e){let{textures:t,activeCubeFace:r,activeMipmapLevel:i}=e,s=[r,i];for(let e of t)s.push(e.id);return x(s)}class h_{constructor(e){this.renderer=e,this._renderContexts={}}get(e=null,t=null,r=0){let i;if(null===e)i="default";else{let t=e.texture.format,r=e.texture.type,s=e.textures.length;i=`${s}:${t}:${r}:${e.samples}:${e.depthBuffer}:${e.stencilBuffer}`}let s=i+"-"+(null!==t?t.id:"default")+"-"+r,a=this._renderContexts[s];return void 0===a&&((a=new hx).mrt=t,this._renderContexts[s]=a),null!==e&&(a.sampleCount=0===e.samples?1:e.samples),a.clearDepthValue=this.renderer.getClearDepth(),a.clearStencilValue=this.renderer.getClearStencil(),a}dispose(){this._renderContexts={}}}let hv=new u.Pq0;class hS extends d6{constructor(e,t,r){super(),this.renderer=e,this.backend=t,this.info=r,this._htmlTextures=new Set}updateRenderTarget(e,t=0){let r=this.get(e),i=0===e.samples?1:e.samples,s=r.depthTextureMips||(r.depthTextureMips={}),a=e.textures,n=this.getSize(a[0]),o=n.width>>t,l=n.height>>t,d=e.depthTexture||s[t],h=!0===e.depthBuffer||!0===e.stencilBuffer,c=!1,p=void 0!==d&&void 0!==d.image&&d.image.depth>1,m=n.depth>1&&(e.useArrayDepthTexture||e.multiview||p);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=n.depth,d.renderTarget=e,s[t]=d),d&&(d.isArrayTexture=m),(r.width!==n.width||n.height!==r.height)&&(c=!0,d&&(d.needsUpdate=!0,d.image.width=o,d.image.height=l,d.image.depth=m?n.depth:1)),r.width=n.width,r.height=n.height,r.textures=a,r.depthTexture=d||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleC
7ount!==i&&(c=!0,d&&(d.needsUpdate=!0),r.sampleCount=i);let g={sampleCount:i};if(!0!==e.isXRRenderTarget){for(let e=0;e<a.length;e++){let t=a[e];c&&(t.needsUpdate=!0),this.updateTexture(t,g)}d&&this.updateTexture(d,g)}!0!==r.initialized&&(r.initialized=!0,this.info.memory.renderTargets++,r.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}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.destroyTexture(e),e.isFramebufferTexture){let t=this.renderer.getRenderTarget();t?e.type=t.texture.type:e.type=u.OUM}if(e.isHTMLTexture&&e.image){let t=this.renderer.domElement;if("requestPaint"in t){if(t.hasAttribute("layoutsubtree")||t.setAttribute("layoutsubtree","true"),e.image.parentNode!==t&&t.appendChild(e.image),0===this._htmlTextures.size){let e=this._htmlTextures;t.onpaint=t=>{let r=t&&t.changedElements;for(let t of e)(!r||r.includes(t.image))&&(t.needsUpdate=!0)}}this._htmlTextures.add(e)}}let{width:a,height:n,depth:o}=this.getSize(e);if(t.width=a,t.height=n,t.depth=o,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,n):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,i||!0===e.isStorageTexture||!0===e.isExternalTexture)s.createTexture(e,t),r.generation=e.version;else if(e.version>0){let i=e.image;if(void 0===i)(0,u.R8M)("Renderer: Texture marked for update but image is undefined.");else if(!1===i.complete)(0,u.R8M)("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);let a=!0===e.isStorageTexture&&!1===e.mipmapsAutoUpdate;t.needsMipmaps&&0===e.mipmaps.length&&!a&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;!0!==r.initialized&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&!0===u.ppV.enabled&&u.ppV.getTransfer(e.colorSpace)!==u.KLL&&(0,u.R8M)("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=hv){let r=e.images?e.images[0]:e.image;return r?(void 0!==r.image&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):"undefined"!=typeof VideoFrame&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){return e.mipmaps.length>0?e.mipmaps.length:!0===e.isCompressedTexture?1:Math.floor(Math.log2(Math.max(t,r)))+1}needsMipmaps(e){return!0===e.generateMipmaps||e.mipmaps.length>0}_destroyRenderTarget(e){if(!0===this.has(e)){let t=this.get(e),r=t.textures,i=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let e=0;e<r.length;e++)this._destroyTexture(r[e]);i&&this._destroyTexture(i),this.delete(e),this.backend.delete(e),this.info.memory.renderTargets--}}_destroyTexture(e){if(!0===this.has(e)){let t=this.get(e);e.removeEventListener("dispose",t.onDispose);let r=t.isDefaultTexture;if(this.backend.destroyTexture(e,r),t.bindGroups)for(let r of t.bindGroups){let t=this.backend.get(r);for(let i of(t.groups=void 0,t.versions=void 0,r.bindings))i.isSampler&&i.texture===e&&(!0!==i.isSampledTexture&&this.backend.destroySampler(i),i.reset(),i.release())}this._htmlTextures.delete(e),this.delete(e),this.info.destroyTexture(e)}}}class hN 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 hR extends iS{static get type(){return"OverrideContextNode"}constructor(e,t=null){super(t,{overrideNodes:e}),this.isOverrideContextNode=!0}getFlowContextData(){let e=[];this.traverse(t=>{!0===t.isOverrideContextNode&&e.push(t.value.overrideNodes)});let t=new Map(e.flatMap(e=>Array.from(e.entries()))),r=super.getFlowContextData();return r.overrideNodes=t,r}}function hA(e,t=null,r=null){if(t&&t.isNode){let e=t;t=()=>e}return new hR(new Map([[e,t]]),r)}function hE(e,t=null){let r=new Map;for(let[t,i]of e){let e=null!==i?"function"==typeof i?i:()=>i:null;r.set(t,e)}return new hR(r,t)}Z("overrideNode",(e,t,r)=>hA(t,r,e)),Z("overrideNodes",(e,t)=>hE(t,e));class hC extends e9{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let r,i=this.getNodeType(e),s=e.getStructTypeNode(i);return null!==s?r=s.getMemberType(e,t):((0,u.z3S)(`TSL: Member "${t}" not found in struct "${i}".`,new f),r="float"),r}
7getHash(){return String(this.id)}generate(){return this.name}}class hw extends O{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):"void"}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=-1){if(!0!==e.isNode)return(0,u.z3S)("TSL: Invalid node added to stack.",new f),this;if(-1===t)if(this._currentNode){let e=this._nodeDataLibrary.get(this._currentNode);void 0===e&&(e={delta:0},this._nodeDataLibrary.set(this._currentNode,e)),e.delta++,t=this.nodes.indexOf(this._currentNode)+e.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}addToStackBefore(e){let t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){let r=new eN(t);return this._currentCond=iv(e,r),this.addToStack(this._currentCond)}ElseIf(e,t){let r=iv(e,new eN(t));return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new eN(e),this}Switch(e){return this._expressionNode=eR(e),this}Case(...e){let t=[];if(e.length>=2)for(let r=0;r<e.length-1;r++)t.push(this._expressionNode.equal(eR(e[r])));else(0,u.z3S)("TSL: Invalid parameter length. Case() requires at least two parameters.",new f);let r=new eN(e[e.length-1]),i=t[0];for(let e=1;e<t.length;e++)i=i.or(t[e]);let s=iv(i,r);return null===this._currentCond?(this._currentCond=s,this.addToStack(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&&i.isIntent(e)&&!0!==i.isAssign(e)||(t["node"+r++]=i);return t.outputNode||null}build(e,...t){let r,i=eO(),s=e.buildStage;eD(this),e.setActiveStack(this);for(let t=0;t<this.nodes.length;t++){let r=this.nodes[t],i=this._currentNode;if(this._currentNode=r,!(r.isVarNode&&r.isIntent(e))||!0===r.isAssign(e)){if("setup"===s)r.build(e);else if("analyze"===s)r.build(e,this);else if("generate"===s){let t=e.getDataFromNode(r,"any").stages,i=t&&t[e.shaderStage];if(r.isVarNode&&i&&1===i.length&&i[0]&&i[0].isStackNode)continue;r.build(e,"void")}this._currentNode=i}}if(this.outputNode){let i=this.outputNode.build(e,...t);("generate"!==e.buildStage||"void"!==this.outputNode.getNodeType(e))&&(r=i)}else r=super.build(e,...t);return eD(i),e.removeActiveStack(this),r}}let hM=ew(hw).setParameterLength(0,1);class hB extends O{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=Object.entries(e).map(([e,t])=>"string"==typeof t?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1}),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(let r of this.membersLayout){let i=r.type,s=/float|int|uint|bool/.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(0,u.z3S)(`TSL: Unsupported type: ${i}`,new f),a=/float|int|uint|bool/.test(i)?1:/vec2/.test(i)?2:/vec3/.test(i)||/vec4/.test(i)?4:/mat2/.test(i)?2:/mat3/.test(i)||/mat4/.test(i)?4:void(0,u.z3S)(`TSL: Unsupported type: ${i}`,new f),n=t%(e=Math.max(e,a))%a;0!==n&&(t+=a-n),t+=s}return Math.ceil(t/e)*e}getMemberType(e,t){let r=this.membersLayout.find(e=>e.name===t);return r?r.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class hU extends O{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){let e=super._getChildren(),t=e.find(e=>e.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){let t=e.getVarFromNode(this),r=t.type,i=e.getPropertyName(t);return e.addLineFlowCode(`${i} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}class hF extends O{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}generateNodeType(){return"OutputType"}generate(e){let t=e.getDataFromNode(this);if(void 0===t.membersLayout){let r=this.members,i=[];for(let t=0;t<r.length;t++){let s="m"+t,a=r[t].getNodeType(e);i.push({name:s,type:a,index:t})}t.membersLayout=i,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}let r=e.getOutputStructName(),i=this.members,s=""!==r?r+".":"";for(let r=0;r<i.length;r++){let a=i[r].build(e,t.membersLayout[r].type);e.addLineFlowCode(`${s}m${r} = ${a}`,this)}return r}}let hL=ew(hF);
7class hP{constructor(e=u.NTi){this.blending=e,this.blendSrc=u.ie2,this.blendDst=u.OuU,this.blendEquation=u.gO9,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.premultiplyAlpha=!1}copy(e){return this.blending=e.blending,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.premultiplyAlpha=e.premultiplyAlpha,this}clone(){return new this.constructor().copy(this)}}let hD=new hP(u.XIg),hO=new hP(u.pCc);function hI(e,t){for(let r=0;r<e.length;r++)if(e[r].name===t)return r;return -1}class hV extends hF{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.blendModes={output:hO},this.isMRTNode=!0}setBlendMode(e,t){return this.blendModes[e]=t,this}getBlendMode(e){return this.blendModes[e]||hD}has(e){return void 0!==this.outputNodes[e]}get(e){return this.outputNodes[e]}merge(e){let t={...this.outputNodes,...e.outputNodes},r={...this.blendModes,...e.blendModes},i=hG(t);return i.blendings=r,i}setup(e){let t=this.outputNodes,r=e.renderer.getRenderTarget(),i=[],s=r.textures;for(let r in t){let a=hI(s,r);if(-1===a)continue;let n=e.getOutputType(a);i[a]=t[r].convert(n)}return this.members=i,super.setup(e)}}let hG=ew(hV);class hk extends G{static get type(){return"BitcastNode"}constructor(e,t,r=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=r,this.isBitcastNode=!0}generateNodeType(e){if(null!==this.inputType){let t=this.valueNode.getNodeType(e),r=e.getTypeLength(t);return e.getTypeFromLength(r,this.conversionType)}return this.conversionType}generate(e){let t=this.getNodeType(e),r="";if(null!==this.inputType){let t=this.valueNode.getNodeType(e);r=1===e.getTypeLength(t)?this.inputType:e.changeComponentType(t,this.inputType)}else r=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,r)}( ${this.valueNode.build(e,r)} )`}}let hz=eB(hk).setParameterLength(2),h$=e=>new hk(e,"uint","float"),hW={};class hH extends ru{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){"int"===r?t.assign(hz(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return e$;case"int":return ez;case"uvec2":return ej;case"uvec3":return eY;case"uvec4":return e1;case"ivec2":return eq;case"ivec3":return eK;case"ivec4":return e0}}_createTrailingZerosBaseLayout(e,t){let r=this._returnDataNode(t);return eP(([e])=>{let i=e$(0);return this._resolveElementType(e,i,t),r(h$(ek(i.bitAnd(rH(i)))).shiftRight(23).sub(127))}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){let r=this._returnDataNode(t);return eP(([e])=>{eI(e.equal(e$(0)),()=>e$(32));let i=e$(0),s=e$(0);return this._resolveElementType(e,i,t),eI(i.shiftRight(16).equal(0),()=>{s.addAssign(16),i.shiftLeftAssign(16)}),eI(i.shiftRight(24).equal(0),()=>{s.addAssign(8),i.shiftLeftAssign(8)}),eI(i.shiftRight(28).equal(0),()=>{s.addAssign(4),i.shiftLeftAssign(4)}),eI(i.shiftRight(30).equal(0),()=>{s.addAssign(2),i.shiftLeftAssign(2)}),eI(i.shiftRight(31).equal(0),()=>{s.addAssign(1)}),r(s)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){let r=this._returnDataNode(t);return eP(([e])=>{let i=e$(0);return this._resolveElementType(e,i,t),i.assign(i.sub(i.shiftRight(e$(1)).bitAnd(e$(0x55555555)))),i.assign(i.bitAnd(e$(0x33333333)).add(i.shiftRight(e$(2)).bitAnd(e$(0x33333333)))),r(i.add(i.shiftRight(e$(4))).bitAnd(e$(0xf0f0f0f)).mul(e$(0x1010101)).shiftRight(e$(24)))}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,i){let s=this._returnDataNode(t);return eP(([e])=>{if(1===r)return s(i(e));{let t=s(0),a=["x","y","z","w"];for(let s=0;s<r;s++){let r=a[s];t[r].assign(i(e[r]))}return t}}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}setup(e){let{method:t,aNode:r}=this,{renderer:i}=e;if(i.backend.isWebGPUBackend)return super.setup(e);let s=this.getInputType(e),a=e.getElementType(s),n=e.getTypeLength(s),o=`${t}_base_${a}`,l=`${t}_${s}`,u=hW[o];if(void 0===u){switch(t){case hH.COUNT_LEADING_ZEROS:u=this._createLeadingZerosBaseLayout(o,a);break;case hH.COUNT_TRAILING_ZEROS:u=this._createTrailingZerosBaseLayout(o,a);break;case hH.COUNT_ONE_BITS:u=this._createOneBitsBaseLayout(o,a)}hW[o]=u}let d=hW[l];return void 0===d&&(d=this._createMainLayout(l,s,n,u),hW[l]=d),eP(()=>d(r))()}}hH.COUNT_TRAILING_ZEROS="countTrailingZeros",hH.COUNT_LEADING_ZEROS="countLeadingZeros",hH.COUNT_ONE_BITS="countOneBits";let hq=eB(hH,hH.COUNT_TRAILING_ZEROS).setParameterLength(1),hj=eB(hH,hH.COUNT_LEADING_ZEROS).setParameterLength(1),hX=eB(hH,hH.COUNT_ONE_BITS).setParameterLength(1),hQ=eP(([e])=>{let t=e.toUint().mul(0x2c9277b5).add(0xac564b05),r=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(0x108ef2d9);
7return r.shiftRight(22).bitXor(r).toFloat().mul(1/0x100000000)}),hK=(e,t)=>ie(tK(4,e.mul(tQ(1,e))),t);class hY extends G{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){let t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}let hZ=eB(hY,"snorm").setParameterLength(1),hJ=eB(hY,"unorm").setParameterLength(1),h0=eB(hY,"float16").setParameterLength(1);class h1 extends G{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return"vec2"}generate(e){let t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}let h2=eB(h1,"snorm").setParameterLength(1),h3=eB(h1,"unorm").setParameterLength(1),h4=eB(h1,"float16").setParameterLength(1),h5=eP(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),h6=eP(([e])=>eQ(h5(e.z.add(h5(e.y.mul(1)))),h5(e.z.add(h5(e.x.mul(1)))),h5(e.y.add(h5(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),h8=eP(([e,t,r])=>{let i=eQ(e).toVar(),s=ek(1.4).toVar(),a=ek(0).toVar(),n=eQ(i).toVar();return oJ({start:ek(0),end:ek(3),type:"float",condition:"<="},()=>{let e=eQ(h6(n.mul(2))).toVar();i.addAssign(e.add(r.mul(ek(.1).mul(t)))),n.mulAssign(1.8),s.mulAssign(1.5),i.mulAssign(1.2);let o=ek(h5(i.z.add(h5(i.x.add(h5(i.y)))))).toVar();a.addAssign(o.div(s)),n.addAssign(.14)}),a}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class h9 extends O{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){let t=this.parametersNodes,r=this._candidateFn;if(null===r){let i=null,s=-1;for(let r of this.functionNodes){let a=r.shaderNode.layout;if(null===a)throw Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");let n=a.inputs;if(t.length===n.length){let a=0;for(let r=0;r<t.length;r++){let i=t[r],s=n[r];i.getNodeType(e)===s.type&&a++}a>s&&(i=r,s=a)}}this._candidateFn=r=i}return r}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}let h7=ew(h9),ce=e=>(...t)=>h7(e,...t),ct=tV(0).setGroup(tD).onRenderUpdate(e=>e.time),cr=tV(0).setGroup(tD).onRenderUpdate(e=>e.deltaTime),ci=tV(0,"uint").setGroup(tD).onRenderUpdate(e=>e.frameId),cs=eP(([e,t,r=eH(.5)])=>d$(e.sub(r),t).add(r)),ca=eP(([e,t,r=eH(.5)])=>{let i=e.sub(r),s=i.dot(i),a=s.mul(s).mul(t);return e.add(i.mul(a))}),cn=eP(({position:e=null,horizontal:t=!0,vertical:r=!1})=>{let i;null!==e?((i=aR.toVar())[3][0]=e.x,i[3][1]=e.y,i[3][2]=e.z):i=aR;let s=ad.mul(i);return ev(t)&&(s[0][0]=aR[0].length(),s[0][1]=0,s[0][2]=0),ev(r)&&(s[1][0]=0,s[1][1]=aR[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,al.mul(s).mul(aI)}),co=eP(([e=null])=>{let t=lx();return lx(lu(e)).sub(t).lessThan(0).select(sj,e)}),cl=eP(([e,t=sE(),r=ek(0)])=>{let i=e.x,s=e.y,a=r.mod(i.mul(s)).floor(),n=a.mod(i),o=s.sub(a.add(1).div(i).ceil()),l=e.reciprocal(),u=eH(n,o);return t.add(u).mul(l)}),cu=eP(([e,t=null,r=null,i=ek(1),s=aI,a=aQ])=>{let n=a.abs().normalize();n=n.div(n.dot(eQ(1)));let o=s.yz.mul(i),l=s.zx.mul(i),u=s.xy.mul(i),d=e.value,h=null!==t?t.value:d,c=null!==r?r.value:d,p=sD(d,o).mul(n.x);return tX(p,sD(h,l).mul(n.y),sD(c,u).mul(n.z))}),cd=new u.Zcv,ch=new u.Pq0,cc=new u.Pq0,cp=new u.Pq0,cm=new u.kn4,cg=new u.Pq0(0,0,-1),cf=new u.IUQ,cb=new u.Pq0,cy=new u.Pq0,cx=new u.IUQ,cT=new u.I9Y,c_=new u.O0B,cv=sj.flipX();c_.depthTexture=new u.VCu(1,1);let cS=!1;class cN extends sL{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||c_.texture,cv),this._reflectorBaseNode=e.reflector||new cR(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 
7can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new cN({defaultTexture:c_.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.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class cR extends O{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();let{target:r=new u.B69,resolutionScale:i=1,generateMipmaps:s=!1,bounces:a=!0,depth:n=!1,samples:o=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=i,void 0!==t.resolution&&((0,u.mcG)('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=s,this.bounces=a,this.depth=n,this.samples=o,this.updateBeforeType=a?w.RENDER:w.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let r=this.resolutionScale;t.getDrawingBufferSize(cT),e.setSize(Math.round(cT.width*r),Math.round(cT.height*r))}setup(e){return this._updateResolution(c_,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,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=u.NZq,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new u.VCu),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&cS)return!1;cS=!0;let{scene:t,camera:r,renderer:i,material:s}=e,{target:a}=this,n=this.getVirtualCamera(r),o=this.getRenderTarget(n);i.getDrawingBufferSize(cT),this._updateResolution(o,i),cc.setFromMatrixPosition(a.matrixWorld),cp.setFromMatrixPosition(r.matrixWorld),cm.extractRotation(a.matrixWorld),ch.set(0,0,1),ch.applyMatrix4(cm),cb.subVectors(cc,cp);let l=cb.dot(ch)>0,d=!1;if(!0===l&&!1===this.forceUpdate){if(!1===this.hasOutput){cS=!1;return}d=!0}cb.reflect(ch).negate(),cb.add(cc),cm.extractRotation(r.matrixWorld),cg.set(0,0,-1),cg.applyMatrix4(cm),cg.add(cp),cy.subVectors(cc,cg),cy.reflect(ch).negate(),cy.add(cc),n.coordinateSystem=r.coordinateSystem,n.position.copy(cb),n.up.set(0,1,0),n.up.applyMatrix4(cm),n.up.reflect(ch),n.lookAt(cy),n.near=r.near,n.far=r.far,n.updateMatrixWorld(),n.projectionMatrix.copy(r.projectionMatrix),cd.setFromNormalAndCoplanarPoint(ch,cc),cd.applyMatrix4(n.matrixWorldInverse),cf.set(cd.normal.x,cd.normal.y,cd.normal.z,cd.constant);let h=n.projectionMatrix;cx.x=(Math.sign(cf.x)+h.elements[8])/h.elements[0],cx.y=(Math.sign(cf.y)+h.elements[9])/h.elements[5],cx.z=-1,cx.w=(1+h.elements[10])/h.elements[14],cf.multiplyScalar(1/cf.dot(cx)),h.elements[2]=cf.x,h.elements[6]=cf.y,h.elements[10]=i.coordinateSystem===u.i7u?cf.z-0:cf.z+1-0,h.elements[14]=cf.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(),m=i.autoClear;i.setMRT(null),i.setRenderTarget(o),i.autoClear=!0;let g=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",d?(i.clear(),this.hasOutput=!1):(i.render(t,n),this.hasOutput=!0),t.name=g,i.setMRT(p),i.setRenderTarget(c),i.autoClear=m,s.visible=!0,cS=!1,this.forceUpdate=!1}get resolution(){return(0,u.mcG)('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){(0,u.mcG)('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}let cA=new u.qUd(-1,1,1,-1,0,1);class cE 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 cC=new cE;class cw extends u.eaF{constructor(e=null){super(cC,e),this.camera=cA,this.isQuadMesh=!0}async renderAsync(e){(0,u.mcG)('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();
7" when creating the renderer.'),await e.init(),e.render(this,cA)}render(e){e.render(this,cA)}}let cM=new u.I9Y;class cB extends sL{static get type(){return"RTTNode"}constructor(e,t=null,r=null,i={type:u.ix0}){let s=new u.O0B(t,r,i);super(s.texture,sE()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=r,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new cw(new lE),this.updateBeforeType=w.RENDER}get autoResize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){let r=Math.floor(e*this._resolutionScale),i=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(r,i),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,!1===this.autoResize&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;this.textureNeedsUpdate=!1;let t=e.getRenderTarget();if(!0===this.autoResize){let t=e.getDrawingBufferSize(cM),r=Math.floor(t.width*this._resolutionScale),i=Math.floor(t.height*this._resolutionScale);(r!==this.renderTarget.width||i!==this.renderTarget.height)&&(this.renderTarget.setSize(r,i),this.textureNeedsUpdate=!0)}let r="RTT";this.node.name&&(r=this.node.name+" [ "+r+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=r,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){let e=new sL(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}let cU=(e,...t)=>new cB(eR(e),...t),cF=eP(([e,t,r],i)=>{let s;s=i.renderer.coordinateSystem===u.i7u?eJ(eQ(e=eH(e.x,e.y.oneMinus()).mul(2).sub(1),t),1):eJ(eQ(e.x,e.y.oneMinus(),t).mul(2).sub(1),1);let a=eJ(r.mul(s));return a.xyz.div(a.w)}),cL=eP(([e,t])=>{let r=t.mul(eJ(e,1)),i=r.xy.div(r.w).mul(.5).add(.5).toVar();return eH(i.x,i.y.oneMinus())}),cP=eP(([e,t,r])=>{let i=sw(sO(t)),s=eq(e.mul(i)).toVar(),a=sO(t,s).toVar(),n=sO(t,s.sub(eq(2,0))).toVar(),o=sO(t,s.sub(eq(1,0))).toVar(),l=sO(t,s.add(eq(1,0))).toVar(),u=sO(t,s.add(eq(2,0))).toVar(),d=sO(t,s.add(eq(0,2))).toVar(),h=sO(t,s.add(eq(0,1))).toVar(),c=sO(t,s.sub(eq(0,1))).toVar(),p=sO(t,s.sub(eq(0,2))).toVar(),m=rz(tQ(ek(2).mul(o).sub(n),a)).toVar(),g=rz(tQ(ek(2).mul(l).sub(u),a)).toVar(),f=rz(tQ(ek(2).mul(h).sub(d),a)).toVar(),b=rz(tQ(ek(2).mul(c).sub(p),a)).toVar(),y=cF(e,a,r).toVar();return rC(r7(m.lessThan(g).select(y.sub(cF(e.sub(eH(ek(1).div(i.x),0)),o,r)),y.negate().add(cF(e.add(eH(ek(1).div(i.x),0)),l,r))),f.lessThan(b).select(y.sub(cF(e.add(eH(0,ek(1).div(i.y))),h,r)),y.negate().add(cF(e.sub(eH(0,ek(1).div(i.y))),c,r)))))}),cD=eP(([e])=>rw(ek(52.9829189).mul(rw(r9(e,eH(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),cO=eP(([e,t,r])=>{let i=ek(2.399963229728653),s=rN(ek(e).add(.5).div(ek(t))),a=ek(e).mul(i).add(r);return eH(rU(a),rM(a)).mul(s)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class cI extends O{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(sE())}sample(e){return this.callback(e)}}class cV extends u.uWO{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageInstancedBufferAttribute=!0}}class cG extends u.THS{constructor(e,t,r=Float32Array){super(ArrayBuffer.isView(e)?e:new r(e*t),t),this.isStorageBufferAttribute=!0}}class ck extends O{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}let cz=eM(ck),c$=new u.kn4,cW=tV(0).setGroup(tD).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),cH=tV(1).setGroup(tD).onRenderUpdate(({scene:e})=>e.backgroundIntensity),cq=tV(new u.kn4).setGroup(tD).onRenderUpd
7ate(({scene:e})=>{let t=e.background;return null!==t&&t.isTexture&&t.mapping!==u.UTZ||e.backgroundNode&&e.backgroundNode.isNode?c$.makeRotationFromEuler(e.backgroundRotation).transpose():c$.identity(),c$});class cj extends sL{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=M.WRITE_ONLY}getInputType(){return"storageTexture"}getTransformedUV(e){return e}setup(e){super.setup(e);let t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return null!==this.storeNode?(this.generateStore(e),""):super.generate(e,t)}generateSnippet(e,t,r,i,s,a,n,o,l){let u=this.value;return e.generateStorageTextureLoad(u,t,r,i,a,l)}toReadWrite(){return this.setAccess(M.READ_WRITE)}toReadOnly(){return this.setAccess(M.READ_ONLY)}toWriteOnly(){return this.setAccess(M.WRITE_ONLY)}store(e,t){let r=this.clone();return r.referenceNode=this.getBase(),r.uvNode=e,r.storeNode=t,null!==t&&r.toStack(),r}generateStore(e){let{uvNode:t,storeNode:r,depthNode:i}=e.getNodeProperties(this),s=super.generate(e,"property"),a=t.build(e,!0===this.value.is3DTexture?"uvec3":"uvec2"),n=r.build(e,"vec4"),o=i?i.build(e,"int"):null,l=e.generateTextureStore(this.value,s,a,o,n);e.addLineFlowCode(l,this)}clone(){let e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}let cX=ew(cj).setParameterLength(1,3);class cQ extends cj{static get type(){return"StorageTexture3DNode"}constructor(e,t,r=null){super(e,t,r),this.isStorageTexture3DNode=!0}getDefaultUV(){return eQ(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}}let cK=ew(cQ).setParameterLength(1,3),cY=eP(({texture:e,uv:t})=>{let r=eQ().toVar();return eI(t.x.lessThan(1e-4),()=>{r.assign(eQ(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{r.assign(eQ(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{r.assign(eQ(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{r.assign(eQ(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{r.assign(eQ(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{r.assign(eQ(0,0,-1))}).Else(()=>{let i=e.sample(t.add(eQ(-.01,0,0))).r.sub(e.sample(t.add(eQ(.01,0,0))).r),s=e.sample(t.add(eQ(0,-.01,0))).r.sub(e.sample(t.add(eQ(0,.01,0))).r),a=e.sample(t.add(eQ(0,0,-.01))).r.sub(e.sample(t.add(eQ(0,0,.01))).r);r.assign(eQ(i,s,a))}),r.normalize()});class cZ extends sL{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return eQ(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return cY({texture:this,uv:e})}}let cJ=ew(cZ).setParameterLength(1,3);class c0 extends nd{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 c1=new WeakMap;class c2 extends G{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=w.OBJECT,this.updateAfterType=w.OBJECT,this.previousModelWorldMatrix=tV(new u.kn4),this.previousProjectionMatrix=tV(new u.kn4).setGroup(tD),this.previousCameraViewMatrix=tV(new u.kn4)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){let i=c4(r);this.previousModelWorldMatrix.value.copy(i);let s=c3(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}){c4(e).copy(e.matrixWorld)}setup(){let e=null===this.projectionMatrix?al:tV(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(aU).mul(aI
7),i=this.previousProjectionMatrix.mul(t).mul(aV);return tQ(r.xy.div(r.w),i.xy.div(i.w))}}function c3(e){let t=c1.get(e);return void 0===t&&(t={},c1.set(e,t)),t}function c4(e,t=0){let r=c3(e),i=r[t];return void 0===i&&(r[t]=i=new u.kn4,r[t].copy(e.matrixWorld)),i}let c5=eM(c2),c6=eP(([e,t])=>r2(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),c8=eP(([e,t])=>r2(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),c9=eP(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),c7=eP(([e,t])=>id(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),r4(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),pe=eP(([e,t])=>{let r=t.a.add(e.a.mul(t.a.oneMinus()));return eJ(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"}]}),pt=eP(([e])=>pa(e.rgb)),pr=eP(([e,t=ek(1)])=>t.mix(pa(e.rgb),e.rgb).max(0)),pi=eP(([e,t=ek(0)])=>{let r=tX(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 id(e.rgb,i,s).max(0)}),ps=eP(([e,t=ek(1)])=>{let r=eQ(.57735,.57735,.57735),i=t.cos();return eQ(e.rgb.mul(i).add(r.cross(e.rgb).mul(t.sin()).add(r.mul(r9(r,e.rgb).mul(i.oneMinus()))))).max(0)}),pa=(e,t=eQ(u.ppV.getLuminanceCoefficients(new u.Pq0)))=>r9(e,t),pn=eP(([e,t=eQ(1),r=eQ(0),i=eQ(1),s=ek(1),a=eQ(u.ppV.getLuminanceCoefficients(new u.Pq0,u.Zr2))])=>{let n=e.rgb.dot(eQ(a)),o=r3(e.rgb.mul(t).add(r),0),l=o.pow(i);return eI(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),eI(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),eI(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(n.add(o.sub(n).mul(s)).max(0)),eJ(o.rgb,e.a)}),po=eP(([e,t])=>e.mul(t).floor().div(t)),pl=null;class pu extends lr{static get type(){return"ViewportSharedTextureNode"}constructor(e=sj,t=null){null===pl&&(pl=new u.Pem),super(e,t,pl)}getTextureForReference(){return pl}updateReference(){return this}}let pd=ew(pu).setParameterLength(0,2),ph=new u.I9Y;class pc extends sL{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){return e.getNodeProperties(this).passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class pp extends pc{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}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.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}class pm extends G{static get type(){return"PassNode"}constructor(e,t,r,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=i,this._width=1,this._height=1;let s=new u.O0B(this._width,this._height,{type:u.ix0,...i});s.texture.name="output";let a=null;(this.scope===pm.DEPTH||!1!==i.depthBuffer)&&((a=new u.VCu).isRenderTargetTexture=!0,a.name="depth",s.depthTexture=a),this.renderTarget=s,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:s.texture},null!==a&&(this._textures.depth=a),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=tV(0),this._cameraFar=tV(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=w.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return(0,u.R8M)("PassNode: .setResolution() is deprecated. Use .setRe
7solutionScale() instead."),this.setResolutionScale(e)}getResolution(){return(0,u.R8M)("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(void 0===t){if("depth"===e)throw Error("THREE.PassNode: Depth texture is not available for this pass.");(t=this.renderTarget.texture.clone()).name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return 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=new pp(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=new pp(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=lg(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=lh(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.getOutputBufferType(),!0===e.reversedDepthBuffer&&null!==this.renderTarget.depthTexture&&(this.renderTarget.depthTexture.type=u.RQf),this.scope===pm.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){let t,{renderer:r}=e,{scene:i}=this,s=r.getOutputRenderTarget();s&&!0===s.isXRRenderTarget?(t=r.xr.getCamera(),r.xr.updateCamera(t),ph.set(s.width,s.height)):(t=this.camera,r.getDrawingBufferSize(ph)),this.setSize(ph.width,ph.height);let a=r.getRenderTarget(),n=r.getMRT(),o=r.autoClear,l=r.transparent,u=r.opaque,d=t.layers.mask,h=r.contextNode,c=i.overrideMaterial;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);null!==this.overrideMaterial&&(i.overrideMaterial=this.overrideMaterial),r.setRenderTarget(this.renderTarget),r.setMRT(this._mrt),r.autoClear=!0,r.transparent=this.transparent,r.opaque=this.opaque,null!==this.contextNode&&((null===this._contextNodeCache||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:iN({...r.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),r.contextNode=this._contextNodeCache.context);let p=i.name;i.name=this.name?this.name:i.name,r.render(i,t),i.name=p,i.overrideMaterial=c,r.setRenderTarget(a),r.setMRT(n),r.autoClear=o,r.transparent=l,r.opaque=u,r.contextNode=h,t.layers.mask=d}setSize(e,t){this._width=e,this._height=t;let r=Math.floor(this._width*this._resolutionScale),i=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,i),null!==this._scissor?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,null!==this._viewport&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}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
7))}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))}dispose(){this.renderTarget.dispose()}}pm.COLOR="color",pm.DEPTH="depth";class pg extends pm{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,i,s){super(pm.COLOR,e,t),this.colorNode=r,this.thicknessNode=i,this.alphaNode=s,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){let{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((e,r,i,s,a,n,o,l)=>{if((a.isMeshToonMaterial||a.isMeshToonNodeMaterial)&&!1===a.wireframe){let u=this._getOutlineMaterial(a);t.renderObject(e,r,i,s,u,n,o,l)}t.renderObject(e,r,i,s,a,n,o,l)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){let e=new lE;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=u.hsX;let t=aQ.negate(),r=al.mul(aU),i=ek(1),s=r.mul(eJ(aI,1)),a=r.mul(eJ(aI.add(t),1)),n=rC(s.sub(a));return e.vertexNode=s.add(n.mul(this.thicknessNode).mul(s.w).mul(i)),e.colorNode=eJ(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 pf=eP(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pb=eP(([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"}]}),py=eP(([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"}]}),px=eP(([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)}),pT=eP(([e,t])=>{let r=e4(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=e4(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=px(e=r.mul(e)),(e=i.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),p_=e4(eQ(1.6605,-.1246,-.0182),eQ(-.5876,1.1329,-.1006),eQ(-.0728,-.0083,1.1187)),pv=e4(eQ(.6274,.0691,.0164),eQ(.3293,.9195,.088),eQ(.0433,.0113,.8956)),pS=eP(([e])=>{let t=eQ(e).toVar(),r=eQ(t.mul(t)).toVar(),i=eQ(r.mul(r)).toVar();return ek(15.5).mul(i.mul(r)).sub(tK(40.14,i.mul(t))).add(tK(31.96,i).sub(tK(6.868,r.mul(t))).add(tK(.4298,r).add(tK(.1191,t).sub(.00232))))}),pN=eP(([e,t])=>{let r=eQ(e).toVar(),i=e4(eQ(.856627153315983,.137318972929847,.11189821299995),eQ(.0951212405381588,.761241990602591,.0767994186031903),eQ(.0482516061458583,.101439036467562,.811302368396859)),s=e4(eQ(1.1271005818144368,-.1413297634984383,-.14132976349843826),eQ(-.11060664309660323,1.157823702216272,-.11060664309660294),eQ(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=ek(-12.47393),n=ek(4.026069);return r.mulAssign(t),r.assign(pv.mul(r)),r.assign(i.mul(r)),r.assign(r3(r,1e-10)),r.assign(rS(r)),r.assign(r.sub(a).div(n.sub(a))),r.assign(ih(r,0,1)),r.assign(pS(r)),r.assign(s.mul(r)),r.assign(ie(r3(eQ(0),r),eQ(2.2))),r.assign(p_.mul(r)),r.assign(ih(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pR=eP(([e,t])=>{let r=ek(.76),i=ek(.15),s=r2((e=e.mul(t)).r,r2(e.g,e.b)),a=iv(s.lessThan(.08),s.sub(tK(6.25,s.mul(s))),.04);e.subAssign(a);let n=r3(e.r,r3(e.g,e.b));eI(n.lessThan(r),()=>e);let o=tQ(1,r),l=tQ(1,o.mul(o).div(n.add(o.sub(r))));e.mulAssign(l.div(n));let u=tQ(1,tY(1,i.mul(n.sub(l)).add(1)));return id(e,eQ(l),u)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class pA extends O{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 pE=ew(pA).setParameterLength(1,3);class pC extends pA{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){let r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}
7getNodeFunction(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,a=e.getCodeFromNode(this,s);""!==i&&(a.name=i);let n=e.getPropertyName(a);return(a.code=this.getNodeFunction(e).getCode(n)+"\n","property"===t)?n:e.format(`${n}()`,s,t)}}let pw=(e,t=[],r="")=>{let i=new pC(e,t,r);return eU((...e)=>i.call(...e),i)};function pM(e){let t,r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||az.z).negate()}let pB=eP(([e,t],r)=>im(e,t,pM(r))),pU=eP(([e],t)=>{let r=pM(t);return e.mul(e,r,r).negate().exp().oneMinus()}),pF=eP(([e,t],r)=>{let i=pM(r),s=t.sub(aG.y).max(0).toConst().mul(i).toConst();return e.mul(e,s,s).negate().exp().oneMinus()}),pL=eP(([e,t])=>eJ(t.toFloat().mix(t_.rgb,e.toVec3()),t_.a)),pP=null,pD=null;class pO extends O{static get type(){return"RangeNode"}constructor(e=ek(),t=ek()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),i=e.getTypeLength(R(t.value)),s=e.getTypeLength(R(r.value));return i>s?i:s}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(e=>{!0===e.isConstNode&&(t=e)}),null===t)throw new sU('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){let t=e.object,r=null;if(t.count>1){let i=this.getConstNode(this.minNode),s=this.getConstNode(this.maxNode),a=i.value,n=s.value,o=e.getTypeLength(R(a)),l=e.getTypeLength(R(n));pP=pP||new u.IUQ,pD=pD||new u.IUQ,pP.setScalar(0),pD.setScalar(0),1===o?pP.setScalar(a):a.isColor?pP.set(a.r,a.g,a.b,1):pP.set(a.x,a.y,a.z||0,a.w||0),1===l?pD.setScalar(n):n.isColor?pD.set(n.r,n.g,n.b,1):pD.set(n.x,n.y,n.z||0,n.w||0);let d=4*t.count,h=new Float32Array(d);for(let e=0;e<d;e++){let t=e%4,r=pP.getComponent(t),i=pD.getComponent(t);h[e]=u.cj9.lerp(r,i,Math.random())}let c=this.getNodeType(e);if(4*t.count*4<=e.getUniformBufferLimit())r=sV(h,"vec4",t.count).element(i9).
7convert(c);else{let t=new u.uWO(h,4);e.geometry.setAttribute("__range"+this.id,t),r=i4(t).convert(c)}}else r=ek(0);return r}}let pI=ew(pO).setParameterLength(2);class pV extends O{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}generateNodeType(){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):((0,u.R8M)(`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 pG=(e,t)=>new pV(e,t),pk=pG("numWorkgroups","uvec3"),pz=pG("workgroupId","uvec3"),p$=pG("globalId","uvec3"),pW=pG("localId","uvec3"),pH=pG("subgroupSize","uint");class pq extends O{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){let{scope:t}=this,{renderer:r}=e;!0===r.backend.isWebGLBackend?e.addFlowCode(`	// ${t}Barrier 
8`):e.addLineFlowCode(`${t}Barrier()`,this)}}let pj=ew(pq);class pX extends I{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r,i=e.isContextAssign();if(r=super.generate(e),!0!==i){let i=this.getNodeType(e);r=e.format(r,i,t)}return r}}class pQ extends O{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(0,u.R8M)('TSL: "label()" has been deprecated. Use "setName()" instead.',new f),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new pX(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 pK extends O{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)}generateNodeType(e){return this.getInputType(e)}generate(e){let t=e.getNodeProperties(this),r=t.parents,i=this.method,s=this.getNodeType(e),a=this.getInputType(e),n=this.pointerNode,o=this.valueNode,l=[];l.push(`&${n.build(e,a)}`),null!==o&&l.push(o.build(e,a));let u=`${e.getMethod(i,s)}( ${l.join(", ")} )`;if(!(r&&1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=sm(u,s).toConst()),t.constNode.build(e);e.addLineFlowCode(u,this)}}pK.ATOMIC_LOAD="atomicLoad",pK.ATOMIC_STORE="atomicStore",pK.ATOMIC_ADD="atomicAdd",pK.ATOMIC_SUB="atomicSub",pK.ATOMIC_MAX="atomicMax",pK.ATOMIC_MIN="atomicMin",pK.ATOMIC_AND="atomicAnd",pK.ATOMIC_OR="atomicOr",pK.ATOMIC_XOR="atomicXor";let pY=ew(pK),pZ=(e,t,r)=>pY(e,t,r).toStack();class pJ extends G{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){let t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null;return(e.isMatrix(t)?0:e.getTypeLength(t))>(e.isMatrix(r)?0:e.getTypeLength(r))?t:r}generateNodeType(e){let t=this.method;return t===pJ.SUBGROUP_ELECT?"bool":t===pJ.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){let r=this.method,i=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,n=this.bNode,o=[];if(r===pJ.SUBGROUP_BROADCAST||r===pJ.SUBGROUP_SHUFFLE||r===pJ.QUAD_BROADCAST){let t=n.getNodeType(e);o.push(a.build(e,i),n.build(e,"float"===t?"int":i))}else r===pJ.SUBGROUP_SHUFFLE_XOR||r===pJ.SUBGROUP_SHUFFLE_DOWN||r===pJ.SUBGROUP_SHUFFLE_UP?o.push(a.build(e,i),n.build(e,"uint")):(null!==a&&o.push(a.build(e,s)),null!==n&&o.push(n.build(e,s)));let l=0===o.length?"()":`( ${o.join(", ")} )`;return e.format(`${e.getMethod(r,i)}${l}`,i,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}pJ.SUBGROUP_ELECT="subgroupElect",pJ.SUBGROUP_BALLOT="subgroupBallot",pJ.SUBGROUP_ADD="subgroupAdd",pJ.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",pJ.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",pJ.SUBGROUP_MUL="subgroupMul",pJ.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",pJ.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",pJ.SUBGROUP_AND="subgroupAnd",pJ.SUBGROUP_OR="subgroupOr",pJ.SUBGROUP_XOR="subgroupXor",pJ.SUBGROUP_MIN="subgroupMin",pJ.SUBGROUP_MAX="subgroupMax",pJ.SUBGROUP_ALL="subgroupAll",pJ.SUBGROUP_ANY="subgroupAny",pJ.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",pJ.QUAD_SWAP_X="quadSwapX",pJ.QUAD_SWAP_Y="quadSwapY",pJ.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",pJ.SUBGROUP_BROADCAST="subgroupBroadcast",pJ.SUBGROUP_SHUFFLE="subgroupShuffle",pJ.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",pJ.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",pJ.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",pJ.QUAD_BROADCAST="quadBroadcast";let p0=eB(pJ,pJ.SUBGROUP_ELECT).setParameterLength(0),p1=eB(pJ,pJ.SUBGROUP_BALLOT).setParameterLength(1),p2=eB(pJ,pJ.SUBGROUP_ADD).setParameterLength(1),p3
8=eB(pJ,pJ.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),p4=eB(pJ,pJ.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),p5=eB(pJ,pJ.SUBGROUP_MUL).setParameterLength(1),p6=eB(pJ,pJ.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),p8=eB(pJ,pJ.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),p9=eB(pJ,pJ.SUBGROUP_AND).setParameterLength(1),p7=eB(pJ,pJ.SUBGROUP_OR).setParameterLength(1),me=eB(pJ,pJ.SUBGROUP_XOR).setParameterLength(1),mt=eB(pJ,pJ.SUBGROUP_MIN).setParameterLength(1),mr=eB(pJ,pJ.SUBGROUP_MAX).setParameterLength(1),mi=eB(pJ,pJ.SUBGROUP_ALL).setParameterLength(0),ms=eB(pJ,pJ.SUBGROUP_ANY).setParameterLength(0),ma=eB(pJ,pJ.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),mn=eB(pJ,pJ.QUAD_SWAP_X).setParameterLength(1),mo=eB(pJ,pJ.QUAD_SWAP_Y).setParameterLength(1),ml=eB(pJ,pJ.QUAD_SWAP_DIAGONAL).setParameterLength(1),mu=eB(pJ,pJ.SUBGROUP_BROADCAST).setParameterLength(2),md=eB(pJ,pJ.SUBGROUP_SHUFFLE).setParameterLength(2),mh=eB(pJ,pJ.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),mc=eB(pJ,pJ.SUBGROUP_SHUFFLE_UP).setParameterLength(2),mp=eB(pJ,pJ.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),mm=eB(pJ,pJ.QUAD_BROADCAST).setParameterLength(1);function mg(e){let t=(a=a||new WeakMap).get(e);return void 0===t&&a.set(e,t={}),t}function mf(e){let t=mg(e);return t.shadowMatrix||(t.shadowMatrix=tV("mat4").setGroup(tD).onRenderUpdate(t=>((!0!==e.castShadow||!1===t.renderer.shadowMap.enabled)&&(e.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(e.shadow.camera.coordinateSystem=t.camera.coordinateSystem,e.shadow.camera.updateProjectionMatrix()),e.shadow.updateMatrices(e)),e.shadow.matrix)))}function mb(e,t=aG){let r=mf(e).mul(t);return r.xyz.div(r.w)}function my(e){let t=mg(e);return t.position||(t.position=tV(new u.Pq0).setGroup(tD).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function mx(e){let t=mg(e);return t.targetPosition||(t.targetPosition=tV(new u.Pq0).setGroup(tD).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))}function mT(e){let t=mg(e);return t.viewPosition||(t.viewPosition=tV(new u.Pq0).setGroup(tD).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new u.Pq0,r.value.setFromMatrixPosition(e.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}let m_=e=>ad.transformDirection(my(e).sub(mx(e))),mv=e7("vec3","totalDiffuse"),mS=e7("vec3","totalSpecular"),mN=e7("vec3","outgoingLight"),mR=(e,t)=>{for(let r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},mA=new WeakMap,mE=[];class mC extends O{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=mv,this.totalSpecularNode=mS,this.outgoingLightNode=mN,this._lights=[],this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let r=e[t];if(mE.push(r.id),mE.push(+!!r.castShadow),!0===r.isSpotLight){let e=null!==r.map?r.map.id:-1,t=r.colorNode?r.colorNode.getCacheKey():-1;mE.push(e,t)}}let t=x(mE);return mE.length=0,t}getHash(e){let t=e.getDataFromNode(this);if(void 0===t.lightNodesHash){let r=this.setupLightsNode(e);t.lightNodes=r;let i=[];for(let e of r)i.push(e.getHash());t.lightNodesHash="lights-"+i.join(",")}return t.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=e.getDataFromNode(this),r=[],i=t.lightNodes||null,s=[...e.context.materialLightings,...this._lights].sort((e,t)=>e.id-t.id),a=e.renderer.library;for(let e of s)if(e.isNode)r.push(e);else{let t=null;if(null!==i&&(t=mR(e.id,i)),null===t){let r=a.getLightNodeClass(e.constructor);if(null===r){(0,u.R8M)(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}!1===mA.has(e)&&mA.set(e,new r(e)),t=mA.get(e)}r.push(t)}return r}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){let t=e.getDataFromNode(this);return void 0===t.lightNodes&&(t.lightNodes=this.setupLightsNode(e)),t.lightNodes}setup(e){let t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode,i=e.context,s=i.lightingModel,a=e.getNodeProperties(this);if(s){let{totalDiffuseNode:t,totalSpecularNode:n}=this;i.outgoingLight=r,a.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?eQ(l.mix(p,o)):eQ(o)),t.assign(p),n.assign(d.add(c)),r.assign(t.add(n)),s.finish(e),r=r.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}class mw extends O{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=w.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){mM.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||aG)}}let mM=e7("vec3","shadowPositionWorld"),mB=new WeakMap,mU=eP(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let i=sD(e,t.xy).setName("t_basic");return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)}),mF=eP(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i}
8)=>{let s=(t,r)=>{let s=sD(e,t);return e.isArrayTexture&&(s=s.depth(i)),s.compare(r)},a=nh("mapSize","vec2",r).setGroup(tD),n=nh("radius","float",r).setGroup(tD),o=eH(1).div(a),l=n.mul(o.x),u=cD(sQ.xy).mul(6.28318530718);return tX(s(t.xy.add(cO(0,5,u).mul(l)),t.z),s(t.xy.add(cO(1,5,u).mul(l)),t.z),s(t.xy.add(cO(2,5,u).mul(l)),t.z),s(t.xy.add(cO(3,5,u).mul(l)),t.z),s(t.xy.add(cO(4,5,u).mul(l)),t.z)).mul(.2)}),mL=eP(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:i})=>{let s=nh("mapSize","vec2",r).setGroup(tD),a=eH(1).div(s),n=t.xy,o=rw(n.mul(s).add(.5)).toConst();n.subAssign(o.sub(.5).mul(a));let l=r=>{let s=sD(e,n).offset(r).gather();return e.isArrayTexture&&(s=s.depth(i)),s.compare(t.z)},u=l(eq(-1,1)).toConst(),d=l(eq(1,1)).toConst(),h=l(eq(-1,-1)).toConst(),c=l(eq(1,-1)).toConst();return tX(id(u.x,d.y,o.x).add(u.y).add(d.x).mul(o.y),id(u.w,d.z,o.x).add(u.z).add(d.w),id(h.x,c.y,o.x).add(h.y).add(c.x),id(h.w,c.z,o.x).add(h.z).add(c.w).mul(o.y.oneMinus())).mul(1/9)}),mP=eP(({depthTexture:e,shadowCoord:t,depthLayer:r},i)=>{let s=sD(e).sample(t.xy);e.isArrayTexture&&(s=s.depth(r));let a=(s=s.rg).x,n=r3(1e-7,s.y.mul(s.y)),o=i.renderer.reversedDepthBuffer?r4(a,t.z):r4(t.z,a),l=ek(1).toVar();return eI(o.notEqual(1),()=>{let e=t.z.sub(a),r=n.div(n.add(e.mul(e)));r=ih(tQ(r,.3).div(.65)),l.assign(r3(o,r))}),l}),mD=e=>{let t=mB.get(e);return void 0===t&&((t=new lE).colorNode=eJ(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=u.XIg,t.fog=!1,mB.set(e,t)),t},mO=e=>{let t=mB.get(e);void 0!==t&&(t.dispose(),mB.delete(e))},mI=new d0,mV=[],mG=(e,t,r,i)=>{mV[0]=e,mV[1]=t;let s=mI.get(mV);return(void 0===s||s.shadowType!==r||s.useVelocity!==i)&&((s=(s,a,n,o,l,d,h,c,p)=>{(!0===s.castShadow||s.receiveShadow&&r===u.RyA)&&(i&&(E(s).useVelocity=!0),s.onBeforeShadow(e,s,n,t.camera,o,a.overrideMaterial,d),e.renderObject(s,a,n,o,l,d,h,c,p),s.onAfterShadow(e,s,n,t.camera,o,a.overrideMaterial,d))}).shadowType=r,s.useVelocity=i,mI.set(mV,s)),mV[0]=null,mV[1]=null,s},mk=eP(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:s})=>{let a=ek(0).toVar("meanVertical"),n=ek(0).toVar("squareMeanVertical"),o=e.lessThanEqual(ek(1)).select(ek(0),ek(2).div(e.sub(1))),l=e.lessThanEqual(ek(1)).select(ek(0),ek(-1));oJ({start:ez(0),end:ez(e),type:"int",condition:"<"},({i:e})=>{let u=l.add(ek(e).mul(o)),d=i.sample(tX(sQ.xy,eH(0,u).mul(t)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),d=d.x,a.addAssign(d),n.addAssign(d.mul(d))}),a.divAssign(e),n.divAssign(e);let u=rN(n.sub(a.mul(a)).max(0));return eH(a,u)}),mz=eP(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:s})=>{let a=ek(0).toVar("meanHorizontal"),n=ek(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual(ek(1)).select(ek(0),ek(2).div(e.sub(1))),l=e.lessThanEqual(ek(1)).select(ek(0),ek(-1));oJ({start:ez(0),end:ez(e),type:"int",condition:"<"},({i:e})=>{let u=l.add(ek(e).mul(o)),d=i.sample(tX(sQ.xy,eH(u,0).mul(t)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),a.addAssign(d.x),n.addAssign(tX(d.y.mul(d.y),d.x.mul(d.x)))}),a.divAssign(e),n.divAssign(e);let u=rN(n.sub(a.mul(a)).max(0));return eH(a,u)}),m$=[mU,mF,mL,mP],mW=new cw;class mH extends mw{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._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:i,shadow:s,depthLayer:a}){let n=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:a});return n.select(o,ek(1))}setupShadowCoord(e,t){let r,{shadow:i}=this,{renderer:s}=e,a=i.biasNode||nh("bias","float",i).setGroup(tD),n=t;if(i.camera.isOrthographicCamera||!0!==s.logarithmicDepthBuffer)r=(n=n.xyz.div(n.w)).z;else{let e=n.w;n=n.xy.div(e);let t=nh("near","float",i.camera).setGroup(tD),s=nh("far","float",i.camera).setGroup(tD);r=lf(e.negate(),t,s)}return eQ(n.x,n.y.oneMinus(),s.reversedDepthBuffer?r.sub(a):r.add(a))}getShadowFilterFn(e){return m$[e]}setupRenderTarget(e,t){let r=new u.VCu(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?u.gWB:u.TiK;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 t,r,i,{renderer:s,camera:a}=e,{light:n,shadow:o}=this,{depthTexture:l,shadowMap:d}=this.setupRenderTarget(o,e),h=s.shadowMap.type,c=s.hasCompatibility(u.x$Y.TEXTURE_COMPARE);if((h===u.QP0||h===u.Wk7)&&c?(l.minFilter=u.k6q,l.magFilter=u.k6q):(l.minFilter=u.hxR,l.magFilter=u.hxR),o.camera.coordinateSystem=a.coordinateSystem,o.camera.updateProjectionMatrix(),h===u.RyA&&!0!==o.isPointLightShadow){l.compareFunction=null,d.depth>1?(d._vsmShadowMapVertical||(d._vsmShadowMapVertical=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:u.paN,type:u.ix0,depth:d.depth,depthBuffer:!1}),d._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=d._vsmShadowMapVertical,d._vsmShadowMapHorizontal||(d._vsmShadowMapHorizontal=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:u.paN,type:u.ix0,depth:d.depth,depthBuffer:!1}),d._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=d._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:u.paN,type:u.ix0,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:u.paN,type:u.ix0,depthBuffer:!1}));let t=sD(l);l.isArrayTexture&&(t=t.depth(this.depthLayer));let r=sD(this.vsmShadowMapVertical.texture);l.isArrayTexture&&(r=r.depth(this.depthLayer));let i=nh("blurSamples","float",o).setGroup(tD),s=nh("radius","float",o).setGroup(tD),a=nh("mapSize","vec2",o).setGroup(tD),n=this.vsmMaterialVertical||(this.vsmMaterialVertical=new lE);n.fragmentNode=mk({samples:i,radius:s,size:a,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),n.name="VSMVertical",(n=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new lE)).fragmentNode=mz({samples:i,radius:s,size:a,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),n.name="VSMHorizontal"}let p=nh("intensity","float",o).setGroup(tD),m=nh("normalBias","float",o).setGroup(tD),g=mf(n),f=a0.mul(m);t=!s.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?g.mul(mM.add(f)):tV("mat4").onObjectUpdate(({object:e},t)=>
8t.value.multiplyMatrices(g.value,e.matrixWorld)).mul(aI).add(g.mul(eJ(f,0)));let b=this.setupShadowCoord(e,t),y=o.filterNode||this.getShadowFilterFn(s.shadowMap.type)||null;if(null===y)throw Error("THREE.WebGPURenderer: Shadow map type not supported yet.");let x=h===u.RyA&&!0!==o.isPointLightShadow?this.vsmShadowMapHorizontal.texture:l,T=this.setupShadowFilter(e,{filterFn:y,shadowTexture:d.texture,depthTexture:x,shadowCoord:b,shadow:o,depthLayer:this.depthLayer});!0===s.shadowMap.transmitted&&(d.texture.isCubeTexture?r=nl(d.texture,b.xyz):(r=sD(d.texture,b),l.isArrayTexture&&(r=r.depth(this.depthLayer)))),i=r?id(1,T.rgb.mix(r,1),p.mul(r.a)).toVar():id(1,T,p).toVar(),this.shadowMap=d,this.shadow.map=d;let _=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return r&&i.toInspector(`${_} / Color`,()=>this.shadowMap.texture.isCubeTexture?nl(this.shadowMap.texture,lk()):sD(this.shadowMap.texture)),i.toInspector(`${_} / Depth`,()=>{let e,t=nh("near","float",this.shadow.camera),r=nh("far","float",this.shadow.camera);return e=this.shadowMap.texture.isCubeTexture?nl(this.shadowMap.depthTexture,lk()).r:sD(this.shadowMap.depthTexture).r,lh(this.shadow.camera.isPerspectiveCamera?lg(e,t,r):lc(e,t,r),t,r).oneMinus()})}setup(e){if(!1!==e.renderer.shadowMap.enabled)return eP(()=>{let t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),null===r&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){let{shadow:t,shadowMap:r,light:i}=this,{renderer:s,scene:a}=e;t.updateMatrices(i),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);let n=a.name;a.name=`Shadow Map [ ${i.name||"ID: "+i.id} ]`,s.render(a,t.camera),a.name=n}updateShadow(e){var t,r,i;let{shadowMap:s,light:a,shadow:o}=this,{renderer:l,scene:d,camera:h}=e,c=l.shadowMap.type,p=s.depthTexture.version;this._depthVersionCached=p;let m=o.camera.layers.mask;(0xfffffffe&o.camera.layers.mask)==0&&(o.camera.layers.mask=h.layers.mask);let g=l.getRenderObjectFunction(),f=l.getMRT(),b=!!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=n),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,n=r,d.overrideMaterial=mD(a),l.setRenderObjectFunction(mG(l,o,c,b)),l.setClearColor(0,0),l.setRenderTarget(s),this.renderShadow(e),l.setRenderObjectFunction(g),c===u.RyA&&!0!==o.isPointLightShadow&&this.vsmPass(l),o.camera.layers.mask=m,l.toneMapping=(i=n).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),mW.material=this.vsmMaterialVertical,mW.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),mW.material=this.vsmMaterialHorizontal,mW.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,mO(this.light),this.shadowMap&&(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)}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 mq=(e,t)=>
8new mH(e,t),mj=new u.Q1f,mX=new u.kn4,mQ=new u.Pq0,mK=new u.Pq0,mY=[new u.Pq0(1,0,0),new u.Pq0(-1,0,0),new u.Pq0(0,-1,0),new u.Pq0(0,1,0),new u.Pq0(0,0,1),new u.Pq0(0,0,-1)],mZ=[new u.Pq0(0,-1,0),new u.Pq0(0,-1,0),new u.Pq0(0,0,-1),new u.Pq0(0,0,1),new u.Pq0(0,-1,0),new u.Pq0(0,-1,0)],mJ=[new u.Pq0(1,0,0),new u.Pq0(-1,0,0),new u.Pq0(0,1,0),new u.Pq0(0,-1,0),new u.Pq0(0,0,1),new u.Pq0(0,0,-1)],m0=[new u.Pq0(0,-1,0),new u.Pq0(0,-1,0),new u.Pq0(0,0,1),new u.Pq0(0,0,-1),new u.Pq0(0,-1,0),new u.Pq0(0,-1,0)],m1=eP(({depthTexture:e,bd3D:t,dp:r})=>nl(e,t).compare(r)),m2=eP(({depthTexture:e,bd3D:t,dp:r,shadow:i})=>{let s=nh("radius","float",i).setGroup(tD),a=nh("mapSize","vec2",i).setGroup(tD),n=s.div(a.x),o=rz(t),l=rC(r7(t,o.x.greaterThan(o.z).select(eQ(0,1,0),eQ(1,0,0)))),u=r7(t,l),d=cD(sQ.xy).mul(6.28318530718),h=cO(0,5,d),c=cO(1,5,d),p=cO(2,5,d),m=cO(3,5,d),g=cO(4,5,d);return nl(e,t.add(l.mul(h.x).add(u.mul(h.y)).mul(n))).compare(r).add(nl(e,t.add(l.mul(c.x).add(u.mul(c.y)).mul(n))).compare(r)).add(nl(e,t.add(l.mul(p.x).add(u.mul(p.y)).mul(n))).compare(r)).add(nl(e,t.add(l.mul(m.x).add(u.mul(m.y)).mul(n))).compare(r)).add(nl(e,t.add(l.mul(g.x).add(u.mul(g.y)).mul(n))).compare(r)).mul(.2)}),m3=eP(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:i},s)=>{let a=r.xyz.toConst(),n=a.abs().toConst(),o=n.x.max(n.y).max(n.z),l=tV("float").setGroup(tD).onRenderUpdate(()=>i.camera.near),u=tV("float").setGroup(tD).onRenderUpdate(()=>i.camera.far),d=nh("bias","float",i).setGroup(tD),h=ek(1).toVar();return eI(o.sub(u).lessThanEqual(0).and(o.sub(l).greaterThanEqual(0)),()=>{let r;s.renderer.reversedDepthBuffer?(r=lm(o.negate(),l,u)).subAssign(d):s.renderer.logarithmicDepthBuffer?(r=lf(o.negate(),l,u)).addAssign(d):(r=lp(o.negate(),l,u)).addAssign(d);let n=a.normalize();h.assign(e({depthTexture:t,bd3D:n,dp:r,shadow:i}))}),h});class m4 extends mH{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===u.bTm?m1:m2}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:i,shadow:s}){return m3({filterFn:t,depthTexture:r,shadowCoord:i,shadow:s})}setupRenderTarget(e,t){let r=new u.Gc6(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?u.gWB:u.TiK;let i=t.createCubeRenderTarget(e.mapSize.width);return i.texture.name="PointShadowMap",i.depthTexture=r,{shadowMap:i,depthTexture:r}}renderShadow(e){let{shadow:t,shadowMap:r,light:i}=this,{renderer:s,scene:a}=e,n=t.camera,o=t.matrix,l=s.coordinateSystem===u.i7u,d=l?mY:mJ,h=l?mZ:m0;r.setSize(t.mapSize.width,t.mapSize.width);let c=s.autoClear,p=s.getClearColor(mj),m=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha);for(let e=0;e<6;e++){s.setRenderTarget(r,e),s.clear();let l=i.distance||n.far;l!==n.far&&(n.far=l,n.updateProjectionMatrix()),mQ.setFromMatrixPosition(i.matrixWorld),n.position.copy(mQ),mK.copy(n.position),mK.add(d[e]),n.up.copy(h[e]),n.lookAt(mK),n.updateMatrixWorld(),o.makeTranslation(-mQ.x,-mQ.y,-mQ.z),mX.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),t._frustum.setFromProjectionMatrix(mX,n.coordinateSystem,n.reversedDepth);let u=a.name;a.name=`Point Light Shadow [ ${i.name||"ID: "+i.id} ] - Face ${e+1}`,s.render(a,n),a.name=u}s.autoClear=c,s.setClearColor(p,m)}}let m5=(e,t)=>new m4(e,t);class m6 extends o6{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new u.Q1f,this.colorNode=e&&e.colorNode||tV(this.color).setGroup(tD),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=w.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){null!==this.shadowNode&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,null!==this.baseColorNode&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return mT(this.light).sub(e.context.positionView||az)}setupDirect(){}setupDirectRectArea(){}
8setupShadowNode(){return mq(this.light)}setupShadow(e){let{renderer:t}=e;if(!1===t.shadowMap.enabled)return;let r=this.shadowColorNode;if(null===r){let e,t=this.light.shadow.shadowNode;e=void 0!==t?eR(t):this.setupShadowNode(),this.shadowNode=e,this.shadowColorNode=r=this.colorNode.mul(e),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),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 m8=eP(({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)}),m9=({color:e,lightVector:t,cutoffDistance:r,decayExponent:i})=>{let s=t.normalize(),a=m8({lightDistance:t.length(),cutoffDistance:r,decayExponent:i});return{lightDirection:s,lightColor:e.mul(a)}};class m7 extends m6{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=tV(0).setGroup(tD),this.decayExponentNode=tV(2).setGroup(tD)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return m5(this.light)}setupDirect(e){return m9({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}let ge=eP(([e=sE()])=>{let t=e.mul(2),r=t.x.floor(),i=t.y.floor();return r.add(i).mod(2).sign()}),gt=eP(([e=sE()],{renderer:t,material:r})=>{let i,s=iu(e.mul(2).sub(1));if(r.alphaToCoverage&&t.currentSamples>0){let e=ek(s.fwidth()).toVar();i=im(e.oneMinus(),e.add(1),s).oneMinus()}else i=iv(s.greaterThan(1),0,1);return i}),gr=eP(([e,t,r])=>{let i=ek(r).toVar(),s=ek(t).toVar();return iv(eW(e).toVar(),s,i).uniformFlow()}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),gi=eP(([e,t])=>{let r=eW(t).toVar(),i=ek(e).toVar();return iv(r,i.negate(),i).uniformFlow()}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),gs=eP(([e])=>ez(rA(ek(e).toVar()))).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),ga=eP(([e,t])=>{let r=ek(e).toVar();return t.assign(gs(r)),r.sub(ek(t))}),gn=ce([eP(([e,t,r,i,s,a])=>{let n=ek(a).toVar(),o=ek(s).toVar(),l=ek(i).toVar(),u=ek(r).toVar(),d=ek(t).toVar(),h=ek(e).toVar(),c=ek(tQ(1,o)).toVar();return tQ(1,n).mul(h.mul(c).add(d.mul(o))).add(n.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"}]}),eP(([e,t,r,i,s,a])=>{let n=ek(a).toVar(),o=ek(s).toVar(),l=eQ(i).toVar(),u=eQ(r).toVar(),d=eQ(t).toVar(),h=eQ(e).toVar(),c=ek(tQ(1,o)).toVar();return tQ(1,n).mul(h.mul(c).add(d.mul(o))).add(n.mul(u.mul(c).add(l.mul(o))))}).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"}]})]),go=ce([eP(([e,t,r,i,s,a,n,o,l,u,d])=>{let h=ek(d).toVar(),c=ek(u).toVar(),p=ek(l).toVar(),m=ek(o).toVar(),g=ek(n).toVar(),f=ek(a).toVar(),b=ek(s).toVar(),y=ek(i).toVar(),x=ek(r).toVar(),T=ek(t).toVar(),_=ek(e).toVar(),v=ek(tQ(1,p)).toVar(),S=ek(tQ(1,c)).toVar();return ek(tQ(1,h)).toVar().mul(S.mul(_.mul(v).add(T.mul(p))).add(c.mul(x.mul(v).add(y.mul(p))))).add(h.mul(S.mul(b.mul(v).add(f.mul(p))).add(c.mul(g.mul(v).add(m.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),eP(([e,t,r,i,s,a,n,o,l,u,d])=>{let h=ek(d).toVar(),c=ek(u).toVar(),p=ek(l).toVar(),m=eQ(o).toVar(),g=eQ(n).toVar(),f=eQ(a).toVar(),b=eQ(s).toVar(),y=eQ(i).toVar(),x=eQ(r).toVar(),T=eQ(t).toVar(),_=eQ(e).toVar(),v=ek(tQ(1,p)).toVar(),S=ek(tQ(1,c)).toVar();return ek(tQ(1,h)).toVar().mul(S.mul(_.mul(v).add(T.mul(p))).add(c.mul(x.mul(v).add(y.mul(p))))).add(h.mul(S.mul(b.mul(v).add(f.mul(p))).add(c.mul(g.mul(v).add(m.mul(p))))))}
vendor: 4,140 bytes, line 8
8).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"}]})]),gl=ce([eP(([e,t,r])=>{let i=ek(r).toVar(),s=ek(t).toVar(),a=e$(e).toVar(),n=e$(a.bitAnd(e$(7))).toVar(),o=ek(gr(n.lessThan(e$(4)),s,i)).toVar(),l=ek(tK(2,gr(n.lessThan(e$(4)),i,s))).toVar();return gi(o,eW(n.bitAnd(e$(1)))).add(gi(l,eW(n.bitAnd(e$(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),eP(([e,t,r,i])=>{let s=ek(i).toVar(),a=ek(r).toVar(),n=ek(t).toVar(),o=e$(e).toVar(),l=e$(o.bitAnd(e$(15))).toVar(),u=ek(gr(l.lessThan(e$(8)),n,a)).toVar(),d=ek(gr(l.lessThan(e$(4)),a,gr(l.equal(e$(12)).or(l.equal(e$(14))),n,s))).toVar();return gi(u,eW(l.bitAnd(e$(1)))).add(gi(d,eW(l.bitAnd(e$(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"}]})]),gu=ce([eP(([e,t,r])=>{let i=ek(r).toVar(),s=ek(t).toVar(),a=eY(e).toVar();return eQ(gl(a.x,s,i),gl(a.y,s,i),gl(a.z,s,i))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),eP(([e,t,r,i])=>{let s=ek(i).toVar(),a=ek(r).toVar(),n=ek(t).toVar(),o=eY(e).toVar();return eQ(gl(o.x,n,a,s),gl(o.y,n,a,s),gl(o.z,n,a,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"}]})]),gd=eP(([e])=>tK(.6616,ek(e).toVar())).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),gh=eP(([e])=>tK(.982,ek(e).toVar())).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),gc=ce([gd,eP(([e])=>tK(.6616,eQ(e).toVar())).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),gp=ce([gh,eP(([e])=>tK(.982,eQ(e).toVar())).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),gm=eP(([e,t])=>{let r=ez(t).toVar(),i=e$(e).toVar();return i.shiftLeft(r).bitOr(i.shiftRight(ez(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),gg=eP(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(gm(r,ez(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(gm(e,ez(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(gm(t,ez(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(gm(r,ez(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(gm(e,ez(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(gm(t,ez(4))),t.addAssign(e)}),gf=eP(([e,t,r])=>{let i=e$(r).toVar(),s=e$(t).toVar(),a=e$(e).toVar();return i.bitXorAssign(s),i.subAssign(gm(s,ez(14))),a.bitXorAssign(i),a.subAssign(gm(i,ez(11))),s.bitXorAssign(a),s.subAssign(gm(a,ez(25))),i.bitXorAssign(s),i.subAssign(gm(s,ez(16))),a.bitXorAssign(i),a.subAssign(gm(i,ez(4))),s.bitXorAssign(a),s.subAssign(gm(a,ez(14))),i.bitXorAssign(s),i.subAssign(gm(s,ez(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),gb=eP(([e])=>ek(e$(e).toVar()).div(ek(e$(ez(0xffffffff))))).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),gy=eP(([e])=>{let t=ek(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"}]}),gx=eP(([e])=>{let t=ez(e).toVar(),r=e$(e$(1)).toVar(),i=e$(e$(ez(0xdeadbeef)).add(r.shiftLeft(e$(2))).add(e$(13))).toVar();return gf(i.add(e$(t)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),gT=eP(([e,t])=>{let r=ez(t).toVar(),i=ez(e).toVar(),s=e$(e$(2)).toVar(),a=e$().toVar(),n=e$().toVar(),o=e$().toVar();return a.assign(n.assign(o.assign(e$(ez(0xdeadbeef)).add(s.shiftLeft(e$(2))).add(e$(13))))),a.addAssign(e$(i)),n.addAssign(e$(r)),gf(a,n,o)}
8).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),g_=eP(([e,t,r])=>{let i=ez(r).toVar(),s=ez(t).toVar(),a=ez(e).toVar(),n=e$(e$(3)).toVar(),o=e$().toVar(),l=e$().toVar(),u=e$().toVar();return o.assign(l.assign(u.assign(e$(ez(0xdeadbeef)).add(n.shiftLeft(e$(2))).add(e$(13))))),o.addAssign(e$(a)),l.addAssign(e$(s)),u.addAssign(e$(i)),gf(o,l,u)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),gv=ce([gx,gT,g_,eP(([e,t,r,i])=>{let s=ez(i).toVar(),a=ez(r).toVar(),n=ez(t).toVar(),o=ez(e).toVar(),l=e$(e$(4)).toVar(),u=e$().toVar(),d=e$().toVar(),h=e$().toVar();return u.assign(d.assign(h.assign(e$(ez(0xdeadbeef)).add(l.shiftLeft(e$(2))).add(e$(13))))),u.addAssign(e$(o)),d.addAssign(e$(n)),h.addAssign(e$(a)),gg(u,d,h),u.addAssign(e$(s)),gf(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"}]}),eP(([e,t,r,i,s])=>{let a=ez(s).toVar(),n=ez(i).toVar(),o=ez(r).toVar(),l=ez(t).toVar(),u=ez(e).toVar(),d=e$(e$(5)).toVar(),h=e$().toVar(),c=e$().toVar(),p=e$().toVar();return h.assign(c.assign(p.assign(e$(ez(0xdeadbeef)).add(d.shiftLeft(e$(2))).add(e$(13))))),h.addAssign(e$(u)),c.addAssign(e$(l)),p.addAssign(e$(o)),gg(h,c,p),h.addAssign(e$(n)),c.addAssign(e$(a)),gf(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"}]})]),gS=ce([eP(([e,t])=>{let r=ez(t).toVar(),i=e$(gv(ez(e).toVar(),r)).toVar(),s=eY().toVar();return s.x.assign(i.bitAnd(ez(255))),s.y.assign(i.shiftRight(ez(8)).bitAnd(ez(255))),s.z.assign(i.shiftRight(ez(16)).bitAnd(ez(255))),s}
8).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),eP(([e,t,r])=>{let i=ez(r).toVar(),s=ez(t).toVar(),a=e$(gv(ez(e).toVar(),s,i)).toVar(),n=eY().toVar();return n.x.assign(a.bitAnd(ez(255))),n.y.assign(a.shiftRight(ez(8)).bitAnd(ez(255))),n.z.assign(a.shiftRight(ez(16)).bitAnd(ez(255))),n}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),gN=ce([eP(([e])=>{let t=eH(e).toVar(),r=ez().toVar(),i=ez().toVar(),s=ek(ga(t.x,r)).toVar(),a=ek(ga(t.y,i)).toVar(),n=ek(gy(s)).toVar(),o=ek(gy(a)).toVar();return gc(ek(gn(gl(gv(r,i),s,a),gl(gv(r.add(ez(1)),i),s.sub(1),a),gl(gv(r,i.add(ez(1))),s,a.sub(1)),gl(gv(r.add(ez(1)),i.add(ez(1))),s.sub(1),a.sub(1)),n,o)).toVar())}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),eP(([e])=>{let t=eQ(e).toVar(),r=ez().toVar(),i=ez().toVar(),s=ez().toVar(),a=ek(ga(t.x,r)).toVar(),n=ek(ga(t.y,i)).toVar(),o=ek(ga(t.z,s)).toVar(),l=ek(gy(a)).toVar(),u=ek(gy(n)).toVar(),d=ek(gy(o)).toVar();return gp(ek(go(gl(gv(r,i,s),a,n,o),gl(gv(r.add(ez(1)),i,s),a.sub(1),n,o),gl(gv(r,i.add(ez(1)),s),a,n.sub(1),o),gl(gv(r.add(ez(1)),i.add(ez(1)),s),a.sub(1),n.sub(1),o),gl(gv(r,i,s.add(ez(1))),a,n,o.sub(1)),gl(gv(r.add(ez(1)),i,s.add(ez(1))),a.sub(1),n,o.sub(1)),gl(gv(r,i.add(ez(1)),s.add(ez(1))),a,n.sub(1),o.sub(1)),gl(gv(r.add(ez(1)),i.add(ez(1)),s.add(ez(1))),a.sub(1),n.sub(1),o.sub(1)),l,u,d)).toVar())}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),gR=ce([eP(([e])=>{let t=eH(e).toVar(),r=ez().toVar(),i=ez().toVar(),s=ek(ga(t.x,r)).toVar(),a=ek(ga(t.y,i)).toVar(),n=ek(gy(s)).toVar(),o=ek(gy(a)).toVar();return gc(eQ(gn(gu(gS(r,i),s,a),gu(gS(r.add(ez(1)),i),s.sub(1),a),gu(gS(r,i.add(ez(1))),s,a.sub(1)),gu(gS(r.add(ez(1)),i.add(ez(1))),s.sub(1),a.sub(1)),n,o)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),eP(([e])=>{let t=eQ(e).toVar(),r=ez().toVar(),i=ez().toVar(),s=ez().toVar(),a=ek(ga(t.x,r)).toVar(),n=ek(ga(t.y,i)).toVar(),o=ek(ga(t.z,s)).toVar(),l=ek(gy(a)).toVar(),u=ek(gy(n)).toVar(),d=ek(gy(o)).toVar();return gp(eQ(go(gu(gS(r,i,s),a,n,o),gu(gS(r.add(ez(1)),i,s),a.sub(1),n,o),gu(gS(r,i.add(ez(1)),s),a,n.sub(1),o),gu(gS(r.add(ez(1)),i.add(ez(1)),s),a.sub(1),n.sub(1),o),gu(gS(r,i,s.add(ez(1))),a,n,o.sub(1)),gu(gS(r.add(ez(1)),i,s.add(ez(1))),a.sub(1),n,o.sub(1)),gu(gS(r,i.add(ez(1)),s.add(ez(1))),a,n.sub(1),o.sub(1)),gu(gS(r.add(ez(1)),i.add(ez(1)),s.add(ez(1))),a.sub(1),n.sub(1),o.sub(1)),l,u,d)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),gA=eP(([e])=>gb(gv(ez(gs(ek(e).toVar())).toVar()))).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),gE=eP(([e])=>{let t=eH(e).toVar();return gb(gv(ez(gs(t.x)).toVar(),ez(gs(t.y)).toVar()))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),gC=ce([gA,gE,eP(([e])=>{let t=eQ(e).toVar(),r=ez(gs(t.x)).toVar();return gb(gv(r,ez(gs(t.y)).toVar(),ez(gs(t.z)).toVar()))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),eP(([e])=>{let t=eJ(e).toVar(),r=ez(gs(t.x)).toVar(),i=ez(gs(t.y)).toVar();return gb(gv(r,i,ez(gs(t.z)).toVar(),ez(gs(t.w)).toVar()))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),gw=eP(([e])=>{let t=ez(gs(ek(e).toVar())).toVar();return eQ(gb(gv(t,ez(0))),gb(gv(t,ez(1))),gb(gv(t,ez(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),gM=eP(([e])=>{let t=eH(e).toVar(),r=ez(gs(t.x)).toVar(),i=ez(gs(t.y)).toVar();return eQ(gb(gv(r,i,ez(0))),gb(gv(r,i,ez(1))),gb(gv(r,i,ez(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),gB=ce([gw,gM,eP(([e])=>{let t=eQ(e).toVar(),r=ez(gs(t.x)).toVar(),i=ez(gs(t.y)).toVar(),s=ez(gs(t.z)).toVar();return eQ(gb(gv(r,i,s,ez(0))),gb(gv(r,i,s,ez(1))),gb(gv(r,i,s,ez(2))))}
vendor: 9,482 bytes, line 8
8).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),eP(([e])=>{let t=eJ(e).toVar(),r=ez(gs(t.x)).toVar(),i=ez(gs(t.y)).toVar(),s=ez(gs(t.z)).toVar(),a=ez(gs(t.w)).toVar();return eQ(gb(gv(r,i,s,a,ez(0))),gb(gv(r,i,s,a,ez(1))),gb(gv(r,i,s,a,ez(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),gU=eP(([e,t,r,i])=>{let s=ek(i).toVar(),a=ek(r).toVar(),n=ez(t).toVar(),o=eQ(e).toVar(),l=ek(0).toVar(),u=ek(1).toVar();return oJ(n,()=>{l.addAssign(u.mul(gN(o))),u.mulAssign(s),o.mulAssign(a)}),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"}]}),gF=eP(([e,t,r,i])=>{let s=ek(i).toVar(),a=ek(r).toVar(),n=ez(t).toVar(),o=eQ(e).toVar(),l=eQ(0).toVar(),u=ek(1).toVar();return oJ(n,()=>{l.addAssign(u.mul(gR(o))),u.mulAssign(s),o.mulAssign(a)}),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"}]}),gL=eP(([e,t,r,i])=>{let s=ek(i).toVar(),a=ek(r).toVar(),n=ez(t).toVar(),o=eQ(e).toVar();return eH(gU(o,n,a,s),gU(o.add(eQ(ez(19),ez(193),ez(17))),n,a,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"}]}),gP=eP(([e,t,r,i])=>{let s=ek(i).toVar(),a=ek(r).toVar(),n=ez(t).toVar(),o=eQ(e).toVar();return eJ(eQ(gF(o,n,a,s)).toVar(),ek(gU(o.add(eQ(ez(19),ez(193),ez(17))),n,a,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"}]}),gD=ce([eP(([e,t,r,i,s,a,n])=>{let o=ez(n).toVar(),l=ek(a).toVar(),u=ez(s).toVar(),d=ez(i).toVar(),h=ez(r).toVar(),c=ez(t).toVar(),p=eH(e).toVar(),m=eQ(gB(eH(c.add(d),h.add(u)))).toVar(),g=eH(m.x,m.y).toVar();g.subAssign(.5),g.mulAssign(l),g.addAssign(.5);let f=eH(eH(ek(c),ek(h)).add(g)).toVar(),b=eH(f.sub(p)).toVar();return eI(o.equal(ez(2)),()=>rz(b.x).add(rz(b.y))),eI(o.equal(ez(3)),()=>r3(rz(b.x),rz(b.y))),r9(b,b)}).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"}]}),eP(([e,t,r,i,s,a,n,o,l])=>{let u=ez(l).toVar(),d=ek(o).toVar(),h=ez(n).toVar(),c=ez(a).toVar(),p=ez(s).toVar(),m=ez(i).toVar(),g=ez(r).toVar(),f=ez(t).toVar(),b=eQ(e).toVar(),y=eQ(gB(eQ(f.add(p),g.add(c),m.add(h)))).toVar();y.subAssign(.5),y.mulAssign(d),y.addAssign(.5);let x=eQ(eQ(ek(f),ek(g),ek(m)).add(y)).toVar(),T=eQ(x.sub(b)).toVar();return eI(u.equal(ez(2)),()=>rz(T.x).add(rz(T.y)).add(rz(T.z))),eI(u.equal(ez(3)),()=>r3(rz(T.x),rz(T.y),rz(T.z))),r9(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"}]})]),gO=eP(([e,t,r])=>{let i=ez(r).toVar(),s=ek(t).toVar(),a=eH(e).toVar(),n=ez().toVar(),o=ez().toVar(),l=eH(ga(a.x,n),ga(a.y,o)).toVar(),u=ek(1e6).toVar();return oJ({start:-1,end:ez(1),name:"x",condition:"<="},({x:e})=>{oJ({start:-1,end:ez(1),name:"y",condition:"<="},({y:t})=>{let r=ek(gD(l,e,t,n,o,s,i)).toVar();u.assign(r2(u,r))})}),eI(i.equal(ez(0)),()=>{u.assign(rN(u))}),u}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gI=eP(([e,t,r])=>{let i=ez(r).toVar(),s=ek(t).toVar(),a=eH(e).toVar(),n=ez().toVar(),o=ez().toVar(),l=eH(ga(a.x,n),ga(a.y,o)).toVar(),u=eH(1e6,1e6).toVar();return oJ({start:-1,end:ez(1),name:"x",condition:"<="},({x:e})=>{oJ({start:-1,end:ez(1),name:"y",condition:"<="},({y:t})=>{let r=ek(gD(l,e,t,n,o,s,i)).toVar();eI(r.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(r)}).ElseIf(r.lessThan(u.y),()=>{u.y.assign(r)})})}),eI(i.equal(ez(0)),()=>{u.assign(rN(u))}),u}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gV=eP(([e,t,r])=>{let i=ez(r).toVar(),s=ek(t).toVar(),a=eH(e).toVar(),n=ez().toVar(),o=ez().toVar(),l=eH(ga(a.x,n),ga(a.y,o)).toVar(),u=eQ(1e6,1e6,1e6).toVar();return oJ({start:-1,end:ez(1),name:"x",condition:"<="},({x:e})=>{oJ({start:-1,end:ez(1),name:"y",condition:"<="},({y:t})=>{let r=ek(gD(l,e,t,n,o,s,i)).toVar();eI(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)})})}),eI(i.equal(ez(0)),()=>{u.assign(rN(u))}),u}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),gG=ce([gO,eP(([e,t,r])=>{let i=ez(r).toVar(),s=ek(t).toVar(),a=eQ(e).toVar(),n=ez().toVar(),o=ez().toVar(),l=ez().toVar(),u=eQ(ga(a.x,n),ga(a.y,o),ga(a.z,l)).toVar(),d=ek(1e6).toVar();return oJ({start:-1,end:ez(1),name:"x",condition:"<="},({x:e})=>{oJ({start:-1,end:ez(1),name:"y",condition:"<="},({y:t})=>{oJ({start:-1,end:ez(1),name:"z",condition:"<="},({z:r})=>{let a=ek(gD(u,e,t,r,n,o,l,s,i)).toVar();d.assign(r2(d,a))})})}),eI(i.equal(ez(0)),()=>{d.assign(rN(d))}),d}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),gk=ce([gI,eP(([e,t,r])=>{let i=ez(r).toVar(),s=ek(t).toVar(),a=eQ(e).toVar(),n=ez().toVar(),o=ez().toVar(),l=ez().toVar(),u=eQ(ga(a.x,n),ga(a.y,o),ga(a.z,l)).toVar(),d=eH(1e6,1e6).toVar();return oJ({start:-1,end:ez(1),name:"x",condition:"<="},({x:e})=>{oJ({start:-1,end:ez(1),name:"y",condition:"<="},({y:t})=>{oJ({start:-1,end:ez(1),name:"z",condition:"<="},({z:r})=>{let a=ek(gD(u,e,t,r,n,o,l,s,i)).toVar();eI(a.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(a)}).ElseIf(a.lessThan(d.y),()=>{d.y.assign(a)})})})}),eI(i.equal(ez(0)),()=>{d.assign(rN(d))}),d}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),gz=ce([gV,eP(([e,t,r])=>{let i=ez(r).toVar(),s=ek(t).toVar(),a=eQ(e).toVar(),n=ez().toVar(),o=ez().toVar(),l=ez().toVar(),u=eQ(ga(a.x,n),ga(a.y,o),ga(a.z,l)).toVar(),d=eQ(1e6,1e6,1e6).toVar();return oJ({start:-1,end:ez(1),name:"x",condition:"<="},({x:e})=>{oJ({start:-1,end:ez(1),name:"y",condition:"<="},({y:t})=>{oJ({start:-1,end:ez(1),name:"z",condition:"<="},({z:r})=>{let a=ek(gD(u,e,t,r,n,o,l,s,i)).toVar();eI(a.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(a)}).ElseIf(a.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(a)}).ElseIf(a.lessThan(d.z),()=>{d.z.assign(a)})})})}),eI(i.equal(ez(0)),()=>{d.assign(rN(d))}),d}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),g$=eP(([e,t,r,i,s,a,n,o,l,u,d])=>{let h=ez(e).toVar(),c=eH(t).toVar(),p=eH(r).toVar(),m=eH(i).toVar(),g=ek(s).toVar(),f=ek(a).toVar(),b=ek(n).toVar(),y=eW(o).toVar(),x=ez(l).toVar(),T=ek(u).toVar(),_=ek(d).toVar(),v=c.mul(p).add(m),S=ek(0).toVar();return eI(h.equal(ez(0)),()=>{S.assign(gR(v))}),eI(h.equal(ez(1)),()=>{S.assign(gB(v))}),eI(h.equal(ez(2)),()=>{S.assign(gz(v,g,ez(0)))}),eI(h.equal(ez(3)),()=>{S.assign(gF(eQ(v,0),x,T,_))}),S.assign(S.mul(b.sub(f)).add(f)),eI(y,()=>{S.assign(ih(S,f,b))}),S}).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"}]}),gW=eP(([e,t,r,i,s,a,n,o,l,u,d])=>{let h=ez(e).toVar(),c=eQ(t).toVar(),p=eQ(r).toVar(),m=eQ(i).toVar(),g=ek(s).toVar(),f=ek(a).toVar(),b=ek(n).toVar(),y=eW(o).toVar(),x=ez(l).toVar(),T=ek(u).toVar(),_=ek(d).toVar(),v=c.mul(p).add(m),S=ek(0).toVar();return eI(h.equal(ez(0)),()=>{S.assign(gR(v))}),eI(h.equal(ez(1)),()=>{S.assign(gB(v))}),eI(h.equal(ez(2)),()=>{S.assign(gz(v,g,ez(0)))}),eI(h.equal(ez(3)),()=>{S.assign(gF(v,x,T,_))}),S.assign(S.mul(b.sub(f)).add(f)),eI(y,()=>{S.assign(ih(S,f,b))}),S}).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"}]}),gH=eP(([e])=>{let t=e.y,r=e.z,i=eQ().toVar();return eI(t.lessThan(1e-4),()=>{i.assign(eQ(r,r,r))}).Else(()=>{let s=e.x,a=ez(rY(s=s.sub(rA(s)).mul(6).toVar())),n=s.sub(ek(a)),o=r.mul(t.oneMinus()),l=r.mul(t.mul(n).oneMinus()),u=r.mul(t.mul(n.oneMinus()).oneMinus());eI(a.equal(ez(0)),()=>{i.assign(eQ(r,u,o))}).ElseIf(a.equal(ez(1)),()=>{i.assign(eQ(l,r,o))}).ElseIf(a.equal(ez(2)),()=>{i.assign(eQ(o,r,u))}).ElseIf(a.equal(ez(3)),()=>{i.assign(eQ(o,l,r))}).ElseIf(a.equal(ez(4)),()=>{i.assign(eQ(u,o,r))}).Else(()=>{i.assign(eQ(r,o,l))})}),i}
8).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),gq=eP(([e])=>{let t=eQ(e).toVar(),r=ek(t.x).toVar(),i=ek(t.y).toVar(),s=ek(t.z).toVar(),a=ek(r2(r,r2(i,s))).toVar(),n=ek(r3(r,r3(i,s))).toVar(),o=ek(n.sub(a)).toVar(),l=ek().toVar(),u=ek().toVar(),d=ek().toVar();return d.assign(n),eI(n.greaterThan(0),()=>{u.assign(o.div(n))}).Else(()=>{u.assign(0)}),eI(u.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{eI(r.greaterThanEqual(n),()=>{l.assign(i.sub(s).div(o))}).ElseIf(i.greaterThanEqual(n),()=>{l.assign(tX(2,s.sub(r).div(o)))}).Else(()=>{l.assign(tX(4,r.sub(i).div(o)))}),l.mulAssign(1/6),eI(l.lessThan(0),()=>{l.addAssign(1)})}),eQ(l,u,d)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),gj=eP(([e])=>{let t=eQ(e).toVar(),r=eZ(t2(t,eQ(.04045))).toVar();return id(eQ(t.div(12.92)).toVar(),eQ(ie(r3(t.add(eQ(.055)),eQ(0)).div(1.055),eQ(2.4))).toVar(),r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),gX=(e,t)=>{e=ek(e);let r=eH((t=ek(t)).dFdx(),t.dFdy()).length().mul(.7071067811865476);return im(e.sub(r),e.add(r),t)},gQ=(e,t,r,i)=>id(e,t,r[i].clamp()),gK=(e,t,r,i,s)=>id(e,t,gX(r,i[s])),gY=eP(([e,t,r])=>{let i=rC(e).toVar(),s=tQ(ek(.5).mul(t.sub(r)),aG).div(i).toVar(),a=tQ(ek(-.5).mul(t.sub(r)),aG).div(i).toVar(),n=eQ().toVar();n.x=i.x.greaterThan(ek(0)).select(s.x,a.x),n.y=i.y.greaterThan(ek(0)).select(s.y,a.y),n.z=i.z.greaterThan(ek(0)).select(s.z,a.z);let o=r2(n.x,n.y,n.z).toVar();return aG.add(i.mul(o)).toVar().sub(r)}),gZ=eP(([e,t])=>{let r=e.x,i=e.y,s=e.z,a=t.element(0).mul(.886227);return(a=(a=(a=(a=(a=(a=(a=a.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(tK(r,r).sub(tK(i,i))))});var gJ=Object.freeze({__proto__:null,BRDF_GGX:un,BRDF_Lambert:l1,BasicPointShadowFilter:m1,BasicShadowFilter:mU,Break:o0,Const:iF,Continue:()=>sm("continue").toStack(),DFGLUT:uu,D_GGX:ui,Discard:sg,EPSILON:rd,F_Schlick:l0,Fn:eP,HALF_PI:rg,INFINITY:rh,If:eI,Loop:oJ,NodeAccess:M,NodeShaderStage:C,NodeType:{BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},NodeUpdateType:w,OnBeforeFrameUpdate:e=>oE(oA.BEFORE_FRAME,e),OnBeforeMaterialUpdate:e=>oE(oA.BEFORE_MATERIAL,e),OnBeforeObjectUpdate:e=>oE(oA.BEFORE_OBJECT,e),OnFrameUpdate:ow,OnMaterialUpdate:e=>oE(oA.MATERIAL,e),OnObjectUpdate:oC,PCFShadowFilter:mF,PCFSoftShadowFilter:mL,PI:rc,PI2:rp,PointShadowFilter:m2,Return:()=>sm("return").toStack(),Schlick_to_F0:uc,ShaderNode:eN,Stack:eV,Switch:(...e)=>K.Switch(...e),TBNViewMatrix:nO,TWO_PI:rm,VSMShadowFilter:mP,V_GGX_SmithCorrelated:ut,Var:iU,VarIntent:iL,abs:rz,acesFilmicToneMapping:pT,acos:rI,acosh:rV,add:tX,addMethodChaining:Z,addNodeElement:function(e){(0,u.R8M)("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)},agxToneMapping:pN,all:rf,alphaT:tp,ambientOcclusion:tB,and:t5,anisotropy:tm,anisotropyB:tf,anisotropyT:tg,any:rb,append:e=>((0,u.R8M)("TSL: append() has been renamed to Stack().",new f),eV(e)),array:tk,asin:rD,asinh:rO,assign:t$,atan:rG,atanh:rk,atomicAdd:(e,t)=>pZ(pK.ATOMIC_ADD,e,t),atomicAnd:(e,t)=>pZ(pK.ATOMIC_AND,e,t),atomicFunc:pZ,atomicLoad:e=>pZ(pK.ATOMIC_LOAD,e,null),atomicMax:(e,t)=>pZ(pK.ATOMIC_MAX,e,t),atomicMin:(e,t)=>pZ(pK.ATOMIC_MIN,e,t),atomicOr:(e,t)=>pZ(pK.ATOMIC_OR,e,t),atomicStore:(e,t)=>pZ(pK.ATOMIC_STORE,e,t),atomicSub:(e,t)=>pZ(pK.ATOMIC_SUB,e,t),atomicXor:(e,t)=>pZ(pK.ATOMIC_XOR,e,t),attenuationColor:tw,attenuationDistance:tC,attribute:sA,attributeArray:(e,t="float")=>{let r,i;return!0===t.isStructTypeNode?(r=t.getLength(),i=S("float")):(r=N(t),i=S(t)),oF(new cG(e,r,i),t,e)},backgroundBlurriness:cW,backgroundIntensity:cH,backgroundRotation:cq,batch:oW,batchColor:o$,bentNormalView:nV,billboarding:cn,bitAnd:t7,bitNot:re,bitOr:rt,bitXor:rr,bitangentGeometry:nF,bitangentLocal:nL,bitangentView:nP,bitangentWorld:nD,bitcast:hz,blendBurn:c6,blendColor:pe,blendDodge:c8,blendOverlay:c7,blendScreen:c9,blur:dt,bool:eW,buffer:sV,bufferAttribute:i3,builtin:sW,builtinAOContext:iC,builtinShadowContext:iE,bumpMap:nX,bvec2:eX,bvec3:eZ,bvec4:e2,bypass:sd,cache:sl,call:tH,cameraFar:ao,cameraIndex:aa,cameraNear:an,cameraNormalMatrix:ac,cameraPosition:ap,cameraProjectionMatrix:al,cameraProjectionMatrixInverse:au,cameraViewMatrix:ad,cameraViewport:am,cameraWorldMatrix:ah,cbrt:il,cdl:pn,ceil:rE,checker:ge,cineonToneMapping:py,clamp:i
8h,clearcoat:tn,clearcoatNormalView:a1,clearcoatRoughness:to,clipSpace:aD,code:pE,color:eG,colorSpaceToWorking:iH,colorToDirection:e=>((0,u.mcG)('TSL: "colorToDirection()" has been renamed to "unpackRGBToNormal()".'),nk(e)),compute:sa,computeKernel:ss,computeSkinning:oY,context:iN,convert:e8,convertColorSpace:(e,t,r)=>new i$(eR(e),t,r),convertToTexture:(e,...t)=>e.isSampleNode||e.isTextureNode?e:e.isPassNode?e.getTextureNode():cU(e,...t),cos:rU,cosh:rF,countLeadingZeros:hj,countOneBits:hX,countTrailingZeros:hq,cross:r7,cubeTexture:nl,cubeTextureBase:no,dFdx:rj,dFdy:rX,dashSize:tv,debug:s_,decrement:rl,decrementBefore:rn,defaultBuildStages:U,defaultShaderStages:B,defined:ev,degrees:rx,deltaTime:cr,densityFogFactor:pU,depth:ly,depthPass:(e,t,r)=>new pm(pm.DEPTH,e,t,r),determinant:r0,difference:r8,diffuseColor:tt,diffuseContribution:tr,directPointLight:m9,directionToColor:e=>((0,u.mcG)('TSL: "directionToColor()" has been renamed to "packNormalToRGB()".'),nG(e)),directionToFaceDirection:e=>((0,u.mcG)('TSL: "directionToFaceDirection()" has been renamed to "negateOnBackSide()".'),aj(e)),dispersion:tM,disposeShadowMaterial:mO,distance:r6,div:tY,dot:r9,drawIndex:sr,dynamicBufferAttribute:(e,t=null,r=0,i=0)=>i2(e,t,r,i,u.Vnu),element:e6,emissive:ti,equal:tJ,equirectDirection:lk,equirectUV:lG,exp:rT,exp2:r_,exponentialHeightFogFactor:pF,expression:sm,faceDirection:aq,faceForward:ig,faceforward:ig,float:ek,floatBitsToInt:e=>new hk(e,"int","float"),floatBitsToUint:h$,floor:rA,fog:pL,fract:rw,frameGroup:tP,frameId:ci,frontFacing:aH,fwidth:rZ,gain:(e,t)=>e.lessThan(.5)?hK(e.mul(2),t).div(2):tQ(1,hK(tK(tQ(1,e),2),t).div(2)),gapSize:tS,getConstNodeType:eS,getCurrentStack:eO,getDirection:u8,getDistanceAttenuation:m8,getGeometryRoughness:l7,getNormalFromDepth:cP,getParallaxCorrectNormal:gY,getRoughness:ue,getScreenPosition:cL,getShIrradianceAt:gZ,getShadowMaterial:mD,getShadowRenderObjectFunction:mG,getTextureIndex:hI,getViewPosition:cF,ggxConvolution:da,globalId:p$,glsl:(e,t)=>pE(e,t,"glsl"),glslFn:(e,t)=>pw(e,t,"glsl"),grayscale:pt,greaterThan:t2,greaterThanEqual:t4,hash:hQ,highpModelNormalViewMatrix:aP,highpModelViewMatrix:aL,hue:ps,increment:ro,incrementBefore:ra,inspector:sN,instance:oV,instanceColor:oI,instanceIndex:i9,instancedArray:(e,t="float")=>{let r,i;!0===t.isStructTypeNode?(r=t.getLength(),i=S("float")):(r=N(t),i=S(t));let s=new cV(e,r,i);return oF(s,t,s.count)},instancedBufferAttribute:i4,instancedDynamicBufferAttribute:i5,instancedMesh:oG,int:ez,intBitsToFloat:e=>new hk(e,"float","int"),interleavedGradientNoise:cD,inverse:r1,inverseSqrt:rR,inversesqrt:rR,invocationLocalIndex:st,invocationSubgroupIndex:se,ior:tR,iridescence:td,iridescenceIOR:th,iridescenceThickness:tc,isolate:so,ivec2:eq,ivec3:eK,ivec4:e0,js:(e,t)=>pE(e,t,"js"),label:iw,length:rW,lengthSq:iu,lessThan:t1,lessThanEqual:t3,lightPosition:my,lightProjectionUV:mb,lightShadowMatrix:mf,lightTargetDirection:m_,lightTargetPosition:mx,lightViewPosition:mT,lightingContext:o7,lights:(e=[])=>new mC().setLights(e),linearDepth:lx,linearToneMapping:pf,localId:pW,log:rv,log2:rS,logarithmicDepthToViewZ:(e,t,r)=>{let i=e.mul(rv(r.div(t)));return ek(Math.E).pow(i).mul(t).negate()},luminance:pa,mat2:e3,mat3:e4,mat4:e5,matcapUV:dV,materialAO:oS,materialAlphaTest:nY,materialAnisotropy:on,materialAnisotropyVector:oN,materialAttenuationColor:om,materialAttenuationDistance:op,materialClearcoat:oe,materialClearcoatNormal:or,materialClearcoatRoughness:ot,materialColor:nZ,materialDispersion:o_,materialEmissive:n0,materialEnvIntensity:a7,materialEnvRotation:ne,materialIOR:oc,materialIridescence:oo,materialIridescenceIOR:ol,materialIridescenceThickness:ou,materialLightMap:ov,materialLineDashOffset:ox,materialLineDashSize:of,materialLineGapSize:ob,materialLineScale:og,materialLineWidth:oy,materialMetalness:n9,materialNormal:n7,materialOpacity:n1,materialPointSize:oT,materialReference:nm,materialReflectivity:n6,materialRefractionRatio:a9,materialRotation:oi,materialRoughness:n8,materialSheen:os,materialSheenRoughness:oa,materialShininess:nJ,materialSpecular:n2,materialSpecularColor:n4,materialSpecularIntensity:n3,materialSpecularStrength:n5,materialThickness:oh,materialTransmission:od,max:r3,maxMipLevel:sB,mediumpModelViewMatrix:aF,metalness:ta,min:r2,mix:id,mixElement:iy,mod:tZ,modelDirection:aN,modelNormalMatrix:aM,modelPosition:aA,modelRadius:aw,modelScale:aE,modelViewMatrix:aU,modelViewPosition:aC,modelViewProjection:oR,modelWorldMatrix:aR,modelWorldMatrixInverse:aB,morphReference:o5,mrt:hG,mul:tK,mx_aastep:gX,mx_add:(e,t=ek(0))=>tX(e,t),mx_atan2:(e=ek(0),t=ek(1))=>rG(e,t),mx_cell_noise_float:(e=sE())=>gC(e.convert("vec2|vec3")),mx_contrast:(e,t=1,r=.5)=>ek(e).sub(r).mul(t).add(r),mx_divide:(e,t=ek(1))=>tY(e,t),mx_fractal_noise_float:(e=sE(),t=3,r=2,i=.5,s=1)=>gU(e,ez(t),r,i).mul(s),mx_fractal_noise_vec2:(e=sE(),t=3,r=2,i=.5,s=1)=>gL(e,ez(t),r,i).mul(s),mx_fractal_noise_vec3:(e=sE(),t=3,r=2,i=.5,s=1)=>gF(e,ez(t),r,i).mul(s),mx_fractal_noise_vec4:(e=sE(),t=3,r=2,i=.5,s=1)=>gP(e,ez(t),r,i).mul(s),mx_frame:()=>ci,mx_heighttonormal:(e,t)=>nX(e=eQ(e),t=ek(t)),mx_hsvtorgb:gH,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=ek(1))=>tQ(t,e),mx_modulo:(e,t=ek(1))=>tZ(e,t),mx_multiply:(e,t=ek(1))=>tK(e,t),mx_noise_float:(e=sE(),t=1,r=0)=>gN(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec3:(e=sE(),t=1,r=0)=>gR(e.convert("vec2|vec3")).mul(t).add(r),mx_noise_vec4:(e=sE(),t=1,r=0)=>eJ(gR(e=e.convert("vec2|vec3")),gN(e.add(eH(19,73)))).mul(t).add(r),mx_place2d:(e,t=eH(.5,.5),r=eH(1,1),i=ek(0),s=eH(0,0))=>{let a=e;if(t&&(a=a.sub(t)),r&&(a=a.mul(r)),i){let e=i.mul(Math.PI/180),t=e.cos(),r=e.sin();a=eH(a.x.mul(t).sub(a.y.mul(r)),a.x.mul(r).add(a.y.mul(t)))}return t&&(a=a.add(t)),s&&(a=a.add(s)),a},mx_power:(e,t=ek(1))=>ie(e,t),mx_ramp4:(e,t,r,i,s=sE())=>{let a=s.x.clamp(),n=s.y.clamp(),o=id(e,t,a),l=id(r,i,a);return id(o,l,n)},mx_ramplr:(e,t,r=sE())=>gQ(e,t,r,"x"),mx_ramptb:(e,t,r=sE())=>gQ(e,t,r,"y"),mx_rgbtohsv:gq,mx_rotate2d:(e,t)=>
vendor: 6,894 bytes, line 8
8d$(e=eH(e),(t=ek(t)).mul(Math.PI/180)),mx_rotate3d:(e,t,r)=>{e=eQ(e),t=ek(t),r=eQ(r);let i=t.mul(Math.PI/180),s=r.normalize(),a=i.cos(),n=i.sin(),o=ek(1).sub(a);return e.mul(a).add(s.cross(e).mul(n)).add(s.mul(s.dot(e)).mul(o))},mx_safepower:(e,t=1)=>(e=ek(e)).abs().pow(t).mul(e.sign()),mx_separate:(e,t=null)=>{if("string"==typeof t){let r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},i=t.replace(/^out/,"").toLowerCase();if(void 0!==r[i])return e.element(r[i])}if("number"==typeof t)return e.element(t);if("string"==typeof t&&1===t.length){let r={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(void 0!==r[t])return e.element(r[t])}return e},mx_splitlr:(e,t,r,i=sE())=>gK(e,t,r,i,"x"),mx_splittb:(e,t,r,i=sE())=>gK(e,t,r,i,"y"),mx_srgb_texture_to_lin_rec709:gj,mx_subtract:(e,t=ek(0))=>tQ(e,t),mx_timer:()=>ct,mx_transform_uv:(e=1,t=0,r=sE())=>r.mul(e).add(t),mx_unifiednoise2d:(e,t=sE(),r=eH(1,1),i=eH(0,0),s=1,a=0,n=1,o=!1,l=1,u=2,d=.5)=>g$(e,t.convert("vec2|vec3"),r,i,s,a,n,o,l,u,d),mx_unifiednoise3d:(e,t=sE(),r=eH(1,1),i=eH(0,0),s=1,a=0,n=1,o=!1,l=1,u=2,d=.5)=>gW(e,t.convert("vec2|vec3"),r,i,s,a,n,o,l,u,d),mx_worley_noise_float:(e=sE(),t=1)=>gG(e.convert("vec2|vec3"),t,ez(1)),mx_worley_noise_vec2:(e=sE(),t=1)=>gk(e.convert("vec2|vec3"),t,ez(1)),mx_worley_noise_vec3:(e=sE(),t=1)=>gz(e.convert("vec2|vec3"),t,ez(1)),negate:rH,negateOnBackSide:aj,neutralToneMapping:pR,nodeArray:eC,nodeImmutable:eM,nodeObject:eR,nodeObjectIntent:eA,nodeObjects:eE,nodeProxy:ew,nodeProxyConstructor:eU,nodeProxyIntent:eB,normalFlat:aK,normalGeometry:aX,normalLocal:aQ,normalMap:nW,normalView:aJ,normalViewGeometry:aY,normalWorld:a0,normalWorldGeometry:aZ,normalize:rC,not:t8,notEqual:t0,numWorkgroups:pk,objectDirection:ab,objectGroup:tO,objectPosition:ax,objectRadius:av,objectScale:aT,objectViewPosition:a_,objectWorldMatrix:ay,oneMinus:rq,or:t6,orthographicDepthToViewZ:lc,oscSawtooth:(e=ct)=>e.fract(),oscSine:(e=ct)=>e.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5),oscSquare:(e=ct)=>e.fract().round(),oscTriangle:(e=ct)=>e.add(.5).fract().mul(2).sub(1).abs(),output:t_,outputStruct:hL,overloadingFn:ce,overrideNode:hA,overrideNodes:hE,packHalf2x16:h0,packNormalToRGB:nG,packSnorm2x16:hZ,packUnorm2x16:hJ,parabola:hK,parallaxDirection:nI,parallaxUV:(e,t)=>e.sub(nI.mul(t)),parameter:(e,t)=>new hC(e,t),pass:(e,t,r)=>new pm(pm.COLOR,e,t,r),passTexture:(e,t)=>new pc(e,t),pcurve:(e,t,r)=>ie(tY(ie(e,t),tX(ie(e,t),ie(tQ(1,e),r))),1/t),perspectiveDepthToViewZ:lg,pmremTexture:dA,pointShadow:m5,pointUV:cz,pointWidth:tN,positionGeometry:aO,positionLocal:aI,positionPrevious:aV,positionView:az,positionViewDirection:a$,positionWorld:aG,positionWorldDirection:ak,posterize:po,pow:ie,pow2:it,pow3:ir,pow4:ii,premultiplyAlpha:sf,property:e7,quadBroadcast:mm,quadSwapDiagonal:ml,quadSwapX:mn,quadSwapY:mo,radians:ry,rand:ib,range:pI,rangeFogFactor:pB,reciprocal:rK,reference:nh,referenceBuffer:nc,reflect:r5,reflectVector:ni,reflectView:nt,reflector:e=>new cN(e),refract:ip,refractVector:ns,refractView:nr,reinhardToneMapping:pb,remap:sh,remapClamp:sc,renderGroup:tD,renderOutput:sx,rendererReference:iQ,replaceDefaultUV:function(e,t=null){return iN(t,{getUV:"function"==typeof e?e:()=>e})},rotate:d$,rotateUV:cs,roughness:ts,round:rQ,rtt:cU,sRGBTransferEOTF:iG,sRGBTransferOETF:ik,sample:(e,t=null)=>new cI(e,eR(t)),sampler:e=>(!0===e.isNode?e:sD(e)).convert("sampler"),samplerComparison:e=>(!0===e.isNode?e:sD(e)).convert("samplerComparison"),saturate:ic,saturation:pr,screenCoordinate:sQ,screenDPR:sq,screenSize:sX,screenUV:sj,select:iv,setCurrentStack:eD,setName:iA,shaderStages:F,shadow:mq,shadowPositionWorld:mM,shapeCircle:gt,sharedUniformGroup:tL,sheen:tl,sheenRoughness:tu,shiftLeft:ri,shiftRight:rs,shininess:tT,sign:r$,sin:rM,sinc:(e,t)=>rM(rc.mul(t.mul(e).sub(1))).div(rc.mul(t.mul(e).sub(1))),sinh:rB,skinning:oK,smoothstep:im,smoothstepElement:ix,specularColor:tb,specularColorBlended:ty,specularF90:tx,spherizeUV:ca,split:(e,t)=>new $(eR(e),t),spritesheetUV:cl,sqrt:rN,stack:hM,step:r4,stepElement:iT,storage:oF,storageBarrier:()=>pj("storage").toStack(),storageTexture:cX,storageTexture3D:cK,struct:(e,t=null)=>{let r=new hB(e,t);return eU((...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 new hU(r,i)},r)},sub:tQ,subBuild:iD,subgroupAdd:p2,subgroupAll:mi,subgroupAnd:p9,subgroupAny:ms,subgroupBallot:p1,subgroupBroadcast:mu,subgroupBroadcastFirst:ma,subgroupElect:p0,subgroupExclusiveAdd:p4,subgroupExclusiveMul:p8,subgroupInclusiveAdd:p3,subgroupInclusiveMul:p6,subgroupIndex:i7,subgroupMax:mr,subgroupMin:mt,subgroupMul:p5,subgroupOr:p7,subgroupShuffle:md,subgroupShuffleDown:mp,subgroupShuffleUp:mc,subgroupShuffleXor:mh,subgroupSize:pH,subgroupXor:me,tan:rL,tangentGeometry:nC,tangentLocal:nw,tangentView:nM,tangentWorld:nB,tanh:rP,texture:sD,texture3D:cJ,texture3DLevel:(e,t,r)=>cJ(e,t).level(r),texture3DLoad:(...e)=>cJ(...e).setSampler(!1),textureBarrier:()=>pj("texture").toStack(),textureBicubic:uB,textureBicubicLevel:uM,textureCubeUV:u9,textureLevel:(e,t,r)=>sD(e,t).level(r),textureLoad:sO,textureSize:sw,textureStore:(e,t,r)=>{let i;return!0===e.isStorageTextureNode?i=e.store(t,r):(i=cX(e,t,r),null!==r&&i.toStack()),i},thickness:tE,time:ct,toneMapping:iY,toneMappingExposure:iZ,toonOutlinePass:(e,t,r=new u.Q1f(0,0,0),i=.003,s=1)=>new pg(e,t,eR(r),eR(i),eR(s)),transformDirection:is,transformNormal:a2,transformNormalByInverseViewMatrix:io,transformNormalByViewMatrix:ia,transformNormalToView:a3,transformedClearcoatNormalView:a6,transformedNormalView:a4,transformedNormalWorld:a5,transmission:tA,transpose:rJ,triNoise3D:h8,triplanarTexture:(...e)=>cu(...e),triplanarTextures:cu,trunc:rY,uint:e$,uintBitsToFloat:e=>new hk(e,"float","uint"),uniform:tV,uniformArray:sz,uniformCubeTexture:(e=na)=>no(e),uniformFlow:iR,uniformGroup:tF,uniformTexture:(e=sF)=>sD(e),unpackHalf2x16:h4,unpackNormal:nz,unpackRGBToNormal:nk,unpackSnorm2x16:h2,unpackUnorm2x16:h3,unpremultiplyAlpha:sb,userData:(e,t,r)=>new c0(e,t,r),uv:sE,uvec2:ej,uvec3:eY,uvec4:e1,varying:iI,varyingProperty:te,vec2:eH,vec3:eQ,vec4:eJ,vectorComponents:L,velocity:c5,vertexColor:lA,vertexIndex:i8,vertexStage:iV,vibrance:pi,viewZToLogarithmicDepth:lf,viewZToOrthographicDepth:lh,viewZToPerspectiveDepth:lp,viewZToReversedOrthographicDepth:(e,t,r)=>e.add(r).div(r.sub(t)),viewZToReversedPerspectiveDepth:lm,viewport:sK,viewportCoordinate:sZ,viewportDepthTexture:lu,viewportLinearDepth:lT,viewportMipTexture:ls,viewportOpaqueMipTexture:ln,viewportResolution:s0,viewportSafeUV:co,viewportSharedTexture:pd,viewportSize:sY,viewportTexture:li,viewportUV:sJ,vogelDiskSample:cO,wgsl:(e,t)=>pE(e,t,"wgsl"),wgslFn:(e,t)=>pw(e,t,"wgsl"),workgroupArray:(e,t)=>new pQ("Workgroup",e,t),workgroupBarrier:()=>pj("workgroup").toStack(),workgroupId:pz,workingToColorSpace:iW,xor:t9});let g0=new hN;class g1 extends d6{constructor(e,t){super(),this.renderer=e,this.nodes=t}
8update(e,t,r){let i=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(null===s)i._clearColor.getRGB(g0),g0.a=i._clearColor.a;else if(!0===s.isColor)s.getRGB(g0),g0.a=1,a=!0;else if(!0===s.isNode){let r=this.get(e);g0.copy(i._clearColor);let a=r.backgroundMesh;if(void 0===a){let e=eJ(s).mul(cH).context({getUV:()=>cq.mul(aZ),getTextureLevel:()=>cW}),t=al.element(3).element(3).equal(1),i=tY(1,al.element(1).element(1)).mul(3),n=t.select(aI.mul(i),aI),o=aU.mul(eJ(n,0)),l=al.mul(eJ(o.xyz,1));l=l.setZ(l.w);let d=new lE;d.name="Background.material",d.side=u.hsX,d.depthTest=!1,d.depthWrite=!1,d.allowOverride=!1,d.fog=!1,d.lights=!1,d.vertexNode=l,d.colorNode=e,r.backgroundMeshNode=e,r.backgroundMesh=a=new u.eaF(new u.Gu$(1,32,32),d),a.frustumCulled=!1,a.name="Background.mesh",s.addEventListener("dispose",function e(){s.removeEventListener("dispose",e),a.material.dispose(),a.geometry.dispose()})}let n=s.getCacheKey();r.backgroundCacheKey!==n&&(r.backgroundMeshNode.node=eJ(s).mul(cH),r.backgroundMeshNode.needsUpdate=!0,a.material.needsUpdate=!0,r.backgroundCacheKey=n),t.unshift(a,a.geometry,a.material,0,0,null,null)}else(0,u.z3S)("Renderer: Unsupported background configuration.",s);let n=i.xr.getEnvironmentBlendMode();if("additive"===n?g0.set(0,0,0,1):"alpha-blend"===n&&g0.set(0,0,0,0),!0===i.autoClear||!0===a){let e=r.clearColorValue;e.r=g0.r,e.g=g0.g,e.b=g0.b,e.a=g0.a,(!0===i.backend.isWebGLBackend||!0===i.alpha)&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),r.depthClearValue=i.getClearDepth(),r.stencilClearValue=i.getClearStencil(),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 g2=0;class g3{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=g2++}}class g4{constructor(e,t,r,i,s,a,n,o,l,u,d=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=d,this.nodeAttributes=i,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=n,this.updateAfterNodes=o,this.observer=l,this.hardwareClipping=u,this.usedTimes=0}createBindings(){let e=[];for(let t of this.bindings)if(!0!==t.bindings[0].groupNode.shared){let r=new g3(t.name,[]);for(let i of(e.push(r),t.bindings))r.bindings.push(i.clone())}else e.push(t);return e}}class g5{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class g6{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class g8{constructor(e,t,r=!1,i=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=i}}class g9 extends g8{constructor(e,t,r=null,i=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=i}}class g7{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let fe=0;class ft{constructor(e=null){this.id=fe++,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 fr{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class fi{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class fs extends fi{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class fa extends fi{constructor(e,t=new u.I9Y){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class fn extends fi{constructor(e,t=new u.Pq0){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class fo extends fi{constructor(e,t=new u.IUQ){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class fl extends fi{constructor(e,t=new u.Q1f){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class fu extends fi{constructor(e,t=new u.k_V){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class fd extends fi{constructor(e,t=new u.dwI){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class fh extends fi{constructor(e,t=new u.kn4){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class fc extends fs{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class fp extends fa{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class fm extends fn{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class fg extends fo{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class ff extends fl{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class fb extends fu{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class fy extends fd{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class fx extends fh{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let fT=0,f_=new WeakMap,fv=new WeakMap,fS=new WeakMap,fN=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),fR=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0"),fA=e=>{if(e.writeUsageCount>0)return!0;
8if(void 0!==e.subBuildsCache){for(let t in e.subBuildsCache)if(fA(e.subBuildsCache[t]))return!0}return!1};class fE{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=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=hM(),this.stacks=[],this.tab="	",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new ft,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:fT++})}isFlatShading(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}isOpaque(){let e=this.material;return!1===e.transparent&&e.blending===u.NTi&&!1===e.alphaToCoverage}createRenderTarget(e,t,r){return new u.O0B(e,t,r)}createCubeRenderTarget(e,t){return new lz(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t="vec4",r=this.renderer.getRenderTarget();if(null!==r){let i=r.textures[e].type,s=r.textures[e].format,a="vec";i===u.Yuy?a="ivec":i===u.bkx&&(a="uvec"),t=s===u.VT0||s===u.ZQM?i===u.Yuy?"int":i===u.bkx?"uint":"float":s===u.paN||s===u.TkQ?`${a}2`:s===u.HIg||s===u.VGF?`${a}3`:`${a}4`}return t}getOutputStructName(){}_getBindGroup(e,t){let r,i=t[0].groupNode,s=i.shared;if(s)for(let e=1;e<t.length;e++)i!==t[e].groupNode&&(s=!1);if(s){let i="";for(let e of t)if(e.isNodeUniformsGroup)for(let t of(e.uniforms.sort((e,t)=>e.nodeUniform.node.id-t.nodeUniform.node.id),e.uniforms))i+=t.nodeUniform.node.id;else i+=e.nodeUniform.id;let s=this.renderer._currentRenderContext||this.renderer,a=f_.get(s);void 0===a&&(a=new Map,f_.set(s,a));let n=y(i);void 0===(r=a.get(n))&&(r=new g3(e,t),a.set(n,r))}else r=new g3(e,t);return 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 F)for(let i in r[e]){let s=r[e][i],a=t[i]||(t[i]=[]);for(let e of s)!1===a.includes(e)&&a.push(e)}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)=>e.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}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){!1===this.nodes.has(e)&&(this.nodes.add(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){let t=e.getUpdateBeforeType(),r=e.getUpdateAfterType();(t!==w.NONE||r!==w.NONE)&&this.sequentialNodes.add(e)}buildUpdateNodes(){for(let e of this.nodes)e.getUpdateType()!==w.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==w.NONE&&this.updateBeforeNodes.push(e),r!==w.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===u.k6q||e.magFilter===u.kRr||e.magFilter===u.Cfg||e.magFilter===u.$_I||e.minFilter===u.k6q||e.minFilter===u.kRr||e.minFilter===u.Cfg||e.minFilter===u.$_I}getUniformBufferLimit(){return this.renderer.backend.capabilities.getUniformBufferLimit()}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw Error("THREE.NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}addContext(e){let t=this.getContext();return this.setContext({...this.context,...e}),t}getSharedContext(){let e={...this.context};return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}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 ft(t?this.getCache():null)),r.cache}isAvailable(){return!1}getVertexIndex(){(0,u.R8M)("Abstract function.")}getInstanceIndex(){(0,u.R8M)("Abstract function.")}getDrawIndex(){(0,u.R8M)("Abstract function.")}getFrontFacing(){(0,u.R8M)("Abstract function.")}getFragCoord(){(0,u.R8M)("Abstract function.")}isFlipY(){return!1}isContextAssign(){return!0===this.context.assign}increaseUsage(e){let t=this.getDataFromNode(e);return t.usageCount=void 0===t.usageCount?1:t.usageCount+1,this.isContextAssign()?t.writeUsageCount=void 0===t.writeUsageCount?1:t.writeUsageCount+1:t.readUsageCount=void 0===t.readUsageCount?1:t.readUsageCount+1,t.usageCount}hasWriteUsage(e){let t=e.getShared(this),r=(t.isGlobal(this)?this.globalCache:this.cache).getData(t);
vendor: 8,894 bytes, line 8
8if(void 0!==r){for(let e in r)if(fA(r[e]))return!0}return!1}generateTexture(){(0,u.R8M)("Abstract function.")}generateTextureLod(){(0,u.R8M)("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 a=r?r[s]:null;null!==a?i+=a.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||"uvec2"===e||"ivec2"===e?t=new u.I9Y:"vec3"===e||"uvec3"===e||"ivec3"===e?t=new u.Pq0:("vec4"===e||"uvec4"===e||"ivec4"===e)&&(t=new u.IUQ)),"float"===e)return fR(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")}( ${fR(t.r)}, ${fR(t.g)}, ${fR(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(`THREE.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 g5(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;return!0===e.isDepthTexture?"float":t===u.Yuy?"int":t===u.bkx?"uint":"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=_.get(e),i="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),i+r}getTypeFromArray(e){return fN.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,a=e.normalized;return e instanceof u.Oax||!0===a||(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")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw Error("THREE.NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=hM(this.stack);let e=eO();return this.stacks.push(e),eD(this.stack),this.stack}removeStack(){let e=this.stack;for(let t of e.nodes)this.getDataFromNode(t).stack=e;return this.stack=e.parent,eD(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];if(0===this.subBuildLayers.length)return s;let a=i.any?i.any.subBuilds:null,n=this.getClosestSubBuild(a);return n&&(void 0===s.subBuildsCache&&(s.subBuildsCache={}),(s=s.subBuildsCache[n]||(s.subBuildsCache[n]={})).subBuilds=a),s}getNodeProperties(e,t="any"){let r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t,r=null){let i=this.getDataFromNode(e,"vertex"),s=i.bufferAttribute;if(void 0===s){let a=this.uniforms.index++;null===r&&(r="nodeAttribute"+a),s=new g5(r,t,e),this.bufferAttributes.push(s),i.bufferAttribute=s}return s}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,i=this.shaderStage){let s=this.getDataFromNode(e,i,this.globalCache),a=s.structType;if(void 0===a){let n=this.structs.index++;null===r&&(r="StructType"+n),a=new fr(r,t),this.structs[i].push(a),this.types[i][r]=e,s.structType=a}return a}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),a=s.uniform;if(void 0===a){let n=this.uniforms.index++;a=new g6(i||"nodeUniform"+n,t,e),this.uniforms[r].push(a),this.registerDeclaration(a),s.uniform=a}return a}getVarFromNode(e,t=null,r=e.getNodeType(this),i=this.shaderStage,s=!1){let a=this.getDataFromNode(e,i),n=this.getSubBuildProperty("variable",a.subBuilds),o=a[n];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"!==n&&(t=this.getSubBuildProperty(t,a.subBuilds));let h=e.getArrayCount(this);o=new g8(t,r,s,h),s||u.push(o),this.registerDeclaration(o),a[n]=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 a=this.getDataFromNode(e,"any"),n=this.getSubBuildProperty("varying",a.subBuilds),o=a[n];if(void 0===o){let e=this.varyings,l=e.length;null===t&&(t="nodeVarying"+l),"varying"!==n&&(t=this.getSubBuildProperty(t,a.subBuilds)),o=new g9(t,r,i,s),e.push(o),this.registerDeclaration(o),a[n]=o}return o}registerDeclaration(e){let t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),i=e.name,s=i,a=this.getPropertyName(e),n=1;for(;void 0!==r[a];)e.name=s=i+"_"+n++,a=this.getPropertyName(e);s!==i&&(0,u.R8M)(`TSL: Declaration name '${i}' of '${e.type}' already in use. Renamed to '${s}'.`),r[a]=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 g7("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,a=t;for(;a;){if(!0===i.get(a)){s=!1;break}a=this.getDataFromNode(a).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=[]),a=i.flowCodeBlock||(i.flowCodeBlock=new WeakMap);s.push(t),a.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=this.renderer.backend,r=fv.get(t);void 0===r&&(r=new WeakMap,fv.set(t,r));let i=r.get(e);if(void 0===i){i=new pC;let t=this.currentFunctionNode;this.currentFunctionNode=i,i.code=this.buildFunctionCode(e),this.currentFunctionNode=t,r.set(e,i)}return i}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})}}};
8for(let e of t.inputs)r[e.name]=new hC(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,a=this.cache,n=this.buildStage,o=this.stack,l={code:""};for(let r of(this.flow=l,this.vars={},this.declarations={},this.cache=new ft,this.stack=hM(),U))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=a,this.stack=o,this.setBuildStage(n),l}getFunctionOperator(){return null}buildFunctionCode(){(0,u.R8M)("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,a=this.cache,n=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};
9`),this.flowCode[e]=this.flowCode[e]+s.code,u=s}else u=t.build(this);return this.setShaderStage(n),this.cache=a,this.tab=s,this.context=o,u}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){(0,u.R8M)("Abstract function.")}getVaryings(){(0,u.R8M)("Abstract function.")}getVar(e,t,r=null){return`${null!==r?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e,t=!1){let r=[],i=this.vars[e];if(void 0!==i)for(let e of i)r.push(`${this.getVar(e.type,e.name,e.count)};`);return r.join(t?"\n":"\n	")}getUniforms(){(0,u.R8M)("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(){(0,u.R8M)("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}prebuild(){let{object:e,renderer:t,material:r}=this;if(!0===t.contextNode.isContextNode?this.context={...this.context,...t.contextNode.getFlowContextData()}:(0,u.z3S)('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(!0===r.contextNode.isContextNode?this.context={...this.context,...r.contextNode.getFlowContextData()}:(0,u.z3S)('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),null!==r){let e=t.library.fromMaterial(r);null===e&&((0,u.z3S)(`NodeBuilder: Material "${r.type}" is not compatible.`),e=new lE),e.build(this)}else this.addFlow("compute",e)}build(){for(let e of(this.prebuild(),U))for(let t of(this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position),F))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}async buildAsync(){for(let e of(this.prebuild(),U))for(let t of(this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position),F)){for(let r of(this.setShaderStage(t),this.flowNodes[t]))"generate"===e?this.flowNode(r):r.build(this);await (0,u.aH0)()}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUp
9dateNodes(),this}getSharedDataFromNode(e){let t=fS.get(e);return void 0===t&&(t={}),t}getNodeUniform(e,t){let r=this.getSharedDataFromNode(e),i=r.cache;if(void 0===i){if("float"===t||"int"===t||"uint"===t)i=new fc(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)i=new fp(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)i=new fm(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)i=new fg(e);else if("color"===t)i=new ff(e);else if("mat2"===t)i=new fb(e);else if("mat3"===t)i=new fy(e);else if("mat4"===t)i=new fx(e);else throw Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);r.cache=i}return i}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
10`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has("velocity")||!0===E(this.object).useVelocity}}class fC{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={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){let t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===w.FRAME){let t=this._getMaps(this.updateBeforeMap,r);if(t.frameId!==this.frameId){let r=t.frameId;t.frameId=this.frameId,!1===e.updateBefore(this)&&(t.frameId=r)}}else if(t===w.RENDER){let t=this._getMaps(this.updateBeforeMap,r);if(t.renderId!==this.renderId){let r=t.renderId;t.renderId=this.renderId,!1===e.updateBefore(this)&&(t.renderId=r)}}else t===w.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===w.FRAME){let t=this._getMaps(this.updateAfterMap,r);t.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(t.frameId=this.frameId)}else if(t===w.RENDER){let t=this._getMaps(this.updateAfterMap,r);t.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(t.renderId=this.renderId)}else t===w.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),r=e.updateReference(this);if(t===w.FRAME){let t=this._getMaps(this.updateMap,r);t.frameId!==this.frameId&&!1!==e.update(this)&&(t.frameId=this.frameId)}else if(t===w.RENDER){let t=this._getMaps(this.updateMap,r);t.renderId!==this.renderId&&!1!==e.update(this)&&(t.renderId=this.renderId)}else t===w.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class fw{constructor(e,t,r=null,i="",s=!1){this.type=e,this.name=t,this.count=r,this.qualifier=i,this.isConst=s}}fw.isNodeFunctionInput=!0;class fM extends m6{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class fB extends m6{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:m_(this.light),lightColor:e}}}class fU extends m6{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=my(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=tV(new u.Q1f).setGroup(tD)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}
10setup(e){let{colorNode:t,groundColorNode:r,lightDirectionNode:i}=this,s=id(r,t,a0.dot(i).mul(.5).add(.5));e.context.irradiance.addAssign(s)}}class fF extends m6{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=tV(0).setGroup(tD),this.penumbraCosNode=tV(0).setGroup(tD),this.cutoffDistanceNode=tV(0).setGroup(tD),this.decayExponentNode=tV(0).setGroup(tD),this.colorNode=tV(this.color).setGroup(tD)}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 im(r,i,t)}getLightCoord(e){let t=e.getNodeProperties(this),r=t.projectionUV;return void 0===r&&(t.projectionUV=r=mb(this.light,e.context.positionWorld)),r}setupDirect(e){let t,r,{colorNode:i,cutoffDistanceNode:s,decayExponentNode:a,light:n}=this,o=this.getLightVector(e),l=o.normalize(),u=l.dot(m_(n)),d=this.getSpotAttenuation(e,u),h=m8({lightDistance:o.length(),cutoffDistance:s,decayExponent:a}),c=i.mul(d).mul(h);return n.colorNode?(r=this.getLightCoord(e),t=n.colorNode(r)):n.map&&(r=this.getLightCoord(e),t=sD(n.map,r.xy).onRenderUpdate(()=>n.map)),t&&(c=r.mul(2).sub(1).abs().lessThan(1).all().select(c.mul(t),c)),{lightColor:c,lightDirection:l}}}class fL extends fF{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){let r=this.light.iesMap,i=null;if(r&&!0===r.isTexture){let e=t.acos().mul(1/Math.PI);this._iesTextureNode=sD(r,eH(e,0),0),i=this._iesTextureNode.r}else i=super.getSpotAttenuation(e,t);return i}update(e){super.update(e),null!==this._iesTextureNode&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}class fP extends m6{static get type(){return"LightProbeNode"}constructor(e=null){super(e);let t=[];for(let e=0;e<9;e++)t.push(new u.Pq0);this.lightProbe=sz(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=gZ(a0,this.lightProbe);e.context.irradiance.addAssign(t)}}let fD=eP(([e,t])=>{let r=e.abs().sub(t);return rW(r3(r,0)).add(r2(r3(r.x,r.y),0))});class fO extends fF{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=ek(0),r=this.penumbraCosNode,i=mf(this.light).mul(e.context.positionWorld||aG);return eI(i.w.greaterThan(0),()=>{let e=fD(i.xyz.div(i.w).xy.sub(eH(.5)),eH(.5)),s=tY(-1,tQ(1,rI(r)).sub(1));t.assign(ic(e.mul(-2).mul(s)))}),t}}let fI=new u.kn4,fV=new u.kn4,fG=null;class fk extends m6{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=tV(new u.Pq0).setGroup(tD),this.halfWidth=tV(new u.Pq0).setGroup(tD),this.updateType=w.RENDER}update(e){super.update(e);let{light:t}=this,r=e.camera.matrixWorldInverse;fV.identity(),fI.copy(t.matrixWorld),fI.premultiply(r),fV.extractRotation(fI),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(fV),this.halfHeight.value.applyMatrix4(fV)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=sD(fG.LTC_FLOAT_1),r=sD(fG.LTC_FLOAT_2)):(t=sD(fG.LTC_HALF_1),r=sD(fG.LTC_HALF_2));let{colorNode:i,light:s}=this;return{lightColor:i,lightPosition:mT(s),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){fG=e}}class fz{parseFunction(){(0,u.R8M)("Abstract function.")}}class f${constructor(e,t,r="",i=""){this.type=e,this.inputs=t,this.name=r,this.precision=i}getCode(){(0,u.R8M)("Abstract function.")}}f$.isNodeFunction=!0;let fW=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,fH=/[a-z_0-9]+/ig,fq="#pragma main";class fj extends f${constructor(e){let{type:t,inputs:r,name:i,precision:s,inputsCode:a,blockCode:n,headerCode:o}=(e=>{let t=(e=e.trim()).indexOf(fq),r=-1!==t?e.slice(t+fq.length):e,i=r.match(fW);if(null!==i&&5===i.length){let s=i[4],a=[],n=null;for(;null!==(n=fH.exec(s));)a.push(n);let o=[],l=0;for(;l<a.length;){let e="const"===a[l][0];!0===e&&l++;let t=a[l][0];"in"===t||"out"===t||"inout"===t?l++:t="";let r=a[l++][0],i=Number.parseInt(a[l][0]);!1===Number.isNaN(i)?l++:i=null;let s=a[l++][0];o.push(new fw(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("THREE.FunctionNode: Function is not a GLSL code.")})(e);super(t,r,i,s),this.inputsCode=a,this.blockCode=n,this.headerCode=o}getCode(e=this.name){let t,r=this.blockCode;if(""!==r){let{type:i,inputsCode:s,headerCode:a,precision:n}=this,o=`${i} ${e} ( ${s.trim()} )`;""!==n&&(o=`${n} ${o}`),t=a+o+r}else t="";return t}}class fX extends fz{parseFunction(e){return new fj(e)}}let fQ=[],fK=[],fY=tV(0,"int").setGroup(tD);class fZ extends d6{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new fC,this.nodeBuilderCache=new Map,this.callHashCache=new d0,this.groupsData=new d0,this._buildQueue=[],this._buildInProgress=!1,this.cacheLib={}}updateGroup(e){let t=e.groupNode;if(t.updateType===w.OBJECT)return!0;fQ[0]=t,fQ[1]=e;let r=this.groupsData.get(fQ);return void 0===r&&this.groupsData.set(fQ,r={}),fQ[0]=null,fQ[1]=null,r.version!==t.version&&(r.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}_createNodeBuilder(e,t){let r=this.backend.createNodeBuilder(e.object,this.renderer);return r.scene=e.scene,r.material=t,r.camera=e.camera,r.context.material=t,r.lightsNode=e.lightsNode,r.environmentNode=this.getEnvironmentNode(e.scene),r.fogNode=this.getFogNode(e.scene),r.clippingContext=e.clippingContext,this.renderer.getOutputRe
10nderTarget()&&this.renderer.getOutputRenderTarget().multiview&&r.enableMultiview(),r}getForRender(e,t=!1){let r=this.get(e),i=r.nodeBuilderState;if(void 0===i){let{nodeBuilderCache:s}=this,a=this.getForRenderCacheKey(e);if(void 0===(i=s.get(a))){let n=async()=>{let r=this._createNodeBuilder(e,e.material);try{t?await r.buildAsync():r.build()}catch(i){r=this._createNodeBuilder(e,new lE),t?await r.buildAsync():r.build(),(0,u.z3S)("TSL: "+i)}return r};if(t)return n().then(e=>(i=this._createNodeBuilderState(e),s.set(a,i),i.usedTimes++,r.nodeBuilderState=i,i));{let t=this._createNodeBuilder(e,e.material);try{t.build()}catch(i){(t=this._createNodeBuilder(e,new lE)).build();let r=i.stackTrace;!r&&i.stack&&(r=new f(i.stack)),(0,u.z3S)("TSL: "+i,r)}i=this._createNodeBuilderState(t),s.set(a,i)}}i.usedTimes++,r.nodeBuilderState=i}return i}getForRenderAsync(e){let t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){let t=this.get(e);if(void 0!==t.nodeBuilderState)return t.nodeBuilderState;let r=this.getForRenderCacheKey(e),i=this.nodeBuilderCache.get(r);return void 0!==i?(i.usedTimes++,t.nodeBuilderState=i,i):(!0!==t.pendingBuild&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){this._buildInProgress||0===this._buildQueue.length||(this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()}))}delete(e){if(e.isRenderObject){let t=this.get(e).nodeBuilderState;void 0!==t&&(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||t.version!==e.version){let i=this.backend.createNodeBuilder(e,this.renderer);i.build(),t.nodeBuilderState=r=this._createNodeBuilderState(i),t.version=e.version}return r}_createNodeBuilderState(e){return new g4(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(!1===this.renderer.lighting.enabled)return null;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}
10getBackgroundNode(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){fQ[0]=e,fQ[1]=t;let r=this.renderer.info.calls,i=this.callHashCache.get(fQ)||{};if(i.callId!==r){if(fK.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),fK.push(+!!this.renderer.lighting.enabled),this.renderer.lighting.enabled){fK.push(t.getCacheKey(!0)),fK.push(+!!this.renderer.shadowMap.enabled),fK.push(this.renderer.shadowMap.type);let r=this.getEnvironmentNode(e);r&&fK.push(r.getCacheKey())}let s=this.getFogNode(e);s&&fK.push(s.getCacheKey()),i.callId=r,i.cacheKey=x(fK),this.callHashCache.set(fQ,i),fK.length=0}return fQ[0]=null,fQ[1]=null,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 dA(r);else return lj(!0===r.isCubeTexture?nl(r):sD(r));if(!0===r.isTexture)return sD(r,sj.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&(0,u.z3S)("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),a=s.get(t);return(void 0===a||i)&&(a=r(),s.set(t,a)),a}updateFog(e){let t=this.get(e),r=e.fog;r?t.fog!==r&&(t.fogNode=this.getCacheNode("fog",r,()=>{if(r.isFogExp2)return pL(nh("color","color",r).setGroup(tD),pU(nh("density","float",r).setGroup(tD)));if(r.isFog){let e=nh("color","color",r).setGroup(tD);return pL(e,pB(nh("near","float",r).setGroup(tD),nh("far","float",r).setGroup(tD)))}(0,u.z3S)("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?nl(r):!0===r.isTexture?sD(r):void(0,u.z3S)("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 a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=r,a.camera=i,a.material=s,a}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}getOutputNode(e){let t=this.renderer;return e.isArrayTexture?this.backend.isWebGLBackend?sD(e,sj).depth(sW("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):sD(e,sj).depth(fY).renderOutput(t.toneMapping,t.currentColorSpace):sD(e,sj).renderOutput(t.toneMapping,t.currentColorSpace)}setOutputLayerIndex(e){fY.value=e}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 fC,this.nodeBuilderCache=new Map,this.cacheLib={}}}let fJ=new u.Zcv;class f0{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new u.kn4,this.viewNormalMatrix=new u.dwI,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,null!==e&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,r){let i=e.length;for(let s=0;s<i;s++){fJ.copy(e[s]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let i=t[r+s],a=fJ.normal;i.x=-a.x,i.y=-a.y,i.z=-a.z,i.w=fJ.constant}}updateGlobal(e,t){this.shadowPass=null!==e.overrideMaterial&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix.copy(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 a=t.clippingPlanes,n=a.length;if(this.clipIntersection?(r=this.intersectionPlanes,i=e.intersectionPlanes.length):(r=this.unionPlanes,i=e.unionPlanes.length),r.length!==i+n){r.length=i+n;for(let e=0;e<n;e++)r[i+e]=new u.IUQ;s=!0}this.projectPlanes(a,r,i),s&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}
10getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return void 0===t&&(t=new f0(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class f1{constructor(e,t,r){this.bundleGroup=e,this.camera=t,this.renderContext=r}}let f2=[];class f3{constructor(){this.bundles=new d0}get(e,t,r){let i=this.bundles;f2[0]=e,f2[1]=t,f2[2]=r;let s=i.get(f2);return void 0===s&&(s=new f1(e,t,r),i.set(f2,s)),f2[0]=null,f2[1]=null,f2[2]=null,s}dispose(){this.bundles=new d0}}class f4{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(0,u.R8M)(`Redefinition of node ${t}`);if("function"!=typeof e)throw Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if("function"==typeof t||"object"==typeof t)throw Error(`THREE.NodeLibrary: Base class ${t} is not a class.`);r.set(t,e)}addClass(e,t,r){if(r.has(t))return void(0,u.R8M)(`Redefinition of node ${t.name}`);if("function"!=typeof e)throw Error(`THREE.NodeLibrary: Node class ${e.name} is not a class.`);if("function"!=typeof t)throw Error(`THREE.NodeLibrary: Base class ${t.name} is not a class.`);r.set(t,e)}}let f5=new mC,f6=new WeakMap;class f8{constructor(){this.enabled=!0,this._cache=[]}createNode(e=[]){return new mC().setLights(e)}getNode(e){if(!0!==e.isScene&&!0!==e.isGroup)return f5;let t=f6.get(e);return void 0===t&&(t=this.createNode(),f6.set(e,t)),t}beginRender(e){this._cache.push(this.getNode(e).getLights())}finishRender(e){this.getNode(e).setLights(this._cache.pop())}}class f9 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 f7=new u.Pq0,be=new u.Pq0,bt=new WeakMap;class br 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._cameraL.matrixWorldAutoUpdate=!1,this._cameraR=new u.ubm,this._cameraR.viewport=new u.IUQ,this._cameraR.matrixWorldAutoUpdate=!1,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new u.nZQ,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding="undefined"!=typeof XRWebGLBinding,this._supportsWebGPUBinding=void 0!==globalThis.XRGPUBinding,this._createXRLayer=bo.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSamples=null,this._currentSize=new u.I9Y,this._onSessionEvent=bs.bind(this),this._onSessionEnd=ba.bind(this),this._onInputSourcesChange=bn.bind(this),this._onAnimationFrame=bl.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._webgpuBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){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&&(0,u.R8M)("XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,!0===this.isPresenting&&(0,u.R8M)("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}getBaseLayer(){return null!==this._glProjLayer?this._glProjLayer:this._glBaseLayer}getBinding(){return null===this._glBinding&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}foveateBoundTexture(e){if(!0!==e.isPostProcessingRenderTarget||!0!==this.isPresenting||null===this._glProjLayer)return;let t=this._renderer.backend;if(void 0===t||!0!==t.isWebGLBackend||null===t.state)return;
10let r=this._renderer.getOutputRenderTarget();if(null===r||!0!==r.isXRRenderTarget)return;let i=this.getBinding();if(null===i||"function"!=typeof i.foveateBoundTexture)return;this._renderer._textures.updateRenderTarget(e);let{textureGPU:s,glTextureType:a}=t.get(e.texture);if(void 0!==s&&void 0!==a&&e._xrFoveationTextureGPU!==s){e._xrFoveationTextureGPU=s,t.state.bindTexture(a,s);try{i.foveateBoundTexture(a,this.getFoveation())}catch(e){(0,u.mcG)(`XRManager: Unable to foveate bound XR post-processing texture. ${e.name}: ${e.message}`)}finally{t.state.unbindTexture()}}}getWebGPUBinding(){return null===this._webgpuBinding&&this._supportsWebGPUBinding&&(this._webgpuBinding=new globalThis.XRGPUBinding(this._session,this._renderer.backend.device)),this._webgpuBinding}_isWebGPUSession(){return!0===this._renderer.backend.isWebGPUBackend&&null!==this._session&&this._session.enabledFeatures.includes("webgpu")}_validateWebGPUSession(){let e=this._renderer;if(!0===e.backend.isWebGPUBackend){if(!1===this._session.enabledFeatures.includes("webgpu"))throw Error('THREE.XRManager: WebGPU XR sessions require the "webgpu" session feature. Use VRButtonGPU/XRButton with "webgpu" enabled or use a WebGL backend.');e.samples>0&&((0,u.mcG)("THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session."),null===this._currentSamples&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){let t=this.getWebGPUBinding(),r=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:"depth24plus"});this._glProjLayer=r,e.updateRenderState({layers:[r]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new u.O0B(r.textureWidth,r.textureHeight,{depth:2,minFilter:u.k6q,magFilter:u.k6q,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,!0===this._useMultiviewIfPossible&&(0,u.mcG)("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}
10_disposeWebGPUSession(){let e=this._renderer,t=this._xrRenderTarget;if(null===t||!0!==e.backend.isWebGPUBackend)return;let r=e.backend,i=e._textures,s=r.get?r.get(t):null;s&&(s.descriptors=void 0);let a=e=>{null!=e&&(r.delete&&r.delete(e),i.delete&&i.delete(e))};for(let e=0;e<t.textures.length;e++)a(t.textures[e]);a(t.depthTexture),a(t),e._renderContexts&&e._renderContexts.dispose&&e._renderContexts.dispose(),t.dispose()}_getWebGPUViewData(e){let t=this.getWebGPUBinding(),r={colorTexture:null,viewDescriptors:[],viewports:[]};for(let i=0;i<e.length;i++){let s=t.getViewSubImage(this._glProjLayer,e[i]);null===r.colorTexture&&(r.colorTexture=s.colorTexture),r.viewports.push(s.viewport),s.getViewDescriptor&&r.viewDescriptors.push(s.getViewDescriptor())}return r}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,r,i,s,a,n,o={}){let l=new u.bdM(e,t),d=new f9(s,a,{format:u.GWd,type:u.OUM,depthTexture:new u.VCu(s,a,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:a,plane:c,material:h,rendercall:n,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,a,n,o,l={}){let d=new u.Ho_(e,e,e*t/r,64,64,!0,Math.PI-t/2,t),h=new f9(a,n,{format:u.GWd,type:u.OUM,depthTexture:new u.VCu(a,n,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);let m={type:"cylinder",radius:e,centralAngle:t,aspectratio:r,translation:i,quaternion:s,pixelwidth:a,pixelheight:n,plane:p,material:c,rendercall:o,renderTarget:h};if(this._layers.push(m),null!==this._session){m.plane.material=new u.V9B({color:0xffffff,side:u.hsX}),m.plane.material.blending=u.bCz,m.plane.material.blendEquation=u.gO9,m.plane.material.blendSrc=u.ojh,m.plane.material.blendDst=u.ojh,m.xrlayer=this._createXRLayer(m);let e=this._session.renderState.layers;e.unshift(m.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;this.isPresenting=!1;let s=new u.I9Y;r.getSize(s);let a=r.getRenderTarget();for(let i of this._layers){let s;i.renderTarget.isXRRenderTarget=null!==this._session,i.renderTarget._hasExternalTextures=i.renderTarget.isXRRenderTarget;let a=r.contextNode;if(i.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){i.xrlayer.transform=new XRRigidTransform(i.plane.getWorldPosition(e),i.plane.getWorldQuaternion(t));let n=this._glBinding.getSubImage(i.xrlayer,this._xrFrame);r.backend.setXRRenderTargetTextures(i.renderTarget,n.colorTexture,void 0),r._setXRLayerSize(i.renderTarget.width,i.renderTarget.height),void 0===(s=bt.get(a))&&(s=a.context({getOutput:e=>sx(e,r.toneMapping,r.outputColorSpace)}),bt.set(a,s))}else s=a;r.contextNode=s,r.setRenderTarget(i.renderTarget),i.rendercall(),r.contextNode=a}r.setRenderTarget(a),r._setXRLayerSize(s.x,s.y),this.isPresenting=i}getSession(){return this._session}async setSession(e){let t=this._renderer;!1===t.initialized&&await t.init(),this._gl=t.getContext();let r=this._gl;if(this._session=e,null!==e){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),this._val
10idateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(!0===this._supportsLayers){let i=null,s=null,a=null,n=r.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(a=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,i=t.stencil?u.dcC:u.zdS,s=t.stencil?u.V3x:u.bkx);let o={colorFormat:r.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(o.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();let l=this._glBinding.createProjectionLayer(o),d=[l];this._glProjLayer=l,t.setPixelRatio(1),t._setXRLayerSize(l.textureWidth,l.textureHeight);let h=this._useMultiview?2:1,c=new u.VCu(l.textureWidth,l.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i,h);if(this._xrRenderTarget=new f9(l.textureWidth,l.textureHeight,{format:u.GWd,type:u.OUM,colorSpace:t.outputColorSpace,depthTexture:c,stencilBuffer:t.stencil,samples:4*!!n.antialias,resolveDepthBuffer:!1===l.ignoreDepthValues,resolveStencilBuffer:!1===l.ignoreDepthValues,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(let e of this._layers)e.plane.material=new u.V9B({color:0xffffff,side:"cylinder"===e.type?u.hsX:u.hB5}),e.plane.material.blending=u.bCz,e.plane.material.blendEquation=u.gO9,e.plane.material.blendSrc=u.ojh,e.plane.material.blendDst=u.ojh,e.xrlayer=this._createXRLayer(e),d.unshift(e.xrlayer);e.updateRenderState({layers:d})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());let i=new XRWebGLLayer(e,r,{antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()});this._glBaseLayer=i,e.updateRenderState({baseLayer:i}),t.setPixelRatio(1),t._setXRLayerSize(i.framebufferWidth,i.framebufferHeight),this._xrRenderTarget=new f9(i.framebufferWidth,i.framebufferHeight,{format:u.GWd,type:u.OUM,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:!1===i.ignoreDepthValues,resolveStencilBuffer:!1===i.ignoreDepthValues}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}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 a=e.near,n=e.far,o=this._cameraXR,l=this._cameraL,d=this._cameraR;o.near=d.near=l.near=a,o.far=d.far=l.far=n,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=-5&o.layers.mask,d.layers.mask=-3&o.layers.mask;let h=e.parent,c=o.cameras;bi(o,h);for(let e=0;e<c.length;e++)bi(c[e],h);2===c.length?function(e,t,r){f7.setFromMatrixPosition(t.matrixWorld),be.setFromMatrixPosition(r.matrixWorld);let i=f7.distanceTo(be),s=t.projectionMatrix.elements,a=r.projectionMatrix.elements,n=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=(a[8]+1)/a[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=n+c,r=o+c;e.projectionMatrix.makePerspective(n*d-p,n*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 bi(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function bs(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 ba(){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,null!==this._currentSamples&&(t._samples=this._currentSamples,this._currentSamples=null),t._resetXRState(),this._disposeWebGPUSession(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._webgpuBinding=null,this._glBaseLayer=null,this._glProjLayer=null,!0===this._sessionUsesLayers)for(let e of this._layers)e.renderTarget=new f9(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 bn(e){let t=this._controllers,r=this._controllerInputSources;for(let i=0;i<e.removed.length;i++){let s=e.removed[i],a=r.indexOf(s);a>=0&&(r[a]=null,t[a].disconnect(s))}for(let i=0;i<e.added.length;i++){let s=e.added[i],a=r.indexOf(s);if(-1===a){for(let e=0;e<t.length;e++)if(e>=r.length){r.push(s),a=e;break}else if(null===r[e]){r[e]=s,a=e;break}if(-1===a)break}let n=t[a];n&&n.connect(s)}}function bo(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space
10: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 bl(e,t){if(void 0===t)return;let r=this._cameraXR,i=this._renderer,s=i.backend,a=this._glBaseLayer,n=this.getReferenceSpace(),o=t.getViewerPose(n);if(this._xrFrame=t,null!==o){let e=o.views,t=this._isWebGPUSession()?this._getWebGPUViewData(e):null;null!==this._glBaseLayer&&null===t&&s.setXRTarget(a.framebuffer);let n=!1;e.length!==r.cameras.length&&(r.cameras.length=0,n=!0);for(let i=0;i<e.length;i++){let o,l=e[i];if(null!==t)o=t.viewports[i];else if(!0===this._supportsLayers){let e=this._glBinding.getViewSubImage(this._glProjLayer,l);o=e.viewport,0===i&&s.setXRRenderTargetTextures(this._xrRenderTarget,e.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:e.depthStencilTexture)}else o=a.getViewport(l);let d=this._cameras[i];void 0===d&&((d=new u.ubm).layers.enable(i),d.viewport=new u.IUQ,d.matrixWorldAutoUpdate=!1,this._cameras[i]=d),d.matrix.fromArray(l.transform.matrix),d.matrix.decompose(d.position,d.quaternion,d.scale),d.projectionMatrix.fromArray(l.projectionMatrix),d.projectionMatrixInverse.copy(d.projectionMatrix).invert(),d.viewport.set(o.x,o.y,o.width,o.height),0===i&&(r.matrix.copy(d.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)),!0===n&&r.cameras.push(d)}null!==t&&null!==t.colorTexture&&s.setXRRenderTargetTextures(this._xrRenderTarget,t.colorTexture,t.viewDescriptors),i.setOutputRenderTarget(this._xrRenderTarget);let l=i._getFrameBufferTarget();i.xr.foveateBoundTexture(l)}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,n)}this._currentAnimationLoop&&this._currentAnimationLoop(e,t),t.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:t}),this._xrFrame=null}class bu extends u.Qev{constructor(e){super(),this.domElement=e,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.colorTexture=new u.Pem,this.depthTexture=new u.VCu}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._dispatchResize())}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._dispatchResize())}getScissor(e){let t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(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}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,i,s=0,a=1){let n=this._viewport;e.isVector4?n.copy(e):n.set(e,t,r,i),n.minDepth=s,n.maxDepth=a}_dispatchResize(){this.dispatchEvent({type:"resize"})}dispose(){this.dispatchEvent({type:"dispose"})}}let bd=new u.Z58,bh=new u.I9Y,bc=new u.IUQ,bp=new u.PPD,bm=new u.uf3,bg=new u.kn4,bf=new u.IUQ,bb={[u.hB5]:u.hsX,[u.hsX]:u.hB5,[u.$EB]:u.$EB};class by{constructor(e,t={}){this.isRenderer=!0;let{logarithmicDepthBuffer:r=!1,reversedDepthBuffer:i=!1,alpha:s=!0,depth:a=!0,stencil:n=!1,antialias:o=!1,samples:l=0,getFallback:d=null,outputBufferType:h=u.ix0,multiview:c=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=s,this.logarithmicDepthBuffer=r,this.reversedDepthBuffer=i,this.outputColorSpace
10=u.er$,this.toneMapping=u.y_p,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=a,this.stencil=n,this.info=new hi,this.contextNode=iN(),this.library=new f4,this.lighting=new f8,this._samples=l||!0===o?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new bu(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new sv,this._inspector.setRenderer(this),this._getFallback=d,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._quadCache=new Map,this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTargets=new Map;let p=+(!0!==this.alpha);this._clearColor=new hN(0,0,0,p),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.onError=this._onError,this._outputBufferType=h,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._callDepth=-1,this._initPromise=null,this._compilationPromises=null,this._currentSourceMaterial=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,transmitted:!1,type:u.QP0},this.xr=new br(this,c),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,r)=>{await this.compileAsync(r,t,e);let i=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,s=this._renderLists.get(e,t),a=this._renderContexts.get(i,this._mrt),n=e.overrideMaterial||r.material,{fragmentShader:o,vertexShader:l}=this._objects.get(r,n,e,t,s.lightsNode,a,a.clippingContext).getNodeBuilderState();return{fragmentShader:o,vertexShader:l}}}}
10async init(){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 fZ(this,r),this._animation=new dJ(this,this._nodes,this.info),this._attributes=new d9(r,this.info),this._background=new g1(this,this._nodes),this._geometries=new hr(this._attributes,this.info),this._textures=new hS(this,r,this.info),this._pipelines=new hu(r,this._nodes,this.info),this._bindings=new hd(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new d5(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new hb(this.lighting),this._bundles=new f3,this._renderContexts=new h_(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise}get domElement(){return this._canvasTarget.domElement}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,a=this._currentRenderContext,n=this._currentRenderObjectFunction,o=this._handleObjectFunction,l=this._compilationPromises;null===r&&(r=e);let d=!0===e.isScene?e:!0===r.isScene?r:bd,h=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,c=this._renderContexts.get(h,this._mrt),p=this._activeMipmapLevel,m=[];this._currentRenderContext=c,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=m,i.renderId++,i.update(),c.depth=this.depth,c.stencil=this.stencil,c.clippingContext||(c.clippingContext=new f0),c.clippingContext.updateGlobal(d,t),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t=this._updateCamera(t),d.onBeforeRender(this,e,t,h);let g=t.isArrayCamera?bm:bp;t.isArrayCamera?g.setFromArrayCamera(t):(bg.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),g.setFromProjectionMatrix(bg,t.coordinateSystem,t.reversedDepth));let f=this._renderLists.get(d,t);if(f.begin(),this._projectObject(e,t,0,f,c.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&f.pushLight(e)}),f.finish(),null!==h){this._textures.updateRenderTarget(h,p);let e=this._textures.get(h);c.textures=e.textures,c.depthTexture=e.depthTexture}else c.textures=null,c.depthTexture=null;r!==e?this._background.update(r,f,c):this._background.update(d,f,c);let b=f.opaque,y=f.transparent,x=f.transparentDoublePass,T=f.lightsNode;for(let e of(!0===this.opaque&&b.length>0&&this._renderObjects(b,t,d,T),!0===this.transparent&&y.length>0&&this._renderTransparents(y,x,t,d,T),i.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=n,this._handleObjectFunction=o,this._compilationPromises=l,m)){let t=this._objects.get(e.object,e.material,e.scene,e.camera,e.lightsNode,e.renderContext,e.clippingContext,e.passId);t.drawRange=e.object.geometry.drawRange,t.group=e.group,await this._nodes.getForRenderAsync(t),this._nodes.updateBefore(t),this._geometries.updateForRender(t),this._nodes.updateForRender(t),this._bindings.updateForRender(t);let r=[];this._pipelines.getForRender(t,r),r.length>0&&await Promise.all(r),this._nodes.updateAfter(t),await (0,u.aH0)()}}async renderAsync(e,t){(0,u.mcG)('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){(0,u.z3S)("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){null!==this._inspector&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){let t=this.contextNode.value;!0===e?(t.modelViewMatrix=aL,t.modelNormalViewMatrix=aP):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===aL&&e.modelNormalViewMatrix===aP}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return(0,u.mcG)('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
11
12Message: ${e.message}`;e.reason&&(t+=`
13Reason: ${e.reason}`),(0,u.z3S)(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),(0,u.z3S)(t)}_bundleNeedsUpdate(e,t){return void 0===t.bundleGPU||e.version!==t.version}_renderBundle(e,t,r){let{bundleGroup:i,camera:s,renderList:a}=e,n=this._currentRenderContext,o=this._bundles.get(i,s,n),l=this.backend.get(o);if(this._bundleNeedsUpdate(i,l)){this.backend.beginBundle(n),this._currentRenderBundle=o;let{transparentDoublePass:e,transparent:u,opaque:d}=a;!0===this.opaque&&d.length>0&&this._renderObjects(d,s,t,r),!0===this.transparent&&u.length>0&&this._renderTransparents(u,e,s,t,r),this._currentRenderBundle=null,this.backend.finishBundle(n,o),l.ver
vendor: 6,138 bytes, line 13
13sion=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._geometries.updateForRender(r),this._nodes.updateForRender(r),this._bindings.updateForRender(r),this._nodes.updateAfter(r))}}this.backend.addBundle(n,o)}render(e,t){if(!1===this._initialized)throw Error('THREE.Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(e,t)}get initialized(){return this._initialized}_renderOutputLayers(e,t){if(!0!==t.texture.isArrayTexture||t.texture.image.depth<=1)return void this._renderScene(e,e.camera,!1);let r=this._activeCubeFace;try{for(let r=0;r<t.texture.image.depth;r++)this._nodes.setOutputLayerIndex(r),this._activeCubeFace=r,this._renderScene(e,e.camera,!1)}finally{this._nodes.setOutputLayerIndex(0),this._activeCubeFace=r}}_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:a}=this.getDrawingBufferSize(bh),{depth:n,stencil:o}=this,l=this._outputRenderTarget||this._canvasTarget,d=this._frameBufferTargets.get(l);if(void 0===d){(d=new u.O0B(s,a,{depthBuffer:n,stencilBuffer:o,type:this._outputBufferType,format:u.GWd,colorSpace:u.ppV.workingColorSpace,generateMipmaps:!1,minFilter:u.k6q,magFilter:u.k6q,samples:this.samples})).isPostProcessingRenderTarget=!0;let e=()=>{l.removeEventListener("dispose",e),d.dispose(),this._frameBufferTargets.delete(l)};l.addEventListener("dispose",e),this._frameBufferTargets.set(l,d)}let h=this.getOutputRenderTarget();d.depthBuffer=n,d.stencilBuffer=o,null!==h?d.setSize(h.width,h.height,h.depth):d.setSize(s,a,1);let c=this._outputRenderTarget?this._outputRenderTarget.viewport:l._viewport,p=this._outputRenderTarget?this._outputRenderTarget.scissor:l._scissor,m=this._outputRenderTarget?1:l._pixelRatio,g=this._outputRenderTarget?this._outputRenderTarget.scissorTest:l._scissorTest;return d.viewport.copy(c),d.scissor.copy(p),d.viewport.multiplyScalar(m),d.scissor.multiplyScalar(m),d.scissorTest=g,d.multiview=null!==h&&h.multiview,d.useArrayDepthTexture=null!==h&&h.useArrayDepthTexture,d.resolveDepthBuffer=null===h||h.resolveDepthBuffer,d._autoAllocateDepthBuffer=null!==h&&h._autoAllocateDepthBuffer,d}_renderScene(e,t,r=!0){let i;if(!0===this._isDeviceLost)return;let s=r?this._getFrameBufferTarget():null,a=this._nodes.nodeFrame,n=a.renderId,o=this._currentRenderContext,l=this._currentRenderObjectFunction,u=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;let d=!0===e.isScene?e:bd,h=this._renderTarget||this._outputRenderTarget,c=this._activeCubeFace,p=this._activeMipmapLevel;if(null!==s?(i=s,this.setRenderTarget(i)):i=h,null!==i&&!0===i.depthBuffer){let e=this._textures.get(i);!0!==e.depthInitialized&&((!1===this.autoClear||!0===this.autoClear&&!1===this.autoClearDepth)&&this.clearDepth(),e.depthInitialized=!0)}let m=this._renderContexts.get(i,this._mrt,this._callDepth);this._currentRenderContext=m,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,a.renderId=this.info.calls,this.backend.updateTimeStampUID(m),this.inspector.beginRender(this.backend.getTimestampUID(m),e,t,i),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t=this._updateCamera(t);let g=this._canvasTarget,f=g._viewport,b=g._scissor,y=g._pixelRatio;null!==i&&(f=i.viewport,b=i.scissor,y=1),this.getDrawingBufferSize(bh),bc.set(0,0,bh.width,bh.height);let x=void 0===f.minDepth?0:f.minDepth,T=void 0===f.maxDepth?1:f.maxDepth;m.viewportValue.copy(f).multiplyScalar(y).floor(),m.viewportValue.width>>=p,m.viewportValue.height>>=p,m.viewportValue.minDepth=x,m.viewportValue.maxDepth=T,m.viewport=!1===m.viewportValue.equals(bc),m.scissorValue.copy(b).multiplyScalar(y).floor(),m.scissor=g._scissorTest&&!1===m.scissorValue.equals(bc),m.scissorValue.width>>=p,m.scissorValue.height>>=p,m.clippingContext||(m.clippingContext=new f0),m.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,i);let _=t.isArrayCamera?bm:bp;t.isArrayCamera?_.setFromArrayCamera(t):(bg.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(bg,t.coordinateSystem,t.reversedDepth));let v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,m.clippingContext),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),null!==i){this._textures.updateRenderTarget(i,p);let e=this._textures.get(i);m.textures=e.textures,m.depthTexture=e.depthTexture,m.width=e.width,m.height=e.height,m.renderTarget=i,m.depth=i.depthBuffer,m.stencil=i.stencilBuffer}else m.textures=null,m.depthTexture=null,m.width=bh.width,m.height=bh.height,m.depth=this.depth,m.stencil=this.stencil;m.width>>=p,m.height>>=p,m.activeCubeFace=c,m.activeMipmapLevel=p,m.occlusionQueryCount=v.occlusionQueryCount,m.scissorValue.max(bf.set(0,0,0,0)),m.scissorValue.x+m.scissorValue.width>m.width&&(m.scissorValue.width=Math.max(m.width-m.scissorValue.x,0)),m.scissorValue.y+m.scissorValue.height>m.height&&(m.scissorValue.height=Math.max(m.height-m.scissorValue.y,0)),this._background.update(d,v,m),m.camera=t,this.backend.beginRender(m);let{bundles:S,lightsNode:N,transparentDoublePass:R,transparent:A,opaque:E}=v;return S.length>0&&this._renderBundles(S,d,N),!0===this.opaque&&E.length>0&&this._renderObjects(E,t,d,N),!0===this.transparent&&A.length>0&&this._renderTransparents(A,R,t,d,N),this.backend.finishRender(m),a.renderId=n,this._currentRenderContext=o,this._currentRenderObjectFunction=l,this._handleObjectFunction=u,this.lighting.finishRender(e),this._callDepth--,null!==s&&(this.setRenderTarget(h,c,p),this._renderOutput(i)),d.onAfterRender(this,e,t,i),this.inspector.finishRender(this.backend.getTimestampUID(m)),m}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){let t,r=this._nodes.getOutputCacheKey(),i=this._quadCache.get(e.texture);
13if(void 0===i){(t=new cw(new lE)).name="Output Color Transform",t.material.name="outputColorTransform",t.material.fragmentNode=this._nodes.getOutputNode(e.texture),i={quad:t,cacheKey:r},this._quadCache.set(e.texture,i);let s=()=>{t.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",s)};e.texture.addEventListener("dispose",s)}else t=i.quad,i.cacheKey!==r&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0,i.cacheKey=r);let s=this.autoClear,a=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(t,e),this.autoClear=s,this.xr.enabled=a}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,r=0,i=-1){if(null!==t&&t.isReadbackBuffer&&!1===this.info.memoryMap.has(t)){this.info.createReadbackBuffer(t);let e=()=>{t.removeEventListener("dispose",e),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",e)}if(r%4!=0||i>0&&i%4!=0)throw Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,r,i)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,i){this._canvasTarget.setScissor(e,t,r,i)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,i,s=0,a=1){this._canvasTarget.setViewport(e,t,r,i,s,a)}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!0===this.reversedDepthBuffer?1-this._clearDepth: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)throw Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');let i=this._renderTarget||this._getFrameBufferTarget(),s=null;if(null!==i){this._textures.updateRenderTarget(i);let e=this._textures.get(i);(s=this._renderContexts.get(i,null,-1)).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;let t=this.backend.getClearColor();s.clearColorValue.r=t.r,s.clearColorValue.g=t.g,s.clearColorValue.b=t.b,s.clearColorValue.a=t.a,s.clearDepthValue=this.getClearDepth(),s.clearStencilValue=this.getClearStencil(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel(),!0===i.depthBuffer&&(e.depthInitialized=!0)}this.backend.clear(e,t,r,s),null!==i&&null===this._renderTarget&&this._renderOutput(i)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){(0,u.mcG)('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){(0,u.mcG)('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){(0,u.mcG)('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){(0,u.mcG)('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){let e=this.currentToneMapping!==u.y_p,t=this.currentColorSpace!==u.ppV.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return null!==this._renderTarget?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}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(){if(!0===this._initialized){for(let e of(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTargets.keys()))e.dispose();
13Object.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}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){for(let e of(this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTargets.keys()))e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(!0===this._isDeviceLost)return;if(!1===this._initialized)return(0,u.R8M)("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);let r=this._nodes.nodeFrame,i=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);let s=this.backend,a=this._pipelines,n=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===a.has(r)){let e=()=>{r.removeEventListener("dispose",e),a.delete(r),n.deleteForCompute(r),o.delete(r)};r.addEventListener("dispose",e);let t=r.onInitFunction;null!==t&&t.call(r,{renderer:this})}o.updateForCompute(r),n.updateForCompute(r);let i=n.getForCompute(r),l=a.getForCompute(r,i);s.compute(e,r,i,l,t)}s.finishCompute(e),r.renderId=i,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){!1===this._initialized&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return(0,u.mcG)('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return!1===this._initialized&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(!1===this._initialized)throw Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){(0,u.mcG)('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(!1===this._initialized)throw Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(!1===this._initialized)throw Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);let t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){let r;if(null!==t)if(t.isVector2)t=bf.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void(0,u.z3S)("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=bf.copy(t).floor()}else t=bf.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),this._inspector.copyFramebufferToTexture(e)}
13copyTextureToTexture(e,t,r=null,i=null,s=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,i,s,a),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,r,i,s,a=0,n=0){return this.backend.copyTextureToBuffer(e.textures[a],t,r,i,s,n)}_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 a=t.isArrayCamera?bm:bp;if(!e.frustumCulled||a.intersectsSprite(e)){!0===this.sortObjects&&bf.setFromMatrixPosition(e.matrixWorld).applyMatrix4(bg);let{geometry:t,material:a}=e;a.visible&&i.push(e,t,a,r,bf.z,null,s)}}else if(e.isLineLoop)(0,u.z3S)("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 a=t.isArrayCamera?bm:bp;if(!e.frustumCulled||a.intersectsObject(e)){let{geometry:t,material:a}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),bf.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(bg)),Array.isArray(a)){let n=t.groups;for(let o=0,l=n.length;o<l;o++){let l=n[o],u=a[l.materialIndex];u&&u.visible&&i.push(e,t,u,r,bf.z,l,s)}}else a.visible&&i.push(e,t,a,r,bf.z,null,s)}}}if(!0===e.isBundleGroup&&void 0!==this.backend.beginBundle){let a=i;i=this._renderLists.get(e,t);let n=this._bundles.get(e,t,this._currentRenderContext),o=this.backend.get(n);if(this._bundleNeedsUpdate(e,o)){i.begin(),void 0===o.renderObjects?o.renderObjects=[]:o.renderObjects.length=0;let a=e.children;for(let e=0,n=a.length;e<n;e++)this._projectObject(a[e],t,r,i,s);i.finish()}a.pushBundle({bundleGroup:e,camera:t,renderList:i});return}let a=e.children;for(let e=0,n=a.length;e<n;e++)this._projectObject(a[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:a}of(this._renderObjects(e,r,i,s),t))a.side=u.$EB}else this._renderObjects(e,r,i,s)}_renderObjects(e,t,r,i,s=null){for(let a=0,n=e.length;a<n;a++){let{object:n,geometry:o,material:l,group:u,clippingContext:d}=e[a];this._currentRenderObjectFunction(n,r,t,o,l,u,i,d,s)}}_getShadowNodes(e){let t=e.version,r=this._cacheShadowNodes.get(e);if(void 0===r||r.version!==t){let i=e.map&&e.map.isTexture,s=e.colorNode&&e.colorNode.isNode,a=e.castShadowNode&&e.castShadowNode.isNode,n=e.maskShadowNode&&e.maskShadowNode.isNode||e.maskNode&&e.maskNode.isNode,o=null,l=null,d=null;if(i||s||a||n){let t,r;if(a?(t=e.castShadowNode.rgb,r=e.castShadowNode.a,!0!==this.shadowMap.transmitted&&(0,u.mcG)("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(t=eQ(0),r=ek(1)),i&&(r=r.mul(nh("map","texture",e).a)),s&&(r=r.mul(e.colorNode.a)),l=eJ(t,r),n){let t=e.maskShadowNode||e.maskNode;l=eP(([e])=>(t.not().discard(),e))(l)}}e.depthNode&&e.depthNode.isNode&&(d=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?o=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(o=e.positionNode),r={version:t,colorNode:l,depthNode:d,positionNode:o},this._cacheShadowNodes.set(e,r)}return r}_updateCamera(e){let t=this.xr;if(!1===t.isPresenting){let t=!1;if(!0===this.reversedDepthBuffer&&!0!==e.reversedDepth){if(e._reversedDepth=!0,e.isArrayCamera)for(let t of e.cameras)t._reversedDepth=!0;t=!0}let r=this.coordinateSystem;if(e.coordinateSystem!==r){if(e.coordinateSystem=r,e.isArrayCamera)for(let t of e.cameras)t.coordinateSystem=r;t=!0}if(!0===t&&(e.updateProjectionMatrix(),e.isArrayCamera))for(let t of e.cameras)t.updateProjectionMatrix()}return null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===t.enabled&&!0===t.isPresenting&&(!0===t.cameraAutoUpdate&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,r,i,s,a,n,o=null,l=null){let d,h,c,p,m,g,f,b=!1,y=this._currentSourceMaterial;if(e.onBeforeRender(this,t,r,i,s,a),!0===s.allowOverride&&null!==t.overrideMaterial){this._currentSourceMaterial=s;let e=t.overrideMaterial;if(b=!0,d=e.isNodeMaterial?e.colorNode:null,h=e.isNodeMaterial?e.depthNode:null,c=e.isNodeMaterial?e.positionNode:null,p=t.overrideMaterial.side,m=e.displacementMap,g=e.dis
13placementScale,f=e.displacementBias,s.positionNode&&s.positionNode.isNode&&(e.positionNode=s.positionNode),e.alphaTest=s.alphaTest,e.alphaMap=s.alphaMap,e.displacementMap=s.displacementMap,e.displacementScale=s.displacementScale,e.displacementBias=s.displacementBias,e.transparent=s.transparent||s.transmission>0||s.transmissionNode&&s.transmissionNode.isNode||s.backdropNode&&s.backdropNode.isNode,e.isShadowPassMaterial){let{colorNode:t,depthNode:r,positionNode:i}=this._getShadowNodes(s);this.shadowMap.type===u.RyA?e.side=null!==s.shadowSide?s.shadowSide:s.side:e.side=null!==s.shadowSide?s.shadowSide:bb[s.side],null!==t&&(e.colorNode=t),null!==r&&(e.depthNode=r),null!==i&&(e.positionNode=i)}s=e}!0===s.transparent&&s.side===u.$EB&&!1===s.forceSinglePass?(s.side=u.hsX,this._handleObjectFunction(e,s,t,r,n,a,o,"backSide"),s.side=u.hB5,this._handleObjectFunction(e,s,t,r,n,a,o,l),s.side=u.$EB):this._handleObjectFunction(e,s,t,r,n,a,o,l),b&&(t.overrideMaterial.colorNode=d,t.overrideMaterial.depthNode=h,t.overrideMaterial.positionNode=c,t.overrideMaterial.side=p,t.overrideMaterial.displacementMap=m,t.overrideMaterial.displacementScale=g,t.overrideMaterial.displacementBias=f),this._currentSourceMaterial=y,e.onAfterRender(this,t,r,i,s,a)}hasCompatibility(e){if(!1===this._initialized)throw Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,i,s,a,n,o){let l=this._objects.get(e,t,r,i,s,this._currentRenderContext,n,o);l.drawRange=e.geometry.drawRange,l.group=a,null!==this._currentRenderBundle&&(this.backend.get(this._currentRenderBundle).renderObjects.push(l),l.bundle=this._currentRenderBundle.bundleGroup);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),this._pipelines.isReady(l)&&(this.backend.draw(l,this.info),u&&this._nodes.updateAfter(l))}_createObjectPipeline(e,t,r,i,s,a,n,o){if(null!==this._compilationPromises)return void this._compilationPromises.push({object:e,material:t,scene:r,camera:i,lightsNode:s,group:a,clippingContext:n,passId:o,renderContext:this._currentRenderContext});let l=this._objects.get(e,t,r,i,s,this._currentRenderContext,n,o);l.drawRange=e.geometry.drawRange,l.group=a,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)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class bx{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function bT(e){return e+(16-e%16)%16}class b_ extends bx{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return bT(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}class bv extends b_{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let bS=0;class bN extends bv{constructor(e,t){super("UniformBuffer_"+bS++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return bT(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class bR extends bv{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){let t=e.index;if(this._addedIndices.has(t))return;let r=this._updateRangeCache.get(t);void 0===r&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}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,a=i.itemSize*e,n=t%16,o=n%s,l=n+o;t+=o,0!==l&&16-l<a&&(t+=16-l),i.offset=t/e,i.index=r,t+=a}return 16*Math.ceil(t/16)}update(){let e=!1;for(let t of this.uniforms)!0===this.updateByType(t)&&(e=!0);return e}release(){super.release(),this._values=null}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(0,u.z3S)("WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset,a=e.getType();return r[s]!==i&&(this._getBufferForType(a)[s]=r[s]=i,t=!0,this.addUniformUpdateRange(e)),t}updateVector2(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset,a=e.getType();if(r[s+0]!==i.x||r[s+1]!==i.y){let n=this._getBufferForType(a);n[s+0]=r[s+0]=i.x,n[s+1]=r[s+1]=i.y,t=!0,this.addUniformUpdateRange(e)}return t}updateVector3(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset,a=e.getType();if(r[s+0]!==i.x||r[s+1]!==i.y||r[s+2]!==i.z){let n=this._getBufferForType(a);n[s+0]=r[s+0]=i.x,n[s+1]=r[s+1]=i.y,n[s+2]=r[s+2]=i.z,t=!0,this.addUniformUpdateRange(e)}return t}updateVector4(e){let t=!1,r=this.values,i=e.getValue(),s=e.offset,a=e.getType();if(r[s+0]!==i.x||r[s+1]!==i.y||r[s+2]!==i.z||r[s+3]!==i.w){let n=this._getBufferForType(a);n[s+0]=r[s+0]=i.x,n[s+1]=r[s+1]=i.y,n[s+2]=r[s+2]=i.z,n[s+3]=r[s+3]=i.w,t=!0,this.addUniformUpdateRange(e)}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 a=this.buffer;a[s+0]=r[s+0]=i.r,a[s+1]=r[s+1]=i.g,a[s+2]=r[s+2]=i.b,t=!0,this.addUniformUpdateRange(e)}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
13]||r[s+8]!==i[6]||r[s+9]!==i[7]||r[s+10]!==i[8]){let a=this.buffer;a[s+0]=r[s+0]=i[0],a[s+1]=r[s+1]=i[1],a[s+2]=r[s+2]=i[2],a[s+4]=r[s+4]=i[3],a[s+5]=r[s+5]=i[4],a[s+6]=r[s+6]=i[5],a[s+8]=r[s+8]=i[6],a[s+9]=r[s+9]=i[7],a[s+10]=r[s+10]=i[8],t=!0,this.addUniformUpdateRange(e)}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,this.addUniformUpdateRange(e)),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 bA=0;class bE extends bR{constructor(e,t){super(e),this.id=bA++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class bC extends bx{constructor(e,t){super(e),this._texture=t,this.version=-1,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture=e,this.reset())}get texture(){return this._texture}update(){let{texture:e,version:t}=this;return t!==e.version&&(this.version=e.version,!0)}reset(){this.generation=null,this.version=-1}release(){this._texture=null}}let bw=0;class bM extends bC{constructor(e,t){super(e,t),this.id=bw++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}}class bB extends bM{constructor(e,t,r,i=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r,this.access=i}update(){let{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class bU extends bB{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledCubeTexture=!0}}class bF extends bB{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledTexture3D=!0}}let bL={bitcast_int_uint:new pA("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new pA("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }"),textureGather:new pA(`
14vec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset, bool flipY ) {
15	if ( flipY ) offset.y = - offset.y;
16	vec2 size = vec2( textureSize( map, 0 ) );
17	vec2 st = floor( coord * size + vec2( offset ) - 0.5 );
18	vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
19	vec4 ret = vec4(
20		textureLod( map, ij.xw, 0.0 )[ comp ],
21		textureLod( map, ij.zw, 0.0 )[ comp ],
22		textureLod( map, ij.zy, 0.0 )[ comp ],
23		textureLod( map, ij.xy, 0.0 )[ comp ]
24	);
25	return flipY ? ret.wzyx : ret;
26}
27`),textureGatherArray:new pA(`
28vec4 tsl_textureGather_array( const int comp, sampler2DArray map, vec3 coord, ivec2 offset, bool flipY ) {
29	if ( flipY ) offset.y = - offset.y;
30	vec2 size = vec2( textureSize( map, 0 ).xy );
31	vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );
32	vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
33	vec4 ret = vec4(
34		textureLod( map, vec3( ij.xw, coord.z ), 0.0 )[ comp ],
35		textureLod( map, vec3( ij.zw, coord.z ), 0.0 )[ comp ],
36		textureLod( map, vec3( ij.zy, coord.z ), 0.0 )[ comp ],
37		textureLod( map, vec3( ij.xy, coord.z ), 0.0 )[ comp ]
38	);
39	return flipY ? ret.wzyx : ret;
40}
41`),textureGatherCompare:new pA(`
42vec4 tsl_textureGatherCompare( sampler2DShadow map, vec2 coord, ivec2 offset, float ref, bool flipY ) {
43	if ( flipY ) offset.y = - offset.y;
44	vec2 size = vec2( textureSize( map, 0 ) );
45	vec2 st = floor( coord * size + vec2( offset ) - 0.5 );
46	vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
47	vec4 ret = vec4(
48		textureLod( map, vec3( ij.xw, ref ), 0.0 ),
49		textureLod( map, vec3( ij.zw, ref ), 0.0 ),
50		textureLod( map, vec3( ij.zy, ref ), 0.0 ),
51		textureLod( map, vec3( ij.xy, ref ), 0.0 )
52	);
53	return flipY ? ret.wzyx : ret;
54}
55`),textureGatherCompareArray:new pA(`
56vec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2 offset, float ref, bool flipY ) {
57	if ( flipY ) offset.y = - offset.y;
58	vec2 size = vec2( textureSize( map, 0 ).xy );
59	vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 );
60	vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy;
61	vec4 ret = vec4(
62		texture( map, vec4( ij.xw, coord.z, ref ) ),
63		texture( map, vec4( ij.zw, coord.z, ref ) ),
64		texture( map, vec4( ij.zy, coord.z, ref ) ),
65		texture( map, vec4( ij.xy, coord.z, ref ) )
66	);
67	return flipY ? ret.wzyx : ret;
68}
69`)},bP={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",bitcast_uint_int:"tsl_bitcast_uint_to_int",bitcast_int_uint:"tsl_bitcast_int_to_uint",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16"},bD={low:"lowp",medium:"mediump",high:"highp"},bO={swizzleAssign:!0,storageBuffer:!1},bI={perspective:"smooth",linear:"noperspective"},bV={centroid:"centroid"},bG=`
70precision highp float;
71precision highp int;
72precision highp sampler2D;
73precision highp sampler3D;
74precision highp samplerCube;
75precision highp sampler2DArray;
76
77precision highp usampler2D;
78precision highp usampler3D;
79precision highp usamplerCube;
80precision highp usampler2DArray;
81
82precision highp isampler2D;
83precision highp isampler3D;
84precision highp isamplerCube;
85precision highp isampler2DArray;
86
87precision highp sampler2DShadow;
88precision highp sampler2DArrayShadow;
89precision highp samplerCubeShadow;
90`;class bk extends fE{constructor(e,t){super(e,t,new fX),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==u.jf0}_include(e){let t=bL[e];return t.build(this),this.addInclude(t),t}getMethod(e){return void 0!==bL[e]&&this._include(e),bP[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`${e} ? ${t} : ${r}`}getOutputStructName(){return""}buildFunctionCode(e){let t=e.layout,r=this.flowShaderNode(e),i=[];
90for(let e of t.inputs)i.push(this.getType(e.type)+" "+e.name);return`${this.getType(t.type)} ${t.name}( ${i.join(", ")} ) {
91
92	${r.vars}
93
94${r.code}
95	return ${r.result};
96
97}`}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"),a=s?u.ZQM:u.VT0;2===i?a=s?u.TkQ:u.paN:3===i?a=s?u.VGF:u.HIg:4===i&&(a=s?u.c90:u.GWd);let n={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,a,n[t.array.constructor.name]||u.RQf);c.needsUpdate=!0,c.isPBOTexture=!0;let p=new sL(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?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),a=this.getPropertyName(s);this.increaseUsage(r);let n=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( ${a}, 0 ).x )`,e),s.propertySizeName=d);let{itemSize:h}=i,c="."+L.join("").slice(0,h),p=`ivec2(${n} % ${d}, ${n} / ${d})`,m=this.generateTextureLoad(null,a,p,"0",null,null),g="vec4";i.pbo.type===u.bkx?g="uvec4":i.pbo.type===u.Yuy&&(g="ivec4"),this.addLineFlowCode(`${l} = ${g}(${m})${c}`,e),o.propertyName=l}return l}generateTextureLoad(e,t,r,i,s,a){let n;return null===i&&(i="0"),n=s?a?`texelFetchOffset( ${t}, ivec3( ${r}, ${s} ), int( ${i} ), ${a} )`:`texelFetch( ${t}, ivec3( ${r}, ${s} ), int( ${i} ) )`:a?`texelFetchOffset( ${t}, ${r}, int( ${i} ), ${a} )`:`texelFetch( ${t}, ${r}, int( ${i} ) )`,null!==e&&e.isDepthTexture&&(n+=".x"),n}generateTexture(e,t,r,i,s){return(i&&(r=`vec3( ${r}, ${i} )`),e.isDepthTexture)?s?`textureOffset( ${t}, ${r}, ${s} ).x`:`texture( ${t}, ${r} ).x`:s?`textureOffset( ${t}, ${r}, ${s} )`:`texture( ${t}, ${r} )`}generateTextureLevel(e,t,r,i,s,a){return(s&&(r=`vec3( ${r}, ${s} )`),a)?`textureLodOffset( ${t}, ${r}, ${i}, ${a} )`:`textureLod( ${t}, ${r}, ${i} )`}generateTextureBias(e,t,r,i,s,a){return(s&&(r=`vec3( ${r}, ${s} )`),a)?`textureOffset( ${t}, ${r}, ${a}, ${i} )`:`texture( ${t}, ${r}, ${i} )`}generateTextureGrad(e,t,r,i,s,a){return(s&&(r=`vec3( ${r}, ${s} )`),a)?`textureGradOffset( ${t}, ${r}, ${i[0]}, ${i[1]}, ${a} )`:`textureGrad( ${t}, ${r}, ${i[0]}, ${i[1]} )`}generateTextureCompare(e,t,r,i,s,a,n=this.shaderStage){if("fragment"===n)return e.isCubeTexture?`texture( ${t}, vec4( ${r}, ${i} ) )`:s?a?`textureOffset( ${t}, vec4( ${r}, ${s}, ${i} ), ${a} )`:`texture( ${t}, vec4( ${r}, ${s}, ${i} ) )`:a?`textureOffset( ${t}, vec3( ${r}, ${i} ), ${a} )`:`texture( ${t}, vec3( ${r}, ${i} ) )`;(0,u.z3S)(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureGather(e,t,r,i,s,a,n){return(e.isDepthTexture&&(i="0"),null===a&&(a="ivec2( 0 )"),null===n&&(n="false"),s)?(this._include("textureGatherArray"),`tsl_textureGather_array( ${i}, ${t}, vec3( ${r}, ${s} ), ${a}, ${n} )`):(this._include("textureGather"),`tsl_textureGather( ${i}, ${t}, ${r}, ${a}, ${n} )`)}generateTextureGatherCompare(e,t,r,i,s,a,n){return(null===a&&(a="ivec2( 0 )"),null===n&&(n="false"),s)?(this._include("textureGatherCompareArray"),`tsl_textureGatherCompare_array( ${t}, vec3( ${r}, ${s} ), ${a}, ${i}, ${n} )`):(this._include("textureGatherCompare"),`tsl_textureGatherCompare( ${t}, ${r}, ${a}, ${i}, ${n} )`)}getUniforms(e){let t=this.uniforms[e],r=[],i={};for(let e of t){let t=null,s=!1;if("texture"===e.type||"texture3D"===e.type){let r=e.node,i=r.value,s="";(!0===i.isDataTexture||!0===i.isData3DTexture)&&(i.type===u.bkx?s="u":i.type===u.Yuy&&(s="i")),t="texture3D"===e.type&&!1===i.isArrayTexture?`${s}sampler3D ${e.name};`:i.compareFunction&&null!==r.compareNode?!0===i.isArrayTexture?`sampler2DArrayShadow ${e.name};`:`sampler2DShadow ${e.name};`:!0===i.isArrayTexture||!0===i.isDataArrayTexture||!0===i.isCompressedArrayTexture?`${s}sampler2DArray ${e.name};`:`${s}sampler2D ${e.name};`}else if("cubeTexture"===e.type)t=`samplerCube ${e.name};`;else if("cubeDepthTexture"===e.type)t=e.node.value.compareFunction?`samplerCubeShadow ${e.name};`:`samplerCube ${e.name};`;else if("buffer"===e.type){let r=e.node,i=this.getType(r.bufferType),s=r.bufferCount,a=s>0?s:"";t=`${r.name} {
98	${i} ${e.name}[${a}];
99};
100`}else{let t=e.groupNode.name;if(void 0===i[t]){let e=this.uniformGroups[t];if(void 0!==e){let r=[];for(let t of e.uniforms){let e=t.getType(),i=this.getVectorType(e),s=t.nodeUniform.node.precision,a=`${i} ${t.name};`;null!==s&&(a=bD[s]+" "+a),r.push("	"+a)}i[t]=r}}s=!0}
100if(!s){let i=e.node.precision;null!==i&&(t=bD[i]+" "+t),t="uniform "+t,r.push(t)}}let s="";for(let e in i){let t=i[e];s+=this._getGLSLUniformStruct(e,t.join("\n"))+"\n"}return s+r.join("\n")}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==u.Yuy){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);let i=r.array;!1==(i instanceof Uint32Array||i instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){let e=this.getAttributesArray(),r=0;for(let i of e)t+=`layout( location = ${r++} ) in ${i.type} ${i.name};
101`}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"fragment"===e&&0===i.length&&i.push(`layout( location = 0 ) out ${this.getOutputType()} 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=bI[i.interpolationType]||i.interpolationType,s=bV[i.interpolationSampling]||"";t+=`${e} ${s} out ${r} ${i.name};
102`}else{let e=r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":"";t+=`${e}out ${r} ${i.name};
103`}else t+=`${r} ${i.name};
104`}else if("fragment"===e){for(let e of r)if(e.needsInterpolation){let r=this.getType(e.type);if(e.interpolationType){let i=bI[e.interpolationType]||e.interpolationType,s=bV[e.interpolationSampling]||"";t+=`${i} ${s} in ${r} ${e.name};
105`}else{let i=r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":"";t+=`${i}in ${r} ${e.name};
106`}}}for(let r of this.builtins[e])t+=`${r};
107`;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`}getSubgroupSize(){(0,u.z3S)("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){(0,u.z3S)("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){(0,u.z3S)("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}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=bO[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)}bO[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} ]`)}
107enableMultiview(){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};
108	`)}return t}_getGLSLUniformStruct(e,t){return`
109layout( std140 ) uniform ${e} {
110${t}
111};`}_getGLSLVertexCode(e){return`#version 300 es
112
113${this.getSignature()}
114
115// extensions
116${e.extensions}
117
118// precision
119${bG}
120
121// structs
122${e.structs}
123
124// uniforms
125${e.uniforms}
126
127// varyings
128${e.varyings}
129
130// attributes
131${e.attributes}
132
133// vars
134${e.vars}
135
136// codes
137${e.codes}
138
139void main() {
140
141	// transforms
142	${e.transforms}
143
144	// flow
145	${e.flow}
146
147	gl_PointSize = 1.0;
148
149}
150`}_getGLSLFragmentCode(e){return`#version 300 es
151
152${this.getSignature()}
153
154// extensions
155${e.extensions}
156
157// precision
158${bG}
159
160// structs
161${e.structs}
162
163// uniforms
164${e.uniforms}
165
166// varyings
167${e.varyings}
168
169// vars
170${e.vars}
171
172// codes
173${e.codes}
174
175void main() {
176
177	// flow
178	${e.flow}
179
180}
181`}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),a=e.name;a&&(r.length>0&&(r+="\n"),r+=`	// flow -> ${a}
182	`),r+=`${i.code}
183	`,e===s&&"compute"!==t&&(r+="// result\n	","vertex"===t?(r+="gl_Position = ",r+=`${this.format(i.result,s.getNodeType(this),"vec4")};`):"fragment"!==t||e.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${this.format(i.result,s.getNodeType(this),this.getOutputType())};`))}let a=e[t];if(a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t,!0),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=r,"vertex"===t){let e=this.renderer.backend.extensions;this.object.isBatchedMesh&&!1===e.has("WEBGL_multi_draw")&&(a.uniforms+="\nuniform uint nodeUniformDrawId;\n")}}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),a=this.getDataFromNode(e,r,this.globalCache),n=a.uniformGPU;if(void 0===n){let i=e.groupNode,o=i.name,l=this.getBindGroupArray(o,r);if("texture"===t)n=new bB(s.name,s.node,i),l.push(n);else if("cubeTexture"===t||"cubeDepthTexture"===t)n=new bU(s.name,s.node,i),l.push(n);else if("texture3D"===t)n=new bF(s.name,s.node,i),l.push(n);else if("buffer"===t){s.name=`buffer${e.id}`;let t=this.getSharedDataFromNode(e),r=t.buffer;void 0===r&&(e.name=`NodeBuffer_${e.id}`,(r=new bN(e,i)).name=e.name,t.buffer=r),l.push(r),n=r}else{let e=this.uniformGroups[o];void 0===e?(e=new bE(o,i),this.uniformGroups[o]=e,l.push(e)):-1===l.indexOf(e)&&l.push(e);let r=(n=this.getNodeUniform(s,t)).name;e.uniforms.some(e=>e.name===r)||e.addUniform(n)}a.uniformGPU=n}return s}}let bz=null,b$=null;class bW{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[u.v9J.RENDER]:null,[u.v9J.COMPUTE]:null},this.trackTimestamp=!0===e.trackTimestamp}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){let t=this.get(e),r=this.renderer.info.frame;t.timestampUID=(!0===e.isComputeNode?"c:"+this.renderer.info.compute.frameCalls:"r:"+this.renderer.info.render.frameCalls)+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){let t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){let t=e.startsWith("c:")?u.v9J.COMPUTE:u.v9J.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}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;let r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return bz=bz||new u.I9Y,this.renderer.getDrawingBufferSize(bz)}setScissorTest(){}getClearColor(){let e=this.renderer;return b$=b$||new hN,e.getClearColor(b$),b$.getRGB(b$),b$}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}hasCompatibility(){return!1}initRenderTarget(){}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)}deleteBindGroupData(){}dispose(){}}let bH=0;class bq{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 bj{constructor(e){this.backend=e}createAttribute(e,t){let r,i=this.backend,{gl:s}=i,a=e.array,n=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,a,n),l.bufferType=t,l.version=o.version),a instanceof Float32Array)r=s.FLOAT;else if("undefined"!=typeof Float16Array&&a instanceof Float16Array)r=s.HALF_FLOAT;else if(a instanceof Uint16Array)r=e.isFloat16BufferAttribute?s.HALF_FLOAT:s.UNSIGNED_SHORT;else if(a instanceof Int16Array)r=s.SHORT;else if(a instanceof Uint32Array)r=s.UNSIGNED_INT;else if(a instanceof Int32Array)r=s.INT;else if(a instanceof Int8Array)r=s.BYTE;else if(a instanceof Uint8Array)r=s.UNSIGNED_BYTE;else if(a instanceof Uint8ClampedArray)r=s.UNSIGNED_BYTE;else throw Error("THREE.WebGLBackend: Unsupported buffer data format: "+a);let h={bufferGPU:d,bufferType:t,type:r,byteLength:a.byteLength,bytesPerElement:a.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:r===s.INT||r===s.UNSIGNED_INT||e.gpuType===u.Yuy,id:bH++};(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(h=new bq(h,this._createBuffer(s,t,a,n))),i.set(e,h)}updateAttribute(e){let t=this.backend,{gl:r}=t,i=e.array,s=e.isInterleavedBufferAttribute?e.data:e,a=t.get(s),n=a.bufferType,o=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(n,a.bufferGPU),0===o.length)r.bufferSubData(n,0,i);else{for(let e=0,t=o.length;e<t;
183e++){let t=o[e];r.bufferSubData(n,t.start*i.BYTES_PER_ELEMENT,i,t.start,t.count)}s.clearUpdateRanges()}r.bindBuffer(n,null),a.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,t=null,r=0,i=-1){let s,a=this.backend,{gl:n}=a,o=e.isInterleavedBufferAttribute?e.data:e,l=a.get(o),{bufferGPU:u}=l,d=-1===i?l.byteLength-r:i;if(null===t)s=new Uint8Array(new ArrayBuffer(d));else if(t.isReadbackBuffer){if(!0===t._mapped)throw Error("THREE.WebGPURenderer: ReadbackBuffer must be released before being used again.");let e=()=>{t.buffer=null,t._mapped=!1,t.removeEventListener("release",e),t.removeEventListener("dispose",e)};t.addEventListener("release",e),t.addEventListener("dispose",e),t.buffer=(s=new Uint8Array(new ArrayBuffer(d))).buffer}else s=new Uint8Array(t);return(n.bindBuffer(n.COPY_READ_BUFFER,u),n.getBufferSubData(n.COPY_READ_BUFFER,r,s),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer)?t:s.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 bX{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},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.currentDepthReversed=!1,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)}setMRTBlending(e,t,r){let i=this.gl,s=this.backend.drawBuffersIndexedExt;if(!s)return void(0,u.mcG)("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.");for(let a=0;a<e.length;a++){let n=e[a],o=null;if(null!==t){let e=t.getBlendMode(n.name);e.blending===u.pCc?o=r:e.blending!==u.XIg&&(o=e)}else o=r;null!==o?this._setMRTBlendingIndex(a,o):s.blendFuncSeparateiOES(a,i.ONE,i.ZERO,i.ONE,i.ZERO)}}_setMRTBlendingIndex(e,t){let{gl:r}=this,i=this.backend.drawBuffersIndexedExt,s=t.blending,a=t.blendSrc,n=t.blendDst,d=t.blendEquation,h=t.premultipliedAlpha;if(s===u.bCz){let r=null!==t.blendSrcAlpha?t.blendSrcAlpha:a,s=null!==t.blendDstAlpha?t.blendDstAlpha:n,u=null!==t.blendEquationAlpha?t.blendEquationAlpha:d;i.blendEquationSeparateiOES(e,o[d],o[u]),i.blendFuncSeparateiOES(e,l[a],l[n],l[r],l[s])}else if(i.blendEquationSeparateiOES(e,r.FUNC_ADD,r.FUNC_ADD),h)switch(s){case u.NTi:i.blendFuncSeparateiOES(e,r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case u.EZo:i.blendFuncSeparateiOES(e,r.ONE,r.ONE,r.ONE,r.ONE);break;case u.Kwu:i.blendFuncSeparateiOES(e,r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case u.EdD:i.blendFuncSeparateiOES(e,r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:i.blendFuncSeparateiOES(e,r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA)}else switch(s){case u.NTi:i.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case u.EZo:i.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case u.Kwu:i.blendFuncSeparateiOES(e,r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case u.EdD:i.blendFuncSeparateiOES(e,r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:i.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA)}}setBlending(e,t,r,i,s,a,n,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:(0,u.z3S)("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:(0,u.z3S)("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case u.EdD:(0,u.z3S)("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:(0,u.z3S)("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,a=a||r,n=n||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||a!==this.currentBlendSrcAlpha||n!==this.currentBlendDstAlpha)&&(h.blendFuncSeparate(l[r],l[i],l[a],l[n]),this.currentBlendSrc=r,this.currentBlendDst=i,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=n),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)}setReversedDepth(e){if(this.currentDepthReversed!==e){let t=this.backend.extensions.get("EXT_clip_control");e?t.clipControlEXT(t.LOWER_LEFT_EXT,t.ZERO_TO_ONE_EXT):t.clipControlEXT(t.LOWER_LEFT_EXT,t.NEGATIVE_ONE_TO_ONE_EXT),this.currentDepthReversed=e}}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthReversed&&(e=u.ri6[e]),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}}
183scissor(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?this.enable(t.SCISSOR_TEST):this.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 a=e.stencilWrite;if(this.setStencilTest(a),a&&(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.currentSamples>0?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 a=e.textures;if(i.length!==a.length||i[0]!==r.COLOR_ATTACHMENT0){for(let e=0,t=a.length;e<t;e++)i[e]=r.COLOR_ATTACHMENT0+e;i.length=a.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:a,maxTextures:n}=this;void 0===r&&(r=null===s?i.TEXTURE0+n-1:s);let o=a[r];void 0===o&&(o={type:void 0,texture:void 0},a[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)}getParameter(e){let{gl:t,parameters:r}=this;return void 0!==r[e]?r[e]:t.getParameter(e)}pixelStorei(e,t){let{gl:r,parameters:i}=this;i[e]!==t&&(r.pixelStorei(e,t),i[e]=t)}}class bQ{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,a=u.ppV.getTransfer(t);if(e===u.OUM)return i.UNSIGNED_BYTE;if(e===u.Wew)return i.UNSIGNED_SHORT_4_4_4_4;if(e===u.gJ2)return i.UNSIGNED_SHORT_5_5_5_1;if(e===u.Dmk)return i.UNSIGNED_INT_5_9_9_9_REV;if(e===u.yT7)return i.UNSIGNED_INT_10F_11F_11F_REV;if(e===u.tJf)return i.BYTE;if(e===u.fBL)return i.SHORT;if(e===u.cHt)return i.UNSIGNED_SHORT;if(e===u.Yuy)return i.INT;if(e===u.bkx)return i.UNSIGNED_INT;if(e===u.RQf)return i.FLOAT;if(e===u.ix0)return i.HALF_FLOAT;if(e===u.wrO)return i.ALPHA;if(e===u.HIg)return i.RGB;if(e===u.GWd)return i.RGBA;if(e===u.zdS)return i.DEPTH_COMPONENT;if(e===u.dcC)return i.DEPTH_STENCIL;if(e===u.VT0)return i.RED;if(e===u.ZQM)return i.RED_INTEGER;if(e===u.paN)return i.RG;if(e===u.TkQ)return i.RG_INTEGER;if(e===u.c90)return i.RGBA_INTEGER;if(e===u.IE4||e===u.Nz6||e===u.jR7||e===u.BXX)if(a===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||e===u.BVL||e===u.gZr||e===u.OtU||e===u.jSS){if(null===(r=s.get("WEBGL_compressed_texture_etc")))return null;if(e===u.CVz||e===u.Riy)return a===u.KLL?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(e===u.KDk)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;
183if(e===u.BVL)return r.COMPRESSED_R11_EAC;if(e===u.gZr)return r.COMPRESSED_SIGNED_R11_EAC;if(e===u.OtU)return r.COMPRESSED_RG11_EAC;if(e===u.jSS)return r.COMPRESSED_SIGNED_RG11_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 a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===u.B_h)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===u.czI)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===u.rSH)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===u.Qrf)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===u.psI)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===u.a5J)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===u._QJ)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===u.uB5)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===u.lyL)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===u.bC7)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===u.y3Z)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===u.ojs)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===u.S$4)return a===u.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(e===u.Fn||e===u.H23||e===u.W9U){if(null===(r=s.get("EXT_texture_compression_bptc")))return null;if(e===u.Fn)return a===u.KLL?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(e===u.H23)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(e===u.W9U)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_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;if(e===u.Kef)return r.COMPRESSED_RED_RGTC1_EXT;if(e===u.XG_)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===u.HO_)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===u.CWW)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return e===u.V3x?i.UNSIGNED_INT_24_8:void 0!==i[e]?i[e]:null}_clientWaitAsync(){let{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((r,i)=>{!function s(){let a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),i();return}if(a===e.TIMEOUT_EXPIRED)return void requestAnimationFrame(s);e.deleteSync(t),r()}()})}}let bK=!1,bY,bZ,bJ;class b0{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,!1===bK&&(this._init(),bK=!0)}_init(){let e=this.gl;bY={[u.GJx]:e.REPEAT,[u.ghU]:e.CLAMP_TO_EDGE,[u.kTW]:e.MIRRORED_REPEAT},bZ={[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},bJ={[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,a=!1){let{gl:n,extensions:o}=this;if(null!==e){if(void 0!==n[e])return n[e];(0,u.R8M)("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let l=null;i&&((l=o.get("EXT_texture_norm16"))||(0,u.R8M)("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let d=t;if(t===n.RED&&(r===n.FLOAT&&(d=n.R32F),r===n.HALF_FLOAT&&(d=n.R16F),r===n.UNSIGNED_BYTE&&(d=n.R8),r===n.BYTE&&(d=n.R8_SNORM),r===n.UNSIGNED_SHORT&&l&&(d=l.R16_EXT),r===n.SHORT&&l&&(d=l.R16_SNORM_EXT)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(d=n.R8UI),r===n.UNSIGNED_SHORT&&(d=n.R16UI),r===n.UNSIGNED_INT&&(d=n.R32UI),r===n.BYTE&&(d=n.R8I),r===n.SHORT&&(d=n.R16I),r===n.INT&&(d=n.R32I)),t===n.RG&&(r===n.FLOAT&&(d=n.RG32F),r===n.HALF_FLOAT&&(d=n.RG16F),r===n.UNSIGNED_BYTE&&(d=n.RG8),r===n.BYTE&&(d=n.RG8_SNORM),r===n.UNSIGNED_SHORT&&l&&(d=l.RG16_EXT),r===n.SHORT&&l&&(d=l.RG16_SNORM_EXT)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(d=n.RG8UI),r===n.UNSIGNED_SHORT&&(d=n.RG16UI),r
183===n.UNSIGNED_INT&&(d=n.RG32UI),r===n.BYTE&&(d=n.RG8I),r===n.SHORT&&(d=n.RG16I),r===n.INT&&(d=n.RG32I)),t===n.RGB){let e=a?u.VxR:u.ppV.getTransfer(s);r===n.FLOAT&&(d=n.RGB32F),r===n.HALF_FLOAT&&(d=n.RGB16F),r===n.UNSIGNED_BYTE&&(d=e===u.KLL?n.SRGB8:n.RGB8),r===n.BYTE&&(d=n.RGB8_SNORM),r===n.UNSIGNED_SHORT&&l&&(d=l.RGB16_EXT),r===n.SHORT&&l&&(d=l.RGB16_SNORM_EXT),r===n.UNSIGNED_SHORT_5_6_5&&(d=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(d=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(d=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(d=n.RGB9_E5),r===n.UNSIGNED_INT_10F_11F_11F_REV&&(d=n.R11F_G11F_B10F)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(d=n.RGB8UI),r===n.UNSIGNED_SHORT&&(d=n.RGB16UI),r===n.UNSIGNED_INT&&(d=n.RGB32UI),r===n.BYTE&&(d=n.RGB8I),r===n.SHORT&&(d=n.RGB16I),r===n.INT&&(d=n.RGB32I)),t===n.RGBA){let e=a?u.VxR:u.ppV.getTransfer(s);r===n.FLOAT&&(d=n.RGBA32F),r===n.HALF_FLOAT&&(d=n.RGBA16F),r===n.UNSIGNED_BYTE&&(d=e===u.KLL?n.SRGB8_ALPHA8:n.RGBA8),r===n.BYTE&&(d=n.RGBA8_SNORM),r===n.UNSIGNED_SHORT&&l&&(d=l.RGBA16_EXT),r===n.SHORT&&l&&(d=l.RGBA16_SNORM_EXT),r===n.UNSIGNED_SHORT_4_4_4_4&&(d=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(d=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(d=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(d=n.RGBA16UI),r===n.UNSIGNED_INT&&(d=n.RGBA32UI),r===n.BYTE&&(d=n.RGBA8I),r===n.SHORT&&(d=n.RGBA16I),r===n.INT&&(d=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(d=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(d=n.DEPTH_COMPONENT24),r===n.FLOAT&&(d=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(d=n.DEPTH24_STENCIL8),(d===n.R16F||d===n.R32F||d===n.RG16F||d===n.RG32F||d===n.RGBA16F||d===n.RGBA32F)&&o.get("EXT_color_buffer_float"),d}setTextureParameters(e,t){let{gl:r,extensions:i,backend:s}=this,{state:a}=this.backend,n=u.ppV.getPrimaries(u.ppV.workingColorSpace),o=t.colorSpace===u.jf0?null:u.ppV.getPrimaries(t.colorSpace),l=t.colorSpace===u.jf0||n===o?r.NONE:r.BROWSER_DEFAULT_WEBGL;a.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),a.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,l),r.texParameteri(e,r.TEXTURE_WRAP_S,bY[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,bY[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,bY[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,bZ[t.magFilter]);let d=void 0!==t.mipmaps&&t.mipmaps.length>0,h=t.minFilter===u.k6q&&d?u.$_I:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,bZ[h]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,bJ[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 a=i.get("EXT_texture_filter_anisotropic");r.texParameterf(e,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){let{gl:t,backend:r,defaultTextures:i}=this,s=this.getGLTextureType(e),a=i[s];void 0===a&&(a=t.createTexture(),r.state.bindTexture(s,a),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),i[s]=a),r.set(e,{textureGPU:a,glTextureType:s})}createTexture(e,t){let r,i,s,a,n,{gl:o,backend:l}=this;if(!0===e.isExternalTexture)r=e.sourceTexture,i=this.getGLTextureType(e);else{let{levels:u,width:d,height:h,depth:c}=t;s=l.utils.convert(e.format,e.colorSpace),a=l.utils.convert(e.type),n=this.getInternalFormat(e.internalFormat,s,a,e.normalized,e.colorSpace,e.isVideoTexture),r=o.createTexture(),i=this.getGLTextureType(e),l.state.bindTexture(i,r),this.setTextureParameters(i,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?o.texStorage3D(o.TEXTURE_2D_ARRAY,u,n,d,h,c):e.isData3DTexture?o.texStorage3D(o.TEXTURE_3D,u,n,d,h,c):e.isVideoTexture||o.texStorage2D(i,u,n,d,h)}l.set(e,{textureGPU:r,glTextureType:i,glFormat:s,glType:a,glInternalFormat:n})}copyBufferToTexture(e,t){let{gl:r,backend:i}=this,{state:s}=i,{textureGPU:a,glTextureType:n,glFormat:o,glType:l}=i.get(t),{width:u,height:d}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),i.state.bindTexture(n,a),s.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(n,0,0,0,u,d,o,l,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),i.state.unbindTexture()}updateTexture(e,t){let{gl:r}=this,{width:i,height:s}=t,{textureGPU:a,glTextureType:n,glFormat:o,glType:l,glInternalFormat:d}=this.backend.get(e);if(!e.isRenderTargetTexture&&void 0!==a)if(this.backend.state.bindTexture(n,a),this.setTextureParameters(n,e),e.isCompressedTexture){let i=e.mipmaps,s=t.image;for(let t=0;t<i.length;t++){let a=i[t];e.isCompressedArrayTexture?e.format!==r.RGBA?null!==o?r.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,s.depth,o,a.data):(0,u.R8M)("WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texSubImage3D(r.TEXTURE_2D_ARRAY,t,0,0,0,a.width,a.height,s.depth,o,l,a.data):null!==o?r.compressedTexSubImage2D(r.TEXTURE_2D,t,0,0,a.width,a.height,o,a.data):(0,u.R8M)("WebGLBackend: Unsupported compressed texture format")}}else if(e.isCubeTexture){let a=t.images,n=e.mipmaps;for(let e=0;e<6;e++){let t=b1(a[e]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,0,0,i,s,o,l,t);for(let t=0;t<n.length;t++){let i=b1(n[t].images[e]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,t+1,0,0,i.width,i.height,o,l,i)}}}else if(e.isDataArrayTexture||e.isArrayTexture){let i=t.image;if(e.layerUpdates.size>0){let t=(0,u.Nex)(i.width,i.height,e.format,e.type);for(let s of e.layerUpdates){let e=i.data.subarray(s*t/i.data.BYTES_PER_ELEMENT,(s+1)*t/i.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,s,i.width,i.height,1,o,l,e)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,i.width,i.height,i.depth,o,l,i.data)}else if(e.isData3DTexture){let e=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,e.width,e.height,e.depth,o,l,e.data)}
vendor: 8,046 bytes, line 183
183else if(e.isVideoTexture)e.update(),r.texImage2D(n,0,d,o,l,t.image);else if(e.isHTMLTexture)"function"==typeof r.texElementImage2D&&(3===r.texElementImage2D.length?r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,t.image):r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image));else{let a=e.mipmaps;if(a.length>0)for(let e=0,t=a.length;e<t;e++){let t=a[e],i=b1(t);r.texSubImage2D(n,e,0,0,t.width,t.height,o,l,i)}else{let e=b1(t.image);r.texSubImage2D(n,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,t=!1){let{gl:r,backend:i}=this,{textureGPU:s,renderTarget:a}=i.get(e);this.deallocateRenderBuffers(a),!1===t&&!0!==e.isExternalTexture&&r.deleteTexture(s),i.delete(e)}copyTextureToTexture(e,t,r=null,i=null,s=0,a=0){let n,o,l,u,d,h,c,p,m,{gl:g,backend:f}=this,{state:b}=this.backend,{textureGPU:y,glTextureType:x,glType:T,glFormat:_}=f.get(t);b.bindTexture(x,y);let v=e.isCompressedTexture?e.mipmaps[a]:e.image;if(null!==r)n=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);n=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,m=i.z):(c=0,p=0,m=0),b.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,t.flipY),b.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),b.pixelStorei(g.UNPACK_ALIGNMENT,t.unpackAlignment);let S=b.getParameter(g.UNPACK_ROW_LENGTH),N=b.getParameter(g.UNPACK_IMAGE_HEIGHT),R=b.getParameter(g.UNPACK_SKIP_PIXELS),A=b.getParameter(g.UNPACK_SKIP_ROWS),E=b.getParameter(g.UNPACK_SKIP_IMAGES);b.pixelStorei(g.UNPACK_ROW_LENGTH,v.width),b.pixelStorei(g.UNPACK_IMAGE_HEIGHT,v.height),b.pixelStorei(g.UNPACK_SKIP_PIXELS,u),b.pixelStorei(g.UNPACK_SKIP_ROWS,d),b.pixelStorei(g.UNPACK_SKIP_IMAGES,h);let C=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,w=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){let r=f.get(e),i=f.get(t),x=f.get(r.renderTarget),T=f.get(i.renderTarget),_=x.framebuffers[r.cacheKey],v=T.framebuffers[i.cacheKey],S=b.currentBoundFramebuffers[g.READ_FRAMEBUFFER]??null,N=b.currentBoundFramebuffers[g.DRAW_FRAMEBUFFER]??null;b.bindFramebuffer(g.READ_FRAMEBUFFER,_),b.bindFramebuffer(g.DRAW_FRAMEBUFFER,v);for(let e=0;e<l;e++)C&&(g.framebufferTextureLayer(g.READ_FRAMEBUFFER,g.COLOR_ATTACHMENT0,r.textureGPU,s,h+e),g.framebufferTextureLayer(g.DRAW_FRAMEBUFFER,g.COLOR_ATTACHMENT0,y,a,m+e)),g.blitFramebuffer(u,d,n,o,c,p,n,o,g.DEPTH_BUFFER_BIT,g.NEAREST);b.bindFramebuffer(g.READ_FRAMEBUFFER,S),b.bindFramebuffer(g.DRAW_FRAMEBUFFER,N)}else if(0!==s||e.isRenderTargetTexture||f.has(e)){let t=f.get(e);null===this._srcFramebuffer&&(this._srcFramebuffer=g.createFramebuffer()),null===this._dstFramebuffer&&(this._dstFramebuffer=g.createFramebuffer());let r=b.currentBoundFramebuffers[g.READ_FRAMEBUFFER]??null,i=b.currentBoundFramebuffers[g.DRAW_FRAMEBUFFER]??null;b.bindFramebuffer(g.READ_FRAMEBUFFER,this._srcFramebuffer),b.bindFramebuffer(g.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let e=0;e<l;e++)C?g.framebufferTextureLayer(g.READ_FRAMEBUFFER,g.COLOR_ATTACHMENT0,t.textureGPU,s,h+e):g.framebufferTexture2D(g.READ_FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,t.textureGPU,s),w?g.framebufferTextureLayer(g.DRAW_FRAMEBUFFER,g.COLOR_ATTACHMENT0,y,a,m+e):g.framebufferTexture2D(g.DRAW_FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,y,a),0!==s?g.blitFramebuffer(u,d,n,o,c,p,n,o,g.COLOR_BUFFER_BIT,g.NEAREST):w?g.copyTexSubImage3D(x,a,c,p,m+e,u,d,n,o):g.copyTexSubImage2D(x,a,c,p,u,d,n,o);b.bindFramebuffer(g.READ_FRAMEBUFFER,r),b.bindFramebuffer(g.DRAW_FRAMEBUFFER,i)}else w?e.isDataTexture||e.isData3DTexture?g.texSubImage3D(x,a,c,p,m,n,o,l,_,T,v.data):t.isCompressedArrayTexture?g.compressedTexSubImage3D(x,a,c,p,m,n,o,l,_,v.data):g.texSubImage3D(x,a,c,p,m,n,o,l,_,T,v):e.isDataTexture?g.texSubImage2D(g.TEXTURE_2D,a,c,p,n,o,_,T,v.data):e.isCompressedTexture?g.compressedTexSubImage2D(g.TEXTURE_2D,a,c,p,v.width,v.height,_,v.data):g.texSubImage2D(g.TEXTURE_2D,a,c,p,n,o,_,T,v);b.pixelStorei(g.UNPACK_ROW_LENGTH,S),b.pixelStorei(g.UNPACK_IMAGE_HEIGHT,N),b.pixelStorei(g.UNPACK_SKIP_PIXELS,R),b.pixelStorei(g.UNPACK_SKIP_ROWS,A),b.pixelStorei(g.UNPACK_SKIP_IMAGES,E),0===a&&t.generateMipmaps&&g.generateMipmap(x),b.unbindTexture()}copyFramebufferToTexture(e,t,r){let{gl:i}=this,{state:s}=this.backend,{textureGPU:a}=this.backend.get(e),{x:n,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!==n||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(n,p,n+l,p+u,n,p,n+l,p+u,r,i.NEAREST),s.bindFramebuffer(i.READ_FRAMEBUFFER,d),s.bindTexture(i.TEXTURE_2D,a),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,n,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,a,0),i.blitFramebuffer(0,0,l,u,0,0,l,u,r,i.NEAREST),i.deleteFramebuffer(e)}}else s.bindTexture(i.TEXTURE_2D,a),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,n,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,a=t.renderTarget,{depthTexture:n,depthBuffer:o,stencilBuffer:l,width:u,height:d}=a;if(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,a.samples,t,u,d):r>0?(n&&n.isDepthTexture&&n.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,a){let{backend:n,gl:o}=this,{textureGPU:l,glFormat:u,glType:d}=this.backend.get(e),h=o.createFramebuffer();n.state.bindFramebuffer(o.READ_FRAMEBUFFER,h);let c=e.isCubeTexture?o.TEXTURE_CUBE_MAP_POSITIVE_X+a:o.TEXTURE_2D;o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,l,0);let p=this._getTypedArrayType(d),m=i*s*this._getBytesPerTexel(d,u),g=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,g),o.bufferData(o.PIXEL_PACK_BUFFER,m,o.STREAM_READ),o.readPixels(t,r,i,s,u,d,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await n.utils._clientWaitAsync();let f=new p(m/p.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,g),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,f),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),n.state.bindFramebuffer(o.READ_FRAMEBUFFER,null),o.deleteFramebuffer(h),f}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;
183if(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(`THREE.WebGLTextureUtils: 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}dispose(){let{gl:e}=this;null!==this._srcFramebuffer&&e.deleteFramebuffer(this._srcFramebuffer),null!==this._dstFramebuffer&&e.deleteFramebuffer(this._dstFramebuffer)}}function b1(e){return e.isDataTexture?e.image.data:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas?e:e.data}class b2{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 b3{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=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}getUniformBufferLimit(){if(null!==this.maxUniformBlockSize)return this.maxUniformBlockSize;let e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}let b4={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",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class b5{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:a,info:n,index:o}=this;0!==o?r.drawElements(i,t,a,e):r.drawArrays(i,e,t),n.update(s,t,1)}renderInstances(e,t,r){let{gl:i,mode:s,type:a,index:n,object:o,info:l}=this;0!==r&&(0!==n?i.drawElementsInstanced(s,t,a,e,r):i.drawArraysInstanced(s,e,t,r),l.update(o,t,r))}renderMultiDraw(e,t,r){let{extensions:i,mode:s,object:a,info:n}=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];n.update(a,i,1)}}}class b6{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return void 0===t&&((0,u.R8M)(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestampQuery(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}}class b8 extends b6{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){(0,u.R8M)("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)(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(null==t||null!==this.activeQuery)return;let r=this.queries[t];
183if(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){(0,u.z3S)("Error in beginQuery:",e),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;let t=this.queryOffsets.get(e);if(null!=t&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(e){(0,u.z3S)("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=new Map;for(let[t,r]of this.queryOffsets){let i=this.queryStates.get(r);if("ended"===i){let i=this.queries[r];e.set(t,this.resolveQuery(i))}}if(0===e.size)return this.lastValue;let t={},r=[];for(let[i,s]of e){let e=i.match(/^(.*):f(\d+)$/),a=parseInt(e[2]);!1===r.includes(a)&&r.push(a),void 0===t[a]&&(t[a]=0);let n=await s;this.timestamps.set(i,n),t[a]+=n}let i=t[r[r.length-1]];return this.lastValue=i,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,i}catch(e){return(0,u.z3S)("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))},a=()=>{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(a,1);return}let i=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(i)/1e6)}catch(e){(0,u.z3S)("Error checking query:",e),t(this.lastValue)}};a()})}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 b9 extends bW{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);let t=this.parameters,r={antialias:e.currentSamples>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 b2(this),this.capabilities=new b3(this),this.attributeUtils=new bj(this),this.textureUtils=new b0(this),this.bufferRenderer=new b5(this),this.state=new bX(this),this.utils=new bQ(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.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:((0,u.R8M)("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return u.TdN}get hasTimestamp(){return null!==this.disjoint}async getArrayBufferAsync(e,t=null,r=0,i=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,i)}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&&(0,u.R8M)("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new b8(this.gl,e,2048));let r=this.timestampQueryPool[e];null!==r.allocateQueriesForContext(t)&&r.beginQuery(t)}prepareTimestampBuffer(e,t){this.disjoint&&this.trackTimestamp&&this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){let{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{let{width:e,height:r}=this.getDrawingBufferSize();t.viewport(0,0,e,r)}if(e.scissor)this.updateScissor(e);else{let{width:e,height:r}=this.getDrawingBufferSize();t.scissor(0,0,e,r)}this.initTimestampQuery(u.v9J.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);let i=e.occlusionQueryCount;i>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=Array(i),r.occlusionQueryObjects=Array(i),r.occlusionQueryIndex=0)}finishRender(e){let{gl:t,state:r}=this,i=this.get(e),s=i.previousContext;r.resetVertexState();let a=e.occlusionQueryCount;a>0&&(a>i.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));let n=e.textures;if(null!==n)for(let e=0;e<n.length;e++){let t=n[e];t.generateMipmaps&&this.generateMipmaps(t)}if(this._currentContext=s,this._resolveRenderTarget(e),null!==s){if(this._setFramebuffer(s),s.viewport)this.updateViewport(s);else{let{width:e,height:t}=this.getDrawingBufferSize();r.viewport(0,0,e,t)}if(s.scissor)this.updateScissor(s);else{let{width:e,height:t}=this.getDrawingBufferSize();r.scissor(0,0,e,t)}}this.prepareTimestampBuffer(u.v9J.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){let t=this.get(e),{currentOcclusionQueries:r,currentOcclusionQueryObjects:i}=t;if(r&&i){let e=new WeakSet,{gl:s}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;let a=()=>{let n=0;for(let t=0;t<r.length;t++){let a=r[t];null!==a&&s.getQueryParameter(a,s.QUERY_RESULT_AVAILABLE)&&(0===s.getQueryParameter(a,s.QUERY_RESULT)&&e.add(i[t]),r[t]=null,s.deleteQuery(a),n++)}n<r.length?requestAnimationFrame(a):t.occluded=e};a()}}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:a}=e.viewportValue;t.viewport(r,e.height-a-i,s,a)}updateScissor(e){let{state:t}=this,{x:r,y:i,width:s,height:a}=e.scissorValue;t.scissor(r,e.height-a-i,s,a)}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}
183clear(e,t,r,i=null,s=!0,a=!0){let{gl:n,renderer:o}=this;null===i&&(i={textures:null,clearColorValue:this.getClearColor()});let l=0;if(e&&(l|=n.COLOR_BUFFER_BIT),t&&(l|=n.DEPTH_BUFFER_BIT),r&&(l|=n.STENCIL_BUFFER_BIT),0!==l){let u;u=i.clearColorValue?i.clearColorValue:this.getClearColor();let d=o.getClearDepth(),h=o.getClearStencil();if(t&&this.state.setDepthMask(!0),null===i.textures)n.clearColor(u.r,u.g,u.b,u.a),n.clear(l);else{if(s&&this._setFramebuffer(i),e)for(let e=0;e<i.textures.length;e++)0===e?n.clearBufferfv(n.COLOR,e,[u.r,u.g,u.b,u.a]):n.clearBufferfv(n.COLOR,e,[0,0,0,1]);t&&r?n.clearBufferfi(n.DEPTH_STENCIL,0,d,h):t?n.clearBufferfv(n.DEPTH,0,[d]):r&&n.clearBufferiv(n.STENCIL,0,[h]),s&&a&&this._resolveRenderTarget(i),s&&null!==this._currentContext&&this._currentContext!==i&&this._setFramebuffer(this._currentContext)}}}beginCompute(e){let{state:t,gl:r}=this;t.bindFramebuffer(r.FRAMEBUFFER,null),this.initTimestampQuery(u.v9J.COMPUTE,this.getTimestampUID(e))}compute(e,t,r,i,s=null){let{state:a,gl:n}=this;!1===this.discard&&(a.enable(n.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):a.setVertexState(c),a.useProgram(o),this._bindUniforms(r);let p=this._getTransformFeedback(l);n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,p),n.beginTransformFeedback(n.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]):s&&"object"==typeof s&&s.isIndirectStorageBufferAttribute&&((0,u.mcG)("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),s=t.count),d[0].isStorageInstancedBufferAttribute?n.drawArraysInstanced(n.POINTS,0,1,s):n.drawArrays(n.POINTS,0,s),n.endTransformFeedback(),n.bindTransformFeedback(n.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{state:t,gl:r}=this;this.discard=!1,t.disable(r.RASTERIZER_DISCARD),this.prepareTimestampBuffer(u.v9J.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}_draw(e,t,r,i,s,a){if(e.isBatchedMesh)if(!1===this.hasFeature("WEBGL_multi_draw")){let{gl:r}=this,i=r.getUniformLocation(a,"nodeUniformDrawId"),s=e._multiDrawStarts,n=e._multiDrawCounts,o=e._multiDrawCount;for(let e=0;e<o;e++)r.uniform1ui(i,e),t.render(s[e],n[e])}else t.renderMultiDraw(e._multiDrawStarts,e._multiDrawCounts,e._multiDrawCount);else s>1?t.renderInstances(r,i,s):t.render(r,i)}draw(e){let{object:t,pipeline:r,material:i,context:s,hardwareClippingPlanes:a}=e,{programGPU:n}=this.get(r),{gl:o,state:l}=this,u=this.get(s),d=e.getDrawParameters();if(null===d)return;this._bindUniforms(e.getBindings());let h=t.isMesh&&0>t.matrixWorld.determinantAffine();l.setMaterial(i,h,a),null!==s.mrt&&null!==s.textures&&l.setMRTBlending(s.textures,s.mrt,i),l.useProgram(n);let c=e.getAttributes(),p=this.get(c),m=p.vaoGPU;if(void 0===m){let e=this._getVaoKey(c);void 0===(m=this.vaoCache[e])&&(m=this._createVao(c),this.vaoCache[e]=m,p.vaoGPU=m)}let g=e.getIndex(),f=null!==g?this.get(g).bufferGPU:null;l.setVertexState(m,f);let b=u.lastOcclusionObject;if(b!==t&&void 0!==b){if(null!==b&&!0===b.occlusionTest&&(o.endQuery(o.ANY_SAMPLES_PASSED),u.occlusionQueryIndex++),!0===t.occlusionTest){let e=o.createQuery();o.beginQuery(o.ANY_SAMPLES_PASSED,e),u.occlusionQueries[u.occlusionQueryIndex]=e,u.occlusionQueryObjects[u.occlusionQueryIndex]=t}u.lastOcclusionObject=t}let y=this.bufferRenderer;t.isPoints?y.mode=o.POINTS:t.isLineSegments?y.mode=o.LINES:t.isLine?y.mode=o.LINE_STRIP:t.isLineLoop?y.mode=o.LINE_LOOP:!0===i.wireframe?(l.setLineWidth(i.wireframeLinewidth*this.renderer.getPixelRatio()),y.mode=o.LINES):y.mode=o.TRIANGLES;let{vertexCount:x,instanceCount:T}=d,{firstVertex:_}=d;if(y.object=t,null!==g){_*=g.array.BYTES_PER_ELEMENT;let e=this.get(g);y.index=g.count,y.type=e.type}else y.index=0;
vendor: 12,475 bytes, line 183
183if(!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 a=0;e:for(let t of e.getBindings())for(let e of t.bindings){if(e===s)break e;(e.isUniformsGroup||e.isUniformBuffer)&&a++}let u=this.renderer.getPixelRatio(),d=this._currentContext.renderTarget,h=this._isRenderCameraDepthArray(this._currentContext),c=this._currentContext.activeCubeFace;if(h){let e=this.get(d.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:t}=d;for(let e=0,r=i.length;e<r;e++)this.renderer._activeCubeFace=e,this._currentContext.activeCubeFace=e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,t,this._currentContext,!1,!1);this.renderer._activeCubeFace=c,this._currentContext.activeCubeFace=c}}for(let s=0,d=i.length;s<d;s++){let d=i[s];if(t.layers.test(d.layers)){h&&(this.renderer._activeCubeFace=s,this._currentContext.activeCubeFace=s,this._setFramebuffer(this._currentContext));let i=d.viewport;if(void 0!==i){let t=i.x*u,r=i.y*u,s=i.width*u,a=i.height*u;l.viewport(Math.floor(t),Math.floor(e.context.height-a-r),Math.floor(s),Math.floor(a))}l.bindBufferBase(o.UNIFORM_BUFFER,a,r.indexesGPU[s]),this._draw(t,y,_,x,T,n)}this._currentContext.activeCubeFace=c,this.renderer._activeCubeFace=c}}else this._draw(t,y,_,x,T,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,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,r,i,s,a){return this.textureUtils.copyTextureToBuffer(e,t,r,i,s,a)}updateSampler(){return""}createNodeBuilder(e,t){return new bk(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:a}=i,n=r.createProgram(),o=this.get(s).shaderGPU,l=this.get(a).shaderGPU;if(r.attachShader(n,o),r.attachShader(n,l),r.linkProgram(n),this.set(i,{programGPU:n,fragmentShader:o,vertexShader:l}),null!==t&&this.parallel){let s=new Promise(t=>{let s=this.parallel,a=()=>{r.getProgramParameter(n,s.COMPLETION_STATUS_KHR)?(this._completeCompile(e,i),t()):requestAnimationFrame(a)};a()});t.push(s);return}this._completeCompile(e,i)}_handleSource(e,t){let r=e.split("\n"),i=[],s=Math.max(t-6,0),a=Math.min(t+6,r.length);for(let e=s;e<a;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 a=/ERROR: 0:(\d+)/.exec(s);if(!a)return s;{let i=parseInt(a[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 a=this._getShaderErrors(i,r,"vertex"),n=this._getShaderErrors(i,t,"fragment");(0,u.z3S)("WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(e,i.VALIDATE_STATUS)+"\n\nProgram Info Log: "+s+"\n"+a+"\n"+n)}else""!==s&&(0,u.R8M)("WebGLProgram: Program Info Log:",s)}}_completeCompile(e,t){let{state:r,gl:i}=this,{programGPU:s,fragmentShader:a,vertexShader:n}=this.get(t);!1===i.getProgramParameter(s,i.LINK_STATUS)&&this._logProgramError(s,a,n),r.useProgram(s);let o=e.getBindings();this._setupBindings(o,s),this.set(t,{programGPU:s,pipeline: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:a}=e,n=i.createProgram(),o=this.get(s).shaderGPU,l=this.get(a).shaderGPU,u=a.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(n,o),i.attachShader(n,l),i.transformFeedbackVaryings(n,d,i.SEPARATE_ATTRIBS),i.linkProgram(n),!1===i.getProgramParameter(n,i.LINK_STATUS)&&this._logProgramError(n,o,l),r.useProgram(n),this._setupBindings(t,n);let c=a.attributes,p=[],m=[];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);m.push(r)}this.set(e,{programGPU:n,transformBuffers:m,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;for(let r of e.bindings){let e=this.get(r);if(r.isUniformsGroup||r.isUniformBuffer){let i=r.buffer,s=e.bufferGPU;t.bindBuffer(t.UNIFORM_BUFFER,s);let a=r.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,s),0===a.length)t.bufferData(t.UNIFORM_BUFFER,i,t.DYNAMIC_DRAW);else{let e=(0,u.iu4)(i),r=e?1:i.BYTES_PER_ELEMENT;for(let s=0,n=a.length;s<n;s++){let n=a[s],o=n.start*r,l=n.count*r,u=o*(e?i.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,u,i,o,l)}}this.set(r,e)}else if(r.isSampledTexture){let{textureGPU:t,glTextureType:i}=this.get(r.texture);e.textureGPU=t,e.glTextureType=i,this.set(r,e)}}}updateBinding(e){let t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){let r=this.get(e).bufferGPU,i=e.buffer,s=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,r),0===s.length)t.bufferData(t.UNIFORM_BUFFER,i,t.DYNAMIC_DRAW);else{let e=(0,u.iu4)(i),r=e?1:i.BYTES_PER_ELEMENT,a=s[0].start;for(let n=0,o=s.length;n<o;n++){let o=s[n],l=s[n+1],u=o.start+o.count;if(void 0!==l&&l.start===u)continue;let d=a*r,h=(u-a)*r,c=d*(e?i.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,c,i,d,h),void 0!==l&&(a=l.start)}}}}createUniformBuffer(e){let t=this.get(e);if(void 0===t.bufferGPU){let r=this.gl,i=e.buffer;t.bufferGPU=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,t.bufferGPU),r.bufferData(r.UNIFORM_BUFFER,i.byteLength,r.DYNAMIC_DRAW)}}destroyUniformBuffer(e){let t=this.get(e);this.gl.deleteBuffer(t.bufferGPU),this.delete(e)}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(b4).filter(t=>b4[t]===e),r=this.extensions;for(let e=0;e<t.length;e++)if(r.has(t[e]))return!0;return!1}copyTextureToTexture(e,t,r=null,i=null,s=0,a=0){this.textureUtils.copyTextureToTexture(e,t,r,i,s,a)}copyFramebufferToTexture(e,t,r){this.textureUtils.copyFramebufferToTexture(e,t,r)}hasCompatibility(e){return e===u.x$Y.TEXTURE_COMPARE||super.hasCompatibility(e)}initRenderTarget(e){let{gl:t,state:r}=this;this._setFramebuffer(e),r.bindFramebuffer(t.FRAMEBUFFER,null)}_setFramebuffer(e){let{gl:t,state:r}=this,i=null;if(null!==e.textures){let s,a=e.renderTarget,n=this.get(a),{samples:o,depthBuffer:l,stencilBuffer:u}=a,d=!0===a.isCubeRenderTarget,h=!0===a.isRenderTarget3D,c=a.depth>1,p=!0===a.isXRRenderTarget,m=!0===p&&!0===a._hasExternalTextures,g=n.msaaFrameBuffer,f=n.depthRenderbuffer,b=this.extensions.get("WEBGL_multisampled_render_to_texture"),y=this.extensions.get("OVR_multiview2"),x=this._useMultisampledExtension(a),T=hT(e);if(d?(n.cubeFramebuffers||(n.cubeFramebuffers={}),s=n.cubeFramebuffers[T]):p&&!1===m?s=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),s=n.framebuffers[T]),void 0===s){s=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,s);let i=e.textures,l=[];if(d){n.cubeFramebuffers[T]=s;let{textureGPU:e}=this.get(i[0]),r=this.renderer._activeCubeFace,a=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,a)}else{n.framebuffers[T]=s;for(let r=0;r<i.length;r++){let s=i[r],n=this.get(s);n.renderTarget=e.renderTarget,n.cacheKey=T;let l=t.COLOR_ATTACHMENT0+r;if(a.multiview)y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,l,n.textureGPU,0,o,0,2);else if(h||c){let e=this.renderer._activeCubeFace,r=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,l,n.textureGPU,r,e)}else if(x)b.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,t.TEXTURE_2D,n.textureGPU,0,o);else{let e=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,l,t.TEXTURE_2D,n.textureGPU,e)}}}let p=u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(!0===a._autoAllocateDepthBuffer){let r=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(r,e,0,x),n.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,a.multiview)y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,p,r.textureGPU,0,o,0,2);else if(m&&x)b.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 if(e.depthTexture.isCubeTexture){let e=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,p,t.TEXTURE_CUBE_MAP_POSITIVE_X+e,r.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,p,t.TEXTURE_2D,r.textureGPU,0)}n.depthInvalidationArray=l}else{if(this._isRenderCameraDepthArray(e)){r.bindFramebuffer(t.FRAMEBUFFER,s);let i=this.renderer._activeCubeFace,a=this.get(e.depthTexture),n=u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,n,a.textureGPU,0,i)}if((p||x||a.multiview)&&!0!==a._isOpaqueFramebuffer){r.bindFramebuffer(t.FRAMEBUFFER,s);let i=this.get(e.textures[0]);a.multiview?y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,i.textureGPU,0,o,0,2):x?b.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===a._autoAllocateDepthBuffer){let e=n.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,e),t.framebufferRenderbuffer(t.FRAMEBUFFER,l,t.RENDERBUFFER,e)}else{let r=this.get(e.depthTexture);a.multiview?y.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,l,r.textureGPU,0,o,0,2):x?b.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&&!a.multiview){if(void 0===g){let i=[];g=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,g);let s=[],a=e.textures;for(let r=0;r<a.length;r++){s[r]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,s[r]),i.push(t.COLOR_ATTACHMENT0+r);let a=e.textures[r],n=this.get(a);t.renderbufferStorageMultisample(t.RENDERBUFFER,o,n.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+r,t.RENDERBUFFER,s[r])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),n.msaaFrameBuffer=g,n.msaaRenderbuffers=s,l&&void 0===f){f=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(f,e,o),n.depthRenderbuffer=f;let r=u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;i.push(r)}n.invalidationArray=i}i=n.msaaFrameBuffer}else i=s;
vendor: 9,641 bytes, line 183
183r.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,a=e[r],n=this.get(a);t.bindBuffer(t.ARRAY_BUFFER,n.bufferGPU),t.enableVertexAttribArray(r),!0===a.isInterleavedBufferAttribute?(i=a.data.stride*n.bytesPerElement,s=a.offset*n.bytesPerElement):(i=0,s=0),n.isInteger?t.vertexAttribIPointer(r,a.itemSize,n.type,i,s):t.vertexAttribPointer(r,a.itemSize,n.type,a.normalized,i,s),a.isInstancedBufferAttribute&&!a.isInterleavedBufferAttribute?t.vertexAttribDivisor(r,a.meshPerAttribute):a.isInterleavedBufferAttribute&&a.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(r,a.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,i=0,s=0;for(let a of e)for(let e of a.bindings)if(e.isUniformsGroup||e.isUniformBuffer){let s=i++,a=r.getUniformBlockIndex(t,e.name);r.uniformBlockBinding(t,a,s)}else if(e.isSampledTexture){let i=s++,a=r.getUniformLocation(t,e.name);r.uniform1i(a,i)}}_bindUniforms(e){let{gl:t,state:r}=this,i=0,s=0;for(let a of e)for(let e of a.bindings){let a=this.get(e);if(e.isUniformsGroup||e.isUniformBuffer){let e=i++;r.bindBufferBase(t.UNIFORM_BUFFER,e,a.bufferGPU)}else if(e.isSampledTexture){let e=s++;r.bindTexture(a.glTextureType,a.textureGPU,t.TEXTURE0+e)}}}_resolveRenderTarget(e){let{gl:t,state:r}=this,i=e.renderTarget;if(null!==e.textures&&i){let s=this.get(i);if(i.samples>0&&!1===this._useMultisampledExtension(i)){let a=s.framebuffers[e.getCacheKey()],n=t.COLOR_BUFFER_BIT;i.resolveDepthBuffer&&(i.depthBuffer&&(n|=t.DEPTH_BUFFER_BIT),i.stencilBuffer&&i.resolveStencilBuffer&&(n|=t.STENCIL_BUFFER_BIT));let o=s.msaaFrameBuffer,l=s.msaaRenderbuffers,u=e.textures,d=u.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,o),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),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,s.invalidationArray)}else if(!1===i.resolveDepthBuffer&&s.framebuffers){let i=s.framebuffers[e.getCacheKey()];r.bindFramebuffer(t.DRAW_FRAMEBUFFER,i),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,s.depthInvalidationArray)}}}_useMultisampledExtension(e){return!0===e.multiview||e.samples>0&&!0===this.extensions.has("WEBGL_multisampled_render_to_texture")&&!1!==e._autoAllocateDepthBuffer}dispose(){null!==this.textureUtils&&this.textureUtils.dispose();let e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}let b7={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list"},ye="undefined"!=typeof self&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},yt={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},yr={Store:"store"},yi={Load:"load",Clear:"clear"},ys={CCW:"ccw",CW:"cw"},ya={None:"none",Back:"back"},yn={Uint16:"uint16",Uint32:"uint32"},yo={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R16Unorm:"r16unorm",R16Snorm:"r16snorm",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RG16Unorm:"rg16unorm",RG16Snorm:"rg16snorm",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA16Unorm:"rgba16unorm",RGBA16Snorm:"rgba16snorm",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},yl={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},yu={Linear:"linear",Nearest:"nearest"},yd={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},yh={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},yc={None:0,All:15},yp={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},ym={Storage:"storage",ReadOnlyStorage:"read-only-storage"},yg={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},yf={NonFiltering:"non-filtering",Comparison:"comparison"},yb={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},yy={TwoD:"2d",ThreeD:"3d"},yx={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},yT={All:"all"},y_={Vertex:"vertex",Instance:"instance"},yv={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"},yS={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class yN extends bC{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){let{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update(
183)}}class yR extends b_{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let yA=0;class yE extends yR{constructor(e,t){super("StorageBuffer_"+yA++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:M.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}let yC=[null];class yw{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(t=null!==e.depthTexture?this.getTextureFormatGPU(e.depthTexture):e.stencil?!0===this.backend.renderer.reversedDepthBuffer?yo.Depth32FloatStencil8:yo.Depth24PlusStencil8:!0===this.backend.renderer.reversedDepthBuffer?yo.Depth32Float:yo.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){let e=this.backend.renderer,r=e.getRenderTarget();t=r?r.samples:e.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);let r=(t=this.getSampleCount(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()}getCurrentColorFormats(e){return null!==e.textures?e.textures.map(e=>this.getTextureFormatGPU(e)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?b7.PointList:e.isLineSegments||e.isMesh&&!0===t.wireframe?b7.LineList:e.isLine?b7.LineStrip:e.isMesh?b7.TriangleList:void 0}getSampleCount(e){return e>=4?4:1}
183getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){let e=this.backend.parameters.outputType;if(void 0===e)return null===this._preferredCanvasFormat&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(e===u.OUM)return yo.BGRA8Unorm;if(e===u.ix0)return yo.RGBA16Float;throw Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function yM(e,t){yC[0]=t,e.queue.submit(yC),yC[0]=null}class yB{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class yU{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}class yF{constructor(){this.label=""}reset(){this.label=""}}class yL{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}class yP{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}class yD{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}class yO{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new yI,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}class yI{constructor(){this.count=1,this.mask=0xffffffff,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=0xffffffff,this.alphaToCoverageEnabled=!1}}class yV{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class yG{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}class yk{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}}let yz=new yB,y$=new yU,yW=new yF,yH=new yL,yq=new yD,yj=new yO,yX=new yP,yQ=new yV,yK=new yG,yY=new yk;class yZ extends d6{constructor(e){super(),this.device=e;let t=`
184struct VarysStruct {
185	@builtin( position ) Position: vec4f,
186	@location( 0 ) vTex : vec2f,
187	@location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32,
188};
189
190@group( 0 ) @binding ( 2 )
191var<uniform> flipY: u32;
192
193@vertex
194fn mainVS(
195		@builtin( vertex_index ) vertexIndex : u32,
196		@builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct {
197
198	var Varys : VarysStruct;
199
200	var pos = array(
201		vec2f( -1, -1 ),
202		vec2f( -1,  3 ),
203		vec2f(  3, -1 ),
204	);
205
206	let p = pos[ vertexIndex ];
207	let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 );
208	Varys.vTex = p * mult + vec2f( 0.5 );
209	Varys.Position = vec4f( p, 0, 1 );
210	Varys.vBaseArrayLayer = instanceIndex;
211
212	return Varys;
213
214}
215
216@group( 0 ) @binding( 0 )
217var imgSampler : sampler;
218
219@group( 0 ) @binding( 1 )
220var img2d : texture_2d<f32>;
221
222@fragment
223fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
224
225	return textureSample( img2d, imgSampler, Varys.vTex );
226
227}
228
229@group( 0 ) @binding( 1 )
230var img2dArray : texture_2d_array<f32>;
231
232@fragment
233fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
234
235	return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer );
236
237}
238
239const faceMat = array(
240  mat3x3f(  0,  0,  -2,  0, -2,   0,  1,  1,   1 ),   // pos-x
241  mat3x3f(  0,  0,   2,  0, -2,   0, -1,  1,  -1 ),   // neg-x
242  mat3x3f(  2,  0,   0,  0,  0,   2, -1,  1,  -1 ),   // pos-y
243  mat3x3f(  2,  0,   0,  0,  0,  -2, -1, -1,   1 ),   // neg-y
244  mat3x3f(  2,  0,   0,  0, -2,   0, -1,  1,   1 ),   // pos-z
245  mat3x3f( -2,  0,   0,  0, -2,   0,  1,  1,  -1 ),   // neg-z
246);
247
248@group( 0 ) @binding( 1 )
249var imgCube : texture_cube<f32>;
250
251@fragment
252fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> {
253
254	return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) );
255
256}
257`;this.mipmapSampler=e.createSampler({minFilter:yu.Linear}),this.flipYSampler=e.createSampler({minFilter:yu.Nearest}),y$.size=4,y$.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(y$),y$.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),y$.size=4,y$.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(y$),y$.reset(),this.transferPipelines={},yQ.label="mipmap",yQ.code=t,this.mipmapShaderModule=e.createShaderModule(yQ),yQ.reset()}getTransferPipeline(e,t){t=t||"2d-array";let r=`${e}-${t}`,i=this.transferPipelines[r];return void 0===i&&(yj.label=`mipmap-${e}-${t}`,yj.vertex={module:this.mipmapShaderModule},yj.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},yj.layout="auto",i=this.device.createRenderPipeline(yj),yj.reset(),this.transferPipelines[r]=i),i}flipY(e,t,r=0){let i=t.format,{width:s,height:a}=t.size;yK.size.width=s,yK.size.height=a,yK.format=i,yK.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;let n=this.device.createTexture(yK);yK.reset();let o=this.getTransferPipeline(i,e.textureBindingViewDimension),l=this.getTransferPipeline(i,n.textureBindingViewDimension),u=this.device.createCommandEncoder(yW),d=(e,t,r,i,s,a)=>{let n=e.getBindGroupLayout(0);yY.dimension=t.textureBindingViewDimension||"2d-array",yY.mipLevelCount=1;let o=t.createView(yY);yY.reset(),yz.layout=n,yz.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:o},{binding:2,resource:{buffer:a?this.flipUniformBuffer:this.noFlipUniformBuffer}});let l=this.device.createBindGroup(yz);yz.reset(),yY.dimension="2d",yY.mipLevelCount=1,yY.baseArrayLayer=s,yY.arrayLayerCount=1;let d=i.createView(yY);yY.reset(),yX.view=d,yX.loadOp=yi.Clear,yX.storeOp=yr.Store,yq.colorAttachments.push(yX);let h=u.beginRenderPass(yq);yq.reset(),yX.reset(),h.setPipeline(e),h.setBindGroup(0,l),h.draw(3,1,0,r),h.end()};d(o,e,r,n,0,!1),d(l,n,0,e,r,!0),yM(this.device,u.finish()),n.destroy()}generateMipmaps(e,t=null){let r=this.get(e),i=r.layers||this._mipmapCreateBundles(e),s=t;null===s&&(yW.label="mipmapEncoder",s=this.device.createCommandEncoder(yW),yW.reset()),this._mipmapRunBundles(s,i),null===t&&yM(this.device,s.finish()),r.layers=i}_mipmapCreateBundles(e){let t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),i=r.getBindGroupLayout(0),s=[];for(let a=1;a<e.mipLevelCount;a++)for(let n=0;n<e.depthOrArrayLayers;n++){yY.dimension=t,yY.baseMipLevel=a-1,yY.mipLevelCount=1;let o=e.createView(yY);yY.reset(),yz.layout=i,yz.entries.push({binding:0,resource:this.mipmapSampler},{binding:1,resource:o},{binding:2,resource:{buffer:this.noFlipUniformBuffer}});let l=this.device.createBindGroup(yz);yz.reset(),yY.dimension="2d",yY.baseMipLevel=a,yY.mipLevelCount=1,yY.baseArrayLayer=n,yY.arrayLayerCount=1;let u=e.createView(yY);yY.reset();let d=new yP;d.view=u,d.loadOp=yi.Clear,d.storeOp=yr.Store;let h=new yD;h.colorAttachments.push(d),yH.colorFormats=[e.format];let c=this.device.createRenderBundleEncoder(yH);yH.reset(),c.setPipeline(r),c.setBindGroup(0,l),c.draw(3,1,0,n),s.push({renderBundles:[c.finish()],passDescriptor:h})}return s}_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()}}}class yJ{constructor(){this.label="",this.addressModeU="clamp-to-edge",this.addressModeV="clamp-to-edge",this.addressModeW="clamp-to-edge",this.magFilter="nearest",this.minFilter="nearest",this.mipmapFilter="nearest",this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}reset(){this.label="",this.addressModeU="clamp-to-edge",this.addressModeV="clamp-to-edge",this.addressModeW="clamp-to-edge",this.magFilter="nearest",this.minFilter="nearest",this.mipmapFilter="nearest",this.lodMinClamp=0,this.lodMaxClamp=32,this.compare=void 0,this.maxAnisotropy=1}}class y0{constructor(){this.texture=null,this.mipLevel=0,this.origin={x:0,y:0,z:0},this.aspect="all"}reset(){this.texture=null,this.mipLevel=0,this.origin.x=0,this.origin.y=0,this.origin.z=0,this.aspect="all"}}class y1{constructor(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.buffer=null,this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}}class y2{constructor(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}reset(){this.offset=0,this.bytesPerRow=void 0,this.rowsPerImage=void 0}}class y3{constructor(){this.source=null,this.origin={x:0,y:0},this.flipY=!1}reset(){this.source=null,this.origin.x=0,this.origin.y=0,this.flipY=!1}}
257class y4 extends y0{constructor(){super(),this.colorSpace="srgb",this.premultipliedAlpha=!1}reset(){super.reset(),this.colorSpace="srgb",this.premultipliedAlpha=!1}}class y5{constructor(){this.width=0,this.height=1,this.depthOrArrayLayers=1}reset(){this.width=0,this.height=1,this.depthOrArrayLayers=1}}let y6=new yU,y8=new yF,y9=new yJ,y7=new y0,xe=new y1,xt=new y2,xr=new y3,xi=new y4,xs=new yG,xa=new y5,xn={[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"},xo=[0,1,3,2,4,5];function xl(e,t,r,i,s,a,n,o,l,u){y7.texture=t,y7.mipLevel=r,y7.origin.z=i,xt.offset=i*a,xt.bytesPerRow=n,xt.rowsPerImage=o,xa.width=l,xa.height=u,e.queue.writeTexture(y7,s.data,xt,xa),y7.reset(),xt.reset(),xa.reset()}class xu{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){let t=this.backend,r=e.texture,i=e.textureNode,s=r.minFilter+"-"+r.magFilter+"-"+r.wrapS+"-"+r.wrapT+"-"+(r.wrapR||"0")+"-"+r.anisotropy+"-"+ +(!0===r.isDepthTexture)+"-"+(null!==r.compareFunction&&null!==i.compareNode?r.compareFunction:0),a=this._samplerCache.get(s);if(void 0===a){y9.addressModeU=this._convertAddressMode(r.wrapS),y9.addressModeV=this._convertAddressMode(r.wrapT),y9.addressModeW=this._convertAddressMode(r.wrapR),y9.magFilter=this._convertFilterMode(r.magFilter),y9.minFilter=this._convertFilterMode(r.minFilter),y9.mipmapFilter=this._convertMipmapFilterMode(r.minFilter),r.isDepthTexture&&(null===r.compareFunction||null===i.compareNode)&&(y9.magFilter=yu.Nearest,y9.minFilter=yu.Nearest,y9.mipmapFilter=yu.Nearest),y9.magFilter===yu.Linear&&y9.minFilter===yu.Linear&&y9.mipmapFilter===yu.Linear&&(y9.maxAnisotropy=r.anisotropy),r.isDepthTexture&&null!==r.compareFunction&&null!==i.compareNode&&t.hasCompatibility(u.x$Y.TEXTURE_COMPARE)&&(y9.compare=xn[r.compareFunction]);let e=t.device.createSampler(y9);y9.reset(),a={sampler:e,usedTimes:0},this._samplerCache.set(s,a)}let n=t.get(e);return n.sampler!==a.sampler&&(this._releaseSampler(n),n.samplerKey=s,n.sampler=a.sampler,a.usedTimes++),s}destroySampler(e){this._releaseSampler(this.backend.get(e))}_releaseSampler(e){if(void 0!==e.sampler){let t=this._samplerCache.get(e.samplerKey);t.usedTimes--,0===t.usedTimes&&this._samplerCache.delete(e.samplerKey),e.sampler=void 0,e.samplerKey=void 0}}createDefaultTexture(e){let t,r=xd(e,this.backend.device);t=e.isCubeTexture?this._getDefaultCubeTextureGPU(r):this._getDefaultTextureGPU(r),this.backend.get(e).texture=t}createTexture(e,t={}){let r=this.backend,i=r.get(e);if(i.initialized){if(!0===i.externalTexture)return;throw Error("THREE.WebGPUTextureUtils: Texture already initialized.")}if(e.isExternalTexture){i.texture=e.sourceTexture,i.initialized=!0;return}void 0===t.needsMipmaps&&(t.needsMipmaps=!1),void 0===t.levels&&(t.levels=1),void 0===t.depth&&(t.depth=1);let{width:s,height:a,depth:n,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),d=e.internalFormat||t.format||xd(e,r.device);i.format=d;let{samples:h,primarySamples:c,isMSAA:p}=r.utils.getTextureSampleData(e),m=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;!0===e.isStorageTexture&&(m|=GPUTextureUsage.STORAGE_BINDING),!0!==e.isCompressedTexture&&!0!==e.isCompressedArrayTexture&&d!==yo.RGB9E5UFloat&&(m|=GPUTextureUsage.RENDER_ATTACHMENT);let g=new yG;if(g.label=e.name,g.size.width=s,g.size.height=a,g.size.depthOrArrayLayers=n,g.mipLevelCount=o,g.sampleCount=c,g.dimension=l,g.format=d,g.usage=m,void 0===d){(0,u.R8M)("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}e.isCubeTexture&&(g.textureBindingViewDimension=yx.Cube);try{i.texture=r.device.createTexture(g)}catch(t){(0,u.R8M)("WebGPURenderer: Failed to create texture with descriptor:",g),this.createDefaultTexture(e);return}if(p){let e=Object.assign({},g);
257e.label=e.label+"-msaa",e.sampleCount=h,e.mipLevelCount=1,i.msaaTexture=r.device.createTexture(e)}i.initialized=!0,i.textureDescriptorGPU=g}destroyTexture(e,t=!1){let r=this.backend,i=r.get(e);void 0!==i.texture&&!1===t&&!0!==e.isExternalTexture&&i.texture.destroy(),void 0!==i.msaaTexture&&i.msaaTexture.destroy(),r.delete(e)}generateMipmaps(e,t=null){let r=this.backend.get(e);this._generateMipmaps(r.texture,t)}getColorBuffer(){let e=this.backend,t=e.renderer.getCanvasTarget(),{width:r,height:i}=e.getDrawingBufferSize(),s=e.renderer.currentSamples,a=t.colorTexture,n=e.get(a);if(a.width===r&&a.height===i&&a.samples===s)return n.texture;let o=n.texture;return o&&o.destroy(),xs.label="colorBuffer",xs.size.width=r,xs.size.height=i,xs.sampleCount=e.utils.getSampleCount(e.renderer.currentSamples),xs.format=e.utils.getPreferredCanvasFormat(),xs.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,o=e.device.createTexture(xs),xs.reset(),a.source.width=r,a.source.height=i,a.samples=s,n.texture=o,o}getDepthBuffer(e=!0,t=!1){let r,i,s=this.backend,a=s.renderer.getCanvasTarget(),{width:n,height:o}=s.getDrawingBufferSize(),l=s.renderer.currentSamples,d=a.depthTexture;if(d.width===n&&d.height===o&&d.samples===l&&d.depth===e&&d.stencil===t)return s.get(d).texture;let h=s.get(d).texture;if(t?(r=u.dcC,i=!0===s.renderer.reversedDepthBuffer?u.RQf:u.V3x):e&&(r=u.zdS,i=!0===s.renderer.reversedDepthBuffer?u.RQf:u.bkx),void 0!==h){if(d.image.width===n&&d.image.height===o&&d.format===r&&d.type===i&&d.samples===l)return h;this.destroyTexture(d)}return d.name="depthBuffer",d.format=r,d.type=i,d.image.width=n,d.image.height=o,d.samples=l,this.createTexture(d,{width:n,height:o}),s.get(d).texture}updateTexture(e,t){let r=this.backend.get(e),i=e.mipmaps,{textureDescriptorGPU:s}=r;if(!e.isRenderTargetTexture&&void 0!==s){if(e.isDataTexture)if(i.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];this._copyBufferToTexture(a,r.texture,s,0,e.flipY,0,t)}else this._copyBufferToTexture(t.image,r.texture,s,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)if(e.layerUpdates&&e.layerUpdates.size>0){for(let i of e.layerUpdates)this._copyBufferToTexture(t.image,r.texture,s,i,e.flipY,i);e.clearLayerUpdates()}else for(let i=0;i<t.image.depth;i++)this._copyBufferToTexture(t.image,r.texture,s,i,e.flipY,i);else if(e.isCompressedTexture||e.isCompressedArrayTexture)e.isCompressedArrayTexture&&e.layerUpdates.size>0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,s,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,s);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,s);else if(e.isHTMLTexture){let t=this.backend.device,i=this.backend.renderer.domElement,a=e.image;if("function"!=typeof t.queue.copyElementImageToTexture)return;if(!r.hasPaintCallback){r.hasPaintCallback=!0,i.requestPaint();return}let n=s.size.width,o=s.size.height;2===t.queue.copyElementImageToTexture.length?t.queue.copyElementImageToTexture({source:a},{destination:{texture:r.texture},width:n,height:o}):t.queue.copyElementImageToTexture(a,n,o,{texture:r.texture}),e.flipY&&this._flipY(r.texture,s)}else if(i.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];this._copyImageToTexture(a,r.texture,s,0,e.flipY,e.premultiplyAlpha,t)}else this._copyImageToTexture(t.image,r.texture,s,0,e.flipY,e.premultiplyAlpha);r.version=e.version}}async copyTextureToBuffer(e,t,r,i,s,a){let n=this.backend.device,o=this.backend.get(e),l=o.texture,u=o.textureDescriptorGPU.format,d=this._getBytesPerTexel(u),h=i*d;y6.size=(s-1)*(h=256*Math.ceil(h/256))+i*d,y6.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let c=n.createBuffer(y6);y6.reset();let p=n.createCommandEncoder(y8);y7.texture=l,y7.origin.x=t,y7.origin.y=r,y7.origin.z=a,xe.buffer=c,xe.bytesPerRow=h,xa.width=i,xa.height=s,p.copyTextureToBuffer(y7,xe,xa),y7.reset(),xe.reset(),xa.reset();let m=this._getTypedArrayType(u);yM(n,p.finish()),await c.mapAsync(GPUMapMode.READ);let g=c.getMappedRange().slice();return c.destroy(),new m(g)}dispose(){this._samplerCache.clear()}_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.defaultCubeTexture[e];if(void 0===t){let r=new u.b4q;r.minFilter=u.hxR,r.magFilter=u.hxR,this.createTexture(r,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=r}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,r){let i=e.images,s=e.mipmaps;for(let a=0;a<6;a++){let n=i[a],o=!0===e.flipY?xo[a]:a;n.isDataTexture?this._copyBufferToTexture(n.image,t,r,o,e.flipY):this._copyImageToTexture(n,t,r,o,e.flipY,e.premultiplyAlpha);for(let i=0;i<s.length;i++){let n=s[i].images[a];n.isDataTexture?this._copyBufferToTexture(n.image,t,r,o,e.flipY,0,i+1):this._copyImageToTexture(n,t,r,o,e.flipY,e.premultiplyAlpha,i+1)}}}_copyImageToTexture(e,t,r,i,s,a,n=0){let o=this.backend.device,l=n>0?e.width:r.size.width,u=n>0?e.height:r.size.height;xr.source=e,xr.flipY=s,xi.texture=t,xi.mipLevel=n,xi.origin.z=i,xi.premultipliedAlpha=a,xa.width=l,xa.height=u;try{o.queue.copyExternalImageToTexture(xr,xi,xa)}catch(e){}finally{xr.reset(),xi.reset(),xa.reset()}}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new yZ(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,i,s,a=0,n=0){let o=this.backend.device,l=e.data,u=this._getBytesPerTexel(r.format),d=e.width*u;y7.texture=t,y7.mipLevel=n,y7.origin.z=i,xt.offset=e.width*e.height*u*a,xt.bytesPerRow=d,xa.width=e.width,xa.height=e.height,o.queue.writeTexture(y7,l,xt,xa),y7.reset(),xt.reset(),xa.reset(),!0===s&&this._flipY(t,r,i)}_copyCompressedBufferToTexture(e,t,r,i=null){let s=this.backend.device,a=this._getBlockData(r.format),n=r.size.depthOrArrayLayers>1,o=i&&i.size>0?i:null;for(let i=0;i<e.length;i++){let l=e[i],u=l.width,d=l.height,h=n?r.size.depthOrArrayLayers:1,c=Math.ceil(u/a.width)*a.byteLength,p=Math.ceil(d/a.height),m=c*p,g=Math.ceil(u/a.width)*a.width,f=p*a.height;if(null!==o)for(let e of o)xl(s,t,i,e,l,m,c,p,g,f);else for(let e=0;e<h;e++)xl(s,t,i,e,l,m,c,p,g,f)}}_getBlockData(e){return e===yo.BC1RGBAUnorm||e===yo.BC1RGBAUnormSRGB?{byteLength:8,width:4,height:4}:e===yo.BC2RGBAUnorm||e===yo.BC2RGBAUnormSRGB||e===yo.BC3RGBAUnorm||e===yo.BC3RGBAUnormSRGB?{byteLength:16,width:4,height:4}:e===yo.BC4RUnorm||e===yo.BC4RSnorm?{byteLength:8,width:4,height:4}:e===yo.BC5RGUnorm||e===yo.BC5RGSnorm||e===yo.BC6HRGBUFloat||e===yo.BC6HRGBFloat||e===yo.BC7RGBAUnorm||e===yo.BC7RGBAUnormSRGB?{byteLength:16,width:4,height:4}:e===yo.ETC2RGB8Unorm||e===yo.ETC2RGB8UnormSRGB||e===yo.ETC2RGB8A1Unorm||e===yo.ETC2RGB8A1UnormSRGB?{byteLength:8,width:4,height:4}:e===yo.ETC2RGBA8Unorm||e===yo.ETC2RGBA8UnormSRGB?{byteLength:16,width:4,height:4}:e===yo.EACR11Unorm||e===yo.EACR11Snorm?{byteLength:8,width:4,height:4}:e===yo.EACRG11Unorm||e===yo.EACRG11Snorm||e===yo.ASTC4x4Unorm||e===yo.ASTC4x4UnormSRGB?{byteLength:16,width:4,height:4}:e===yo.ASTC5x4Unorm||e===yo.ASTC5x4UnormSRGB?{byteLength:16,width:5,height:4}:e===yo.ASTC5x5Unorm||e===yo.ASTC5x5UnormSRGB?{byteLength:16,width:5,height:5}:e===yo.ASTC6x5Unorm||e===yo.ASTC6x5UnormSRGB?{byteLength:16,width:6,height:5}:e===yo.ASTC6x6Unorm||e===yo.ASTC6x6UnormSRGB?{byteLength:16,width:6,height:6}:e===yo.ASTC8x5Unorm||e===yo.ASTC8x5UnormSRGB?{byteLength:16,width:8,height:5}:e===yo.ASTC8x6Unorm||e===yo.ASTC8x6UnormSRGB?{byteLength:16,width:8,height:6}:e===yo.ASTC8x8Unorm||e===yo.ASTC8x8UnormSRGB?{byteLength:16,width:8,height:8}:e===yo.ASTC10x5Unorm||e===yo.ASTC10x5UnormSRGB?{byteLength:16,width:10,height:5}:e===yo.ASTC10x6Unorm||e===yo.ASTC10x6UnormSRGB?{byteLength:16,width:10,height:6}:e===yo.ASTC10x8Unorm||e===yo.ASTC10x8UnormSRGB?{byteLength:16,width:10,height:8}:e===yo.ASTC10x10Unorm||e===yo.ASTC10x10UnormSRGB?{byteLength:16,width:10,height:10}:e===yo.ASTC12x10Unorm||e===yo.ASTC12x10UnormSRGB?{byteLength:16,width:12,height:10}:e===yo.ASTC12x12Unorm||e===yo.ASTC12x12UnormSRGB?{byteLength:16,width:12,height:12}:void 0}_convertAddressMode(e){let t=yl.ClampToEdge;return e===u.GJx?t=yl.Repeat:e===u.kTW&&(t=yl.MirrorRepeat),t}_convertFilterMode(e){let t=yu.Linear;return(e===u.hxR||e===u.pHI||e===u.Cfg)&&(t=yu.Nearest),t}_convertMipmapFilterMode(e){return e===u.Cfg||e===u.$_I?yu.Linear:yu.Nearest}_getBytesPerTexel(e){return e===yo.R8Unorm||e===yo.R8Snorm||e===yo.R8Uint||e===yo.R8Sint?1:e===yo.R16Uint||e===yo.R16Sint||e===yo.R16Float||e===yo.RG8Unorm||e===yo.RG8Snorm||e===yo.RG8Uint||e===yo.RG8Sint||e===yo.R16Unorm||e===yo.R16Snorm?2:e===yo.R32Uint||e===yo.R32Sint||e===yo.R32Float||e===yo.RG16Uint||e===yo.RG16Sint||e===yo.RG16Float||e===yo.RGBA8Unorm||e===yo.RGBA8UnormSRGB||e===yo.RGBA8Snorm||e===yo.RGBA8Uint||e===yo.RGBA8Sint||e===yo.BGRA8Unorm||e===yo.BGRA8UnormSRGB||e===yo.RG16Unorm||e===yo.RG16Snorm||e===yo.RGB9E5UFloat||e===yo.RGB10A2Unorm||e===yo.RG11B10UFloat||e===yo.Depth32Float||e===yo.Depth24Plus||e===yo.Depth24PlusStencil8||e===yo.Depth32FloatStencil8?4:e===yo.RG32Uint||e===yo.RG32Sint||e===yo.RG32Float||e===yo.RGBA16Uint||e===yo.RGBA16Sint||e===yo.RGBA16Float||e===yo.RGBA16Unorm||e===yo.RGBA16Snorm?8:e===yo.RGBA32Uint||e===yo.RGBA32Sint||e===yo.RGBA32Float?16:void 0}_getTypedArrayType(e){return e===yo.R8Uint?Uint8Array:e===yo.R8Sint?Int8Array:e===yo.R8Unorm?Uint8Array:e===yo.R8Snorm?Int8Array:e===yo.RG8Uint?Uint8Array:e===yo.RG8Sint?Int8Array:e===yo.RG8Unorm?Uint8Array:e===yo.RG8Snorm?Int8Array:e===yo.RGBA8Uint?Uint8Array:e===yo.RGBA8Sint?Int8Array:e===yo.RGBA8Unorm||e===yo.RGBA8UnormSRGB?Uint8Array:e===yo.RGBA8Snorm?Int8Array:e===yo.R16Uint?Uint16Array:e===yo.R16Sint?Int16Array:e===yo.RG16Uint?Uint16Array:e===yo.RG16Sint?Int16Array:e===yo.RGBA16Uint?Uint16Array:e===yo.RGBA16Sint?Int16Array:e===yo.R16Float||e===yo.RG16Float||e===yo.RGBA16Float||e===yo.R16Unorm?Uint16Array:e===yo.R16Snorm?Int16Array:e===yo.RG16Unorm?Uint16Array:e===yo.RG16Snorm?Int16Array:e===yo.RGBA16Unorm?Uint16Array:e===yo.RGBA16Snorm?Int16Array:e===yo.R32Uint?Uint32Array:e===yo.R32Sint?Int32Array:e===yo.R32Float?Float32Array:e===yo.RG32Uint?Uint32Array:e===yo.RG32Sint?Int32Array:e===yo.RG32Float?Float32Array:e===yo.RGBA32Uint?Uint32Array:e===yo.RGBA32Sint?Int32Array:e===yo.RGBA32Float?Float32Array:e===yo.BGRA8Unorm||e===yo.BGRA8UnormSRGB?Uint8Array:e===yo.RGB10A2Unorm||e===yo.RGB9E5UFloat||e===yo.RG11B10UFloat?Uint32Array:e===yo.Depth32Float?Float32Array:e===yo.Depth24Plus||e===yo.Depth24PlusStencil8?Uint32Array:e===yo.Depth32FloatStencil8?Float32Array:void 0}_getDimension(e){return e.is3DTexture||e.isData3DTexture?yy.ThreeD:yy.TwoD}}function xd(e,t){let r,i=e.format,s=e.type,a=e.normalized,n=e.colorSpace,o=u.ppV.getTransfer(n),l=!1;if(a&&!1===(l=t.features.has(yv.TextureFormatsTier1))&&(0,u.R8M)("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature."),!0===e.isCompressedTexture||!0===e.isCompressedArrayTexture)switch(i){case u.IE4:case u.Nz6:r=o===u.KLL?yo.BC1RGBAUnormSRGB:yo.BC1RGBAUnorm;break;case u.jR7:r=o===u.KLL?yo.BC2RGBAUnormSRGB:yo.BC2RGBAUnorm;break;case u.BXX:r=o===u.KLL?yo.BC3RGBAUnormSRGB:yo.BC3RGBAUnorm;break;case u.Kef:r=yo.BC4RUnorm;break;case u.XG_:r=yo.BC4RSnorm;break;case u.HO_:r=yo.BC5RGUnorm;break;case u.CWW:r=yo.BC5RGSnorm;break;case u.Fn:r=o===u.KLL?yo.BC7RGBAUnormSRGB:yo.BC7RGBAUnorm;break;case u.H23:r=yo.BC6HRGBFloat;break;case u.W9U:r=yo.BC6HRGBUFloat;break;case u.Riy:case u.CVz:r=o===u.KLL?yo.ETC2RGB8UnormSRGB:yo.ETC2RGB8Unorm;break;case u.KDk:r=o===u.KLL?yo.ETC2RGBA8UnormSRGB:yo.ETC2RGBA8Unorm;break;case u.BVL:r=yo.EACR11Unorm;break;case u.gZr:r=yo.EACR11Snorm;break;case u.OtU:r=yo.EACRG11Unorm;break;case u.jSS:r=yo.EACRG11Snorm;break;case u.qa3:r=o===u.KLL?yo.ASTC4x4UnormSRGB:yo.ASTC4x4Unorm;break;case u.B_h:r=o===u.KLL?yo.ASTC5x4UnormSRGB:yo.ASTC5x4Unorm;break;case u.czI:r=o===u.KLL?yo.ASTC5x5UnormSRGB:yo.ASTC5x5Unorm;break;case u.rSH:r=o===u.KLL?yo.ASTC6x5UnormSRGB:yo.ASTC6x5Unorm;break;case u.Qrf:r=o===u.KLL?yo.ASTC6x6UnormSRGB:yo.ASTC6x6Unorm;break;case u.psI:r=o===u.KLL?yo.ASTC8x5UnormSRGB:yo.ASTC8x5Unorm;break;case u.a5J:r=o===u.KLL?yo.ASTC8x6UnormSRGB:yo.ASTC8x6Unorm;break;case u._QJ:r=o===u.KLL?yo.ASTC8x8UnormSRGB:yo.ASTC8x8Unorm;break;case u.uB5:r=o===u.KLL?yo.ASTC10x5UnormSRGB:yo.ASTC10x5Unorm;break;case u.lyL:r=o===u.KLL?yo.ASTC10x6UnormSRGB:yo.ASTC10x6Unorm;break;case u.bC7:r=o===u.KLL?yo.ASTC10x8UnormSRGB:yo.ASTC10x8Unorm;break;case u.y3Z:r=o===u.KLL?yo.ASTC10x10UnormSRGB:yo.ASTC10x10Unorm;break;case u.ojs:r=o===u.KLL?yo.ASTC12x10UnormSRGB:yo.ASTC12x10Unorm;break;case u.S$4:r=o===u.KLL?yo.ASTC12x12UnormSRGB:yo.ASTC12x12Unorm;break;case u.GWd:r=o===u.KLL?yo.RGBA8UnormSRGB:yo.RGBA8Unorm;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture format.",i)}else switch(i){case u.GWd:switch(s){case u.tJf:r=yo.RGBA8Snorm;break;case u.fBL:r=l?yo.RGBA16Snorm:yo.RGBA16Sint;break;case u.cHt:r=l?yo.RGBA16Unorm:yo.RGBA16Uint;break;case u.bkx:r=yo.RGBA32Uint;break;case u.Yuy:r=yo.RGBA32Sint;break;case u.OUM:r=o===u.KLL?yo.RGBA8UnormSRGB:yo.RGBA8Unorm;break;case u.ix0:r=yo.RGBA16Float;break;case u.RQf:r=yo.RGBA32Float;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case u.HIg:switch(s){case u.Dmk:r=yo.RGB9E5UFloat;break;case u.yT7:r=yo.RG11B10UFloat;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case u.VT0:switch(s){case u.tJf:r=yo.R8Snorm;break;case u.fBL:r=l?yo.R16Snorm:yo.R16Sint;break;case u.cHt:r=l?yo.R16Unorm:yo.R16Uint;break;case u.bkx:r=yo.R32Uint;break;case u.Yuy:r=yo.R32Sint;break;case u.OUM:r=yo.R8Unorm;break;case u.ix0:r=yo.R16Float;break;case u.RQf:r=yo.R32Float;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case u.paN:switch(s){case u.tJf:r=yo.RG8Snorm;break;case u.fBL:r=l?yo.RG16Snorm:yo.RG16Sint;break;case u.cHt:r=l?yo.RG16Unorm:yo.RG16Uint;break;case u.bkx:r=yo.RG32Uint;break;case u.Yuy:r=yo.RG32Sint;break;case u.OUM:r=yo.RG8Unorm;break;case u.ix0:r=yo.RG16Float;break;case u.RQf:r=yo.RG32Float;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case u.zdS:switch(s){case u.cHt:r=yo.Depth16Unorm;break;case u.bkx:r=yo.Depth24Plus;break;case u.RQf:r=yo.Depth32Float;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case u.dcC:switch(s){case u.V3x:r=yo.Depth24PlusStencil8;break;case u.RQf:t&&!1===t.features.has(yv.Depth32FloatStencil8)&&(0,u.z3S)('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),r=yo.Depth32FloatStencil8;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case u.ZQM:switch(s){case u.Yuy:r=yo.R32Sint;break;case u.bkx:r=yo.R32Uint;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case u.TkQ:switch(s){case u.Yuy:r=yo.RG32Sint;break;case u.bkx:r=yo.RG32Uint;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case u.c90:switch(s){case u.Yuy:r=yo.RGBA32Sint;break;case u.bkx:r=yo.RGBA32Uint;break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:(0,u.z3S)("WebGPURenderer: Unsupported texture format.",i)}return r}let xh=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,xc=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,xp={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>
257":"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 xm extends f${constructor(e){let{type:t,inputs:r,name:i,inputsCode:s,blockCode:a,outputType:n}=(e=>{let t=(e=e.trim()).match(xh);if(null!==t&&4===t.length){let r=t[2],i=[],s=null;for(;null!==(s=xc.exec(r));)i.push({name:s[1],type:s[2]});let a=[];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=xp[s]),a.push(new fw(s,t))}let n=e.substring(t[0].length),o=t[3]||"void",l=void 0!==t[1]?t[1]:"";return{type:xp[o]||o,inputs:a,name:l,inputsCode:r,blockCode:n,outputType:o}}throw Error("THREE.WGSLNodeFunction: Function is not a WGSL code.")})(e);super(t,r,i),this.inputsCode=s,this.blockCode=a,this.outputType=n}getCode(e=this.name){let t="void"!==this.outputType?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class xg extends fz{parseFunction(e){return new xm(e)}}let xf={[M.READ_ONLY]:"read",[M.WRITE_ONLY]:"write",[M.READ_WRITE]:"read_write"},xb={[u.GJx]:"repeat",[u.ghU]:"clamp",[u.kTW]:"mirror"},xy={vertex:ye.VERTEX,fragment:ye.FRAGMENT,compute:ye.COMPUTE},xx={instance:!0,swizzleAssign:!1,storageBuffer:!0},xT={"^^":"tsl_xor"},x_={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>"},xv={},xS={tsl_xor:new pA("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new pA("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new pA("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new pA("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new pA("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new pA("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new pA("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new pA("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 pA("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 pA("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new pA("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 pA("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),inverse_mat2:new pA(`
258fn tsl_inverse_mat2( m : mat2x2<f32> ) -> mat2x2<f32> {
259
260	let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ];
261
262	return mat2x2<f32>(
263		m[ 1 ][ 1 ], - m[ 0 ][ 1 ],
264		- m[ 1 ][ 0 ], m[ 0 ][ 0 ]
265	) * ( 1.0 / det );
266
267}
268`),inverse_mat3:new pA(`
269fn tsl_inverse_mat3( m : mat3x3<f32> ) -> mat3x3<f32> {
270
271	let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ];
272	let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ];
273	let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ];
274
275	let b01 = a22 * a11 - a12 * a21;
276	let b11 = - a22 * a10 + a12 * a20;
277	let b21 = a21 * a10 - a11 * a20;
278
279	let det = a00 * b01 + a01 * b11 + a02 * b21;
280
281	return mat3x3<f32>(
282		b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ),
283		b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ),
284		b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 )
285	) * ( 1.0 / det );
286
287}
288`),inverse_mat4:new pA(`
289fn tsl_inverse_mat4( m : mat4x4<f32> ) -> mat4x4<f32> {
290
291	let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ];
292	let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ];
293	let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ];
294	let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ];
295
296	let b00 = a00 * a11 - a01 * a10;
297	let b01 = a00 * a12 - a02 * a10;
298	let b02 = a00 * a13 - a03 * a10;
299	let b03 = a01 * a12 - a02 * a11;
300	let b04 = a01 * a13 - a03 * a11;
301	let b05 = a02 * a13 - a03 * a12;
302	let b06 = a20 * a31 - a21 * a30;
303	let b07 = a20 * a32 - a22 * a30;
304	let b08 = a20 * a33 - a23 * a30;
305	let b09 = a21 * a32 - a22 * a31;
306	let b10 = a21 * a33 - a23 * a31;
307	let b11 = a22 * a33 - a23 * a32;
308
309	let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
310
311	return mat4x4<f32>(
312		a11 * b11 - a12 * b10 + a13 * b09,
313		a02 * b10 - a01 * b11 - a03 * b09,
314		a31 * b05 - a32 * b04 + a33 * b03,
315		a22 * b04 - a21 * b05 - a23 * b03,
316		a12 * b08 - a10 * b11 - a13 * b07,
317		a00 * b11 - a02 * b08 + a03 * b07,
318		a32 * b02 - a30 * b05 - a33 * b01,
319		a20 * b05 - a22 * b02 + a23 * b01,
320		a10 * b10 - a11 * b08 + a13 * b06,
321		a01 * b08 - a00 * b10 - a03 * b06,
322		a30 * b04 - a31 * b02 + a33 * b00,
323		a21 * b02 - a20 * b04 - a23 * b00,
324		a11 * b07 - a10 * b09 - a12 * b06,
325		a00 * b09 - a01 * b07 + a02 * b06,
326		a31 * b01 - a30 * b03 - a32 * b00,
327		a20 * b03 - a21 * b01 + a22 * b00
328	) * ( 1.0 / det );
329
330}
331`),biquadraticTexture:new pA(`
332fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
333
334	let res = vec2f( iRes );
335
336	let uvScaled = coord * res;
337	let uvWrapping = ( ( uvScaled % res ) + res ) % res;
338
339	// https://www.shadertoy.com/view/WtyXRy
340
341	let uv = uvWrapping - 0.5;
342	let iuv = floor( uv );
343	let f = fract( uv );
344
345	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
346	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
347	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
348	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
349
350	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
351
352}
353`),biquadraticTextureArray:new pA(`
354fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f {
355
356	let res = vec2f( iRes );
357
358	let uvScaled = coord * res;
359	let uvWrapping = ( ( uvScaled % res ) + res ) % res;
360
361	// https://www.shadertoy.com/view/WtyXRy
362
363	let uv = uvWrapping - 0.5;
364	let iuv = floor( uv );
365	let f = fract( uv );
366
367	let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level );
368	let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level );
369	let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level );
370	let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level );
371
372	return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
373
374}
375`)},xN={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",inverse_mat2:"tsl_inverse_mat2",inverse_mat3:"tsl_inverse_mat3",inverse_mat4:"tsl_inverse_mat4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"},xR="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(xR+="diagnostic( off, derivative_uniformity );\n");class xA extends fE{constructor(e,t){super(e,t,new xg),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,r,i,s,a=this.shaderStage){return"fragment"!==a?this.generateTextureSampleLevel(e,t,r,"0",i):i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`}generateTextureSampleLevel(e,t,r,i,s,a){if(!1===this.isUnfilterable(e))if(s)return a?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`;else return a?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`;return this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,a,i,s):this.generateTextureLod(e,t,r,s,a,i)}generateWrapFunction(e){let t=`tsl_coord_${xb[e.wrapS]}S_${xb[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`,r=xv[t];if(void 0===r){let i=[],s=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f",a=`fn ${t}( coord : ${s} ) -> ${s} {
376
377	return ${s}(
378`,n=(e,t)=>{e===u.GJx?(i.push(xS.repeatWrapping_float),a+=`		tsl_repeatWrapping_float( coord.${t}
378 )`):e===u.ghU?(i.push(xS.clampWrapping_float),a+=`		tsl_clampWrapping_float( coord.${t} )`):e===u.kTW?(i.push(xS.mirrorWrapping_float),a+=`		tsl_mirrorWrapping_float( coord.${t} )`):(a+=`		coord.${t}`,(0,u.R8M)(`WebGPURenderer: Unsupported texture wrap type "${e}" for vertex shader.`))};n(e.wrapS,"x"),a+=",\n",n(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(a+=",\n",n(e.wrapR,"z")),a+="\n	);\n\n}\n",xv[t]=r=new pA(a,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.cache);void 0===i.dimensionsSnippet&&(i.dimensionsSnippet={});let s=i.dimensionsSnippet[r];if(void 0===i.dimensionsSnippet[r]){let a,n,{primarySamples:o}=this.renderer.backend.utils.getTextureSampleData(e);n=e.is3DTexture||e.isData3DTexture?"vec3<u32>":"vec2<u32>",a=o>1||e.isStorageTexture?t:`${t}${r?`, u32( ${r} )`:""}`,s=new iM(new sp(`textureDimensions( ${a} )`,n)),i.dimensionsSnippet[r]=s,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(i.arrayLayerCount=new iM(new sp(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(i.cubeFaceCount=new iM(new sp("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,r,i,s="0u",a){let n=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,s);return(i&&(r=`${r} + vec2<f32>(${i}) / ${o}`),a)?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${n}( ${r} ), ${o}, u32( ${a} ), u32( ${s} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${n}( ${r} ), ${o}, u32( ${s} ) )`)}generateTextureLod(e,t,r,i,s,a="0u"){if(!0===e.isCubeTexture){s&&(r=`${r} + vec3<f32>(${s})`);let i=e.isDepthTexture?"u32":"f32";return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}( ${a} ) )`}let n=this.generateWrapFunction(e),o=this.generateTextureDimension(e,t,a),l=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",u="vec3"===l?"vec3<u32>( 1, 1, 1 )":"vec2<u32>( 1, 1 )";s&&(r=`${r} + ${l}<f32>(${s}) / ${l}<f32>( ${o} )`);let d=`${l}<f32>( 0 )`,h=`${l}<f32>( ${o} - ${u} )`;return r=`${l}<u32>( clamp( floor( ${n}( ${r} ) * ${l}<f32>( ${o} ) ), ${d}, ${h} ) )`,this.generateTextureLoad(e,t,r,a,i,null)}generateStorageTextureLoad(e,t,r,i,s,a){return a&&(r=`${r} + ${a}`),s?`textureLoad( ${t}, ${r}, ${s} )`:`textureLoad( ${t}, ${r} )`}generateTextureLoad(e,t,r,i,s,a){let n;return null===i&&(i="0u"),a&&(r=`${r} + ${a}`),s?n=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(n=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,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&&this.renderer.hasCompatibility(u.x$Y.TEXTURE_COMPARE)}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&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,a=this.shaderStage){return this.isUnfilterable(e)?this.generateTextureLod(e,t,r,i,s,"0",a):this._generateTextureSample(e,t,r,i,s,a)}generateTextureGrad(e,t,r,i,s,a,n=this.shaderStage){if("fragment"===n)if(s)return a?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s}, ${i[0]}, ${i[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s}, ${i[0]}, ${i[1]} )`;else return a?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i[0]}, ${i[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i[0]}, ${i[1]} )`;(0,u.z3S)(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,r,i,s,a,n=this.shaderStage){if("fragment"===n)return!0===e.isDepthTexture&&!0===e.isArrayTexture?a?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i} )`;(0,u.z3S)(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureGather(e,t,r,i,s,a){let n=!0===e.isDepthTexture?"":`${i}, `;return s?a?`textureGather( ${n}${t}, ${t}_sampler, ${r}, ${s}, ${a} )`:`textureGather( ${n}${t}, ${t}_sampler, ${r}, ${s} )`:a?`textureGather( ${n}${t}, ${t}_sampler, ${r}, ${a} )`:`textureGather( ${n}${t}, ${t}_sampler, ${r})`}generateTextureGatherCompare(e,t,r,i,s,a){return s?a?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i})`:a?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i})`}generateTextureLevel(e,t,r,i,s,a){if(!1===this.isUnfilterable(e))if(s)return a?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`;else return a?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`;return this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,a,i,s):this.generateTextureLod(e,t,r,s,a,i)}generateTextureBias(e,t,r,i,s,a,n=this.shaderStage){if("fragment"===n)if(s)return a?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`;else return a?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i} )`;(0,u.z3S)(`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||"cubeDepthTexture"===r||"storageTexture"===r||"texture3D"===r?t:"buffer"!==r&&"storageBuffer"!==r&&"indirectStorageBuffer"!==r?e.groupNode.name+"."+t:this.isCu
vendor: 6,488 bytes, lines 378-385
378stomStruct(e)?t:t+".value"}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){let t=xT[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?((0,u.R8M)("WebGPURenderer: Atomic operations are only supported in compute shaders."),M.READ_WRITE):M.READ_ONLY:e.access}getStorageAccess(e,t){return xf[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,i=null){let s=super.getUniformFromNode(e,t,r,i),a=this.getDataFromNode(e,r,this.globalCache);if(void 0===a.uniformGPU){let n,o=e.groupNode,l=o.name,u=this.getBindGroupArray(l,r);if("texture"===t||"cubeTexture"===t||"cubeDepthTexture"===t||"storageTexture"===t||"texture3D"===t){let i=null,a=this.getNodeAccess(e,r);if("texture"===t||"storageTexture"===t?i=!0===e.value.is3DTexture?new bF(s.name,s.node,o,a):new bB(s.name,s.node,o,a):"cubeTexture"===t||"cubeDepthTexture"===t?i=new bU(s.name,s.node,o,a):"texture3D"===t&&(i=new bF(s.name,s.node,o,a)),i.store=!0===e.isStorageTextureNode,i.mipLevel=i.store?e.mipLevel:0,i.setVisibility(xy[r]),!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===i.store||null!==e.gatherNode){let e=new yN(`${s.name}_sampler`,s.node,o);e.setVisibility(xy[r]),u.push(e,i),n=[e,i]}else u.push(i),n=[i]}else if("buffer"===t||"storageBuffer"===t||"indirectStorageBuffer"===t){let a=this.getSharedDataFromNode(e),l=a.buffer;void 0===l&&(a.buffer=l=new("buffer"===t?bN:yE)(e,o)),l.setVisibility(l.getVisibility()|xy[r]),u.push(l),n=l,s.name=i||"NodeBuffer_"+s.id}else{let e=this.uniformGroups[l];void 0===e&&((e=new bE(l,o)).setVisibility(ye.VERTEX|ye.FRAGMENT|ye.COMPUTE),this.uniformGroups[l]=e),-1===u.indexOf(e)&&u.push(e);let r=(n=this.getNodeUniform(s,t)).name;e.uniforms.some(e=>e.name===r)||e.addUniform(n)}a.uniformGPU=n}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)} {
379${r.vars}
380${r.code}
381`;return r.result&&(s+=`	return ${r.result};
382`),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 a=this.getType(i);t.push(`var<${r}> ${e}: array< ${a}, ${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,a=this.getType(i.type);t.push(`@location( ${e} ) ${s} : ${a}`)}}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} {
383`;r+=this.getStructMembers(t),r+="\n};",e.push(r)}t="\n"+e.join("\n\n")+"\n"}return t}getVar(e,t,r=null,i=""){let s=`var${i} ${t} : `;return null!==r?s+=this.generateArrayDeclaration(e,r):s+=this.getType(e),s}getVars(e,t=!1){let r="";t&&(r="<private>");let i=[],s=this.vars[e];if(void 0!==s)for(let e of s)i.push(`${this.getVar(e.type,e.name,e.count,r)};`);return t?i.join("\n"):`
384	${i.join("\n	")}
385`}getVaryings(e){let t=[];if("vertex"===e&&this.getBuiltin("position","builtinClipSpace","vec4<f32>","vertex"),"vertex"===e||"fragment"===e){let r=this.varyings,i=this.vars[e],s=0;for(let a=0;a<r.length;a++){let n=r[a];if(n.needsInterpolation){let e=`@location( ${s++} )`;if(n.interpolationType){let t=null!==n.interpolationSampling?`, ${n.interpolationSampling} )`:" )";e+=` @interpolate( ${n.interpolationType}${t}`}
385else/^(int|uint|ivec|uvec)/.test(n.type)&&(e+=" @interpolate(flat, either)");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.renderer.backend,r=this.uniforms[e],i=[],s=[],a=[],n={};for(let a of r){let r=a.groupNode.name,o=this.bindingsIndexes[r];if("texture"===a.type||"cubeTexture"===a.type||"cubeDepthTexture"===a.type||"storageTexture"===a.type||"texture3D"===a.type){let r,s=a.node,n=s.value;(!0===n.isCubeTexture||!1===this.isUnfilterable(n)&&!0!==s.isStorageTextureNode||null!==s.gatherNode)&&(this.isSampleCompare(n)&&null!==s.compareNode?i.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${a.name}_sampler : sampler_comparison;`):i.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${a.name}_sampler : sampler;`));let l="",{primarySamples:u}=t.utils.getTextureSampleData(n);if(u>1&&(l="_multisampled"),!0===n.isCubeTexture&&!0===n.isDepthTexture)r="texture_depth_cube";else if(!0===n.isCubeTexture)r="texture_cube<f32>";else if(!0===n.isDepthTexture)r=t.compatibilityMode&&null===n.compareFunction?`texture${l}_2d<f32>`:`texture_depth${l}_2d${!0===n.isArrayTexture?"_array":""}`;else if(!0===a.node.isStorageTextureNode){let i=xd(n,t.device),s=this.getStorageAccess(a.node,e),o=a.node.value.is3DTexture,l=a.node.value.isArrayTexture,u=o?"3d":`2d${l?"_array":""}`;r=`texture_storage_${u}<${i}, ${s}>`}else if(!0===n.isArrayTexture||!0===n.isDataArrayTexture||!0===n.isCompressedArrayTexture)r="texture_2d_array<f32>";else if(!0===n.is3DTexture||!0===n.isData3DTexture)r="texture_3d<f32>";else{let e=this.getComponentTypeFromTexture(n).charAt(0);r=`texture${l}_2d<${e}32>`}i.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${a.name} : ${r};`)}else if("buffer"===a.type||"storageBuffer"===a.type||"indirectStorageBuffer"===a.type){let t=a.node,r=this.getType(t.getNodeType(this)),i=t.bufferCount,n=i>0&&"buffer"===a.type?", "+i:"",l=t.isStorageBufferNode?`storage, ${this.getStorageAccess(t,e)}`:"uniform";if(this.isCustomStruct(a))s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var<${l}> ${a.name} : ${r};`);else{let e=t.isAtomic?`atomic<${r}>`:`${r}`,i=`	value : array< ${e}${n} >`;s.push(this._getWGSLStructBinding(a.name,i,l,o.binding++,o.group))}}else{let e=a.groupNode.name;if(void 0===n[e]){let t=this.uniformGroups[e];if(void 0!==t){let r=[];for(let e of t.uniforms){let t=e.getType(),i=this.getType(this.getVectorType(t));r.push(`	${e.name} : ${i}`)}let i=this.uniformGroupsBindings[e];void 0===i&&(i={index:o.binding++,id:o.group},this.uniformGroupsBindings[e]=i),n[e]={index:i.index,id:i.id,snippets:r}}}}}for(let e in n){let t=n[e];a.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}return[...i,...s,...a].join("\n")}buildCode(){let e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};for(let t in this.sortBindingGroups(),e){this.shaderStage=t;let r=this.allowGlobalVariables,i=e[t];i.uniforms=this.getUniforms(t),i.attributes=this.getAttributes(t),i.varyings=this.getVaryings(t),i.structs=this.getStructs(t),i.vars=this.getVars(t,r),i.codes=this.getCodes(t),i.directives=this.getDirectives(t),i.scopedArrays=this.getScopedArrays(t);let s="// code\n\n";s+=this.flowCode[t];let a=this.flowNodes[t],n=a[a.length-1],o=n.outputNode,l=void 0!==o&&!0===o.isOutputStructNode;for(let e of a){let r=this.getFlowData(e),a=e.name;if(a&&(s.length>0&&(s+="\n"),s+=`	// flow -> ${a}
386`),s+=`${r.code}
387	`,e===n&&"compute"!==t){if(s+="// result\n\n	","vertex"===t)s+=`varyings.builtinClipSpace = ${r.result};`;else if("fragment"===t)if(l)i.returnType=o.getNodeType(this),i.structs+="var<private> output : "+i.returnType+";",s+=`return ${r.result};`;else{let e=`	@location( 0 ) color: ${this.getType(this.getOutputType())}`,t=this.getBuiltins("output");t&&(e+=",\n	"+t),i.returnType="OutputStruct",i.structs+=this._getWGSLStruct("OutputStruct",e),i.structs+="\nvar<private> output : OutputStruct;",s+=`output.color = ${this.format(r.result,n.getNodeType(this),this.getOutputType())};
388
389	return output;`}}}i.flow=s}if(this.shaderStage=null,null!==this.material)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{let t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return null!==t&&(r=this._getWGSLMethod(e+"_"+t)),void 0===r&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){let t=this.getType(e);return`bitcast<${t}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return x_[e]||e}isAvailable(e){let t=xx[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),xx[e]=t),t}_getWGSLMethod(e){return void 0!==xS[e]&&this._include(e),xN[e]}_include(e){let t=xS[e];return t.build(this),this.addInclude(t),t}
389_getWGSLVertexCode(e){return`${this.getSignature()}
390// directives
391${e.directives}
392
393// structs
394${e.structs}
395
396// uniforms
397${e.uniforms}
398
399// varyings
400${e.varyings}
401var<private> varyings : VaryingsStruct;
402
403// vars
404${e.vars}
405
406// codes
407${e.codes}
408
409@vertex
410fn main( ${e.attributes} ) -> VaryingsStruct {
411
412	// flow
413	${e.flow}
414
415	return varyings;
416
417}
418`}_getWGSLFragmentCode(e){return`${this.getSignature()}
419// global
420${xR}
421
422// structs
423${e.structs}
424
425// uniforms
426${e.uniforms}
427
428// vars
429${e.vars}
430
431// codes
432${e.codes}
433
434@fragment
435fn main( ${e.varyings} ) -> ${e.returnType} {
436
437	// flow
438	${e.flow}
439
440}
441`}_getWGSLComputeCode(e,t){let[r,i,s]=t;return`${this.getSignature()}
442// directives
443${e.directives}
444
445// system
446var<private> instanceIndex : u32;
447
448// locals
449${e.scopedArrays}
450
451// structs
452${e.structs}
453
454// uniforms
455${e.uniforms}
456
457// vars
458${this.allowGlobalVariables?e.vars:""}
459
460// codes
461${e.codes}
462
463@compute @workgroup_size( ${r}, ${i}, ${s} )
464fn main( ${e.attributes} ) {
465
466	// local vars
467	${this.allowGlobalVariables?"":e.vars}
468
469	// system
470	instanceIndex = globalId.x
471		+ globalId.y * ( ${r} * numWorkgroups.x )
472		+ globalId.z * ( ${r} * numWorkgroups.x ) * ( ${i} * numWorkgroups.y );
473
474	// flow
475	${e.flow}
476
477}
478`}_getWGSLStruct(e,t){return`
479struct ${e} {
480${t}
481};`}_getWGSLStructBinding(e,t,r,i=0,s=0){let a=e+"Struct",n=this._getWGSLStruct(a,t);return`${n}
482@binding( ${i} ) @group( ${s} )
483var<${r}> ${e} : ${a};`}}let xE=new yU,xC=new yF,xw=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);"undefined"!=typeof Float16Array&&xw.set(Float16Array,["float16"]);let xM=new Map([[u.Oax,["float16"]]]),xB=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class xU{constructor(e){this.backend=e}createAttribute(e,t){let r=this._getBufferAttribute(e),i=this.backend,s=i.get(r),a=s.buffer;if(void 0===a){let n,o=i.device,l=r.array;if(!1===e.normalized){if(l.constructor===Int16Array||l.constructor===Int8Array)l=new Int32Array(l);else if((l.constructor===Uint16Array||l.constructor===Uint8Array)&&(l=new Uint32Array(l),t&GPUBufferUsage.INDEX))for(let e=0;e<l.length;e++)65535===l[e]&&(l[e]=0xffffffff)}if(r.array=l,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&3===r.itemSize?n=4:r.itemSize>1&&r.itemSize*l.BYTES_PER_ELEMENT%4!=0&&(n=4*Math.floor((r.itemSize*l.BYTES_PER_ELEMENT+3)/4)/l.BYTES_PER_ELEMENT),void 0!==n){let e=r.itemSize,t=new l.constructor(r.count*n);for(let i=0;i<r.count;i++)t.set(l.subarray(i*e,i*e+e),i*n);(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&(r.itemSize=n,r.array=t),l=t,s._itemSize=e,s._paddedItemSize=n}let u=l.byteLength;xE.label=r.name,xE.size=u+(4-u%4)%4,xE.usage=t,xE.mappedAtCreation=!0,a=o.createBuffer(xE),xE.reset(),new l.constructor(a.getMappedRange()).set(l),a.unmap(),s.buffer=a}}updateAttribute(e){let t=this._getBufferAttribute(e),r=this.backend,i=r.device,s=r.get(t),a=r.get(t).buffer,n=t.array,o=s._itemSize,l=s._paddedItemSize;if(void 0!==l){n=new n.constructor(t.count*l);for(let e=0;e<t.count;e++)n.set(t.array.subarray(e*o,e*o+o),e*l);(t.isStorageBufferAttribute||t.isStorageInstancedBufferAttribute)&&(t.array=n)}let d=t.updateRanges;if(0===d.length)i.queue.writeBuffer(a,0,n,0);else{let e=(0,u.iu4)(n),r=e?1:n.BYTES_PER_ELEMENT;for(let t=0,s=d.length;t<s;t++){let s,u,h=d[t];if(void 0!==l){let e=Math.floor(h.start/o),t=Math.ceil((h.start+h.count)/o)-e;s=e*l*r,u=t*l*r}else s=h.start*r,u=h.count*r;let c=s*(e?n.BYTES_PER_ELEMENT:1);i.queue.writeBuffer(a,c,n,s,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,a=this._getBufferAttribute(i),n=r.get(a);if(void 0===n){let e,t;!0===i.isInterleavedBufferAttribute?(e=i.data.stride*s,t=i.data.isInstancedInterleavedBuffer?y_.Instance:y_.Vertex):(e=i.itemSize*s,t=i.isInstancedBufferAttribute?y_.Instance:y_.Vertex,i.itemSize>1&&e%4!=0&&(e=4*Math.floor((e+3)/4))),!1===i.normalized&&(i.array.constructor===Int16Array||i.array.
483constructor===Uint16Array)&&(e=4),n={arrayStride:e,attributes:[],stepMode:t},r.set(a,n)}let o=this._getVertexFormat(i),l=!0===i.isInterleavedBufferAttribute?i.offset*s:0;n.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,t=null,r=0,i=-1){let s,a=this.backend,n=a.device,o=a.get(this._getBufferAttribute(e)).buffer,l=-1===i?o.size-r:i;if(null!==t&&t.isReadbackBuffer){let e=a.get(t);if(!0===t._mapped)throw Error("THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.");if(t._mapped=!0,void 0===e.readBufferGPU){xE.label=`${t.name}_readback`,xE.size=t.maxByteLength,xE.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,s=n.createBuffer(xE),xE.reset();let r=()=>{t.buffer=null,t._mapped=!1,s.unmap()},i=()=>{t.buffer=null,t._mapped=!1,s.destroy(),a.delete(t),t.removeEventListener("release",r),t.removeEventListener("dispose",i)};t.addEventListener("release",r),t.addEventListener("dispose",i),e.readBufferGPU=s}else s=e.readBufferGPU}else xE.label=`${e.name}_readback`,xE.size=l,xE.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,s=n.createBuffer(xE),xE.reset();xC.label=`readback_encoder_${e.name}`;let u=n.createCommandEncoder(xC);if(xC.reset(),u.copyBufferToBuffer(o,r,s,0,l),yM(n,u.finish()),await s.mapAsync(GPUMapMode.READ,0,l),null===t){let e=s.getMappedRange(0,l).slice();return s.destroy(),e}if(t.isReadbackBuffer)return t.buffer=s.getMappedRange(0,l),t;{let e=s.getMappedRange(0,l);return new Uint8Array(t).set(new Uint8Array(e)),s.destroy(),t}}_getVertexFormat(e){let t,{itemSize:r,normalized:i}=e,s=e.array.constructor,a=e.constructor;if(1===r)t=xB.get(s);else{let e=(xM.get(a)||xw.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||(0,u.z3S)("WebGPUAttributeUtils: Vertex format not supported yet."),t}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}let xF=new yB,xL=new yU,xP=new yk;class xD{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class xO{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){let t=this.backend,r=t.device,i=t.get(e);if(i.layout)return i.layout.layoutGPU;let s=this._createLayoutEntries(e),a=y(JSON.stringify(s)),n=this._bindGroupLayoutCache.get(a);return void 0===n&&(n=new xD(r.createBindGroupLayout({entries:s})),this._bindGroupLayoutCache.set(a,n)),n.usedTimes++,i.layout=n,i.layoutKey=a,n.layoutGPU}createBindings(e,t,r,i=0){let s,{backend:a}=this,n=a.get(e),o=this.createBindingsLayout(e);r>0&&(void 0===n.groups&&(n.groups=[],n.versions=[]),n.versions[r]===i&&(s=n.groups[r])),void 0===s&&(s=this.createBindGroup(e,o),r>0&&(n.groups[r]=s,n.versions[r]=i)),n.group=s}updateBinding(e){let t=this.backend,r=t.device,i=e.buffer,s=t.get(e).buffer,a=e.updateRanges;if(0===a.length)r.queue.writeBuffer(s,0,i,0);else{let e=(0,u.iu4)(i),t=e?1:i.BYTES_PER_ELEMENT,n=a[0].start;for(let o=0,l=a.length;o<l;o++){let l=a[o],u=a[o+1],d=l.start+l.count;if(void 0!==u&&u.start===d)continue;let h=n*t,c=(d-n)*t,p=h*(e?i.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(s,p,i,h,c),void 0!==u&&(n=u.start)}}}createBindGroupIndex(e,t){let r=this.backend.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=e[0];xL.label="bindingCameraIndex_"+s,xL.size=16,xL.usage=i;let a=r.createBuffer(xL);xL.reset(),r.queue.writeBuffer(a,0,e,0),xF.label="bindGroupCameraIndex_"+s,xF.layout=t,xF.entries.push({binding:0,resource:{buffer:a}});let n=r.createBindGroup(xF);return xF.reset(),n}createBindGroup(e,t){let r=this.backend,i=r.device,s=0;for(let a of(xF.label="bindGroup_"+e.name,xF.layout=t,e.bindings)){if(a.isUniformBuffer){let e=r.get(a);xF.entries.push({binding:s,resource:{buffer:e.buffer}})}else if(a.isStorageBuffer){let e=r.get(a.attribute).buffer;xF.entries.push({binding:s,resource:{buffer:e}})}else if(a.isSampledTexture){let e,t=r.get(a.texture);if(void 0!==t.externalTexture)e=i.importExternalTexture({source:t.externalTexture});else{let r=a.store?1:t.texture.mipLevelCount,i=a.store?a.mipLevel:0,s=`view-${t.texture.width}-${t.texture.height}`;if(t.texture.depthOrArrayLayers>1&&(s+=`-${t.texture.depthOrArrayLayers}`),s+=`-${r}-${i}`,void 0===(e=t[s])){let n,o=yT.All;n=a.isSampledCubeTexture?yx.Cube:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?yx.TwoDArray:a.isSampledTexture3D?yx.ThreeD:yx.TwoD,xP.aspect=o,xP.dimension=n,xP.mipLevelCount=r,xP.baseMipLevel=i,e=t[s]=t.texture.createView(xP),xP.reset()}}xF.entries.push({binding:s,resource:e})}else if(a.isSampler){let e=r.get(a);xF.entries.push({binding:s,resource:e.sampler})}s++}let a=i.createBindGroup(xF);return xF.reset(),a}_createLayoutEntries(e){let t=[],r=0;for(let i of e.bindings){let e=this.backend,s={binding:r,visibility:i.visibility};if(i.isUniformBuffer||i.isStorageBuffer){let e={};i.isStorageBuffer&&(i.visibility&ye.COMPUTE&&(i.access===M.READ_WRITE||i.access===M.WRITE_ONLY)?e.type=ym.Storage:e.type=ym.ReadOnlyStorage),s.buffer=e}else if(i.isSampledTexture&&i.store){let e={};e.format=this.backend.get(i.texture).texture.format;let t=i.access;t===M.READ_WRITE?e.access=yg.ReadWrite:t===M.WRITE_ONLY?e.access=yg.WriteOnly:e.access=yg.ReadOnly,i.texture.isArrayTexture?e.viewDimension=yx.TwoDArray:i.texture.is3DTexture&&(e.viewDimension=yx.ThreeD),s.storageTexture=e}else if(i.isSampledTexture){let t={},{primarySamples:r}=e.utils.getTextureSampleData(i.texture);if(r>1&&(t.multisampled=!0,i.texture.isDepthTexture||(t.sampleType=yb.UnfilterableFloat)),i.texture.isDepthTexture)e.compatibilityMode&&null===i.texture.compareFunction?t.sampleType=yb.UnfilterableFloat:t.sampleType=yb.Depth;else{let e=i.texture.type;e===u.Yuy?t.sampleType=yb.SInt:e===u.bkx?t.sampleType=yb.UInt:e===u.RQf&&(this.backend.hasFeature("float32-filterable")?t.sampleType=yb.Float:t.sampleType=yb.UnfilterableFloat)}i.isSampledCubeTexture?t.viewDimension=yx.Cube:i.texture.isArrayTexture||i.texture.isDataArrayTexture||i.texture.isCompressedArrayTexture?t.viewDimension=yx.TwoDArray:i.isSampledTexture3D&&(t.viewDimension=yx.ThreeD),s.texture=t}else if(i.isSampler){let t={};i.texture.isDepthTexture&&(null!==i.texture.compareFunction&&null!==i.textureNode.compareNode&&e.hasCompatibility(u.x$Y.TEXTURE_COMPARE)?t.type=yf.Comparison:t.type=yf.NonFiltering),s.sampler=t}else(0,u.z3S)(`WebGPUBindingUtils: Unsupported binding "${i}".`);t.push(s),r++}return t}deleteBindGroupData(e){let{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,0===r.layout.usedTimes&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class xI{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}class xV{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}}class xG{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}}let xk=new xV,xz=new xG,x$=new yL,xW=new yO;class xH{constructor(e){this.backend=e}
483_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){let r,{object:i,material:s,geometry:a,pipeline:n}=e,{vertexProgram:o,fragmentProgram:l}=n,d=this.backend,h=d.device,c=d.utils,p=d.get(n),m=[];for(let t of e.getBindings()){let{layoutGPU:e}=d.get(t).layout;m.push(e)}let g=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 b=this._getColorWriteMask(s),y=[];if(null!==e.context.textures){let t=e.context.textures,i=e.context.mrt;for(let e=0;e<t.length;e++){let s,a=t[e],n=c.getTextureFormatGPU(a);if(null!==i)if(!0!==this.backend.compatibilityMode){let e=i.getBlendMode(a.name);e.blending===u.pCc?s=r:e.blending!==u.XIg&&(s=this._getBlending(e))}else(0,u.mcG)("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets."),s=r;else s=r;y.push({format:n,blend:s,writeMask:b})}}else{let t=c.getCurrentColorFormat(e.context);y.push({format:t,blend:r,writeMask:b})}let x=d.get(o).module,T=d.get(l).module,_=this._getPrimitiveState(i,a,s),v=this._getDepthCompare(s),S=c.getCurrentDepthStencilFormat(e.context),N=this._getSampleCount(e.context);xz.bindGroupLayouts=m;let R=h.createPipelineLayout(xz);xz.reset(),xW.label=`renderPipeline_${s.name||s.type}_${s.id}`,xW.vertex=Object.assign({},x,{buffers:g}),xW.fragment=Object.assign({},T,{targets:y}),xW.primitive=_,xW.multisample.count=N,xW.multisample.alphaToCoverageEnabled=s.alphaToCoverage&&N>1,xW.layout=R;let A={},E=e.context.depth,C=e.context.stencil;(!0===E||!0===C)&&(!0===E&&(A.format=S,A.depthWriteEnabled=s.depthWrite,A.depthCompare=v),!0===C&&(A.stencilFront=f,A.stencilBack=f,A.stencilReadMask=s.stencilFuncMask,A.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&_.topology===b7.TriangleList&&(A.depthBias=s.polygonOffsetUnits,A.depthBiasSlopeScale=s.polygonOffsetFactor,A.depthBiasClamp=0),xW.depthStencil=A),h.pushErrorScope("validation");let w=[{program:o,module:x.module},{program:l,module:T.module}],M=xW.label;if(null===t)p.pipeline=h.createRenderPipeline(xW),xW.reset(),h.popErrorScope().then(e=>{null!==e&&(p.error=!0,(0,u.z3S)(`WebGPURenderer: Render pipeline creation failed (${M}): ${e.message}`),this._reportShaderDiagnostics(w,M))});else{let e=new Promise(async e=>{try{let e=null,t=null;try{t=h.createRenderPipelineAsync(xW)}catch(t){e=t}if(xW.reset(),null!==t)try{p.pipeline=await t}catch(t){e=t}let r=await h.popErrorScope();if(null!==r||null!==e){p.error=!0;let t=r&&r.message||e&&e.message||"unknown";(0,u.z3S)(`WebGPURenderer: Async render pipeline creation failed (${M}): ${t}`),await this._reportShaderDiagnostics(w,M)}}finally{e()}});t.push(e)}}createBundleEncoder(e,t="renderBundleEncoder"){let{utils:r,device:i}=this.backend,s=r.getCurrentDepthStencilFormat(e),a=r.getCurrentColorFormats(e),n=this._getSampleCount(e);x$.label=t,x$.colorFormats=a,x$.depthStencilFormat=s,x$.sampleCount=n;let o=i.createRenderBundleEncoder(x$);return x$.reset(),o}createComputePipeline(e,t){let r=this.backend,i=r.device,s=r.get(e.computeProgram).module,a=r.get(e),n=[];for(let e of t){let{layoutGPU:t}=r.get(e).layout;n.push(t)}let o=e.computeProgram,l=`computePipeline_${o.stage}${o.name?`_${o.name}`:""}`;i.pushErrorScope("validation"),xz.bindGroupLayouts=n;let d=i.createPipelineLayout(xz);xz.reset(),xk.label=l,xk.compute=s,xk.layout=d,a.pipeline=i.createComputePipeline(xk),xk.reset(),i.popErrorScope().then(e=>{null!==e&&(a.error=!0,(0,u.z3S)(`WebGPURenderer: Compute pipeline creation failed (${l}): ${e.message}`),this._reportShaderDiagnostics([{program:o,module:s.module}],l))})}async _reportShaderDiagnostics(e,t){for(let{program:r,module:i}of e){let e=await i.getCompilationInfo();if(0===e.messages.length)continue;let s=r.code.split("\n");for(let i of e.messages){let e=i.lineNum>0?` at line ${i.lineNum}${i.linePos>0?`:${i.linePos}`:""}`:"",a=`WebGPURenderer [${t} / ${r.stage} ${i.type}]${e}: ${i.message}`,n="";i.lineNum>0&&i.lineNum<=s.length&&(n=`
484  ${s[i.lineNum-1]}`,i.linePos>0&&(n+=`
485  ${" ".repeat(i.linePos-1)}^`)),("error"===i.type?u.z3S:u.R8M)(a+n)}}}_getBlending(e){let t,r,i=e.blending,s=e.blendSrc,a=e.blendDst,n=e.blendEquation;if(i===u.bCz){let i=null!==e.blendSrcAlpha?e.blendSrcAlpha:s,o=null!==e.blendDstAlpha?e.blendDstAlpha:a,l=null!==e.blendEquationAlpha?e.blendEquationAlpha:n;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(n)},r={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(o),operation:this._getBlendOperation(l)}}else{let s=e.premultipliedAlpha,a=(e,i,s,a)=>
485{t={srcFactor:e,dstFactor:i,operation:yh.Add},r={srcFactor:s,dstFactor:a,operation:yh.Add}};if(s)switch(i){case u.NTi:a(yd.One,yd.OneMinusSrcAlpha,yd.One,yd.OneMinusSrcAlpha);break;case u.EZo:a(yd.One,yd.One,yd.One,yd.One);break;case u.Kwu:a(yd.Zero,yd.OneMinusSrc,yd.Zero,yd.One);break;case u.EdD:a(yd.Dst,yd.OneMinusSrcAlpha,yd.Zero,yd.One)}else switch(i){case u.NTi:a(yd.SrcAlpha,yd.OneMinusSrcAlpha,yd.One,yd.OneMinusSrcAlpha);break;case u.EZo:a(yd.SrcAlpha,yd.One,yd.One,yd.One);break;case u.Kwu:(0,u.z3S)(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case u.EdD:(0,u.z3S)(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};(0,u.z3S)("WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;switch(e){case u.ojh:t=yd.Zero;break;case u.qad:t=yd.One;break;case u.f4X:t=yd.Src;break;case u.LiQ:t=yd.OneMinusSrc;break;case u.ie2:t=yd.SrcAlpha;break;case u.OuU:t=yd.OneMinusSrcAlpha;break;case u.wn6:t=yd.Dst;break;case u.aEY:t=yd.OneMinusDst;break;case u.hdd:t=yd.DstAlpha;break;case u.Nt7:t=yd.OneMinusDstAlpha;break;case u.hgQ:t=yd.SrcAlphaSaturated;break;case 211:t=yd.Constant;break;case 212:t=yd.OneMinusConstant;break;default:(0,u.z3S)("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t,r=e.stencilFunc;switch(r){case u.HPb:t=yt.Never;break;case u.sKt:t=yt.Always;break;case u.kYr:t=yt.Less;break;case u.CR7:t=yt.LessEqual;break;case u.jsO:t=yt.Equal;break;case u.TMh:t=yt.GreaterEqual;break;case u.RcT:t=yt.Greater;break;case u.klZ:t=yt.NotEqual;break;default:(0,u.z3S)("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case u.VVr:t=yp.Keep;break;case u.kqe:t=yp.Zero;break;case u.kG0:t=yp.Replace;break;case u.oVO:t=yp.Invert;break;case u.HLH:t=yp.IncrementClamp;break;case u.ROr:t=yp.DecrementClamp;break;case u.Ru$:t=yp.IncrementWrap;break;case u.fJr:t=yp.DecrementWrap;break;default:(0,u.z3S)("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case u.gO9:t=yh.Add;break;case u.FXf:t=yh.Subtract;break;case u.nST:t=yh.ReverseSubtract;break;case u.znC:t=yh.Min;break;case u.$ei:t=yh.Max;break;default:(0,u.z3S)("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){let i={};i.topology=this.backend.utils.getPrimitiveTopology(e,r),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?yn.Uint16:yn.Uint32);let s=r.side===u.hsX;return e.isMesh&&0>e.matrixWorld.determinantAffine()&&(s=!s),i.frontFace=!0===s?ys.CW:ys.CCW,i.cullMode=r.side===u.$EB?ya.None:ya.Back,i}_getColorWriteMask(e){return!0===e.colorWrite?yc.All:yc.None}_getDepthCompare(e){let t;if(!1===e.depthTest)t=yt.Always;else{let r=this.backend.parameters.reversedDepthBuffer?u.ri6[e.depthFunc]:e.depthFunc;switch(r){case u.eHc:t=yt.Never;break;case u.lGu:t=yt.Always;break;case u.brA:t=yt.Less;break;case u.xSv:t=yt.LessEqual;break;case u.U3G:t=yt.Equal;break;case u.Gwm:t=yt.GreaterEqual;break;case u.K52:t=yt.Greater;break;case u.bw0:t=yt.NotEqual;break;default:(0,u.z3S)("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class xq{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}let xj=new yU,xX=new yF,xQ=new xq;class xK extends b6{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,xQ.label=`queryset_global_timestamp_${t}`,xQ.type="timestamp",xQ.count=this.maxQueries,this.querySet=this.device.createQuerySet(xQ),xQ.reset();let i=8*this.maxQueries;xj.label=`buffer_timestamp_resolve_${t}`,xj.size=i,xj.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(xj),xj.reset(),xj.label=`buffer_timestamp_result_${t}`,xj.size=i,xj.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(xj),xj.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return(0,u.mcG)(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;let t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||0===this.currentQueryIndex||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if("unmapped"!==this.resultBuffer.mapState)return this.lastValue;let e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=8*t;this.currentQueryIndex=0,this.queryOffsets.clear();let i=this.device.createCommandEncoder(xX);i.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),i.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);let s=i.finish();if(yM(this.device,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 a=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),n={},o=[];for(let[t,r]of e){let e=t.match(/^(.*):f(\d+)$/),i=parseInt(e[2]);!1===o.includes(i)&&o.push(i),void 0===n[i]&&(n[i]=0);let s=a[r],l=a[r+1],u=Number(l-s)/1e6;this.timestamps.set(t,u),n[i]+=u}let l=n[o[o.length-1]];return this.resultBuffer.unmap(),this.lastValue=l,this.frames=o,l}catch(e){return(0,u.z3S)("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){(0,u.z3S)("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){(0,u.z3S)("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 xY{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}}class xZ{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}class xJ{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}}let x0={r:0,g:0,b:0,a:1},x1=new yU,x2=new yF,x3=new xY,x4=new xq,x5=new yV,x6=new xJ,x8=new y0,x9=new y0,x7=new yk,Te=new y5;class Tt extends bW{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new yw(this),this.attributeUtils=new xU(this),this.bindingUtils=new xO(this),this.capabilities=new xI(this),this.pipelineUtils=new xH(this),this.textureUtils=new xu(this),this.occludedResolveCache=new Map;let t="undefined"==typeof navigator||!1===/Android/.test(navigator.userAgent);this._compatibility={[u.x$Y.TEXTURE_COMPARE]:t}}async init(e){let t;await super.init(e);let r=this.parameters;if(void 0===r.device){let i={powerPreference:r.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},s="undefined"!=typeof navigator?await navigator.gpu.requestAdapter(i):null;if(null===s)throw Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");let a=Object.values(yv),n=[];for(let e of a)s.features.has(e)&&n.push(e);let o={requiredFeatures:n,requiredLimits:r.requiredLimits};t=await s.requestDevice(o)}else t=r.device;this.compatibilityMode=!t.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),t.lost.then(t=>{if("destroyed"===t.reason)return;let r={api:"WebGPU",message:t.message||"Unknown reason",reason:t.reason||null,originalEvent:t};e.onDeviceLost(r)}),t.onuncapturederror=t=>{let r=t.error,i=r&&r.constructor?r.constructor.name:"GPUError",s=r&&r.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:i,message:s,originalEvent:t})},this.device=t,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(yv.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,r=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}get context(){let e=this.renderer.getCanvasTarget(),t=this.get(e),r=t.context;if(void 0===r){let i=this.parameters;r=!0===e.isDefaultCanvasTarget&&void 0!==i.context?i.context:e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${u.sPf} webgpu`);let s=i.alpha?"premultiplied":"opaque",a=i.outputType===u.ix0?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasF
vendor: 13,185 bytes, line 485
485ormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,toneMapping:{mode:a}}),t.context=r}return r}get coordinateSystem(){return u.i7u}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,r=0,i=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,i)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),i=e.currentSamples,s=r.descriptor;if(void 0===s||r.samples!==i){if((s=new yD).colorAttachments.push(new yP),!0===e.depth||!0===e.stencil){let t=new xZ;t.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),s.depthStencilAttachment=t}let t=s.colorAttachments[0];i>0?t.view=this.textureUtils.getColorBuffer().createView():t.resolveTarget=void 0,r.descriptor=s,r.samples=i}let a=s.colorAttachments[0];return i>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),s}_isRenderCameraDepthArray(e){let t=e.camera;return e.depthTexture&&!0===e.depthTexture.isArrayTexture&&null!==t&&!0===t.isArrayCamera}_hasExternalTexture(e){let t=e.textures;if(null===t)return!1;for(let e=0;e<t.length;e++)if(!0===this.get(t[e]).externalTexture)return!0;return!1}_createExternalTextureViews(e,t){let r=[],i=e.camera;if(t.xrViewDescriptors&&null!==i&&!0===i.isArrayCamera)for(let e=0;e<t.xrViewDescriptors.length;e++)r.push({view:t.texture.createView(t.xrViewDescriptors[e]),resolveTarget:void 0,depthSlice:void 0});else r.push({view:t.texture.createView({dimension:yx.TwoD,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1}),resolveTarget:void 0,depthSlice:void 0});return r}_getRenderPassDescriptor(e,t={}){let r=e.renderTarget,i=this.get(r),s=this._hasExternalTexture(e),a=i.descriptors;(void 0===a||i.width!==r.width||i.height!==r.height||i.samples!==r.samples||s)&&(i.descriptors=a={});let n=e.getCacheKey(),o=a[n];if(void 0===o||s){let t,s=e.textures,l=[],u=this._isRenderCameraDepthArray(e);for(let i=0;i<s.length;i++){let a=this.get(s[i]);if(!0===a.externalTexture){l.push(...this._createExternalTextureViews(e,a));continue}if(x7.label=`colorAttachment_${i}`,x7.baseMipLevel=e.activeMipmapLevel,x7.mipLevelCount=1,x7.baseArrayLayer=e.activeCubeFace,x7.arrayLayerCount=1,x7.dimension=yx.TwoD,r.isRenderTarget3D)t=e.activeCubeFace,x7.baseArrayLayer=0,x7.dimension=yx.ThreeD;else if(r.isRenderTarget&&s[i].image.depth>1)if(!0===u){let t=e.camera.cameras;for(let e=0;e<t.length;e++){x7.baseArrayLayer=e,x7.arrayLayerCount=1,x7.dimension=yx.TwoD;let t=a.texture.createView(x7);l.push({view:t,resolveTarget:void 0,depthSlice:void 0})}}else x7.dimension=yx.TwoDArray;if(!0!==u){let e,r,i=a.texture.createView(x7);void 0!==a.msaaTexture?(e=a.msaaTexture.createView(),r=i):(e=i,r=void 0),l.push({view:e,resolveTarget:r,depthSlice:t})}x7.reset()}let d=[];for(let e=0;e<l.length;e++){let t=l[e],r=new yP;r.view=t.view,r.depthSlice=t.depthSlice,r.resolveTarget=t.resolveTarget,d.push(r)}if(o={textureViews:l,colorAttachments:d,descriptor:new yD},e.depth){let t=this.get(e.depthTexture);(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(x7.dimension=yx.TwoD,x7.arrayLayerCount=1,x7.baseArrayLayer=e.activeCubeFace);let r=new xZ;r.view=t.texture.createView(x7),o.depthStencilAttachment=r,x7.reset()}a[n]=o,i.width=r.width,i.height=r.height,i.samples=r.samples,i.activeMipmapLevel=e.activeMipmapLevel,i.activeCubeFace=e.activeCubeFace}let l=o.descriptor;l.reset();for(let e=0;e<o.colorAttachments.length;e++){let r=o.colorAttachments[e],i={r:0,g:0,b:0,a:1};0===e&&t.clearValue&&(i=t.clearValue),r.loadOp=t.loadOp||yi.Load,r.storeOp=t.storeOp||yr.Store,r.clearValue=i,l.colorAttachments.push(r)}return o.depthStencilAttachment&&(l.depthStencilAttachment=o.depthStencilAttachment),l}beginRender(e){let t,r,i=this.get(e),s=this.device,a=e.occlusionQueryCount;a>0&&(i.currentOcclusionQuerySet&&i.currentOcclusionQuerySet.destroy(),i.currentOcclusionQueryBuffer&&i.currentOcclusionQueryBuffer.destroy(),i.currentOcclusionQuerySet=i.occlusionQuerySet,i.currentOcclusionQueryBuffer=i.occlusionQueryBuffer,i.currentOcclusionQueryObjects=i.occlusionQueryObjects,x4.label=`occlusionQuerySet_${e.id}`,x4.type="occlusion",x4.count=a,t=s.createQuerySet(x4),x4.reset(),i.occlusionQuerySet=t,i.occlusionQueryIndex=0,i.occlusionQueryObjects=Array(a),i.lastOcclusionObject=null),r=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:yi.Load}),this.initTimestampQuery(u.v9J.RENDER,this.getTimestampUID(e),r),r.occlusionQuerySet=t;let n=r.depthStencilAttachment;if(null!==e.textures){let t=r.colorAttachments;for(let r=0;r<t.length;r++){let i=t[r];e.clearColor?(0===r?i.clearValue=e.clearColorValue:(x0.r=0,x0.g=0,x0.b=0,x0.a=1,i.clearValue=x0),i.loadOp=yi.Clear):i.loadOp=yi.Load,i.storeOp=yr.Store}}else{let t=r.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=yi.Clear):t.loadOp=yi.Load,t.storeOp=yr.Store}e.depth&&(e.clearDepth?(n.depthClearValue=e.clearDepthValue,n.depthLoadOp=yi.Clear):n.depthLoadOp=yi.Load,n.depthStoreOp=yr.Store),e.stencil&&(e.clearStencil?(n.stencilClearValue=e.clearStencilValue,n.stencilLoadOp=yi.Clear):n.stencilLoadOp=yi.Load,n.stencilStoreOp=yr.Store),x2.label="renderContext_"+e.id;let o=s.createCommandEncoder(x2);if(x2.reset(),!0===this._isRenderCameraDepthArray(e)){let t=e.camera.cameras;i.layerDescriptors&&i.layerDescriptors.length===t.length?this._updateArrayCameraLayerDescriptors(e,i,t):this._createArrayCameraLayerDescriptors(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 i.currentPass=o.beginRenderPass(r),e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e);i.descriptor=r,i.encoder=o,i.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},i.renderBundles=[]}_createArrayCameraLayerDescriptors(e,t,r,i){let s=r.depthStencilAttachment;t.layerDescriptors=[];let a=this.get(e.depthTexture);a.viewCache||(a.viewCache=[]);for(let n=0;n<i.length;n++){let i=r.colorAttachments[0],o=new yP;o.view=r.colorAttachments[n].view,o.depthSlice=i.depthSlice,o.resolveTarget=i.resolveTarget,o.loadOp=i.loadOp,o.storeOp=i.storeOp,o.clearValue=i.clearValue;let l=new yD;if(l.label=r.label,l.occlusionQuerySet=r.occlusionQuerySet,l.timestampWrites=r.timestampWrites,l.colorAttachments.push(o),r.depthStencilAttachment){let t=n;a.viewCache[t]||(x7.dimension=yx.TwoD,x7.baseArrayLayer=n,x7.arrayLayerCount=1,a.viewCache[t]=a.texture.createView(x7),x7.reset());let r=new xZ;r.view=a.viewCache[t],r.depthLoadOp=s.depthLoadOp||yi.Clear,r.depthStoreOp=s.depthStoreOp||yr.Store,r.depthClearValue=s.depthClearValue||1,e.stencil&&(r.stencilLoadOp=s.stencilLoadOp,r.stencilStoreOp=s.stencilStoreOp,r.stencilClearValue=s.stencilClearValue),l.depthStencilAttachment=r}else{let e=new xZ;e.view=s.view,e.depthLoadOp=s.depthLoadOp,e.depthStoreOp=s.depthStoreOp,e.depthClearValue=s.depthClearValue,e.depthReadOnly=s.depthReadOnly,e.stencilLoadOp=s.stencilLoadOp,e.stencilStoreOp=s.stencilStoreOp,e.stencilClearValue=s.stencilClearValue,e.stencilReadOnly=s.stencilReadOnly,l.depthStencilAttachment=e}t.layerDescriptors.push(l)}}_updateArrayCameraLayerDescriptors(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=yi.Clear):t.depthLoadOp=yi.Load),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=yi.Clear):t.stencilLoadOp=yi.Load)}}}finishRender(e){let t=this.get(e),r=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();let i=t.encoder;if(!0===this._isRenderCameraDepthArray(e)){let r=[];for(let e=0;e<t.bundleEncoders.length;e++){let i=t.bundleEncoders[e];r.push(i.finish())}for(let s=0;s<t.layerDescriptors.length;s++)if(s<r.length){let a=t.layerDescriptors[s],n=i.beginRenderPass(a);if(e.viewport){let{x:t,y:r,width:i,height:s,minDepth:a,maxDepth:o}=e.viewportValue;n.setViewport(t,r,i,s,a,o)}if(e.scissor){let{x:t,y:r,width:i,height:s}=e.scissorValue;n.setScissorRect(t,r,i,s)}n.executeBundles([r[s]]),n.end()}}else t.currentPass&&t.currentPass.end();if(r>0){let i=8*r,s=this.occludedResolveCache.get(i);void 0===s&&(x1.size=i,x1.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,s=this.device.createBuffer(x1),x1.reset(),this.occludedResolveCache.set(i,s)),x1.size=i,x1.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer(x1);x1.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,s,0),t.encoder.copyBufferToBuffer(s,0,a,0,i),t.occlusionQueryBuffer=a,this.resolveOccludedAsync(e)}if(yM(this.device,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:a,minDepth:n,maxDepth:o}=e.viewportValue;t.setViewport(r,i,s,a,n,o)}updateScissor(e){let{currentPass:t}=this.get(e),{x:r,y:i,width:s,height:a}=e.scissorValue;t.setScissorRect(r,i,s,a)}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,a,n,o=this.device,l=this.renderer,u=[];if(e){let e=this.getClearColor();x0.r=e.r,x0.g=e.g,x0.b=e.b,x0.a=e.a}if(null===i){a=l.depth,n=l.stencil;let t=this._getDefaultRenderPassDescriptor();if(e){let e=(u=t.colorAttachments)[0];e.clearValue=x0,e.loadOp=yi.Clear,e.storeOp=yr.Store}(a||n)&&(s=t.depthStencilAttachment)}else{a=i.depth,n=i.stencil;let o={loadOp:e?yi.Clear:yi.Load,clearValue:e?x0:void 0};a&&(o.depthLoadOp=t?yi.Clear:yi.Load,o.depthClearValue=t?l.getClearDepth():void 0,o.depthStoreOp=yr.Store),n&&(o.stencilLoadOp=r?yi.Clear:yi.Load,o.stencilClearValue=r?l.getClearStencil():void 0,o.stencilStoreOp=yr.Store);let d=this._getRenderPassDescriptor(i,o);u=d.colorAttachments,s=d.depthStencilAttachment}a&&s&&(t?(s.depthLoadOp=yi.Clear,s.depthClearValue=l.getClearDepth()):s.depthLoadOp=yi.Load,s.depthStoreOp=yr.Store),n&&s&&(r?(s.stencilLoadOp=yi.Clear,s.stencilClearValue=l.getClearStencil()):s.stencilLoadOp=yi.Load,s.stencilStoreOp=yr.Store),x2.label="clear";let d=o.createCommandEncoder(x2);x2.reset(),d.beginRenderPass({colorAttachments:u,depthStencilAttachment:s}).end(),yM(o,d.finish())}beginCompute(e){let t=this.get(e),r="computeGroup_"+e.id;x3.label=r,x2.label=r,this.initTimestampQuery(u.v9J.COMPUTE,this.getTimestampUID(e),x3),t.cmdEncoderGPU=this.device.createCommandEncoder(x2),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(x3),t.currentPipeline=null,x2.reset(),x3.reset()}compute(e,t,r,i,s=null){let a=this.get(t),n=this.get(e),{passEncoderGPU:o}=n,l=this.get(i).pipeline;n.currentPipeline!==l&&(o.setPipeline(l),n.currentPipeline=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.dispatchSize||t.count),s&&s.isIndirectStorageBufferAttribute){let e=this.get(s).buffer;o.dispatchWorkgroupsIndirect(e,0);return}if("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 n=Math.ceil(e/i),o=this.device.limits.maxComputeWorkgroupsPerDimension;s=[n,1,1],n>o&&(s[0]=Math.min(n,o),s[1]=Math.ceil(n/o)),a.dispatchSize=s}s=a.dispatchSize}o.dispatchWorkgroups(s[0],s[1]||1,s[2]||1)}finishCompute(e){let t=this.get(e);t.passEncoderGPU.end(),yM(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,i,s,a,n,o,l){let{object:u,material:d,context:h}=e,c=e.getIndex(),p=null!==c;l.pipeline!==i&&(o.setPipeline(i),l.pipeline=i);let m=l.bindingGroups;for(let e=0,t=s.length;e<t;e++){let t=s[e];if(m[e]!==t.id){let r=this.get(t);o.setBindGroup(e,r.group),m[e]=t.id}}if(!0===p&&l.index!==c){let e=this.get(c).buffer,t=c.array instanceof Uint16Array?yn.Uint16:yn.Uint32;o.setIndexBuffer(e,t),l.index=c}for(let e=0,t=a.length;e<t;e++){let t=a[e];if(l.attributes[e]!==t){let r=this.get(t).buffer;o.setVertexBuffer(e,r),l.attributes[e]=t}}if(!0===h.stencil&&!0===d.stencilWrite&&r.currentStencilRef!==d.stencilRef&&(o.setStencilReference(d.stencilRef),r.currentStencilRef=d.stencilRef),!0===u.isBatchedMesh){let e=u._multiDrawStarts,r=u._multiDrawCounts,i=u._multiDrawCount,s=!0===p?c.array.BYTES_PER_ELEMENT:1;d.wireframe&&(s=u.geometry.attributes.position.count>65535?4:2);for(let a=0;a<i;a++)!0===p?o.drawIndexed(r[a],1,e[a]/s,0,a):o.draw(r[a],1,e[a],a),t.update(u,r[a],1)}
vendor: 1,185 bytes, line 485
485else if(!0===p){let{vertexCount:r,instanceCount:i,firstVertex:s}=n,a=e.getIndirect();if(null!==a){let t=this.get(a).buffer,r=e.getIndirectOffset(),i=Array.isArray(r)?r:[r];for(let e=0;e<i.length;e++)o.drawIndexedIndirect(t,i[e])}else o.drawIndexed(r,i,s,0,0);t.update(u,r,i)}else{let{vertexCount:r,instanceCount:i,firstVertex:s}=n,a=e.getIndirect();if(null!==a){let t=this.get(a).buffer,r=e.getIndirectOffset(),i=Array.isArray(r)?r:[r];for(let e=0;e<i.length;e++)o.drawIndirect(t,i[e])}else o.draw(r,i,s,0);t.update(u,r,i)}}draw(e,t){let{object:r,context:i,pipeline:s}=e,a=this.get(i),n=this.get(s),o=n.pipeline;if(!0===n.error)return;let l=e.getDrawParameters();if(null===l)return;let u=e.getBindings(),d=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let s=this.get(e.camera),n=e.camera.cameras,h=e.getBindingGroup("cameraIndex");if(void 0===s.indexesGPU||s.indexesGPU.length!==n.length){let e=this.get(h),t=[],r=new Uint32Array([0,0,0,0]);for(let i=0,s=n.length;i<s;i++){r[0]=i;let{layoutGPU:s}=e.layout,a=this.bindingUtils.createBindGroupIndex(r,s);t.push(a)}s.indexesGPU=t}let c=this.renderer.getPixelRatio();for(let p=0,m=n.length;p<m;p++){let m=n[p];
vendor: 6,920 bytes, line 485
485if(r.layers.test(m.layers)){let r=m.viewport,n=a.currentPass,g=a.currentSets,f=void 0!==a.bundleEncoders;if(f){let e=a.bundleEncoders[p],t=a.bundleSets[p];n=e,g=t}if(r&&!f&&n.setViewport(Math.floor(r.x*c),Math.floor(r.y*c),Math.floor(r.width*c),Math.floor(r.height*c),i.viewportValue.minDepth,i.viewportValue.maxDepth),h&&s.indexesGPU){let e=u.indexOf(h);n.setBindGroup(e,s.indexesGPU[p]),g.bindingGroups[e]=h.id}this._draw(e,t,a,o,u,d,l,n,g)}}}else if(a.currentPass){if(void 0!==a.occlusionQuerySet){let e=a.lastOcclusionObject;e!==r&&(null!==e&&!0===e.occlusionTest&&(a.currentPass.endOcclusionQuery(),a.occlusionQueryIndex++),!0===r.occlusionTest&&(a.currentPass.beginOcclusionQuery(a.occlusionQueryIndex),a.occlusionQueryObjects[a.occlusionQueryIndex]=r),a.lastOcclusionObject=r)}this._draw(e,t,a,o,u,d,l,a.currentPass,a.currentSets)}}needsRenderUpdate(e){let t=this.get(e),{object:r,material:i}=e,s=this.utils,a=s.getSampleCountRenderContext(e.context),n=s.getCurrentColorSpace(e.context),o=s.getCurrentColorFormat(e.context),l=s.getCurrentDepthStencilFormat(e.context),u=s.getPrimitiveTopology(r,i),d=r.isMesh&&0>r.matrixWorld.determinantAffine(),h=!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!==a||t.colorSpace!==n||t.colorFormat!==o||t.depthStencilFormat!==l||t.primitiveTopology!==u||t.frontFaceCW!==d||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.sampleCount=a,t.colorSpace=n,t.colorFormat=o,t.depthStencilFormat=l,t.primitiveTopology=u,t.frontFaceCW=d,t.clippingContextCacheKey=e.clippingContextCacheKey,h=!0),h}getRenderCacheKey(e){let{object:t,material:r}=e,i=this.utils,s=e.context,a=t.isMesh&&0>t.matrixWorld.determinantAffine();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,a,i.getSampleCountRenderContext(s),i.getCurrentColorSpace(s),i.getCurrentColorFormat(s),i.getCurrentDepthStencilFormat(s),i.getPrimitiveTopology(t,r),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){return 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,t=!1){this.textureUtils.destroyTexture(e,t)}async copyTextureToBuffer(e,t,r,i,s,a){return this.textureUtils.copyTextureToBuffer(e,t,r,i,s,a)}initTimestampQuery(e,t,r){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new xK(this.device,e,2048));let i=this.timestampQueryPool[e],s=i.allocateQueriesForContext(t);x6.querySet=i.querySet,x6.beginningOfPassWriteIndex=s,x6.endOfPassWriteIndex=s+1,r.timestampWrites=x6}createNodeBuilder(e,t){return new xA(e,t)}createProgram(e){let t=this.get(e);x5.label=e.stage+(""!==e.name?`_${e.name}`:""),x5.code=e.code,t.module={module:this.device.createShaderModule(x5),entryPoint:"main"},x5.reset()}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)}createUniformBuffer(e){let t=this.get(e);if(void 0===t.buffer){let r=e.byteLength,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=[];e.visibility&ye.VERTEX&&s.push("vertex"),e.visibility&ye.FRAGMENT&&s.push("fragment"),e.visibility&ye.COMPUTE&&s.push("compute");let a=`(${s.join(",")})`;x1.label=`bindingBuffer${e.id}_${e.name}_${a}`,x1.size=r,x1.usage=i;let n=this.device.createBuffer(x1);x1.reset(),t.buffer=n}}destroyUniformBuffer(e){this.get(e).buffer.destroy(),this.delete(e)}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)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(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.delete(this.renderer.getCanvasTarget())}hasFeature(e){return void 0!==yS[e]&&(e=yS[e]),this.device.features.has(e)}
485copyTextureToTexture(e,t,r=null,i=null,s=0,a=0){let n=0,o=0,l=0,u=0,d=0,h=0,c=e.image.width,p=e.image.height,m=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,m=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,m=1)),null!==i&&(n=i.x,o=i.y,l=i.z||0),x2.label="copyTextureToTexture_"+e.id+"_"+t.id;let g=this.device.createCommandEncoder(x2);x2.reset();let f=this.get(e).texture,b=this.get(t).texture;x8.texture=f,x8.mipLevel=s,x8.origin.x=u,x8.origin.y=d,x8.origin.z=h,x9.texture=b,x9.mipLevel=a,x9.origin.x=n,x9.origin.y=o,x9.origin.z=l,Te.width=c,Te.height=p,Te.depthOrArrayLayers=m,g.copyTextureToTexture(x8,x9,Te),x8.reset(),x9.reset(),Te.reset(),yM(this.device,g.finish()),0===a&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,r){let i,s=this.get(t),a=null;a=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 n=this.get(e).texture;if(a.format!==n.format)return void(0,u.z3S)("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",a.format,n.format);if(s.currentPass?(s.currentPass.end(),i=s.encoder):(x2.label="copyFramebufferToTexture_"+e.id,i=this.device.createCommandEncoder(x2),x2.reset()),x8.texture=a,x8.origin.x=r.x,x8.origin.y=r.y,x9.texture=n,Te.width=r.z,Te.height=r.w,i.copyTextureToTexture(x8,x9,Te),x8.reset(),x9.reset(),Te.reset(),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,i),s.currentPass){let{descriptor:e}=s;for(let t=0;t<e.colorAttachments.length;t++)e.colorAttachments[t].loadOp=yi.Load;t.depth&&(e.depthStencilAttachment.depthLoadOp=yi.Load),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=yi.Load),s.currentPass=i.beginRenderPass(e),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else yM(this.device,i.finish())}hasCompatibility(e){return void 0!==this._compatibility[e]?this._compatibility[e]:super.hasCompatibility(e)}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(let e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(let e of Object.values(this.timestampQueryPool))null!==e&&e.dispose();void 0===this.parameters.device&&null!==this.device&&this.device.destroy()}}class Tr extends u.nCl{constructor(e,t,r,i,s,a){super(e,t,r,i,s,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class Ti extends u.nCl{constructor(e,t,r,i,s,a){super(e,t,r,i,s,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class Ts extends f4{constructor(){super(),this.addMaterial(l9,"MeshPhongMaterial"),this.addMaterial(dU,"MeshStandardMaterial"),this.addMaterial(dL,"MeshPhysicalMaterial"),this.addMaterial(dI,"MeshToonMaterial"),this.addMaterial(lJ,"MeshBasicMaterial"),this.addMaterial(l6,"MeshLambertMaterial"),this.addMaterial(lV,"MeshNormalMaterial"),this.addMaterial(dk,"MeshMatcapMaterial"),this.addMaterial(lw,"LineBasicMaterial"),this.addMaterial(lB,"LineDashedMaterial"),this.addMaterial(dX,"PointsMaterial"),this.addMaterial(dH,"SpriteMaterial"),this.addMaterial(dZ,"ShadowMaterial"),this.addLight(m7,u.HiM),this.addLight(fB,u.ZyN),this.addLight(fk,u.ure),this.addLight(fF,u.nCl),this.addLight(fM,u.$p8),this.addLight(fU,u.dth),this.addLight(fP,u.FZo),this.addLight(fL,Tr),this.addLight(fO,Ti),this.addToneMapping(pf,u.kyO),this.addToneMapping(pb,u.Mjd),this.addToneMapping(py,u.nNL),this.addToneMapping(pT,u.FV),this.addToneMapping(pN,u.LAk),this.addToneMapping(pR,u.aJ8)}}class Ta extends by{constructor(e={}){let t;e.forceWebGL?t=b9:(t=Tt,e.getFallback=()=>((0,u.R8M)("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new b9(e))),super(new t(e),e),this.library=new Ts,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}u.YJl,u.Qev,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.