1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9923],{351:(e,t,r)=>{r.d(t,{L6:()=>h,XB:()=>u});var i=r(75180),s=r(74872),a=r(61296),n=r(87275);let o=a.Mv.negate().reflect(s.j8),l=a.Mv.negate().refract(s.j8,n.YU),u=o.transformDirection(i.FL).toVar("reflectVector"),h=l.transformDirection(i.FL).toVar("refractVector")},1690:(e,t,r)=>{r.d(t,{t:()=>u});var i=r(57218),s=r(69707),a=r(71115),n=r(13662),o=r(51365);class l extends i.A{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,o.z3)("TSL: Invalid node added to stack.",new s.A),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 n.mqP(t);return this._currentCond=(0,a.L)(e,r),this.addToStack(this._currentCond)}ElseIf(e,t){let r=new n.mqP(t),i=(0,a.L)(e,r);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new n.mqP(e),this}Switch(e){return this._expressionNode=(0,n.mp$)(e),this}Case(...e){let t=[];if(e.length>=2)for(let r=0;r<e.length-1;r++)t.push(this._expressionNode.equal((0,n.mp$)(e[r])));else(0,o.z3)("TSL: Invalid parameter length. Case() requires at least two parameters.",new s.A);let r=e[e.length-1],i=new n.mqP(r),l=t[0];for(let e=1;e<t.length;e++)l=l.or(t[e]);let u=(0,a.L)(l,i);return null===this._currentCond?(this._currentCond=u,this.addToStack(this._currentCond)):(this._currentCond.elseNode=u,this._currentCond=u,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=(0,n.I1H)(),s=e.buildStage;(0,n.cFV)(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(0,n.cFV)(i),e.removeActiveStack(this),r}}let u=(0,n.Hmo)(l).setParameterLength(0,1)},1806:(e,t,r)=>{var i=r(57218);r(39848),r(12106),i.A},2520:(e,t,r)=>{r.d(t,{A:()=>s});var i=r(45192);let s=(0,r(13662).Fn)(e=>{let{roughness:t}=e,r=(0,i.A)(),s=t.max(.0525);return(s=s.add(r)).min(1)})},2550:(e,t,r)=>{r.d(t,{u:()=>u});var i=r(52698),s=r(51166),a=r(96310);let n=new(r(26609)).P,o=new a.I,l=new a.I;class u extends i.i{constructor(e=50,t=1,r=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*s.a5*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*s.up*this.fov);return .5*this.getFilmHeight()/e}
1getEffectiveFOV(){return 2*s.a5*Math.atan(Math.tan(.5*s.up*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,r){n.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(n.x,n.y).multiplyScalar(-e/n.z),n.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(n.x,n.y).multiplyScalar(-e/n.z)}getViewSize(e,t){return this.getViewBounds(e,o,l),t.subVectors(l,o)}setViewOffset(e,t,r,i,s,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*s.up*this.fov)/this.zoom,r=2*t,i=this.aspect*r,a=-.5*i,n=this.view;if(null!==this.view&&this.view.enabled){let e=n.fullWidth,s=n.fullHeight;a+=n.offsetX*i/e,t-=n.offsetY*r/s,i*=n.width/e,r*=n.height/s}let o=this.filmOffset;0!==o&&(a+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,t,t-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}},2704:(e,t,r)=>{r.d(t,{e:()=>H});var i=r(26609),s=r(96310),a=r(93998);let n=new i.P,o=new i.P,l=new i.P,u=new i.P,h=new i.P,d=new i.P,c=new i.P;class p{constructor(e=new i.P,t=new i.P(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,n)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,r)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=n.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(n.copy(this.origin).addScaledVector(this.direction,t),n.distanceToSquared(e))}distanceSqToSegment(e,t,r,i){let s,a,n,h;o.copy(e).add(t).multiplyScalar(.5),l.copy(t).sub(e).normalize(),u.copy(this.origin).sub(o);let d=.5*e.distanceTo(t),c=-this.direction.dot(l),p=u.dot(this.direction),m=-u.dot(l),g=u.lengthSq(),f=Math.abs(1-c*c);if(f>0)if(s=c*m-p,a=c*p-m,h=d*f,s>=0)if(a>=-h)if(a<=h){let e=1/f;s*=e,a*=e,n=s*(s+c*a+2*p)+a*(c*s+a+2*m)+g}else n=-(s=Math.max(0,-(c*(a=d)+p)))*s+a*(a+2*m)+g;else n=-(s=Math.max(0,-(c*(a=-d)+p)))*s+a*(a+2*m)+g;else a<=-h?(a=(s=Math.max(0,-(-c*d+p)))>0?-d:Math.min(Math.max(-d,-m),d),n=-s*s+a*(a+2*m)+g):a<=h?(s=0,n=(a=Math.min(Math.max(-d,-m),d))*(a+2*m)+g):(a=(s=Math.max(0,-(c*d+p)))>0?d:Math.min(Math.max(-d,-m),d),n=-s*s+a*(a+2*m)+g);else a=c>0?-d:d,n=-(s=Math.max(0,-(c*a+p)))*s+a*(a+2*m)+g;return r&&r.copy(this.origin).addScaledVector(this.direction,s),i&&i.copy(o).addScaledVector(l,a),n}intersectSphere(e,t){n.subVectors(e.center,this.origin);let r=n.dot(this.direction),i=n.dot(n)-r*r,s=e.radius*e.radius;if(i>s)return null;let a=Math.sqrt(s-i),o=r-a,l=r+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;let r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){let r=this.distanceToPlane(e);return null===r?null:this.at(r,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return!!(0===t||e.normal.dot(this.direction)*t<0)}intersectBox(e,t){let r,i,s,a,n,o,l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return(l>=0?(r=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(r=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),u>=0?(s=(e.min.y-d.y)*u,a=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,a=(e.min.y-d.y)*u),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a<i||isNaN(i))&&(i=a),h>=0?(n=(e.min.z-d.z)*h,o=(e.max.z-d.z)*h):(n=(e.max.z-d.z)*h,o=(e.min.z-d.z)*h),r>o||n>i||((n>r||r!=r)&&(r=n),(o<i||i!=i)&&(i=o),i<0)))?null:this.at(r>=0?r:i,t)}intersectsBox(e){return null!==this.intersectBox(e,n)}intersectTriangle(e,t,r,i,s){let a;h.subVectors(t,e),d.subVectors(r,e),c.crossVectors(h,d);let n=this.direction.dot(c);if(n>0){if(i)return null;a=1}else{if(!(n<0))return null;a=-1,n=-n}u.subVectors(this.origin,e);let o=a*this.direction.dot(d.crossVectors(u,d));if(o<0)return null;let l=a*this.direction.dot(h.cross(u));if(l<0||o+l>n)return null;let p=-a*u.dot(c);return p<0?null:this.at(p/n,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}var m=r(26990),g=r(84774),f=r(25756);let y=new i.P,x=new i.P,b=new i.P,v=new i.P,_=new i.P,T=new i.P,
1S=new i.P,A=new i.P,M=new i.P,w=new i.P,R=new f.I,N=new f.I,C=new f.I;class E{constructor(e=new i.P,t=new i.P,r=new i.P){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),y.subVectors(e,t),i.cross(y);let s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,r,i,s){y.subVectors(i,t),x.subVectors(r,t),b.subVectors(e,t);let a=y.dot(y),n=y.dot(x),o=y.dot(b),l=x.dot(x),u=x.dot(b),h=a*l-n*n;if(0===h)return s.set(0,0,0),null;let d=1/h,c=(l*o-n*u)*d,p=(a*u-n*o)*d;return s.set(1-c-p,p,c)}static containsPoint(e,t,r,i){return null!==this.getBarycoord(e,t,r,i,v)&&v.x>=0&&v.y>=0&&v.x+v.y<=1}static getInterpolation(e,t,r,i,s,a,n,o){return null===this.getBarycoord(e,t,r,i,v)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(s,v.x),o.addScaledVector(a,v.y),o.addScaledVector(n,v.z),o)}static getInterpolatedAttribute(e,t,r,i,s,a){return R.setScalar(0),N.setScalar(0),C.setScalar(0),R.fromBufferAttribute(e,t),N.fromBufferAttribute(e,r),C.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(R,s.x),a.addScaledVector(N,s.y),a.addScaledVector(C,s.z),a}static isFrontFacing(e,t,r,i){return y.subVectors(r,t),x.subVectors(e,t),0>y.cross(x).dot(i)}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return y.subVectors(this.c,this.b),x.subVectors(this.a,this.b),.5*y.cross(x).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return E.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return E.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,r,i,s){return E.getInterpolation(e,this.a,this.b,this.c,t,r,i,s)}containsPoint(e){return E.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return E.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let r,i,s=this.a,a=this.b,n=this.c;_.subVectors(a,s),T.subVectors(n,s),A.subVectors(e,s);let o=_.dot(A),l=T.dot(A);if(o<=0&&l<=0)return t.copy(s);M.subVectors(e,a);let u=_.dot(M),h=T.dot(M);if(u>=0&&h<=u)return t.copy(a);let d=o*h-u*l;if(d<=0&&o>=0&&u<=0)return r=o/(o-u),t.copy(s).addScaledVector(_,r);w.subVectors(e,n);let c=_.dot(w),p=T.dot(w);if(p>=0&&c<=p)return t.copy(n);let m=c*l-o*p;if(m<=0&&l>=0&&p<=0)return i=l/(l-p),t.copy(s).addScaledVector(T,i);let g=u*p-c*h;if(g<=0&&h-u>=0&&c-p>=0)return S.subVectors(n,a),i=(h-u)/(h-u+(c-p)),t.copy(a).addScaledVector(S,i);let f=1/(g+m+d);return r=m*f,i=d*f,t.copy(s).addScaledVector(_,r).addScaledVector(T,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}var F=r(2945),B=r(71497),P=r(61806);let V=new m.k,L=new p,I=new a.i,O=new i.P,D=new i.P,U=new i.P,z=new i.P,k=new i.P,G=new i.P,W=new i.P,$=new i.P;class H extends g.B{constructor(e=new P.L,t=new B.V){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let r=e[t[0]];if(void 0!==r){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=r.length;e<t;e++){let t=r[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let r=this.geometry,i=r.attributes.position,s=r.morphAttributes.position,a=r.morphTargetsRelative;t.fromBufferAttribute(i,e);let n=this.morphTargetInfluences;if(s&&n){G.set(0,0,0);for(let r=0,i=s.length;r<i;r++){let i=n[r],o=s[r];0!==i&&(k.fromBufferAttribute(o,e),a?G.addScaledVector(k,i):G.addScaledVector(k.sub(t),i))}t.add(G)}return t}raycast(e,t){let r=this.geometry,i=this.material,s=this.matrixWorld;void 0===i||(null===r.boundingSphere&&r.computeBoundingSphere(),I.copy(r.boun
1dingSphere),I.applyMatrix4(s),L.copy(e.ray).recast(e.near),!1===I.containsPoint(L.origin)&&(null===L.intersectSphere(I,O)||L.origin.distanceToSquared(O)>(e.far-e.near)**2)||(V.copy(s).invert(),L.copy(e.ray).applyMatrix4(V),(null===r.boundingBox||!1!==L.intersectsBox(r.boundingBox))&&this._computeIntersections(e,t,L)))}_computeIntersections(e,t,r){let i,s=this.geometry,a=this.material,n=s.index,o=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,c=s.drawRange;if(null!==n)if(Array.isArray(a))for(let s=0,o=d.length;s<o;s++){let o=d[s],p=a[o.materialIndex],m=Math.max(o.start,c.start),g=Math.min(n.count,Math.min(o.start+o.count,c.start+c.count));for(let s=m;s<g;s+=3)(i=j(this,p,e,r,l,u,h,n.getX(s),n.getX(s+1),n.getX(s+2)))&&(i.faceIndex=Math.floor(s/3),i.face.materialIndex=o.materialIndex,t.push(i))}else{let s=Math.max(0,c.start),o=Math.min(n.count,c.start+c.count);for(let d=s;d<o;d+=3)(i=j(this,a,e,r,l,u,h,n.getX(d),n.getX(d+1),n.getX(d+2)))&&(i.faceIndex=Math.floor(d/3),t.push(i))}else if(void 0!==o)if(Array.isArray(a))for(let s=0,n=d.length;s<n;s++){let n=d[s],p=a[n.materialIndex],m=Math.max(n.start,c.start),g=Math.min(o.count,Math.min(n.start+n.count,c.start+c.count));for(let s=m;s<g;s+=3)(i=j(this,p,e,r,l,u,h,s,s+1,s+2))&&(i.faceIndex=Math.floor(s/3),i.face.materialIndex=n.materialIndex,t.push(i))}else{let s=Math.max(0,c.start),n=Math.min(o.count,c.start+c.count);for(let o=s;o<n;o+=3)(i=j(this,a,e,r,l,u,h,o,o+1,o+2))&&(i.faceIndex=Math.floor(o/3),t.push(i))}}}function j(e,t,r,a,n,o,l,u,h,d){e.getVertexPosition(u,D),e.getVertexPosition(h,U),e.getVertexPosition(d,z);let c=function(e,t,r,i,s,a,n,o){if(null===(t.side===F.hsX?i.intersectTriangle(n,a,s,!0,o):i.intersectTriangle(s,a,n,t.side===F.hB5,o)))return null;$.copy(o),$.applyMatrix4(e.matrixWorld);let l=r.ray.origin.distanceTo($);return l<r.near||l>r.far?null:{distance:l,point:$.clone(),object:e}}(e,t,r,a,D,U,z,W);if(c){let e=new i.P;E.getBarycoord(W,D,U,z,e),n&&(c.uv=E.getInterpolatedAttribute(n,u,h,d,e,new s.I)),o&&(c.uv1=E.getInterpolatedAttribute(o,u,h,d,e,new s.I)),l&&(c.normal=E.getInterpolatedAttribute(l,u,h,d,e,new i.P),c.normal.dot(a.direction)>0&&c.normal.multiplyScalar(-1));let t={a:u,b:h,c:d,normal:new i.P,materialIndex:0};E.getNormal(D,U,z,t.normal),c.face=t,c.barycoord=e}return c}},2945:(e,t,r)=>{r.d(t,{$EB:()=>p,$_I:()=>eg,$ei:()=>M,AZd:()=>tv,BVL:()=>eQ,BXX:()=>e$,B_h:()=>e3,CR7:()=>tV,CVz:()=>eK,CWW:()=>tc,Cfg:()=>ec,Dmk:()=>eN,EZo:()=>f,EdD:()=>x,FFZ:()=>tj,FV:()=>Q,FXf:()=>T,Fn:()=>tn,GJx:()=>eo,GWd:()=>eB,Gwm:()=>G,H23:()=>to,HIg:()=>eF,HLH:()=>tw,HO_:()=>td,HPb:()=>tF,HXV:()=>eq,IE4:()=>ek,IjV:()=>t_,Jnc:()=>n,K52:()=>W,KDk:()=>eZ,KLL:()=>tb,KRh:()=>j,Kef:()=>tu,Kwu:()=>y,LAk:()=>J,LiQ:()=>C,Mjd:()=>Y,NTi:()=>g,NZq:()=>ef,Nt7:()=>P,Nz6:()=>eG,OUM:()=>ey,Om:()=>en,OtU:()=>e0,OuU:()=>F,QP0:()=>l,Qrf:()=>e4,ROr:()=>tR,RQf:()=>eS,RcT:()=>tL,Riy:()=>eY,Ru$:()=>tN,RyA:()=>h,S$4:()=>ta,TMh:()=>tO,TdN:()=>tK,TiK:()=>tG,TkQ:()=>eD,U3G:()=>k,UTZ:()=>et,V3x:()=>eR,VGF:()=>eU,VT0:()=>eL,VVr:()=>tA,Vb5:()=>a,Vnu:()=>tX,VxR:()=>tx,W9U:()=>tl,WNZ:()=>s,Wew:()=>eM,Wk7:()=>u,XG_:()=>th,XIg:()=>m,XrR:()=>q,Yuy:()=>e_,ZQM:()=>eI,Zr2:()=>ty,_QJ:()=>e7,a5J:()=>e9,aEY:()=>L,aJ8:()=>ee,agE:()=>tq,amv:()=>tU,bC7:()=>tr,bCz:()=>b,bI3:()=>tp,bTm:()=>o,bkx:()=>eT,brA:()=>U,bw0:()=>$,c90:()=>ez,cHt:()=>ev,caT:()=>H,czI:()=>e5,dcC:()=>eV,eHc:()=>O,eoi:()=>tW,er$:()=>tf,f4X:()=>N,fBL:()=>eb,fJr:()=>tC,gJ2:()=>ew,gO9:()=>_,gWB:()=>tH,gZr:()=>eJ,ghU:()=>el,hB5:()=>d,hdd:()=>B,hgQ:()=>I,hsX:()=>c,hxR:()=>eh,hy7:()=>er,i7u:()=>tY,ie2:()=>E,ix0:()=>eA,jR7:()=>eW,jSS:()=>e1,jf0:()=>tg,jsO:()=>tP,jzd:()=>t$,k6Q:()=>eH,k6q:()=>ep,kG0:()=>tM,kO0:()=>tk,kRr:()=>em,kTW:()=>eu,kTp:()=>ej,kYr:()=>tB,klZ:()=>tI,kqe:()=>tS,kyO:()=>K,lGu:()=>D,lyL:()=>tt,nNL:()=>Z,nST:()=>S,oVO:()=>tE,ojh:()=>w,ojs:()=>ts,pBf:()=>eX,pCc:()=>v,pHI:()=>ed,pO5:()=>tT,paN:()=>eO,psI:()=>e8,qa3:()=>e2,qad:()=>R,rSH:()=>e6,sKt:()=>tD,sPf:()=>i,tJf:()=>ex,uB5:()=>te,uV5:()=>ea,v9J:()=>tZ,vim:()=>tz,vyJ:()=>tm,wfO:()=>es,wn6:()=>V,wrO:()=>eE,x$Y:()=>tQ,xFO:()=>ei,xSv:()=>z,y3Z:()=>ti,yT7:()=>eC,y_p:()=>X,zdS:()=>eP,znC:()=>A});let i="185",s=0,a=1,n=2,o=0,l=1,u=2,h=3,d=0,c=1,p=2,m=0,g=1,f=2,y=3,x=4,b=5,v=6,_=100,T=101,S=102,A=103,M=104,w=200,R=201,N=202,C=203,E=204,F=205,B=206,P=207,V=208,L=209,I=210,O=0,D=1,U=2,z
1=3,k=4,G=5,W=6,$=7,H=0,j=1,q=2,X=0,K=1,Y=2,Z=3,Q=4,J=6,ee=7,et=300,er=301,ei=302,es=303,ea=304,en=306,eo=1e3,el=1001,eu=1002,eh=1003,ed=1004,ec=1005,ep=1006,em=1007,eg=1008,ef=1008,ey=1009,ex=1010,eb=1011,ev=1012,e_=1013,eT=1014,eS=1015,eA=1016,eM=1017,ew=1018,eR=1020,eN=35902,eC=35899,eE=1021,eF=1022,eB=1023,eP=1026,eV=1027,eL=1028,eI=1029,eO=1030,eD=1031,eU=1032,ez=1033,ek=33776,eG=33777,eW=33778,e$=33779,eH=35840,ej=35841,eq=35842,eX=35843,eK=36196,eY=37492,eZ=37496,eQ=37488,eJ=37489,e0=37490,e1=37491,e2=37808,e3=37809,e5=37810,e6=37811,e4=37812,e8=37813,e9=37814,e7=37815,te=37816,tt=37817,tr=37818,ti=37819,ts=37820,ta=37821,tn=36492,to=36494,tl=36495,tu=36283,th=36284,td=36285,tc=36286,tp=0,tm=1,tg="",tf="srgb",ty="srgb-linear",tx="linear",tb="srgb",tv="",t_="rg",tT="ga",tS=0,tA=7680,tM=7681,tw=7682,tR=7683,tN=34055,tC=34056,tE=5386,tF=512,tB=513,tP=514,tV=515,tL=516,tI=517,tO=518,tD=519,tU=512,tz=513,tk=514,tG=515,tW=516,t$=517,tH=518,tj=519,tq=35044,tX=35048,tK=2e3,tY=2001,tZ={COMPUTE:"compute",RENDER:"render"},tQ={TEXTURE_COMPARE:"depthTextureCompare"}},3443:(e,t,r)=>{r.d(t,{cr:()=>u});var i=r(12106),s=r(74872),a=r(71440),n=r(56169),o=r(5542);let l=(0,i.Fn)(([e,t],r)=>{let i=e.mul(a.km.w).xyz;return"NORMAL"===r.subBuildFn&&!0!==r.isFlatShading()&&(i=i.toVarying(t)),i}).once(["NORMAL"]),u=(0,i.Fn)(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?l(s.j8.cross(a.bW),"v_bitangentView").normalize():n.p,!0!==e.isFlatShading()&&(t=(0,o.Mg)(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView")},4470:(e,t,r)=>{r.d(t,{A:()=>n,d:()=>o});var i=r(57218),s=r(12106);class a extends i.A{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 n=a,o=(0,s.Hm)(a).setParameterLength(1,2)},5032:(e,t,r)=>{r.d(t,{Q:()=>c});var i=r(5092),s=r(74872),a=r(66406),n=r(13662),o=r(2945),l=r(5542),u=r(86467),h=r(51365);class d extends i.A{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=o.bI3,this.unpackNormalMode=o.AZd}setup(e){let{normalMapType:t,scaleNode:r,unpackNormalMode:i}=this,d=this.node.mul(2).sub(1);if(t===o.bI3?i===o.IjV?d=(0,u.kh)(d.xy):i===o.pO5?d=(0,u.kh)(d.yw):i!==o.AZd&&(0,h.z3)(`THREE.NodeMaterial: Unexpected unpack normal mode: ${i}`):i!==o.AZd&&(0,h.z3)(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${i}'`),null!==r){let t=r;!0===e.isFlatShading()&&(t=(0,l.Mg)(t)),d=(0,n.eR5)(d.xy.mul(t),d.z)}let c=null;return t===o.vyJ?c=(0,s.I9)(d):t===o.bI3?c=a.d$.mul(d).normalize():((0,h.z3)(`NodeMaterial: Unsupported normal map type: ${t}`),c=s.j8),c}}let c=(0,n.Hmo)(d).setParameterLength(1,2)},5092:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(57218);class s extends i.A{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)}}let a=s},5542:(e,t,r)=>{r.d(t,{Mg:()=>u,hG:()=>l});var i=r(57218),s=r(13662),a=r(2945);class n extends i.A{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===a.hsX?"false":e.getFrontFacing()}}let o=(0,s.DSt)(n),l=(0,s.fVC)(o).mul(2).sub(1),u=(0,s.Fn)(([e],{material:t})=>{let r=t.side;return r===a.hsX?e=e.mul(-1):r===a.$EB&&(e=e.mul(l)),e})},5939:(e,t,r)=>{var i=r(5092);r(12106);class s extends i.A{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===s.SUBGROUP_ELECT?"bool":t===s.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){let r=this.method,i=this.getNodeType(e),a=this.getInputType(e),n=this.aNode,o=this.bNode,l=[];if(r===s.SUBGROUP_BROADCAST||r===s.SUBGROUP_SHUFFLE||r===s.QUAD_BROADCAST){let t=o.getNodeType(e);l.push(n.build(e,i),o.build(e,"float"===t?"int":i))}else r===s.SUBGROUP_SHUFFLE_XOR||r===s.SUBGROUP_SHUFFLE_DOWN||r===s.SUBGROUP_SHUFFLE_UP?l.push(n.build(e,i),o.build(e,"uint")):(null!==n&&l.push(n.build(e,a)),null!==o&&l.push(o.build(e,a)));let u=0===l.length?"()":`( ${l.join(", ")} )`;return e.format(`${e.getMethod(r,i)}${u}`,i,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}s.SUBGROUP_ELECT="subgroupElect",s.SUBGROUP_BALLOT="subgroupBallot",s.SUBGROUP_ADD="subgroupAdd",s.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",s.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",s.SUBGROUP_MUL="subgroupMul",s.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",s.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",s.SUBGROUP_AND="subgroupAnd",s.SUBGROUP_OR="subgroupOr",s.SUBGROUP_XOR="subgroupXor",s.SUBGROUP_MIN="subgroupMin",s.SUBGROUP_MAX="subgroupMax",s.SUBGROUP_ALL="subgroupAll",s.SUBGROUP_ANY="subgroupAny",s.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",s.QUAD_SWAP_X="quadSwapX",s.QUAD_SWAP_Y="quadSwapY",s.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",s.SUBGROUP_BROADCAST="subgroupBroadcast",s.SUBGROUP_SHUFFLE="subgroupShuffle",s.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",s.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",s.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",s.QUAD_BROADCAST="quadBroadcast"},5972:(e,t,r)=>{r.d(t,{A:()=>i});let i=(0,r(13662).Fn)(({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))})},6293:(e,t,r)=>{r.d(t,{A:()=>a,r:()=>n});var i=r(61114);class s extends i.A{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 a=s,n=(e,t,r)=>new s(e,t,r)},6441:(e,t,r)=>{var i=r(30617),s=r(12106);class a extends i.Ay{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}}(0,s.mV)("overrideNode",(e,t,r)=>(function(e,t=null,r=null){if(t&&t.isNode){let e=t;t=()=>e}return new a(new Map([[e,t]]),r)})(t,r,e)),(0,s.mV)("overrideNodes",(e,t)=>(function(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 a(r,t)})(t,e))},6526:(e,t,r)=>{r.d(t,{rYl:()=>a.rYl,Cx3:()=>A,wqm:()=>M,pXN:()=>w,KzA:()=>p.Kz,yWT:()=>a.yWT,gnS:()=>a.gnS,Rzx:()=>b.Rz,WND:()=>E,y4m:()=>a.y4m,rYY:()=>F,OcF:()=>a.OcF,jhA:()=>a.jhA,SPz:()=>c.SP,arf:()=>y.ar,vFZ:()=>P.v,pot:()=>m.po,y17:()=>B.y,flI:()=>C,irg:()=>v.ir,sxC:()=>i.sx,m11:()=>g.m1,F8e:()=>a.F8e,PMw:()=>a.PMw,wHr:()=>x.wH,PiW:()=>s.P,uv:()=>f.uv,ZcS:()=>a.ZcS,eR5:()=>a.eR5,lnd:()=>a.lnd}),r(83815),r(50803),r(64994),r(15842),r(94531),r(30617),r(6441),r(89670),r(30573),r(21387),r(1690),r(68987);var i=r(24481),s=r(61114);r(87954),r(33962),r(89976),r(78879),r(29335);var a=r(13662),n=r(98121),o=r(81951);r(29950),r(59759);var l=r(30710);let u=(0,a.Fn)(([e])=>e.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),h=(0,a.Fn)(([e])=>(0,a.eR5)(u(e.z.add(u(e.y.mul(1)))),u(e.z.add(u(e.x.mul(1)))),u(e.y.add(u(e.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",input
1s:[{name:"p",type:"vec3"}]});(0,a.Fn)(([e,t,r])=>{let i=(0,a.eR5)(e).toVar(),s=(0,a.fVC)(1.4).toVar(),n=(0,a.fVC)(0).toVar(),o=(0,a.eR5)(i).toVar();return(0,l.FZ)({start:(0,a.fVC)(0),end:(0,a.fVC)(3),type:"float",condition:"<="},()=>{let e=(0,a.eR5)(h(o.mul(2))).toVar();i.addAssign(e.add(r.mul((0,a.fVC)(.1).mul(t)))),o.mulAssign(1.8),s.mulAssign(1.5),i.mulAssign(1.2);let l=(0,a.fVC)(u(i.z.add(u(i.x.add(u(i.y)))))).toVar();n.addAssign(l.div(s)),o.addAssign(.14)}),n}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]}),r(57641);var d=r(92222);r(45605),r(29646),r(86467),r(97553),r(89039);var c=r(27300),p=r(75180),m=r(61296),g=r(96621);r(64139),r(82196);var f=r(39848),y=r(74872),x=r(40786);r(56288),r(82590),r(33738),r(1806),r(80904),r(66406),r(8926),r(79699),r(61046),r(3443),r(19793),r(6293),r(96798),r(7176);var b=r(86389);r(88722),r(55301),r(44342),r(87275),r(90083),r(98469),r(46836),r(7439),r(84552),r(58955),r(77168);var v=r(14508);r(351),r(44268);var _=r(2945),T=r(26990);let S=new T.k,A=(0,a.PiW)(0).setGroup(i.sx).onRenderUpdate(({scene:e})=>e.backgroundBlurriness),M=(0,a.PiW)(1).setGroup(i.sx).onRenderUpdate(({scene:e})=>e.backgroundIntensity),w=(0,a.PiW)(new T.k).setGroup(i.sx).onRenderUpdate(({scene:e})=>{let t=e.background;return null!==t&&t.isTexture&&t.mapping!==_.UTZ||e.backgroundNode&&e.backgroundNode.isNode?S.makeRotationFromEuler(e.backgroundRotation).transpose():S.identity(),S});r(15024),r(70215),r(71440),r(8227),r(37989),r(29276),r(92548);var R=r(12106);function N(e){let t,r=e.context.getViewZ;return void 0!==r&&(t=r(this)),(t||m.tX.z).negate()}(0,R.Fn)(([e,t])=>(0,o.jk)(1,e.oneMinus().div(t)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),(0,R.Fn)(([e,t])=>(0,o.jk)(e.div(t.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),(0,R.Fn)(([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),(0,R.Fn)(([e,t])=>(0,o.jh)(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),(0,o.PM)(.5,e))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),(0,R.Fn)(([e,t])=>{let r=t.a.add(e.a.mul(t.a.oneMinus()));return(0,R.ln)(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"}]}),r(66133),r(50067),r(55398),r(5542),r(5032),r(57123),r(99769),r(95538),r(37537),r(7264),r(63300),r(29892),r(20407),r(66318),r(4470),r(87801),r(94548),r(95080);let C=(0,a.Fn)(([e,t],r)=>{let i=N(r);return(0,o.TF)(e,t,i)}),E=(0,a.Fn)(([e],t)=>{let r=N(t);return e.mul(e,r,r).negate().exp().oneMinus()});(0,a.Fn)(([e,t],r)=>{let i=N(r),s=t.sub(m.MI.y).max(0).toConst().mul(i).toConst();return e.mul(e,s,s).negate().exp().oneMinus()});let F=(0,a.Fn)(([e,t])=>(0,a.lnd)(t.toFloat().mix(a.CGW.rgb,e.toVec3()),a.CGW.a));var B=r(33696);r(39651),r(28350),r(88737),r(39106),r(69247),r(5939),r(48214),r(31450),r(24222),r(67850),r(56759),r(61989),r(41601),r(83861);var P=r(91752);r(46362),(0,a.Fn)(([e=(0,f.uv)()],{renderer:t,material:r})=>{let i,s=(0,o.DL)(e.mul(2).sub(1));if(r.alphaToCoverage&&t.currentSamples>0){let e=(0,a.fVC)(s.fwidth()).toVar();i=(0,o.TF)(e.oneMinus(),e.add(1),s).oneMinus()}else i=(0,a.Ltv)(s.greaterThan(1),0,1);return i});var V=r(71115);let L=(0,a.Fn)(([e,t,r])=>{let i=(0,a.fVC)(r).toVar(),s=(0,a.fVC)(t).toVar(),n=(0,a.lcY)(e).toVar();return(0,V.L)(n,s,i).uniformFlow()}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),I=(0,a.Fn)(([e,t])=>{let r=(0,a.lcY)(t).toVar(),i=(0,a.fVC)(e).toVar();return(0,V.L)(r,i.negate(),i).uniformFlow()}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),O=(0,a.Fn)(([e])=>{let t=(0,a.fVC)(e).toVar();return(0,a.Whr)((0,o.RI)(t))}
1).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),D=(0,a.Fn)(([e,t])=>{let r=(0,a.fVC)(e).toVar();return t.assign(O(r)),r.sub((0,a.fVC)(t))}),U=(0,a.Fn)(([e,t,r,i,s,o])=>{let l=(0,a.fVC)(o).toVar(),u=(0,a.fVC)(s).toVar(),h=(0,a.fVC)(i).toVar(),d=(0,a.fVC)(r).toVar(),c=(0,a.fVC)(t).toVar(),p=(0,a.fVC)(e).toVar(),m=(0,a.fVC)((0,n.jb)(1,u)).toVar();return(0,n.jb)(1,l).mul(p.mul(m).add(c.mul(u))).add(l.mul(d.mul(m).add(h.mul(u))))}).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"}]}),z=(0,a.Fn)(([e,t,r,i,s,o])=>{let l=(0,a.fVC)(o).toVar(),u=(0,a.fVC)(s).toVar(),h=(0,a.eR5)(i).toVar(),d=(0,a.eR5)(r).toVar(),c=(0,a.eR5)(t).toVar(),p=(0,a.eR5)(e).toVar(),m=(0,a.fVC)((0,n.jb)(1,u)).toVar();return(0,n.jb)(1,l).mul(p.mul(m).add(c.mul(u))).add(l.mul(d.mul(m).add(h.mul(u))))}).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"}]}),k=(0,d.f)([U,z]),G=(0,a.Fn)(([e,t,r,i,s,o,l,u,h,d,c])=>{let p=(0,a.fVC)(c).toVar(),m=(0,a.fVC)(d).toVar(),g=(0,a.fVC)(h).toVar(),f=(0,a.fVC)(u).toVar(),y=(0,a.fVC)(l).toVar(),x=(0,a.fVC)(o).toVar(),b=(0,a.fVC)(s).toVar(),v=(0,a.fVC)(i).toVar(),_=(0,a.fVC)(r).toVar(),T=(0,a.fVC)(t).toVar(),S=(0,a.fVC)(e).toVar(),A=(0,a.fVC)((0,n.jb)(1,g)).toVar(),M=(0,a.fVC)((0,n.jb)(1,m)).toVar();return(0,a.fVC)((0,n.jb)(1,p)).toVar().mul(M.mul(S.mul(A).add(T.mul(g))).add(m.mul(_.mul(A).add(v.mul(g))))).add(p.mul(M.mul(b.mul(A).add(x.mul(g))).add(m.mul(y.mul(A).add(f.mul(g))))))}).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"}]}),W=(0,a.Fn)(([e,t,r,i,s,o,l,u,h,d,c])=>{let p=(0,a.fVC)(c).toVar(),m=(0,a.fVC)(d).toVar(),g=(0,a.fVC)(h).toVar(),f=(0,a.eR5)(u).toVar(),y=(0,a.eR5)(l).toVar(),x=(0,a.eR5)(o).toVar(),b=(0,a.eR5)(s).toVar(),v=(0,a.eR5)(i).toVar(),_=(0,a.eR5)(r).toVar(),T=(0,a.eR5)(t).toVar(),S=(0,a.eR5)(e).toVar(),A=(0,a.fVC)((0,n.jb)(1,g)).toVar(),M=(0,a.fVC)((0,n.jb)(1,m)).toVar();return(0,a.fVC)((0,n.jb)(1,p)).toVar().mul(M.mul(S.mul(A).add(T.mul(g))).add(m.mul(_.mul(A).add(v.mul(g))))).add(p.mul(M.mul(b.mul(A).add(x.mul(g))).add(m.mul(y.mul(A).add(f.mul(g))))))}).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"}]}),$=(0,d.f)([G,W]),H=(0,a.Fn)(([e,t,r])=>{let i=(0,a.fVC)(r).toVar(),s=(0,a.fVC)(t).toVar(),o=(0,a.Hdr)(e).toVar(),l=(0,a.Hdr)(o.bitAnd((0,a.Hdr)(7))).toVar(),u=(0,a.fVC)(L(l.lessThan((0,a.Hdr)(4)),s,i)).toVar(),h=(0,a.fVC)((0,n.lK)(2,L(l.lessThan((0,a.Hdr)(4)),i,s))).toVar();return I(u,(0,a.lcY)(l.bitAnd((0,a.Hdr)(1)))).add(I(h,(0,a.lcY)(l.bitAnd((0,a.Hdr)(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),j=(0,a.Fn)(([e,t,r,i])=>{let s=(0,a.fVC)(i).toVar(),n=(0,a.fVC)(r).toVar(),o=(0,a.fVC)(t).toVar(),l=(0,a.Hdr)(e).toVar(),u=(0,a.Hdr)(l.bitAnd((0,a.Hdr)(15))).toVar(),h=(0,a.fVC)(L(u.lessThan((0,a.Hdr)(8)),o,n)).toVar(),d=(0,a.fVC)(L(u.lessThan((0,a.Hdr)(4)),n,L(u.equal((0,a.Hdr)(12)).or(u.equal((0,a.Hdr)(14))),o,s))).toVar();return I(h,(0,a.lcY)(u.bitAnd((0,a.Hdr)(1)))).add(I(d,(0,a.lcY)(u.bitAnd((0,a.Hdr)(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"}]}),q=(0,d.f)([H,j]),X=(0,a.Fn)(([e,t,r])=>{let i=(0,a.fVC)(r).toVar(),s=(0,a.fVC)(t).toVar(),n=(0,a.VN6)(e).toVar();return(0,a.eR5)(q(n.x,s,i),q(n.y,s,i),q(n.z,s,i))}
1).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),K=(0,a.Fn)(([e,t,r,i])=>{let s=(0,a.fVC)(i).toVar(),n=(0,a.fVC)(r).toVar(),o=(0,a.fVC)(t).toVar(),l=(0,a.VN6)(e).toVar();return(0,a.eR5)(q(l.x,o,n,s),q(l.y,o,n,s),q(l.z,o,n,s))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),Y=(0,d.f)([X,K]),Z=(0,a.Fn)(([e])=>{let t=(0,a.fVC)(e).toVar();return(0,n.lK)(.6616,t)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),Q=(0,a.Fn)(([e])=>{let t=(0,a.fVC)(e).toVar();return(0,n.lK)(.982,t)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),J=(0,a.Fn)(([e])=>{let t=(0,a.eR5)(e).toVar();return(0,n.lK)(.6616,t)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),ee=(0,d.f)([Z,J]),et=(0,a.Fn)(([e])=>{let t=(0,a.eR5)(e).toVar();return(0,n.lK)(.982,t)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),er=(0,d.f)([Q,et]),ei=(0,a.Fn)(([e,t])=>{let r=(0,a.Whr)(t).toVar(),i=(0,a.Hdr)(e).toVar();return i.shiftLeft(r).bitOr(i.shiftRight((0,a.Whr)(32).sub(r)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),es=(0,a.Fn)(([e,t,r])=>{e.subAssign(r),e.bitXorAssign(ei(r,(0,a.Whr)(4))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(ei(e,(0,a.Whr)(6))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(ei(t,(0,a.Whr)(8))),t.addAssign(e),e.subAssign(r),e.bitXorAssign(ei(r,(0,a.Whr)(16))),r.addAssign(t),t.subAssign(e),t.bitXorAssign(ei(e,(0,a.Whr)(19))),e.addAssign(r),r.subAssign(t),r.bitXorAssign(ei(t,(0,a.Whr)(4))),t.addAssign(e)}),ea=(0,a.Fn)(([e,t,r])=>{let i=(0,a.Hdr)(r).toVar(),s=(0,a.Hdr)(t).toVar(),n=(0,a.Hdr)(e).toVar();return i.bitXorAssign(s),i.subAssign(ei(s,(0,a.Whr)(14))),n.bitXorAssign(i),n.subAssign(ei(i,(0,a.Whr)(11))),s.bitXorAssign(n),s.subAssign(ei(n,(0,a.Whr)(25))),i.bitXorAssign(s),i.subAssign(ei(s,(0,a.Whr)(16))),n.bitXorAssign(i),n.subAssign(ei(i,(0,a.Whr)(4))),s.bitXorAssign(n),s.subAssign(ei(n,(0,a.Whr)(14))),i.bitXorAssign(s),i.subAssign(ei(s,(0,a.Whr)(24))),i}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),en=(0,a.Fn)(([e])=>{let t=(0,a.Hdr)(e).toVar();return(0,a.fVC)(t).div((0,a.fVC)((0,a.Hdr)((0,a.Whr)(0xffffffff))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),eo=(0,a.Fn)(([e])=>{let t=(0,a.fVC)(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"}]}),el=(0,a.Fn)(([e])=>{let t=(0,a.Whr)(e).toVar(),r=(0,a.Hdr)((0,a.Hdr)(1)).toVar(),i=(0,a.Hdr)((0,a.Hdr)((0,a.Whr)(0xdeadbeef)).add(r.shiftLeft((0,a.Hdr)(2))).add((0,a.Hdr)(13))).toVar();return ea(i.add((0,a.Hdr)(t)),i,i)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),eu=(0,a.Fn)(([e,t])=>{let r=(0,a.Whr)(t).toVar(),i=(0,a.Whr)(e).toVar(),s=(0,a.Hdr)((0,a.Hdr)(2)).toVar(),n=(0,a.Hdr)().toVar(),o=(0,a.Hdr)().toVar(),l=(0,a.Hdr)().toVar();return n.assign(o.assign(l.assign((0,a.Hdr)((0,a.Whr)(0xdeadbeef)).add(s.shiftLeft((0,a.Hdr)(2))).add((0,a.Hdr)(13))))),n.addAssign((0,a.Hdr)(i)),o.addAssign((0,a.Hdr)(r)),ea(n,o,l)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),eh=(0,a.Fn)(([e,t,r])=>{let i=(0,a.Whr)(r).toVar(),s=(0,a.Whr)(t).toVar(),n=(0,a.Whr)(e).toVar(),o=(0,a.Hdr)((0,a.Hdr)(3)).toVar(),l=(0,a.Hdr)().toVar(),u=(0,a.Hdr)().toVar(),h=(0,a.Hdr)().toVar();return l.assign(u.assign(h.assign((0,a.Hdr)((0,a.Whr)(0xdeadbeef)).add(o.shiftLeft((0,a.Hdr)(2))).add((0,a.Hdr)(13))))),l.addAssign((0,a.Hdr)(n)),u.addAssign((0,a.Hdr)(s)),h.addAssign((0,a.Hdr)(i)),ea(l,u,h)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ed=(0,a.Fn)(([e,t,r,i])=>{let s=(0,a.Whr)(i).toVar(),n=(0,a.Whr)(r).toVar(),o=(0,a.Whr)(t).toVar(),l=(0,a.Whr)(e).toVar(),u=(0,a.Hdr)((0,a.Hdr)(4)).toVar(),h=(0,a.Hdr)().toVar(),d=(0,a.Hdr)().toVar(),c=(0,a.Hdr)().toVar();return h.assign(d.assign(c.assign((0,a.Hdr)((0,a.Whr)(0xdeadbeef)).add(u.shiftLeft((0,a.Hdr)(2))).add((0,a.Hdr)(13))))),h.addAssign((0,a.Hdr)(l)),d.addAssign((0,a.Hdr)(o)),c.addAssign((0,a.Hdr)(n)),es(h,d,c),h.addAssign((0,a.Hdr)(s)),ea(h,d,c)}).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"}]}),ec=(0,a.Fn)(([e,t,r,i,s])=>{let n=(0,a.Whr)(s).toVar(),o=(0,a.Whr)(i).toVar(),l=(0,a.Whr)(r).toVar(),u=(0,a.Whr)(t).toVar(),h=(0,a.Whr)(e).toVar(),d=(0,a.Hdr)((0,a.Hdr)(5)).toVar(),c=(0,a.Hdr)().toVar(),p=(0,a.Hdr)().toVar(),m=(0,a.Hdr)().toVar();return c.assign(p.assign(m.assign((0,a.Hdr)((0,a.Whr)(0xdeadbeef)).add(d.shiftLeft((0,a.Hdr)(2))).add((0,a.Hdr)(13))))),c.addAssign((0,a.Hdr)(h)),p.addAssign((0,a.Hdr)(u)),m.addAssign((0,a.Hdr)(l)),es(c,p,m),c.addAssign((0,a.Hdr)(o)),p.addAssign((0,a.Hdr)(n)),ea(c,p,m)}).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"}]}),ep=(0,d.f)([el,eu,eh,ed,ec]),em=(0,a.Fn)(([e,t])=>{let r=(0,a.Whr)(t).toVar(),i=(0,a.Whr)(e).toVar(),s=(0,a.Hdr)(ep(i,r)).toVar(),n=(0,a.VN6)().toVar();return n.x.assign(s.bitAnd((0,a.Whr)(255))),n.y.assign(s.shiftRight((0,a.Whr)(8)).bitAnd((0,a.Whr)(255))),n.z.assign(s.shiftRight((0,a.Whr)(16)).bitAnd((0,a.Whr)(255))),n}
1).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),eg=(0,a.Fn)(([e,t,r])=>{let i=(0,a.Whr)(r).toVar(),s=(0,a.Whr)(t).toVar(),n=(0,a.Whr)(e).toVar(),o=(0,a.Hdr)(ep(n,s,i)).toVar(),l=(0,a.VN6)().toVar();return l.x.assign(o.bitAnd((0,a.Whr)(255))),l.y.assign(o.shiftRight((0,a.Whr)(8)).bitAnd((0,a.Whr)(255))),l.z.assign(o.shiftRight((0,a.Whr)(16)).bitAnd((0,a.Whr)(255))),l}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ef=(0,d.f)([em,eg]),ey=(0,a.Fn)(([e])=>{let t=(0,a.ZcS)(e).toVar(),r=(0,a.Whr)().toVar(),i=(0,a.Whr)().toVar(),s=(0,a.fVC)(D(t.x,r)).toVar(),n=(0,a.fVC)(D(t.y,i)).toVar(),o=(0,a.fVC)(eo(s)).toVar(),l=(0,a.fVC)(eo(n)).toVar();return ee((0,a.fVC)(k(q(ep(r,i),s,n),q(ep(r.add((0,a.Whr)(1)),i),s.sub(1),n),q(ep(r,i.add((0,a.Whr)(1))),s,n.sub(1)),q(ep(r.add((0,a.Whr)(1)),i.add((0,a.Whr)(1))),s.sub(1),n.sub(1)),o,l)).toVar())}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ex=(0,a.Fn)(([e])=>{let t=(0,a.eR5)(e).toVar(),r=(0,a.Whr)().toVar(),i=(0,a.Whr)().toVar(),s=(0,a.Whr)().toVar(),n=(0,a.fVC)(D(t.x,r)).toVar(),o=(0,a.fVC)(D(t.y,i)).toVar(),l=(0,a.fVC)(D(t.z,s)).toVar(),u=(0,a.fVC)(eo(n)).toVar(),h=(0,a.fVC)(eo(o)).toVar(),d=(0,a.fVC)(eo(l)).toVar();return er((0,a.fVC)($(q(ep(r,i,s),n,o,l),q(ep(r.add((0,a.Whr)(1)),i,s),n.sub(1),o,l),q(ep(r,i.add((0,a.Whr)(1)),s),n,o.sub(1),l),q(ep(r.add((0,a.Whr)(1)),i.add((0,a.Whr)(1)),s),n.sub(1),o.sub(1),l),q(ep(r,i,s.add((0,a.Whr)(1))),n,o,l.sub(1)),q(ep(r.add((0,a.Whr)(1)),i,s.add((0,a.Whr)(1))),n.sub(1),o,l.sub(1)),q(ep(r,i.add((0,a.Whr)(1)),s.add((0,a.Whr)(1))),n,o.sub(1),l.sub(1)),q(ep(r.add((0,a.Whr)(1)),i.add((0,a.Whr)(1)),s.add((0,a.Whr)(1))),n.sub(1),o.sub(1),l.sub(1)),u,h,d)).toVar())}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),eb=(0,d.f)([ey,ex]),ev=(0,a.Fn)(([e])=>{let t=(0,a.ZcS)(e).toVar(),r=(0,a.Whr)().toVar(),i=(0,a.Whr)().toVar(),s=(0,a.fVC)(D(t.x,r)).toVar(),n=(0,a.fVC)(D(t.y,i)).toVar(),o=(0,a.fVC)(eo(s)).toVar(),l=(0,a.fVC)(eo(n)).toVar();return ee((0,a.eR5)(k(Y(ef(r,i),s,n),Y(ef(r.add((0,a.Whr)(1)),i),s.sub(1),n),Y(ef(r,i.add((0,a.Whr)(1))),s,n.sub(1)),Y(ef(r.add((0,a.Whr)(1)),i.add((0,a.Whr)(1))),s.sub(1),n.sub(1)),o,l)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),e_=(0,a.Fn)(([e])=>{let t=(0,a.eR5)(e).toVar(),r=(0,a.Whr)().toVar(),i=(0,a.Whr)().toVar(),s=(0,a.Whr)().toVar(),n=(0,a.fVC)(D(t.x,r)).toVar(),o=(0,a.fVC)(D(t.y,i)).toVar(),l=(0,a.fVC)(D(t.z,s)).toVar(),u=(0,a.fVC)(eo(n)).toVar(),h=(0,a.fVC)(eo(o)).toVar(),d=(0,a.fVC)(eo(l)).toVar();return er((0,a.eR5)($(Y(ef(r,i,s),n,o,l),Y(ef(r.add((0,a.Whr)(1)),i,s),n.sub(1),o,l),Y(ef(r,i.add((0,a.Whr)(1)),s),n,o.sub(1),l),Y(ef(r.add((0,a.Whr)(1)),i.add((0,a.Whr)(1)),s),n.sub(1),o.sub(1),l),Y(ef(r,i,s.add((0,a.Whr)(1))),n,o,l.sub(1)),Y(ef(r.add((0,a.Whr)(1)),i,s.add((0,a.Whr)(1))),n.sub(1),o,l.sub(1)),Y(ef(r,i.add((0,a.Whr)(1)),s.add((0,a.Whr)(1))),n,o.sub(1),l.sub(1)),Y(ef(r.add((0,a.Whr)(1)),i.add((0,a.Whr)(1)),s.add((0,a.Whr)(1))),n.sub(1),o.sub(1),l.sub(1)),u,h,d)).toVar())}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),eT=(0,d.f)([ev,e_]);(0,a.Fn)(([e])=>{let t=(0,a.fVC)(e).toVar();return en(ep((0,a.Whr)(O(t)).toVar()))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),(0,a.Fn)(([e])=>{let t=(0,a.ZcS)(e).toVar();return en(ep((0,a.Whr)(O(t.x)).toVar(),(0,a.Whr)(O(t.y)).toVar()))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),(0,a.Fn)(([e])=>{let t=(0,a.eR5)(e).toVar();return en(ep((0,a.Whr)(O(t.x)).toVar(),(0,a.Whr)(O(t.y)).toVar(),(0,a.Whr)(O(t.z)).toVar()))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),(0,a.Fn)(([e])=>{let t=(0,a.lnd)(e).toVar();return en(ep((0,a.Whr)(O(t.x)).toVar(),(0,a.Whr)(O(t.y)).toVar(),(0,a.Whr)(O(t.z)).toVar(),(0,a.Whr)(O(t.w)).toVar()))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]});let eS=(0,a.Fn)(([e])=>{let t=(0,a.fVC)(e).toVar(),r=(0,a.Whr)(O(t)).toVar();return(0,a.eR5)(en(ep(r,(0,a.Whr)(0))),en(ep(r,(0,a.Whr)(1))),en(ep(r,(0,a.Whr)(2))))}
1).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),eA=(0,a.Fn)(([e])=>{let t=(0,a.ZcS)(e).toVar(),r=(0,a.Whr)(O(t.x)).toVar(),i=(0,a.Whr)(O(t.y)).toVar();return(0,a.eR5)(en(ep(r,i,(0,a.Whr)(0))),en(ep(r,i,(0,a.Whr)(1))),en(ep(r,i,(0,a.Whr)(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),eM=(0,a.Fn)(([e])=>{let t=(0,a.eR5)(e).toVar(),r=(0,a.Whr)(O(t.x)).toVar(),i=(0,a.Whr)(O(t.y)).toVar(),s=(0,a.Whr)(O(t.z)).toVar();return(0,a.eR5)(en(ep(r,i,s,(0,a.Whr)(0))),en(ep(r,i,s,(0,a.Whr)(1))),en(ep(r,i,s,(0,a.Whr)(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ew=(0,a.Fn)(([e])=>{let t=(0,a.lnd)(e).toVar(),r=(0,a.Whr)(O(t.x)).toVar(),i=(0,a.Whr)(O(t.y)).toVar(),s=(0,a.Whr)(O(t.z)).toVar(),n=(0,a.Whr)(O(t.w)).toVar();return(0,a.eR5)(en(ep(r,i,s,n,(0,a.Whr)(0))),en(ep(r,i,s,n,(0,a.Whr)(1))),en(ep(r,i,s,n,(0,a.Whr)(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),eR=(0,d.f)([eS,eA,eM,ew]),eN=(0,a.Fn)(([e,t,r,i])=>{let s=(0,a.fVC)(i).toVar(),n=(0,a.fVC)(r).toVar(),o=(0,a.Whr)(t).toVar(),u=(0,a.eR5)(e).toVar(),h=(0,a.fVC)(0).toVar(),d=(0,a.fVC)(1).toVar();return(0,l.FZ)(o,()=>{h.addAssign(d.mul(eb(u))),d.mulAssign(s),u.mulAssign(n)}),h}).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"}]}),eC=(0,a.Fn)(([e,t,r,i])=>{let s=(0,a.fVC)(i).toVar(),n=(0,a.fVC)(r).toVar(),o=(0,a.Whr)(t).toVar(),u=(0,a.eR5)(e).toVar(),h=(0,a.eR5)(0).toVar(),d=(0,a.fVC)(1).toVar();return(0,l.FZ)(o,()=>{h.addAssign(d.mul(eT(u))),d.mulAssign(s),u.mulAssign(n)}),h}).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"}]});(0,a.Fn)(([e,t,r,i])=>{let s=(0,a.fVC)(i).toVar(),n=(0,a.fVC)(r).toVar(),o=(0,a.Whr)(t).toVar(),l=(0,a.eR5)(e).toVar();return(0,a.ZcS)(eN(l,o,n,s),eN(l.add((0,a.eR5)((0,a.Whr)(19),(0,a.Whr)(193),(0,a.Whr)(17))),o,n,s))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),(0,a.Fn)(([e,t,r,i])=>{let s=(0,a.fVC)(i).toVar(),n=(0,a.fVC)(r).toVar(),o=(0,a.Whr)(t).toVar(),l=(0,a.eR5)(e).toVar(),u=(0,a.eR5)(eC(l,o,n,s)).toVar(),h=(0,a.fVC)(eN(l.add((0,a.eR5)((0,a.Whr)(19),(0,a.Whr)(193),(0,a.Whr)(17))),o,n,s)).toVar();return(0,a.lnd)(u,h)}).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"}]});let eE=(0,a.Fn)(([e,t,r,i,s,n,l])=>{let u=(0,a.Whr)(l).toVar(),h=(0,a.fVC)(n).toVar(),d=(0,a.Whr)(s).toVar(),c=(0,a.Whr)(i).toVar(),p=(0,a.Whr)(r).toVar(),m=(0,a.Whr)(t).toVar(),g=(0,a.ZcS)(e).toVar(),f=(0,a.eR5)(eR((0,a.ZcS)(m.add(c),p.add(d)))).toVar(),y=(0,a.ZcS)(f.x,f.y).toVar();y.subAssign(.5),y.mulAssign(h),y.addAssign(.5);let x=(0,a.ZcS)((0,a.ZcS)((0,a.fVC)(m),(0,a.fVC)(p)).add(y)).toVar(),b=(0,a.ZcS)(x.sub(g)).toVar();return(0,a.If)(u.equal((0,a.Whr)(2)),()=>(0,o.tn)(b.x).add((0,o.tn)(b.y))),(0,a.If)(u.equal((0,a.Whr)(3)),()=>(0,o.T9)((0,o.tn)(b.x),(0,o.tn)(b.y))),(0,o.Om)(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"}]}),eF=(0,a.Fn)(([e,t,r,i,s,n,l,u,h])=>{let d=(0,a.Whr)(h).toVar(),c=(0,a.fVC)(u).toVar(),p=(0,a.Whr)(l).toVar(),m=(0,a.Whr)(n).toVar(),g=(0,a.Whr)(s).toVar(),f=(0,a.Whr)(i).toVar(),y=(0,a.Whr)(r).toVar(),x=(0,a.Whr)(t).toVar(),b=(0,a.eR5)(e).toVar(),v=(0,a.eR5)(eR((0,a.eR5)(x.add(g),y.add(m),f.add(p)))).toVar();v.subAssign(.5),v.mulAssign(c),v.addAssign(.5);let _=(0,a.eR5)((0,a.eR5)((0,a.fVC)(x),(0,a.fVC)(y),(0,a.fVC)(f)).add(v)).toVar(),T=(0,a.eR5)(_.sub(b)).toVar();return(0,a.If)(d.equal((0,a.Whr)(2)),()=>(0,o.tn)(T.x).add((0,o.tn)(T.y)).add((0,o.tn)(T.z))),(0,a.If)(d.equal((0,a.Whr)(3)),()=>(0,o.T9)((0,o.tn)(T.x),(0,o.tn)(T.y),(0,o.tn)(T.z))),(0,o.Om)(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"}]}),eB=(0,d.f)([eE,eF]);(0,a.Fn)(([e,t,r])=>{let i=(0,a.Whr)(r).toVar(),s=(0,a.fVC)(t).toVar(),n=(0,a.ZcS)(e).toVar(),u=(0,a.Whr)().toVar(),h=(0,a.Whr)().toVar(),d=(0,a.ZcS)(D(n.x,u),D(n.y,h)).toVar(),c=(0,a.fVC)(1e6).toVar();return(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"x",condition:"<="},({x:e})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"y",condition:"<="},({y:t})=>{let r=(0,a.fVC)(eB(d,e,t,u,h,s,i)).toVar();c.assign((0,o.jk)(c,r))})}),(0,a.If)(i.equal((0,a.Whr)(0)),()=>{c.assign((0,o.RZ)(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),(0,a.Fn)(([e,t,r])=>{let i=(0,a.Whr)(r).toVar(),s=(0,a.fVC)(t).toVar(),n=(0,a.ZcS)(e).toVar(),u=(0,a.Whr)().toVar(),h=(0,a.Whr)().toVar(),d=(0,a.ZcS)(D(n.x,u),D(n.y,h)).toVar(),c=(0,a.ZcS)(1e6,1e6).toVar();return(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"x",condition:"<="},({x:e})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"y",condition:"<="},({y:t})=>{let r=(0,a.fVC)(eB(d,e,t,u,h,s,i)).toVar();(0,a.If)(r.lessThan(c.x),()=>{c.y.assign(c.x),c.x.assign(r)}).ElseIf(r.lessThan(c.y),()=>{c.y.assign(r)})})}),(0,a.If)(i.equal((0,a.Whr)(0)),()=>{c.assign((0,o.RZ)(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]});let eP=(0,a.Fn)(([e,t,r])=>{let i=(0,a.Whr)(r).toVar(),s=(0,a.fVC)(t).toVar(),n=(0,a.ZcS)(e).toVar(),u=(0,a.Whr)().toVar(),h=(0,a.Whr)().toVar(),d=(0,a.ZcS)(D(n.x,u),D(n.y,h)).toVar(),c=(0,a.eR5)(1e6,1e6,1e6).toVar();return(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"x",condition:"<="},({x:e})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"y",condition:"<="},({y:t})=>{let r=(0,a.fVC)(eB(d,e,t,u,h,s,i)).toVar();(0,a.If)(r.lessThan(c.x),()=>{c.z.assign(c.y),c.y.assign(c.x),c.x.assign(r)}).ElseIf(r.lessThan(c.y),()=>{c.z.assign(c.y),c.y.assign(r)}).ElseIf(r.lessThan(c.z),()=>{c.z.assign(r)})})}),(0,a.If)(i.equal((0,a.Whr)(0)),()=>{c.assign((0,o.RZ)(c))}),c}
1).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]});(0,a.Fn)(([e,t,r])=>{let i=(0,a.Whr)(r).toVar(),s=(0,a.fVC)(t).toVar(),n=(0,a.eR5)(e).toVar(),u=(0,a.Whr)().toVar(),h=(0,a.Whr)().toVar(),d=(0,a.Whr)().toVar(),c=(0,a.eR5)(D(n.x,u),D(n.y,h),D(n.z,d)).toVar(),p=(0,a.fVC)(1e6).toVar();return(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"x",condition:"<="},({x:e})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"y",condition:"<="},({y:t})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"z",condition:"<="},({z:r})=>{let n=(0,a.fVC)(eB(c,e,t,r,u,h,d,s,i)).toVar();p.assign((0,o.jk)(p,n))})})}),(0,a.If)(i.equal((0,a.Whr)(0)),()=>{p.assign((0,o.RZ)(p))}),p}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),(0,a.Fn)(([e,t,r])=>{let i=(0,a.Whr)(r).toVar(),s=(0,a.fVC)(t).toVar(),n=(0,a.eR5)(e).toVar(),u=(0,a.Whr)().toVar(),h=(0,a.Whr)().toVar(),d=(0,a.Whr)().toVar(),c=(0,a.eR5)(D(n.x,u),D(n.y,h),D(n.z,d)).toVar(),p=(0,a.ZcS)(1e6,1e6).toVar();return(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"x",condition:"<="},({x:e})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"y",condition:"<="},({y:t})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"z",condition:"<="},({z:r})=>{let n=(0,a.fVC)(eB(c,e,t,r,u,h,d,s,i)).toVar();(0,a.If)(n.lessThan(p.x),()=>{p.y.assign(p.x),p.x.assign(n)}).ElseIf(n.lessThan(p.y),()=>{p.y.assign(n)})})})}),(0,a.If)(i.equal((0,a.Whr)(0)),()=>{p.assign((0,o.RZ)(p))}),p}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]});let eV=(0,a.Fn)(([e,t,r])=>{let i=(0,a.Whr)(r).toVar(),s=(0,a.fVC)(t).toVar(),n=(0,a.eR5)(e).toVar(),u=(0,a.Whr)().toVar(),h=(0,a.Whr)().toVar(),d=(0,a.Whr)().toVar(),c=(0,a.eR5)(D(n.x,u),D(n.y,h),D(n.z,d)).toVar(),p=(0,a.eR5)(1e6,1e6,1e6).toVar();return(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"x",condition:"<="},({x:e})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"y",condition:"<="},({y:t})=>{(0,l.FZ)({start:-1,end:(0,a.Whr)(1),name:"z",condition:"<="},({z:r})=>{let n=(0,a.fVC)(eB(c,e,t,r,u,h,d,s,i)).toVar();(0,a.If)(n.lessThan(p.x),()=>{p.z.assign(p.y),p.y.assign(p.x),p.x.assign(n)}).ElseIf(n.lessThan(p.y),()=>{p.z.assign(p.y),p.y.assign(n)}).ElseIf(n.lessThan(p.z),()=>{p.z.assign(n)})})})}),(0,a.If)(i.equal((0,a.Whr)(0)),()=>{p.assign((0,o.RZ)(p))}),p}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),eL=(0,d.f)([eP,eV]);(0,a.Fn)(([e,t,r,i,s,n,l,u,h,d,c])=>{let p=(0,a.Whr)(e).toVar(),m=(0,a.ZcS)(t).toVar(),g=(0,a.ZcS)(r).toVar(),f=(0,a.ZcS)(i).toVar(),y=(0,a.fVC)(s).toVar(),x=(0,a.fVC)(n).toVar(),b=(0,a.fVC)(l).toVar(),v=(0,a.lcY)(u).toVar(),_=(0,a.Whr)(h).toVar(),T=(0,a.fVC)(d).toVar(),S=(0,a.fVC)(c).toVar(),A=m.mul(g).add(f),M=(0,a.fVC)(0).toVar();return(0,a.If)(p.equal((0,a.Whr)(0)),()=>{M.assign(eT(A))}),(0,a.If)(p.equal((0,a.Whr)(1)),()=>{M.assign(eR(A))}),(0,a.If)(p.equal((0,a.Whr)(2)),()=>{M.assign(eL(A,y,(0,a.Whr)(0)))}),(0,a.If)(p.equal((0,a.Whr)(3)),()=>{M.assign(eC((0,a.eR5)(A,0),_,T,S))}),M.assign(M.mul(b.sub(x)).add(x)),(0,a.If)(v,()=>{M.assign((0,o.qE)(M,x,b))}),M}).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"}]}),(0,a.Fn)(([e,t,r,i,s,n,l,u,h,d,c])=>{let p=(0,a.Whr)(e).toVar(),m=(0,a.eR5)(t).toVar(),g=(0,a.eR5)(r).toVar(),f=(0,a.eR5)(i).toVar(),y=(0,a.fVC)(s).toVar(),x=(0,a.fVC)(n).toVar(),b=(0,a.fVC)(l).toVar(),v=(0,a.lcY)(u).toVar(),_=(0,a.Whr)(h).toVar(),T=(0,a.fVC)(d).toVar(),S=(0,a.fVC)(c).toVar(),A=m.mul(g).add(f),M=(0,a.fVC)(0).toVar();return(0,a.If)(p.equal((0,a.Whr)(0)),()=>{M.assign(eT(A))}),(0,a.If)(p.equal((0,a.Whr)(1)),()=>{M.assign(eR(A))}),(0,a.If)(p.equal((0,a.Whr)(2)),()=>{M.assign(eL(A,y,(0,a.Whr)(0)))}),(0,a.If)(p.equal((0,a.Whr)(3)),()=>{M.assign(eC(A,_,T,S))}),M.assign(M.mul(b.sub(x)).add(x)),(0,a.If)(v,()=>{M.assign((0,o.qE)(M,x,b))}),M}).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"}]}),(0,a.Fn)(([e])=>{let t=e.y,r=e.z,i=(0,a.eR5)().toVar();return(0,a.If)(t.lessThan(1e-4),()=>{i.assign((0,a.eR5)(r,r,r))}).Else(()=>{let s=e.x;s=s.sub((0,o.RI)(s)).mul(6).toVar();let n=(0,a.Whr)((0,o.BU)(s)),l=s.sub((0,a.fVC)(n)),u=r.mul(t.oneMinus()),h=r.mul(t.mul(l).oneMinus()),d=r.mul(t.mul(l.oneMinus()).oneMinus());(0,a.If)(n.equal((0,a.Whr)(0)),()=>{i.assign((0,a.eR5)(r,d,u))}).ElseIf(n.equal((0,a.Whr)(1)),()=>{i.assign((0,a.eR5)(h,r,u))}).ElseIf(n.equal((0,a.Whr)(2)),()=>{i.assign((0,a.eR5)(u,r,d))}).ElseIf(n.equal((0,a.Whr)(3)),()=>{i.assign((0,a.eR5)(u,h,r))}).ElseIf(n.equal((0,a.Whr)(4)),()=>{i.assign((0,a.eR5)(d,u,r))}).Else(()=>{i.assign((0,a.eR5)(r,u,h))})}),i}
1).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),(0,a.Fn)(([e])=>{let t=(0,a.eR5)(e).toVar(),r=(0,a.fVC)(t.x).toVar(),i=(0,a.fVC)(t.y).toVar(),s=(0,a.fVC)(t.z).toVar(),l=(0,a.fVC)((0,o.jk)(r,(0,o.jk)(i,s))).toVar(),u=(0,a.fVC)((0,o.T9)(r,(0,o.T9)(i,s))).toVar(),h=(0,a.fVC)(u.sub(l)).toVar(),d=(0,a.fVC)().toVar(),c=(0,a.fVC)().toVar(),p=(0,a.fVC)().toVar();return p.assign(u),(0,a.If)(u.greaterThan(0),()=>{c.assign(h.div(u))}).Else(()=>{c.assign(0)}),(0,a.If)(c.lessThanEqual(0),()=>{d.assign(0)}).Else(()=>{(0,a.If)(r.greaterThanEqual(u),()=>{d.assign(i.sub(s).div(h))}).ElseIf(i.greaterThanEqual(u),()=>{d.assign((0,n.WQ)(2,s.sub(r).div(h)))}).Else(()=>{d.assign((0,n.WQ)(4,r.sub(i).div(h)))}),d.mulAssign(1/6),(0,a.If)(d.lessThan(0),()=>{d.addAssign(1)})}),(0,a.eR5)(d,c,p)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),(0,a.Fn)(([e])=>{let t=(0,a.eR5)(e).toVar(),r=(0,a.qP5)((0,n.MM)(t,(0,a.eR5)(.04045))).toVar(),i=(0,a.eR5)(t.div(12.92)).toVar(),s=(0,a.eR5)((0,o.n7)((0,o.T9)(t.add((0,a.eR5)(.055)),(0,a.eR5)(0)).div(1.055),(0,a.eR5)(2.4))).toVar();return(0,o.jh)(i,s,r)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),r(51187),r(93410),r(10379),r(45622),r(5972),r(65462),r(36850),r(82842),r(45192),r(2520),r(47330)},6593:(e,t,r)=>{r.d(t,{N:()=>s});var i=r(26609);class s{constructor(e=new i.P(Infinity,Infinity,Infinity),t=new i.P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t+=3)this.expandByPoint(n.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,r=e.count;t<r;t++)this.expandByPoint(n.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;t<r;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let r=n.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=Infinity,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let r=e.geometry;if(void 0!==r){let i=r.getAttribute("position");if(!0===t&&void 0!==i&&!0!==e.isInstancedMesh)for(let t=0,r=i.count;t<r;t++)!0===e.isMesh?e.getVertexPosition(t,n):n.fromBufferAttribute(i,t),n.applyMatrix4(e.matrixWorld),this.expandByPoint(n);else void 0!==e.boundingBox?(null===e.boundingBox&&e.computeBoundingBox(),o.copy(e.boundingBox)):(null===r.boundingBox&&r.computeBoundingBox(),o.copy(r.boundingBox)),o.applyMatrix4(e.matrixWorld),this.union(o)}let i=e.children;for(let e=0,r=i.length;e<r;e++)this.expandByObject(i[e],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,n),n.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(m),g.subVectors(this.max,m),l.subVectors(e.a,m),u.subVectors(e.b,m),h.subVectors(e.c,m),d.subVectors(u,l),c.subVectors(h,u),p.subVectors(l,h);let t=[0,-d.z,d.y,0,-c.z,c.y,0,-p.z,p.y,d.z,0,-d.x,c.z,0,-c.x,p.z,0,-p.x,-d.y,d.x,0,-c.y,c.x,0,-p.y,p.x,0];return!!x(t,l,u,h,g)&&!!x(t=[1,0,0,0,1,0,0,0,1],l,u,h,g)&&(f.crossVectors(d,c),x(t=[f.x,f.y,f.z],l,u,h,g))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,n).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(n).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(a)
1),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}let a=[new i.P,new i.P,new i.P,new i.P,new i.P,new i.P,new i.P,new i.P],n=new i.P,o=new s,l=new i.P,u=new i.P,h=new i.P,d=new i.P,c=new i.P,p=new i.P,m=new i.P,g=new i.P,f=new i.P,y=new i.P;function x(e,t,r,i,s){for(let a=0,n=e.length-3;a<=n;a+=3){y.fromArray(e,a);let n=s.x*Math.abs(y.x)+s.y*Math.abs(y.y)+s.z*Math.abs(y.z),o=t.dot(y),l=r.dot(y),u=i.dot(y);if(Math.max(-Math.max(o,l,u),Math.min(o,l,u))>n)return!1}return!0}},7176:(e,t,r)=>{r.d(t,{w:()=>n});var i=r(64994),s=r(25756);class a extends i.A{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 s.I(1,1,1,1))}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}let n=(e=0)=>new a(e)},7264:(e,t,r)=>{r.d(t,{C:()=>u});var i=r(5092),s=r(12106),a=r(57123),n=r(2945),o=r(68929);class l extends i.A{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=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=(0,s.ln)(t.rgb,t.a.clamp(0,1)),t=(0,a.D)(t);let r=(null!==this._toneMapping?this._toneMapping:e.toneMapping)||n.y_p,i=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||n.jf0;return r!==n.y_p&&(t=t.toneMapping(r)),i!==n.jf0&&i!==o.pp.workingColorSpace&&(t=t.workingToColorSpace(i)),t=(0,a.I)(t)}}let u=(e,t=null,r=null)=>new l((0,s.mp)(e),t,r);(0,s.mV)("renderOutput",u)},7439:(e,t,r)=>{r.d(t,{x:()=>f});var i=r(98121),s=r(81951),a=r(13662);r(29646);let n=1/6,o=e=>(0,i.lK)(n,(0,i.lK)(e,(0,i.lK)(e,e.negate().add(3)).sub(3)).add(1)),l=e=>(0,i.lK)(n,(0,i.lK)(e,(0,i.lK)(e,(0,i.lK)(3,e).sub(6))).add(4)),u=e=>(0,i.lK)(n,(0,i.lK)(e,(0,i.lK)(e,(0,i.lK)(-3,e).add(3)).add(3)).add(1)),h=e=>(0,i.lK)(n,(0,s.n7)(e,3)),d=e=>o(e).add(l(e)),c=e=>u(e).add(h(e)),p=e=>(0,i.WQ)(-1,l(e).div(o(e).add(l(e)))),m=e=>(0,i.WQ)(1,h(e).div(u(e).add(h(e)))),g=(e,t,r)=>{let n=e.uvNode,o=(0,i.lK)(n,t.zw).add(.5),l=(0,s.RI)(o),u=(0,s.jc)(o),h=d(u.x),g=c(u.x),f=p(u.x),y=m(u.x),x=p(u.y),b=m(u.y),v=(0,a.ZcS)(l.x.add(f),l.y.add(x)).sub(.5).mul(t.xy),_=(0,a.ZcS)(l.x.add(y),l.y.add(x)).sub(.5).mul(t.xy),T=(0,a.ZcS)(l.x.add(f),l.y.add(b)).sub(.5).mul(t.xy),S=(0,a.ZcS)(l.x.add(y),l.y.add(b)).sub(.5).mul(t.xy),A=d(u.y).mul((0,i.WQ)(h.mul(e.sample(v).level(r)),g.mul(e.sample(_).level(r)))),M=c(u.y).mul((0,i.WQ)(h.mul(e.sample(T).level(r)),g.mul(e.sample(S).level(r))));return A.add(M)},f=(0,a.Fn)(([e,t])=>{let r=(0,a.ZcS)(e.size((0,a.Whr)(t))),n=(0,a.ZcS)(e.size((0,a.Whr)(t.add(1)))),o=(0,i.y4)(1,r),l=(0,i.y4)(1,n),u=g(e,(0,a.lnd)(o,r),(0,s.RI)(t)),h=g(e,(0,a.lnd)(l,n),(0,s.mk)(t));return(0,s.jc)(t).mix(u,h)})},7519:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(57218);class s extends i.A{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)}}let a=s},8227:(e,t,r)=>{r.d(t,{b:()=>n});var i=r(57218),s=r(13662);class a extends i.A{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 n=(0,s.Hmo)(a).setParameterLength(1,2)},8926:(e,t,r)=>{r.d(t,{I:()=>h});
1var i=r(6293),s=r(19793),a=r(13662),n=r(94018),o=r(83815),l=r(79699);class u extends i.A{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let i,s=null;t&&t.isStructTypeNode?(i="struct",s=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):null===t&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(i=(0,l.Hq)(e.itemSize),r=e.count):i=t,super(e,i,r),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=o.pF.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(0,n._)(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(o.pF.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return null===this._attribute&&(this._attribute=(0,s.xI)(this.value),this._varying=(0,a.PCg)(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 h=(e,t=null,r=0)=>new u(e,t,r)},9404:(e,t,r)=>{r.d(t,{q:()=>s});var i=r(52698);class s extends i.i{constructor(e=-1,t=1,r=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,r,i,s,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2,s=r-e,a=r+e,n=i+t,o=i-t;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=e*this.view.offsetX,a=s+e*this.view.width,n-=t*this.view.offsetY,o=n-t*this.view.height}this.projectionMatrix.makeOrthographic(s,a,n,o,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}},10379:(e,t,r)=>{r.d(t,{A:()=>i});let i=(0,r(13662).Fn)(({alpha:e,dotNH:t})=>{let r=e.pow2(),i=t.pow2().mul(r.oneMinus()).oneMinus();return r.div(i.pow2()).mul(1/Math.PI)}
1).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]})},12106:(e,t,r)=>{r.d(t,{DS:()=>X,Fn:()=>Q,G$:()=>k,Hd:()=>en,Hm:()=>q,I1:()=>ee,I8:()=>ey,If:()=>et,PQ:()=>ep,RT:()=>H,VN:()=>em,Wh:()=>ea,Ws:()=>eu,Zc:()=>el,_j:()=>j,ab:()=>ex,aq:()=>eh,cF:()=>J,eR:()=>ec,fV:()=>es,lc:()=>eo,ln:()=>ef,mV:()=>y,mp:()=>W,mq:()=>G,pB:()=>eT,pm:()=>ev,qP:()=>eg,sw:()=>z,w0:()=>e_,xA:()=>K,yW:()=>ei});var i=r(57218),s=r(15907),a=r(7519),n=r(24328),o=r(38028),l=r(72156),u=r(26719),h=r(39609),d=r(38530),c=r(69707),p=r(79699),m=r(51365);let g=null,f=new Map;function y(e,t){if(f.has(e))return void(0,m.R8)(`TSL: Redefinition of method chaining '${e}'.`);if("function"!=typeof t)throw Error(`THREE.TSL: Node element ${e} is not a function`);f.set(e,t),"assign"!==e&&(i.A.prototype[e]=function(...e){return this.isStackNode?this.addToStack(t(...e)):t(this,...e)},i.A.prototype[e+"Assign"]=function(...e){return this.isStackNode?this.assign(e[0],t(...e)):this.assign(t(this,...e))})}let x=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("");i.A.prototype.assign=function(...e){if(!0!==this.isStackNode)return null!==g?g.assign(this,...e):(0,m.z3)("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new c.A),this;{let t=f.get("assign");return this.addToStack(t(...e))}},i.A.prototype.toVarIntent=function(){return this},i.A.prototype.get=function(e){return new d.A(this,e)};let b={};function v(e,t,r){b[e]=b[t]=b[r]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new o.A(this,e),this._cache[e]=t),t},set(t){this[e].assign(W(t))}};let s=e.toUpperCase(),a=t.toUpperCase(),n=r.toUpperCase();i.A.prototype["set"+s]=i.A.prototype["set"+a]=i.A.prototype["set"+n]=function(t){let r=x(e);return new l.A(this,r,W(t))},i.A.prototype["flip"+s]=i.A.prototype["flip"+a]=i.A.prototype["flip"+n]=function(){let t=x(e);return new u.A(this,t)}}let _=["x","y","z","w"],T=["r","g","b","a"],S=["s","t","p","q"];for(let e=0;e<4;e++){let t=_[e],r=T[e],i=S[e];v(t,r,i);for(let s=0;s<4;s++){t=_[e]+_[s],v(t,r=T[e]+T[s],i=S[e]+S[s]);for(let a=0;a<4;a++){t=_[e]+_[s]+_[a],v(t,r=T[e]+T[s]+T[a],i=S[e]+S[s]+S[a]);for(let n=0;n<4;n++)t=_[e]+_[s]+_[a]+_[n],v(t,r=T[e]+T[s]+T[a]+T[n],i=S[e]+S[s]+S[a]+S[n])}}}for(let e=0;e<32;e++)b[e]={get(){this._cache=this._cache||{};let t=this._cache[e];return void 0===t&&(t=new s.A(this,new h.A(e,"uint")),this._cache[e]=t),t},set(t){this[e].assign(W(t))}};Object.defineProperties(i.A.prototype,b);let A=function(e,t=null){let r=(0,p.AZ)(e);if("node"===r);else if(null===t&&("float"===r||"boolean"===r)||r&&"shader"!==r&&"string"!==r)return W(D(e,t));else if("shader"===r)return e.isFn?e:Q(e);return e},M=function(e,t=null){for(let r in e)e[r]=W(e[r],t);return e},w=function(e,t=null){let r=e.length;for(let i=0;i<r;i++)e[i]=W(e[i],t);return e},R=function(e,t=null,r=null,i=null){function s(e){return null!==i?(e=W(Object.assign(e,i)),!0===i.intent&&(e=e.toVarIntent())):e=W(e),e}let a,n=t,o,l;function u(t){let r;return(r=n?/[a-z]/i.test(n)?n+"()":n:e.type,void 0!==o&&t.length<o)?((0,m.z3)(`TSL: "${r}" parameter length is less than minimum required.`,new c.A),t.concat(Array(o-t.length).fill(0))):void 0!==l&&t.length>l?((0,m.z3)(`TSL: "${r}" parameter length exceeds limit.`,new c.A),t.slice(0,l)):t}return null===t?a=(...t)=>s(new e(...j(u(t)))):null!==r?(r=W(r),a=(...i)=>s(new e(t,...j(u(i)),r))):a=(...r)=>s(new e(t,...j(u(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},N=function(e,...t){return new e(...j(t))};class C extends i.A{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:s,rawInputs:a}=this,n=e.getNodeProperties(s),o=e.getClosestSubBuild(s.subBuilds)||"",l=o||"default";if(n[l])return n[l];let u=e.subBuildFn,h=e.fnCall;e.subBuildFn=o,e.fnCall=this;let d=null;if(s.layout){if(a){let t=s.layout.inputs;if(E(a))for(let r=0;r<t.length;r++){let t=a[r];t&&t.isNode&&t.build(e)}else{let r=a[0];for(let i of t){let t=r[i.name];t&&t.isNode&&t.build(e)}}}let r=e.buildFunctionNode(s);e.addInclude(r);let i=a?(H(t=a),E(t)?[...t]:t[0]):null;d=r.call(i)}else{let t,n=new Proxy(e,{get:(e,t,r)=>Symbol.iterator===t?function*(){yield}:Reflect.get(e,t,r)}),o=a?(t=0,H(r=a),new Proxy(r,{get:(e,s,a)=>{let n;if("length"===s)return r.length;if(Symbol.iterator===s)n=function*(){for(let e of r)yield W(e)};else{if(r.length>0)if(Object.getPrototypeOf(r[0])===Object.prototype){let e=r[0];n=void 0===e[s]?e[t++]:Reflect.get(e,s,a)}else r[0]instanceof i.A&&(n=void 0===r[s]?r[t++]:Reflect.get(r,s,a));else n=Reflect.get(e,s,a);n=W(n)}return n}})):null,l=Array.isArray(a)?a.length>0:null!==a,u=s.jsFunc;d=W(l||u.length>1?u(o,n):u(n))}return e.subBuildFn=u,e.fnCall=h,s.once&&(n[l]=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 E(e){return e[0]&&(e[0].isNode||Object.getPrototypeOf(e[0])!==Object.prototype)}class F extends i.A{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 C(this,e)}setup(){return this.call()}}let B=[.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],P=new Map;for(let e of[!1,!0])P.set(e,new h.A(e));let V=new Map;for(let e of[0,1,2,3])V.set(e,new h.A(e,"uint"));let L=new Map([...V].map(e=>new h.A(e.value,"int")));
1for(let e of[-1,-2])L.set(e,new h.A(e,"int"));let I=new Map([...L].map(e=>new h.A(e.value)));for(let e of B)I.set(e,new h.A(e));for(let e of B)I.set(-e,new h.A(-e));let O=new Map([...P,...I]),D=(e,t)=>O.has(e)?O.get(e):!0===e.isNode?e:new h.A(e,t),U=function(e,t=null){return(...r)=>{for(let t of r)if(void 0===t)return(0,m.z3)(`TSL: Invalid parameter for the type "${e}".`,new c.A),new h.A(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=[(0,p.yI)(e,...r)]),1===r.length&&null!==t&&t.has(r[0]))return $(t.get(r[0]));if(1===r.length){let t=D(r[0],e);return t.nodeType===e?$(t):$(new a.A(t,e))}let i=r.map(e=>D(e));return $(new n.A(i,e))}};function z(e){return e&&e.isNode&&e.traverse(t=>{t.isConstNode&&(e=t.value)}),!!e}let k=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function G(e,t){return new F(e,t)}let W=(e,t=null)=>A(e,t),$=(e,t=null)=>W(e,t).toVarIntent(),H=(e,t=null)=>new M(e,t),j=(e,t=null)=>new w(e,t),q=(e,t=null,r=null,i=null)=>new R(e,t,r,i),X=(e,...t)=>new N(e,...t),K=(e,t=null,r=null,i={})=>new R(e,t,r,{...i,intent:!0}),Y=0;class Z extends i.A{constructor(e,t=null){super();let r=null;null!==t&&("object"==typeof t?r=t.return:("string"==typeof t?r=t:(0,m.z3)("TSL: Invalid layout type.",new c.A),t=null)),this.shaderNode=new G(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"+Y++,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,m.z3)('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function Q(e,t=null){let r=new Z(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 J=e=>{g=e},ee=()=>g,et=(...e)=>g.If(...e);function er(e){return g&&g.addToStack(e),e}y("toStack",er);let ei=new U("color"),es=new U("float",I),ea=new U("int",L),en=new U("uint",V),eo=new U("bool",P),el=new U("vec2"),eu=new U("ivec2"),eh=new U("uvec2"),ed=new U("bvec2"),ec=new U("vec3"),ep=new U("ivec3"),em=new U("uvec3"),eg=new U("bvec3"),ef=new U("vec4"),ey=new U("ivec4"),ex=new U("uvec4"),eb=new U("bvec4"),ev=new U("mat2"),e_=new U("mat3"),eT=new U("mat4");y("toColor",ei),y("toFloat",es),y("toInt",ea),y("toUint",en),y("toBool",eo),y("toVec2",el),y("toIVec2",eu),y("toUVec2",eh),y("toBVec2",ed),y("toVec3",ec),y("toIVec3",ep),y("toUVec3",em),y("toBVec3",eg),y("toVec4",ef),y("toIVec4",ey),y("toUVec4",ex),y("toBVec4",eb),y("toMat2",ev),y("toMat3",e_),y("toMat4",eT),y("element",q(s.A).setParameterLength(2)),y("convert",(e,t)=>new a.A(W(e),t)),y("append",e=>((0,m.R8)("TSL: .append() has been renamed to .toStack().",new c.A),er(e)))},13662:(e,t,r)=>{r.d(t,{Fn:()=>i.Fn,If:()=>i.If,mqP:()=>i.mq,tnl:()=>o.tn,WQq:()=>n.WQ,mVC:()=>i.mV,rYl:()=>o.rY,lcY:()=>i.lc,qP5:()=>i.qP,mkO:()=>
1o.mk,qE8:()=>o.qE,yWT:()=>i.yW,_OA:()=>u._O,gnS:()=>o.gn,PuG:()=>o.Pu,IbF:()=>o.Ib,swK:()=>i.sw,y4m:()=>n.y4,Omf:()=>o.Om,IeL:()=>o.Ie,fVC:()=>i.fV,RIf:()=>o.RI,jcx:()=>o.jc,I1H:()=>i.I1,OcF:()=>d.Oc,Whr:()=>i.Wh,Wst:()=>i.Ws,Bw9:()=>o.Bw,p67:()=>o.p6,pmN:()=>i.pm,w00:()=>i.w0,pBV:()=>i.pB,T9B:()=>o.T9,jkA:()=>o.jk,jhA:()=>o.jh,lKK:()=>n.lK,_jj:()=>i._j,DSt:()=>i.DS,mp$:()=>i.mp,Hmo:()=>i.Hm,S86:()=>o.S8,CGW:()=>a.CG,zWV:()=>o.zW,MZ5:()=>a.MZ,Ltv:()=>l.L,cFV:()=>i.cF,F8e:()=>o.F8,PMw:()=>o.PM,jbE:()=>n.jb,Hdr:()=>i.Hd,PiW:()=>s.P,VN6:()=>i.VN,PCg:()=>h.PC,ZcS:()=>i.Zc,eR5:()=>i.eR,lnd:()=>i.ln});var i=r(12106);r(49415);var s=r(61114),a=r(21387);r(50803),r(94548);var n=r(98121),o=r(81951),l=r(71115),u=r(30617);r(28051);var h=r(87954);r(55398),r(99769);var d=r(19793);r(39651),r(94531),r(15842),r(97553);var c=r(4470);(0,i.mV)("discard",e=>(e?(0,l.L)(e,(0,c.d)("discard")):(0,c.d)("discard")).toStack()),r(7264),r(78771),r(37600),r(47307)},14508:(e,t,r)=>{r.d(t,{Ay:()=>g,ir:()=>f,qY:()=>y});var i=r(57218),s=r(83815),a=r(61114),n=r(40786),o=r(86389),l=r(6293),u=r(13662),h=r(61046),d=r(15907),c=r(51365);class p extends d.A{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 m extends i.A{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=s.KS.OBJECT}element(e){return new p(this,(0,u.mp$)(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return(0,c.R8)('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;null!==this.count?t=(0,l.r)(null,e,this.count):Array.isArray(this.getValueFromReference())?(t=(0,h.W)(null,e)).updateType=s.KS.OBJECT:t="texture"===e?(0,n.wH)(null):"cubeTexture"===e?(0,o.Rz)(null):(0,a.P)(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 g=m,f=(e,t,r)=>new m(e,t,r),y=(e,t,r,i)=>new m(e,t,i,r)},15024:(e,t,r)=>{r(13662),r(70215).Ay},15842:(e,t,r)=>{var i=r(57218),s=r(12106);class a extends i.A{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 n=(0,s.Hm)(a).setParameterLength(2);(0,s.mV)("bypass",n)},15907:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(57218);class s extends i.A{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} ]`}}let a=s},16613:(e,t,r)=>{let i,s;r.d(t,{A:()=>uh});class a{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(
1),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()}}var n=r(56900),o=r(79699);let l=0,u=new WeakMap;class h{constructor(e,t,r,i,s,a,n,o,u,h){this.id=l++,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=u,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=h,this.clippingContextCacheKey=null!==h?h.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 h=s.start*u,d=(s.start+s.count)*u;null!==i&&(h=Math.max(h,i.start*u),d=Math.min(d,(i.start+i.count)*u));let c=r.attributes.position,p=1/0;o?p=n.count:null!=c&&(p=c.count),h=Math.max(h,0);let m=(d=Math.min(d,p))-h;return m<0||m===1/0?null:(a.vertexCount=m,a.firstVertex=h,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=u.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)}u.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>
11)&&(i+=e.uuid+","),i+=this.context.id+",",i+=e.receiveShadow+",",(0,o.YZ)(i)}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=(0,o.tW)(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=(0,o.tW)(e,1)),e=(0,o.tW)(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 d=[];class c{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);d[0]=e,d[1]=t,d[2]=a,d[3]=s;let u=l.get(d);return void 0===u?(u=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,i,s,a,n,o),l.set(d,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)),d[0]=null,d[1]=null,d[2]=null,d[3]=null,u}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new n.A)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,i,s,a,n,o,l,u,d){let c=this.getChainMap(d),p=new h(e,t,r,i,s,a,n,o,l,u);return p.onDispose=()=>{this.pipelines.delete(p),this.bindings.deleteForRender(p),this.nodes.delete(p),c.delete(p.getChainArray())},p}}class p{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 m=p;var g=r(2945);class f extends m{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)1===t?(this.backend.createAttribute(e),this.info.createAttribute(e)):2===t?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):3===t?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):4===t&&(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===g.Vnu)&&(this.backend.updateAttribute(e),r.version=t.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}var y=r(18385);function x(e){return null!==e.index?e.index.version:e.attributes.position.version}function b(e){return null!==e.index?e.index.id:e.attributes.position.id}function v(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?y.MW:y.A$)(t,1);return s.version=x(e),s.__id=b(e),s}class _ extends m{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,3):this.updateAttribute(t,1);let t=this.getIndex(e);null!==t&&this.updateAttribute(t,2);let r=e.geometry.indirect;null!==r&&this.updateAttribute(r,4)}updateAttribute(e,t){let r=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}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=v(t),e.set(t,r)):(r.version!==x(t)||r.__id!==b(t))&&(this.attributes.delete(r),r=v(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()}}var T=r(51365);class S{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,T.z3)("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===g.tJf||e.type===g.OUM?t=1:e.type===g.fBL||e.type===g.cHt||e.type===g.
1ix0?t=2:(e.type===g.Yuy||e.type===g.bkx||e.type===g.RQf)&&(t=4);let r=4;e.format===g.wrO||e.format===g.VT0||e.format===g.ZQM||e.format===g.zdS||e.format===g.dcC?r=1:e.format===g.paN||e.format===g.TkQ?r=2:(e.format===g.HIg||e.format===g.VGF)&&(r=3);let i=t*r;e.type===g.Wew||e.type===g.gJ2?i=2:(e.type===g.V3x||e.type===g.Dmk||e.type===g.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 A{constructor(e){this.cacheKey=e,this.usedTimes=0}}let M=A;class w extends M{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class R extends M{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let N=0;class C{constructor(e,t,r,i=null,s=null){this.id=N++,this.code=e,this.stage=t,this.name=r,this.transforms=i,this.attributes=s,this.usedTimes=0}}class E extends m{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 C(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 C(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 C(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),h=this.caches.get(u);void 0===h?(s&&0===s.usedTimes&&this._releasePipeline(s),h=this._getRenderPipeline(e,o,l,u,t)):e.pipeline=h,h.usedTimes++,o.usedTimes++,l.usedTimes++,i.pipeline=h}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 R(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 w(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)}
vendor: 1,696 bytes, line 1
1_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 F extends m{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?4:3;this.attributes.update(t,r)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}
1}_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?4:3,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 B=Object.freeze([]);function P(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 V(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 L(e){return(e.transmission>0||e.transmissionNode&&e.transmissionNode.isNode)&&e.side===g.$EB&&!1===e.forceSinglePass}class I{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?(L(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?(L(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||P),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||V),this.transparent.length>1&&this.transparent.sort(t||V),r&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:B);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 O=[];class D{constructor(e){this.lighting=e,this.lists=new n.A}get(e,t){let r=this.lists;O[0]=e,O[1]=t;let i=r.get(O);return void 0===i&&(i=new I(this.lighting,e,t),r.set(O,i)),O[0]=null,O[1]=null,i}dispose(){this.lists=new n.A}}var U=r(25756);let z=0;class k{constructor(){this.id=z++,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.I,this.scissor=!1,this.scissorValue=new U.I,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 G(this)}}function G(e){let{textures:t,activeCubeFace:r,activeMipmapLevel:i}=e,s=[r,i];for(let e of t)s.push(e.id);return(0,o.g0)(s)}class W{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 k).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={}}}var $=r(26609),H=r(96201),j=r(68929);let q=new $.P;class X extends m{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,u=e.depthTexture||s[t],h=!0===e.depthBuffer||!0===e.stencilBuffer,d=!1,c=void 0!==u&&void 0!==u.image&&u.image.depth>1,p=n.depth>1&&(e.useArrayDepthTexture||e.multiview||c);void 0===u&&h&&((u=new H.V).format=e.stencilBuffer?g.dcC:g.zdS,u.type=e.stencilBuffer?g.V3x:g.bkx,u.image.width=o,u.image.height=l,u.image.depth=n.depth,u.renderTarget=e,s[t]=u),u&&(u.isArrayTexture=p),(r.width!==n.width||n.height!==r.height)&&(d=!0,u&&(u.needsUpdate=!0,u.image.width=o,u.image.height=l,u.image.depth=
1p?n.depth:1)),r.width=n.width,r.height=n.height,r.textures=a,r.depthTexture=u||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==i&&(d=!0,u&&(u.needsUpdate=!0),r.sampleCount=i);let m={sampleCount:i};if(!0!==e.isXRRenderTarget){for(let e=0;e<a.length;e++){let t=a[e];d&&(t.needsUpdate=!0),this.updateTexture(t,m)}u&&this.updateTexture(u,m)}!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=g.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,T.R8)("Renderer: Texture marked for update but image is undefined.");else if(!1===i.complete)(0,T.R8)("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===j.pp.enabled&&j.pp.getTransfer(e.colorSpace)!==g.KLL&&(0,T.R8)("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=q){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()
1)}this._htmlTextures.delete(e),this.delete(e),this.info.destroyTexture(e)}}}var K=r(50782);class Y extends K.Q{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)}}var Z=r(6526),Q=r(96285),J=r(2704),ee=r(61806);class et extends ee.L{constructor(e=1,t=32,r=16,i=0,s=2*Math.PI,a=0,n=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:r,phiStart:i,phiLength:s,thetaStart:a,thetaLength:n},t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));const o=Math.min(a+n,Math.PI);let l=0;const u=[],h=new $.P,d=new $.P,c=[],p=[],m=[],g=[];for(let c=0;c<=r;c++){const f=[],y=c/r,x=e*Math.cos(a+y*n),b=Math.sqrt(e*e-x*x);let v=0;0===c&&0===a?v=.5/t:c===r&&o===Math.PI&&(v=-.5/t);for(let e=0;e<=t;e++){const r=e/t,a=i+r*s;h.x=-b*Math.cos(a),h.y=x,h.z=b*Math.sin(a),p.push(h.x,h.y,h.z),d.copy(h).normalize(),m.push(d.x,d.y,d.z),g.push(r+v,1-y),f.push(l++)}u.push(f)}for(let e=0;e<r;e++)for(let i=0;i<t;i++){const t=u[e][i+1],s=u[e][i],n=u[e+1][i],l=u[e+1][i+1];(0!==e||a>0)&&c.push(t,s,l),(e!==r-1||o<Math.PI)&&c.push(s,n,l)}this.setIndex(c),this.setAttribute("position",new y.qt(p,3)),this.setAttribute("normal",new y.qt(m,3)),this.setAttribute("uv",new y.qt(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new et(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}let er=new Y;class ei extends m{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){let i=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background,a=!1;if(null===s)i._clearColor.getRGB(er),er.a=i._clearColor.a;else if(!0===s.isColor)s.getRGB(er),er.a=1,a=!0;else if(!0===s.isNode){let r=this.get(e);er.copy(i._clearColor);let a=r.backgroundMesh;if(void 0===a){let e=(0,Z.lnd)(s).mul(Z.wqm).context({getUV:()=>Z.pXN.mul(Z.arf),getTextureLevel:()=>Z.Cx3}),t=Z.KzA.element(3).element(3).equal(1),i=(0,Z.y4m)(1,Z.KzA.element(1).element(1)).mul(3),n=t.select(Z.pot.mul(i),Z.pot),o=Z.SPz.mul((0,Z.lnd)(n,0)),l=Z.KzA.mul((0,Z.lnd)(o.xyz,1));l=l.setZ(l.w);let u=new Q.A;u.name="Background.material",u.side=g.hsX,u.depthTest=!1,u.depthWrite=!1,u.allowOverride=!1,u.fog=!1,u.lights=!1,u.vertexNode=l,u.colorNode=e,r.backgroundMeshNode=e,r.backgroundMesh=a=new J.e(new et(1,32,32),u),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=(0,Z.lnd)(s).mul(Z.wqm),r.backgroundMeshNode.needsUpdate=!0,a.material.needsUpdate=!0,r.backgroundCacheKey=n),t.unshift(a,a.geometry,a.material,0,0,null,null)}else(0,T.z3)("Renderer: Unsupported background configuration.",s);let n=i.xr.getEnvironmentBlendMode();if("additive"===n?er.set(0,0,0,1):"alpha-blend"===n&&er.set(0,0,0,0),!0===i.autoClear||!0===a){let e=r.clearColorValue;e.r=er.r,e.g=er.g,e.b=er.b,e.a=er.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 es=0;class ea{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=es++}}class en{constructor(e,t,r,i,s,a,n,o,l,u,h=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=h,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 ea(t.name,[]);for(let i of(e.push(r),t.bindings))r.bindings.push(i.clone())}else e.push(t);return e}}var eo=r(5092),el=r(83815),eu=r(13662),eh=r(84551),ed=r(86389),ec=r(57641),ep=r(40786),em=r(61296),eg=r(40641),ef=r(29210),ey=r(84774),ex=r(2550);class eb extends ey.B{constructor(e,t,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ex.u(-90,1,e,t);i.layers=this.layers,this.add(i);const s=new ex.u(-90,1,e,t);s.layers=this.layers,this.add(s);const a=new ex.u(-90,1,e,t);a.layers=this.layers,this.add(a);const n=new ex.u(-90,1,e,t);n.layers=this.layers,this.add(n);const o=new ex.u(-90,1,e,t);o.layers=this.layers,this.add(o);const l=new ex.u(-90,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[r,i,s,a,n,o]=t;
1for(let e of t)this.remove(e);if(e===g.TdN)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),n.up.set(0,1,0),n.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(e===g.i7u)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),n.up.set(0,-1,0),n.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,a,n,o,l,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),c=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=r.texture.generateMipmaps;r.texture.generateMipmaps=!1;let g=!1;g=!0===e.isWebGLRenderer?e.state.buffers.depth.getReversed():e.reversedDepthBuffer,e.setRenderTarget(r,0,i),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,s),e.setRenderTarget(r,1,i),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,a),e.setRenderTarget(r,2,i),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,n),e.setRenderTarget(r,3,i),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,o),e.setRenderTarget(r,4,i),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,l),r.texture.generateMipmaps=m,e.setRenderTarget(r,5,i),g&&!1===e.autoClear&&e.clearDepth(),e.render(t,u),e.setRenderTarget(h,d,c),e.xr.enabled=p,r.texture.needsPMREMUpdate=!0}}var ev=r(24946);class e_ extends eg.O{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1};this.texture=new eh.b([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=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let s=new ev.i(5,5,5),a=(0,ec.C)(em.tv),n=new Q.A;n.colorNode=(0,ep.wH)(t,a,0),n.side=g.hsX,n.blending=g.XIg;let o=new J.e(s,n),l=new ef.Z;l.add(o),t.minFilter===g.$_I&&(t.minFilter=g.k6q);let u=new eb(1,10,this),h=e.getMRT();return e.setMRT(null),u.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 eT=new WeakMap;class eS extends eo.A{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=(0,ed.Rz)(null);const t=new eh.b;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=el.KS.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===g.wfO||r===g.uV5){if(eT.has(e)){let t=eT.get(e);eM(t,e.mapping),this._cubeTexture=t}else{var s;let r=e.image;if(null!=(s=r)&&s.height>0){let i=new e_(r.height);i.fromEquirectangularTexture(t,e),eM(i.texture,e.mapping),this._cubeTexture=i.texture,eT.set(e,i.texture),e.addEventListener("dispose",eA)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function eA(e){let t=e.target;t.removeEventListener("dispose",eA);let r=eT.get(t);void 0!==r&&(eT.delete(t),r.dispose())}function eM(e,t){t===g.wfO?e.mapping=g.hy7:t===g.uV5&&(e.mapping=g.xFO)}let ew=(0,eu.Hmo)(eS).setParameterLength(1);r(49415),r(50803);var eR=r(64994);r(15842),r(39609);var eN=r(30617);r(89670),r(19534),r(47307);var eC=r(94531);class eE{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}let eF=eE;r(89976),r(57218);class eB{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class eP{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}}
1class eV{constructor(e,t,r=!1,i=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=i}}let eL=eV;class eI extends eL{constructor(e,t,r=null,i=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=i}}class eO{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let eD=0;class eU{constructor(e=null){this.id=eD++,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)}}var ez=r(30573);class ek{constructor(e,t){this.name=e,this.members=t,this.output=!1}}var eG=r(95080),eW=r(88500),e$=r(79623),eH=r(26990),ej=r(96310);class eq{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 eX extends eq{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class eK extends eq{constructor(e,t=new ej.I){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class eY extends eq{constructor(e,t=new $.P){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class eZ extends eq{constructor(e,t=new U.I){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class eQ extends eq{constructor(e,t=new K.Q){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class eJ extends eq{constructor(e,t=new eW.k){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class e0 extends eq{constructor(e,t=new e$.d){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class e1 extends eq{constructor(e,t=new eH.k){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class e2 extends eX{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class e3 extends eK{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class e5 extends eY{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class e6 extends eZ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class e4 extends eQ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class e8 extends eJ{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class e9 extends e0{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class e7 extends e1{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}var te=r(1690);let tt=0,tr=new WeakMap,ti=new WeakMap,ts=new WeakMap,ta=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),tn=e=>/e/g.test(e)?String(e).replace(/\+/g,""):(e=Number(e))+(e%1?"":".0"),to=e=>{if(e.writeUsageCount>0)return!0;if(void 0!==e.subBuildsCache){for(let t in e.subBuildsCache)if(to(e.subBuildsCache[t]))return!0}return!1};class tl{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=(0,te.t)(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new eU,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:tt++})}isFlatShading(){return!0===this.material.flatShading||!1===this.geometry.hasAttribute("normal")}
1isOpaque(){let e=this.material;return!1===e.transparent&&e.blending===g.NTi&&!1===e.alphaToCoverage}createRenderTarget(e,t,r){return new eg.O(e,t,r)}createCubeRenderTarget(e,t){return new e_(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===g.Yuy?a="ivec":i===g.bkx&&(a="uvec"),t=s===g.VT0||s===g.ZQM?i===g.Yuy?"int":i===g.bkx?"uint":"float":s===g.paN||s===g.TkQ?`${a}2`:s===g.HIg||s===g.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=tr.get(s);void 0===a&&(a=new Map,tr.set(s,a));let n=(0,o.YZ)(i);void 0===(r=a.get(n))&&(r=new ea(e,t),a.set(n,r))}else r=new ea(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 el.$8)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!==el.KS.NONE||r!==el.KS.NONE)&&this.sequentialNodes.add(e)}buildUpdateNodes(){for(let e of this.nodes)e.getUpdateType()!==el.KS.NONE&&this.updateNodes.push(e);for(let e of this.sequentialNodes){let t=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==el.KS.NONE&&this.updateBeforeNodes.push(e),r!==el.KS.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===g.k6q||e.magFilter===g.kRr||e.magFilter===g.Cfg||e.magFilter===g.$_I||e.minFilter===g.k6q||e.minFilter===g.kRr||e.minFilter===g.Cfg||e.minFilter===g.$_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 eU(t?this.getCache():null)),r.cache}isAvailable(){return!1}getVertexIndex(){(0,T.R8)("Abstract function.")}getInstanceIndex(){(0,T.R8)("Abstract function.")}getDrawIndex(){(0,T.R8)("Abstract function.")}getFrontFacing(){(0,T.R8)("Abstract function.")}getFragCoord(){(0,T.R8)("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);
1if(void 0!==r){for(let e in r)if(to(r[e]))return!0}return!1}generateTexture(){(0,T.R8)("Abstract function.")}generateTextureLod(){(0,T.R8)("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 K.Q:"vec2"===e||"uvec2"===e||"ivec2"===e?t=new ej.I:"vec3"===e||"uvec3"===e||"ivec3"===e?t=new $.P:("vec4"===e||"uvec4"===e||"ivec4"===e)&&(t=new U.I)),"float"===e)return tn(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")}( ${tn(t.r)}, ${tn(t.g)}, ${tn(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 eB(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===g.Yuy?"int":t===g.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=(0,o.Hq)(e),i="float"===t?"":t[0];return!0===/mat2/.test(t)&&(r=r.replace("vec","mat")),i+r}getTypeFromArray(e){return ta.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 y.O||!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=(0,te.t)(this.stack);
1let e=(0,eu.I1H)();return this.stacks.push(e),(0,eu.cFV)(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,(0,eu.cFV)(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 eB(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 ek(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 eP(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]=[]),h=this.vars[l]||(this.vars[l]=0);null===t&&(t=(s?"nodeConst":"nodeVar")+h,this.vars[l]++),"variable"!==n&&(t=this.getSubBuildProperty(t,a.subBuilds));let d=e.getArrayCount(this);o=new eL(t,r,s,d),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 eI(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,T.R8)(`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 eO("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=ti.get(t);void 0===r&&(r=new WeakMap,ti.set(t,r));let i=r.get(e);if(void 0===i){i=new eG.Ay;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})}}};
1for(let e of t.inputs)r[e.name]=new ez.A(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 eU,this.stack=(0,te.t)(),el.Xp))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,T.R8)("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}; 2`),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,T.R8)("Abstract function.")}getVaryings(){(0,T.R8)("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,T.R8)("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,T.R8)("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,T.z3)('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(!0===r.contextNode.isContextNode?this.context={...this.context,...r.contextNode.getFlowContextData()}:(0,T.z3)('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),null!==r){let e=t.library.fromMaterial(r);null===e&&((0,T.z3)(`NodeBuilder: Material "${r.type}" is not compatible.`),e=new Q.A),e.build(this)}else this.addFlow("compute",e)}build(){for(let e of(this.prebuild(),el.Xp))for(let t of(this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position),el.$8))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(),el.Xp))for(let t of(this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position),el.$8)){for(let r of(this.setShaderStage(t),this.flowNodes[t]))"generate"===e?this.flowNode(r):r.build(this);await (0,T.aH)()}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUp
2dateNodes(),this}getSharedDataFromNode(e){let t=ts.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 e2(e);else if("vec2"===t||"ivec2"===t||"uvec2"===t)i=new e3(e);else if("vec3"===t||"ivec3"===t||"uvec3"===t)i=new e5(e);else if("vec4"===t||"ivec4"===t||"uvec4"===t)i=new e6(e);else if("color"===t)i=new e4(e);else if("mat2"===t)i=new e8(e);else if("mat3"===t)i=new e9(e);else if("mat4"===t)i=new e7(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${g.sPf} - Node System 3`}needsPreviousData(){let e=this.renderer.getMRT();return e&&e.has("velocity")||!0===(0,o.aC)(this.object).useVelocity}}let tu=tl;r(53148);class th{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===el.KS.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===el.KS.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===el.KS.OBJECT&&e.updateBefore(this)}updateAfterNode(e){let t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===el.KS.FRAME){let t=this._getMaps(this.updateAfterMap,r);t.frameId!==this.frameId&&!1!==e.updateAfter(this)&&(t.frameId=this.frameId)}else if(t===el.KS.RENDER){let t=this._getMaps(this.updateAfterMap,r);t.renderId!==this.renderId&&!1!==e.updateAfter(this)&&(t.renderId=this.renderId)}else t===el.KS.OBJECT&&e.updateAfter(this)}updateNode(e){let t=e.getUpdateType(),r=e.updateReference(this);if(t===el.KS.FRAME){let t=this._getMaps(this.updateMap,r);t.frameId!==this.frameId&&!1!==e.update(this)&&(t.frameId=this.frameId)}else if(t===el.KS.RENDER){let t=this._getMaps(this.updateMap,r);t.renderId!==this.renderId&&!1!==e.update(this)&&(t.renderId=this.renderId)}else t===el.KS.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 td{constructor(e,t,r=null,i="",s=!1){this.type=e,this.name=t,this.count=r,this.qualifier=i,this.isConst=s}}td.isNodeFunctionInput=!0,r(33962),r(6441);var tc=r(21387),tp=r(69707);r(68987),r(69363);var tm=r(37600),tg=r(24481),tf=r(61114),ty=r(28051);r(87954),r(19793),r(6293);var tx=r(96798);r(46537);var tb=r(44342),tv=r(90083),t_=r(27300);r(58955),r(77168),r(73705);var tT=r(14508);r(98469),r(8926),r(15024),r(70215),r(37989),r(8227);var tS=r(61046);r(29276),r(92548),r(7176);var tA=r(87801),tM=r(4470);r(94548),r(66133);var tw=r(55398),tR=r(5542);r(5032),r(29892);var tN=r(7264),tC=r(96621);r(99769),r(63300),r(82196),r(64139),r(37537);var tE=r(95538);r(33696),r(69247),r(88737),r(28350),r(39651),r(5939),r(39106);var tF=r(95944);class tB extends tF.A{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}r(48983);var tP=r(64551);class tV extends tP.A{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=ew(this.envNode)}}class tL extends tP.A{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){let t=(0,eu.fVC)(1/Math.PI);
3e.context.irradianceLightMap=this.lightMapNode.mul(t)}}var tI=r(48214);class tO extends tF.A{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){let e=this.colorNode;return{lightDirection:(0,tI.lV)(this.light),lightColor:e}}}var tD=r(75180),tU=r(74872),tz=r(66406),tk=r(91752),tG=r(87275);let tW=new WeakMap;class t$ extends tP.A{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=(0,tk.v)(i),s.set(i,a)),r=a}let i=!0===t.useAnisotropy||t.anisotropy>0?tz.Km:tU.j8,s=r.context(tH(tc.nR,i)).mul(tG.st),a=r.context(tj(tU.O7)).mul(Math.PI).mul(tG.st),n=(0,eC.az)(s),o=(0,eC.az)(a);e.context.radiance.addAssign(n),e.context.iblIrradiance.addAssign(o);let l=e.context.lightingModel.clearcoatRadiance;if(l){let e=r.context(tH(tc.v1,tU.vu)).mul(tG.st),t=(0,eC.az)(e);l.addAssign(t)}}_getPMREMNodeCache(e){let t=tW.get(e);return void 0===t&&(t=new WeakMap,tW.set(e,t)),t}}let tH=(e,t)=>{let r=null;return{getUV:()=>(null===r&&(r=em.Mv.negate().reflect(t),r=(r=(0,eu.zWV)(e).mix(r,t).normalize()).transformDirection(tD.FL)),r),getTextureLevel:()=>e}},tj=e=>({getUV:()=>e,getTextureLevel:()=>(0,eu.fVC)(1)});var tq=r(81951);class tX extends tF.A{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=(0,tI.Qp)(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=(0,tf.P)(new K.Q).setGroup(tg.sx)}update(e){let{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){let{colorNode:t,groundColorNode:r,lightDirectionNode:i}=this,s=tU.O7.dot(i).mul(.5).add(.5),a=(0,tq.jh)(r,t,s);e.context.irradiance.addAssign(a)}}var tK=r(82842);class tY extends tF.A{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=(0,tf.P)(0).setGroup(tg.sx),this.penumbraCosNode=(0,tf.P)(0).setGroup(tg.sx),this.cutoffDistanceNode=(0,tf.P)(0).setGroup(tg.sx),this.decayExponentNode=(0,tf.P)(0).setGroup(tg.sx),this.colorNode=(0,tf.P)(this.color).setGroup(tg.sx)}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(0,tq.TF)(r,i,t)}getLightCoord(e){let t=e.getNodeProperties(this),r=t.projectionUV;return void 0===r&&(t.projectionUV=r=(0,tI.hs)(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((0,tI.lV)(n)),h=this.getSpotAttenuation(e,u),d=o.length(),c=(0,tK.A)({lightDistance:d,cutoffDistance:s,decayExponent:a}),p=i.mul(h).mul(c);return n.colorNode?(r=this.getLightCoord(e),t=n.colorNode(r)):n.map&&(r=this.getLightCoord(e),t=(0,ep.wH)(n.map,r.xy).onRenderUpdate(()=>n.map)),t&&(p=r.mul(2).sub(1).abs().lessThan(1).all().select(p.mul(t),p)),{lightColor:p,lightDirection:l}}}let tZ=tY;class tQ extends tZ{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=(0,ep.wH)(r,(0,eu.ZcS)(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)}}r(99209),r(24222);var tJ=r(47330);class t0 extends tF.A{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new $.P);this.lightProbe=(0,tS.W)(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=(0,tJ.A)(tU.O7,this.lightProbe);
3e.context.irradiance.addAssign(t)}}var t1=r(31450),t2=r(83861);r(41601);var t3=r(12106),t5=r(98121);let t6=(0,t3.Fn)(([e,t])=>{let r=e.abs().sub(t);return(0,tq.Bw)((0,tq.T9)(r,0)).add((0,tq.jk)((0,tq.T9)(r.x,r.y),0))});class t4 extends tZ{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=(0,t3.fV)(0),r=this.penumbraCosNode,i=(0,tI.Ey)(this.light).mul(e.context.positionWorld||em.MI);return(0,t3.If)(i.w.greaterThan(0),()=>{let e=t6(i.xyz.div(i.w).xy.sub((0,t3.Zc)(.5)),(0,t3.Zc)(.5)),s=(0,t5.y4)(-1,(0,t5.jb)(1,(0,tq.HQ)(r)).sub(1));t.assign((0,tq.Ih)(e.mul(-2).mul(s)))}),t}}let t8=new eH.k,t9=new eH.k,t7=null;class re extends tF.A{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=(0,tf.P)(new $.P).setGroup(tg.sx),this.halfWidth=(0,tf.P)(new $.P).setGroup(tg.sx),this.updateType=el.KS.RENDER}update(e){super.update(e);let{light:t}=this,r=e.camera.matrixWorldInverse;t9.identity(),t8.copy(t.matrixWorld),t8.premultiply(r),t9.extractRotation(t8),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(t9),this.halfHeight.value.applyMatrix4(t9)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=(0,ep.wH)(t7.LTC_FLOAT_1),r=(0,ep.wH)(t7.LTC_FLOAT_2)):(t=(0,ep.wH)(t7.LTC_HALF_1),r=(0,ep.wH)(t7.LTC_HALF_2));let{colorNode:i,light:s}=this;return{lightColor:i,lightPosition:(0,tI.p)(s),halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){t7=e}}r(67850),r(56759),r(78879),r(29335),r(71115),r(29950),r(59759);class rt{parseFunction(){(0,T.R8)("Abstract function.")}}let rr=rt;class ri{constructor(e,t,r="",i=""){this.type=e,this.inputs=t,this.name=r,this.precision=i}getCode(){(0,T.R8)("Abstract function.")}}ri.isNodeFunction=!0;let rs=ri,ra=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,rn=/[a-z_0-9]+/ig,ro="#pragma main";class rl extends rs{constructor(e){const{type:t,inputs:r,name:i,precision:s,inputsCode:a,blockCode:n,headerCode:o}=(e=>{let t=(e=e.trim()).indexOf(ro),r=-1!==t?e.slice(t+ro.length):e,i=r.match(ra);if(null!==i&&5===i.length){let s=i[4],a=[],n=null;for(;null!==(n=rn.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 td(r,s,i,t,e))}let u=r.substring(i[0].length),h=void 0!==i[3]?i[3]:"",d=i[2];return{type:d,inputs:o,name:h,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 ru extends rr{parseFunction(e){return new rl(e)}}r(15907),r(7519),r(78771),r(80904),r(26719),r(92222),r(24328);var rh=r(30710);r(29646),r(38530),r(56288);var rd=r(89039);r(82590),r(1806),r(72156),r(38028),r(94018);class rc extends eF{constructor(){super()}indirect({context:e}){let t=e.ambientOcclusion,r=e.reflectedLight,i=e.irradianceLightMap;r.indirectDiffuse.assign((0,eu.lnd)(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign((0,eu.lnd)(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(tc.YL.rgb)}finish(e){let{material:t,context:r}=e,i=r.outgoingLight,s=e.context.environment;if(s)switch(t.combine){case g.caT:i.rgb.assign((0,tq.jh)(i.rgb,i.rgb.mul(s.rgb),tb.O_.mul(tb.wk)));break;case g.KRh:i.rgb.assign((0,tq.jh)(i.rgb,s.rgb,tb.O_.mul(tb.wk)));break;case g.XrR:i.rgb.addAssign(s.rgb.mul(tb.O_.mul(tb.wk)));break;
3default:(0,T.R8)("BasicLightingModel: Unsupported .combine value:",t.combine)}}}let rp=rc;var rm=r(5972),rg=r(93410);let rf=(0,eu.Fn)(({dotNH:e})=>tc.zO.mul((0,eu.fVC)(.5)).add(1).mul((0,eu.fVC)(1/Math.PI)).mul(e.pow(tc.zO))),ry=(0,eu.Fn)(({lightDirection:e})=>{let t=e.add(em.Mv).normalize(),r=tU.j8.dot(t).clamp(),i=em.Mv.dot(t).clamp(),s=(0,rm.A)({f0:tc.vy,f90:1,dotVH:i}),a=(0,eu.fVC)(.25),n=rf({dotNH:r});return s.mul(a).mul(n)});class rx extends rp{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){let i=tU.j8.dot(e).clamp().mul(t);r.directDiffuse.addAssign(i.mul((0,rg.A)({diffuseColor:tc.YL.rgb}))),!0===this.specular&&r.directSpecular.addAssign(i.mul(ry({lightDirection:e})).mul(tb.O_))}indirect(e){let{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul((0,rg.A)({diffuseColor:tc.YL}))),i.indirectDiffuse.mulAssign(t)}}var rb=r(51187),rv=r(45622);let r_=(0,eu.Fn)(({lightDirection:e,f0:t,f90:r,roughness:i,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:n})=>{let o=(0,rb.A)({lightDirection:e,f0:t,f90:r,roughness:i,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:n}),l=tU.j8.dot(e).clamp(),u=tU.j8.dot(em.Mv).clamp(),h=(0,rv.A)({roughness:i,dotNV:u}),d=(0,rv.A)({roughness:i,dotNV:l}),c=t.mul(h.x).add(r.mul(h.y)),p=t.mul(d.x).add(r.mul(d.y)),m=h.x.add(h.y),g=d.x.add(d.y),f=(0,eu.fVC)(1).sub(m),y=(0,eu.fVC)(1).sub(g),x=t.add(t.oneMinus().mul(.047619)),b=c.mul(p).mul(x).div((0,eu.fVC)(1).sub(f.mul(y).mul(x).mul(x)).add(tq.p8)),v=f.mul(y),_=b.mul(v);return o.add(_)}),rT=(0,eu.Fn)(e=>{let{dotNV:t,specularColor:r,specularF90:i,roughness:s}=e,a=(0,rv.A)({dotNV:t,roughness:s});return r.mul(a.x).add(i.mul(a.y))});var rS=r(65462);let rA=(0,eu.Fn)(({roughness:e,dotNH:t})=>{let r=e.pow2(),i=(0,eu.fVC)(1).div(r),s=t.pow2().oneMinus().max(.0078125);return(0,eu.fVC)(2).add(i).mul(s.pow(i.mul(.5))).div(2*Math.PI)}
3).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),rM=(0,eu.Fn)(({dotNV:e,dotNL:t})=>(0,eu.fVC)(1).div((0,eu.fVC)(4).mul(t.add(e).sub(t.mul(e))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),rw=(0,eu.Fn)(({lightDirection:e})=>{let t=e.add(em.Mv).normalize(),r=tU.j8.dot(e).clamp(),i=tU.j8.dot(em.Mv).clamp(),s=tU.j8.dot(t).clamp(),a=rA({roughness:tc.AB,dotNH:s}),n=rM({dotNV:i,dotNL:r});return tc.MQ.mul(a).mul(n)}),rR=(0,eu.Fn)(({N:e,V:t,roughness:r})=>{let i=e.dot(t).saturate(),s=(0,eu.ZcS)(r,i.oneMinus().sqrt());return s.assign(s.mul(.984375).add(.0078125)),s}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),rN=(0,eu.Fn)(({f:e})=>{let t=e.length();return(0,tq.T9)(t.mul(t).add(e.z).div(t.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),rC=(0,eu.Fn)(({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,(0,tq.T9)(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"}]}),rE=(0,eu.Fn)(({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(),h=l.cross(u),d=(0,eu.eR5)().toVar();return(0,eu.If)(h.dot(r.sub(s)).greaterThanEqual(0),()=>{let l=t.sub(e.mul(t.dot(e))).normalize(),u=e.cross(l).negate(),h=i.mul((0,eu.w00)(l,u,e).transpose()).toVar(),c=h.mul(s.sub(r)).normalize().toVar(),p=h.mul(a.sub(r)).normalize().toVar(),m=h.mul(n.sub(r)).normalize().toVar(),g=h.mul(o.sub(r)).normalize().toVar(),f=(0,eu.eR5)(0).toVar();f.addAssign(rC({v1:c,v2:p})),f.addAssign(rC({v1:p,v2:m})),f.addAssign(rC({v1:m,v2:g})),f.addAssign(rC({v1:g,v2:c})),d.assign((0,eu.eR5)(rN({f:f})))}),d}).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"}]});(0,eu.Fn)(({P:e,p0:t,p1:r,p2:i,p3:s})=>{let a=r.sub(t).toVar(),n=s.sub(t).toVar(),o=a.cross(n),l=(0,eu.eR5)().toVar();return(0,eu.If)(o.dot(e.sub(t)).greaterThanEqual(0),()=>{let a=t.sub(e).normalize().toVar(),n=r.sub(e).normalize().toVar(),o=i.sub(e).normalize().toVar(),u=s.sub(e).normalize().toVar(),h=(0,eu.eR5)(0).toVar();h.addAssign(rC({v1:a,v2:n})),h.addAssign(rC({v1:n,v2:o})),h.addAssign(rC({v1:o,v2:u})),h.addAssign(rC({v1:u,v2:a})),l.assign((0,eu.eR5)(rN({f:h.abs()})))}),l}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]});var rF=r(7439);let rB=(0,eu.Fn)(([e,t,r,i,s])=>{let a=(0,eu.eR5)((0,tq.e)(t.negate(),(0,tq.S8)(e),(0,t5.y4)(1,i))),n=(0,eu.eR5)((0,tq.Bw)(s[0].xyz),(0,tq.Bw)(s[1].xyz),(0,tq.Bw)(s[2].xyz));return(0,tq.S8)(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"}]}),rP=(0,eu.Fn)(([e,t])=>e.mul((0,tq.qE)(t.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),rV=(0,tE.gu)(),rL=(0,tE.VM)(),rI=(0,eu.Fn)(([e,t,r],{material:i})=>{let s=(i.side===g.hsX?rV:rL).sample(e),a=(0,tq.p6)(tC.es.x).mul(rP(t,r));return(0,rF.x)(s,a)}),rO=(0,eu.Fn)(([e,t,r])=>((0,eu.If)(r.notEqual(0),()=>{let i=(0,tq.Rm)(t).negate().div(r);return(0,tq.oN)(i.negate().mul(e))}),(0,eu.eR5)(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),rD=(0,eu.Fn)(([e,t,r,i,s,a,n,o,l,u,h,d,c,p,m])=>{let g,f;if(m){g=(0,eu.lnd)().toVar(),f=(0,eu.eR5)().toVar();let s=h.sub(1).mul(m.mul(.025)),a=(0,eu.eR5)(h.sub(s),h,h.add(s));(0,rh.FZ)({start:0,end:3},({i:s})=>
3{let h=a.element(s),m=rB(e,t,d,h,o),y=n.add(m),x=u.mul(l.mul((0,eu.lnd)(y,1))),b=(0,eu.ZcS)(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign((0,eu.ZcS)(b.x,b.y.oneMinus()));let v=rI(b,r,h);g.element(s).assign(v.element(s)),g.a.addAssign(v.a),f.element(s).assign(i.element(s).mul(rO((0,tq.Bw)(m),c,p).element(s)))}),g.a.divAssign(3)}else{let s=rB(e,t,d,h,o),a=n.add(s),m=u.mul(l.mul((0,eu.lnd)(a,1))),y=(0,eu.ZcS)(m.xy.div(m.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign((0,eu.ZcS)(y.x,y.y.oneMinus())),g=rI(y,r,h),f=i.mul(rO((0,tq.Bw)(s),c,p))}let y=f.rgb.mul(g.rgb),x=e.dot(t).clamp(),b=(0,eu.eR5)(rT({dotNV:x,specularColor:s,specularF90:a,roughness:r})),v=f.r.add(f.g,f.b).div(3);return(0,eu.lnd)(b.oneMinus().mul(y),g.a.oneMinus().mul(v).oneMinus())}),rU=(0,eu.w00)(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),rz=(e,t)=>e.sub(t).div(e.add(t)).pow2(),rk=(0,eu.Fn)(({outsideIOR:e,eta2:t,cosTheta1:r,thinFilmThickness:i,baseF0:s})=>{let a,n=(0,tq.jh)(e,t,(0,tq.TF)(0,.03,i)),o=e.div(n).pow2().mul(r.pow2().oneMinus()).oneMinus();(0,eu.If)(o.lessThan(0),()=>(0,eu.eR5)(1));let l=o.sqrt(),u=rz(n,e),h=(0,rm.A)({f0:u,f90:1,dotVH:r}),d=h.oneMinus(),c=n.lessThan(e).select(Math.PI,0),p=(0,eu.fVC)(Math.PI).sub(c),m=(a=s.clamp(0,.9999).sqrt(),(0,eu.eR5)(1).add(a).div((0,eu.eR5)(1).sub(a))),g=rz(m,n.toVec3()),f=(0,rm.A)({f0:g,f90:1,dotVH:l}),y=(0,eu.eR5)(m.x.lessThan(n).select(Math.PI,0),m.y.lessThan(n).select(Math.PI,0),m.z.lessThan(n).select(Math.PI,0)),x=n.mul(i,l,2),b=(0,eu.eR5)(p).add(y),v=h.mul(f).clamp(1e-5,.9999),_=v.sqrt(),T=d.pow2().mul(f).div((0,eu.eR5)(1).sub(v)),S=h.add(T).toVar(),A=T.sub(d).toVar();return(0,rh.FZ)({start:1,end:2,condition:"<=",name:"m"},({m:e})=>{var t,r;let i,s,a,n,o,l;A.mulAssign(_);let u=(t=(0,eu.fVC)(e).mul(x),r=(0,eu.fVC)(e).mul(b),i=t.mul(2*Math.PI*1e-9),s=(0,eu.eR5)(54856e-17,44201e-17,52481e-17),a=(0,eu.eR5)(1681e3,1795300,2208400),n=(0,eu.eR5)(43278e5,93046e5,66121e5),o=(0,eu.fVC)(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(i.mul(2239900).add(r.x).cos()).mul(i.pow2().mul(-45282e5).exp()),l=s.mul(n.mul(2*Math.PI).sqrt()).mul(a.mul(i).add(r).cos()).mul(i.pow2().negate().mul(n).exp()),l=(0,eu.eR5)(l.x.add(o),l.y,l.z).div(10685e-11),rU.mul(l)).mul(2);S.addAssign(A.mul(u))}),S.max((0,eu.eR5)(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"}]}),rG=(0,eu.Fn)(({normal:e,viewDir:t,roughness:r})=>{let i=e.dot(t).saturate(),s=r.mul(r),a=r.add(.1).reciprocal(),n=(0,eu.fVC)(-1.9362).add(r.mul(1.0678)).add(s.mul(.4573)).sub(a.mul(.8469)),o=(0,eu.fVC)(-.6014).add(r.mul(.5538)).sub(s.mul(.467)).sub(a.mul(.1255));return n.mul(i).add(o).exp().saturate()}),rW=(0,eu.eR5)(.04),r$=(0,eu.fVC)(1);class rH extends eF{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=(0,eu.eR5)().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=(0,eu.eR5)().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=(0,eu.eR5)().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=(0,eu.eR5)().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=(0,eu.eR5)().toVar("sheenSpecularIndirect")),!0===this.iridescence){let e=tU.j8.dot(em.Mv).clamp(),t=rk({outsideIOR:(0,eu.fVC)(1),eta2:tc.rS,cosTheta1:e,thinFilmThickness:tc.HW,baseF0:tc.vy}),r=rk({outsideIOR:(0,eu.fVC)(1),eta2:tc.rS,cosTheta1:e,thinFilmThickness:tc.HW,baseF0:tc.YL.rgb});this.iridescenceFresnel=(0,tq.jh)(t,r,tc.lV),this.iridescenceF0Dielectric=(0,rS.A)({f:t,f90:1,dotVH:e}),this.iridescenceF0Metallic=(0,rS.A)({f:r,f90:1,dotVH:e}),this.iridescenceF0=(0,tq.jh)(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,tc.lV)}if(!0===this.transmission){let t=em.MI,r=tD.fr.sub(em.MI).normalize(),i=tU.O7,s=e.context;s.backdrop=rD(i,r,tc.nR,tc.v,tc.pf,tc.dX,t,t_.n6,tD.S3,tD.Kz,tc.lq,tc.Xf,tc.mr,tc.ym,this.dispersion?tc.HG:null),s.backdropAlpha=tc.vN,tc.YL.a.mulAssign((0,tq.jh)(1,s.backdrop.a,tc.vN))}super.start(e)}computeMultiscattering(e,t,r,i,s=null){let a=tU.j8.dot(em.Mv).clamp(),n=(0,rv.A)({roughness:tc.nR,dotNV:a}),o=s?tc.tj.mix(i,s):i,l=o.mul(n.x).add(r.mul(n.y)),u=n.x.add(n.y).oneMinus(),h=o.add(o.oneMinus().mul(.047619)),d=l.mul(h).div(u.mul(h).oneMinus());e.addAssign(l),t.addAssign(d.mul(u))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){let i=tU.j8.dot(e).clamp().mul(t).toVar();if(!0===this.sheen){this.sheenSpecularDirect.addAssign(i.mul(rw({lightDirection:e})));let t=rG({normal:tU.j8,viewDir:em.Mv,roughness:tc.AB}),r=rG({normal:tU.j8,viewDir:e,roughness:tc.AB}),s=tc.MQ.r.max(tc.MQ.g).max(tc.MQ.b).mul(t.max(r)).oneMinus();i.mulAssign(s)}if(!0===this.clearcoat){let r=tU.vu.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(r.mul((0,rb.A)({lightDirection:e,f0:rW,f90:r$,roughness:tc.v1,normalView:tU.vu})))}r.directDiffuse.addAssign(i.mul((0,rg.A)({diffuseColor:tc.v}))),r.directSpecular.addAssign(i.mul(r_({lightDirection:e,f0:tc.pf,f90:1,roughness:tc.nR,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),h=t.add(r).add(i),d=tU.j8,c=em.Mv,p=em.tX.toVar(),m=rR({N:d,V:c,roughness:tc.nR}),g=a.sample(m).toVar(),f=n.sample(m).toVar(),y=(0,eu.w00)((0,eu.eR5)(g.x,0,g.y),(0,eu.eR5)(0,1,0),(0,eu.eR5)(g.z,0,g.w)).toVar(),x=tc.pf.mul(f.x).add(tc.dX.sub(tc.pf).mul(f.y)).toVar();if(s.directSpecular.addAssign(e.mul(x).mul(rE({N:d,V:c,P:p,mInv:y,p0:o,p1:l,p2:u,p3:h}))),s.directDiffuse.addAssign(e.mul(tc.v).mul(rE({N:d,V:c,P:p,mInv:(0,eu.w00)(1,0,0,0,1,0,0,0,1),p0:o,p1:l,p2:u,p3:h}))),!0===this.clearcoat){let t=tU.vu,r=rR({N:t,V:c,roughness:tc.v1}),i=a.sample(r),s=n.sample(r),d=(0,eu.w00)((0,eu.eR5)(i.x,0,i.y),(0,eu.eR5)(0,1,0),(0,eu.eR5)(i.z,0,i.w)),m=rW.mul(s.x).add(r$.sub(rW).mul(s.y));this.clearcoatSpecularDirect.addAssign(e.mul(m).mul(rE({N:t,V:c,P:p,mInv:d,p0:o,p1:l,p2:u,p3:h})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){let{irradiance:t,reflectedLight:r}=e.context,i=t.mul((0,rg.A)({diffuseColor:tc.v})).toVar();if(!0===this.sheen){let e=rG({normal:tU.j8,viewDir:em.Mv,roughness:tc.AB}),t=tc.MQ.r.max(tc.MQ.g).max(tc.MQ.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(tc.MQ,rG({normal:tU.j8,viewDir:em.Mv,roughness:tc.AB}))),!0===this.clearcoat){let e=rT({dotNV:tU.vu.dot(em.Mv).clamp(),specularColor:rW,specularF90:r$,roughness:tc.v1});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(e))}let s=(0,eu.eR5)().toVar("singleScatteringDielectric"),a=(0,eu.eR5)().toVar("multiScatteringDielectric"),n=(0,eu.eR5)().toVar("singleScatteringMetallic"),o=(0,eu.eR5)().toVar("multiScatteringMetallic");this.computeMultiscattering(s,a,tc.dX,tc.vy,this.iridescenceF0Dielectric),this.computeMultiscattering(n,o,tc.dX,tc.YL.rgb,this.iridescenceF0Metallic);let l=(0,tq.jh)(s,n,tc.lV),u=(0,tq.jh)(a,o,tc.lV),h=s.add(a),d=tc.v.mul(h.oneMinus()),c=r.mul(1/Math.PI),p=t.mul(l).add(u.mul(c)).toVar(),m=d.mul(c).toVar();if(!0===this.sheen){let e=rG({normal:tU.j8,viewDir:em.Mv,roughness:tc.AB}),t=tc.MQ.r.max(tc.MQ.g).max(tc.MQ.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=tU.j8.dot(em.Mv).clamp().add(t),s=tc.nR.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=tU.vu.dot(em.Mv).clamp(),r=(0,rm.A)({dotVH:e,f0:rW,f90:r$}),i=t.mul(tc.ti.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(tc.ti));t.assign(i)}if(!0===this.sheen){let e=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(e)}}}let rj=[],rq=[],rX=(0,Z.PiW)(0,"int").setGroup(Z.sxC);class rK extends m{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new th,this.nodeBuilderCache=new Map,this.callHashCache=new n.A,this.groupsData=new n.A,this._buildQueue=[],this._buildInProgress=!1,this.cacheLib={}}updateGroup(e){let t=e.groupNode;
3if(t.updateType===el.KS.OBJECT)return!0;rj[0]=t,rj[1]=e;let r=this.groupsData.get(rj);return void 0===r&&this.groupsData.set(rj,r={}),rj[0]=null,rj[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.getOutputRenderTarget()&&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 Q.A),t?await r.buildAsync():r.build(),(0,T.z3)("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 Q.A)).build();let r=i.stackTrace;!r&&i.stack&&(r=new tp.A(i.stack)),(0,T.z3)("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 en(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}
3getBackgroundNode(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){rj[0]=e,rj[1]=t;let r=this.renderer.info.calls,i=this.callHashCache.get(rj)||{};if(i.callId!==r){if(rq.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),rq.push(+!!this.renderer.lighting.enabled),this.renderer.lighting.enabled){rq.push(t.getCacheKey(!0)),rq.push(+!!this.renderer.shadowMap.enabled),rq.push(this.renderer.shadowMap.type);let r=this.getEnvironmentNode(e);r&&rq.push(r.getCacheKey())}let s=this.getFogNode(e);s&&rq.push(s.getCacheKey()),i.callId=r,i.cacheKey=(0,o.g0)(rq),this.callHashCache.set(rj,i),rq.length=0}return rj[0]=null,rj[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===g.wfO||r.mapping===g.uV5||r.mapping===g.Om)if(e.backgroundBlurriness>0||r.mapping===g.Om)return(0,Z.vFZ)(r);else return ew(!0===r.isCubeTexture?(0,Z.Rzx)(r):(0,Z.wHr)(r));if(!0===r.isTexture)return(0,Z.wHr)(r,Z.m11.flipY()).setUpdateMatrix(!0);!0!==r.isColor&&(0,T.z3)("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){let e=(0,Z.irg)("color","color",r).setGroup(Z.sxC),t=(0,Z.irg)("density","float",r).setGroup(Z.sxC);return(0,Z.rYY)(e,(0,Z.WND)(t))}if(r.isFog){let e=(0,Z.irg)("color","color",r).setGroup(Z.sxC),t=(0,Z.irg)("near","float",r).setGroup(Z.sxC),i=(0,Z.irg)("far","float",r).setGroup(Z.sxC);return(0,Z.rYY)(e,(0,Z.flI)(t,i))}(0,T.z3)("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?(0,Z.Rzx)(r):!0===r.isTexture?(0,Z.wHr)(r):void(0,T.z3)("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?(0,Z.wHr)(e,Z.m11).depth((0,tx.S)("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):(0,Z.wHr)(e,Z.m11).depth(rX).renderOutput(t.toneMapping,t.currentColorSpace):(0,Z.wHr)(e,Z.m11).renderOutput(t.toneMapping,t.currentColorSpace)}setOutputLayerIndex(e){rX.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 th,this.nodeBuilderCache=new Map,this.cacheLib={}}}var rY=r(44063);let rZ=new rY.Z;class rQ{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new eH.k,this.viewNormalMatrix=new e$.d,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++){rZ.copy(e[s]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);let i=t[r+s],a=rZ.normal;i.x=-a.x,i.y=-a.y,i.z=-a.z,i.w=rZ.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.I;s=!0}this.projectPlanes(a,r,i),s&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}
3getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return void 0===t&&(t=new rQ(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}var rJ=r(66463);class r0{constructor(e,t,r){this.bundleGroup=e,this.camera=t,this.renderContext=r}}let r1=[];class r2{constructor(){this.bundles=new n.A}get(e,t,r){let i=this.bundles;r1[0]=e,r1[1]=t,r1[2]=r;let s=i.get(r1);return void 0===s&&(s=new r0(e,t,r),i.set(r1,s)),r1[0]=null,r1[1]=null,r1[2]=null,s}dispose(){this.bundles=new n.A}}class r3{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,T.R8)(`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,T.R8)(`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 r5=r3,r6=new t1.A,r4=new WeakMap;class r8{constructor(){this.enabled=!0,this._cache=[]}createNode(e=[]){return new t1.A().setLights(e)}getNode(e){if(!0!==e.isScene&&!0!==e.isGroup)return r6;let t=r4.get(e);return void 0===t&&(t=this.createNode(),r4.set(e,t)),t}beginRender(e){this._cache.push(this.getNode(e).getLights())}finishRender(e){this.getNode(e).setLights(this._cache.pop())}}class r9 extends ex.u{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}var r7=r(83745),ie=r(65415),it=r(51166);class ir extends ey.B{constructor(){super(),this.isGroup=!0,this.type="Group"}}let ii={type:"move"};class is{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new ir,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new ir,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new $.P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new $.P),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new ir,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new $.P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new $.P,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let r of e.hand.values())this._getHandJoint(t,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,r){let i=null,s=null,a=null,n=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){for(let i of(a=!0,e.hand.values())){let e=t.getJointPose(i,r),s=this._getHandJoint(l,i);null!==e&&(s.matrix.fromArray(e.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,s.jointRadius=e.radius),s.visible=null!==e}let i=l.joints["index-finger-tip"],s=l.joints["thumb-tip"],n=i.position.distanceTo(s.position);l.inputState.pinching&&n>.025?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&n<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&null!==(s=t.getPose(e.gripSpace,r))&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,o.eventsEnabled&&o.dispatchEvent({type:"gripUpdated",data:e,target:this}));null!==n&&(null===(i=t.getPose(e.targetRaySpace,r))&&null!==s&&(i=s),null!==i&&(n.matrix.fromArray(i.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),n.matrixWorldNeedsUpdate=!0,i.linearVelocity?(n.hasLinearVelocity=!0,n.linearVelocity.copy(i.linearVelocity)):n.hasLinearVelocity=!1,i.angularVelocity?(n.hasAngularVelocity=!0,n.angularVelocity.copy(i.angularVelocity)):n.hasAngularVelocity=!1,this.dispatchEvent(ii)))}return null!==n&&(n.visible=null!==i),null!==o&&(o.visible=null!==s),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let r=new ir;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class ia extends eg.O{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}}class io extends ee.L{constructor(e=1,t=1,r=1,i=32,s=1,a=!1,n=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiu
3sTop:e,radiusBottom:t,height:r,radialSegments:i,heightSegments:s,openEnded:a,thetaStart:n,thetaLength:o};const l=this;i=Math.floor(i),s=Math.floor(s);const u=[],h=[],d=[],c=[];let p=0;const m=[],g=r/2;let f=0;function x(r){let s=p,a=new ej.I,m=new $.P,y=0,x=!0===r?e:t,b=!0===r?1:-1;for(let e=1;e<=i;e++)h.push(0,g*b,0),d.push(0,b,0),c.push(.5,.5),p++;let v=p;for(let e=0;e<=i;e++){let t=e/i*o+n,r=Math.cos(t),s=Math.sin(t);m.x=x*s,m.y=g*b,m.z=x*r,h.push(m.x,m.y,m.z),d.push(0,b,0),a.x=.5*r+.5,a.y=.5*s*b+.5,c.push(a.x,a.y),p++}for(let e=0;e<i;e++){let t=s+e,i=v+e;!0===r?u.push(i,i+1,t):u.push(i+1,i,t),y+=3}l.addGroup(f,y,!0===r?1:2),f+=y}(function(){let a=new $.P,y=new $.P,x=0,b=(t-e)/r;for(let l=0;l<=s;l++){let u=[],f=l/s,x=f*(t-e)+e;for(let e=0;e<=i;e++){let t=e/i,s=t*o+n,l=Math.sin(s),m=Math.cos(s);y.x=x*l,y.y=-f*r+g,y.z=x*m,h.push(y.x,y.y,y.z),a.set(l,b,m).normalize(),d.push(a.x,a.y,a.z),c.push(t,1-f),u.push(p++)}m.push(u)}for(let r=0;r<i;r++)for(let i=0;i<s;i++){let a=m[i][r],n=m[i+1][r],o=m[i+1][r+1],l=m[i][r+1];(e>0||0!==i)&&(u.push(a,n,l),x+=3),(t>0||i!==s-1)&&(u.push(n,o,l),x+=3)}l.addGroup(f,x,0),f+=x})(),!1===a&&(e>0&&x(!0),t>0&&x(!1)),this.setIndex(u),this.setAttribute("position",new y.qt(h,3)),this.setAttribute("normal",new y.qt(d,3)),this.setAttribute("uv",new y.qt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new io(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}var il=r(55105),iu=r(71497);let ih=new $.P,id=new $.P,ic=new WeakMap;class ip extends r7.Q{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new ex.u,this._cameraL.viewport=new U.I,this._cameraL.matrixWorldAutoUpdate=!1,this._cameraR=new ex.u,this._cameraR.viewport=new U.I,this._cameraR.matrixWorldAutoUpdate=!1,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new r9,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=ib.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSamples=null,this._currentSize=new ej.I,this._onSessionEvent=ig.bind(this),this._onSessionEnd=iy.bind(this),this._onInputSourcesChange=ix.bind(this),this._onAnimationFrame=iv.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,T.R8)("XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,!0===this.isPresenting&&(0,T.R8)("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;
3let 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,T.mc)(`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,T.mc)("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 eg.O(r.textureWidth,r.textureHeight,{depth:2,minFilter:g.k6q,magFilter:g.k6q,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,!0===this._useMultiviewIfPossible&&(0,T.mc)("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}
3_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 il.b(e,t),u=new ia(s,a,{format:g.GWd,type:g.OUM,depthTexture:new H.V(s,a,o.stencil?g.V3x:g.bkx,void 0,void 0,void 0,void 0,void 0,void 0,o.stencil?g.dcC:g.zdS),stencilBuffer:o.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});u._autoAllocateDepthBuffer=!0;let h=new iu.V({color:0xffffff,side:g.hB5});h.map=u.texture,h.map.offset.y=1,h.map.repeat.y=-1;let d=new J.e(l,h);d.position.copy(r),d.quaternion.copy(i);let c={type:"quad",width:e,height:t,translation:r,quaternion:i,pixelwidth:s,pixelheight:a,plane:d,material:h,rendercall:n,renderTarget:u};if(this._layers.push(c),null!==this._session){c.plane.material=new iu.V({color:0xffffff,side:g.hB5}),c.plane.material.blending=g.bCz,c.plane.material.blendEquation=g.gO9,c.plane.material.blendSrc=g.ojh,c.plane.material.blendDst=g.ojh,c.xrlayer=this._createXRLayer(c);let e=this._session.renderState.layers;e.unshift(c.xrlayer),this._session.updateRenderState({layers:e})}else u.isXRRenderTarget=!1;return d}createCylinderLayer(e,t,r,i,s,a,n,o,l={}){let u=new io(e,e,e*t/r,64,64,!0,Math.PI-t/2,t),h=new ia(a,n,{format:g.GWd,type:g.OUM,depthTexture:new H.V(a,n,l.stencil?g.V3x:g.bkx,void 0,void 0,void 0,void 0,void 0,void 0,l.stencil?g.dcC:g.zdS),stencilBuffer:l.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});h._autoAllocateDepthBuffer=!0;let d=new iu.V({color:0xffffff,side:g.hsX});d.map=h.texture,d.map.offset.y=1,d.map.repeat.y=-1;let c=new J.e(u,d);c.position.copy(i),c.quaternion.copy(s);let p={type:"cylinder",radius:e,centralAngle:t,aspectratio:r,translation:i,quaternion:s,pixelwidth:a,pixelheight:n,plane:c,material:d,rendercall:o,renderTarget:h};if(this._layers.push(p),null!==this._session){p.plane.material=new iu.V({color:0xffffff,side:g.hsX}),p.plane.material.blending=g.bCz,p.plane.material.blendEquation=g.gO9,p.plane.material.blendSrc=g.ojh,p.plane.material.blendDst=g.ojh,p.xrlayer=this._createXRLayer(p);let e=this._session.renderState.layers;e.unshift(p.xrlayer),this._session.updateRenderState({layers:e})}else h.isXRRenderTarget=!1;return c}renderLayers(){let e=new $.P,t=new ie.P,r=this._renderer,i=this.isPresenting;this.isPresenting=!1;let s=new ej.I;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=ic.get(a))&&(s=a.context({getOutput:e=>(0,tN.C)(e,r.toneMapping,r.outputColorSpace)}),ic.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
3idateWebGPUSession(),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?g.dcC:g.zdS,s=t.stencil?g.V3x:g.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),u=[l];this._glProjLayer=l,t.setPixelRatio(1),t._setXRLayerSize(l.textureWidth,l.textureHeight);let h=this._useMultiview?2:1,d=new H.V(l.textureWidth,l.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i,h);if(this._xrRenderTarget=new ia(l.textureWidth,l.textureHeight,{format:g.GWd,type:g.OUM,c
3olorSpace:t.outputColorSpace,depthTexture:d,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 iu.V({color:0xffffff,side:"cylinder"===e.type?g.hsX:g.hB5}),e.plane.material.blending=g.bCz,e.plane.material.blendEquation=g.gO9,e.plane.material.blendSrc=g.ojh,e.plane.material.blendDst=g.ojh,e.xrlayer=this._createXRLayer(e),u.unshift(e.xrlayer);e.updateRenderState({layers:u})}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 ia(i.framebufferWidth,i.framebufferHeight,{format:g.GWd,type:g.OUM,c
3olorSpace: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,u=this._cameraR;o.near=u.near=l.near=a,o.far=u.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,u.layers.mask=-3&o.layers.mask;let h=e.parent,d=o.cameras;im(o,h);for(let e=0;e<d.length;e++)im(d[e],h);2===d.length?function(e,t,r){ih.setFromMatrixPosition(t.matrixWorld),id.setFromMatrixPosition(r.matrixWorld);let i=ih.distanceTo(id),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],h=(s[8]-1)/s[0],d=(a[8]+1)/a[0],c=i/(-h+d),p=-(c*h);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*h-p,n*d+(i-p),l*o/r*t,u*o/r*t,t,r),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}(o,l,u):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*it.a5*Math.atan(1/t.projectionMatrix.elements[5]),t.zoom=1)}_getController(e){let t=this._controllers[e];return void 0===t&&(t=new is,this._controllers[e]=t),t}}function im(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}function ig(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 iy(){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 ia(e.pixelwidth,e.pixelheight,{format:g.GWd,type:g.OUM,depthTexture:new H.V(e.pixelwidth,e.pixelheight,e.stencilBuffer?g.V3x:g.bkx,void 0,void 0,void 0,void 0,void 0,void 0,e.stencilBuffer?g.dcC:g.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 ix(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 ib(e){return"quad"===e.type?this._glBinding.createQuadLayer({transform:new XRRigidTransform(e.translation,e.quaternion),width:e.width/2,height:e.height/2,space
3: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 iv(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 u=this._cameras[i];void 0===u&&((u=new ex.u).layers.enable(i),u.viewport=new U.I,u.matrixWorldAutoUpdate=!1,this._cameras[i]=u),u.matrix.fromArray(l.transform.matrix),u.matrix.decompose(u.position,u.quaternion,u.scale),u.projectionMatrix.fromArray(l.projectionMatrix),u.projectionMatrixInverse.copy(u.projectionMatrix).invert(),u.viewport.set(o.x,o.y,o.width,o.height),0===i&&(r.matrix.copy(u.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)),!0===n&&r.cameras.push(u)}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}var i_=r(23039),iT=r(89723);class iS extends r7.Q{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new U.I(0,0,this._width,this._height),this._scissor=new U.I(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new iT.P,this.depthTexture=new H.V}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 iA=new(r(93998)).i,iM=new ej.I(.5,.5),iw=new $.P;class iR{constructor(e=new rY.Z,t=new rY.Z,r=new rY.Z,i=new rY.Z,s=new rY.Z,a=new rY.Z){this.planes=[e,t,r,i,s,a]}set(e,t,r,i,s,a){let n=this.planes;return n[0].copy(e),n[1].copy(t),n[2].copy(r),n[3].copy(i),n[4].copy(s),n[5].copy(a),this}copy(e){let t=this.planes;for(let r=0;r<6;
3r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=g.TdN,r=!1){let i=this.planes,s=e.elements,a=s[0],n=s[1],o=s[2],l=s[3],u=s[4],h=s[5],d=s[6],c=s[7],p=s[8],m=s[9],f=s[10],y=s[11],x=s[12],b=s[13],v=s[14],_=s[15];if(i[0].setComponents(l-a,c-u,y-p,_-x).normalize(),i[1].setComponents(l+a,c+u,y+p,_+x).normalize(),i[2].setComponents(l+n,c+h,y+m,_+b).normalize(),i[3].setComponents(l-n,c-h,y-m,_-b).normalize(),r)i[4].setComponents(o,d,f,v).normalize(),i[5].setComponents(l-o,c-d,y-f,_-v).normalize();else if(i[4].setComponents(l-o,c-d,y-f,_-v).normalize(),t===g.TdN)i[5].setComponents(l+o,c+d,y+f,_+v).normalize();else if(t===g.i7u)i[5].setComponents(o,d,f,v).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),iA.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),iA.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(iA)}intersectsSprite(e){return iA.center.set(0,0,0),iA.radius=.7071067811865476+iM.distanceTo(e.center),iA.applyMatrix4(e.matrixWorld),this.intersectsSphere(iA)}intersectsSphere(e){let t=this.planes,r=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let r=0;r<6;r++){let i=t[r];if(iw.x=i.normal.x>0?e.max.x:e.min.x,iw.y=i.normal.y>0?e.max.y:e.min.y,iw.z=i.normal.z>0?e.max.z:e.min.z,0>i.distanceToPoint(iw))return!1}return!0}containsPoint(e){let t=this.planes;for(let r=0;r<6;r++)if(0>t[r].distanceToPoint(e))return!1;return!0}clone(){return new this.constructor().copy(this)}}let iN=new eH.k;class iC{constructor(){this.coordinateSystem=g.TdN,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,r=this._frustums;for(let e=0;e<t.length;e++){let i=t[e];iN.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),void 0===r[e]&&(r[e]=new iR),r[e].setFromProjectionMatrix(iN,i.coordinateSystem,i.reversedDepth)}return this._count=t.length,this}intersectsObject(e){let t=this._frustums;for(let r=0;r<this._count;r++)if(t[r].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let r=0;r<this._count;r++)if(t[r].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let r=0;r<this._count;r++)if(t[r].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let r=0;r<this._count;r++)if(t[r].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let r=0;r<this._count;r++)if(t[r].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,r=e._frustums;for(let i=0;i<e._count;i++)void 0===t[i]&&(t[i]=new iR),t[i].copy(r[i]);return this._count=e._count,this}clone(){return new iC().copy(this)}}let iE=new ef.Z,iF=new ej.I,iB=new U.I,iP=new iR,iV=new iC,iL=new eH.k,iI=new U.I,iO={[g.hB5]:g.hsX,[g.hsX]:g.hB5,[g.$EB]:g.$EB};class iD{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:r=!1,reversedDepthBuffer:i=!1,alpha:s=!0,depth:a=!0,stencil:n=!1,antialias:o=!1,samples:l=0,getFallback:u=null,outputBufferType:h=g.ix0,multiview:d=!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=g.er$,this.toneMapping=g.y_p,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=a,this.stencil=n,this.info=new S,this.contextNode=(0,eN._O)(),this.library=new r5,this.lighting=new r8,this._samples=l||!0===o?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new iS(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new i_.A,this._inspector.setRenderer(this),this._getFallback=u,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;const c=+(!0!==this.alpha);this._clearColor=new Y(0,0,0,c),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this.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:g.QP0}
3,this.xr=new ip(this,d),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}}}}async 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 rK(this,r),this._animation=new a(this,this._nodes,this.info),this._attributes=new f(r,this.info),this._background=new ei(this,this._nodes),this._geometries=new _(this._attributes,this.info),this._textures=new X(this,r,this.info),this._pipelines=new E(r,this._nodes,this.info),this._bindings=new F(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new c(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new D(this.lighting),this._bundles=new r2,this._renderContexts=new W(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 u=!0===e.isScene?e:!0===r.isScene?r:iE,h=this.needsFrameBufferTarget&&null===this._renderTarget?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,d=this._renderContexts.get(h,this._mrt),c=this._activeMipmapLevel,p=[];this._currentRenderContext=d,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=p,i.renderId++,i.update(),d.depth=this.depth,d.stencil=this.stencil,d.clippingContext||(d.clippingContext=new rQ),d.clippingContext.updateGlobal(u,t),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),t=this._updateCamera(t),u.onBeforeRender(this,e,t,h);let m=t.isArrayCamera?iV:iP;t.isArrayCamera?m.setFromArrayCamera(t):(iL.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),m.setFromProjectionMatrix(iL,t.coordinateSystem,t.reversedDepth));let g=this._renderLists.get(u,t);if(g.begin(),this._projectObject(e,t,0,g,d.clippingContext),r!==e&&r.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&g.pushLight(e)}),g.finish(),null!==h){this._textures.updateRenderTarget(h,c);let e=this._textures.get(h);d.textures=e.textures,d.depthTexture=e.depthTexture}else d.textures=null,d.depthTexture=null;r!==e?this._background.update(r,g,d):this._background.update(u,g,d);let f=g.opaque,y=g.transparent,x=g.transparentDoublePass,b=g.lightsNode;for(let e of(!0===this.opaque&&f.length>0&&this._renderObjects(f,t,u,b),!0===this.transparent&&y.length>0&&this._renderTransparents(y,x,t,u,b),i.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=n,this._handleObjectFunction=o,this._compilationPromises=l,p)){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,T.aH)()}}async renderAsync(e,t){(0,T.mc)('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,T.z3)("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=t_.io,t.modelNormalViewMatrix=t_.Po):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){let e=this.contextNode.value;return e.modelViewMatrix===t_.io&&e.modelNormalViewMatrix===t_.Po}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return(0,T.mc)('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: 4 5Message: ${e.message}`;e.reason&&(t+=` 6Reason: ${e.reason}`),(0,T.z3)(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),(0,T.z3)(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:h}=a;!0===this.opaque&&h.length>0&&this._renderObjects(h,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,135 bytes, line 6
6sion=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!==g.y_p,i=t!==j.pp.workingColorSpace;if(!1===r&&!1===i)return null;let{width:s,height:a}=this.getDrawingBufferSize(iF),{depth:n,stencil:o}=this,l=this._outputRenderTarget||this._canvasTarget,u=this._frameBufferTargets.get(l);if(void 0===u){(u=new eg.O(s,a,{depthBuffer:n,stencilBuffer:o,type:this._outputBufferType,format:g.GWd,colorSpace:j.pp.workingColorSpace,generateMipmaps:!1,minFilter:g.k6q,magFilter:g.k6q,samples:this.samples})).isPostProcessingRenderTarget=!0;let e=()=>{l.removeEventListener("dispose",e),u.dispose(),this._frameBufferTargets.delete(l)};l.addEventListener("dispose",e),this._frameBufferTargets.set(l,u)}let h=this.getOutputRenderTarget();u.depthBuffer=n,u.stencilBuffer=o,null!==h?u.setSize(h.width,h.height,h.depth):u.setSize(s,a,1);let d=this._outputRenderTarget?this._outputRenderTarget.viewport:l._viewport,c=this._outputRenderTarget?this._outputRenderTarget.scissor:l._scissor,p=this._outputRenderTarget?1:l._pixelRatio,m=this._outputRenderTarget?this._outputRenderTarget.scissorTest:l._scissorTest;return u.viewport.copy(d),u.scissor.copy(c),u.viewport.multiplyScalar(p),u.scissor.multiplyScalar(p),u.scissorTest=m,u.multiview=null!==h&&h.multiview,u.useArrayDepthTexture=null!==h&&h.useArrayDepthTexture,u.resolveDepthBuffer=null===h||h.resolveDepthBuffer,u._autoAllocateDepthBuffer=null!==h&&h._autoAllocateDepthBuffer,u}_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 h=!0===e.isScene?e:iE,d=this._renderTarget||this._outputRenderTarget,c=this._activeCubeFace,p=this._activeMipmapLevel;if(null!==s?(i=s,this.setRenderTarget(i)):i=d,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,y=g._scissor,x=g._pixelRatio;null!==i&&(f=i.viewport,y=i.scissor,x=1),this.getDrawingBufferSize(iF),iB.set(0,0,iF.width,iF.height);let b=void 0===f.minDepth?0:f.minDepth,v=void 0===f.maxDepth?1:f.maxDepth;m.viewportValue.copy(f).multiplyScalar(x).floor(),m.viewportValue.width>>=p,m.viewportValue.height>>=p,m.viewportValue.minDepth=b,m.viewportValue.maxDepth=v,m.viewport=!1===m.viewportValue.equals(iB),m.scissorValue.copy(y).multiplyScalar(x).floor(),m.scissor=g._scissorTest&&!1===m.scissorValue.equals(iB),m.scissorValue.width>>=p,m.scissorValue.height>>=p,m.clippingContext||(m.clippingContext=new rQ),m.clippingContext.updateGlobal(h,t),h.onBeforeRender(this,e,t,i);let _=t.isArrayCamera?iV:iP;t.isArrayCamera?_.setFromArrayCamera(t):(iL.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(iL,t.coordinateSystem,t.reversedDepth));let T=this._renderLists.get(e,t);if(T.begin(),this._projectObject(e,t,0,T,m.clippingContext),T.finish(),!0===this.sortObjects&&T.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=iF.width,m.height=iF.height,m.depth=this.depth,m.stencil=this.stencil;m.width>>=p,m.height>>=p,m.activeCubeFace=c,m.activeMipmapLevel=p,m.occlusionQueryCount=T.occlusionQueryCount,m.scissorValue.max(iI.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(h,T,m),m.camera=t,this.backend.beginRender(m);let{bundles:S,lightsNode:A,transparentDoublePass:M,transparent:w,opaque:R}=T;return S.length>0&&this._renderBundles(S,h,A),!0===this.opaque&&R.length>0&&this._renderObjects(R,t,h,A),!0===this.transparent&&w.length>0&&this._renderTransparents(w,M,t,h,A),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(d,c,p),this._renderOutput(i)),h.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);
6if(void 0===i){(t=new rJ.A(new Q.A)).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,T.mc)('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,T.mc)('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){(0,T.mc)('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){(0,T.mc)('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!==g.y_p,t=this.currentColorSpace!==j.pp.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:g.y_p}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:j.pp.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();
6Object.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,T.R8)("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,T.mc)('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,T.mc)('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=iI.set(t.x,t.y,e.image.width,e.image.height).floor();else{if(!t.isVector4)return void(0,T.z3)("Renderer.copyFramebufferToTexture: Invalid rectangle.");t=iI.copy(t).floor()}else t=iI.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)}
6copyTextureToTexture(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?iV:iP;if(!e.frustumCulled||a.intersectsSprite(e)){!0===this.sortObjects&&iI.setFromMatrixPosition(e.matrixWorld).applyMatrix4(iL);let{geometry:t,material:a}=e;a.visible&&i.push(e,t,a,r,iI.z,null,s)}}else if(e.isLineLoop)(0,T.z3)("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?iV:iP;if(!e.frustumCulled||a.intersectsObject(e)){let{geometry:t,material:a}=e;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),iI.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(iL)),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,iI.z,l,s)}}else a.visible&&i.push(e,t,a,r,iI.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=g.hsX;for(let{material:e}of(this._renderObjects(t,r,i,s,"backSide"),t))e.side=g.hB5;for(let{material:a}of(this._renderObjects(e,r,i,s),t))a.side=g.$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:h}=e[a];this._currentRenderObjectFunction(n,r,t,o,l,u,i,h,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,u=null;if(i||s||a||n){let t,r;if(a?(t=e.castShadowNode.rgb,r=e.castShadowNode.a,!0!==this.shadowMap.transmitted&&(0,T.mc)("Renderer: `shadowMap.transmitted` needs to be set to `true` when using `material.castShadowNode`.")):(t=(0,t3.eR)(0),r=(0,t3.fV)(1)),i&&(r=r.mul((0,tT.ir)("map","texture",e).a)),s&&(r=r.mul(e.colorNode.a)),l=(0,t3.ln)(t,r),n){let t=e.maskShadowNode||e.maskNode;l=(0,t3.Fn)(([e])=>(t.not().discard(),e))(l)}}e.depthNode&&e.depthNode.isNode&&(u=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?o=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(o=e.positionNode),r={version:t,colorNode:l,depthNode:u,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 u,h,d,c,p,m,f,y=!1,x=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(y=!0,u=e.isNodeMaterial?e.colorNode:null,h=e.isNodeMaterial?e.depthNode:null,d=e.isNodeMaterial?e.positionNode:null,c=t.overrideMaterial.side,p=e.displacementMap,m=e.displacementScale,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{c
6olorNode:t,depthNode:r,positionNode:i}=this._getShadowNodes(s);this.shadowMap.type===g.RyA?e.side=null!==s.shadowSide?s.shadowSide:s.side:e.side=null!==s.shadowSide?s.shadowSide:iO[s.side],null!==t&&(e.colorNode=t),null!==r&&(e.depthNode=r),null!==i&&(e.positionNode=i)}s=e}!0===s.transparent&&s.side===g.$EB&&!1===s.forceSinglePass?(s.side=g.hsX,this._handleObjectFunction(e,s,t,r,n,a,o,"backSide"),s.side=g.hB5,this._handleObjectFunction(e,s,t,r,n,a,o,l),s.side=g.$EB):this._handleObjectFunction(e,s,t,r,n,a,o,l),y&&(t.overrideMaterial.colorNode=u,t.overrideMaterial.depthNode=h,t.overrideMaterial.positionNode=d,t.overrideMaterial.side=c,t.overrideMaterial.displacementMap=p,t.overrideMaterial.displacementScale=m,t.overrideMaterial.displacementBias=f),this._currentSourceMaterial=x,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}}let iU=iD;class iz{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)}}let ik=iz;function iG(e){return e+(16-e%16)%16}class iW extends ik{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 iG(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}let i$=iW;class iH extends i${constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let ij=iH,iq=0;class iX extends ij{constructor(e,t){super("UniformBuffer_"+iq++,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 iG(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class iK extends ij{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,T.z3)("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
6]||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 iY=iK,iZ=0;class iQ extends iY{constructor(e,t){super(e),this.id=iZ++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class iJ extends ik{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 i0=iJ,i1=0;class i2 extends i0{constructor(e,t){super(e,t),this.id=i1++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}}class i3 extends i2{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 i5 extends i3{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledCubeTexture=!0}}class i6 extends i3{constructor(e,t,r,i=null){super(e,t,r,i),this.isSampledTexture3D=!0}}var i4=r(53104);let i8={bitcast_int_uint:new tA.Ay("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new tA.Ay("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }"),textureGather:new tA.Ay(` 7vec4 tsl_textureGather( const int comp, sampler2D map, vec2 coord, ivec2 offset, bool flipY ) { 8 if ( flipY ) offset.y = - offset.y; 9 vec2 size = vec2( textureSize( map, 0 ) ); 10 vec2 st = floor( coord * size + vec2( offset ) - 0.5 ); 11 vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy; 12 vec4 ret = vec4( 13 textureLod( map, ij.xw, 0.0 )[ comp ], 14 textureLod( map, ij.zw, 0.0 )[ comp ], 15 textureLod( map, ij.zy, 0.0 )[ comp ], 16 textureLod( map, ij.xy, 0.0 )[ comp ] 17 ); 18 return flipY ? ret.wzyx : ret; 19} 20`),textureGatherArray:new tA.Ay(` 21vec4 tsl_textureGather_array( const int comp, sampler2DArray map, vec3 coord, ivec2 offset, bool flipY ) { 22 if ( flipY ) offset.y = - offset.y; 23 vec2 size = vec2( textureSize( map, 0 ).xy ); 24 vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 ); 25 vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy; 26 vec4 ret = vec4( 27 textureLod( map, vec3( ij.xw, coord.z ), 0.0 )[ comp ], 28 textureLod( map, vec3( ij.zw, coord.z ), 0.0 )[ comp ], 29 textureLod( map, vec3( ij.zy, coord.z ), 0.0 )[ comp ], 30 textureLod( map, vec3( ij.xy, coord.z ), 0.0 )[ comp ] 31 ); 32 return flipY ? ret.wzyx : ret; 33} 34`),textureGatherCompare:new tA.Ay(` 35vec4 tsl_textureGatherCompare( sampler2DShadow map, vec2 coord, ivec2 offset, float ref, bool flipY ) { 36 if ( flipY ) offset.y = - offset.y; 37 vec2 size = vec2( textureSize( map, 0 ) ); 38 vec2 st = floor( coord * size + vec2( offset ) - 0.5 ); 39 vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy; 40 vec4 ret = vec4( 41 textureLod( map, vec3( ij.xw, ref ), 0.0 ), 42 textureLod( map, vec3( ij.zw, ref ), 0.0 ), 43 textureLod( map, vec3( ij.zy, ref ), 0.0 ), 44 textureLod( map, vec3( ij.xy, ref ), 0.0 ) 45 ); 46 return flipY ? ret.wzyx : ret; 47} 48`),textureGatherCompareArray:new tA.Ay(` 49vec4 tsl_textureGatherCompare_array( sampler2DArrayShadow map, vec3 coord, ivec2 offset, float ref, bool flipY ) { 50 if ( flipY ) offset.y = - offset.y; 51 vec2 size = vec2( textureSize( map, 0 ).xy );
52 vec2 st = floor( coord.xy * size + vec2( offset ) - 0.5 ); 53 vec4 ij = vec4( st + 0.5, st + 1.5 ) / size.xyxy; 54 vec4 ret = vec4( 55 texture( map, vec4( ij.xw, coord.z, ref ) ), 56 texture( map, vec4( ij.zw, coord.z, ref ) ), 57 texture( map, vec4( ij.zy, coord.z, ref ) ), 58 texture( map, vec4( ij.xy, coord.z, ref ) ) 59 ); 60 return flipY ? ret.wzyx : ret; 61} 62`)},i9={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"},i7={low:"lowp",medium:"mediump",high:"highp"},se={swizzleAssign:!0,storageBuffer:!1},st={perspective:"smooth",linear:"noperspective"},sr={centroid:"centroid"},si=` 63precision highp float; 64precision highp int; 65precision highp sampler2D; 66precision highp sampler3D; 67precision highp samplerCube; 68precision highp sampler2DArray; 69 70precision highp usampler2D; 71precision highp usampler3D; 72precision highp usamplerCube; 73precision highp usampler2DArray; 74 75precision highp isampler2D; 76precision highp isampler3D; 77precision highp isamplerCube; 78precision highp isampler2DArray; 79 80precision highp sampler2DShadow; 81precision highp sampler2DArrayShadow; 82precision highp samplerCubeShadow; 83`;class ss extends tu{constructor(e,t){super(e,t,new ru),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return!0===e.isVideoTexture&&e.colorSpace!==g.jf0}_include(e){let t=i8[e];return t.build(this),this.addInclude(t),t}getMethod(e){return void 0!==i8[e]&&this._include(e),i9[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=[];for(let e of t.inputs)i.push(this.getType(e.type)+" "+e.name);return`${this.getType(t.type)} ${t.name}( ${i.join(", ")} ) { 84 85 ${r.vars} 86 87${r.code} 88 return ${r.result}; 89 90}`}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?g.ZQM:g.VT0;2===i?a=s?g.TkQ:g.paN:3===i?a=s?g.VGF:g.HIg:4===i&&(a=s?g.c90:g.GWd);let n={Float32Array:g.RQf,Uint8Array:g.OUM,Uint16Array:g.cHt,Uint32Array:g.bkx,Int8Array:g.tJf,Int16Array:g.fBL,Int32Array:g.Yuy,Uint8ClampedArray:g.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 u=o*l*i,h=new e.constructor(u);h.set(e,0),t.array=h;let d=new i4.G(t.array,o,l,a,n[t.array.constructor.name]||g.RQf);d.needsUpdate=!0,d.isPBOTexture=!0;let c=new ep.Ay(d,null,null);c.setPrecision("high"),t.pboNode=c,t.pbo=c.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),u=s.propertySizeName;void 0===u&&(u=l+"Size",this.getVarFromNode(t,u,"uint"),this.addLineFlowCode(`${u} = uint( textureSize( ${a}, 0 ).x )`,e),s.propertySizeName=u);let{itemSize:h}=i,d="."+el.Iy.join("").slice(0,h),c=`ivec2(${n} % ${u}, ${n} / ${u})`,p=this.generateTextureLoad(null,a,c,"0",null,null),m="vec4";i.pbo.type===g.bkx?m="uvec4":i.pbo.type===g.Yuy&&(m="ivec4"),this.addLineFlowCode(`${l} = ${m}(${p})${d}`,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,T.z3)(`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===g.bkx?s="u":i.type===g.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} { 91 ${i} ${e.name}[${a}]; 92}; 93`}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=i7[s]+" "+a),r.push(" "+a)}i[t]=r}}s=!0}
93if(!s){let i=e.node.precision;null!==i&&(t=i7[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!==g.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}; 94`}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=st[i.interpolationType]||i.interpolationType,s=sr[i.interpolationSampling]||"";t+=`${e} ${s} out ${r} ${i.name}; 95`}else{let e=r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":"";t+=`${e}out ${r} ${i.name}; 96`}else t+=`${r} ${i.name}; 97`}else if("fragment"===e){for(let e of r)if(e.needsInterpolation){let r=this.getType(e.type);if(e.interpolationType){let i=st[e.interpolationType]||e.interpolationType,s=sr[e.interpolationSampling]||"";t+=`${i} ${s} in ${r} ${e.name}; 98`}else{let i=r.includes("int")||r.includes("uv")||r.includes("iv")?"flat ":"";t+=`${i}in ${r} ${e.name}; 99`}}}for(let r of this.builtins[e])t+=`${r}; 100`;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,T.z3)("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){(0,T.z3)("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){(0,T.z3)("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=se[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)}se[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} ]`)}
100enableMultiview(){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}; 101 `)}return t}_getGLSLUniformStruct(e,t){return` 102layout( std140 ) uniform ${e} { 103${t} 104};`}_getGLSLVertexCode(e){return`#version 300 es 105 106${this.getSignature()} 107 108// extensions 109${e.extensions} 110 111// precision 112${si} 113 114// structs 115${e.structs} 116 117// uniforms 118${e.uniforms} 119 120// varyings 121${e.varyings} 122 123// attributes 124${e.attributes} 125 126// vars 127${e.vars} 128 129// codes 130${e.codes} 131 132void main() { 133 134 // transforms 135 ${e.transforms} 136 137 // flow 138 ${e.flow} 139 140 gl_PointSize = 1.0; 141 142} 143`}_getGLSLFragmentCode(e){return`#version 300 es 144 145${this.getSignature()} 146 147// extensions 148${e.extensions} 149 150// precision 151${si} 152 153// structs 154${e.structs} 155 156// uniforms 157${e.uniforms} 158 159// varyings 160${e.varyings} 161 162// vars 163${e.vars} 164 165// codes 166${e.codes} 167 168void main() { 169 170 // flow 171 ${e.flow} 172 173} 174`}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} 175 `),r+=`${i.code} 176 `,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 i3(s.name,s.node,i),l.push(n);else if("cubeTexture"===t||"cubeDepthTexture"===t)n=new i5(s.name,s.node,i),l.push(n);else if("texture3D"===t)n=new i6(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 iX(e,i)).name=e.name,t.buffer=r),l.push(r),n=r}else{let e=this.uniformGroups[o];void 0===e?(e=new iQ(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 sa=null,sn=null;class so{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[g.v9J.RENDER]:null,[g.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:")?g.v9J.COMPUTE:g.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,T.mc)("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 sa=sa||new ej.I,this.renderer.getDrawingBufferSize(sa)}setScissorTest(){}getClearColor(){let e=this.renderer;return sn=sn||new Y,e.getClearColor(sn),sn.getRGB(sn),sn}getDomElement(){let e=this.domElement;return null===e&&("setAttribute"in(e=void 0!==this.parameters.canvas?this.parameters.canvas:(0,T.lP)())&&e.setAttribute("data-engine",`three.js r${g.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 sl=so,su=0;class sh{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 sd{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),u=l.bufferGPU;if(void 0===u&&(l.bufferGPU=u=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:u,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===g.Yuy,id:su++};(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(h=new sh(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;
176e++){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,h=-1===i?l.byteLength-r:i;if(null===t)s=new Uint8Array(new ArrayBuffer(h));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(h))).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 sc{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;i={[g.gO9]:e.FUNC_ADD,[g.FXf]:e.FUNC_SUBTRACT,[g.nST]:e.FUNC_REVERSE_SUBTRACT},s={[g.ojh]:e.ZERO,[g.qad]:e.ONE,[g.f4X]:e.SRC_COLOR,[g.ie2]:e.SRC_ALPHA,[g.hgQ]:e.SRC_ALPHA_SATURATE,[g.wn6]:e.DST_COLOR,[g.hdd]:e.DST_ALPHA,[g.LiQ]:e.ONE_MINUS_SRC_COLOR,[g.OuU]:e.ONE_MINUS_SRC_ALPHA,[g.aEY]:e.ONE_MINUS_DST_COLOR,[g.Nt7]:e.ONE_MINUS_DST_ALPHA};let t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=new U.I().fromArray(t),this.currentViewport=new U.I().fromArray(r),this._tempVec4=new U.I}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!==g.WNZ?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===g.Vb5?t.cullFace(t.BACK):e===g.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,T.mc)("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===g.pCc?o=r:e.blending!==g.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,a=this.backend.drawBuffersIndexedExt,n=t.blending,o=t.blendSrc,l=t.blendDst,u=t.blendEquation,h=t.premultipliedAlpha;if(n===g.bCz){let r=null!==t.blendSrcAlpha?t.blendSrcAlpha:o,n=null!==t.blendDstAlpha?t.blendDstAlpha:l,h=null!==t.blendEquationAlpha?t.blendEquationAlpha:u;a.blendEquationSeparateiOES(e,i[u],i[h]),a.blendFuncSeparateiOES(e,s[o],s[l],s[r],s[n])}else if(a.blendEquationSeparateiOES(e,r.FUNC_ADD,r.FUNC_ADD),h)switch(n){case g.NTi:a.blendFuncSeparateiOES(e,r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case g.EZo:a.blendFuncSeparateiOES(e,r.ONE,r.ONE,r.ONE,r.ONE);break;case g.Kwu:a.blendFuncSeparateiOES(e,r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case g.EdD:a.blendFuncSeparateiOES(e,r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:a.blendFuncSeparateiOES(e,r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA)}else switch(n){case g.NTi:a.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case g.EZo:a.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE,r.ONE,r.ONE);break;case g.Kwu:a.blendFuncSeparateiOES(e,r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case g.EdD:a.blendFuncSeparateiOES(e,r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ZERO,r.ONE);break;default:a.blendFuncSeparateiOES(e,r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA)}}setBlending(e,t,r,a,n,o,l,u){let{gl:h}=this;if(e===g.XIg){!0===this.currentBlendingEnabled&&(this.disable(h.BLEND),this.currentBlendingEnabled=!1);return}if(!1===this.currentBlendingEnabled&&(this.enable(h.BLEND),this.currentBlendingEnabled=!0),e!==g.bCz){if(e!==this.currentBlending||u!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==g.gO9||this.currentBlendEquationAlpha!==g.gO9)&&(h.blendEquation(h.FUNC_ADD),this.currentBlendEquation=g.gO9,this.currentBlendEquationAlpha=g.gO9),u)switch(e){case g.NTi:h.blendFuncSeparate(h.ONE,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA);break;case g.EZo:h.blendFunc(h.ONE,h.ONE);break;case g.Kwu:h.blendFuncSeparate(h.ZERO,h.ONE_MINUS_SRC_COLOR,h.ZERO,h.ONE);break;case g.EdD:h.blendFuncSeparate(h.DST_COLOR,h.ONE_MINUS_SRC_ALPHA,h.ZERO,h.ONE);break;default:(0,T.z3)("WebGLState: Invalid blending: ",e)}else switch(e){case g.NTi:h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA);break;case g.EZo:h.blendFuncSeparate(h.SRC_ALPHA,h.ONE,h.ONE,h.ONE);break;case g.Kwu:(0,T.z3)("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case g.EdD:(0,T.z3)("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:(0,T.z3)("WebGLState: Invalid blending: ",e)}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=u}return}n=n||t,o=o||r,l=l||a,(t!==this.currentBlendEquation||n!==this.currentBlendEquationAlpha)&&(h.blendEquationSeparate(i[t],i[n]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=n),(r!==this.currentBlendSrc||a!==this.currentBlendDst||o!==this.currentBlendSrcAlpha||l!==this.currentBlendDstAlpha)&&(h.blendFuncSeparate(s[r],s[a],s[o],s[l]),this.currentBlendSrc=r,this.currentBlendDst=a,this.currentBlendSrcAlpha=o,this.currentBlendDstAlpha=l),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=T.ri[e]),this.currentDepthFunc!==e){let{gl:t}=this;switch(e){case g.eHc:t.depthFunc(t.NEVER);break;case g.lGu:t.depthFunc(t.ALWAYS);break;case g.brA:t.depthFunc(t.LESS);break;case g.xSv:t.depthFunc(t.LEQUAL);break;case g.U3G:t.depthFunc(t.EQUAL);break;case g.Gwm:t.depthFunc(t.GEQUAL);break;case g.K52:t.depthFunc(t.GREATER);break;case g.bw0:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}
176scissor(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===g.$EB?this.disable(i.CULL_FACE):this.enable(i.CULL_FACE);let s=e.side===g.hsX;t&&(s=!s),this.setFlipSided(s),e.blending===g.NTi&&!1===e.transparent?this.setBlending(g.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 sp{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=g.jf0){let r,{gl:i,extensions:s}=this,a=j.pp.getTransfer(t);if(e===g.OUM)return i.UNSIGNED_BYTE;if(e===g.Wew)return i.UNSIGNED_SHORT_4_4_4_4;if(e===g.gJ2)return i.UNSIGNED_SHORT_5_5_5_1;if(e===g.Dmk)return i.UNSIGNED_INT_5_9_9_9_REV;if(e===g.yT7)return i.UNSIGNED_INT_10F_11F_11F_REV;if(e===g.tJf)return i.BYTE;if(e===g.fBL)return i.SHORT;if(e===g.cHt)return i.UNSIGNED_SHORT;if(e===g.Yuy)return i.INT;if(e===g.bkx)return i.UNSIGNED_INT;if(e===g.RQf)return i.FLOAT;if(e===g.ix0)return i.HALF_FLOAT;if(e===g.wrO)return i.ALPHA;if(e===g.HIg)return i.RGB;if(e===g.GWd)return i.RGBA;if(e===g.zdS)return i.DEPTH_COMPONENT;if(e===g.dcC)return i.DEPTH_STENCIL;if(e===g.VT0)return i.RED;if(e===g.ZQM)return i.RED_INTEGER;if(e===g.paN)return i.RG;if(e===g.TkQ)return i.RG_INTEGER;if(e===g.c90)return i.RGBA_INTEGER;if(e===g.IE4||e===g.Nz6||e===g.jR7||e===g.BXX)if(a===g.KLL){if(null===(r=s.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(e===g.IE4)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===g.Nz6)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===g.jR7)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===g.BXX)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(r=s.get("WEBGL_compressed_texture_s3tc")))return null;if(e===g.IE4)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===g.Nz6)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===g.jR7)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===g.BXX)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===g.k6Q||e===g.kTp||e===g.HXV||e===g.pBf){if(null===(r=s.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===g.k6Q)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===g.kTp)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===g.HXV)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===g.pBf)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(e===g.CVz||e===g.Riy||e===g.KDk||e===g.BVL||e===g.gZr||e===g.OtU||e===g.jSS){if(null===(r=s.get("WEBGL_compressed_texture_etc")))return null;if(e===g.CVz||e===g.Riy)return a===g.KLL?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(e===g.KDk)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;
176if(e===g.BVL)return r.COMPRESSED_R11_EAC;if(e===g.gZr)return r.COMPRESSED_SIGNED_R11_EAC;if(e===g.OtU)return r.COMPRESSED_RG11_EAC;if(e===g.jSS)return r.COMPRESSED_SIGNED_RG11_EAC}if(e===g.qa3||e===g.B_h||e===g.czI||e===g.rSH||e===g.Qrf||e===g.psI||e===g.a5J||e===g._QJ||e===g.uB5||e===g.lyL||e===g.bC7||e===g.y3Z||e===g.ojs||e===g.S$4){if(null===(r=s.get("WEBGL_compressed_texture_astc")))return null;if(e===g.qa3)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===g.B_h)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===g.czI)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===g.rSH)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===g.Qrf)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===g.psI)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===g.a5J)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===g._QJ)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===g.uB5)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===g.lyL)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===g.bC7)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===g.y3Z)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===g.ojs)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===g.S$4)return a===g.KLL?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(e===g.Fn||e===g.H23||e===g.W9U){if(null===(r=s.get("EXT_texture_compression_bptc")))return null;if(e===g.Fn)return a===g.KLL?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(e===g.H23)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(e===g.W9U)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(e===g.Kef||e===g.XG_||e===g.HO_||e===g.CWW){if(null===(r=s.get("EXT_texture_compression_rgtc")))return null;if(e===g.Kef)return r.COMPRESSED_RED_RGTC1_EXT;if(e===g.XG_)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===g.HO_)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===g.CWW)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return e===g.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}a===e.TIMEOUT_EXPIRED?requestAnimationFrame(s):(e.deleteSync(t),r())}()})}}let sm=!1,sg,sf,sy;class sx{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,!1===sm&&(this._init(),sm=!0)}_init(){let e=this.gl;sg={[g.GJx]:e.REPEAT,[g.ghU]:e.CLAMP_TO_EDGE,[g.kTW]:e.MIRRORED_REPEAT},sf={[g.hxR]:e.NEAREST,[g.pHI]:e.NEAREST_MIPMAP_NEAREST,[g.Cfg]:e.NEAREST_MIPMAP_LINEAR,[g.k6q]:e.LINEAR,[g.kRr]:e.LINEAR_MIPMAP_NEAREST,[g.$_I]:e.LINEAR_MIPMAP_LINEAR},sy={[g.amv]:e.NEVER,[g.FFZ]:e.ALWAYS,[g.vim]:e.LESS,[g.TiK]:e.LEQUAL,[g.kO0]:e.EQUAL,[g.gWB]:e.GEQUAL,[g.eoi]:e.GREATER,[g.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,T.R8)("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let l=null;i&&((l=o.get("EXT_texture_norm16"))||(0,T.R8)("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let u=t;if(t===n.RED&&(r===n.FLOAT&&(u=n.R32F),r===n.HALF_FLOAT&&(u=n.R16F),r===n.UNSIGNED_BYTE&&(u=n.R8),r===n.BYTE&&(u=n.R8_SNORM),r===n.UNSIGNED_SHORT&&l&&(u=l.R16_EXT),r===n.SHORT&&l&&(u=l.R16_SNORM_EXT)),t===n.RED_INTEGER&&(r===n.UNSIGNED_BYTE&&(u=n.R8UI),r===n.UNSIGNED_SHORT&&(u=n.R16UI),r===n.UNSIGNED_INT&&(u=n.R32UI),r===n.BYTE&&(u=n.R8I),r===n.SHORT&&(u=n.R16I),r===n.INT&&(u=n.R32I)),t===n.RG&&(r===n.FLOAT&&(u=n.RG32F),r===n.HALF_FLOAT&&(u=n.RG16F),r===n.UNSIGNED_BYTE&&(u=n.RG8),r===n.BYTE&&(u=n.RG8_SNORM),r===n.UNSIGNED_SHORT&&l&&(u=l.RG16_EXT),r===n.SHORT&&l&&(u=l.RG16_SNORM_EXT)),t===n.RG_INTEGER&&(r===n.UNSIGNED_BYTE&&(u=n.RG8UI),r===n.UNSIGNED_SHORT&&(u=n.RG16UI),r
176===n.UNSIGNED_INT&&(u=n.RG32UI),r===n.BYTE&&(u=n.RG8I),r===n.SHORT&&(u=n.RG16I),r===n.INT&&(u=n.RG32I)),t===n.RGB){let e=a?g.VxR:j.pp.getTransfer(s);r===n.FLOAT&&(u=n.RGB32F),r===n.HALF_FLOAT&&(u=n.RGB16F),r===n.UNSIGNED_BYTE&&(u=e===g.KLL?n.SRGB8:n.RGB8),r===n.BYTE&&(u=n.RGB8_SNORM),r===n.UNSIGNED_SHORT&&l&&(u=l.RGB16_EXT),r===n.SHORT&&l&&(u=l.RGB16_SNORM_EXT),r===n.UNSIGNED_SHORT_5_6_5&&(u=n.RGB565),r===n.UNSIGNED_SHORT_5_5_5_1&&(u=n.RGB5_A1),r===n.UNSIGNED_SHORT_4_4_4_4&&(u=n.RGB4),r===n.UNSIGNED_INT_5_9_9_9_REV&&(u=n.RGB9_E5),r===n.UNSIGNED_INT_10F_11F_11F_REV&&(u=n.R11F_G11F_B10F)}if(t===n.RGB_INTEGER&&(r===n.UNSIGNED_BYTE&&(u=n.RGB8UI),r===n.UNSIGNED_SHORT&&(u=n.RGB16UI),r===n.UNSIGNED_INT&&(u=n.RGB32UI),r===n.BYTE&&(u=n.RGB8I),r===n.SHORT&&(u=n.RGB16I),r===n.INT&&(u=n.RGB32I)),t===n.RGBA){let e=a?g.VxR:j.pp.getTransfer(s);r===n.FLOAT&&(u=n.RGBA32F),r===n.HALF_FLOAT&&(u=n.RGBA16F),r===n.UNSIGNED_BYTE&&(u=e===g.KLL?n.SRGB8_ALPHA8:n.RGBA8),r===n.BYTE&&(u=n.RGBA8_SNORM),r===n.UNSIGNED_SHORT&&l&&(u=l.RGBA16_EXT),r===n.SHORT&&l&&(u=l.RGBA16_SNORM_EXT),r===n.UNSIGNED_SHORT_4_4_4_4&&(u=n.RGBA4),r===n.UNSIGNED_SHORT_5_5_5_1&&(u=n.RGB5_A1)}return t===n.RGBA_INTEGER&&(r===n.UNSIGNED_BYTE&&(u=n.RGBA8UI),r===n.UNSIGNED_SHORT&&(u=n.RGBA16UI),r===n.UNSIGNED_INT&&(u=n.RGBA32UI),r===n.BYTE&&(u=n.RGBA8I),r===n.SHORT&&(u=n.RGBA16I),r===n.INT&&(u=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(r===n.UNSIGNED_SHORT&&(u=n.DEPTH_COMPONENT16),r===n.UNSIGNED_INT&&(u=n.DEPTH_COMPONENT24),r===n.FLOAT&&(u=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&r===n.UNSIGNED_INT_24_8&&(u=n.DEPTH24_STENCIL8),(u===n.R16F||u===n.R32F||u===n.RG16F||u===n.RG32F||u===n.RGBA16F||u===n.RGBA32F)&&o.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){let{gl:r,extensions:i,backend:s}=this,{state:a}=this.backend,n=j.pp.getPrimaries(j.pp.workingColorSpace),o=t.colorSpace===g.jf0?null:j.pp.getPrimaries(t.colorSpace),l=t.colorSpace===g.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,sg[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,sg[t.wrapT]),e!==r.TEXTURE_3D&&e!==r.TEXTURE_2D_ARRAY||t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,sg[t.wrapR]),r.texParameteri(e,r.TEXTURE_MAG_FILTER,sf[t.magFilter]);let u=void 0!==t.mipmaps&&t.mipmaps.length>0,h=t.minFilter===g.k6q&&u?g.$_I:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,sf[h]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,sy[t.compareFunction])),!0===i.has("EXT_texture_filter_anisotropic")){if(t.magFilter===g.hxR||t.minFilter!==g.Cfg&&t.minFilter!==g.$_I||t.type===g.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:h,height:d,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,h,d,c):e.isData3DTexture?o.texStorage3D(o.TEXTURE_3D,u,n,h,d,c):e.isVideoTexture||o.texStorage2D(i,u,n,h,d)}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:h}=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,h,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:u}=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,T.R8)("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,T.R8)("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=sb(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=sb(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=function(e,t,r,i){let s=function(e){switch(e){case g.OUM:case g.tJf:return{byteLength:1,components:1};case g.cHt:case g.fBL:case g.ix0:return{byteLength:2,components:1};case g.Wew:case g.gJ2:return{byteLength:2,components:4};case g.bkx:case g.Yuy:case g.RQf:return{byteLength:4,components:1};case g.Dmk:case g.yT7:return{byteLength:4,components:3}}throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`)}(i);switch(r){case g.wrO:return e*t;case g.VT0:case g.ZQM:return e*t/s.components*s.byteLength;case g.paN:case g.TkQ:return e*t*2/s.components*s.byteLength;case g.HIg:return e*t*3/s.components*s.byteLength;case g.GWd:case g.c90:return e*t*4/s.components*s.byteLength;case g.IE4:case g.Nz6:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case g.jR7:case g.BXX:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case g.kTp:case g.pBf:return Math.max(e,16)*Math.max(t,8)/4;case g.k6Q:case g.HXV:return Math.max(e,8)*Math.max(t,8)/2;case g.CVz:case g.Riy:case g.BVL:case g.gZr:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8;case g.KDk:case g.OtU:case g.jSS:case g.qa3:return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16;case g.B_h:return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16;case g.czI:return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16;case g.rSH:return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16;case g.Qrf:return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16;case g.psI:return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16;case g.a5J:return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16;case g._QJ:return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16;case g.uB5:return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16;case g.lyL:return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16;case g.bC7:return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16;case g.y3Z:return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16;case g.ojs:return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16;case g.S$4:return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16;case g.Fn:case g.H23:case g.W9U:return Math.ceil(e/4)*Math.ceil(t/4)*16;case g.Kef:case g.XG_:return Math.ceil(e/4)*Math.ceil(t/4)*8;case g.HO_:case g.CWW:return Math.ceil(e/4)*Math.ceil(t/4)*16}throw Error(`Unable to determine texture byte length for ${r} format.`)}(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 176
176else if(e.isVideoTexture)e.update(),r.texImage2D(n,0,u,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=sb(t);r.texSubImage2D(n,e,0,0,t.width,t.height,o,l,i)}else{let e=sb(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,h,d,c,p,m,{gl:g,backend:f}=this,{state:y}=this.backend,{textureGPU:x,glTextureType:b,glType:v,glFormat:_}=f.get(t);y.bindTexture(b,x);let T=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,h=r.min.y,d=r.isBox3?r.min.z:0;else{let t=Math.pow(2,-s);n=Math.floor(T.width*t),o=Math.floor(T.height*t),l=e.isDataArrayTexture||e.isArrayTexture?T.depth:e.isData3DTexture?Math.floor(T.depth*t):1,u=0,h=0,d=0}null!==i?(c=i.x,p=i.y,m=i.z):(c=0,p=0,m=0),y.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,t.flipY),y.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),y.pixelStorei(g.UNPACK_ALIGNMENT,t.unpackAlignment);let S=y.getParameter(g.UNPACK_ROW_LENGTH),A=y.getParameter(g.UNPACK_IMAGE_HEIGHT),M=y.getParameter(g.UNPACK_SKIP_PIXELS),w=y.getParameter(g.UNPACK_SKIP_ROWS),R=y.getParameter(g.UNPACK_SKIP_IMAGES);y.pixelStorei(g.UNPACK_ROW_LENGTH,T.width),y.pixelStorei(g.UNPACK_IMAGE_HEIGHT,T.height),y.pixelStorei(g.UNPACK_SKIP_PIXELS,u),y.pixelStorei(g.UNPACK_SKIP_ROWS,h),y.pixelStorei(g.UNPACK_SKIP_IMAGES,d);let N=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,C=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){let r=f.get(e),i=f.get(t),b=f.get(r.renderTarget),v=f.get(i.renderTarget),_=b.framebuffers[r.cacheKey],T=v.framebuffers[i.cacheKey],S=y.currentBoundFramebuffers[g.READ_FRAMEBUFFER]??null,A=y.currentBoundFramebuffers[g.DRAW_FRAMEBUFFER]??null;y.bindFramebuffer(g.READ_FRAMEBUFFER,_),y.bindFramebuffer(g.DRAW_FRAMEBUFFER,T);for(let e=0;e<l;e++)N&&(g.framebufferTextureLayer(g.READ_FRAMEBUFFER,g.COLOR_ATTACHMENT0,r.textureGPU,s,d+e),g.framebufferTextureLayer(g.DRAW_FRAMEBUFFER,g.COLOR_ATTACHMENT0,x,a,m+e)),g.blitFramebuffer(u,h,n,o,c,p,n,o,g.DEPTH_BUFFER_BIT,g.NEAREST);y.bindFramebuffer(g.READ_FRAMEBUFFER,S),y.bindFramebuffer(g.DRAW_FRAMEBUFFER,A)}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=y.currentBoundFramebuffers[g.READ_FRAMEBUFFER]??null,i=y.currentBoundFramebuffers[g.DRAW_FRAMEBUFFER]??null;y.bindFramebuffer(g.READ_FRAMEBUFFER,this._srcFramebuffer),y.bindFramebuffer(g.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let e=0;e<l;e++)N?g.framebufferTextureLayer(g.READ_FRAMEBUFFER,g.COLOR_ATTACHMENT0,t.textureGPU,s,d+e):g.framebufferTexture2D(g.READ_FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,t.textureGPU,s),C?g.framebufferTextureLayer(g.DRAW_FRAMEBUFFER,g.COLOR_ATTACHMENT0,x,a,m+e):g.framebufferTexture2D(g.DRAW_FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,x,a),0!==s?g.blitFramebuffer(u,h,n,o,c,p,n,o,g.COLOR_BUFFER_BIT,g.NEAREST):C?g.copyTexSubImage3D(b,a,c,p,m+e,u,h,n,o):g.copyTexSubImage2D(b,a,c,p,u,h,n,o);y.bindFramebuffer(g.READ_FRAMEBUFFER,r),y.bindFramebuffer(g.DRAW_FRAMEBUFFER,i)}else C?e.isDataTexture||e.isData3DTexture?g.texSubImage3D(b,a,c,p,m,n,o,l,_,v,T.data):t.isCompressedArrayTexture?g.compressedTexSubImage3D(b,a,c,p,m,n,o,l,_,T.data):g.texSubImage3D(b,a,c,p,m,n,o,l,_,v,T):e.isDataTexture?g.texSubImage2D(g.TEXTURE_2D,a,c,p,n,o,_,v,T.data):e.isCompressedTexture?g.compressedTexSubImage2D(g.TEXTURE_2D,a,c,p,T.width,T.height,_,T.data):g.texSubImage2D(g.TEXTURE_2D,a,c,p,n,o,_,v,T);y.pixelStorei(g.UNPACK_ROW_LENGTH,S),y.pixelStorei(g.UNPACK_IMAGE_HEIGHT,A),y.pixelStorei(g.UNPACK_SKIP_PIXELS,M),y.pixelStorei(g.UNPACK_SKIP_ROWS,w),y.pixelStorei(g.UNPACK_SKIP_IMAGES,R),0===a&&t.generateMipmaps&&g.generateMipmap(b),y.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,h=!0===e.isDepthTexture||t.renderTarget&&t.renderTarget.samples>0,d=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(h){let r,h,c=0!==n||0!==o;if(!0===e.isDepthTexture?(r=i.DEPTH_BUFFER_BIT,h=i.DEPTH_ATTACHMENT,t.stencil&&(r|=i.STENCIL_BUFFER_BIT)):(r=i.COLOR_BUFFER_BIT,h=i.COLOR_ATTACHMENT0),c){let e=this.backend.get(t.renderTarget),h=e.framebuffers[t.getCacheKey()],c=e.msaaFrameBuffer;s.bindFramebuffer(i.DRAW_FRAMEBUFFER,h),s.bindFramebuffer(i.READ_FRAMEBUFFER,c);let p=d-o-u;i.blitFramebuffer(n,p,n+l,p+u,n,p,n+l,p+u,r,i.NEAREST),s.bindFramebuffer(i.READ_FRAMEBUFFER,h),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,h,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,d-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:h}=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,h):r>0?(n&&n.isDepthTexture&&n.type===s.FLOAT&&(t=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,r,t,u,h)):s.renderbufferStorage(s.RENDERBUFFER,t,u,h),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else o&&l&&(r>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,r,s.DEPTH24_STENCIL8,u,h):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,u,h),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:h}=this.backend.get(e),d=o.createFramebuffer();n.state.bindFramebuffer(o.READ_FRAMEBUFFER,d);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(h),m=i*s*this._getBytesPerTexel(h,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,h,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(d),f}_getTypedArrayType(e){let{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;
176if(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 sb(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 sv{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 s_{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 sT={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 sS{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 sA{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,T.R8)(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestampQuery(e){return this.timestamps.has(e)}allocateQueriesForContext(){}async resolveQueriesAsync(){}dispose(){}}let sM=sA;class sw extends sM{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,T.R8)("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,T.mc)(`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];
176if(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,T.z3)("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,T.z3)("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,T.z3)("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,T.z3)("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 sR extends sl{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 sv(this),this.capabilities=new s_(this),this.attributeUtils=new sd(this),this.textureUtils=new sx(this),this.bufferRenderer=new sS(this),this.state=new sc(this),this.utils=new sp(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,T.R8)("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 g.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,T.R8)("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 sw(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(g.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(g.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}
176clear(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 h=o.getClearDepth(),d=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,h,d):t?n.clearBufferfv(n.DEPTH,0,[h]):r&&n.clearBufferiv(n.STENCIL,0,[d]),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(g.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:u}=this.get(i),h=this._getVaoKey(u),d=this.vaoCache[h];void 0===d?this.vaoCache[h]=this._createVao(u):a.setVertexState(d),a.useProgram(o),this._bindUniforms(r);let c=this._getTransformFeedback(l);n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,c),n.beginTransformFeedback(n.POINTS),Array.isArray(s=null!==s?s:t.count)?((0,T.mc)("WebGLBackend.compute(): The count parameter must be a single number, not an array."),s=s[0]):s&&"object"==typeof s&&s.isIndirectStorageBufferAttribute&&((0,T.mc)("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),s=t.count),u[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(g.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),h=e.getDrawParameters();if(null===h)return;this._bindUniforms(e.getBindings());let d=t.isMesh&&0>t.matrixWorld.determinantAffine();l.setMaterial(i,d,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 y=u.lastOcclusionObject;if(y!==t&&void 0!==y){if(null!==y&&!0===y.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 x=this.bufferRenderer;t.isPoints?x.mode=o.POINTS:t.isLineSegments?x.mode=o.LINES:t.isLine?x.mode=o.LINE_STRIP:t.isLineLoop?x.mode=o.LINE_LOOP:!0===i.wireframe?(l.setLineWidth(i.wireframeLinewidth*this.renderer.getPixelRatio()),x.mode=o.LINES):x.mode=o.TRIANGLES;let{vertexCount:b,instanceCount:v}=h,{firstVertex:_}=h;if(x.object=t,null!==g){_*=g.array.BYTES_PER_ELEMENT;let e=this.get(g);x.index=g.count,x.type=e.type}else x.index=0;
vendor: 12,470 bytes, line 176
176if(!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(),h=this._currentContext.renderTarget,d=this._isRenderCameraDepthArray(this._currentContext),c=this._currentContext.activeCubeFace;if(d){let e=this.get(h.depthTexture);if(e.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){e.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;let{stencilBuffer:t}=h;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,h=i.length;s<h;s++){let h=i[s];if(t.layers.test(h.layers)){d&&(this.renderer._activeCubeFace=s,this._currentContext.activeCubeFace=s,this._setFramebuffer(this._currentContext));let i=h.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,x,_,b,v,n)}this._currentContext.activeCubeFace=c,this.renderer._activeCubeFace=c}}else this._draw(t,x,_,b,v,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 ss(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,T.z3)("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,T.R8)("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,h=[],d=[];for(let e=0;e<u.length;e++){let t=u[e];h.push(t.varyingName),d.push(t.attributeNode)}i.attachShader(n,o),i.attachShader(n,l),i.transformFeedbackVaryings(n,h,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<d.length;e++){let t=d[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,T.iu)(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,T.iu)(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 h=a*r,d=(u-a)*r,c=h*(e?i.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,c,i,h,d),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(sT).filter(t=>sT[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===g.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,h=!0===a.isCubeRenderTarget,d=!0===a.isRenderTarget3D,c=a.depth>1,p=!0===a.isXRRenderTarget,m=!0===p&&!0===a._hasExternalTextures,g=n.msaaFrameBuffer,f=n.depthRenderbuffer,y=this.extensions.get("WEBGL_multisampled_render_to_texture"),x=this.extensions.get("OVR_multiview2"),b=this._useMultisampledExtension(a),v=G(e);if(h?(n.cubeFramebuffers||(n.cubeFramebuffers={}),s=n.cubeFramebuffers[v]):p&&!1===m?s=this._xrFramebuffer:(n.framebuffers||(n.framebuffers={}),s=n.framebuffers[v]),void 0===s){s=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,s);let i=e.textures,l=[];if(h){n.cubeFramebuffers[v]=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[v]=s;for(let r=0;r<i.length;r++){let s=i[r],n=this.get(s);n.renderTarget=e.renderTarget,n.cacheKey=v;let l=t.COLOR_ATTACHMENT0+r;if(a.multiview)x.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,l,n.textureGPU,0,o,0,2);else if(d||c){let e=this.renderer._activeCubeFace,r=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,l,n.textureGPU,r,e)}else if(b)y.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,b),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=v,a.multiview)x.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,p,r.textureGPU,0,o,0,2);else if(m&&b)y.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,p,t.TEXTURE_2D,r.textureGPU,0,o);else if(e.depthTexture.isArrayTexture){let e=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,p,r.textureGPU,0,e)}else 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||b||a.multiview)&&!0!==a._isOpaqueFramebuffer){r.bindFramebuffer(t.FRAMEBUFFER,s);let i=this.get(e.textures[0]);a.multiview?x.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,i.textureGPU,0,o,0,2):b?y.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i.textureGPU,0);let l=u?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(!0===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?x.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,l,r.textureGPU,0,o,0,2):b?y.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,l,t.TEXTURE_2D,r.textureGPU,0,o):t.framebufferTexture2D(t.FRAMEBUFFER,l,t.TEXTURE_2D,r.textureGPU,0)}}}if(o>0&&!1===b&&!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: 7,377 bytes, line 176
176r.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,h=u.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,o),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),h)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(h){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(h)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 sN="triangle-list",sC="undefined"!=typeof self&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},sE="never",sF="less",sB="equal",sP="less-equal",sV="greater",sL="not-equal",sI="greater-equal",sO="always",sD="store",sU="load",sz="clear",sk="uint16",sG="uint32",sW="r8unorm",s$="r8snorm",sH="r8uint",sj="r8sint",sq="r16uint",sX="r16sint",sK="r16float",sY="rg8unorm",sZ="rg8snorm",sQ="rg8uint",sJ="rg8sint",s0="r16unorm",s1="r16snorm",s2="r32uint",s3="r32sint",s5="r32float",s6="rg16uint",s4="rg16sint",s8="rg16float",s9="rgba8unorm",s7="rgba8unorm-srgb",ae="rgba8snorm",at="rgba8uint",ar="rgba8sint",ai="bgra8unorm",as="bgra8unorm-srgb",aa="rg16unorm",an="rg16snorm",ao="rgb9e5ufloat",al="rgb10a2unorm",au="rg11b10ufloat",ah="rg32uint",ad="rg32sint",ac="rg32float",ap="rgba16uint",am="rgba16sint",ag="rgba16float",af="rgba16unorm",ay="rgba16snorm",ax="rgba32uint",ab="rgba32sint",av="rgba32float",a_="depth24plus",aT="depth24plus-stencil8",aS="depth32float",aA="depth32float-stencil8",aM="bc1-rgba-unorm",aw="bc1-rgba-unorm-srgb",aR="bc2-rgba-unorm",aN="bc2-rgba-unorm-srgb",aC="bc3-rgba-unorm",aE="bc3-rgba-unorm-srgb",aF="bc4-r-unorm",aB="bc4-r-snorm",aP="bc5-rg-unorm",aV="bc5-rg-snorm",aL="bc6h-rgb-ufloat",aI="bc6h-rgb-float",aO="bc7-rgba-unorm",aD="bc7-rgba-unorm-srgb",aU="etc2-rgb8unorm",az="etc2-rgb8unorm-srgb",ak="etc2-rgba8unorm",aG="etc2-rgba8unorm-srgb",aW="eac-r11unorm",a$="eac-r11snorm",aH="eac-rg11unorm",aj="eac-rg11snorm",aq="astc-4x4-unorm",aX="astc-4x4-unorm-srgb",aK="astc-5x4-unorm",aY="astc-5x4-unorm-srgb",aZ="astc-5x5-unorm",aQ="astc-5x5-unorm-srgb",aJ="astc-6x5-unorm",a0="astc-6x5-unorm-srgb",a1="astc-6x6-unorm",a2="astc-6x6-unorm-srgb",a3="astc-8x5-unorm",a5="astc-8x5-unorm-srgb",a6="astc-8x6-unorm",a4="astc-8x6-unorm-srgb",a8="astc-8x8-unorm",a9="astc-8x8-unorm-srgb",a7="astc-10x5-unorm",ne="astc-10x5-unorm-srgb",nt="astc-10x6-unorm",nr="astc-10x6-unorm-srgb",ni="astc-10x8-unorm",ns="astc-10x8-unorm-srgb",na="astc-10x10-unorm",nn="astc-10x10-unorm-srgb",no="astc-12x10-unorm",nl="astc-12x10-unorm-srgb",nu="astc-12x12-unorm",nh="astc-12x12-unorm-srgb",nd="linear",nc="nearest",np="zero",nm="one-minus-src",ng="src-alpha",nf="one-minus-src-alpha",ny="unfilterable-float",nx="2d-array",nb="cube",nv="vertex",n_="instance",nT={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"},nS={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class nA extends i0{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(
176)}}class nM extends i${constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let nw=nM,nR=0;class nN extends nw{constructor(e,t){super("StorageBuffer_"+nR++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:el.pF.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}let nC=[null];class nE{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?aA:aT:!0===this.backend.renderer.reversedDepthBuffer?aS:a_),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?"point-list":e.isLineSegments||e.isMesh&&!0===t.wireframe?"line-list":e.isLine?"line-strip":e.isMesh?sN:void 0}getSampleCount(e){return e>=4?4:1}
vendor: 4,339 bytes, lines 176-215
176getSampleCountRenderContext(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===g.OUM)return ai;if(e===g.ix0)return ag;throw Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function nF(e,t){nC[0]=t,e.queue.submit(nC),nC[0]=null}class nB{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class nP{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 nV{constructor(){this.label=""}reset(){this.label=""}}class nL{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 nI{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 nO{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 nD{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new nU,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 nU{constructor(){this.count=1,this.mask=0xffffffff,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=0xffffffff,this.alphaToCoverageEnabled=!1}}class nz{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class nk{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 nG{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 nW=new nB,n$=new nP,nH=new nV,nj=new nL,nq=new nO,nX=new nD,nK=new nI,nY=new nz,nZ=new nk,nQ=new nG;class nJ extends m{constructor(e){super(),this.device=e;const t=` 177struct VarysStruct { 178 @builtin( position ) Position: vec4f, 179 @location( 0 ) vTex : vec2f, 180 @location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32, 181}; 182 183@group( 0 ) @binding ( 2 ) 184var<uniform> flipY: u32; 185 186@vertex 187fn mainVS( 188 @builtin( vertex_index ) vertexIndex : u32, 189 @builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct { 190 191 var Varys : VarysStruct; 192 193 var pos = array( 194 vec2f( -1, -1 ), 195 vec2f( -1, 3 ), 196 vec2f( 3, -1 ), 197 ); 198 199 let p = pos[ vertexIndex ]; 200 let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 ); 201 Varys.vTex = p * mult + vec2f( 0.5 ); 202 Varys.Position = vec4f( p, 0, 1 ); 203 Varys.vBaseArrayLayer = instanceIndex; 204 205 return Varys; 206 207} 208 209@group( 0 ) @binding( 0 ) 210var imgSampler : sampler; 211 212@group( 0 ) @binding( 1 ) 213var img2d : texture_2d<f32>; 214 215@fragment
216fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> { 217 218 return textureSample( img2d, imgSampler, Varys.vTex ); 219 220} 221 222@group( 0 ) @binding( 1 ) 223var img2dArray : texture_2d_array<f32>; 224 225@fragment 226fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> { 227 228 return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer ); 229 230} 231 232const faceMat = array( 233 mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x 234 mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x 235 mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y 236 mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y 237 mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z 238 mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z 239); 240 241@group( 0 ) @binding( 1 ) 242var imgCube : texture_cube<f32>; 243 244@fragment 245fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4<f32> { 246 247 return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) ); 248 249} 250`;this.mipmapSampler=e.createSampler({minFilter:nd}),this.flipYSampler=e.createSampler({minFilter:nc}),n$.size=4,n$.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(n$),n$.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),n$.size=4,n$.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(n$),n$.reset(),this.transferPipelines={},nY.label="mipmap",nY.code=t,this.mipmapShaderModule=e.createShaderModule(nY),nY.reset()}getTransferPipeline(e,t){t=t||"2d-array";let r=`${e}-${t}`,i=this.transferPipelines[r];return void 0===i&&(nX.label=`mipmap-${e}-${t}`,nX.vertex={module:this.mipmapShaderModule},nX.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},nX.layout="auto",i=this.device.createRenderPipeline(nX),nX.reset(),this.transferPipelines[r]=i),i}flipY(e,t,r=0){let i=t.format,{width:s,height:a}=t.size;nZ.size.width=s,nZ.size.height=a,nZ.format=i,nZ.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;let n=this.device.createTexture(nZ);nZ.reset();let o=this.getTransferPipeline(i,e.textureBindingViewDimension),l=this.getTransferPipeline(i,n.textureBindingViewDimension),u=this.device.createCommandEncoder(nH),h=(e,t,r,i,s,a)=>{let n=e.getBindGroupLayout(0);nQ.dimension=t.textureBindingViewDimension||"2d-array",nQ.mipLevelCount=1;let o=t.createView(nQ);nQ.reset(),nW.layout=n,nW.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(nW);nW.reset(),nQ.dimension="2d",nQ.mipLevelCount=1,nQ.baseArrayLayer=s,nQ.arrayLayerCount=1;let h=i.createView(nQ);nQ.reset(),nK.view=h,nK.loadOp=sz,nK.storeOp=sD,nq.colorAttachments.push(nK);let d=u.beginRenderPass(nq);nq.reset(),nK.reset(),d.setPipeline(e),d.setBindGroup(0,l),d.draw(3,1,0,r),d.end()};h(o,e,r,n,0,!1),h(l,n,0,e,r,!0),nF(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&&(nH.label="mipmapEncoder",s=this.device.createCommandEncoder(nH),nH.reset()),this._mipmapRunBundles(s,i),null===t&&nF(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++){nQ.dimension=t,nQ.baseMipLevel=a-1,nQ.mipLevelCount=1;let o=e.createView(nQ);nQ.reset(),nW.layout=i,nW.entries.push({binding:0,resource:this.mipmapSampler},{binding:1,resource:o},{binding:2,resource:{buffer:this.noFlipUniformBuffer}});let l=this.device.createBindGroup(nW);nW.reset(),nQ.dimension="2d",nQ.baseMipLevel=a,nQ.mipLevelCount=1,nQ.baseArrayLayer=n,nQ.arrayLayerCount=1;let u=e.createView(nQ);nQ.reset();let h=new nI;h.view=u,h.loadOp=sz,h.storeOp=sD;let d=new nO;d.colorAttachments.push(h),nj.colorFormats=[e.format];let c=this.device.createRenderBundleEncoder(nj);nj.reset(),c.setPipeline(r),c.setBindGroup(0,l),c.draw(3,1,0,n),s.push({renderBundles:[c.finish()],passDescriptor:d})}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 n0{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 n1{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"}}let n2=n1;class n3{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 n5{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 n6{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}}
250class n4 extends n2{constructor(){super(),this.colorSpace="srgb",this.premultipliedAlpha=!1}reset(){super.reset(),this.colorSpace="srgb",this.premultipliedAlpha=!1}}class n8{constructor(){this.width=0,this.height=1,this.depthOrArrayLayers=1}reset(){this.width=0,this.height=1,this.depthOrArrayLayers=1}}var n9=r(27240);let n7=new nP,oe=new nV,ot=new n0,or=new n2,oi=new n3,os=new n5,oa=new n6,on=new n4,oo=new nk,ol=new n8,ou={[g.amv]:"never",[g.vim]:"less",[g.kO0]:"equal",[g.TiK]:"less-equal",[g.eoi]:"greater",[g.gWB]:"greater-equal",[g.FFZ]:"always",[g.jzd]:"not-equal"},oh=[0,1,3,2,4,5];function od(e,t,r,i,s,a,n,o,l,u){or.texture=t,or.mipLevel=r,or.origin.z=i,os.offset=i*a,os.bytesPerRow=n,os.rowsPerImage=o,ol.width=l,ol.height=u,e.queue.writeTexture(or,s.data,os,ol),or.reset(),os.reset(),ol.reset()}class oc{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){ot.addressModeU=this._convertAddressMode(r.wrapS),ot.addressModeV=this._convertAddressMode(r.wrapT),ot.addressModeW=this._convertAddressMode(r.wrapR),ot.magFilter=this._convertFilterMode(r.magFilter),ot.minFilter=this._convertFilterMode(r.minFilter),ot.mipmapFilter=this._convertMipmapFilterMode(r.minFilter),r.isDepthTexture&&(null===r.compareFunction||null===i.compareNode)&&(ot.magFilter=nc,ot.minFilter=nc,ot.mipmapFilter=nc),ot.magFilter===nd&&ot.minFilter===nd&&ot.mipmapFilter===nd&&(ot.maxAnisotropy=r.anisotropy),r.isDepthTexture&&null!==r.compareFunction&&null!==i.compareNode&&t.hasCompatibility(g.x$Y.TEXTURE_COMPARE)&&(ot.compare=ou[r.compareFunction]);let e=t.device.createSampler(ot);ot.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=op(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),u=e.internalFormat||t.format||op(e,r.device);i.format=u;let{samples:h,primarySamples:d,isMSAA:c}=r.utils.getTextureSampleData(e),p=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;!0===e.isStorageTexture&&(p|=GPUTextureUsage.STORAGE_BINDING),!0!==e.isCompressedTexture&&!0!==e.isCompressedArrayTexture&&u!==ao&&(p|=GPUTextureUsage.RENDER_ATTACHMENT);let m=new nk;if(m.label=e.name,m.size.width=s,m.size.height=a,m.size.depthOrArrayLayers=n,m.mipLevelCount=o,m.sampleCount=d,m.dimension=l,m.format=u,m.usage=p,void 0===u){(0,T.R8)("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}e.isCubeTexture&&(m.textureBindingViewDimension=nb);try{i.texture=r.device.createTexture(m)}catch(t){(0,T.R8)("WebGPURenderer: Failed to create texture with descriptor:",m),this.createDefaultTexture(e);return}if(c){let e=Object.assign({},m);e.label=e.label+"-msaa",e.sampleCount=h,e.mipLevelCount=1,i.msaaTexture=r.device.createTexture(e)}i.initialized=!0,i.textureDescriptorGPU=m}
vendor: 6,273 bytes, line 250
250destroyTexture(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(),oo.label="colorBuffer",oo.size.width=r,oo.size.height=i,oo.sampleCount=e.utils.getSampleCount(e.renderer.currentSamples),oo.format=e.utils.getPreferredCanvasFormat(),oo.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,o=e.device.createTexture(oo),oo.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,u=a.depthTexture;if(u.width===n&&u.height===o&&u.samples===l&&u.depth===e&&u.stencil===t)return s.get(u).texture;let h=s.get(u).texture;if(t?(r=g.dcC,i=!0===s.renderer.reversedDepthBuffer?g.RQf:g.V3x):e&&(r=g.zdS,i=!0===s.renderer.reversedDepthBuffer?g.RQf:g.bkx),void 0!==h){if(u.image.width===n&&u.image.height===o&&u.format===r&&u.type===i&&u.samples===l)return h;this.destroyTexture(u)}return u.name="depthBuffer",u.format=r,u.type=i,u.image.width=n,u.image.height=o,u.samples=l,this.createTexture(u,{width:n,height:o}),s.get(u).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,h=this._getBytesPerTexel(u),d=i*h;n7.size=(s-1)*(d=256*Math.ceil(d/256))+i*h,n7.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let c=n.createBuffer(n7);n7.reset();let p=n.createCommandEncoder(oe);or.texture=l,or.origin.x=t,or.origin.y=r,or.origin.z=a,oi.buffer=c,oi.bytesPerRow=d,ol.width=i,ol.height=s,p.copyTextureToBuffer(or,oi,ol),or.reset(),oi.reset(),ol.reset();let m=this._getTypedArrayType(u);nF(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 n9.g;r.minFilter=g.hxR,r.magFilter=g.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 eh.b;r.minFilter=g.hxR,r.magFilter=g.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?oh[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;oa.source=e,oa.flipY=s,on.texture=t,on.mipLevel=n,on.origin.z=i,on.premultipliedAlpha=a,ol.width=l,ol.height=u;try{o.queue.copyExternalImageToTexture(oa,on,ol)}catch(e){}finally{oa.reset(),on.reset(),ol.reset()}}_getPassUtils(){let e=this._passUtils;return null===e&&(this._passUtils=e=new nJ(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),h=e.width*u;or.texture=t,or.mipLevel=n,or.origin.z=i,os.offset=e.width*e.height*u*a,os.bytesPerRow=h,ol.width=e.width,ol.height=e.height,o.queue.writeTexture(or,l,os,ol),or.reset(),os.reset(),ol.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,h=l.height,d=n?r.size.depthOrArrayLayers:1,c=Math.ceil(u/a.width)*a.byteLength,p=Math.ceil(h/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)od(s,t,i,e,l,m,c,p,g,f);else for(let e=0;e<d;e++)od(s,t,i,e,l,m,c,p,g,f)}}_getBlockData(e){return e===aM||e===aw?{byteLength:8,width:4,height:4}
250:e===aR||e===aN||e===aC||e===aE?{byteLength:16,width:4,height:4}:e===aF||e===aB?{byteLength:8,width:4,height:4}:e===aP||e===aV||e===aL||e===aI||e===aO||e===aD?{byteLength:16,width:4,height:4}:e===aU||e===az||"etc2-rgb8a1unorm"===e||"etc2-rgb8a1unorm-srgb"===e?{byteLength:8,width:4,height:4}:e===ak||e===aG?{byteLength:16,width:4,height:4}:e===aW||e===a$?{byteLength:8,width:4,height:4}:e===aH||e===aj||e===aq||e===aX?{byteLength:16,width:4,height:4}:e===aK||e===aY?{byteLength:16,width:5,height:4}:e===aZ||e===aQ?{byteLength:16,width:5,height:5}:e===aJ||e===a0?{byteLength:16,width:6,height:5}:e===a1||e===a2?{byteLength:16,width:6,height:6}:e===a3||e===a5?{byteLength:16,width:8,height:5}:e===a6||e===a4?{byteLength:16,width:8,height:6}:e===a8||e===a9?{byteLength:16,width:8,height:8}:e===a7||e===ne?{byteLength:16,width:10,height:5}:e===nt||e===nr?{byteLength:16,width:10,height:6}:e===ni||e===ns?{byteLength:16,width:10,height:8}:e===na||e===nn?{byteLength:16,width:10,height:10}:e===no||e===nl?{byteLength:16,width:12,height:10}:e===nu||e===nh?{byteLength:16,width:12,height:12}:void 0}_convertAddressMode(e){let t="clamp-to-edge";return e===g.GJx?t="repeat":e===g.kTW&&(t="mirror-repeat"),t}_convertFilterMode(e){let t=nd;return(e===g.hxR||e===g.pHI||e===g.Cfg)&&(t=nc),t}_convertMipmapFilterMode(e){return e===g.Cfg||e===g.$_I?nd:nc}_getBytesPerTexel(e){return e===sW||e===s$||e===sH||e===sj?1:e===sq||e===sX||e===sK||e===sY||e===sZ||e===sQ||e===sJ||e===s0||e===s1?2:e===s2||e===s3||e===s5||e===s6||e===s4||e===s8||e===s9||e===s7||e===ae||e===at||e===ar||e===ai||e===as||e===aa||e===an||e===ao||e===al||e===au||e===aS||e===a_||e===aT||e===aA?4:e===ah||e===ad||e===ac||e===ap||e===am||e===ag||e===af||e===ay?8:e===ax||e===ab||e===av?16:void 0}_getTypedArrayType(e){return e===sH?Uint8Array:e===sj?Int8Array:e===sW?Uint8Array:e===s$?Int8Array:e===sQ?Uint8Array:e===sJ?Int8Array:e===sY?Uint8Array:e===sZ?Int8Array:e===at?Uint8Array:e===ar?Int8Array:e===s9||e===s7?Uint8Array:e===ae?Int8Array:e===sq?Uint16Array:e===sX?Int16Array:e===s6?Uint16Array:e===s4?Int16Array:e===ap?Uint16Array:e===am?Int16Array:e===sK||e===s8||e===ag||e===s0?Uint16Array:e===s1?Int16Array:e===aa?Uint16Array:e===an?Int16Array:e===af?Uint16Array:e===ay?Int16Array:e===s2?Uint32Array:e===s3?Int32Array:e===s5?Float32Array:e===ah?Uint32Array:e===ad?Int32Array:e===ac?Float32Array:e===ax?Uint32Array:e===ab?Int32Array:e===av?Float32Array:e===ai||e===as?Uint8Array:e===al||e===ao||e===au?Uint32Array:e===aS?Float32Array:e===a_||e===aT?Uint32Array:e===aA?Float32Array:void 0}_getDimension(e){return e.is3DTexture||e.isData3DTexture?"3d":"2d"}}function op(e,t){let r,i=e.format,s=e.type,a=e.normalized,n=e.colorSpace,o=j.pp.getTransfer(n),l=!1;if(a&&!1===(l=t.features.has(nT.TextureFormatsTier1))&&(0,T.R8)("WebGPURenderer: Unable to use normalized textures without texture-formats-tier1 feature."),!0===e.isCompressedTexture||!0===e.isCompressedArrayTexture)switch(i){case g.IE4:case g.Nz6:r=o===g.KLL?aw:aM;break;case g.jR7:r=o===g.KLL?aN:aR;break;case g.BXX:r=o===g.KLL?aE:aC;break;case g.Kef:r=aF;break;case g.XG_:r=aB;break;case g.HO_:r=aP;break;case g.CWW:r=aV;break;case g.Fn:r=o===g.KLL?aD:aO;break;case g.H23:r=aI;break;case g.W9U:r=aL;break;case g.Riy:case g.CVz:r=o===g.KLL?az:aU;break;case g.KDk:r=o===g.KLL?aG:ak;break;case g.BVL:r=aW;break;case g.gZr:r=a$;break;case g.OtU:r=aH;break;case g.jSS:r=aj;break;case g.qa3:r=o===g.KLL?aX:aq;break;case g.B_h:r=o===g.KLL?aY:aK;break;case g.czI:r=o===g.KLL?aQ:aZ;break;case g.rSH:r=o===g.KLL?a0:aJ;break;case g.Qrf:r=o===g.KLL?a2:a1;break;case g.psI:r=o===g.KLL?a5:a3;break;case g.a5J:r=o===g.KLL?a4:a6;break;case g._QJ:r=o===g.KLL?a9:a8;break;case g.uB5:r=o===g.KLL?ne:a7;break;case g.lyL:r=o===g.KLL?nr:nt;break;case g.bC7:r=o===g.KLL?ns:ni;break;case g.y3Z:r=o===g.KLL?nn:na;break;case g.ojs:r=o===g.KLL?nl:no;break;case g.S$4:r=o===g.KLL?nh:nu;break;case g.GWd:r=o===g.KLL?s7:s9;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture format.",i)}else switch(i){case g.GWd:switch(s){case g.tJf:r=ae;break;case g.fBL:r=l?ay:am;break;case g.cHt:r=l?af:ap;break;case g.bkx:r=ax;break;case g.Yuy:r=ab;break;case g.OUM:r=o===g.KLL?s7:s9;break;case g.ix0:r=ag;break;case g.RQf:r=av;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with RGBAFormat.",s)}break;case g.HIg:switch(s){case g.Dmk:r=ao;break;case g.yT7:r=au;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with RGBFormat.",s)}break;case g.VT0:switch(s){case g.tJf:r=s$;break;case g.fBL:r=l?s1:sX;break;case g.cHt:r=l?s0:sq;break;case g.bkx:r=s2;break;case g.Yuy:r=s3;break;case g.OUM:r=sW;break;case g.ix0:r=sK;break;
250case g.RQf:r=s5;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with RedFormat.",s)}break;case g.paN:switch(s){case g.tJf:r=sZ;break;case g.fBL:r=l?an:s4;break;case g.cHt:r=l?aa:s6;break;case g.bkx:r=ah;break;case g.Yuy:r=ad;break;case g.OUM:r=sY;break;case g.ix0:r=s8;break;case g.RQf:r=ac;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with RGFormat.",s)}break;case g.zdS:switch(s){case g.cHt:r="depth16unorm";break;case g.bkx:r=a_;break;case g.RQf:r=aS;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with DepthFormat.",s)}break;case g.dcC:switch(s){case g.V3x:r=aT;break;case g.RQf:t&&!1===t.features.has(nT.Depth32FloatStencil8)&&(0,T.z3)('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),r=aA;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",s)}break;case g.ZQM:switch(s){case g.Yuy:r=s3;break;case g.bkx:r=s2;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",s)}break;case g.TkQ:switch(s){case g.Yuy:r=ad;break;case g.bkx:r=ah;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",s)}break;case g.c90:switch(s){case g.Yuy:r=ab;break;case g.bkx:r=ax;break;default:(0,T.z3)("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",s)}break;default:(0,T.z3)("WebGPURenderer: Unsupported texture format.",i)}return r}let om=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,og=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,of={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class oy extends rs{constructor(e){const{type:t,inputs:r,name:i,inputsCode:s,blockCode:a,outputType:n}=(e=>{let t=(e=e.trim()).match(om);if(null!==t&&4===t.length){let r=t[2],i=[],s=null;for(;null!==(s=og.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=of[s]),a.push(new td(s,t))}let n=e.substring(t[0].length),o=t[3]||"void",l=void 0!==t[1]?t[1]:"";return{type:of[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 ox extends rr{parseFunction(e){return new oy(e)}}let ob={[el.pF.READ_ONLY]:"read",[el.pF.WRITE_ONLY]:"write",[el.pF.READ_WRITE]:"read_write"},ov={[g.GJx]:"repeat",[g.ghU]:"clamp",[g.kTW]:"mirror"},o_={vertex:sC.VERTEX,fragment:sC.FRAGMENT,compute:sC.COMPUTE},oT={instance:!0,swizzleAssign:!1,storageBuffer:!0},oS={"^^":"tsl_xor"},oA={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>"},oM={},ow={tsl_xor:new tA.Ay("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }
250"),mod_float:new tA.Ay("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new tA.Ay("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new tA.Ay("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new tA.Ay("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new tA.Ay("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new tA.Ay("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new tA.Ay("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 tA.Ay("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 tA.Ay("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new tA.Ay("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 tA.Ay("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),inverse_mat2:new tA.Ay(` 251fn tsl_inverse_mat2( m : mat2x2<f32> ) -> mat2x2<f32> { 252 253 let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ]; 254 255 return mat2x2<f32>( 256 m[ 1 ][ 1 ], - m[ 0 ][ 1 ], 257 - m[ 1 ][ 0 ], m[ 0 ][ 0 ] 258 ) * ( 1.0 / det ); 259 260} 261`),inverse_mat3:new tA.Ay(` 262fn tsl_inverse_mat3( m : mat3x3<f32> ) -> mat3x3<f32> { 263 264 let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; 265 let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; 266 let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; 267 268 let b01 = a22 * a11 - a12 * a21; 269 let b11 = - a22 * a10 + a12 * a20; 270 let b21 = a21 * a10 - a11 * a20; 271 272 let det = a00 * b01 + a01 * b11 + a02 * b21; 273 274 return mat3x3<f32>( 275 b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ), 276 b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ), 277 b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 ) 278 ) * ( 1.0 / det ); 279 280} 281`),inverse_mat4:new tA.Ay(` 282fn tsl_inverse_mat4( m : mat4x4<f32> ) -> mat4x4<f32> { 283 284 let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ]; 285 let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ]; 286 let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ]; 287 let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ]; 288 289 let b00 = a00 * a11 - a01 * a10; 290 let b01 = a00 * a12 - a02 * a10; 291 let b02 = a00 * a13 - a03 * a10; 292 let b03 = a01 * a12 - a02 * a11; 293 let b04 = a01 * a13 - a03 * a11; 294 let b05 = a02 * a13 - a03 * a12; 295 let b06 = a20 * a31 - a21 * a30; 296 let b07 = a20 * a32 - a22 * a30; 297 let b08 = a20 * a33 - a23 * a30; 298 let b09 = a21 * a32 - a22 * a31; 299 let b10 = a21 * a33 - a23 * a31; 300 let b11 = a22 * a33 - a23 * a32; 301 302 let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; 303 304 return mat4x4<f32>( 305 a11 * b11 - a12 * b10 + a13 * b09, 306 a02 * b10 - a01 * b11 - a03 * b09, 307 a31 * b05 - a32 * b04 + a33 * b03, 308 a22 * b04 - a21 * b05 - a23 * b03, 309 a12 * b08 - a10 * b11 - a13 * b07, 310 a00 * b11 - a02 * b08 + a03 * b07, 311 a32 * b02 - a30 * b05 - a33 * b01, 312 a20 * b05 - a22 * b02 + a23 * b01, 313 a10 * b10 - a11 * b08 + a13 * b06, 314 a01 * b08 - a00 * b10 - a03 * b06, 315 a30 * b04 - a31 * b02 + a33 * b00, 316 a21 * b02 - a20 * b04 - a23 * b00, 317 a11 * b07 - a10 * b09 - a12 * b06, 318 a00 * b09 - a01 * b07 + a02 * b06, 319 a31 * b01 - a30 * b03 - a32 * b00, 320 a20 * b03 - a21 * b01 + a22 * b00 321 ) * ( 1.0 / det ); 322 323} 324`),biquadraticTexture:new tA.Ay(` 325fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { 326 327 let res = vec2f( iRes ); 328 329 let uvScaled = coord * res; 330 let uvWrapping = ( ( uvScaled % res ) + res ) % res; 331 332 // https://www.shadertoy.com/view/WtyXRy 333 334 let uv = uvWrapping - 0.5; 335 let iuv = floor( uv ); 336 let f = fract( uv ); 337 338 let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); 339 let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); 340 let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); 341 let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); 342 343 return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); 344 345} 346`),biquadraticTextureArray:new tA.Ay(` 347fn tsl_biquadraticTexture_array( map : texture_2d_array<f32>, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f { 348 349 let res = vec2f( iRes ); 350 351 let uvScaled = coord * res; 352 let uvWrapping = ( ( uvScaled % res ) + res ) % res; 353 354 // https://www.shadertoy.com/view/WtyXRy 355 356 let uv = uvWrapping - 0.5; 357 let iuv = floor( uv ); 358 let f = fract( uv ); 359 360 let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level ); 361 let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level ); 362 let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level ); 363 let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level ); 364 365 return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); 366 367} 368`)},oR={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"},oN="";!0!==("undefined"!=typeof navigator&&/Firefox|Deno/g.test(navigator.userAgent))&&(oN+="diagnostic( off, derivative_uniformity );\n");class oC extends tu{constructor(e,t){super(e,t,new ox),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_${ov[e.wrapS]}S_${ov[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`,r=oM[t];
368if(void 0===r){let i=[],s=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f",a=`fn ${t}( coord : ${s} ) -> ${s} { 369 370 return ${s}( 371`,n=(e,t)=>{e===g.GJx?(i.push(ow.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${t} )`):e===g.ghU?(i.push(ow.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${t} )`):e===g.kTW?(i.push(ow.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${t} )`):(a+=` coord.${t}`,(0,T.R8)(`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",oM[t]=r=new tA.Ay(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 ty.Ay(new tM.A(`textureDimensions( ${a} )`,n)),i.dimensionsSnippet[r]=s,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(i.arrayLayerCount=new ty.Ay(new tM.A(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(i.cubeFaceCount=new ty.Ay(new tM.A("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 h=`${l}<f32>( 0 )`,d=`${l}<f32>( ${o} - ${u} )`;return r=`${l}<u32>( clamp( floor( ${n}( ${r} ) * ${l}<f32>( ${o} ) ), ${h}, ${d} ) )`,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(g.x$Y.TEXTURE_COMPARE)}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&e.type===g.RQf||!1===this.isSampleCompare(e)&&e.minFilter===g.hxR&&e.magFilter===g.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,T.z3)(`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,T.z3)(`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,T.z3)(`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,495 bytes, lines 371-378
371stomStruct(e)?t:t+".value"}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){let t=oS[e];return void 0!==t?(this._include(t),t):null}getNodeAccess(e,t){return"compute"!==t?!0===e.isAtomic?((0,T.R8)("WebGPURenderer: Atomic operations are only supported in compute shaders."),el.pF.READ_WRITE):el.pF.READ_ONLY:e.access}getStorageAccess(e,t){return ob[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 i6(s.name,s.node,o,a):new i3(s.name,s.node,o,a):"cubeTexture"===t||"cubeDepthTexture"===t?i=new i5(s.name,s.node,o,a):"texture3D"===t&&(i=new i6(s.name,s.node,o,a)),i.store=!0===e.isStorageTextureNode,i.mipLevel=i.store?e.mipLevel:0,i.setVisibility(o_[r]),!0===e.value.isCubeTexture||!1===this.isUnfilterable(e.value)&&!1===i.store||null!==e.gatherNode){let e=new nA(`${s.name}_sampler`,s.node,o);e.setVisibility(o_[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?iX:nN)(e,o)),l.setVisibility(l.getVisibility()|o_[r]),u.push(l),n=l,s.name=i||"NodeBuffer_"+s.id}else{let e=this.uniformGroups[l];void 0===e&&((e=new iQ(l,o)).setVisibility(sC.VERTEX|sC.FRAGMENT|sC.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)} { 372${r.vars} 373${r.code} 374`;return r.result&&(s+=` return ${r.result}; 375`),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} { 376`;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"):` 377 ${i.join("\n ")} 378`}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}`}
378else/^(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=op(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} 379`),s+=`${r.code} 380 `,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())}; 381 382 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 oA[e]||e}isAvailable(e){let t=oT[e];return void 0===t&&("float32Filterable"===e?t=this.renderer.hasFeature("float32-filterable"):"clipDistance"===e&&(t=this.renderer.hasFeature("clip-distances")),oT[e]=t),t}_getWGSLMethod(e){return void 0!==ow[e]&&this._include(e),oR[e]}_include(e){let t=ow[e];return t.build(this),this.addInclude(t),t}
382_getWGSLVertexCode(e){return`${this.getSignature()} 383// directives 384${e.directives} 385 386// structs 387${e.structs} 388 389// uniforms 390${e.uniforms} 391 392// varyings 393${e.varyings} 394var<private> varyings : VaryingsStruct; 395 396// vars 397${e.vars} 398 399// codes 400${e.codes} 401 402@vertex 403fn main( ${e.attributes} ) -> VaryingsStruct { 404 405 // flow 406 ${e.flow} 407 408 return varyings; 409 410} 411`}_getWGSLFragmentCode(e){return`${this.getSignature()} 412// global 413${oN} 414 415// structs 416${e.structs} 417 418// uniforms 419${e.uniforms} 420 421// vars 422${e.vars} 423 424// codes 425${e.codes} 426 427@fragment 428fn main( ${e.varyings} ) -> ${e.returnType} { 429 430 // flow 431 ${e.flow} 432 433} 434`}_getWGSLComputeCode(e,t){let[r,i,s]=t;return`${this.getSignature()} 435// directives 436${e.directives} 437 438// system 439var<private> instanceIndex : u32; 440 441// locals 442${e.scopedArrays} 443 444// structs 445${e.structs} 446 447// uniforms 448${e.uniforms} 449 450// vars 451${this.allowGlobalVariables?e.vars:""} 452 453// codes 454${e.codes} 455 456@compute @workgroup_size( ${r}, ${i}, ${s} ) 457fn main( ${e.attributes} ) { 458 459 // local vars 460 ${this.allowGlobalVariables?"":e.vars} 461 462 // system 463 instanceIndex = globalId.x 464 + globalId.y * ( ${r} * numWorkgroups.x ) 465 + globalId.z * ( ${r} * numWorkgroups.x ) * ( ${i} * numWorkgroups.y ); 466 467 // flow 468 ${e.flow} 469 470} 471`}_getWGSLStruct(e,t){return` 472struct ${e} { 473${t} 474};`}_getWGSLStructBinding(e,t,r,i=0,s=0){let a=e+"Struct",n=this._getWGSLStruct(a,t);return`${n} 475@binding( ${i} ) @group( ${s} ) 476var<${r}> ${e} : ${a};`}}let oE=new nP,oF=new nV,oB=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&&oB.set(Float16Array,["float16"]);let oP=new Map([[y.O,["float16"]]]),oV=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class oL{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;oE.label=r.name,oE.size=u+(4-u%4)%4,oE.usage=t,oE.mappedAtCreation=!0,a=o.createBuffer(oE),oE.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 u=t.updateRanges;if(0===u.length)i.queue.writeBuffer(a,0,n,0);else{let e=(0,T.iu)(n),r=e?1:n.BYTES_PER_ELEMENT;for(let t=0,s=u.length;t<s;t++){let s,h,d=u[t];if(void 0!==l){let e=Math.floor(d.start/o),t=Math.ceil((d.start+d.count)/o)-e;s=e*l*r,h=t*l*r}else s=d.start*r,h=d.count*r;let c=s*(e?n.BYTES_PER_ELEMENT:1);i.queue.writeBuffer(a,c,n,s,h)}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?n_:nv):(e=i.itemSize*s,t=i.isInstancedBufferAttribute?n_:nv,i.itemSize>1&&e%4!=0&&(e=4*Math.floor((e+3)/4))),!1===i.normalized&&(i.array.constructor===Int16Array||i.array.
476constructor===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){oE.label=`${t.name}_readback`,oE.size=t.maxByteLength,oE.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,s=n.createBuffer(oE),oE.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 oE.label=`${e.name}_readback`,oE.size=l,oE.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,s=n.createBuffer(oE),oE.reset();oF.label=`readback_encoder_${e.name}`;let u=n.createCommandEncoder(oF);if(oF.reset(),u.copyBufferToBuffer(o,r,s,0,l),nF(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=oV.get(s);else{let e=(oP.get(a)||oB.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,T.z3)("WebGPUAttributeUtils: Vertex format not supported yet."),t}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}let oI=new nB,oO=new nP,oD=new nG;class oU{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class oz{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=(0,o.YZ)(JSON.stringify(s)),n=this._bindGroupLayoutCache.get(a);return void 0===n&&(n=new oU(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,T.iu)(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],h=l.start+l.count;if(void 0!==u&&u.start===h)continue;let d=n*t,c=(h-n)*t,p=d*(e?i.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(s,p,i,d,c),void 0!==u&&(n=u.start)}}}createBindGroupIndex(e,t){let r=this.backend.device,i=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,s=e[0];oO.label="bindingCameraIndex_"+s,oO.size=16,oO.usage=i;let a=r.createBuffer(oO);oO.reset(),r.queue.writeBuffer(a,0,e,0),oI.label="bindGroupCameraIndex_"+s,oI.layout=t,oI.entries.push({binding:0,resource:{buffer:a}});let n=r.createBindGroup(oI);return oI.reset(),n}createBindGroup(e,t){let r=this.backend,i=r.device,s=0;for(let a of(oI.label="bindGroup_"+e.name,oI.layout=t,e.bindings)){if(a.isUniformBuffer){let e=r.get(a);oI.entries.push({binding:s,resource:{buffer:e.buffer}})}else if(a.isStorageBuffer){let e=r.get(a.attribute).buffer;oI.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;n=a.isSampledCubeTexture?nb:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?nx:a.isSampledTexture3D?"3d":"2d",oD.aspect="all",oD.dimension=n,oD.mipLevelCount=r,oD.baseMipLevel=i,e=t[s]=t.texture.createView(oD),oD.reset()}}oI.entries.push({binding:s,resource:e})}else if(a.isSampler){let e=r.get(a);oI.entries.push({binding:s,resource:e.sampler})}s++}let a=i.createBindGroup(oI);return oI.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&sC.COMPUTE&&(i.access===el.pF.READ_WRITE||i.access===el.pF.WRITE_ONLY)?e.type="storage":e.type="read-only-storage"),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===el.pF.READ_WRITE?e.access="read-write":t===el.pF.WRITE_ONLY?e.access="write-only":e.access="read-only",i.texture.isArrayTexture?e.viewDimension=nx:i.texture.is3DTexture&&(e.viewDimension="3d"),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=ny)),i.texture.isDepthTexture)e.compatibilityMode&&null===i.texture.compareFunction?t.sampleType=ny:t.sampleType="depth";else{let e=i.texture.type;e===g.Yuy?t.sampleType="sint":e===g.bkx?t.sampleType="uint":e===g.RQf&&(this.backend.hasFeature("float32-filterable")?t.sampleType="float":t.sampleType=ny)}i.isSampledCubeTexture?t.viewDimension=nb:i.texture.isArrayTexture||i.texture.isDataArrayTexture||i.texture.isCompressedArrayTexture?t.viewDimension=nx:i.isSampledTexture3D&&(t.viewDimension="3d"),s.texture=t}else if(i.isSampler){let t={};i.texture.isDepthTexture&&(null!==i.texture.compareFunction&&null!==i.textureNode.compareNode&&e.hasCompatibility(g.x$Y.TEXTURE_COMPARE)?t.type="comparison":t.type="non-filtering"),s.sampler=t}else(0,T.z3)(`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 ok{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}class oG{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}}class oW{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}}let o$=new oG,oH=new oW,oj=new nL,oq=new nD;class oX{constructor(e){this.backend=e}
476_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,u=this.backend,h=u.device,d=u.utils,c=u.get(n),p=[];for(let t of e.getBindings()){let{layoutGPU:e}=u.get(t).layout;p.push(e)}let m=u.attributeUtils.createShaderVertexBuffers(e);s.blending!==g.XIg&&(s.blending!==g.NTi||!1!==s.transparent)&&(r=this._getBlending(s));let f={};!0===s.stencilWrite&&(f={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});let y=this._getColorWriteMask(s),x=[];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=d.getTextureFormatGPU(a);if(null!==i)if(!0!==this.backend.compatibilityMode){let e=i.getBlendMode(a.name);e.blending===g.pCc?s=r:e.blending!==g.XIg&&(s=this._getBlending(e))}else(0,T.mc)("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;x.push({format:n,blend:s,writeMask:y})}}else{let t=d.getCurrentColorFormat(e.context);x.push({format:t,blend:r,writeMask:y})}let b=u.get(o).module,v=u.get(l).module,_=this._getPrimitiveState(i,a,s),S=this._getDepthCompare(s),A=d.getCurrentDepthStencilFormat(e.context),M=this._getSampleCount(e.context);oH.bindGroupLayouts=p;let w=h.createPipelineLayout(oH);oH.reset(),oq.label=`renderPipeline_${s.name||s.type}_${s.id}`,oq.vertex=Object.assign({},b,{buffers:m}),oq.fragment=Object.assign({},v,{targets:x}),oq.primitive=_,oq.multisample.count=M,oq.multisample.alphaToCoverageEnabled=s.alphaToCoverage&&M>1,oq.layout=w;let R={},N=e.context.depth,C=e.context.stencil;(!0===N||!0===C)&&(!0===N&&(R.format=A,R.depthWriteEnabled=s.depthWrite,R.depthCompare=S),!0===C&&(R.stencilFront=f,R.stencilBack=f,R.stencilReadMask=s.stencilFuncMask,R.stencilWriteMask=s.stencilWriteMask),!0===s.polygonOffset&&_.topology===sN&&(R.depthBias=s.polygonOffsetUnits,R.depthBiasSlopeScale=s.polygonOffsetFactor,R.depthBiasClamp=0),oq.depthStencil=R),h.pushErrorScope("validation");let E=[{program:o,module:b.module},{program:l,module:v.module}],F=oq.label;if(null===t)c.pipeline=h.createRenderPipeline(oq),oq.reset(),h.popErrorScope().then(e=>{null!==e&&(c.error=!0,(0,T.z3)(`WebGPURenderer: Render pipeline creation failed (${F}): ${e.message}`),this._reportShaderDiagnostics(E,F))});else{let e=new Promise(async e=>{try{let e=null,t=null;try{t=h.createRenderPipelineAsync(oq)}catch(t){e=t}if(oq.reset(),null!==t)try{c.pipeline=await t}catch(t){e=t}let r=await h.popErrorScope();if(null!==r||null!==e){c.error=!0;let t=r&&r.message||e&&e.message||"unknown";(0,T.z3)(`WebGPURenderer: Async render pipeline creation failed (${F}): ${t}`),await this._reportShaderDiagnostics(E,F)}}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);oj.label=t,oj.colorFormats=a,oj.depthStencilFormat=s,oj.sampleCount=n;let o=i.createRenderBundleEncoder(oj);return oj.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"),oH.bindGroupLayouts=n;let u=i.createPipelineLayout(oH);oH.reset(),o$.label=l,o$.compute=s,o$.layout=u,a.pipeline=i.createComputePipeline(o$),o$.reset(),i.popErrorScope().then(e=>{null!==e&&(a.error=!0,(0,T.z3)(`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=` 477 ${s[i.lineNum-1]}`,i.linePos>0&&(n+=` 478 ${" ".repeat(i.linePos-1)}^`)),("error"===i.type?T.z3:T.R8)(a+n)}}}_getBlending(e){let t,r,i=e.blending,s=e.blendSrc,a=e.blendDst,n=e.blendEquation;if(i===g.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)=>
478{t={srcFactor:e,dstFactor:i,operation:"add"},r={srcFactor:s,dstFactor:a,operation:"add"}};if(s)switch(i){case g.NTi:a("one",nf,"one",nf);break;case g.EZo:a("one","one","one","one");break;case g.Kwu:a(np,nm,np,"one");break;case g.EdD:a("dst",nf,np,"one")}else switch(i){case g.NTi:a(ng,nf,"one",nf);break;case g.EZo:a(ng,"one","one","one");break;case g.Kwu:(0,T.z3)(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case g.EdD:(0,T.z3)(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`)}}if(void 0!==t&&void 0!==r)return{color:t,alpha:r};(0,T.z3)("WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;switch(e){case g.ojh:t=np;break;case g.qad:t="one";break;case g.f4X:t="src";break;case g.LiQ:t=nm;break;case g.ie2:t=ng;break;case g.OuU:t=nf;break;case g.wn6:t="dst";break;case g.aEY:t="one-minus-dst";break;case g.hdd:t="dst-alpha";break;case g.Nt7:t="one-minus-dst-alpha";break;case g.hgQ:t="src-alpha-saturated";break;case 211:t="constant";break;case 212:t="one-minus-constant";break;default:(0,T.z3)("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t,r=e.stencilFunc;switch(r){case g.HPb:t=sE;break;case g.sKt:t=sO;break;case g.kYr:t=sF;break;case g.CR7:t=sP;break;case g.jsO:t=sB;break;case g.TMh:t=sI;break;case g.RcT:t=sV;break;case g.klZ:t=sL;break;default:(0,T.z3)("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case g.VVr:t="keep";break;case g.kqe:t="zero";break;case g.kG0:t="replace";break;case g.oVO:t="invert";break;case g.HLH:t="increment-clamp";break;case g.ROr:t="decrement-clamp";break;case g.Ru$:t="increment-wrap";break;case g.fJr:t="decrement-wrap";break;default:(0,T.z3)("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case g.gO9:t="add";break;case g.FXf:t="subtract";break;case g.nST:t="reverse-subtract";break;case g.znC:t="min";break;case g.$ei:t="max";break;default:(0,T.z3)("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?sk:sG);let s=r.side===g.hsX;return e.isMesh&&0>e.matrixWorld.determinantAffine()&&(s=!s),i.frontFace=!0===s?"cw":"ccw",i.cullMode=r.side===g.$EB?"none":"back",i}_getColorWriteMask(e){return 15*(!0===e.colorWrite)}_getDepthCompare(e){let t;if(!1===e.depthTest)t=sO;else{let r=this.backend.parameters.reversedDepthBuffer?T.ri[e.depthFunc]:e.depthFunc;switch(r){case g.eHc:t=sE;break;case g.lGu:t=sO;break;case g.brA:t=sF;break;case g.xSv:t=sP;break;case g.U3G:t=sB;break;case g.Gwm:t=sI;break;case g.K52:t=sV;break;case g.bw0:t=sL;break;default:(0,T.z3)("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class oK{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}let oY=new nP,oZ=new nV,oQ=new oK;class oJ extends sM{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,oQ.label=`queryset_global_timestamp_${t}`,oQ.type="timestamp",oQ.count=this.maxQueries,this.querySet=this.device.createQuerySet(oQ),oQ.reset();const i=8*this.maxQueries;oY.label=`buffer_timestamp_resolve_${t}`,oY.size=i,oY.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(oY),oY.reset(),oY.label=`buffer_timestamp_result_${t}`,oY.size=i,oY.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(oY),oY.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return(0,T.mc)(`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(oZ);i.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),i.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);let s=i.finish();if(nF(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,T.z3)("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,T.z3)("Error waiting for pending resolve:",e)}if(this.resultBuffer&&"mapped"===this.resultBuffer.mapState)try{this.resultBuffer.unmap()}catch(e){(0,T.z3)("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 o0{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}}class o1{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 o2{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 o3={r:0,g:0,b:0,a:1},o5=new nP,o6=new nV,o4=new o0,o8=new oK,o9=new nz,o7=new o2,le=new n2,lt=new n2,lr=new nG,li=new n8;class ls extends sl{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 nE(this),this.attributeUtils=new oL(this),this.bindingUtils=new oz(this),this.capabilities=new ok(this),this.pipelineUtils=new oX(this),this.textureUtils=new oc(this),this.occludedResolveCache=new Map;const t="undefined"==typeof navigator||!1===/Android/.test(navigator.userAgent);this._compatibility={[g.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(nT),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(nT.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${g.sPf} webgpu`);
vendor: 14,270 bytes, line 478
478let s=i.alpha?"premultiplied":"opaque",a=i.outputType===g.ix0?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,toneMapping:{mode:a}}),t.context=r}return r}get coordinateSystem(){return g.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 nO).colorAttachments.push(new nI),!0===e.depth||!0===e.stencil){let t=new o1;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:"2d",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(lr.label=`colorAttachment_${i}`,lr.baseMipLevel=e.activeMipmapLevel,lr.mipLevelCount=1,lr.baseArrayLayer=e.activeCubeFace,lr.arrayLayerCount=1,lr.dimension="2d",r.isRenderTarget3D)t=e.activeCubeFace,lr.baseArrayLayer=0,lr.dimension="3d";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++){lr.baseArrayLayer=e,lr.arrayLayerCount=1,lr.dimension="2d";let t=a.texture.createView(lr);l.push({view:t,resolveTarget:void 0,depthSlice:void 0})}}else lr.dimension=nx;if(!0!==u){let e,r,i=a.texture.createView(lr);void 0!==a.msaaTexture?(e=a.msaaTexture.createView(),r=i):(e=i,r=void 0),l.push({view:e,resolveTarget:r,depthSlice:t})}lr.reset()}let h=[];for(let e=0;e<l.length;e++){let t=l[e],r=new nI;r.view=t.view,r.depthSlice=t.depthSlice,r.resolveTarget=t.resolveTarget,h.push(r)}if(o={textureViews:l,colorAttachments:h,descriptor:new nO},e.depth){let t=this.get(e.depthTexture);(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(lr.dimension="2d",lr.arrayLayerCount=1,lr.baseArrayLayer=e.activeCubeFace);let r=new o1;r.view=t.texture.createView(lr),o.depthStencilAttachment=r,lr.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||sU,r.storeOp=t.storeOp||sD,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,o8.label=`occlusionQuerySet_${e.id}`,o8.type="occlusion",o8.count=a,t=s.createQuerySet(o8),o8.reset(),i.occlusionQuerySet=t,i.occlusionQueryIndex=0,i.occlusionQueryObjects=Array(a),i.lastOcclusionObject=null),r=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e,{loadOp:sU}),this.initTimestampQuery(g.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:(o3.r=0,o3.g=0,o3.b=0,o3.a=1,i.clearValue=o3),i.loadOp=sz):i.loadOp=sU,i.storeOp=sD}}else{let t=r.colorAttachments[0];e.clearColor?(t.clearValue=e.clearColorValue,t.loadOp=sz):t.loadOp=sU,t.storeOp=sD}e.depth&&(e.clearDepth?(n.depthClearValue=e.clearDepthValue,n.depthLoadOp=sz):n.depthLoadOp=sU,n.depthStoreOp=sD),e.stencil&&(e.clearStencil?(n.stencilClearValue=e.clearStencilValue,n.stencilLoadOp=sz):n.stencilLoadOp=sU,n.stencilStoreOp=sD),o6.label="renderContext_"+e.id;let o=s.createCommandEncoder(o6);if(o6.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 nI;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 nO;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]||(lr.dimension="2d",lr.baseArrayLayer=n,lr.arrayLayerCount=1,a.viewCache[t]=a.texture.createView(lr),lr.reset());let r=new o1;r.view=a.viewCache[t],r.depthLoadOp=s.depthLoadOp||sz,r.depthStoreOp=s.depthStoreOp||sD,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 o1;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=sz):t.depthLoadOp=sU),e.stencil&&(e.clearStencil?(t.stencilClearValue=e.clearStencilValue,t.stencilLoadOp=sz):t.stencilLoadOp=sU)}}}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&&(o5.size=i,o5.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,s=this.device.createBuffer(o5),o5.reset(),this.occludedResolveCache.set(i,s)),o5.size=i,o5.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;let a=this.device.createBuffer(o5);o5.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(nF(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();o3.r=e.r,o3.g=e.g,o3.b=e.b,o3.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=o3,e.loadOp=sz,e.storeOp=sD}(a||n)&&(s=t.depthStencilAttachment)}else{a=i.depth,n=i.stencil;let o={loadOp:e?sz:sU,clearValue:e?o3:void 0};a&&(o.depthLoadOp=t?sz:sU,o.depthClearValue=t?l.getClearDepth():void 0,o.depthStoreOp=sD),n&&(o.stencilLoadOp=r?sz:sU,o.stencilClearValue=r?l.getClearStencil():void 0,o.stencilStoreOp=sD);let h=this._getRenderPassDescriptor(i,o);u=h.colorAttachments,s=h.depthStencilAttachment}a&&s&&(t?(s.depthLoadOp=sz,s.depthClearValue=l.getClearDepth()):s.depthLoadOp=sU,s.depthStoreOp=sD),n&&s&&(r?(s.stencilLoadOp=sz,s.stencilClearValue=l.getClearStencil()):s.stencilLoadOp=sU,s.stencilStoreOp=sD),o6.label="clear";let h=o.createCommandEncoder(o6);o6.reset(),h.beginRenderPass({colorAttachments:u,depthStencilAttachment:s}).end(),nF(o,h.finish())}beginCompute(e){let t=this.get(e),r="computeGroup_"+e.id;o4.label=r,o6.label=r,this.initTimestampQuery(g.v9J.COMPUTE,this.getTimestampUID(e),o4),t.cmdEncoderGPU=this.device.createCommandEncoder(o6),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(o4),t.currentPipeline=null,o6.reset(),o4.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(),nF(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,i,s,a,n,o,l){let{object:u,material:h,context:d}=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?sk:sG;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===d.stencil&&!0===h.stencilWrite&&r.currentStencilRef!==h.stencilRef&&(o.setStencilReference(h.stencilRef),r.currentStencilRef=h.stencilRef),!0===u.isBatchedMesh){let e=u._multiDrawStarts,r=u._multiDrawCounts,i=u._multiDrawCount,s=!0===p?c.array.BYTES_PER_ELEMENT:1;h.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)}else 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(),h=e.getVertexBuffers();if(e.camera.isArrayCamera&&e.camera.cameras.length>0){let s=this.get(e.camera),n=e.camera.cameras,d=e.getBindingGroup("cameraIndex");if(void 0===s.indexesGPU||s.indexesGPU.length!==n.length){let e=this.get(d),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 478
478if(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),d&&s.indexesGPU){let e=u.indexOf(d);n.setBindGroup(e,s.indexesGPU[p]),g.bindingGroups[e]=d.id}this._draw(e,t,a,o,u,h,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,h,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),h=r.isMesh&&0>r.matrixWorld.determinantAffine(),d=!1;return(t.material!==i||t.materialVersion!==i.version||t.transparent!==i.transparent||t.blending!==i.blending||t.premultipliedAlpha!==i.premultipliedAlpha||t.blendSrc!==i.blendSrc||t.blendDst!==i.blendDst||t.blendEquation!==i.blendEquation||t.blendSrcAlpha!==i.blendSrcAlpha||t.blendDstAlpha!==i.blendDstAlpha||t.blendEquationAlpha!==i.blendEquationAlpha||t.colorWrite!==i.colorWrite||t.depthWrite!==i.depthWrite||t.depthTest!==i.depthTest||t.depthFunc!==i.depthFunc||t.stencilWrite!==i.stencilWrite||t.stencilFunc!==i.stencilFunc||t.stencilFail!==i.stencilFail||t.stencilZFail!==i.stencilZFail||t.stencilZPass!==i.stencilZPass||t.stencilFuncMask!==i.stencilFuncMask||t.stencilWriteMask!==i.stencilWriteMask||t.side!==i.side||t.alphaToCoverage!==i.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==n||t.colorFormat!==o||t.depthStencilFormat!==l||t.primitiveTopology!==u||t.frontFaceCW!==h||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=h,t.clippingContextCacheKey=e.clippingContextCacheKey,d=!0),d}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 oJ(this.device,e,2048));let i=this.timestampQueryPool[e],s=i.allocateQueriesForContext(t);o7.querySet=i.querySet,o7.beginningOfPassWriteIndex=s,o7.endOfPassWriteIndex=s+1,r.timestampWrites=o7}createNodeBuilder(e,t){return new oC(e,t)}createProgram(e){let t=this.get(e);o9.label=e.stage+(""!==e.name?`_${e.name}`:""),o9.code=e.code,t.module={module:this.device.createShaderModule(o9),entryPoint:"main"},o9.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&sC.VERTEX&&s.push("vertex"),e.visibility&sC.FRAGMENT&&s.push("fragment"),e.visibility&sC.COMPUTE&&s.push("compute");let a=`(${s.join(",")})`;o5.label=`bindingBuffer${e.id}_${e.name}_${a}`,o5.size=r,o5.usage=i;let n=this.device.createBuffer(o5);o5.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!==nS[e]&&(e=nS[e]),this.device.features.has(e)}
478copyTextureToTexture(e,t,r=null,i=null,s=0,a=0){let n=0,o=0,l=0,u=0,h=0,d=0,c=e.image.width,p=e.image.height,m=1;null!==r&&(!0===r.isBox3?(u=r.min.x,h=r.min.y,d=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,h=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),o6.label="copyTextureToTexture_"+e.id+"_"+t.id;let g=this.device.createCommandEncoder(o6);o6.reset();let f=this.get(e).texture,y=this.get(t).texture;le.texture=f,le.mipLevel=s,le.origin.x=u,le.origin.y=h,le.origin.z=d,lt.texture=y,lt.mipLevel=a,lt.origin.x=n,lt.origin.y=o,lt.origin.z=l,li.width=c,li.height=p,li.depthOrArrayLayers=m,g.copyTextureToTexture(le,lt,li),le.reset(),lt.reset(),li.reset(),nF(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,T.z3)("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",a.format,n.format);if(s.currentPass?(s.currentPass.end(),i=s.encoder):(o6.label="copyFramebufferToTexture_"+e.id,i=this.device.createCommandEncoder(o6),o6.reset()),le.texture=a,le.origin.x=r.x,le.origin.y=r.y,lt.texture=n,li.width=r.z,li.height=r.w,i.copyTextureToTexture(le,lt,li),le.reset(),lt.reset(),li.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=sU;t.depth&&(e.depthStencilAttachment.depthLoadOp=sU),t.stencil&&(e.depthStencilAttachment.stencilLoadOp=sU),s.currentPass=i.beginRenderPass(e),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else nF(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()}}var la=r(98786),ln=r(46956);class lo extends la.i{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new K.Q(0xffffff),this.specular=new K.Q(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new K.Q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=g.bI3,this.normalScale=new ej.I(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ln.O,this.combine=g.caT,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}let ll=new lo;class lu extends Q.A{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(ll),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tV(t):null}setupLightingModel(){return new rx}setupVariants(){let e=(this.shininessNode?(0,eu.fVC)(this.shininessNode):tb.uy).max(1e-4);tc.zO.assign(e);let t=this.specularNode||tb.LT;tc.vy.assign(t)}}var lh=r(2520);class ld extends la.i{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new K.Q(0xffffff),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new K.Q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=g.bI3,this.normalScale=new ej.I(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ln.O,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}let lc=new ld;class lp extends Q.A{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(lc),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new t$(t):null}setupLightingModel(){return new rH}
478setupSpecular(){let e=(0,tq.jh)((0,eu.eR5)(.04),tc.YL.rgb,tc.lV);tc.vy.assign((0,eu.eR5)(.04)),tc.pf.assign(e),tc.dX.assign(1)}setupVariants(){let e=this.metalnessNode?(0,eu.fVC)(this.metalnessNode):tb.MT;tc.lV.assign(e);let t=this.roughnessNode?(0,eu.fVC)(this.roughnessNode):tb.s2;t=(0,lh.A)({roughness:t}),tc.nR.assign(t),this.setupSpecular(),tc.v.assign(tc.YL.rgb.mul(e.oneMinus()))}}let lm=lp;class lg extends ld{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ej.I(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return(0,it.qE)(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new K.Q(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new K.Q(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new K.Q(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}let lf=new lg;class ly extends lm{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(lf),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?(0,eu.fVC)(this.iorNode):tb.oO;tc.lq.assign(e),tc.vy.assign((0,tq.jk)((0,tq.zH)(tc.lq.sub(1).div(tc.lq.add(1))).mul(tb.ee),(0,eu.eR5)(1)).mul(tb.ef)),tc.pf.assign((0,tq.jh)(tc.vy,tc.YL.rgb,tc.lV)),tc.dX.assign((0,tq.jh)(tb.ef,1,tc.lV))}setupLightingModel(){return new rH(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){let e=this.clearcoatNode?(0,eu.fVC)(this.clearcoatNode):tb.Qw,t=this.clearcoatRoughnessNode?(0,eu.fVC)(this.clearcoatRoughnessNode):tb.SY;tc.ti.assign(e),tc.v1.assign((0,lh.A)({roughness:t}))}if(this.useSheen){let e=this.sheenNode?(0,eu.eR5)(this.sheenNode):tb.dy,t=this.sheenRoughnessNode?(0,eu.fVC)(this.sheenRoughnessNode):tb.l8;tc.MQ.assign(e),tc.AB.assign(t)}if(this.useIridescence){let e=this.iridescenceNode?(0,eu.fVC)(this.iridescenceNode):tb.wv,t=this.iridescenceIORNode?(0,eu.fVC)(this.iridescenceIORNode):tb.A0,r=this.iridescenceThicknessNode?(0,eu.fVC)(this.iridescenceThicknessNode):tb.c8;tc.tj.assign(e),tc.rS.assign(t),tc.HW.assign(r)}if(this.useAnisotropy){let e=(this.anisotropyNode?(0,eu.ZcS)(this.anisotropyNode):tb.uc).toVar();tc.J_.assign(e.length()),(0,eu.If)(tc.J_.equal(0),()=>{e.assign((0,eu.ZcS)(1,0))}).Else(()=>{e.divAssign((0,eu.ZcS)(tc.J_)),tc.J_.assign(tc.J_.saturate())}),tc.rX.assign(tc.J_.pow2().mix(tc.nR.pow2(),1)),tc.Z1.assign(tz.d$[0].mul(e.x).add(tz.d$[1].mul(e.y))),tc.Lt.assign(tz.d$[1].mul(e.x).sub(tz.d$[0].mul(e.y)))}if(this.useTransmission){let e=this.transmissionNode?(0,eu.fVC)(this.transmissionNode):tb.Ej,t=this.thicknessNode?(0,eu.fVC)(this.thicknessNode):tb.Cp,r=this.attenuationDistanceNode?(0,eu.fVC)(this.attenuationDistanceNode):tb.Nt,i=this.attenuationColorNode?(0,eu.eR5)(this.attenuationColorNode):tb.XY;if(tc.vN.assign(e),tc.Xf.assign(t),tc.ym.assign(r),tc.mr.assign(i),this.useDispersion){let e=this.dispersionNode?(0,eu.fVC)(this.dispersionNode):tb.wg;tc.HG.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?(0,eu.eR5)(this.clearcoatNormalNode):tb.NM}setup(e){e.context.setupClearcoatNormal=()=>(0,tm.T)(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}}let lx=(0,eu.Fn)(({normal:e,lightDirection:t,builder:r})=>
478{let i=e.dot(t),s=(0,eu.ZcS)(i.mul(.5).add(.5),0);if(r.material.gradientMap){let e=(0,tv.z)("gradientMap","texture").context({getUV:()=>s});return(0,eu.eR5)(e.r)}{let e=s.fwidth().mul(.5);return(0,tq.jh)((0,eu.eR5)(.7),(0,eu.eR5)(1),(0,tq.TF)((0,eu.fVC)(.7).sub(e.x),(0,eu.fVC)(.7).add(e.x),s.x))}});class lb extends eF{direct({lightDirection:e,lightColor:t,reflectedLight:r},i){let s=lx({normal:tU.mb,lightDirection:e,builder:i}).mul(t);r.directDiffuse.addAssign(s.mul((0,rg.A)({diffuseColor:tc.YL.rgb})))}indirect(e){let{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul((0,rg.A)({diffuseColor:tc.YL}))),i.indirectDiffuse.mulAssign(t)}}class lv extends la.i{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new K.Q(0xffffff),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new K.Q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=g.bI3,this.normalScale=new ej.I(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}let l_=new lv;class lT extends Q.A{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(l_),this.setValues(e)}setupLightingModel(){return new lb}}let lS=new iu.V;class lA extends Q.A{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lS),this.setValues(e)}setupNormal(){return(0,tR.Mg)(tU.Rv)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tV(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new tL(tb.ex)),t}setupOutgoingLight(){return tc.YL.rgb}setupLightingModel(){return new rp}}class lM extends la.i{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new K.Q(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new K.Q(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=g.bI3,this.normalScale=new ej.I(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ln.O,this.combine=g.caT,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}let lw=new lM;class lR extends Q.A{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(lw),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t?new tV(t):null}setupLightingModel(){return new rx(!1)}}var lN=r(86467);class lC extends la.i{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=g.bI3,this.normalScale=new ej.I(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}let lE=new lC;class lF extends Q.A{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(lE),this.setValues(e)}setupDiffuseColor(){let e=this.opacityNode?(0,eu.fVC)(this.opacityNode):tb.nB;tc.YL.assign((0,tw.Qk)((0,eu.lnd)((0,lN.fv)(tU.j8),e),g.er$))}}var lB=r(45605);
478class lP extends la.i{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new K.Q(0xffffff),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=g.bI3,this.normalScale=new ej.I(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}let lV=new lP;class lL extends Q.A{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(lV),this.setValues(e)}setupVariants(e){let t,r=lB.Y;t=e.material.matcap?(0,tv.z)("matcap","texture").context({getUV:()=>r}):(0,eu.eR5)((0,tq.jh)(.2,.8,r.y)),tc.YL.rgb.mulAssign(t.rgb)}}class lI extends la.i{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new K.Q(0xffffff),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}let lO=new lI;class lD extends Q.A{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(lO),this.setValues(e)}}class lU extends lI{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}let lz=new lU;class lk extends Q.A{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(lz),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){let e=this.offsetNode?(0,eu.fVC)(this.offsetNode):tb.z1,t=this.dashScaleNode?(0,eu.fVC)(this.dashScaleNode):tb.GG,r=this.dashSizeNode?(0,eu.fVC)(this.dashSizeNode):tb.jW,i=this.gapSizeNode?(0,eu.fVC)(this.gapSizeNode):tb.lV;tc.OI.assign(r),tc.cG.assign(i);let s=(0,eu.PCg)((0,eR.l)("lineDistance").mul(t));(e?s.add(e):s).mod(tc.OI.add(tc.cG)).greaterThan(tc.OI).discard()}}var lG=r(50628);class lW extends la.i{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new K.Q(0xffffff),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let l$=new lW,lH=new ej.I;class lj extends lG.A{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(l$),this.setValues(e)}setupPositionView(){let{positionNode:e}=this;return t_.SP.mul((0,eu.eR5)(e||em.po)).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?(0,eu.ZcS)(a):tb.PA;l=l.mul(tC.hG),r.isPerspectiveCamera&&!0===n&&(l=l.mul(lq.div(em.tX.z.negate()))),s&&s.isNode&&(l=l.mul((0,eu.ZcS)(s)));let u=em.WV.xy;if(i&&i.isNode){let e=(0,eu.fVC)(i);u=(0,rd.e)(u,e)}return u=(u=(u=u.mul(l)).div(tC.yT.div(2))).mul(o.w),o=o.add((0,eu.lnd)(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 lq=(0,eu.PiW)(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(lH);this.value=.5*t.y});class lX extends eF{constructor(){super(),this.shadowNode=(0,eu.fVC)(1).toVar("shadowMask")}direct({lightNode:e}){null!==e.shadowNode&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){tc.YL.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(tc.YL.rgb)}}class lK extends la.i{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new K.Q(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}let lY=new lK;class lZ extends Q.A{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(lY),this.setValues(e)}setupLightingModel(){return new lX}}class lQ extends ey.B{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new K.Q(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}let lJ=new eH.k,l0=new $.P,l1=new $.P;class l2{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ej.I(512,512),this.mapType=g.OUM,this.map=null,this.mapPass=null,this.matrix=new eH.k,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new iR,this._frameExtents=new ej.I(1,1),this._viewportCount=1,this._viewports=[new U.I(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,r=this.matrix;l0.setFromMatrixPosition(e.matrixWorld),t.position.copy(l0),l1.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(l1),t.updateMatrixWorld(),lJ.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lJ,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===g.i7u||t.reversedDepth?r.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(lJ)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.n
478ormalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),(512!==this.mapSize.x||512!==this.mapSize.y)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class l3 extends l2{constructor(){super(new ex.u(90,1,.5,500)),this.isPointLightShadow=!0}}class l5 extends lQ{constructor(e,t,r=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=r,this.decay=i,this.shadow=new l3}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}var l6=r(9404);class l4 extends l2{constructor(){super(new l6.q(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class l8 extends lQ{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ey.B.DEFAULT_UP),this.updateMatrix(),this.target=new ey.B,this.shadow=new l4}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class l9 extends lQ{constructor(e,t,r=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=r,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class l7 extends l2{constructor(){super(new ex.u(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){let t=this.camera,r=2*it.a5*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,s=e.distance||t.far;(r!==t.fov||i!==t.aspect||s!==t.far)&&(t.fov=r,t.aspect=i,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class ue extends lQ{constructor(e,t,r=0,i=Math.PI/3,s=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ey.B.DEFAULT_UP),this.updateMatrix(),this.target=new ey.B,this.distance=r,this.angle=i,this.penumbra=s,this.decay=a,this.map=null,this.shadow=new l7}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){let t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class ut extends lQ{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class ur extends lQ{constructor(e,t,r){super(e,r),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(ey.B.DEFAULT_UP),this.updateMatrix(),this.groundColor=new K.Q(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}class ui{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new $.P)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let r=e.x,i=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*i),t.addScaledVector(a[2],.488603*s),t.addScaledVector(a[3],.488603*r),t.addScaledVector(a[4],r*i*1.092548),t.addScaledVector(a[5],i*s*1.092548),t.addScaledVector(a[6],.315392*(3*s*s-1)),t.addScaledVector(a[7],r*s*1.092548),t.addScaledVector(a[8],.546274*(r*r-i*i)),t}getIrradianceAt(e,t){let r=e.x,i=e.y,s=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*i),t.addScaledVector(a[2],1.023328*s),t.addScaledVector(a[3],1.023328*r),t.addScaledVector(a[4],.858086*r*i),t.addScaledVector(a[5],.858086*i*s),t.addScaledVector(a[6],.743125*s*s-.247708),t.addScaledVector(a[7],.858086*r*s),t.addScaledVector(a[8],.429043*(r*r-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let r=0;r<9;r++)this.coefficients[r].addScaledVector(e.coefficients[r],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let r=0;r<9;r++)this.coefficients[r].lerp(e.coefficients[r],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let r=this.coefficients;for(let i=0;i<9;i++)r[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){let r=this.coefficients;for(let i=0;i<9;i++)r[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){let r=e.x,i=e.y,s=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*s,t[3]=.488603*r,t[4]=1.092548*r*i,t[5]=1.092548*i*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*r*s,t[8]=.546274*(r*r-i*i)}}class us extends lQ{constructor(e=new ui,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class ua extends ue{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 un extends ue{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}}var uo=r(66318);class ul extends r5{constructor(){super(),this.addMaterial(lu,"MeshPhongMaterial"),this.addMaterial(lm,"MeshStandardMaterial"),this.addMaterial(ly,"MeshPhysicalMaterial"),this.addMaterial(lT,"MeshToonMaterial"),this.addMaterial(lA,"MeshBasicMaterial"),this.addMaterial(lR,"MeshLambertMaterial"),this.addMaterial(lF,"MeshNormalMaterial"),this.addMaterial(lL,"Me
478shMatcapMaterial"),this.addMaterial(lD,"LineBasicMaterial"),this.addMaterial(lk,"LineDashedMaterial"),this.addMaterial(lj,"PointsMaterial"),this.addMaterial(lG.A,"SpriteMaterial"),this.addMaterial(lZ,"ShadowMaterial"),this.addLight(t2.A,l5),this.addLight(tO,l8),this.addLight(re,l9),this.addLight(tZ,ue),this.addLight(tB,ut),this.addLight(tX,ur),this.addLight(t0,us),this.addLight(tQ,ua),this.addLight(t4,un),this.addToneMapping(uo.yJ,g.kyO),this.addToneMapping(uo.C4,g.Mjd),this.addToneMapping(uo.vR,g.nNL),this.addToneMapping(uo.Vx,g.FV),this.addToneMapping(uo.lr,g.LAk),this.addToneMapping(uo.KD,g.aJ8)}}class uu extends iU{constructor(e={}){let t;e.forceWebGL?t=sR:(t=ls,e.getFallback=()=>((0,T.R8)("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new sR(e))),super(new t(e),e),this.library=new ul,this.isWebGPURenderer=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}let uh=uu},18385:(e,t,r)=>{r.d(t,{TH:()=>g,O:()=>x,qt:()=>b,A$:()=>f,MW:()=>y});var i=r(26609),s=r(96310),a=r(51166),n=r(2945),o=r(51365);let l=function(){let e=new ArrayBuffer(4),t=new Float32Array(e),r=new Uint32Array(e),i=new Uint32Array(512),s=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(i[e]=0,i[256|e]=32768,s[e]=24,s[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,s[e]=-t-1,s[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,s[e]=13,s[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,s[e]=24,s[256|e]=24):(i[e]=31744,i[256|e]=64512,s[e]=13,s[256|e]=13)}let a=new Uint32Array(2048),n=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,r=0;for(;(8388608&t)==0;)t<<=1,r-=8388608;t&=-8388609,r+=0x38800000,a[e]=t|r}for(let e=1024;e<2048;++e)a[e]=0x38000000+(e-1024<<13);for(let e=1;e<31;++e)n[e]=e<<23;n[31]=0x47800000,n[32]=0x80000000;for(let e=33;e<63;++e)n[e]=0x80000000+(e-32<<23);n[63]=0xc7800000;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:r,baseTable:i,shiftTable:s,mantissaTable:a,exponentTable:n,offsetTable:o}}();function u(e){Math.abs(e)>65504&&(0,o.R8)("DataUtils.toHalfFloat(): Value out of range."),e=(0,a.qE)(e,-65504,65504),l.floatView[0]=e;let t=l.uint32View[0],r=t>>23&511;return l.baseTable[r]+((8388607&t)>>l.shiftTable[r])}function h(e){let t=e>>10;return l.uint32View[0]=l.mantissaTable[l.offsetTable[t]+(1023&e)]+l.exponentTable[t],l.floatView[0]}var d=r(83745);let c=new i.P,p=new s.I,m=0;class g extends d.Q{constructor(e,t,r=!1){if(super(),Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:m++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=r,this.usage=n.agE,this.updateRanges=[],this.gpuType=n.RQf,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,s=this.itemSize;i<s;i++)this.array[e+i]=t.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,r=this.count;t<r;t++)p.fromBufferAttribute(this,t),p.applyMatrix3(e),this.setXY(t,p.x,p.y);else if(3===this.itemSize)for(let t=0,r=this.count;t<r;t++)c.fromBufferAttribute(this,t),c.applyMatrix3(e),this.setXYZ(t,c.x,c.y,c.z);return this}applyMatrix4(e){for(let t=0,r=this.count;t<r;t++)c.fromBufferAttribute(this,t),c.applyMatrix4(e),this.setXYZ(t,c.x,c.y,c.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)c.fromBufferAttribute(this,t),c.applyNormalMatrix(e),this.setXYZ(t,c.x,c.y,c.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)c.fromBufferAttribute(this,t),c.transformDirection(e),this.setXYZ(t,c.x,c.y,c.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let r=this.array[e*this.itemSize+t];return this.normalized&&(r=(0,a.NU)(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=(0,a.S8)(r,this.array)),this.array[e*this.itemSize+t]=r,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=(0,a.NU)(t,this.array)),t}setX(e,t){return this.normalized&&(t=(0,a.S8)(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=(0,a.NU)(t,this.array)),t}setY(e,t){return this.normalized&&(t=(0,a.S8)(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=(0,a.NU)(t,this.array)),t}setZ(e,t){return this.normalized&&(t=(0,a.S8)(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=(0,a.NU)(t,this.array)),t}setW(e,t){return this.normalized&&(t=(0,a.S8)(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=(0,a.S8)(t,this.array),r=(0,a.S8)(r,this.array)),this.array[e+0]=t,this.array[e+1]=r,this}setXYZ(e,t,r,i){return e*=this.itemSize,this.normalized&&(t=(0,a.S8)(t,this.array),r=(0,a.S8)(r,this.array),i=(0,a.S8)(i,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e*=this.itemSize,this.normalized&&(t=(0,a.S8)(t,this.array),r=(0,a.S8)(r,this.array),i=(0,a.S8)(i,this.array),s=(0,a.S8)(s,this.array)),this.array[e+0]=t,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=s,this}
478onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==n.agE&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class f extends g{constructor(e,t,r){super(new Uint16Array(e),t,r)}}class y extends g{constructor(e,t,r){super(new Uint32Array(e),t,r)}}class x extends g{constructor(e,t,r){super(new Uint16Array(e),t,r),this.isFloat16BufferAttribute=!0}getX(e){let t=h(this.array[e*this.itemSize]);return this.normalized&&(t=(0,a.NU)(t,this.array)),t}setX(e,t){return this.normalized&&(t=(0,a.S8)(t,this.array)),this.array[e*this.itemSize]=u(t),this}getY(e){let t=h(this.array[e*this.itemSize+1]);return this.normalized&&(t=(0,a.NU)(t,this.array)),t}setY(e,t){return this.normalized&&(t=(0,a.S8)(t,this.array)),this.array[e*this.itemSize+1]=u(t),this}getZ(e){let t=h(this.array[e*this.itemSize+2]);return this.normalized&&(t=(0,a.NU)(t,this.array)),t}setZ(e,t){return this.normalized&&(t=(0,a.S8)(t,this.array)),this.array[e*this.itemSize+2]=u(t),this}getW(e){let t=h(this.array[e*this.itemSize+3]);return this.normalized&&(t=(0,a.NU)(t,this.array)),t}setW(e,t){return this.normalized&&(t=(0,a.S8)(t,this.array)),this.array[e*this.itemSize+3]=u(t),this}setXY(e,t,r){return e*=this.itemSize,this.normalized&&(t=(0,a.S8)(t,this.array),r=(0,a.S8)(r,this.array)),this.array[e+0]=u(t),this.array[e+1]=u(r),this}setXYZ(e,t,r,i){return e*=this.itemSize,this.normalized&&(t=(0,a.S8)(t,this.array),r=(0,a.S8)(r,this.array),i=(0,a.S8)(i,this.array)),this.array[e+0]=u(t),this.array[e+1]=u(r),this.array[e+2]=u(i),this}setXYZW(e,t,r,i,s){return e*=this.itemSize,this.normalized&&(t=(0,a.S8)(t,this.array),r=(0,a.S8)(r,this.array),i=(0,a.S8)(i,this.array),s=(0,a.S8)(s,this.array)),this.array[e+0]=u(t),this.array[e+1]=u(r),this.array[e+2]=u(i),this.array[e+3]=u(s),this}}class b extends g{constructor(e,t,r){super(new Float32Array(e),t,r)}}},19534:(e,t,r)=>{r.d(t,{A:()=>o});var i=r(57218),s=r(79699),a=r(51365);class n extends i.A{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?(0,s.AZ)(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=(0,s.AZ)(this.value),e.nodeType=this.nodeType,"ArrayBuffer"===e.valueType&&(e.value=(0,s.Yi)(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?(0,s.yI)(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,a.R8)("Abstract function.")}}let o=n},19793:(e,t,r)=>{r.d(t,{xI:()=>x,Oc:()=>b,bQ:()=>v});var i=r(19534),s=r(12106),a=r(87954),n=r(26609),o=r(18385),l=r(51166),u=r(51365);let h=new n.P;class d{constructor(e,t,r,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=r,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,r=this.data.count;t<r;t++)h.fromBufferAttribute(this,t),h.applyMatrix4(e),this.setXYZ(t,h.x,h.y,h.z);return this}applyNormalMatrix(e){for(let t=0,r=this.count;t<r;t++)h.fromBufferAttribute(this,t),h.applyNormalMatrix(e),this.setXYZ(t,h.x,h.y,h.z);return this}transformDirection(e){for(let t=0,r=this.count;t<r;t++)h.fromBufferAttribute(this,t),h.transformDirection(e),this.setXYZ(t,h.x,h.y,h.z);return this}getComponent(e,t){let r=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(r=(0,l.NU)(r,this.array)),r}setComponent(e,t,r){return this.normalized&&(r=(0,l.S8)(r,this.array)),this.data.array[e*this.data.stride+this.offset+t]=r,this}setX(e,t){return this.normalized&&(t=(0,l.S8)(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=(0,l.S8)(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=(0,l.S8)(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=(0,l.S8)(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=(0,l.NU)(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=(0,l.NU)(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=(0,l.NU)(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=(0,l.NU)(t,this.array)),t}setXY(e,t,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=(0,l.S8)(t,this.array),r=(0,l.S8)(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this}setXYZ(e,t,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=(0,l.S8)(t,this.array),r=(0,l.S8)(r,this.array),i=(0,l.S8)(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this}setXYZW(e,t,r,i,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=(0,l.S8)(t,this.array),r=(0,l.S8)(r,this.array),i=(0,l.S8)(i,this.array),s=(0,l.S8)(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=s,this}clone(e){if(void 0!==e)return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new d(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized);{(0,u.Rm)("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let t=0;t<this.count;t++){let r=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[r+t])}return new o.TH(new this.array.constructor(e),this.itemSize,this.normalized)}}toJSON(e){if(void 0!==e)return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized};{(0,u.Rm)("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let t=0;t<this.count;t++){let r=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[r+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}}}var c=r(95249),p=r(2945);let m=new WeakMap;function g(e,t){let r=m.get(e);return void 0===r&&(r=new c.e(e,t),m.set(e,r)),r}class f extends i.A{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=p.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,o=new d(t=!0===s.isInterleavedBuffer?s:!0===s.isBufferAttribute?g(s.array,a):g(s,a),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),n=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=s,n=s;else{let i;r&&(i=r+"Varying"),n=(0,a.PC)(this,i).build(e,t)}return n}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 y(e,t=null,r=0,i=0,a=p.agE,n=!1){return"mat3"===t||null===t&&9===e.itemSize?(0,s.w0)(new f(e,"vec3",9,0).setUsage(a).setInstanced(n),new f(e,"vec3",9,3).setUsage(a).setInstanced(n),new f(e,"vec3",9,6).setUsage(a).setInstanced(n)):"mat4"===t||null===t&&16===e.itemSize?(0,s.pB)(new f(e,"vec4",16,0).setUsage(a).setInstanced(n),new f(e,"vec4",16,4).setUsage(a).setInstanced(n),new f(e,"vec4",16,8).setUsage(a).setInstanced(n),new f(e,"vec4",16,12).setUsage(a).setInstanced(n)):new f(e,t,r,i
478).setUsage(a)}let x=(e,t=null,r=0,i=0)=>y(e,t,r,i),b=(e,t=null,r=0,i=0)=>y(e,t,r,i,p.agE,!0),v=(e,t=null,r=0,i=0)=>y(e,t,r,i,p.Vnu,!0);(0,s.mV)("toAttribute",e=>x(e.value))},20407:(e,t,r)=>{r.d(t,{f:()=>n,y:()=>a});var i=r(81951),s=r(12106);let a=(0,s.Fn)(([e])=>{let t=e.mul(.9478672986).add(.0521327014).pow(2.4),r=e.mul(.0773993808),s=e.lessThanEqual(.04045);return(0,i.jh)(t,r,s)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),n=(0,s.Fn)(([e])=>{let t=e.pow(.41666).mul(1.055).sub(.055),r=e.mul(12.92),s=e.lessThanEqual(.0031308);return(0,i.jh)(t,r,s)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]})},21387:(e,t,r)=>{r.d(t,{AB:()=>x,Ay:()=>o,CG:()=>E,HG:()=>D,HW:()=>_,J_:()=>S,Lt:()=>M,MQ:()=>y,MZ:()=>l,OI:()=>F,Xf:()=>L,YL:()=>h,Z1:()=>A,cG:()=>B,dX:()=>N,lV:()=>m,lq:()=>P,mp:()=>u,mr:()=>O,nR:()=>p,pf:()=>R,qM:()=>U,rS:()=>v,rX:()=>T,ti:()=>g,tj:()=>b,v:()=>d,v1:()=>f,vN:()=>V,vy:()=>w,wg:()=>c,ym:()=>I,zO:()=>C});var i=r(57218),s=r(12106),a=r(79699);class n extends i.A{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1,i=null){super(e),this.name=t,this.varying=r,this.placeholderNode=(0,s.mp)(i),this.isPropertyNode=!0,this.global=!0}getNodeType(e){let t=super.getNodeType(e);return"output"===t?e.getOutputType():t}customCacheKey(){return(0,a.YZ)(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 o=n,l=(e,t,r=null)=>new n(e,t,!1,r),u=(e,t,r=null)=>new n(e,t,!0,r),h=(0,s.DS)(n,"vec4","DiffuseColor"),d=(0,s.DS)(n,"vec3","DiffuseContribution"),c=(0,s.DS)(n,"vec3","EmissiveColor"),p=(0,s.DS)(n,"float","Roughness"),m=(0,s.DS)(n,"float","Metalness"),g=(0,s.DS)(n,"float","Clearcoat"),f=(0,s.DS)(n,"float","ClearcoatRoughness"),y=(0,s.DS)(n,"vec3","Sheen"),x=(0,s.DS)(n,"float","SheenRoughness"),b=(0,s.DS)(n,"float","Iridescence"),v=(0,s.DS)(n,"float","IridescenceIOR"),_=(0,s.DS)(n,"float","IridescenceThickness"),T=(0,s.DS)(n,"float","AlphaT"),S=(0,s.DS)(n,"float","Anisotropy"),A=(0,s.DS)(n,"vec3","AnisotropyT"),M=(0,s.DS)(n,"vec3","AnisotropyB"),w=(0,s.DS)(n,"color","SpecularColor"),R=(0,s.DS)(n,"color","SpecularColorBlended"),N=(0,s.DS)(n,"float","SpecularF90"),C=(0,s.DS)(n,"float","Shininess"),E=(0,s.DS)(n,"output","Output"),F=(0,s.DS)(n,"float","dashSize"),B=(0,s.DS)(n,"float","gapSize"),P=(0,s.DS)(n,"float","IOR"),V=(0,s.DS)(n,"float","Transmission"),L=(0,s.DS)(n,"float","Thickness"),I=(0,s.DS)(n,"float","AttenuationDistance"),O=(0,s.DS)(n,"color","AttenuationColor"),D=(0,s.DS)(n,"float","Dispersion"),U=(0,s.DS)(n,"float","AmbientOcclusion",!1,1)},23039:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(83745);class s extends i.Q{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(){}}let a=s},24222:(e,t,r)=>{r.d(t,{i:()=>n});var i=r(30617),s=r(13662);class a extends i.Ay{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=(0,s.eR5)().toVar("directDiffuse"),a=(0,s.eR5)().toVar("directSpecular"),n=(0,s.eR5)().toVar("indirectDiffuse"),o=(0,s.eR5)().toVar("indirectSpecular");return{radiance:(0,s.eR5)().toVar("radiance"),irradiance:(0,s.eR5)().toVar("irradiance"),iblIrradiance:(0,s.eR5)().toVar("iblIrradiance"),ambientOcclusion:(0,s.fVC)(1).toVar("ambientOcclusion"),reflectedLight:{directDiffuse:i,directSpecular:a,indirectDiffuse:n,indirectSpecular:o},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 n=(0,s.Hmo)(a)},24328:(e,t,r)=>{r.d(t,{A:()=>n});var i=r(5092),s=r(51365);class a extends i.A{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),a=this.nodes,n=e.getComponentType(r),o=[],l=0;for(let t of a){let a;if(l>=i){(0,s.z3)(`TSL: Length of parameters exceeds maximum length of function '${r}()' type.`,this.stackTrace);break}let u=t.getNodeType(e),h=e.getTypeLength(u);if(l+h>i&&((0,s.z3)(`TSL: Length of '${r}()' data exceeds maximum length of output type.`,this.stackTrace),h=i-l,u=e.getTypeFromLength(h)),l+=h,a=t.build(e,u),e.getComponentType(u)!==n){let t=e.getTypeFromLength(h,n);a=e.format(a,u,t)}o.push(a)}let u=`${e.getType(r)}( ${o.join(", ")} )`;return e.format(u,r,t)}}let n=a},24481:(e,t,r)=>{r.d(t,{XA:()=>n,h:()=>l,sx:()=>o});var i=r(57218),s=r(83815);class a extends i.A{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}
478update(){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 n=(e,t=0,r=null)=>new a(e,!0,t,r);s.KS.FRAME;let o=n("render",0,s.KS.RENDER),l=((e,t=1,r=null)=>new a(e,!1,t,r))("object",1,s.KS.OBJECT)},24946:(e,t,r)=>{r.d(t,{i:()=>n});var i=r(61806),s=r(18385),a=r(26609);class n extends i.L{constructor(e=1,t=1,r=1,i=1,n=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:n,depthSegments:o};const l=this;i=Math.floor(i),n=Math.floor(n);const u=[],h=[],d=[],c=[];let p=0,m=0;function g(e,t,r,i,s,n,o,g,f,y,x){let b=n/f,v=o/y,_=n/2,T=o/2,S=g/2,A=f+1,M=y+1,w=0,R=0,N=new a.P;for(let a=0;a<M;a++){let n=a*v-T;for(let o=0;o<A;o++){let l=o*b-_;N[e]=l*i,N[t]=n*s,N[r]=S,h.push(N.x,N.y,N.z),N[e]=0,N[t]=0,N[r]=g>0?1:-1,d.push(N.x,N.y,N.z),c.push(o/f),c.push(1-a/y),w+=1}}for(let e=0;e<y;e++)for(let t=0;t<f;t++){let r=p+t+A*e,i=p+t+A*(e+1),s=p+(t+1)+A*(e+1),a=p+(t+1)+A*e;u.push(r,i,a),u.push(i,s,a),R+=6}l.addGroup(m,R,x),m+=R,p+=w}g("z","y","x",-1,-1,r,t,e,o=Math.floor(o),n,0),g("z","y","x",1,-1,r,t,-e,o,n,1),g("x","z","y",1,1,e,r,t,i,o,2),g("x","z","y",1,-1,e,r,-t,i,o,3),g("x","y","z",1,-1,e,t,r,i,n,4),g("x","y","z",-1,-1,e,t,-r,i,n,5),this.setIndex(u),this.setAttribute("position",new s.qt(h,3)),this.setAttribute("normal",new s.qt(d,3)),this.setAttribute("uv",new s.qt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new n(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}},25756:(e,t,r)=>{r.d(t,{I:()=>s});var i=r(51166);class s{static{s.prototype.isVector4=!0}constructor(e=0,t=0,r=0,i=1){this.x=e,this.y=t,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*r+a[11]*i+a[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,i,s,a=e.elements,n=a[0],o=a[4],l=a[8],u=a[
4781],h=a[5],d=a[9],c=a[2],p=a[6],m=a[10];if(.01>Math.abs(o-u)&&.01>Math.abs(l-c)&&.01>Math.abs(d-p)){if(.1>Math.abs(o+u)&&.1>Math.abs(l+c)&&.1>Math.abs(d+p)&&.1>Math.abs(n+h+m-3))return this.set(1,0,0,0),this;t=Math.PI;let e=(n+1)/2,a=(h+1)/2,g=(m+1)/2,f=(o+u)/4,y=(l+c)/4,x=(d+p)/4;return e>a&&e>g?e<.01?(r=0,i=.707106781,s=.707106781):(i=f/(r=Math.sqrt(e)),s=y/r):a>g?a<.01?(r=.707106781,i=0,s=.707106781):(r=f/(i=Math.sqrt(a)),s=x/i):g<.01?(r=.707106781,i=.707106781,s=0):(r=y/(s=Math.sqrt(g)),i=x/s),this.set(r,i,s,t),this}let g=Math.sqrt((p-d)*(p-d)+(l-c)*(l-c)+(u-o)*(u-o));return .001>Math.abs(g)&&(g=1),this.x=(p-d)/g,this.y=(l-c)/g,this.z=(u-o)/g,this.w=Math.acos((n+h+m-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=(0,i.qE)(this.x,e.x,t.x),this.y=(0,i.qE)(this.y,e.y,t.y),this.z=(0,i.qE)(this.z,e.z,t.z),this.w=(0,i.qE)(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=(0,i.qE)(this.x,e,t),this.y=(0,i.qE)(this.y,e,t),this.z=(0,i.qE)(this.z,e,t),this.w=(0,i.qE)(this.w,e,t),this}clampLength(e,t){let r=this.length();return this.divideScalar(r||1).multiplyScalar((0,i.qE)(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}},26609:(e,t,r)=>{r.d(t,{P:()=>a});var i=r(51166),s=r(65415);class a{static{a.prototype.isVector3=!0}constructor(e=0,t=0,r=0){this.x=e,this.y=t,this.z=r}set(e,t,r){return void 0===r&&(r=this.z),this.x=e,this.y=t,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}
vendor: 10,490 bytes, line 478
478sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(o.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(o.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6]*i,this.y=s[1]*t+s[4]*r+s[7]*i,this.z=s[2]*t+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){let t=this.x,r=this.y,i=this.z,s=e.x,a=e.y,n=e.z,o=e.w,l=2*(a*i-n*r),u=2*(n*t-s*i),h=2*(s*r-a*t);return this.x=t+o*l+a*h-n*u,this.y=r+o*u+n*l-s*h,this.z=i+o*h+s*u-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i,this.y=s[1]*t+s[5]*r+s[9]*i,this.z=s[2]*t+s[6]*r+s[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=(0,i.qE)(this.x,e.x,t.x),this.y=(0,i.qE)(this.y,e.y,t.y),this.z=(0,i.qE)(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=(0,i.qE)(this.x,e,t),this.y=(0,i.qE)(this.y,e,t),this.z=(0,i.qE)(this.z,e,t),this}clampLength(e,t){let r=this.length();return this.divideScalar(r||1).multiplyScalar((0,i.qE)(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let r=e.x,i=e.y,s=e.z,a=t.x,n=t.y,o=t.z;return this.x=i*o-s*n,this.y=s*a-r*o,this.z=r*n-i*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return n.copy(this).projectOnVector(e),this.sub(n)}reflect(e){return this.sub(n.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let r=this.dot(e)/t;return Math.acos((0,i.qE)(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,r){let i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=2*Math.random()-1,r=Math.sqrt(1-t*t);return this.x=r*Math.cos(e),this.y=t,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let n=new a,o=new s.P},26719:(e,t,r)=>{r.d(t,{A:()=>n});var i=r(5092),s=r(83815);class a extends i.A{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){let{components:t,sourceNode:r}=this,i=this.getNodeType(e),a=r.build(e),n=e.getVarFromNode(this),o=e.getPropertyName(n);e.addLineFlowCode(o+" = "+a,this);let l=e.getTypeLength(i),u=[],h=0;for(let e=0;e<l;e++){let r=s.Iy[e];r===t[h]?(u.push("1.0 - "+o+"."+r),h++):u.push(o+"."+r)}return`${e.getType(i)}( ${u.join(", ")} )`}}let n=a},26990:(e,t,r)=>{r.d(t,{k:()=>a});var i=r(2945),s=r(26609);class a{static{a.prototype.isMatrix4=!0}constructor(e,t,r,i,s,a,n,o,l,u,h,d,c,p,m,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,r,i,s,a,n,o,l,u,h,d,c,p,m,g)}set(e,t,r,i,s,a,n,o,l,u,h,d,c,p,m,g){let f=this.elements;return f[0]=e,f[4]=t,f[8]=r,f[12]=i,f[1]=s,f[5]=a,f[9]=n,f[13]=o,f[2]=l,f[6]=u,f[10]=h,f[14]=d,f[3]=c,f[7]=p,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new a().fromArray(this.elements)}copy(e){let t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){let t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,r){return 0===this.determinantAffine()?(e.set(1,0,0),t.set(0,1,0),r.set(0,0,1)):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2)),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){if(0===e.determinantAffine())return this.identity();let t=this.elements,r=e.elements,i=1/n.setFromMatrixColumn(e,0).length(),s=1/n.setFromMatrixColumn(e,1).length(),a=1/n.setFromMatrixColumn(e,2).length();return t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=0,t[4]=r[4]*s,t[5]=r[5]*s,t[6]=r[6]*s,t[7]=0,t[8]=r[8]*a,t[9]=r[9]*a,t[10]=r[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,r=e.x,i=e.y,s=e.z,a=Math.cos(r),n=Math.sin(r),o=Math.cos(i),l=Math.sin(i),u=Math.cos(s),h=Math.sin(s);if("XYZ"===e.order){let e=a*u,r=a*h,i=n*u,s=n*h;t[0]=o*u,t[4]=-o*h,t[8]=l,t[1]=r+i*l,t[5]=e-s*l,t[9]=-n*o,t[2]=s-e*l,t[6]=i+r*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*u,r=o*h,i=l*u,s=l*h;t[0]=e+s*n,t[4]=i*n-r,t[8]=a*l,t[1]=a*h,t[5]=a*u,t[9]=-n,t[2]=r*n-i,t[6]=s+e*n,t[10]=a*o}else if("ZXY"===e.order){let e=o*u,r=o*h,i=l*u,s=l*h;t[0]=e-s*n,t[4]=-a*h,t[8]=i+r*n,t[1]=r+i*n,t[5]=a*u,t[9]=s-e*n,t[2]=-a*l,t[6]=n,t[10]=a*o}else if("ZYX"===e.order){let e=a*u,r=a*h,i=n*u,s=n*h;t[0]=o*u,t[4]=i*l-r,t[8]=e*l+s,t[1]=o*h,t[5]=s*l+e,t[9]=r*l-i,t[2]=-l,t[6]=n*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,r=a*l,i=n*o,s=n*l;t[0]=o*u,t[4]=s-e*h,t[8]=i*h+r,t[1]=h,t[5]=a*u,t[9]=-n*u,t[2]=-l*u,t[6]=r*h+i,t[10]=e-s*h}else if("XZY"===e.order){let e=a*o,r=a*l,i=n*o,s=n*l;t[0]=o*u,t[4]=-h,t[8]=l*u,t[1]=e*h+s,t[5]=a*u,t[9]=r*h-i,t[2]=i*h-r,t[6]=n*u,t[10]=s*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(l,e,u)}lookAt(e,t,r){let i=this.elements;return c.subVectors(e,t),0===c.lengthSq()&&(c.z=1),c.normalize(),h.crossVectors(r,c),0===h.lengthSq()&&(1===Math.abs(r.z)?c.x+=1e-4:c.z+=1e-4,c.normalize(),h.crossVectors(r,c)),h.normalize(),d.crossVectors(c,h),i[0]=h.x,i[4]=d.x,i[8]=c.x,i[1]=h.y,i[5]=d.y,i[9]=c.y,i[2]=h.z,i[6]=d.z,i[10]=c.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let r=e.elements,i=t.elements,s=this.elements,a=r[0],n=r[4],o=r[8],l=r[12],u=r[1],h=r[5],d=r[9],c=r[13],p=r[2],m=r[6],g=r[10],f=r[14],y=r[3],x=r[7],b=r[11],v=r[15],_=i[0],T=i[4],S=i[8],A=i[12],M=i[1],w=i[5],R=i[9],N=i[13],C=i[2],E=i[6],F=i[10],B=i[14],P=i[3],V=i[7],L=i[11],I=i[15];return s[0]=a*_+n*M+o*C+l*P,s[4]=a*T+n*w+o*E+l*V,s[8]=a*S+n*R+o*F+l*L,s[12]=a*A+n*N+o*B+l*I,s[1]=u*_+h*M+d*C+c*P,s[5]=u*T+h*w+d*E+c*V,s[9]=u*S+h*R+d*F+c*L,s[13]=u*A+h*N+d*B+c*I,s[2]=p*_+m*M+g*C+f*P,s[6]=p*T+m*w+g*E+f*V,s[10]=p*S+m*R+g*F+f*L,s[14]=p*A+m*N+g*B+f*I,s[3]=y*_+x*M+b*C+v*P,s[7]=y*T+x*w+b*E+v*V,s[11]=y*S+x*R+b*F+v*L,s[15]=y*A+x*N+b*B+v*I,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],r=e[4],i=e[8],s=e[12],a=e[1],n=e[5],o=e[9],l=e[13],u=e[2],h=e[6],d=e[10],c=e[14],p=e[3],m=e[7],g=e[11],f=e[15],y=o*c-l*d,x=n*c-l*h,b=n*d-o*h,v=a*c-l*u,_=a*d-o*u,T=a*h-n*u;return t*(m*y-g*x+f*b)-r*(p*y-g*v+f*_)+i*(p*x-m*v+f*T)-s*(p*b-m*_+g*T)}determinantAffine(){let e=this.elements,t=e[0],r=e[4],i=e[8],s=e[1],a=e[5],n=e[9],o=e[2],l=e[6],u=e[10];
478return t*(a*u-n*l)-r*(s*u-n*o)+i*(s*l-a*o)}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(e,t,r){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=r),this}invert(){let e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],u=e[8],h=e[9],d=e[10],c=e[11],p=e[12],m=e[13],g=e[14],f=e[15],y=t*n-r*a,x=t*o-i*a,b=t*l-s*a,v=r*o-i*n,_=r*l-s*n,T=i*l-s*o,S=u*m-h*p,A=u*g-d*p,M=u*f-c*p,w=h*g-d*m,R=h*f-c*m,N=d*f-c*g,C=y*N-x*R+b*w+v*M-_*A+T*S;if(0===C)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/C;return e[0]=(n*N-o*R+l*w)*E,e[1]=(i*R-r*N-s*w)*E,e[2]=(m*T-g*_+f*v)*E,e[3]=(d*_-h*T-c*v)*E,e[4]=(o*M-a*N-l*A)*E,e[5]=(t*N-i*M+s*A)*E,e[6]=(g*b-p*T-f*x)*E,e[7]=(u*T-d*b+c*x)*E,e[8]=(a*R-n*M+l*S)*E,e[9]=(r*M-t*R-s*S)*E,e[10]=(p*_-m*b+f*y)*E,e[11]=(h*b-u*_-c*y)*E,e[12]=(n*A-a*w-o*S)*E,e[13]=(t*w-r*A+i*S)*E,e[14]=(m*x-p*v-g*y)*E,e[15]=(u*v-h*x+d*y)*E,this}scale(e){let t=this.elements,r=e.x,i=e.y,s=e.z;return t[0]*=r,t[4]*=i,t[8]*=s,t[1]*=r,t[5]*=i,t[9]*=s,t[2]*=r,t[6]*=i,t[10]*=s,t[3]*=r,t[7]*=i,t[11]*=s,this}getMaxScaleOnAxis(){let e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10]))}makeTranslation(e,t,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let r=Math.cos(t),i=Math.sin(t),s=1-r,a=e.x,n=e.y,o=e.z,l=s*a,u=s*n;return this.set(l*a+r,l*n-i*o,l*o+i*n,0,l*n+i*o,u*n+r,u*o-i*a,0,l*o-i*n,u*o+i*a,s*o*o+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,i,s,a){return this.set(1,r,s,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,r){let i=this.elements,s=t._x,a=t._y,n=t._z,o=t._w,l=s+s,u=a+a,h=n+n,d=s*l,c=s*u,p=s*h,m=a*u,g=a*h,f=n*h,y=o*l,x=o*u,b=o*h,v=r.x,_=r.y,T=r.z;return i[0]=(1-(m+f))*v,i[1]=(c+b)*v,i[2]=(p-x)*v,i[3]=0,i[4]=(c-b)*_,i[5]=(1-(d+f))*_,i[6]=(g+y)*_,i[7]=0,i[8]=(p+x)*T,i[9]=(g-y)*T,i[10]=(1-(d+m))*T,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,r){let i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];let s=this.determinantAffine();if(0===s)return r.set(1,1,1),t.identity(),this;let a=n.set(i[0],i[1],i[2]).length(),l=n.set(i[4],i[5],i[6]).length(),u=n.set(i[8],i[9],i[10]).length();s<0&&(a=-a),o.copy(this);let h=1/a,d=1/l,c=1/u;return o.elements[0]*=h,o.elements[1]*=h,o.elements[2]*=h,o.elements[4]*=d,o.elements[5]*=d,o.elements[6]*=d,o.elements[8]*=c,o.elements[9]*=c,o.elements[10]*=c,t.setFromRotationMatrix(o),r.x=a,r.y=l,r.z=u,this}makePerspective(e,t,r,s,a,n,o=i.TdN,l=!1){let u,h,d=this.elements;if(l)u=a/(n-a),h=n*a/(n-a);else if(o===i.TdN)u=-(n+a)/(n-a),h=-2*n*a/(n-a);else if(o===i.i7u)u=-n/(n-a),h=-n*a/(n-a);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return d[0]=2*a/(t-e),d[4]=0,d[8]=(t+e)/(t-e),d[12]=0,d[1]=0,d[5]=2*a/(r-s),d[9]=(r+s)/(r-s),d[13]=0,d[2]=0,d[6]=0,d[10]=u,d[14]=h,d[3]=0,d[7]=0,d[11]=-1,d[15]=0,this}makeOrthographic(e,t,r,s,a,n,o=i.TdN,l=!1){let u,h,d=this.elements;if(l)u=1/(n-a),h=n/(n-a);else if(o===i.TdN)u=-2/(n-a),h=-(n+a)/(n-a);else if(o===i.i7u)u=-1/(n-a),h=-a/(n-a);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return d[0]=2/(t-e),d[4]=0,d[8]=0,d[12]=-(t+e)/(t-e),d[1]=0,d[5]=2/(r-s),d[9]=0,d[13]=-(r+s)/(r-s),d[2]=0,d[6]=0,d[10]=u,d[14]=h,d[3]=0,d[7]=0,d[11]=0,d[15]=1,this}equals(e){let t=this.elements,r=e.elements;for(let e=0;e<16;e++)if(t[e]!==r[e])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){let r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}let n=new s.P,o=new a,l=new s.P(0,0,0),u=new s.P(1,1,1),h=new s.P,d=new s.P,c=new s.P},27240:(e,t,r)=>{r.d(t,{g:()=>p});var i=r(83745),s=r(2945),a=r(51166),n=r(96310),o=r(26609),l=r(79623),u=r(40524),h=r(51365);let d=0,c=new o.P;class p extends i.Q{constructor(e=p.DEFAULT_IMAGE,t=p.DEFAULT_MAPPING,r=s.ghU,i=s.ghU,o=s.k6q,h=s.$_I,
478c=s.GWd,m=s.OUM,g=p.DEFAULT_ANISOTROPY,f=s.jf0){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:d++}),this.uuid=(0,a.lk)(),this.name="",this.source=new u.k(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=o,this.minFilter=h,this.anisotropy=g,this.format=c,this.internalFormat=null,this.type=m,this.offset=new n.I(0,0),this.repeat=new n.I(1,1),this.center=new n.I(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new l.d,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=f,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!e&&!!e.depth&&e.depth>1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(c).x}get height(){return this.source.getSize(c).y}get depth(){return this.source.getSize(c).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let r=e[t];if(void 0===r){(0,h.R8)(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(void 0===i){(0,h.R8)(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[t]=r}}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];let r={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==s.UTZ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case s.GJx:e.x=e.x-Math.floor(e.x);break;case s.ghU:e.x=e.x<0?0:1;break;case s.kTW:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case s.GJx:e.y=e.y-Math.floor(e.y);break;case s.ghU:e.y=e.y<0?0:1;break;case s.kTW:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}p.DEFAULT_IMAGE=null,p.DEFAULT_MAPPING=s.UTZ,p.DEFAULT_ANISOTROPY=1},27300:(e,t,r)=>{r.d(t,{ID:()=>h,Po:()=>m,SP:()=>d,io:()=>p,n6:()=>u});var i=r(58955),s=r(13662),a=r(61114),n=r(75180),o=r(79623);class l extends i.Ay{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}l.DIRECTION;let u=(0,s.DSt)(l,l.WORLD_MATRIX);l.POSITION,l.SCALE,l.VIEW_POSITION,l.RADIUS;let h=(0,a.P)(new o.d).onObjectUpdate(({object:e},t)=>t.value.getNormalMatrix(e.matrixWorld)),d=(0,s.Fn)(e=>e.context.modelViewMatrix||c).once()().toVar("modelViewMatrix"),c=n.S3.mul(u),p=(0,s.Fn)(e=>
478(e.context.isHighPrecisionModelViewMatrix=!0,(0,a.P)("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),m=(0,s.Fn)(e=>{let t=e.context.isHighPrecisionModelViewMatrix;return(0,a.P)("mat3").onObjectUpdate(({object:e,camera:r})=>(!0!==t&&e.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix")},28051:(e,t,r)=>{r.d(t,{Ay:()=>o});var i=r(57218),s=r(12106),a=r(51365);class n extends i.A{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)}generate(e){let{node:t,name:r,readOnly:i}=this,{renderer:s}=e,n=!0===s.backend.isWebGPUBackend,o=!1,l=!1;i&&(o=e.isDeterministic(t),l=n?i:o);let u=this.getNodeType(e);if("void"==u)return!0!==this.isIntent(e)&&(0,a.z3)('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);let h=e.getVectorType(u),d=t.build(e,h),c=e.getVarFromNode(this,r,h,void 0,l),p=e.getPropertyName(c),m=p;if(l)if(n)m=o?`const ${p}`:`let ${p}`;else{let r=t.getArrayCount(e);m=`const ${e.getVar(c.type,p,r)}`}return e.addLineFlowCode(`${m} = ${d}`,this),p}_hasStack(e){return void 0!==e.getDataFromNode(this).stack}}let o=n,l=(0,s.Hm)(n);(0,s.mV)("toVar",(e,t=null)=>l(e,t).toStack()),(0,s.mV)("toConst",(e,t=null)=>l(e,t,!0).toStack()),(0,s.mV)("toVarIntent",e=>l(e).setIntent(!0).toStack())},28350:(e,t,r)=>{var i=r(57218);r(51365),i.A},29210:(e,t,r)=>{r.d(t,{Z:()=>a});var i=r(84774),s=r(46956);class a extends i.B{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new s.O,this.environmentIntensity=1,this.environmentRotation=new s.O,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}},29276:(e,t,r)=>{r(14508).Ay},29335:(e,t,r)=>{var i=r(12106),s=r(78879),a=r(81951);let n={};class o extends a.Ay{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){"int"===r?t.assign((0,s.hH)(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return i.Hd;case"int":return i.Wh;case"uvec2":return i.aq;case"uvec3":return i.VN;case"uvec4":return i.ab;case"ivec2":return i.Ws;case"ivec3":return i.PQ;case"ivec4":return i.I8}}_createTrailingZerosBaseLayout(e,t){let r=this._returnDataNode(t);return(0,i.Fn)(([e])=>{let n=(0,i.Hd)(0);this._resolveElementType(e,n,t);let o=(0,i.fV)(n.bitAnd((0,a.ze)(n)));return r((0,s.YH)(o).shiftRight(23).sub(127))}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){let r=this._returnDataNode(t);return(0,i.Fn)(([e])=>{(0,i.If)(e.equal((0,i.Hd)(0)),()=>(0,i.Hd)(32));let s=(0,i.Hd)(0),a=(0,i.Hd)(0);return this._resolveElementType(e,s,t),(0,i.If)(s.shiftRight(16).equal(0),()=>{a.addAssign(16),s.shiftLeftAssign(16)}),(0,i.If)(s.shiftRight(24).equal(0),()=>{a.addAssign(8),s.shiftLeftAssign(8)}),(0,i.If)(s.shiftRight(28).equal(0),()=>{a.addAssign(4),s.shiftLeftAssign(4)}),(0,i.If)(s.shiftRight(30).equal(0),()=>{a.addAssign(2),s.shiftLeftAssign(2)}),(0,i.If)(s.shiftRight(31).equal(0),()=>{a.addAssign(1)}),r(a)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){let r=this._returnDataNode(t);return(0,i.Fn)(([e])=>{let s=(0,i.Hd)(0);return this._resolveElementType(e,s,t),s.assign(s.sub(s.shiftRight((0,i.Hd)(1)).bitAnd((0,i.Hd)(0x55555555)))),s.assign(s.bitAnd((0,i.Hd)(0x33333333)).add(s.shiftRight((0,i.Hd)(2)).bitAnd((0,i.Hd)(0x33333333)))),r(s.add(s.shiftRight((0,i.Hd)(4))).bitAnd((0,i.Hd)(0xf0f0f0f)).mul((0,i.Hd)(0x1010101)).shiftRight((0,i.Hd)(24)))}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,s){let a=this._returnDataNode(t);return(0,i.Fn)(([e])=>{if(1===r)return a(s(e));{let t=a(0),i=["x","y","z","w"];for(let a=0;a<r;a++){let r=i[a];t[r].assign(s(e[r]))}return t}}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}setup(e){let{method:t,aNode:r}=this,{renderer:s}=e;if(s.backend.isWebGPUBackend)return super.setup(e);let a=this.getInputType(e),l=e.getElementType(a),u=e.getTypeLength(a),h=`${t}_base_${l}`,d=`${t}_${a}`,c=n[h];if(void 0===c){switch(t){case o.COUNT_LEADING_ZEROS:c=this._createLeadingZerosBaseLayout(h,l);break;case o.COUNT_TRAILING_ZEROS:c=this._createTrailingZerosBaseLayout(h,l);break;case o.COUNT_ONE_BITS:c=this._createOneBitsBaseLayout(h,l)}n[h]=c}let p=n[d];return void 0===p&&(p=this._createMainLayout(d,a,u,c),n[d]=p),(0,i.Fn)(()=>p(r))()}}o.COUNT_TRAILING_ZEROS="countTrailingZeros",o.COUNT_LEADING_ZEROS="countLeadingZeros",o.COUNT_ONE_BITS="countOneBits"},29646:(e,t,r)=>{r.d(t,{$:()=>o});var i=r(61114),s=r(83815),a=r(13662);class n extends i.A{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=s.KS.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 o=(0,a.Hmo)(n).setParameterLength(1)},29892:(e,t,r)=>{r.d(t,{Ay:()=>b});var i=r(5092),s=r(40786),a=r(83815),n=r(13662),o=r(61114),l=r(82196),u=r(2945),h=r(96310),d=r(25756),c=r(96201),p=r(40641),m=r(51365);let g=new h.I;class f extends s.Ay{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 y extends f{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 x extends i.A{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;const s=new p.O(this._width,this._height,{type:u.ix0,...i});s.texture.name="output";let n=null;(this.scope===x.DEPTH||!1!==i.depthBuffer)&&((n=new c.V).isRenderTargetTexture=!0,n.name="depth",s.depthTexture=n),this.renderTarget=s,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:s.texture},null!==n&&(this._textures.depth=n),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=(0,o.P)(0),this._cameraFar=(0,o.P)(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=a.KS.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return(0,m.R8)("PassNode: .setResolution() is deprecated. Use .setRe
478solutionScale() instead."),this.setResolutionScale(e)}getResolution(){return(0,m.R8)("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 y(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 y(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=(0,l.Aj)(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=(0,l.Kj)(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===x.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),g.set(s.width,s.height)):(t=this.camera,r.getDrawingBufferSize(g)),this.setSize(g.width,g.height);let a=r.getRenderTarget(),o=r.getMRT(),l=r.autoClear,u=r.transparent,h=r.opaque,d=t.layers.mask,c=r.contextNode,p=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:(0,n._OA)({...r.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),r.contextNode=this._contextNodeCache.context);let m=i.name;i.name=this.name?this.name:i.name,r.render(i,t),i.name=m,i.overrideMaterial=p,r.setRenderTarget(a),r.setMRT(o),r.autoClear=l,r.transparent=u,r.opaque=h,r.contextNode=c,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 d.I),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,i
478))}setViewport(e,t,r,i){null===e?this._viewport=null:(null===this._viewport&&(this._viewport=new d.I),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,i))}dispose(){this.renderTarget.dispose()}}x.COLOR="color",x.DEPTH="depth";let b=x},29950:(e,t,r)=>{var i=r(5092);r(12106),i.A},30573:(e,t,r)=>{r.d(t,{A:()=>o});var i=r(51365),s=r(69707),a=r(21387);class n extends a.Ay{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){let r,a=this.getNodeType(e),n=e.getStructTypeNode(a);return null!==n?r=n.getMemberType(e,t):((0,i.z3)(`TSL: Member "${t}" not found in struct "${a}".`,new s.A),r="float"),r}getHash(){return String(this.id)}generate(){return this.name}}let o=n},30617:(e,t,r)=>{r.d(t,{Ay:()=>o,_O:()=>l});var i=r(57218),s=r(12106),a=r(51365);class n extends i.A{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 o=n,l=(e=null,t={})=>{let r=e;return(null===r||!0!==r.isNode)&&(t=r||t,r=null),new n(r,t)},u=(e,t)=>l(e,{nodeName:t});(0,s.mV)("context",l),(0,s.mV)("label",function(e,t){return(0,a.R8)('TSL: "label()" has been deprecated. Use "setName()" instead.'),u(e,t)}),(0,s.mV)("uniformFlow",e=>l(e,{uniformFlow:!0})),(0,s.mV)("setName",u),(0,s.mV)("builtinShadowContext",(e,t,r)=>(function(e,t,r=null){return l(r,{getShadow:({light:r,shadowColorNode:i})=>t===r?i.mul(e):i})})(t,r,e)),(0,s.mV)("builtinAOContext",(e,t)=>(function(e,t=null){return l(t,{getAO:(t,{material:r})=>!0===r.transparent?t:null!==t?t.mul(e):e})})(t,e))},30710:(e,t,r)=>{r.d(t,{FZ:()=>l,qC:()=>u});var i=r(57218),s=r(4470),a=r(13662),n=r(51365);class o extends i.A{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),a=!0!==t.isNode&&t.type||"int";r[i]=(0,s.d)(i,a)}let i=e.addStack(),n=this.params[this.params.length-1](r);t.returnsNode=n.context({nodeLoop:n}),t.stackNode=i;let o=this.params[0];if(!0!==o.isNode&&"function"==typeof o.update){let e=(0,a.Fn)(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],o=!1,l=null,u=null,h=null,d=null,c=null,p=null;if(a.isNode?"bool"===a.getNodeType(e)?(o=!0,d="bool",u=a.build(e,d)):(d="int",h=this.getVarName(i),l="0",u=a.build(e,d),c="<"):(d=a.type||"int",h=a.name||this.getVarName(i),l=a.start,u=a.end,c=a.condition,p=a.update,"number"==typeof l?l=e.generateConst(d,l):l&&l.isNode&&(l=l.build(e,d)),"number"==typeof u?u=e.generateConst(d,u):u&&u.isNode&&(u=u.build(e,d)),void 0!==l&&void 0===u?(l+=" - 1",u="0",c=">="):void 0!==u&&void 0===l&&(l="0",c="<"),void 0===c&&(c=Number(l)>Number(u)?">=":"<")),o)s=`while ( ${u} )`;else{let r,i=l,a=u,o=()=>c.includes("<")?"+=":"-=";if(null!=p)switch(typeof p){case"function":r=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":r=h+" "+o()+" "+e.generateConst(d,p);break;case"string":r=h+" "+p;break;default:p.isNode?r=h+" "+o()+" "+p.build(e):((0,n.z3)("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),r="break /* invalid update */")}else r=h+" "+(p="int"===d||"uint"===d?c.includes("<")?"++":"--":o()+" 1.");let m=e.getVar(d,h)+" = "+i,g=h+" "+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 l=(...e)=>new o((0,a._jj)(e,"int")).toStack(),u=()=>(0,s.d)("break").toStack()},31450:(e,t,r)=>{r.d(t,{A:()=>m});var i=r(57218),s=r(13662),a=r(79699),n=r(51365);let o=(0,s.MZ5)("vec3","totalDiffuse"),l=(0,s.MZ5)("vec3","totalSpecular"),u=(0,s.MZ5)("vec3","outgoingLight"),h=(e,t)=>{for(let r of t)if(r.isAnalyticLightNode&&r.light.id===e)return r;return null},d=new WeakMap,c=[];class p extends i.A{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=o,this.totalSpecularNode=l,this.outgoingLightNode=u,this._lights=[],this.global=!0}customCacheKey(){let e=this._lights;for(let t=0;t<e.length;t++){let r=e[t];
478if(c.push(r.id),c.push(+!!r.castShadow),!0===r.isSpotLight){let e=null!==r.map?r.map.id:-1,t=r.colorNode?r.colorNode.getCacheKey():-1;c.push(e,t)}}let t=(0,a.g0)(c);return c.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=h(e.id,i)),null===t){let r=a.getLightNodeClass(e.constructor);if(null===r){(0,n.R8)(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}!1===d.has(e)&&d.set(e,new r(e)),t=d.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,a=i.lightingModel,n=e.getNodeProperties(this);if(a){let{totalDiffuseNode:t,totalSpecularNode:o}=this;i.outgoingLight=r,n.nodes=e.addStack().nodes,a.start(e);let{backdrop:l,backdropAlpha:u}=i,{directDiffuse:h,directSpecular:d,indirectDiffuse:c,indirectSpecular:p}=i.reflectedLight,m=h.add(c);null!==l&&(m=null!==u?(0,s.eR5)(u.mix(m,l)):(0,s.eR5)(l)),t.assign(m),o.assign(d.add(p)),r.assign(t.add(o)),a.finish(e),r=r.bypass(e.removeStack())}else n.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}let m=p},33696:(e,t,r)=>{r.d(t,{y:()=>f});var i=r(57218),s=r(53148),a=r(79699),n=r(6293),o=r(19793),l=r(89670),u=r(13662),h=r(25756),d=r(51166),c=r(83965);let p=null,m=null;class g extends i.A{static get type(){return"RangeNode"}constructor(e=(0,u.fVC)(),t=(0,u.fVC)()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){let t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),i=e.getTypeLength((0,a.AZ)(t.value)),s=e.getTypeLength((0,a.AZ)(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 s.A('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),u=i.value,g=s.value,f=e.getTypeLength((0,a.AZ)(u)),y=e.getTypeLength((0,a.AZ)(g));p=p||new h.I,m=m||new h.I,p.setScalar(0),m.setScalar(0),1===f?p.setScalar(u):u.isColor?p.set(u.r,u.g,u.b,1):p.set(u.x,u.y,u.z||0,u.w||0),1===y?m.setScalar(g):g.isColor?m.set(g.r,g.g,g.b,1):m.set(g.x,g.y,g.z||0,g.w||0);let x=4*t.count,b=new Float32Array(x);for(let e=0;e<x;e++){let t=e%4,r=p.getComponent(t),i=m.getComponent(t);b[e]=d.cj.lerp(r,i,Math.random())}let v=this.getNodeType(e);if(4*t.count*4<=e.getUniformBufferLimit())r=(0,n.r)(b,"vec4",t.count).element(l.cG).convert(v);else{let t=new c.u(b,4);e.geometry.setAttribute("__range"+this.id,t),r=(0,o.Oc)(t).convert(v)}}else r=(0,u.fVC)(0);return r}}let f=(0,u.Hmo)(g).setParameterLength(2)},33738:(e,t,r)=>{r.d(t,{JS:()=>n,SZ:()=>a});var i=r(13662),s=r(81951);r(8227),r(40786);let a=(0,i.Fn)(([e])=>(0,i.jcx)((0,i.fVC)(52.9829189).mul((0,i.jcx)((0,i.Omf)(e,(0,i.ZcS)(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),n=(0,i.Fn)(([e,t,r])=>{let a=(0,i.fVC)(2.399963229728653),n=(0,s.RZ)((0,i.fVC)(e).add(.5).div((0,i.fVC)(t))),o=(0,i.fVC)(e).mul(a).add(r);return(0,i.ZcS)((0,i.gnS)(o),(0,i.F8e)(o)).mul(n)}
478).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]})},33962:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(57218);r(13662);class s extends i.A{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 a=s},36850:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(98121),s=r(81951);let a=(0,r(13662).Fn)(({alpha:e,dotNL:t,dotNV:r})=>{let a=e.pow2(),n=t.mul(a.add(a.oneMinus().mul(r.pow2())).sqrt()),o=r.mul(a.add(a.oneMinus().mul(t.pow2())).sqrt());return(0,i.y4)(.5,n.add(o).max(s.p8))}
478).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]})},37537:(e,t,r)=>{var i=r(95538);r(13662),r(96621),r(89723);i.Ay},37600:(e,t,r)=>{r.d(t,{T:()=>n});var i=r(57218),s=r(12106);class a extends i.A{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 n=(e,t,r=null)=>new a((0,s.mp)(e),t,r)},37989:(e,t,r)=>{var i=r(40786),s=r(13662);(0,s.Fn)(({texture:e,uv:t})=>{let r=(0,s.eR5)().toVar();return(0,s.If)(t.x.lessThan(1e-4),()=>{r.assign((0,s.eR5)(1,0,0))}).ElseIf(t.y.lessThan(1e-4),()=>{r.assign((0,s.eR5)(0,1,0))}).ElseIf(t.z.lessThan(1e-4),()=>{r.assign((0,s.eR5)(0,0,1))}).ElseIf(t.x.greaterThan(.9999),()=>{r.assign((0,s.eR5)(-1,0,0))}).ElseIf(t.y.greaterThan(.9999),()=>{r.assign((0,s.eR5)(0,-1,0))}).ElseIf(t.z.greaterThan(.9999),()=>{r.assign((0,s.eR5)(0,0,-1))}).Else(()=>{let i=e.sample(t.add((0,s.eR5)(-.01,0,0))).r.sub(e.sample(t.add((0,s.eR5)(.01,0,0))).r),a=e.sample(t.add((0,s.eR5)(0,-.01,0))).r.sub(e.sample(t.add((0,s.eR5)(0,.01,0))).r),n=e.sample(t.add((0,s.eR5)(0,0,-.01))).r.sub(e.sample(t.add((0,s.eR5)(0,0,.01))).r);r.assign((0,s.eR5)(i,a,n))}),r.normalize()}),i.Ay},38028:(e,t,r)=>{r.d(t,{A:()=>o});var i=r(57218),s=r(83815);let a=s.Iy.join("");class n extends i.A{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(s.Iy.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 n=null;this.getVectorLength()>=i&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));let o=r.build(e,n);s=this.components.length===i&&this.components===a.slice(0,this.components.length)?e.format(o,n,t):e.format(`${o}.${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}}let o=n},38530:(e,t,r)=>{r.d(t,{A:()=>n});var i=r(57218),s=r(51365);class a extends i.A{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,s.R8)(`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 n=a},39106:(e,t,r)=>{var i=r(15907),s=r(57218);r(51365),r(69707),i.A,s.A},39609:(e,t,r)=>{r.d(t,{A:()=>n});var i=r(19534);let s=/float|u?int/;class a extends i.A{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 s.test(r)&&s.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}let n=a},39651:(e,t,r)=>{var i=r(57218),s=r(89670),a=r(69707),n=r(61114),o=r(83815),l=r(12106),u=r(51365);class h extends i.A{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=o.KS.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return(0,u.R8)('TSL: "label()" has been deprecated. Use "setName()" instead.',new a.A),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=(0,n.P)(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=s.cG.build(e,"uint");e.flow.code=`${e.tab}if ( ${r} >= ${t} ) { return; } 479 480${e.flow.code}`}}else{let r=e.getNodeProperties(this).outputComputeNode;if(r)return r.build(e,t)}}}let d=(e,t=[64])=>{(0===t.length||t.length>3)&&(0,u.z3)("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new a.A);for(let e=0;e<t.length;e++){let r=t[e];("number"!=typeof r||r<=0||!Number.isInteger(r))&&(0,u.z3)(`TSL: compute() workgroupSize element at index [ ${e} ] must be a positive integer`,new a.A)}for(;t.length<3;)t.push(1);return new h((0,l.mp)(e),t)};(0,l.mV)("compute",(e,t,r)=>{let i=d(e,r);return"number"==typeof t?i.count=t:i.dispatchSize=t,i}),(0,l.mV)("computeKernel",d)},39848:(e,t,r)=>{r.d(t,{uv:()=>s});var i=r(64994);let s=(e=0)=>(0,i.l)("uv"+(e>0?e:""),"vec2")},40524:(e,t,r)=>{let i;r.d(t,{k:()=>u});var s=r(51365),a=r(68929);class n{static getDataURL(e,t="image/png"){let r;if(/^data:/i.test(e.src)||"undefined"==typeof HTMLCanvasElement)return e.src;if(e instanceof HTMLCanvasElement)r=e;else{void 0===i&&(i=(0,s.qq)("canvas")),i.width=e.width,i.height=e.height;let t=i.getContext("2d");e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),r=i}return r.toDataURL(t)}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let t=(0,s.qq)("canvas");t.width=e.width,t.height=e.height;let r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);let i=r.getImageData(0,0,e.width,e.height),n=i.data;for(let e=0;e<n.length;e++)n[e]=255*(0,a.dk)(n[e]/255);return r.putImageData(i,0,0),t}if(!e.data)return(0,s.R8)("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e;{let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*(0,a.dk)(t[e]/255
480)):t[e]=(0,a.dk)(t[e]);return{data:t,width:e.width,height:e.height}}}}var o=r(51166);let l=0;class u{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:l++}),this.uuid=(0,o.lk)(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return"undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):"undefined"!=typeof VideoFrame&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];let r={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,r=i.length;t<r;t++)i[t].isDataTexture?e.push(h(i[t].image)):e.push(h(i[t]))}else e=h(i);r.url=e}return t||(e.images[this.uuid]=r),r}}function h(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?n.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:((0,s.R8)("Texture: Unable to serialize Texture."),{})}},40641:(e,t,r)=>{r.d(t,{O:()=>l});var i=r(83745),s=r(27240),a=r(2945),n=r(25756),o=r(40524);class l extends i.Q{constructor(e=1,t=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:a.k6q,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},r),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=r.depth,this.scissor=new n.I(0,0,e,t),this.scissorTest=!1,this.viewport=new n.I(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:r.depth},o=new s.g(i),l=r.count;for(let e=0;e<l;e++)this.textures[e]=o.clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview,this.useArrayDepthTexture=r.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:a.k6q,generateMipmaps:!1,flipY:!1,internalFormat:null};void 0!==e.mapping&&(t.mapping=e.mapping),void 0!==e.wrapS&&(t.wrapS=e.wrapS),void 0!==e.wrapT&&(t.wrapT=e.wrapT),void 0!==e.wrapR&&(t.wrapR=e.wrapR),void 0!==e.magFilter&&(t.magFilter=e.magFilter),void 0!==e.minFilter&&(t.minFilter=e.minFilter),void 0!==e.format&&(t.format=e.format),void 0!==e.type&&(t.type=e.type),void 0!==e.anisotropy&&(t.anisotropy=e.anisotropy),void 0!==e.colorSpace&&(t.colorSpace=e.colorSpace),void 0!==e.flipY&&(t.flipY=e.flipY),void 0!==e.generateMipmaps&&(t.generateMipmaps=e.generateMipmaps),void 0!==e.internalFormat&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){null!==this._depthTexture&&(this._depthTexture.renderTarget=null),null!==e&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,r=1){if(this.width!==e||this.height!==t||this.depth!==r){this.width=e,this.height=t,this.depth=r;for(let i=0,s=this.textures.length;i<s;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=r,!0!==this.textures[i].isData3DTexture&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,r=e.textures.length;t<r;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let r=Object.assign({},e.textures[t].image);this.textures[t].source=new o.k(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}},40786:(e,t,r)=>{r.d(t,{Ay:()=>x,cb:()=>_,wH:()=>v});
480var i=r(61114),s=r(39848),a=r(8227),n=r(55398),o=r(4470),l=r(29646),u=r(13662),h=r(81951),d=r(83815),c=r(2945),p=r(27240),m=r(51365),g=r(53148);let f=new p.g;class y extends i.A{static get type(){return"TextureNode"}constructor(e=f,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=d.KS.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===c.bkx?"uvec4":this.value.type===c.Yuy?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return(0,s.uv)(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=(0,i.P)(this.value.matrix)),this._matrixUniform.mul((0,u.eR5)(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(null===this._flipYUniform&&(this._flipYUniform=(0,i.P)(!1)),t=t.toVar(),t=this.sampler?this._flipYUniform.select(t.flipY(),t):this._flipYUniform.select(t.setY((0,u.Whr)((0,a.b)(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 g.A("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);let i=(0,u.Fn)(()=>{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?d.KS.OBJECT:d.KS.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(c.x$Y.TEXTURE_COMPARE))a=this.compareNode;else{let e=r.compareFunction;null===e||e===c.vim||e===c.TiK||e===c.eoi||e===c.gWB?n=this.compareNode:(a=this.compareNode,(0,m.mc)('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,h){let d=this.value;return s?e.generateTextureBias(d,t,r,s,a,u):o?e.generateTextureGrad(d,t,r,o,a,u):l?n?e.generateTextureGatherCompare(d,t,r,n,a,u,h):e.generateTextureGather(d,t,r,l,a,u,h):n?e.generateTextureCompare(d,t,r,n,a,u):!1===this.sampler?e.generateTextureLoad(d,t,r,i,a,u):i?e.generateTextureLevel(d,t,r,i,a,u):e.generateTexture(d,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),l=this.getNodeType(e),u=a.propertyName;if(void 0===u){let{uvNode:t,levelNode:n,biasNode:d,compareNode:p,compareStepNode:m,depthNode:g,gradNode:f,gatherNode:y,offsetNode:x}=i,b=this.generateUV(e,t),v=n?n.build(e,"float"):null,_=d?d.build(e,"float"):null,T=g?g.build(e,"int"):null,S=p?p.build(e,"float"):null,A=m?m.build(e,"float"):null,M=f?[f[0].build(e,"vec2"),f[1].build(e,"vec2")]:null,w=y?y.build(e,"int"):null,R=x?this.generateOffset(e,x):null,N=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;w&&(l="vec4");let C=T;null===C&&r.isArrayTexture&&!0!==this.isTexture3DNode&&(C="0");let E=e.getVarFromNode(this);u=e.getPropertyName(E);let F=this.generateSnippet(e,s,b,v,_,C,S,M,w,R,N);if(null!==A){let t=r.compareFunction;F=t===c.eoi||t===c.gWB?(0,h.PM)((0,o.d)(F,l),(0,o.d)(A,"float")).build(e,l):(0,h.PM)((0,o.d)(A,"float"),(0,o.d)(F,l)).build(e,l)}e.addLineFlowCode(`${u} = ${F}`,this),a.snippet=F,a.propertyName=u}let d=u;
480return e.needsToWorkingColorSpace(r)&&(d=(0,n.Qk)((0,o.d)(d,l),r.colorSpace).setup(e).build(e,l)),e.format(d,l,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){let t=this.clone();return t.uvNode=(0,u.mp$)(e),t.referenceNode=this.getBase(),(0,u.mp$)(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){let t=this.clone();t.biasNode=(0,u.mp$)(e).mul((0,l.$)(t)),t.referenceNode=this.getBase();let r=t.value;return!1===t.generateMipmaps&&(r&&!1===r.generateMipmaps||r.minFilter===c.hxR||r.magFilter===c.hxR)&&((0,m.R8)("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),(0,u.mp$)(t)}level(e){let t=this.clone();return t.levelNode=(0,u.mp$)(e),t.referenceNode=this.getBase(),(0,u.mp$)(t)}size(e){return(0,a.b)(this,e)}bias(e){let t=this.clone();return t.biasNode=(0,u.mp$)(e),t.referenceNode=this.getBase(),(0,u.mp$)(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){let t=this.clone();return t.compareNode=(0,u.mp$)(e),t.referenceNode=this.getBase(),(0,u.mp$)(t)}grad(e,t){let r=this.clone();return r.gradNode=[(0,u.mp$)(e),(0,u.mp$)(t)],r.referenceNode=this.getBase(),(0,u.mp$)(r)}gather(e=0){let t=this.clone();return t.gatherNode=(0,u.mp$)(e),t.referenceNode=this.getBase(),(0,u.mp$)(t)}depth(e){let t=this.clone();return t.depthNode=(0,u.mp$)(e),t.referenceNode=this.getBase(),(0,u.mp$)(t)}offset(e){let t=this.clone();return t.offsetNode=(0,u.mp$)(e),t.referenceNode=this.getBase(),(0,u.mp$)(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 x=y,b=(0,u.Hmo)(y).setParameterLength(1,4).setName("texture"),v=(e=f,t=null,r=null,i=null)=>{let s;return e&&!0===e.isTextureNode?((s=(0,u.mp$)(e.clone())).referenceNode=e.getBase(),null!==t&&(s.uvNode=(0,u.mp$)(t)),null!==r&&(s.levelNode=(0,u.mp$)(r)),null!==i&&(s.biasNode=(0,u.mp$)(i))):s=b(e,t,r,i),s},_=(...e)=>v(...e).setSampler(!1)},41601:(e,t,r)=>{r.d(t,{nR:()=>F});var i=r(56759),s=r(61114),a=r(13662),n=r(14508),o=r(86389),l=r(24481),u=r(26990),h=r(26609),d=r(50782),c=r(2945),p=r(96201);class m extends p.V{constructor(e,t=c.bkx,r=c.hy7,i,s,a=c.hxR,n=c.hxR,o,l=c.zdS){const u={width:e,height:e,depth:1};super(e,e,t,r,i,s,a,n,o,l),this.image=[u,u,u,u,u,u],this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}var g=r(96621),f=r(33738),y=r(81951),x=r(82196);let b=new d.Q,v=new u.k,_=new h.P,T=new h.P,S=[new h.P(1,0,0),new h.P(-1,0,0),new h.P(0,-1,0),new h.P(0,1,0),new h.P(0,0,1),new h.P(0,0,-1)],A=[new h.P(0,-1,0),new h.P(0,-1,0),new h.P(0,0,-1),new h.P(0,0,1),new h.P(0,-1,0),new h.P(0,-1,0)],M=[new h.P(1,0,0),new h.P(-1,0,0),new h.P(0,1,0),new h.P(0,-1,0),new h.P(0,0,1),new h.P(0,0,-1)],w=[new h.P(0,-1,0),new h.P(0,-1,0),new h.P(0,0,1),new h.P(0,0,-1),new h.P(0,-1,0),new h.P(0,-1,0)],R=(0,a.Fn)(({depthTexture:e,bd3D:t,dp:r})=>(0,o.Rz)(e,t).compare(r)),N=(0,a.Fn)(({depthTexture:e,bd3D:t,dp:r,shadow:i})=>{let s=(0,n.ir)("radius","float",i).setGroup(l.sx),u=(0,n.ir)("mapSize","vec2",i).setGroup(l.sx),h=s.div(u.x),d=(0,y.tn)(t),c=(0,y.S8)((0,y.$A)(t,d.x.greaterThan(d.z).select((0,a.eR5)(0,1,0),(0,a.eR5)(1,0,0)))),p=(0,y.$A)(t,c),m=(0,f.SZ)(g.Vj.xy).mul(6.28318530718),x=(0,f.JS)(0,5,m),b=(0,f.JS)(1,5,m),v=(0,f.JS)(2,5,m),_=(0,f.JS)(3,5,m),T=(0,f.JS)(4,5,m);return(0,o.Rz)(e,t.add(c.mul(x.x).add(p.mul(x.y)).mul(h))).compare(r).add((0,o.Rz)(e,t.add(c.mul(b.x).add(p.mul(b.y)).mul(h))).compare(r)).add((0,o.Rz)(e,t.add(c.mul(v.x).add(p.mul(v.y)).mul(h))).compare(r)).add((0,o.Rz)(e,t.add(c.mul(_.x).add(p.mul(_.y)).mul(h))).compare(r)).add((0,o.Rz)(e,t.add(c.mul(T.x).add(p.mul(T.y)).mul(h))).compare(r)).mul(.2)}),C=(0,a.Fn)(({filterFn:e,depthTexture:t,shadowCoord:r,shadow:i},o)=>{let u=r.xyz.toConst(),h=u.abs().toConst(),d=h.x.max(h.y).max(h.z),c=(0,s.P)("float").setGroup(l.sx).onRenderUpd
480ate(()=>i.camera.near),p=(0,s.P)("float").setGroup(l.sx).onRenderUpdate(()=>i.camera.far),m=(0,n.ir)("bias","float",i).setGroup(l.sx),g=(0,a.fVC)(1).toVar();return(0,a.If)(d.sub(p).lessThanEqual(0).and(d.sub(c).greaterThanEqual(0)),()=>{let r;o.renderer.reversedDepthBuffer?(r=(0,x.gY)(d.negate(),c,p)).subAssign(m):o.renderer.logarithmicDepthBuffer?(r=(0,x.Ps)(d.negate(),c,p)).addAssign(m):(r=(0,x.ae)(d.negate(),c,p)).addAssign(m);let s=u.normalize();g.assign(e({depthTexture:t,bd3D:s,dp:r,shadow:i}))}),g});class E extends i.Ay{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===c.bTm?R:N}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:i,shadow:s}){return C({filterFn:t,depthTexture:r,shadowCoord:i,shadow:s})}setupRenderTarget(e,t){let r=new m(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?c.gWB:c.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===c.i7u,u=l?S:M,h=l?A:w;r.setSize(t.mapSize.width,t.mapSize.width);let d=s.autoClear,p=s.getClearColor(b),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()),_.setFromMatrixPosition(i.matrixWorld),n.position.copy(_),T.copy(n.position),T.add(u[e]),n.up.copy(h[e]),n.lookAt(T),n.updateMatrixWorld(),o.makeTranslation(-_.x,-_.y,-_.z),v.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),t._frustum.setFromProjectionMatrix(v,n.coordinateSystem,n.reversedDepth);let d=a.name;a.name=`Point Light Shadow [ ${i.name||"ID: "+i.id} ] - Face ${e+1}`,s.render(a,n),a.name=d}s.autoClear=d,s.setClearColor(p,m)}}let F=(e,t)=>new E(e,t)},44063:(e,t,r)=>{r.d(t,{Z:()=>l});var i=r(79623),s=r(26609);let a=new s.P,n=new s.P,o=new i.d;class l{constructor(e=new s.P(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,i){return this.normal.set(e,t,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){let i=a.subVectors(r,t).cross(n.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,r=!0){let i=e.delta(a),s=this.normal.dot(i);if(0===s)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let n=-(e.start.dot(this.normal)+this.constant)/s;return!0===r&&(n<0||n>1)?null:t.copy(e.start).addScaledVector(i,n)}intersectsLine(e){let t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let r=t||o.getNormalMatrix(e),i=this.coplanarPoint(a).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}},44268:(e,t,r)=>{r.d(t,{e:()=>m});var i=r(13662),s=r(64994),a=r(80904),n=r(74872),o=r(61296),l=r(71440),u=r(14508),h=r(6293);r(8926),r(89670);let d=new WeakMap,c=new WeakMap;function p(e,t,r,s,a,n){let o=e.element(a.x),l=e.element(a.y),u=e.element(a.z),h=e.element(a.w),d=r.mul(t),c=(0,i.WQq)(o.mul(n.x).mul(d),l.mul(n.y).mul(d),u.mul(n.z).mul(d),h.mul(n.w).mul(d));return s.mul(c).xyz}let m=(0,i.Fn)(([e],t)=>{let r=(0,s.l)("skinIndex","uvec4"),m=(0,s.l)("skinWeight","vec4"),g=(0,u.ir)("bindMatrix","mat4"),f=(0,u.ir)("bindMatrixInverse","mat4"),y=(0,u.qY)("skeleton.boneMatrices","mat4",e.skeleton.bones.length);if((0,a.ow)(({object:e,frameId:t})=>{let r=e.skeleton;if(d.get(r)!==t){d.set(r,t);let e=c.get(r);void 0!==e&&e.previousBoneMatrices.set(r.boneMatrices),r.update(
480)}}),t.needsPreviousData()){let t=function(e,t,r,i,s){let a=e.skeleton,n=c.get(a);if(void 0===n){a.update();let e=new Float32Array(a.boneMatrices);n={previousBoneMatrices:e,node:(0,h.r)(e,"mat4",a.bones.length)},c.set(a,n)}return p(n.node,o.DW,t,r,i,s)}(e,g,f,r,m);o.DW.assign(t)}let x=p(y,o.po,g,f,r,m);if(o.po.assign(x),t.hasGeometryAttribute("normal")){var b,v;let e,s,a,o,u,{skinNormal:h,skinTangent:d}=(b=n.xg,v=l.d8,e=y.element(r.x),s=y.element(r.y),a=y.element(r.z),o=y.element(r.w),u=(0,i.WQq)(m.x.mul(e),m.y.mul(s),m.z.mul(a),m.w.mul(o)),{skinNormal:(u=f.mul(u).mul(g)).transformDirection(b).xyz,skinTangent:u.transformDirection(v).xyz});n.xg.assign(h),t.hasGeometryAttribute("tangent")&&l.d8.assign(d)}},"void")},44342:(e,t,r)=>{r.d(t,{A0:()=>I,CO:()=>Y,Cp:()=>U,Dc:()=>R,Ej:()=>D,GG:()=>W,HM:()=>f,LT:()=>v,MT:()=>w,NM:()=>E,Nt:()=>k,O3:()=>F,O_:()=>S,Oe:()=>g,PA:()=>q,Qw:()=>N,SY:()=>C,XY:()=>G,c8:()=>O,dy:()=>B,ee:()=>T,ef:()=>_,ex:()=>K,jW:()=>$,l8:()=>P,lV:()=>H,nB:()=>b,oO:()=>z,s2:()=>M,uc:()=>V,uy:()=>y,vK:()=>x,wg:()=>X,wk:()=>A,wv:()=>L,z1:()=>j});var i=r(57218),s=r(14508),a=r(90083),n=r(74872),o=r(13662),l=r(61114),u=r(5032),h=r(66133),d=r(96310),c=r(2945);let p=new Map;class m extends i.A{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=p.get(e);return void 0===r&&(r=(0,a.z)(e,t),p.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===m.COLOR){let e=void 0!==t.color?this.getColor(r):(0,o.eR5)();i=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(r===m.OPACITY){let e=this.getFloat(r);i=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(r===m.SPECULAR_STRENGTH)i=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:(0,o.fVC)(1);else if(r===m.SPECULAR_INTENSITY){let e=this.getFloat(r);i=t.specularIntensityMap&&!0===t.specularIntensityMap.isTexture?e.mul(this.getTexture(r).a):e}else if(r===m.SPECULAR_COLOR){let e=this.getColor(r);i=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(r).rgb):e}else if(r===m.ROUGHNESS){let e=this.getFloat(r);i=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(r).g):e}else if(r===m.METALNESS){let e=this.getFloat(r);i=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(r).b):e}else if(r===m.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===m.NORMAL)t.normalMap?((i=(0,u.Q)(this.getTexture("normal"),this.getCache("normalScale","vec2"))).normalMapType=t.normalMapType,(t.normalMap.format==c.paN||t.normalMap.format==c.HO_||t.normalMap.format==c.OtU)&&(i.unpackNormalMode=c.IjV)):i=t.bumpMap?(0,h.F)(this.getTexture("bump").r,this.getFloat("bumpScale")):n.j8;else if(r===m.CLEARCOAT){let e=this.getFloat(r);i=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===m.CLEARCOAT_ROUGHNESS){let e=this.getFloat(r);i=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(r).r):e}else if(r===m.CLEARCOAT_NORMAL)i=t.clearcoatNormalMap?(0,u.Q)(this.getTexture(r),this.getCache(r+"Scale","vec2")):n.j8;else if(r===m.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===m.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===m.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){let e=this.getTexture(r);i=(0,o.pmN)(Z.x,Z.y,Z.y.negate(),Z.x).mul(e.rg.mul(2).sub((0,o.ZcS)(1)).normalize().mul(e.b))}else i=Z;else if(r===m.IRIDESCENCE_THICKNESS){let e=(0,s.ir)("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){let a=(0,s.ir)("0","float",t.iridescenceThicknessRange);
480i=e.sub(a).mul(this.getTexture(r).g).add(a)}else i=e}else if(r===m.TRANSMISSION){let e=this.getFloat(r);i=t.transmissionMap?e.mul(this.getTexture(r).r):e}else if(r===m.THICKNESS){let e=this.getFloat(r);i=t.thicknessMap?e.mul(this.getTexture(r).g):e}else if(r===m.IOR)i=this.getFloat(r);else if(r===m.LIGHT_MAP)i=t.lightMap?this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity")):(0,o.eR5)(0);else if(r===m.AO)i=t.aoMap?this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1):(0,o.fVC)(1);else if(r===m.LINE_DASH_OFFSET)i=t.dashOffset?this.getFloat(r):(0,o.fVC)(0);else{let t=this.getNodeType(e);i=this.getCache(r,t)}return i}}m.ALPHA_TEST="alphaTest",m.COLOR="color",m.OPACITY="opacity",m.SHININESS="shininess",m.SPECULAR="specular",m.SPECULAR_STRENGTH="specularStrength",m.SPECULAR_INTENSITY="specularIntensity",m.SPECULAR_COLOR="specularColor",m.REFLECTIVITY="reflectivity",m.ROUGHNESS="roughness",m.METALNESS="metalness",m.NORMAL="normal",m.CLEARCOAT="clearcoat",m.CLEARCOAT_ROUGHNESS="clearcoatRoughness",m.CLEARCOAT_NORMAL="clearcoatNormal",m.EMISSIVE="emissive",m.ROTATION="rotation",m.SHEEN="sheen",m.SHEEN_ROUGHNESS="sheenRoughness",m.ANISOTROPY="anisotropy",m.IRIDESCENCE="iridescence",m.IRIDESCENCE_IOR="iridescenceIOR",m.IRIDESCENCE_THICKNESS="iridescenceThickness",m.IOR="ior",m.TRANSMISSION="transmission",m.THICKNESS="thickness",m.ATTENUATION_DISTANCE="attenuationDistance",m.ATTENUATION_COLOR="attenuationColor",m.LINE_SCALE="scale",m.LINE_DASH_SIZE="dashSize",m.LINE_GAP_SIZE="gapSize",m.LINE_WIDTH="linewidth",m.LINE_DASH_OFFSET="dashOffset",m.POINT_SIZE="size",m.DISPERSION="dispersion",m.LIGHT_MAP="light",m.AO="ao";let g=(0,o.DSt)(m,m.ALPHA_TEST),f=(0,o.DSt)(m,m.COLOR),y=(0,o.DSt)(m,m.SHININESS),x=(0,o.DSt)(m,m.EMISSIVE),b=(0,o.DSt)(m,m.OPACITY),v=(0,o.DSt)(m,m.SPECULAR),_=(0,o.DSt)(m,m.SPECULAR_INTENSITY),T=(0,o.DSt)(m,m.SPECULAR_COLOR),S=(0,o.DSt)(m,m.SPECULAR_STRENGTH),A=(0,o.DSt)(m,m.REFLECTIVITY),M=(0,o.DSt)(m,m.ROUGHNESS),w=(0,o.DSt)(m,m.METALNESS),R=(0,o.DSt)(m,m.NORMAL),N=(0,o.DSt)(m,m.CLEARCOAT),C=(0,o.DSt)(m,m.CLEARCOAT_ROUGHNESS),E=(0,o.DSt)(m,m.CLEARCOAT_NORMAL),F=(0,o.DSt)(m,m.ROTATION),B=(0,o.DSt)(m,m.SHEEN),P=(0,o.DSt)(m,m.SHEEN_ROUGHNESS),V=(0,o.DSt)(m,m.ANISOTROPY),L=(0,o.DSt)(m,m.IRIDESCENCE),I=(0,o.DSt)(m,m.IRIDESCENCE_IOR),O=(0,o.DSt)(m,m.IRIDESCENCE_THICKNESS),D=(0,o.DSt)(m,m.TRANSMISSION),U=(0,o.DSt)(m,m.THICKNESS),z=(0,o.DSt)(m,m.IOR),k=(0,o.DSt)(m,m.ATTENUATION_DISTANCE),G=(0,o.DSt)(m,m.ATTENUATION_COLOR),W=(0,o.DSt)(m,m.LINE_SCALE),$=(0,o.DSt)(m,m.LINE_DASH_SIZE),H=(0,o.DSt)(m,m.LINE_GAP_SIZE);m.LINE_WIDTH;let j=(0,o.DSt)(m,m.LINE_DASH_OFFSET),q=(0,o.DSt)(m,m.POINT_SIZE),X=(0,o.DSt)(m,m.DISPERSION),K=(0,o.DSt)(m,m.LIGHT_MAP),Y=(0,o.DSt)(m,m.AO),Z=(0,l.P)(new d.I).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))})},45192:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(74872),s=r(13662);let a=(0,s.Fn)(e=>{if(!1===e.geometry.hasAttribute("normal"))return(0,s.fVC)(0);let t=i.Rv.dFdx().abs().max(i.Rv.dFdy().abs());return t.x.max(t.y).max(t.z)})},45605:(e,t,r)=>{r.d(t,{Y:()=>n});var i=r(74872),s=r(61296),a=r(13662);let n=(0,a.Fn)(()=>{let e=(0,a.eR5)(s.Mv.z,0,s.Mv.x.negate()).normalize(),t=s.Mv.cross(e);return(0,a.ZcS)(e.dot(i.j8),t.dot(i.j8)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV")},45622:(e,t,r)=>{r.d(t,{A:()=>u});var i=r(13662),s=r(40786),a=r(53104),n=r(2945);let o=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,10
480751,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,14942,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]),l=null,u=(0,i.Fn)(({roughness:e,dotNV:t})=>{null===l&&((l=new a.G(o,16,16,n.paN,n.ix0)).name="DFG_LUT",l.minFilter=n.k6q,l.magFilter=n.k6q,l.wrapS=n.ghU,l.wrapT=n.ghU,l.generateMipmaps=!1,l.needsUpdate=!0);let r=(0,i.ZcS)(e,t);return(0,s.wH)(l,r).rg})},46362:(e,t,r)=>{r.d(t,{BK:()=>F,Ge:()=>R,u6:()=>S,w6:()=>A});var i=r(13662),s=r(81951),a=r(98121),n=r(71115),o=r(30710);let l=(0,i.fVC)(1),u=(0,i.fVC)(-2),h=(0,i.fVC)(.8),d=(0,i.fVC)(-1),c=(0,i.fVC)(.4),p=(0,i.fVC)(2),m=(0,i.fVC)(.305),g=(0,i.fVC)(3),f=(0,i.fVC)(.21),y=(0,i.fVC)(4),x=(0,i.fVC)(4),b=(0,i.fVC)(16),v=(0,i.Fn)(([e])=>{let t=(0,i.eR5)((0,s.tn)(e)).toVar(),r=(0,i.fVC)(-1).toVar();return(0,i.If)(t.x.greaterThan(t.z),()=>{(0,i.If)(t.x.greaterThan(t.y),()=>{r.assign((0,n.L)(e.x.greaterThan(0),0,3))}).Else(()=>{r.assign((0,n.L)(e.y.greaterThan(0),1,4))})}).Else(()=>{(0,i.If)(t.z.greaterThan(t.y),()=>{r.assign((0,n.L)(e.z.greaterThan(0),2,5))}).Else(()=>{r.assign((0,n.L)(e.y.greaterThan(0),1,4))})}),r}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),_=(0,i.Fn)(([e,t])=>{let r=(0,i.ZcS)().toVar();return(0,i.If)(t.equal(0),()=>{r.assign((0,i.ZcS)(e.z,e.y).div((0,s.tn)(e.x)))}).ElseIf(t.equal(1),()=>{r.assign((0,i.ZcS)(e.x.negate(),e.z.negate()).div((0,s.tn)(e.y)))}).ElseIf(t.equal(2),()=>{r.assign((0,i.ZcS)(e.x.negate(),e.y).div((0,s.tn)(e.z)))}).ElseIf(t.equal(3),()=>{r.assign((0,i.ZcS)(e.z.negate(),e.y).div((0,s.tn)(e.x)))}).ElseIf(t.equal(4),()=>{r.assign((0,i.ZcS)(e.x.negate(),e.z).div((0,s.tn)(e.y)))}).Else(()=>{r.assign((0,i.ZcS)(e.x,e.y).div((0,s.tn)(e.z)))}),(0,a.lK)(.5,r.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),T=(0,i.Fn)(([e])=>{let t=(0,i.fVC)(0).toVar();return(0,i.If)(e.greaterThanEqual(h),()=>{t.assign(l.sub(e).mul(d.sub(u)).div(l.sub(h)).add(u))}).ElseIf(e.greaterThanEqual(c),()=>{t.assign(h.sub(e).mul(p.sub(d)).div(h.sub(c)).add(d))}).ElseIf(e.greaterThanEqual(m),()=>{t.assign(c.sub(e).mul(g.sub(p)).div(c.sub(m)).add(p))}).ElseIf(e.greaterThanEqual(f),()=>{t.assign(m.sub(e).mul(y.sub(g)).div(m.sub(f)).add(g))}).Else(()=>{t.assign((0,i.fVC)(-2).mul((0,s.p6)((0,a.lK)(1.16,e))))}),t}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),S=(0,i.Fn)(([e,t])=>{let r=e.toVar();r.assign((0,a.lK)(2,r).sub(1));let s=(0,i.eR5)(r,1).toVar();return(0,i.If)(t.equal(0),()=>{s.assign(s.zyx)}).ElseIf(t.equal(1),()=>{s.assign(s.xzy),s.xz.mulAssign(-1)}).ElseIf(t.equal(2),()=>{s.x.mulAssign(-1)}
480).ElseIf(t.equal(3),()=>{s.assign(s.zyx),s.xz.mulAssign(-1)}).ElseIf(t.equal(4),()=>{s.assign(s.xzy),s.xy.mulAssign(-1)}).ElseIf(t.equal(5),()=>{s.z.mulAssign(-1)}),s}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),A=(0,i.Fn)(([e,t,r,a,n,o])=>{let l=(0,i.fVC)(r),h=(0,i.eR5)(t),d=(0,s.qE)(T(l),u,o),c=(0,s.jc)(d),p=(0,s.RI)(d),m=(0,i.eR5)(M(e,h,p,a,n,o)).toVar();return(0,i.If)(c.notEqual(0),()=>{let t=(0,i.eR5)(M(e,h,p.add(1),a,n,o)).toVar();m.assign((0,s.jh)(m,t,c))}),m}),M=(0,i.Fn)(([e,t,r,n,o,l])=>{let u=(0,i.fVC)(r).toVar(),h=(0,i.eR5)(t),d=(0,i.fVC)(v(h)).toVar(),c=(0,i.fVC)((0,s.T9)(x.sub(u),0)).toVar();u.assign((0,s.T9)(u,x));let p=(0,i.fVC)((0,s.Ie)(u)).toVar(),m=(0,i.ZcS)(_(h,d).mul(p.sub(2)).add(1)).toVar();return(0,i.If)(d.greaterThan(2),()=>{m.y.addAssign(p),d.subAssign(3)}),m.x.addAssign(d.mul(p)),m.x.addAssign(c.mul((0,a.lK)(3,b))),m.y.addAssign((0,a.lK)(4,(0,s.Ie)(l).sub(p))),m.x.mulAssign(n),m.y.mulAssign(o),e.sample(m).grad((0,i.ZcS)(),(0,i.ZcS)())}),w=(0,i.Fn)(({envMap:e,mipInt:t,outputDirection:r,theta:i,axis:a,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:l})=>{let u=(0,s.gn)(i);return M(e,r.mul(u).add(a.cross(r).mul((0,s.F8)(i))).add(a.mul(a.dot(r).mul(u.oneMinus()))),t,n,o,l)}),R=(0,i.Fn)(({n:e,latitudinal:t,poleAxis:r,outputDirection:a,weights:l,samples:u,dTheta:h,mipInt:d,envMap:c,CUBEUV_TEXEL_WIDTH:p,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:g})=>{let f=(0,i.eR5)((0,n.L)(t,r,(0,s.$A)(r,a))).toVar();(0,i.If)(f.equal((0,i.eR5)(0)),()=>{f.assign((0,i.eR5)(a.z,0,a.x.negate()))}),f.assign((0,s.S8)(f));let y=(0,i.eR5)().toVar();return y.addAssign(l.element(0).mul(w({theta:0,axis:f,outputDirection:a,mipInt:d,envMap:c,CUBEUV_TEXEL_WIDTH:p,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:g}))),(0,o.FZ)({start:(0,i.Whr)(1),end:e},({i:e})=>{(0,i.If)(e.greaterThanEqual(u),()=>{(0,o.qC)()});let t=(0,i.fVC)(h.mul((0,i.fVC)(e))).toVar();y.addAssign(l.element(e).mul(w({theta:t.mul(-1),axis:f,outputDirection:a,mipInt:d,envMap:c,CUBEUV_TEXEL_WIDTH:p,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:g}))),y.addAssign(l.element(e).mul(w({theta:t,axis:f,outputDirection:a,mipInt:d,envMap:c,CUBEUV_TEXEL_WIDTH:p,CUBEUV_TEXEL_HEIGHT:m,CUBEUV_MAX_MIP:g})))}),(0,i.lnd)(y,1)}),N=(0,i.Fn)(([e])=>{let t=(0,i.Hdr)(e).toVar();return t.assign(t.shiftLeft((0,i.Hdr)(16)).bitOr(t.shiftRight((0,i.Hdr)(16)))),t.assign(t.bitAnd((0,i.Hdr)(0x55555555)).shiftLeft((0,i.Hdr)(1)).bitOr(t.bitAnd((0,i.Hdr)(0xaaaaaaaa)).shiftRight((0,i.Hdr)(1)))),t.assign(t.bitAnd((0,i.Hdr)(0x33333333)).shiftLeft((0,i.Hdr)(2)).bitOr(t.bitAnd((0,i.Hdr)(0xcccccccc)).shiftRight((0,i.Hdr)(2)))),t.assign(t.bitAnd((0,i.Hdr)(0xf0f0f0f)).shiftLeft((0,i.Hdr)(4)).bitOr(t.bitAnd((0,i.Hdr)(0xf0f0f0f0)).shiftRight((0,i.Hdr)(4)))),t.assign(t.bitAnd((0,i.Hdr)(0xff00ff)).shiftLeft((0,i.Hdr)(8)).bitOr(t.bitAnd((0,i.Hdr)(0xff00ff00)).shiftRight((0,i.Hdr)(8)))),(0,i.fVC)(t).mul(23283064365386963e-26)}),C=(0,i.Fn)(([e,t])=>(0,i.ZcS)((0,i.fVC)(e).div((0,i.fVC)(t)),N(e))),E=(0,i.Fn)(([e,t,r])=>{let n=r.mul(r).toConst(),o=(0,i.eR5)(1,0,0).toConst(),l=(0,s.$A)(t,o).toConst(),u=(0,s.RZ)(e.x).toConst(),h=(0,a.lK)(2,3.14159265359).mul(e.y).toConst(),d=u.mul((0,s.gn)(h)).toConst(),c=u.mul((0,s.F8)(h)).toVar(),p=(0,a.lK)(.5,t.z.add(1)).toConst();c.assign(p.oneMinus().mul((0,s.RZ)(d.mul(d).oneMinus())).add(p.mul(c)));let m=o.mul(d).add(l.mul(c)).add(t.mul((0,s.RZ)((0,s.T9)(0,d.mul(d).add(c.mul(c)).oneMinus()))));return(0,s.S8)((0,i.eR5)(n.mul(m.x),n.mul(m.y),(0,s.T9)(0,m.z)))}),F=(0,i.Fn)(({roughness:e,mipInt:t,envMap:r,N_immutable:a,GGX_SAMPLES:l,CUBEUV_TEXEL_WIDTH:u,CUBEUV_TEXEL_HEIGHT:h,CUBEUV_MAX_MIP:d})=>{let c=(0,i.eR5)(a).toVar(),p=(0,i.eR5)(0).toVar(),m=(0,i.fVC)(0).toVar();return(0,i.If)(e.lessThan(.001),()=>{p.assign(M(r,c,t,u,h,d))}).Else(()=>{let a=(0,n.L)((0,s.tn)(c.z).lessThan(.999),(0,i.eR5)(0,0,1),(0,i.eR5)(1,0,0)),g=(0,s.S8)((0,s.$A)(a,c)).toVar(),f=(0,s.$A)(c,g).toVar();(0,o.FZ)({start:(0,i.Hdr)(0),end:l},({i:a})=>{let n=E(C(a,l),(0,i.eR5)(0,0,1),e),o=(0,s.S8)(g.mul(n.x).add(f.mul(n.y)).add(c.mul(n.z))),y=(0,s.S8)(o.mul((0,s.Om)(c,o).mul(2)).sub(c)),x=(0,s.T9)((0,s.Om)(c,y),0);(0,i.If)(x.greaterThan(0),()=>{let e=M(r,y,t,u,h,d);p.addAssign(e.mul(x)),m.addAssign(x)})}),(0,i.If)(m.greaterThan(0),()=>{p.assign(p.div(m))})}),(0,i.lnd)(p,1)})},46537:(e,t,r)=>{r.d(t,{di:()=>m,l5:()=>g,zE:()=>p});var i=r(57218),s=r(13662),a=r(61296),n=r(21387),o=r(30710),l=r(81951),u=r(61046),h=r(96798),d=r(24481);class c extends i.A{static get type(){return"ClippingNode"}constructor(e=c.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);let{intersectionPlanes:t,unionPlanes:r}=e.clippingContext;return(this.hardwareClipping=e.hardwareClipping,this.scope===c.ALPHA_TO_COVERAGE)?this.setupAlphaToCoverage(t,r):this.scope===c.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(t,r)}setupAlphaToCoverage(e,t){return(0,s.Fn)(()=>{let r=(0,s.fVC)().toVar("distanceToPlane"),i=(0,s.fVC)().toVar("distanceToGradient"),h=(0,s.fVC)(1).toVar("clipOpacity"),c=t.length;if(!1===this.hardwareClipping&&c>0){let e=(0,u.W)(t).setGroup(d.sx);(0,o.FZ)(c,({i:t})=>{let s=e.element(t);r.assign(a.tX.dot(s.xyz).negate().add(s.w)),i.assign(r.fwidth().div(2)),h.mulAssign((0,l.TF)(i.negate(),i,r))})}let p=e.length;if(p>0){let t=(0,u.W)(e).setGroup(d.sx),n=(0,s.fVC)(1).toVar("intersectionClipOpacity");(0,o.FZ)(p,({i:e})=>{let s=t.element(e);r.assign(a.tX.dot(s.xyz).negate().add(s.w)),i.assign(r.fwidth().div(2)),n.mulAssign((0,l.TF)(i.negate(),i,r).oneMinus())}),h.mulAssign(n.oneMinus())}n.YL.a.mulAssign(h),n.YL.a.equal(0).discard()})()}setupDefault(e,t){return(0,s.Fn)(()=>{let r=t.length;if(!1===this.hardwareClipping&&r>0){let e=(0,u.W)(t).setGroup(d.sx);
480(0,o.FZ)(r,({i:t})=>{let r=e.element(t);a.tX.dot(r.xyz).greaterThan(r.w).discard()})}let i=e.length;if(i>0){let t=(0,u.W)(e).setGroup(d.sx),r=(0,s.lcY)(!0).toVar("clipped");(0,o.FZ)(i,({i:e})=>{let i=t.element(e);r.assign(a.tX.dot(i.xyz).greaterThan(i.w).and(r))}),r.discard()}})()}setupHardwareClipping(e,t){let r=e.length;return t.enableHardwareClipping(r),(0,s.Fn)(()=>{let i=(0,u.W)(e).setGroup(d.sx),s=(0,h.S)(t.getClipDistance());(0,o.FZ)(r,({i:e})=>{let t=i.element(e),r=a.tX.dot(t.xyz).sub(t.w).negate();s.element(e).assign(r)})})()}}c.ALPHA_TO_COVERAGE="alphaToCoverage",c.DEFAULT="default",c.HARDWARE="hardware";let p=()=>new c,m=()=>new c(c.ALPHA_TO_COVERAGE),g=()=>new c(c.HARDWARE)},46836:(e,t,r)=>{r.d(t,{w:()=>v});var i=r(13662),s=r(30710),a=r(80904),n=r(40786),o=r(61296),l=r(74872),u=r(89670),h=r(27240),d=r(2945);class c extends h.g{constructor(e=null,t=1,r=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:i},this.magFilter=d.hxR,this.minFilter=d.hxR,this.wrapR=d.ghU,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}var p=r(96310),m=r(25756),g=r(61046);let f=new WeakMap,y=new m.I,x=new WeakMap,b=(0,i.Fn)(({bufferMap:e,influence:t,stride:r,width:s,depth:a,offset:o})=>{let l=(0,i.Whr)(u.hG).mul(r).add(o),h=l.div(s),d=l.sub(h.mul(s));return(0,n.cb)(e,(0,i.Wst)(d,h)).depth(a).xyz.mul(t)}),v=(0,i.Fn)(([e])=>{let{geometry:t}=e,r=void 0!==t.morphAttributes.position,h=t.hasAttribute("normal")&&void 0!==t.morphAttributes.normal,m=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,v=void 0!==m?m.length:0;if(0===v)return;let _=x.get(e);(void 0===_||_.count!==v)&&(_={base:(0,i.PiW)(1),influences:e.morphTargetInfluences?(0,g.W)(e.morphTargetInfluences,"float"):null,count:v},x.set(e,_));let{base:T,influences:S}=_,{texture:A,stride:M,size:w}=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=f.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||[],u=0;!0===t&&(u=1),!0===r&&(u=2),!0===i&&(u=3);let h=e.attributes.position.count*u,m=1;h>4096&&(m=Math.ceil(h/4096),h=4096);let g=new Float32Array(h*m*4*a),x=new c(g,h,m,a);x.type=d.RQf,x.needsUpdate=!0;let b=4*u;for(let e=0;e<a;e++){let a=s[e],n=o[e],u=l[e],d=h*m*4*e;for(let e=0;e<a.count;e++){let s=e*b;!0===t&&(y.fromBufferAttribute(a,e),g[d+s+0]=y.x,g[d+s+1]=y.y,g[d+s+2]=y.z,g[d+s+3]=0),!0===r&&(y.fromBufferAttribute(n,e),g[d+s+4]=y.x,g[d+s+5]=y.y,g[d+s+6]=y.z,g[d+s+7]=0),!0===i&&(y.fromBufferAttribute(u,e),g[d+s+8]=y.x,g[d+s+9]=y.y,g[d+s+10]=y.z,g[d+s+11]=4===u.itemSize?y.w:1)}}n={count:a,texture:x,stride:u,size:new p.I(h,m)},f.set(e,n),e.addEventListener("dispose",function t(){x.dispose(),f.delete(e),e.removeEventListener("dispose",t)})}return n}(t);!0===r&&o.po.mulAssign(T),!0===h&&l.xg.mulAssign(T);let R=(0,i.Whr)(w.width);(0,s.FZ)(v,({i:t})=>{let s=(0,i.fVC)(0).toVar();e.count>1&&null!==e.morphTexture&&void 0!==e.morphTexture?s.assign((0,n.cb)(e.morphTexture,(0,i.Wst)((0,i.Whr)(t).add(1),(0,i.Whr)(u.cG))).r):s.assign(S.element(t).toVar()),(0,i.If)(s.notEqual(0),()=>{!0===r&&o.po.addAssign(b({bufferMap:A,influence:s,stride:M,width:R,depth:t,offset:(0,i.Whr)(0)})),!0===h&&l.xg.addAssign(b({bufferMap:A,influence:s,stride:M,width:R,depth:t,offset:(0,i.Whr)(1)}))})}),(0,a.ow)(({object:e})=>{let{base:t,influences:r}=_;e.geometry.morphTargetsRelative?t.value=1:t.value=1-e.morphTargetInfluences.reduce((e,t)=>e+t,0),r&&(r.array=e.morphTargetInfluences,r.update())})},"void")},46956:(e,t,r)=>{r.d(t,{O:()=>u});var i=r(65415),s=r(26990),a=r(51166),n=r(51365);let o=new s.k,l=new i.P;class u{constructor(e=0,t=0,r=0,i=u.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,r,i=this._order){return this._x=e,this._y=t,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,r=!0){let i=e.elements,s=i[0],o=i[4],l=i[8],u=i[1],h=i[5
480],d=i[9],c=i[2],p=i[6],m=i[10];switch(t){case"XYZ":this._y=Math.asin((0,a.qE)(l,-1,1)),.9999999>Math.abs(l)?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,h),this._z=0);break;case"YXZ":this._x=Math.asin(-(0,a.qE)(d,-1,1)),.9999999>Math.abs(d)?(this._y=Math.atan2(l,m),this._z=Math.atan2(u,h)):(this._y=Math.atan2(-c,s),this._z=0);break;case"ZXY":this._x=Math.asin((0,a.qE)(p,-1,1)),.9999999>Math.abs(p)?(this._y=Math.atan2(-c,m),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(u,s));break;case"ZYX":this._y=Math.asin(-(0,a.qE)(c,-1,1)),.9999999>Math.abs(c)?(this._x=Math.atan2(p,m),this._z=Math.atan2(u,s)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin((0,a.qE)(u,-1,1)),.9999999>Math.abs(u)?(this._x=Math.atan2(-d,h),this._y=Math.atan2(-c,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-(0,a.qE)(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(p,h),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:(0,n.R8)("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===r&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return o.makeRotationFromQuaternion(e),this.setFromRotationMatrix(o,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return l.setFromEuler(this),this.setFromQuaternion(l,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}u.DEFAULT_ORDER="XYZ"},47307:(e,t,r)=>{var i=r(57218),s=r(23039),a=r(12106),n=r(83815),o=r(51365);class l extends i.A{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=n.KS.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;
480return!0===e.context.inspector&&null!==this.callback&&(t=this.callback(t)),!0!==e.renderer.backend.isWebGPUBackend&&e.renderer.inspector.constructor!==s.A&&(0,o.mc)('TSL: ".toInspector()" is only available with WebGPU.'),t}}(0,a.mV)("toInspector",function(e,t="",r=null){return(e=(0,a.mp)(e)).before(new l(e,t,r))})},47330:(e,t,r)=>{r.d(t,{A:()=>s});var i=r(13662);let s=(0,i.Fn)(([e,t])=>{let r=e.x,s=e.y,a=e.z,n=t.element(0).mul(.886227);return(n=(n=(n=(n=(n=(n=(n=n.add(t.element(1).mul(1.023328).mul(s))).add(t.element(2).mul(1.023328).mul(a))).add(t.element(3).mul(1.023328).mul(r))).add(t.element(4).mul(.858086).mul(r).mul(s))).add(t.element(5).mul(.858086).mul(s).mul(a))).add(t.element(6).mul(a.mul(a).mul(.743125).sub(.247708)))).add(t.element(7).mul(.858086).mul(r).mul(a))).add(t.element(8).mul(.429043).mul((0,i.lKK)(r,r).sub((0,i.lKK)(s,s))))})},48214:(e,t,r)=>{let i;r.d(t,{Ey:()=>h,Qp:()=>c,hs:()=>d,lV:()=>m,p:()=>p});var s=r(61114),a=r(24481),n=r(26609),o=r(75180),l=r(61296);function u(e){let t=(i=i||new WeakMap).get(e);return void 0===t&&i.set(e,t={}),t}function h(e){let t=u(e);return t.shadowMatrix||(t.shadowMatrix=(0,s.P)("mat4").setGroup(a.sx).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 d(e,t=l.MI){let r=h(e).mul(t);return r.xyz.div(r.w)}function c(e){let t=u(e);return t.position||(t.position=(0,s.P)(new n.P).setGroup(a.sx).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.matrixWorld)))}function p(e){let t=u(e);return t.viewPosition||(t.viewPosition=(0,s.P)(new n.P).setGroup(a.sx).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new n.P,r.value.setFromMatrixPosition(e.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}let m=e=>{let t;return o.S3.transformDirection(c(e).sub((t=u(e)).targetPosition||(t.targetPosition=(0,s.P)(new n.P).setGroup(a.sx).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(e.target.matrixWorld)))))}},48983:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(64551);class s extends i.A{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}let a=s},49415:(e,t,r)=>{var i=r(5092),s=r(12106);class a extends i.A{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)}}(0,s.mV)("toArray",(e,t)=>((...e)=>{let t;if(1===e.length){let r=e[0];t=new a(null,r.length,r)}else t=new a(e[0],e[1]);return(0,s.mp)(t)})(Array(t).fill(e)))},50067:(e,t,r)=>{r(81951),r(98121),(0,r(13662).Fn)(([e,t])=>e.mul(t).floor().div(t))},50628:(e,t,r)=>{r.d(t,{A:()=>g});var i=r(96285),s=r(44342),a=r(27300),n=r(61296),o=r(89039),l=r(13662),u=r(98786),h=r(50782);class d extends u.i{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new h.Q(0xffffff),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}var c=r(73705);let p=new d;class m extends i.A{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(p),this.setValues(e)}setupPositionView(e){let{object:t,camera:r}=e,{positionNode:i,rotationNode:u,scaleNode:h,sizeAttenuation:d}=this,p=a.SP.mul((0,l.eR5)(i||0)),m=(0,l.ZcS)(a.n6[0].xyz.length(),a.n6[1].xyz.length());null!==h&&(m=m.mul((0,l.ZcS)(h))),r.isPerspectiveCamera&&!1===d&&(m=m.mul(p.z.negate()));let g=n.WV.xy;if(t.center&&!0===t.center.isVector2){let e=(0,c.ir)("center","vec2",t);g=g.sub(e.sub(.5))}g=g.mul(m);let f=(0,l.fVC)(u||s.O3),y=(0,o.e)(g,f);return(0,l.lnd)(p.xy.add(y),p.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}let g=m},50782:(e,t,r)=>{r.d(t,{Q:()=>d});var i=r(51166),s=r(68929),a=r(2945),n=r(51365);let o={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32},l={h:0,s:0,l:0},u={h:0,s:0,l:0};function h(e,t,r){return(r<0&&(r+=1),r>1&&(r-=1),r<1/6)?e+(t-e)*6*r:r<.5?t:r<2/3?e+(t-e)*6*(2/3-r):e}class d{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){return void 0===t&&void 0===r?e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e):this.setRGB(e,t,r),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=a.er$){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,s.pp.colorSpaceToWorking(this,t),this}setRGB(e,t,r,i=s.pp.workingColorSpace){return this.r=e,this.g=t,this.b=r,s.pp.colorSpaceToWorking(this,i),this}setHSL(e,t,r,a=s.pp.workingColorSpace){if(e=(0,i.rl)(e,1),t=(0,i.qE)(t,0,1),r=(0,i.qE)(r,0,1),0===t)this.r=this.g=this.b=r;else{let i=r<=.5?r*(1+t):r+t-r*t,s=2*r-i;this.r=h(s,i,e+1/3),this.g=h(s,i,e),this.b=h(s,i,e-1/3)}return s.pp.colorSpaceToWorking(this,a),this}setStyle(e,t=a.er$){let r;function i(t){void 0!==t&&1>parseFloat(t)&&(0,n.R8)("Color: Alpha component of "+e+" will be ignored.")}if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:(0,n.R8)("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let i=r[1],s=i.length;if(3===s)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(6===s)return this.setHex(parseInt(i,16),t);(0,n.R8)("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=a.er$){let r=o[e.toLowerCase()];return void 0!==r?this.setHex(r,t):(0,n.R8)("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=(0,s.dk)(e.r),this.g=(0,s.dk)(e.g),this.b=(0,s.dk)(e.b),this}copyLinearToSRGB(e){return this.r=(0,s.rd)(e.r),this.g=(0,s.rd)(e.g),this.b=(0,s.rd)(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=a.er$){return s.pp.workingToColorSpace(c.copy(this),e),65536*Math.round((0,i.qE)(255*c.r,0,255))+256*Math.round((0,i.qE)(255*c.g,0,255))+Math.round((0,i.qE)(255*c.b,0,255))}
480getHexString(e=a.er$){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=s.pp.workingColorSpace){let r,i;s.pp.workingToColorSpace(c.copy(this),t);let a=c.r,n=c.g,o=c.b,l=Math.max(a,n,o),u=Math.min(a,n,o),h=(u+l)/2;if(u===l)r=0,i=0;else{let e=l-u;switch(i=h<=.5?e/(l+u):e/(2-l-u),l){case a:r=(n-o)/e+6*(n<o);break;case n:r=(o-a)/e+2;break;case o:r=(a-n)/e+4}r/=6}return e.h=r,e.s=i,e.l=h,e}getRGB(e,t=s.pp.workingColorSpace){return s.pp.workingToColorSpace(c.copy(this),t),e.r=c.r,e.g=c.g,e.b=c.b,e}getStyle(e=a.er$){s.pp.workingToColorSpace(c.copy(this),e);let t=c.r,r=c.g,i=c.b;return e!==a.er$?`color(${e} ${t.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*r)},${Math.round(255*i)})`}offsetHSL(e,t,r){return this.getHSL(l),this.setHSL(l.h+e,l.s+t,l.l+r)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,r){return this.r=e.r+(t.r-e.r)*r,this.g=e.g+(t.g-e.g)*r,this.b=e.b+(t.b-e.b)*r,this}lerpHSL(e,t){this.getHSL(l),e.getHSL(u);let r=(0,i.Cc)(l.h,u.h,t),s=(0,i.Cc)(l.s,u.s,t),a=(0,i.Cc)(l.l,u.l,t);return this.setHSL(r,s,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,r=this.g,i=this.b,s=e.elements;return this.r=s[0]*t+s[3]*r+s[6]*i,this.g=s[1]*t+s[4]*r+s[7]*i,this.b=s[2]*t+s[5]*r+s[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}let c=new d;d.NAMES=o},50803:(e,t,r)=>{var i=r(5092),s=r(12106),a=r(83815);
480class n extends i.A{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 a.Iy.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),h=e.getDataFromNode(this);if(!0===h.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,h=u.node.context({assign:!0}).build(e);for(let t=0;t<u.components.length;t++){let r=u.components[t];e.addLineFlowCode(`${h}.${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 h.initialized=!0,e.format(r,o,t)}}let o=(0,s.Hm)(n).setParameterLength(2);(0,s.mV)("assign",o)},51166:(e,t,r)=>{r.d(t,{Cc:()=>d,NU:()=>p,S8:()=>m,a5:()=>o,cj:()=>g,lk:()=>l,pu:()=>c,qE:()=>u,rl:()=>h,up:()=>n});var i=r(51365);let s=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],a=1234567,n=Math.PI/180,o=180/Math.PI;function l(){let e=0xffffffff*Math.random()|0,t=0xffffffff*Math.random()|0,r=0xffffffff*Math.random()|0,i=0xffffffff*Math.random()|0;return(s[255&e]+s[e>>8&255]+s[e>>16&255]+s[e>>24&255]+"-"+s[255&t]+s[t>>8&255]+"-"+s[t>>16&15|64]+s[t>>24&255]+"-"+s[63&r|128]+s[r>>8&255]+"-"+s[r>>16&255]+s[r>>24&255]+s[255&i]+s[i>>8&255]+s[i>>16&255]+s[i>>24&255]).toLowerCase()}function u(e,t,r){return Math.max(t,Math.min(r,e))}function h(e,t){return(e%t+t)%t}function d(e,t,r){return(1-r)*e+r*t}function c(e){return e*n}function p(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/0xffffffff;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/0x7fffffff,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("THREE.MathUtils: Invalid component type.")}}function m(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(0xffffffff*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(0x7fffffff*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error("THREE.MathUtils: Invalid component type.")}}let g={DEG2RAD:n,RAD2DEG:o,generateUUID:l,clamp:u,euclideanModulo:h,mapLinear:function(e,t,r,i,s){return i+(e-t)*(s-i)/(r-t)},inverseLerp:function(e,t,r){return e!==t?(r-e)/(t-e):0},lerp:d,damp:function(e,t,r,i){return d(e,t,1-Math.exp(-r*i))},pingpong:function(e,t=1){return t-Math.abs(h(e,2*t)-t)},smoothstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(a=e);let t=a+=0x6d2b79f5;return t=Math.imul(t^t>>>15,1|t),(((t^=t+Math.imul(t^t>>>7,61|t))^t>>>14)>>>0)/0x100000000},degToRad:c,radToDeg:function(e){return e*o},isPowerOfTwo:function(e){return(e&e-1)==0&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,r,s,a){let n=Math.cos,o=Math.sin,l=n(r/2),u=o(r/2),h=n((t+s)/2),d=o((t
480+s)/2),c=n((t-s)/2),p=o((t-s)/2),m=n((s-t)/2),g=o((s-t)/2);switch(a){case"XYX":e.set(l*d,u*c,u*p,l*h);break;case"YZY":e.set(u*p,l*d,u*c,l*h);break;case"ZXZ":e.set(u*c,u*p,l*d,l*h);break;case"XZX":e.set(l*d,u*g,u*m,l*h);break;case"YXY":e.set(u*m,l*d,u*g,l*h);break;case"ZYZ":e.set(u*g,u*m,l*d,l*h);break;default:(0,i.R8)("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+a)}},normalize:m,denormalize:p}},51187:(e,t,r)=>{r.d(t,{A:()=>g});var i=r(5972),s=r(36850),a=r(98121),n=r(81951),o=r(13662);let l=(0,o.Fn)(({alphaT:e,alphaB:t,dotTV:r,dotBV:i,dotTL:s,dotBL:l,dotNV:u,dotNL:h})=>{let d=h.mul((0,o.eR5)(e.mul(r),t.mul(i),u).length()),c=u.mul((0,o.eR5)(e.mul(s),t.mul(l),h).length());return(0,a.y4)(.5,d.add(c).max(n.p8))}).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"}]});var u=r(10379);let h=(0,o.fVC)(1/Math.PI),d=(0,o.Fn)(({alphaT:e,alphaB:t,dotNH:r,dotTH:i,dotBH:s})=>{let a=e.mul(t),n=(0,o.eR5)(t.mul(i),e.mul(s),a.mul(r)),l=n.dot(n),u=a.div(l);return h.mul(a.mul(u.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"}]});var c=r(74872),p=r(61296),m=r(21387);let g=(0,o.Fn)(({lightDirection:e,f0:t,f90:r,roughness:a,f:n,normalView:h=c.j8,USE_IRIDESCENCE:g,USE_ANISOTROPY:f})=>{let y,x,b=a.pow2(),v=e.add(p.Mv).normalize(),_=h.dot(e).clamp(),T=h.dot(p.Mv).clamp(),S=h.dot(v).clamp(),A=p.Mv.dot(v).clamp(),M=(0,i.A)({f0:t,f90:r,dotVH:A});if((0,o.swK)(g)&&(M=m.tj.mix(M,n)),(0,o.swK)(f)){let t=m.Z1.dot(e),r=m.Z1.dot(p.Mv),i=m.Z1.dot(v),s=m.Lt.dot(e),a=m.Lt.dot(p.Mv),n=m.Lt.dot(v);y=l({alphaT:m.rX,alphaB:b,dotTV:r,dotBV:a,dotTL:t,dotBL:s,dotNV:T,dotNL:_}),x=d({alphaT:m.rX,alphaB:b,dotNH:S,dotTH:i,dotBH:n})}else y=(0,s.A)({alpha:b,dotNL:_,dotNV:T}),x=(0,u.A)({alpha:b,dotNH:S});return M.mul(y).mul(x)})},51365:(e,t,r)=>{r.d(t,{AQ:()=>s,R8:()=>d,Rm:()=>u,aH:()=>m,iu:()=>a,lP:()=>o,mc:()=>p,qq:()=>n,ri:()=>g,z3:()=>c});var i=r(2945);function s(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function a(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function n(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function o(){let e=n("canvas");return e.style.display="block",e}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;let l={};function u(...e){console.log("THREE."+e.shift(),...e)}function h(e){let t=e[0];if("string"==typeof t&&t.startsWith("TSL:")){let t=e[1];t&&t.isStackTrace?e[0]+=" "+t.getLocation():e[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return e}function d(...e){let t="THREE."+(e=h(e)).shift();{let r=e[0];r&&r.isStackTrace?console.warn(r.getError(t)):console.warn(t,...e)}}function c(...e){let t="THREE."+(e=h(e)).shift();{let r=e[0];r&&r.isStackTrace?console.error(r.getError(t)):console.error(t,...e)}}function p(...e){let t=e.join(" ");t in l||(l[t]=!0,d(...e))}function m(){return"undefined"!=typeof self&&void 0!==self.scheduler&&void 0!==self.scheduler.yield?self.scheduler.yield():new Promise(e=>{requestAnimationFrame(e)})}let g={[i.eHc]:i.lGu,[i.brA]:i.K52,[i.U3G]:i.bw0,[i.xSv]:i.Gwm,[i.lGu]:i.eHc,[i.K52]:i.brA,[i.bw0]:i.U3G,[i.Gwm]:i.xSv}},52698:(e,t,r)=>{r.d(t,{i:()=>d});var i=r(2945),s=r(26990),a=r(84774),n=r(26609),o=r(65415);let l=new n.P,u=new o.P,h=new n.P;class d extends a.B{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new s.k,this.projectionMatrix=new s.k,this.projectionMatrixInverse=new s.k,this.coordinateSystem=i.TdN,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(l,u,h),1===h.x&&
4801===h.y&&1===h.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(l,u,h.set(1,1,1)).invert()}updateWorldMatrix(e,t,r=!1){super.updateWorldMatrix(e,t,r),this.matrixWorld.decompose(l,u,h),1===h.x&&1===h.y&&1===h.z?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(l,u,h.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}},53104:(e,t,r)=>{r.d(t,{G:()=>a});var i=r(27240),s=r(2945);class a extends i.g{constructor(e=null,t=1,r=1,i,a,n,o,l,u=s.hxR,h=s.hxR,d,c){super(null,n,o,l,u,h,i,a,d,c),this.isDataTexture=!0,this.image={data:e,width:t,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}},53148:(e,t,r)=>{r.d(t,{A:()=>s});class i extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}let s=i},55105:(e,t,r)=>{r.d(t,{b:()=>a});var i=r(61806),s=r(18385);class a extends i.L{constructor(e=1,t=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:r,heightSegments:i};const a=e/2,n=t/2,o=Math.floor(r),l=Math.floor(i),u=o+1,h=l+1,d=e/o,c=t/l,p=[],m=[],g=[],f=[];for(let e=0;e<h;e++){const t=e*c-n;for(let r=0;r<u;r++){const i=r*d-a;m.push(i,-t,0),g.push(0,0,1),f.push(r/o),f.push(1-e/l)}}for(let e=0;e<l;e++)for(let t=0;t<o;t++){const r=t+u*e,i=t+u*(e+1),s=t+1+u*(e+1),a=t+1+u*e;p.push(r,i,a),p.push(i,s,a)}this.setIndex(p),this.setAttribute("position",new s.qt(m,3)),this.setAttribute("normal",new s.qt(g,3)),this.setAttribute("uv",new s.qt(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new a(e.width,e.height,e.widthSegments,e.heightSegments)}}},55301:(e,t,r)=>{r.d(t,{a:()=>p,v:()=>m});var i=r(74872),s=r(61296),a=r(13662),n=r(40786),o=r(8227),l=r(71440),u=r(89670),h=r(21387);let d=(0,a.Fn)(([e,t])=>{let r=(0,a.Whr)((0,o.b)((0,n.cb)(e),0).x).toConst(),i=(0,a.Whr)(t),s=i.mod(r).toConst(),l=i.div(r).toConst();return(0,n.cb)(e,(0,a.Wst)(s,l))}),c=(0,a.Fn)(([e,t])=>{let r=(0,a.Whr)((0,o.b)((0,n.cb)(e),0).x).toConst(),i=(0,a.Whr)(t).mod(r).toConst(),s=(0,a.Whr)(t).div(r).toConst();return(0,n.cb)(e,(0,a.Wst)(i,s)).x}),p=(0,h.mp)("vec4","vBatchColor"),m=(0,a.Fn)(([e],t)=>{let r=null===t.getDrawIndex()?u.cG:u.dK,h=c(e._indirectTexture,(0,a.Whr)(r)),m=e._matricesTexture,g=(0,a.Whr)((0,o.b)((0,n.cb)(m),0).x).toConst(),f=(0,a.fVC)(h).mul(4).toInt().toConst(),y=f.mod(g).toConst(),x=f.div(g).toConst(),b=(0,a.pBV)((0,n.cb)(m,(0,a.Wst)(y,x)),(0,n.cb)(m,(0,a.Wst)(y.add(1),x)),(0,n.cb)(m,(0,a.Wst)(y.add(2),x)),(0,n.cb)(m,(0,a.Wst)(y.add(3),x))),v=e._colorsTexture;if(null!==v){let e=d(v,h);p.assign(e)}let _=(0,a.w00)(b);s.po.assign(b.mul(s.po));let T=i.xg.div((0,a.eR5)(_[0].dot(_[0]),_[1].dot(_[1]),_[2].dot(_[2]))),S=_.mul(T).xyz;i.xg.assign(S),t.hasGeometryAttribute("tangent")&&l.d8.mulAssign(_)},"void")},55398:(e,t,r)=>{r.d(t,{Qk:()=>d});var i=r(5092),s=r(12106),a=r(2945),n=r(68929),o=r(20407),l=r(79623);let u="WorkingColorSpace";class h extends i.A{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===u?n.pp.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),u=t;return!1!==n.pp.enabled&&r!==i&&r&&i&&(n.pp.getTransfer(r)===a.KLL&&(u=(0,s.ln)((0,o.y)(u.rgb),u.a)),n.pp.getPrimaries(r)!==n.pp.getPrimaries(i)&&(u=(0,s.ln)((0,s.w0)(n.pp._getMatrix(new l.d,r,i)).mul(u.rgb),u.a)),n.pp.getTransfer(i)===a.KLL&&(u=(0,s.ln)((0,o.f)(u.rgb),u.a))),u}}let d=(e,t)=>new h((0,s.mp)(e),t,u);(0,s.mV)("workingToColorSpace",(e,t)=>new h((0,s.mp)(e),u,t)),(0,s.mV)("colorSpaceToWorking",d)},56169:(e,t,r)=>{r.d(t,{k:()=>x,p:()=>b});var i=r(39848),s=r(61296),a=r(74872);let n=(0,i.uv)(),o=s.tX.dFdx(),l=s.tX.dFdy(),u=n.dFdx(),h=n.dFdy(),d=a.j8,c=l.cross(d),p=d.cross(o),m=c.mul(u.x).add(p.mul(h.x)),g=c.mul(u.y).add(p.mul(h.y)),f=m.dot(m).max(g.dot(g)),y=f.equal(0).select(0,f.inverseSqrt()),x=m.mul(y).toVar("tangentViewFrame"),b=g.mul(y).toVar("bitangentViewFrame")},56288:(e,t,r)=>{var i=r(57218),s=r(40786),a=r(83815),n=r(96621),o=r(2945),l=r(44063),u=r(84774),h=r(96310),d=r(26609),c=r(25756),p=r(26990),m=r(4064
4801),g=r(96201),f=r(51365);let y=new l.Z,x=new d.P,b=new d.P,v=new d.P,_=new p.k,T=new d.P(0,0,-1),S=new c.I,A=new d.P,M=new d.P,w=new c.I,R=new h.I,N=new m.O,C=n.m1.flipX();N.depthTexture=new g.V(1,1);let E=!1;class F extends s.Ay{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||N.texture,C),this._reflectorBaseNode=e.reflector||new B(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(null===this._depthNode){if(!0!==this._reflectorBaseNode.depth)throw Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new F({defaultTexture:N.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 B extends i.A{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new u.B,resolutionScale:i=1,generateMipmaps:s=!1,bounces:n=!0,depth:o=!1,samples:l=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=i,void 0!==t.resolution&&((0,f.mc)('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=s,this.bounces=n,this.depth=o,this.samples=l,this.updateBeforeType=n?a.KS.RENDER:a.KS.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){let r=this.resolutionScale;t.getDrawingBufferSize(R),e.setSize(Math.round(R.width*r),Math.round(R.height*r))}setup(e){return this._updateResolution(N,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 m.O(0,0,{type:o.ix0,samples:this.samples}),!0===this.generateMipmaps&&(t.texture.minFilter=o.NZq,t.texture.generateMipmaps=!0),!0===this.depth&&(t.depthTexture=new g.V),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&E)return!1;E=!0;let{scene:t,camera:r,renderer:i,material:s}=e,{target:a}=this,n=this.getVirtualCamera(r),l=this.getRenderTarget(n);i.getDrawingBufferSize(R),this._updateResolution(l,i),b.setFromMatrixPosition(a.matrixWorld),v.setFromMatrixPosition(r.matrixWorld),_.extractRotation(a.matrixWorld),x.set(0,0,1),x.applyMatrix4(_),A.subVectors(b,v);let u=A.dot(x)>0,h=!1;if(!0===u&&!1===this.forceUpdate){if(!1===this.hasOutput){E=!1;return}h=!0}A.reflect(x).negate(),A.add(b),_.extractRotation(r.matrixWorld),T.set(0,0,-1),T.applyMatrix4(_),T.add(v),M.subVectors(b,T),M.reflect(x).negate(),M.add(b),n.coordinateSystem=r.coordinateSystem,n.position.copy(A),n.up.set(0,1,0),n.up.applyMatrix4(_),n.up.reflect(x),n.lookAt(M),n.near=r.near,n.far=r.far,n.updateMatrixWorld(),n.projectionMatrix.copy(r.projectionMatrix),y.setFromNormalAndCoplanarPoint(x,b),y.applyMatrix4(n.matrixWorldInverse),S.set(y.normal.x,y.normal.y,y.normal.z,y.constant);let d=n.projectionMatrix;w.x=(Math.sign(S.x)+d.elements[8])/d.elements[0],w.y=(Math.sign(S.y)+d.elements[9])/d.elements[5],w.z=-1,w.w=(1+d.elements[10])/d.elements[14],S.multiplyScalar(1/S.dot(w)),d.elements[2]=S.x,d.elements[6]=S.y,d.elements[10]=i.coordinateSystem===o.i7u?S.z-0:S.z+1-0,d.elements[14]=S.w,this.textureNode.value=l.texture,!0===this.depth&&(this.textureNode.getDepthNode().value=l.depthTexture),s.visible=!1;let c=i.getRenderTarget(),p=i.getMRT(),m=i.autoClear;i.setMRT(null),i.setRenderTarget(l),i.autoClear=!0;let g=t.name;
480t.name=(t.name||"Scene")+" [ Reflector ]",h?(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,E=!1,this.forceUpdate=!1}get resolution(){return(0,f.mc)('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){(0,f.mc)('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}},56759:(e,t,r)=>{let i;r.d(t,{Ay:()=>L,r7:()=>I});var s=r(96285),a=r(66463),n=r(56900),o=r(67850),l=r(12106),u=r(14508),h=r(40786),d=r(86389),c=r(74872),p=r(81951),m=r(98121),g=r(96201),f=r(30710),y=r(96621),x=r(2945),b=r(24481),v=r(82196),_=r(48214),T=r(50782),S=r(79699),A=r(61989),M=r(61296),w=r(61114),R=r(57641);let N=new n.A,C=[],E=(0,l.Fn)(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:s})=>{let a=(0,l.fV)(0).toVar("meanVertical"),n=(0,l.fV)(0).toVar("squareMeanVertical"),o=e.lessThanEqual((0,l.fV)(1)).select((0,l.fV)(0),(0,l.fV)(2).div(e.sub(1))),u=e.lessThanEqual((0,l.fV)(1)).select((0,l.fV)(0),(0,l.fV)(-1));(0,f.FZ)({start:(0,l.Wh)(0),end:(0,l.Wh)(e),type:"int",condition:"<"},({i:e})=>{let h=u.add((0,l.fV)(e).mul(o)),d=i.sample((0,m.WQ)(y.Vj.xy,(0,l.Zc)(0,h).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 h=(0,p.RZ)(n.sub(a.mul(a)).max(0));return(0,l.Zc)(a,h)}),F=(0,l.Fn)(({samples:e,radius:t,size:r,shadowPass:i,depthLayer:s})=>{let a=(0,l.fV)(0).toVar("meanHorizontal"),n=(0,l.fV)(0).toVar("squareMeanHorizontal"),o=e.lessThanEqual((0,l.fV)(1)).select((0,l.fV)(0),(0,l.fV)(2).div(e.sub(1))),u=e.lessThanEqual((0,l.fV)(1)).select((0,l.fV)(0),(0,l.fV)(-1));(0,f.FZ)({start:(0,l.Wh)(0),end:(0,l.Wh)(e),type:"int",condition:"<"},({i:e})=>{let h=u.add((0,l.fV)(e).mul(o)),d=i.sample((0,m.WQ)(y.Vj.xy,(0,l.Zc)(h,0).mul(t)).div(r));i.value.isArrayTexture&&(d=d.depth(s)),a.addAssign(d.x),n.addAssign((0,m.WQ)(d.y.mul(d.y),d.x.mul(d.x)))}),a.divAssign(e),n.divAssign(e);let h=(0,p.RZ)(n.sub(a.mul(a)).max(0));return(0,l.Zc)(a,h)}),B=[A.vY,A.y0,A.uS,A.Rd],P=new a.A;class V extends o.A{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,(0,l.fV)(1))}setupShadowCoord(e,t){let r,{shadow:i}=this,{renderer:s}=e,a=i.biasNode||(0,u.ir)("bias","float",i).setGroup(b.sx),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=(0,u.ir)("near","float",i.camera).setGroup(b.sx),s=(0,u.ir)("far","float",i.camera).setGroup(b.sx);r=(0,v.Ps)(e.negate(),t,s)}return(0,l.eR)(n.x,n.y.oneMinus(),s.reversedDepthBuffer?r.sub(a):r.add(a))}getShadowFilterFn(e){return B[e]}setupRenderTarget(e,t){let r=new g.V(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?x.gWB:x.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:a,camera:n}=e,{light:m,shadow:g}=this,{depthTexture:f,shadowMap:y}=this.setupRenderTarget(g,e),T=a.shadowMap.type,S=a.hasCompatibility(x.x$Y.TEXTURE_COMPARE);if((T===x.QP0||T===x.Wk7)&&S?(f.minFilter=x.k6q,f.magFilter=x.k6q):(f.minFilter=x.hxR,f.magFilter=x.hxR),g.camera.coordinateSystem=n.coordinateSystem,g.camera.updateProjectionMatrix(),T===x.RyA&&!0!==g.isPointLightShadow){f.compareFunction=null,y.depth>1?(y._vsmShadowMapVertical||(y._vsmShadowMapVertical=e.createRenderTarget(g.mapSize.width,g.mapSize.height,{format:x.paN,type:x.ix0,depth:y.depth,depthBuffer:!1}),y._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=y._vsmShadowMapVertical,y._vsmShadowMapHorizontal||(y._vsmShadowMapHorizontal=e.createRenderTarget(g.mapSize.width,g.mapSize.height,{format:x.paN,type:x.ix0,depth:y.depth,depthBuffer:!1}),y._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=y._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(g.mapSize.width,g.mapSize.height,{format:x.paN,type:x.ix0,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(g.mapSize.width,g.mapSize.height,{format:x.paN,type:x.ix0,depthBuffer:!1}));let t=(0,h.wH)(f);f.isArrayTexture&&(t=t.depth(this.depthLayer));let r=(0,h.wH)(this.vsmShadowMapVertical.texture);f.isArrayTexture&&(r=r.depth(this.depthLayer));
480let i=(0,u.ir)("blurSamples","float",g).setGroup(b.sx),a=(0,u.ir)("radius","float",g).setGroup(b.sx),n=(0,u.ir)("mapSize","vec2",g).setGroup(b.sx),o=this.vsmMaterialVertical||(this.vsmMaterialVertical=new s.A);o.fragmentNode=E({samples:i,radius:a,size:n,shadowPass:t,depthLayer:this.depthLayer}).context(e.getSharedContext()),o.name="VSMVertical",(o=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new s.A)).fragmentNode=F({samples:i,radius:a,size:n,shadowPass:r,depthLayer:this.depthLayer}).context(e.getSharedContext()),o.name="VSMHorizontal"}let A=(0,u.ir)("intensity","float",g).setGroup(b.sx),N=(0,u.ir)("normalBias","float",g).setGroup(b.sx),C=(0,_.Ey)(m),B=c.O7.mul(N);t=!a.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?C.mul(o.M.add(B)):(0,w.P)("mat4").onObjectUpdate(({object:e},t)=>t.value.multiplyMatrices(C.value,e.matrixWorld)).mul(M.po).add(C.mul((0,l.ln)(B,0)));let P=this.setupShadowCoord(e,t),V=g.filterNode||this.getShadowFilterFn(a.shadowMap.type)||null;if(null===V)throw Error("THREE.WebGPURenderer: Shadow map type not supported yet.");let L=T===x.RyA&&!0!==g.isPointLightShadow?this.vsmShadowMapHorizontal.texture:f,I=this.setupShadowFilter(e,{filterFn:V,shadowTexture:y.texture,depthTexture:L,shadowCoord:P,shadow:g,depthLayer:this.depthLayer});!0===a.shadowMap.transmitted&&(y.texture.isCubeTexture?r=(0,d.Rz)(y.texture,P.xyz):(r=(0,h.wH)(y.texture,P),f.isArrayTexture&&(r=r.depth(this.depthLayer)))),i=r?(0,p.jh)(1,I.rgb.mix(r,1),A.mul(r.a)).toVar():(0,p.jh)(1,I,A).toVar(),this.shadowMap=y,this.shadow.map=y;let O=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return r&&i.toInspector(`${O} / Color`,()=>this.shadowMap.texture.isCubeTexture?(0,d.Rz)(this.shadowMap.texture,(0,R.i)()):(0,h.wH)(this.shadowMap.texture)),i.toInspector(`${O} / Depth`,()=>{let e,t,r=(0,u.ir)("near","float",this.shadow.camera),i=(0,u.ir)("far","float",this.shadow.camera);return e=this.shadowMap.texture.isCubeTexture?(0,d.Rz)(this.shadowMap.depthTexture,(0,R.i)()).r:(0,h.wH)(this.shadowMap.depthTexture).r,t=this.shadow.camera.isPerspectiveCamera?(0,v.Aj)(e,r,i):(0,v.ME)(e,r,i),(t=(0,v.Kj)(t,r,i)).oneMinus()})}setup(e){if(!1!==e.renderer.shadowMap.enabled)return(0,l.Fn)(()=>{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,s;let a,{shadowMap:n,light:o,shadow:l}=this,{renderer:u,scene:h,camera:d}=e,c=u.shadowMap.type,p=n.depthTexture.version;this._depthVersionCached=p;let m=l.camera.layers.mask;(0xfffffffe&l.camera.layers.mask)==0&&(l.camera.layers.mask=d.layers.mask);let g=u.getRenderObjectFunction(),f=u.getMRT(),y=!!f&&f.has("velocity");t=function(e,t={}){return t.toneMapping=e.toneMapping,t.toneMappingExposure=e.toneMappingExposure,t.outputColorSpace=e.outputColorSpace,t.renderTarget=e.getRenderTarget(),t.activeCubeFace=e.getActiveCubeFace(),t.activeMipmapLevel=e.getActiveMipmapLevel(),t.renderObjectFunction=e.getRenderObjectFunction(),t.pixelRatio=e.getPixelRatio(),t.mrt=e.getMRT(),t.clearColor=e.getClearColor(t.clearColor||new T.Q),t.clearAlpha=e.getClearAlpha(),t.autoClear=e.autoClear,t.scissorTest=e.getScissorTest(),t}(u,t=i),u.setMRT(null),u.setRenderObjectFunction(null),u.setClearColor(0,1),u.autoClear=!0,r=function(e,t={}){return t.background=e.background,t.backgroundNode=e.backgroundNode,t.overrideMaterial=e.overrideMaterial,t}(h,r=t),h.background=null,h.backgroundNode=null,h.overrideMaterial=null,i=r,h.overrideMaterial=(0,A.GJ)(o),u.setRenderObjectFunction((C[0]=u,C[1]=l,(void 0===(a=N.get(C))||a.shadowType!==c||a.useVelocity!==y)&&((a=(e,t,r,i,s,a,n,o,h)=>{(!0===e.castShadow||e.receiveShadow&&c===x.RyA)&&(y&&((0,S.aC)(e).useVelocity=!0),e.onBeforeShadow(u,e,r,l.camera,i,t.overrideMaterial,a),u.renderObject(e,t,r,i,s,a,n,o,h),e.onAfterShadow(u,e,r,l.camera,i,t.overrideMaterial,a))}).shadowType=c,a.useVelocity=y,N.set(C,a)),C[0]=null,C[1]=null,a)),u.setClearColor(0,0),u.setRenderTarget(n),this.renderShadow(e),u.setRenderObjectFunction(g),c===x.RyA&&!0!==l.isPointLightShadow&&this.vsmPass(u),l.camera.layers.mask=m,u.toneMapping=(s=i).toneMapping,u.toneMappingExposure=s.toneMappingExposure,u.outputColorSpace
480=s.outputColorSpace,u.setRenderTarget(s.renderTarget,s.activeCubeFace,s.activeMipmapLevel),u.setRenderObjectFunction(s.renderObjectFunction),u.setPixelRatio(s.pixelRatio),u.setMRT(s.mrt),u.setClearColor(s.clearColor,s.clearAlpha),u.autoClear=s.autoClear,u.setScissorTest(s.scissorTest),h.background=s.background,h.backgroundNode=s.backgroundNode,h.overrideMaterial=s.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),P.material=this.vsmMaterialVertical,P.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),P.material=this.vsmMaterialHorizontal,P.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,(0,A.n2)(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 L=V,I=(e,t)=>new V(e,t)},56900:(e,t,r)=>{r.d(t,{A:()=>s});class i{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 s=i},57123:(e,t,r)=>{r.d(t,{D:()=>a,I:()=>s});var i=r(12106);let s=(0,i.Fn)(([e])=>(0,i.ln)(e.rgb.mul(e.a),e.a),{color:"vec4",return:"vec4"}),a=(0,i.Fn)(([e])=>e.a.equal(0).select((0,i.ln)(0),(0,i.ln)(e.rgb.div(e.a),e.a)),{color:"vec4",return:"vec4"})},57218:(e,t,r)=>{r.d(t,{A:()=>c});var i=r(83815),s=r(79699),a=r(83745),n=r(51166),o=r(51365),l=r(69707);let u={analyze:"setup",generate:"analyze"},h=0;class d extends a.Q{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=i.KS.NONE,this.updateBeforeType=i.KS.NONE,this.updateAfterType=i.KS.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=h++,this.stackTrace=null,!0===d.captureStackTrace&&(this.stackTrace=new l.A)}set needsUpdate(e){!0===e&&this.version++}get uuid(){return null===this._uuid&&(this._uuid=n.cj.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,i.KS.FRAME)}onRenderUpdate(e){return this.onUpdate(e,i.KS.RENDER)}onObjectUpdate(e){return this.onUpdate(e,i.KS.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:a}of this._getChildren(t))r.push((0,s.YZ)(i.slice(0,-4)),a.getCacheKey(e,t));this._cacheKey=(0,s.tW)((0,s.g0)(r),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}getScope(){return this}
480getHash(){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,o.R8)("Abstract function.")}updateAfter(){(0,o.R8)("Abstract function.")}update(){(0,o.R8)("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=u[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,o.R8)("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,o.z3)(`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}}d.captureStackTrace=!1;let c=d},57641:(e,t,r)=>{r.d(t,{C:()=>n,i:()=>o});
480var i=r(61296),s=r(39848),a=r(12106);let n=(0,a.Fn)(([e=i.tv])=>{let t=e.z.atan(e.x).mul(1/(2*Math.PI)).add(.5),r=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return(0,a.Zc)(t,r)}),o=(0,a.Fn)(([e=(0,s.uv)()])=>{let t=e.x.sub(.5).mul(2*Math.PI),r=e.y.sub(.5).mul(Math.PI),i=r.cos(),n=i.mul(t.cos()),o=r.sin(),l=i.mul(t.sin());return(0,a.eR)(n,o,l)})},58955:(e,t,r)=>{r.d(t,{Ay:()=>u});var i=r(57218),s=r(83815),a=r(61114);r(13662);var n=r(26609);let o=new(r(93998)).i;class l extends i.A{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=s.KS.OBJECT,this.uniformNode=new a.A(null)}generateNodeType(){let e=this.scope;return e===l.WORLD_MATRIX?"mat4":e===l.POSITION||e===l.VIEW_POSITION||e===l.DIRECTION||e===l.SCALE?"vec3":e===l.RADIUS?"float":void 0}update(e){let t=this.object3d,r=this.uniformNode,i=this.scope;if(i===l.WORLD_MATRIX)r.value=t.matrixWorld;else if(i===l.POSITION)r.value=r.value||new n.P,r.value.setFromMatrixPosition(t.matrixWorld);else if(i===l.SCALE)r.value=r.value||new n.P,r.value.setFromMatrixScale(t.matrixWorld);else if(i===l.DIRECTION)r.value=r.value||new n.P,t.getWorldDirection(r.value);else if(i===l.VIEW_POSITION){let i=e.camera;r.value=r.value||new n.P,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(i.matrixWorldInverse)}else if(i===l.RADIUS){let i=e.object.geometry;null===i.boundingSphere&&i.computeBoundingSphere(),o.copy(i.boundingSphere).applyMatrix4(t.matrixWorld),r.value=o.radius}}generate(e){let t=this.scope;return t===l.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===l.POSITION||t===l.VIEW_POSITION||t===l.DIRECTION||t===l.SCALE?this.uniformNode.nodeType="vec3":t===l.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}}l.WORLD_MATRIX="worldMatrix",l.POSITION="position",l.SCALE="scale",l.VIEW_POSITION="viewPosition",l.DIRECTION="direction",l.RADIUS="radius";let u=l},59759:(e,t,r)=>{var i=r(5092);r(12106),i.A},61046:(e,t,r)=>{r.d(t,{W:()=>h});var i=r(13662),s=r(83815),a=r(79699),n=r(15907),o=r(6293);class l extends n.A{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 u extends o.A{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=null===t?(0,a.AZ)(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=s.KS.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 l(this,(0,i.mp$)(e))}}let h=(e,t)=>new u(e,t)},61114:(e,t,r)=>{r.d(t,{A:()=>h,P:()=>d});var i=r(19534),s=r(69707),a=r(24481),n=r(12106),o=r(79699),l=r(51365);class u extends i.A{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=a.h}setName(e){return this.name=e,this}label(e){return(0,l.R8)('TSL: "label()" has been deprecated. Use "setName()" instead.',new s.A),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}
480onUpdate(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 h=u,d=(e,t)=>{let r=(0,n.G$)(t||e);if(r===e&&(e=(0,o.yI)(r)),e&&!0===e.isNode){let t=e.value;e.traverse(e=>{!0===e.isConstNode&&(t=e.value)}),e=t}return new u(e,r)}},61296:(e,t,r)=>{r.d(t,{DW:()=>d,MI:()=>c,Mv:()=>g,WV:()=>u,po:()=>h,tX:()=>m,tv:()=>p});var i=r(64994),s=r(12106),a=r(27300),n=r(75180),o=r(51365);let l=(0,s.Fn)(e=>"fragment"!==e.shaderStage?((0,o.mc)("TSL: `clipSpace` is only available in fragment stage."),(0,s.ln)()):e.context.clipSpace.toVarying("v_clipSpace")).once()(),u=(0,i.l)("position","vec3"),h=u.toVarying("positionLocal"),d=u.toVarying("positionPrevious"),c=(0,s.Fn)(e=>a.n6.mul(h).xyz.toVarying(e.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),p=(0,s.Fn)(()=>h.transformDirection(a.n6).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),m=(0,s.Fn)(e=>{if("fragment"===e.shaderStage&&e.material.vertexNode){let e=n.oA.mul(l);return e.xyz.div(e.w).toVar("positionView")}return e.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),g=(0,s.Fn)(e=>(e.camera.isOrthographicCamera?(0,s.eR)(0,0,1):m.negate().toVarying("v_positionViewDirection").normalize()).toVar("positionViewDirection"),"vec3").once(["POSITION"])()},61806:(e,t,r)=>{r.d(t,{L:()=>_});var i=r(26609),s=r(96310),a=r(6593),n=r(83745),o=r(18385),l=r(93998),u=r(84774),h=r(26990),d=r(79623),c=r(51166),p=r(51365);let m=0,g=new h.k,f=new u.B,y=new i.P,x=new a.N,b=new a.N,v=new i.P;class _ extends n.Q{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:m++}),this.uuid=(0,c.lk)(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new((0,p.AQ)(e)?o.MW:o.A$)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);let r=this.attributes.normal;if(void 0!==r){let t=new d.d().getNormalMatrix(e);r.applyNormalMatrix(t),r.needsUpdate=!0}let i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return g.makeRotationFromQuaternion(e),this.applyMatrix4(g),this}rotateX(e){return g.makeRotationX(e),this.applyMatrix4(g),this}rotateY(e){return g.makeRotationY(e),this.applyMatrix4(g),this}rotateZ(e){return g.makeRotationZ(e),this.applyMatrix4(g),this}translate(e,t,r){return g.makeTranslation(e,t,r),this.applyMatrix4(g),this}scale(e,t,r){return g.makeScale(e,t,r),this.applyMatrix4(g),this}lookAt(e){return f.lookAt(e),f.updateMatrix(),this.applyMatrix4(f.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(y).negate(),this.translate(y.x,y.y,y.z),this}setFromPoints(e){let t=this.getAttribute("position");if(void 0===t){let t=[];for(let r=0,i=e.length;r<i;r++){let i=e[r];t.push(i.x,i.y,i.z||0)}this.setAttribute("position",new o.qt(t,3))}else{let r=Math.min(e.length,t.count);for(let i=0;i<r;i++){let r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&(0,p.R8)("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}
480computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new a.N);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){(0,p.z3)("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new i.P(-1/0,-1/0,-1/0),new i.P(Infinity,Infinity,Infinity));return}if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){let r=t[e];x.setFromBufferAttribute(r),this.morphTargetsRelative?(v.addVectors(this.boundingBox.min,x.min),this.boundingBox.expandByPoint(v),v.addVectors(this.boundingBox.max,x.max),this.boundingBox.expandByPoint(v)):(this.boundingBox.expandByPoint(x.min),this.boundingBox.expandByPoint(x.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&(0,p.z3)('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new l.i);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){(0,p.z3)("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new i.P,1/0);return}if(e){let r=this.boundingSphere.center;if(x.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){let r=t[e];b.setFromBufferAttribute(r),this.morphTargetsRelative?(v.addVectors(x.min,b.min),x.expandByPoint(v),v.addVectors(x.max,b.max),x.expandByPoint(v)):(x.expandByPoint(b.min),x.expandByPoint(b.max))}x.getCenter(r);let i=0;for(let t=0,s=e.count;t<s;t++)v.fromBufferAttribute(e,t),i=Math.max(i,r.distanceToSquared(v));if(t)for(let s=0,a=t.length;s<a;s++){let a=t[s],n=this.morphTargetsRelative;for(let t=0,s=a.count;t<s;t++)v.fromBufferAttribute(a,t),n&&(y.fromBufferAttribute(e,t),v.add(y)),i=Math.max(i,r.distanceToSquared(v))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&(0,p.z3)('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void(0,p.z3)("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");let r=t.position,a=t.normal,n=t.uv,l=this.getAttribute("tangent");(void 0===l||l.count!==r.count)&&(l=new o.TH(new Float32Array(4*r.count),4),this.setAttribute("tangent",l));let u=[],h=[];for(let e=0;e<r.count;e++)u[e]=new i.P,h[e]=new i.P;let d=new i.P,c=new i.P,m=new i.P,g=new s.I,f=new s.I,y=new s.I,x=new i.P,b=new i.P,v=this.groups;0===v.length&&(v=[{start:0,count:e.count}]);for(let t=0,i=v.length;t<i;++t){let i=v[t],s=i.start,a=i.count;for(let t=s,i=s+a;t<i;t+=3)!function(e,t,i){d.fromBufferAttribute(r,e),c.fromBufferAttribute(r,t),m.fromBufferAttribute(r,i),g.fromBufferAttribute(n,e),f.fromBufferAttribute(n,t),y.fromBufferAttribute(n,i),c.sub(d),m.sub(d),f.sub(g),y.sub(g);let s=1/(f.x*y.y-y.x*f.y);isFinite(s)&&(x.copy(c).multiplyScalar(y.y).addScaledVector(m,-f.y).multiplyScalar(s),b.copy(m).multiplyScalar(f.x).addScaledVector(c,-y.x).multiplyScalar(s),u[e].add(x),u[t].add(x),u[i].add(x),h[e].add(b),h[t].add(b),h[i].add(b))}(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let _=new i.P,T=new i.P,S=new i.P,A=new i.P;function M(e){S.fromBufferAttribute(a,e),A.copy(S);let t=u[e];_.copy(t),_.sub(S.multiplyScalar(S.dot(t))).normalize(),T.crossVectors(A,t);let r=T.dot(h[e]);l.setXYZW(e,_.x,_.y,_.z,r<0?-1:1)}for(let t=0,r=v.length;t<r;++t){let r=v[t],i=r.start,s=r.count;for(let t=i,r=i+s;t<r;t+=3)M(e.getX(t+0)),M(e.getX(t+1)),M(e.getX(t+2))}this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(void 0!==t){let r=this.getAttribute("normal");if(void 0===r||r.count!==t.count)r=new o.TH(new Float32Array(3*t.count),3),this.setAttribute("normal",r);else for(let e=0,t=r.count;e<t;e++)r.setXYZ(e,0,0,0);let s=new i.P,a=new i.P,n=new i.P,l=new i.P,u=new i.P,h=new i.P,d=new i.P,c=new i.P;if(e)for(let i=0,o=e.count;i<o;i+=3){let o=e.getX(i+0),p=e.getX(i+1),m=e.getX(i+2);s.fromBufferAttribute(t,o),a.fromBufferAttribute(t,p),n.fromBufferAttribute(t,m),d.subVectors(n,a),c.subVectors(s,a),d.cross(c),l.fromBufferAttribute(r,o),u.fromBufferAttribute(r,p),h.fromBufferAttribute(r,m),l.add(d),u.add(d),h.add(d),r.setXYZ(o,l.x,l.y,l.z),r.setXYZ(p,u.x,u.y,u.z),r.setXYZ(m,h.x,h.y,h.z)}else for(let e=0,i=t.count;e<i;e+=3)s.fromBufferAttribute(t,e+0),a.fromBufferAttribute(t,e+1),n.fromBufferAttribute(t,e+2),d.subVectors(n,a),c.subVectors(s,a),d.cross(c),r.setXYZ(e+0,d.x,d.y,d.z),r.setXYZ(e+1,d.x,d.y,d.z),r.setXYZ(e+2,d.x,d.y,d.z);this.normalizeNormals(),r.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,r=e.count;t<r;t++)v.fromBufferAttribute(e,t),v.normalize(),e.setXYZ(t,v.x,v.y,v.z)}toNonIndexed(){function e(e,t){let r=e.array,i=e.itemSize,s=e.normalized,a=new r.constructor(t.length*i),n=0,l=0;for(let s=0,o=t.length;s<o;s++){n=e.isInterleavedBufferAttribute?t[s]*e.data.stride+e.offset:t[s]*i;for(let e=0;e<i;e++)a[l++]=r[n++]}return new o.TH(a,i,s)}if(null===this.index)return(0,p.R8)("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new _,r=this.index.array,i=this.attributes;for(let s in i){let a=e(i[s],r);t.setAttribute(s,a)}let s=this.morphAttributes;for(let i in s){let a=[],n=s[i];for(let t=0,i=n.length;t<i;t++){let i=e(n[t],r);a.push(i)}t.morphAttributes[i]=a}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let e=0,r=a.length;e<r;e++){let r=a[e];t.addGroup(r.start,r.count,r.materialIndex)}return t}toJSON(){let e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=void 0!==this.parameters&&!0===this._transformed?"BufferGeometry":this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters&&!0!==this._transformed){let t=this.parameters;for(let r in t)void 0!==t[r]&&(e[r]=t[r]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let r=this.attributes;for(let t in r){let i=r[t];e.data.attributes[t]=i.toJSON(e.data)}let i={},s=!1;for(let t in this.morphAttributes){let r=this.morphAttributes[t],a=[];for(let t=0,i=r.length;t<i;t++){let i=r[t];a.push(i.toJSON(e.data))}a.length>0&&(i[t]=a,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let n=this.boundingSphere;return null!==n&&(e.data.boundingSphere=n.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let r=e.index;null!==r&&this.setIndex(r.clone());let i=e.attributes;for(let e in i){let r=i[e];this.setAttribute(e,r.clone(t))}let s=e.morphAttributes;for(let e in s){let r=[],i=s[e];for(let e=0,s=i.length;e<s;e++)r.push(i[e].clone(t));this.morphAttributes[e]=r}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let n=e.boundingBox;
480null!==n&&(this.boundingBox=n.clone());let o=e.boundingSphere;return null!==o&&(this.boundingSphere=o.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}},61989:(e,t,r)=>{r.d(t,{GJ:()=>x,Rd:()=>y,n2:()=>b,uS:()=>f,vY:()=>m,y0:()=>g});var i=r(13662),s=r(14508),a=r(40786),n=r(81951),o=r(98121),l=r(24481),u=r(96285),h=r(96621),d=r(33738),c=r(2945);let p=new WeakMap,m=(0,i.Fn)(({depthTexture:e,shadowCoord:t,depthLayer:r})=>{let i=(0,a.wH)(e,t.xy).setName("t_basic");return e.isArrayTexture&&(i=i.depth(r)),i.compare(t.z)}),g=(0,i.Fn)(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:n})=>{let u=(t,r)=>{let i=(0,a.wH)(e,t);return e.isArrayTexture&&(i=i.depth(n)),i.compare(r)},c=(0,s.ir)("mapSize","vec2",r).setGroup(l.sx),p=(0,s.ir)("radius","float",r).setGroup(l.sx),m=(0,i.ZcS)(1).div(c),g=p.mul(m.x),f=(0,d.SZ)(h.Vj.xy).mul(6.28318530718);return(0,o.WQ)(u(t.xy.add((0,d.JS)(0,5,f).mul(g)),t.z),u(t.xy.add((0,d.JS)(1,5,f).mul(g)),t.z),u(t.xy.add((0,d.JS)(2,5,f).mul(g)),t.z),u(t.xy.add((0,d.JS)(3,5,f).mul(g)),t.z),u(t.xy.add((0,d.JS)(4,5,f).mul(g)),t.z)).mul(.2)}),f=(0,i.Fn)(({depthTexture:e,shadowCoord:t,shadow:r,depthLayer:u})=>{let h=(0,s.ir)("mapSize","vec2",r).setGroup(l.sx),d=(0,i.ZcS)(1).div(h),c=t.xy,p=(0,n.jc)(c.mul(h).add(.5)).toConst();c.subAssign(p.sub(.5).mul(d));let m=r=>{let i=(0,a.wH)(e,c).offset(r).gather();return e.isArrayTexture&&(i=i.depth(u)),i.compare(t.z)},g=m((0,i.Wst)(-1,1)).toConst(),f=m((0,i.Wst)(1,1)).toConst(),y=m((0,i.Wst)(-1,-1)).toConst(),x=m((0,i.Wst)(1,-1)).toConst();return(0,o.WQ)((0,n.jh)(g.x,f.y,p.x).add(g.y).add(f.x).mul(p.y),(0,n.jh)(g.w,f.z,p.x).add(g.z).add(f.w),(0,n.jh)(y.x,x.y,p.x).add(y.y).add(x.x),(0,n.jh)(y.w,x.z,p.x).add(y.z).add(x.w).mul(p.y.oneMinus())).mul(1/9)}),y=(0,i.Fn)(({depthTexture:e,shadowCoord:t,depthLayer:r},s)=>{let l=(0,a.wH)(e).sample(t.xy);e.isArrayTexture&&(l=l.depth(r));let u=(l=l.rg).x,h=(0,n.T9)(1e-7,l.y.mul(l.y)),d=s.renderer.reversedDepthBuffer?(0,n.PM)(u,t.z):(0,n.PM)(t.z,u),c=(0,i.fVC)(1).toVar();return(0,i.If)(d.notEqual(1),()=>{let e=t.z.sub(u),r=h.div(h.add(e.mul(e)));r=(0,n.qE)((0,o.jb)(r,.3).div(.65)),c.assign((0,n.T9)(d,r))}),c}),x=e=>{let t=p.get(e);return void 0===t&&((t=new u.A).colorNode=(0,i.lnd)(0,0,0,1),t.isShadowPassMaterial=!0,t.name="ShadowMaterial",t.blending=c.XIg,t.fog=!1,p.set(e,t)),t},b=e=>{let t=p.get(e);void 0!==t&&(t.dispose(),p.delete(e))}},63300:(e,t,r)=>{r(13662),r(96285),r(75180),r(27300),r(61296),r(74872),r(2945),r(29892).Ay},64139:(e,t,r)=>{r.d(t,{z:()=>u});var i=r(95538),s=r(13662),a=r(96621),n=r(96201);let o=null;class l extends i.Ay{static get type(){return"ViewportDepthTextureNode"}constructor(e=a.m1,t=null,r=null){null===r&&(null===o&&(o=new n.V),r=o),super(e,t,r)}}let u=(0,s.Hmo)(l).setParameterLength(0,3)},64551:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(57218);class s extends i.A{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}let a=s},64994:(e,t,r)=>{r.d(t,{A:()=>o,l:()=>l});var i=r(57218),s=r(13662),a=r(51365);class n extends i.A{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,a.R8)(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r);{let i=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(i),n=e.getAttribute(t,a);return"vertex"===e.shaderStage?e.format(n.name,a,r):(0,s.PCg)(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 o=n,l=(e,t=null)=>new n(e,t)},65415:(e,t,r)=>{r.d(t,{P:()=>a});var i=r(51166),s=r(51365);class a{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,s,a,n){let o=r[i+0],l=r[i+1],u=r[i+2],h=r[i+3],d=s[a+0],c=s[a+1],p=s[a+2],m=s[a+3];if(h!==m||o!==d||l!==c||u!==p){let e=o*d+l*c+u*p+h*m;e<0&&(d=-d,c=-c,p=-p,m=-m,e=-e);let t=1-n;if(e<.9995){let r=Math.acos(e),i=Math.sin(r);o=o*(t=Math.sin(t*r)/i)+d*(n=Math.sin(n*r)/i),l=l*t+c*n,u=u*t+p*n,h=h*t+m*n}else{let e=1/Math.sqrt((o=o*t+d*n)*o+(l=l*t+c*n)*l+(u=u*t+p*n)*u+(h=h*t+m*n)*h);o*=e,l*=e,u*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,r,i,s,a){let n=r[i],o=r[i+1],l=r[i+2],u=r[i+3],h=s[a],d=s[a+1],c=s[a+2],p=s[a+3];return e[t]=n*p+u*h+o*c-l*d,e[t+1]=o*p+u*d+l*h-n*c,e[t+2]=l*p+u*c+n*d-o*h,e[t+3]=u*p-n*h-o*d-l*c,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}
vendor: 4,246 bytes, line 480
480set(e,t,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let r=e._x,i=e._y,a=e._z,n=e._order,o=Math.cos,l=Math.sin,u=o(r/2),h=o(i/2),d=o(a/2),c=l(r/2),p=l(i/2),m=l(a/2);switch(n){case"XYZ":this._x=c*h*d+u*p*m,this._y=u*p*d-c*h*m,this._z=u*h*m+c*p*d,this._w=u*h*d-c*p*m;break;case"YXZ":this._x=c*h*d+u*p*m,this._y=u*p*d-c*h*m,this._z=u*h*m-c*p*d,this._w=u*h*d+c*p*m;break;case"ZXY":this._x=c*h*d-u*p*m,this._y=u*p*d+c*h*m,this._z=u*h*m+c*p*d,this._w=u*h*d-c*p*m;break;case"ZYX":this._x=c*h*d-u*p*m,this._y=u*p*d+c*h*m,this._z=u*h*m-c*p*d,this._w=u*h*d+c*p*m;break;case"YZX":this._x=c*h*d+u*p*m,this._y=u*p*d+c*h*m,this._z=u*h*m-c*p*d,this._w=u*h*d-c*p*m;break;case"XZY":this._x=c*h*d-u*p*m,this._y=u*p*d-c*h*m,this._z=u*h*m+c*p*d,this._w=u*h*d+c*p*m;break;default:(0,s.R8)("Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,r=t[0],i=t[4],s=t[8],a=t[1],n=t[5],o=t[9],l=t[2],u=t[6],h=t[10],d=r+n+h;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(u-o)*e,this._y=(s-l)*e,this._z=(a-i)*e}else if(r>n&&r>h){let e=2*Math.sqrt(1+r-n-h);this._w=(u-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(s+l)/e}else if(n>h){let e=2*Math.sqrt(1+n-r-h);this._w=(s-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+u)/e}else{let e=2*Math.sqrt(1+h-r-n);this._w=(a-i)/e,this._x=(s+l)/e,this._y=(o+u)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x),this._w=r,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs((0,i.qE)(this.dot(e),-1,1)))}rotateTowards(e,t){let r=this.angleTo(e);if(0===r)return this;let i=Math.min(1,t/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let r=e._x,i=e._y,s=e._z,a=e._w,n=t._x,o=t._y,l=t._z,u=t._w;return this._x=r*u+a*n+i*l-s*o,this._y=i*u+a*o+s*n-r*l,this._z=s*u+a*l+r*o-i*n,this._w=a*u-r*n-i*o-s*l,this._onChangeCallback(),this}slerp(e,t){let r=e._x,i=e._y,s=e._z,a=e._w,n=this.dot(e);n<0&&(r=-r,i=-i,s=-s,a=-a,n=-n);let o=1-t;if(n<.9995){let e=Math.acos(n),l=Math.sin(e);o=Math.sin(o*e)/l,t=Math.sin(t*e)/l,this._x=this._x*o+r*t,this._y=this._y*o+i*t,this._z=this._z*o+s*t,this._w=this._w*o+a*t,this._onChangeCallback()}else this._x=this._x*o+r*t,this._y=this._y*o+i*t,this._z=this._z*o+s*t,this._w=this._w*o+a*t,this.normalize();return this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}
480_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}},65462:(e,t,r)=>{r.d(t,{A:()=>s});var i=r(13662);let s=(0,i.Fn)(({f:e,f90:t,dotVH:r})=>{let s=r.oneMinus().saturate(),a=s.mul(s),n=s.mul(a,a).clamp(0,.9999);return e.sub((0,i.eR5)(t).mul(n)).div(n.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]})},66133:(e,t,r)=>{r.d(t,{F:()=>c});var i=r(5092),s=r(39848),a=r(74872),n=r(61296),o=r(5542),l=r(13662);let u=(0,l.Fn)(({textureNode:e,bumpScale:t})=>{let r=t=>e.isolate().context({getUV:e=>t(e.uvNode||(0,s.uv)()),forceUVContext:!0}),i=(0,l.fVC)(r(e=>e));return(0,l.ZcS)((0,l.fVC)(r(e=>e.add(e.dFdx()))).sub(i),(0,l.fVC)(r(e=>e.add(e.dFdy()))).sub(i)).mul(t)}),h=(0,l.Fn)(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),l=s.dot(a).mul(o.hG),u=l.sign().mul(i.x.mul(a).add(i.y.mul(n)));return l.abs().mul(r).sub(u).normalize()});class d extends i.A{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 a.j8;let t=null!==this.scaleNode?this.scaleNode:1,r=u({textureNode:this.textureNode,bumpScale:t});return h({surf_pos:n.tX,surf_norm:a.j8,dHdxy:r})}}let c=(0,l.Hmo)(d).setParameterLength(1,2)},66318:(e,t,r)=>{r.d(t,{C4:()=>l,KD:()=>f,Vx:()=>d,lr:()=>g,vR:()=>u,yJ:()=>o});var i=r(13662),s=r(71115),a=r(81951),n=r(98121);let o=(0,i.Fn)(([e,t])=>e.mul(t).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),l=(0,i.Fn)(([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"}]}),u=(0,i.Fn)(([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"}]}),h=(0,i.Fn)(([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)}),d=(0,i.Fn)(([e,t])=>{let r=(0,i.w00)(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),s=(0,i.w00)(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=h(e=r.mul(e)),(e=s.mul(e)).clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),c=(0,i.w00)((0,i.eR5)(1.6605,-.1246,-.0182),(0,i.eR5)(-.5876,1.1329,-.1006),(0,i.eR5)(-.0728,-.0083,1.1187)),p=(0,i.w00)((0,i.eR5)(.6274,.0691,.0164),(0,i.eR5)(.3293,.9195,.088),(0,i.eR5)(.0433,.0113,.8956)),m=(0,i.Fn)(([e])=>{let t=(0,i.eR5)(e).toVar(),r=(0,i.eR5)(t.mul(t)).toVar(),s=(0,i.eR5)(r.mul(r)).toVar();return(0,i.fVC)(15.5).mul(s.mul(r)).sub((0,n.lK)(40.14,s.mul(t))).add((0,n.lK)(31.96,s).sub((0,n.lK)(6.868,r.mul(t))).add((0,n.lK)(.4298,r).add((0,n.lK)(.1191,t).sub(.00232))))}),g=(0,i.Fn)(([e,t])=>{let r=(0,i.eR5)(e).toVar(),s=(0,i.w00)((0,i.eR5)(.856627153315983,.137318972929847,.11189821299995),(0,i.eR
4805)(.0951212405381588,.761241990602591,.0767994186031903),(0,i.eR5)(.0482516061458583,.101439036467562,.811302368396859)),n=(0,i.w00)((0,i.eR5)(1.1271005818144368,-.1413297634984383,-.14132976349843826),(0,i.eR5)(-.11060664309660323,1.157823702216272,-.11060664309660294),(0,i.eR5)(-.016493938717834573,-.016493938717834257,1.2519364065950405)),o=(0,i.fVC)(-12.47393),l=(0,i.fVC)(4.026069);return r.mulAssign(t),r.assign(p.mul(r)),r.assign(s.mul(r)),r.assign((0,a.T9)(r,1e-10)),r.assign((0,a.p6)(r)),r.assign(r.sub(o).div(l.sub(o))),r.assign((0,a.qE)(r,0,1)),r.assign(m(r)),r.assign(n.mul(r)),r.assign((0,a.n7)((0,a.T9)((0,i.eR5)(0),r),(0,i.eR5)(2.2))),r.assign(c.mul(r)),r.assign((0,a.qE)(r,0,1)),r}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),f=(0,i.Fn)(([e,t])=>{let r=(0,i.fVC)(.76),o=(0,i.fVC)(.15);e=e.mul(t);let l=(0,a.jk)(e.r,(0,a.jk)(e.g,e.b)),u=(0,s.L)(l.lessThan(.08),l.sub((0,n.lK)(6.25,l.mul(l))),.04);e.subAssign(u);let h=(0,a.T9)(e.r,(0,a.T9)(e.g,e.b));(0,i.If)(h.lessThan(r),()=>e);let d=(0,n.jb)(1,r),c=(0,n.jb)(1,d.mul(d).div(h.add(d.sub(r))));e.mulAssign(c.div(h));let p=(0,n.jb)(1,(0,n.y4)(1,o.mul(h.sub(c)).add(1)));return(0,a.jh)(e,(0,i.eR5)(c),p)}
480).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]})},66406:(e,t,r)=>{r.d(t,{Km:()=>d,d$:()=>h});var i=r(74872),s=r(71440),a=r(3443),n=r(13662),o=r(81951),l=r(21387),u=r(61296);let h=(0,n.w00)(s.bW,a.cr,i.j8).toVar("TBNViewMatrix"),d=(0,n.Fn)(()=>{let e=l.Lt.cross(u.Mv);return e=e.cross(l.Lt).normalize(),e=(0,o.jh)(e,i.j8,l.J_.mul(l.nR.oneMinus()).oneMinus().pow2().pow2()).normalize()}).once()()},66463:(e,t,r)=>{r.d(t,{A:()=>c});var i=r(61806),s=r(18385),a=r(2704),n=r(9404),o=r(51365);let l=new n.q(-1,1,1,-1,0,1);class u extends i.L{constructor(e=!1){super(),this.setAttribute("position",new s.qt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new s.qt(!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0],2))}}let h=new u;class d extends a.e{constructor(e=null){super(h,e),this.camera=l,this.isQuadMesh=!0}async renderAsync(e){(0,o.mc)('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,l)}render(e){e.render(this,l)}}let c=d},67850:(e,t,r)=>{r.d(t,{A:()=>u,M:()=>l});var i=r(57218),s=r(83815),a=r(13662),n=r(61296);class o extends i.A{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=s.KS.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){l.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||n.MI)}}let l=(0,a.MZ5)("vec3","shadowPositionWorld"),u=o},68929:(e,t,r)=>{let i,s,a,n;r.d(t,{dk:()=>p,pp:()=>c,rd:()=>m});var o=r(2945),l=r(79623),u=r(51365);let h=new l.d().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),d=new l.d().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),c=(i={enabled:!0,workingColorSpace:o.Zr2,spaces:{},convert:function(e,t,r){return!1!==this.enabled&&t!==r&&t&&r&&(this.spaces[t].transfer===o.KLL&&(e.r=p(e.r),e.g=p(e.g),e.b=p(e.b)),this.spaces[t].primaries!==this.spaces[r].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===o.KLL&&(e.r=m(e.r),e.g=m(e.g),e.b=m(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===o.jf0?o.VxR:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,r){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,t){return(0,u.mc)("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(e,t)},toWorkingColorSpace:function(e,t){return(0,u.mc)("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(e,t)}},s=[.64,.33,.3,.6,.15,.06],a=[.2126,.7152,.0722],n=[.3127,.329],i.define({[o.Zr2]:{primaries:s,whitePoint:n,transfer:o.VxR,toXYZ:h,fromXYZ:d,luminanceCoefficients:a,workingColorSpaceConfig:{unpackColorSpace:o.er$},outputColorSpaceConfig:{drawingBufferColorSpace:o.er$}},[o.er$]:{primaries:s,whitePoint:n,transfer:o.KLL,toXYZ:h,fromXYZ:d,luminanceCoefficients:a,outputColorSpaceConfig:{drawingBufferColorSpace:o.er$}}}),i);function p(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function m(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}},68987:(e,t,r)=>{var i=r(57218);r(69363),r(12106),i.A},69247:(e,t,r)=>{var i=r(57218),s=r(4470),a=r(12106);
480class n extends i.A{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,a=this.getNodeType(e),n=this.getInputType(e),o=this.pointerNode,l=this.valueNode,u=[];u.push(`&${o.build(e,n)}`),null!==l&&u.push(l.build(e,n));let h=`${e.getMethod(i,a)}( ${u.join(", ")} )`;if(!(r&&1===r.length&&!0===r[0].isStackNode))return void 0===t.constNode&&(t.constNode=(0,s.d)(h,a).toConst()),t.constNode.build(e);e.addLineFlowCode(h,this)}}n.ATOMIC_LOAD="atomicLoad",n.ATOMIC_STORE="atomicStore",n.ATOMIC_ADD="atomicAdd",n.ATOMIC_SUB="atomicSub",n.ATOMIC_MAX="atomicMax",n.ATOMIC_MIN="atomicMin",n.ATOMIC_AND="atomicAnd",n.ATOMIC_OR="atomicOr",n.ATOMIC_XOR="atomicXor",(0,a.Hm)(n)},69363:(e,t,r)=>{var i=r(57218);r(79699),i.A},69707:(e,t,r)=>{r.d(t,{A:()=>a});let i=[/^StackTrace\.js$/,/^TSLCore\.js$/,/^.*Node\.js$/,/^three\.webgpu.*\.js$/];class s{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&&!i.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} 481${t}`}}let a=s},70215:(e,t,r)=>{r.d(t,{Ay:()=>n});var i=r(40786);r(13662);var s=r(83815);class a extends i.Ay{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=s.pF.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}
481setMipLevel(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(s.pF.READ_WRITE)}toReadOnly(){return this.setAccess(s.pF.READ_ONLY)}toWriteOnly(){return this.setAccess(s.pF.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 n=a},71115:(e,t,r)=>{r.d(t,{L:()=>l});var i=r(57218),s=r(21387),a=r(12106),n=r(51365);class o extends i.A{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:a,ifNode:o,elseNode:l}=e.getNodeProperties(this),u=e.currentFunctionNode,h="void"!==t,d=h?(0,s.MZ)(r).build(e):"";i.nodeProperty=d;let c=a.build(e,"bool");if(e.context.uniformFlow&&null!==l){let i=o.build(e,r),s=l.build(e,r),a=e.getTernary(c,i,s);return e.format(a,r,t)}e.addFlowCode(` 482${e.tab}if ( ${c} ) { 483 484`).addFlowTab();let p=o.build(e,r);if(p&&(h?p=d+" = "+p+";":(p="return "+p+";",null===u&&((0,n.R8)("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),p="// "+p))),e.removeFlowTab().addFlowCode(e.tab+" "+p+"\n\n"+e.tab+"}"),null!==l){e.addFlowCode(" else {\n\n").addFlowTab();let t=l.build(e,r);t&&(h?t=d+" = "+t+";":(t="return "+t+";",null===u&&((0,n.R8)("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 l=(0,a.Hm)(o).setParameterLength(2,3);(0,a.mV)("select",l)},71440:(e,t,r)=>{r.d(t,{bW:()=>h,d8:()=>u,km:()=>l});var i=r(64994);r(75180);var s=r(27300),a=r(13662),n=r(56169),o=r(5542);let l=(0,i.l)("tangent","vec4"),u=l.xyz.toVar("tangentLocal"),h=(0,a.Fn)(e=>{let t;return t="VERTEX"===e.subBuildFn||e.geometry.hasAttribute("tangent")?s.SP.mul((0,a.lnd)(u,0)).xyz.toVarying("v_tangentView").normalize():n.k,!0!==e.isFlatShading()&&(t=(0,o.Mg)(t)),t},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView")},71497:(e,t,r)=>{r.d(t,{V:()=>o});var i=r(98786),s=r(2945),a=r(50782),n=r(46956);class o extends i.i{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new a.Q(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new n.O,this.combine=s.caT,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}},72156:(e,t,r)=>{r.d(t,{A:()=>n});var i=r(5092),s=r(83815);class a extends i.A{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,a=this.getNodeType(e),n=e.getComponentType(i.getNodeType(e)),o=e.getTypeFromLength(r.length,n),l=i.build(e,o),u=t.build(e,a),h=e.getTypeLength(a),d=[];for(let e=0;e<h;e++){let t=s.Iy[e];t===r[0]?(d.push(l),e+=r.length-1):d.push(u+"."+t)}return`${e.getType(a)}( ${d.join(", ")} )`}}let n=a},73705:(e,t,r)=>{r.d(t,{Ay:()=>h,ir:()=>d});var i=r(57218),s=r(83815),a=r(61114),n=r(12106),o=r(15907);class l extends o.A{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 u extends i.A{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=s.KS.OBJECT}setGroup(e){return this.group=e,this}element(e){return new l(this,(0,n.mp)(e))}setNodeType(e){let t=(0,a.P)(null,e);null!==this.group&&t.setGroup(this.group),this.node=t}generateNodeType(e){return null===this.node&&(this.updateReference(e),this.updateV
484alue()),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 h=u,d=(e,t,r)=>new u(e,t,r)},74872:(e,t,r)=>{r.d(t,{I9:()=>b,O7:()=>f,Rv:()=>p,ar:()=>m,j8:()=>g,mb:()=>h,qs:()=>x,vu:()=>y,xg:()=>d});var i=r(64994),s=r(75180),a=r(27300),n=r(13662),o=r(61296),l=r(5542),u=r(51365);let h=(0,i.l)("normal","vec3"),d=(0,n.Fn)(e=>!1===e.geometry.hasAttribute("normal")?((0,u.R8)('TSL: Vertex attribute "normal" not found on geometry.'),(0,n.eR5)(0,1,0)):h,"vec3").once()().toVar("normalLocal"),c=o.tX.dFdx().cross(o.tX.dFdy()).normalize().toVar("normalFlat"),p=(0,n.Fn)(e=>e.isFlatShading()?c:b(d).toVarying("v_normalViewGeometry").normalize(),"vec3").once()().toVar("normalViewGeometry"),m=(0,n.Fn)(e=>{let t=p.transformNormalByInverseViewMatrix(s.S3);return!0!==e.isFlatShading()&&(t=t.toVarying("v_normalWorldGeometry")),t.normalize().toVar("normalWorldGeometry")},"vec3").once()(),g=(0,n.Fn)(e=>{let t;return"NORMAL"===e.subBuildFn||"VERTEX"===e.subBuildFn?(t=p,!0!==e.isFlatShading()&&(t=(0,l.Mg)(t))):t=e.context.setupNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),f=g.transformNormalByInverseViewMatrix(s.S3).toVar("normalWorld"),y=(0,n.Fn)(({subBuildFn:e,context:t})=>"NORMAL"===e||"VERTEX"===e?g:t.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),x=(0,n.Fn)(([e,t=a.n6])=>(0,n.w00)(t).inverse().transpose().mul(e).normalize());(0,n.mVC)("transformNormal",x);let b=(0,n.Fn)(([e],t)=>{let r=t.context.modelNormalViewMatrix;return r?e.transformNormalByViewMatrix(r):a.ID.mul(e).transformNormalByViewMatrix(s.S3)});(0,n.Fn)(()=>((0,u.R8)('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),g)).once(["NORMAL","VERTEX"])(),(0,n.Fn)(()=>((0,u.R8)('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),f)).once(["NORMAL","VERTEX"])(),(0,n.Fn)(()=>((0,u.R8)('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),y)).once(["NORMAL","VERTEX"])()},75180:(e,t,r)=>{r.d(t,{FL:()=>M,Ir:()=>v,Kz:()=>T,S3:()=>A,fr:()=>w,oA:()=>S,xV:()=>_});var i=r(61114),s=r(24481),a=r(26609),n=r(13662),o=r(61046),l=r(96798);r(96621);let u=null,h=null,d=null,c=null,p=null,m=null,g=null,f=null,y=null,x=null,b=(0,i.P)(0,"uint").setName("u_cameraIndex").setGroup((0,s.XA)("cameraIndex")).toVarying("v_cameraIndex"),v=(0,i.P)("float").setName("cameraNear").setGroup(s.sx).onRenderUpdate(({camera:e})=>e.near),_=(0,i.P)("float").setName("cameraFar").setGroup(s.sx).onRenderUpdate(({camera:e})=>e.far),T=(0,n.Fn)(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.projectionMatrix);null===h?h=(0,o.W)(r).setGroup(s.sx).setName("cameraProjectionMatrices"):h.array=r,t=h.element(e.isMultiViewCamera?(0,l.S)("gl_ViewID_OVR"):b)}else null===u&&(u=(0,i.P)(e.projectionMatrix).setName("cameraProjectionMatrix").setGroup(s.sx).onRenderUpdate(({camera:e})=>e.projectionMatrix)),t=u;return t}).once()(),S=(0,n.Fn)(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.projectionMatrixInverse);null===c?c=(0,o.W)(r).setGroup(s.sx).setName("cameraProjectionMatricesInverse"):c.array=r,t=c.element(e.isMultiViewCamera?(0,l.S)("gl_ViewID_OVR"):b)}else null===d&&(d=(0,i.P)(e.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(s.sx).onRenderUpdate(({camera:e})=>e.projectionMatrixInverse)),t=d;return t}).once()(),A=(0,n.Fn)(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.matrixWorldInverse);null===m?m=(0,o.W)(r).setGroup(s.sx).setName("cameraViewMatrices"):m.array=r,t=m.element(e.isMultiViewCamera?(0,l.S)("gl_ViewID_OVR"):b)}else null===p&&(p=(0,i.P)(e.matrixWorldInverse).setName("cameraViewMatrix").setGroup(s.sx).onRenderUpd
484ate(({camera:e})=>e.matrixWorldInverse)),t=p;return t}).once()(),M=(0,n.Fn)(({camera:e})=>{let t;if(e.isArrayCamera&&e.cameras.length>0){let r=[];for(let t of e.cameras)r.push(t.matrixWorld);null===f?f=(0,o.W)(r).setGroup(s.sx).setName("cameraWorldMatrices"):f.array=r,t=f.element(e.isMultiViewCamera?(0,l.S)("gl_ViewID_OVR"):b)}else null===g&&(g=(0,i.P)(e.matrixWorld).setName("cameraWorldMatrix").setGroup(s.sx).onRenderUpdate(({camera:e})=>e.matrixWorld)),t=g;return t}).once()(),w=(0,n.Fn)(({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 a.P);null===x?x=(0,o.W)(r).setGroup(s.sx).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)}):x.array=r,t=x.element(e.isMultiViewCamera?(0,l.S)("gl_ViewID_OVR"):b)}else null===y&&(y=(0,i.P)(new a.P).setName("cameraPosition").setGroup(s.sx).onRenderUpdate(({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld))),t=y;return t}).once()()},77168:(e,t,r)=>{var i=r(57218);r(13662),i.A},78771:(e,t,r)=>{var i=r(5092),s=r(12106),a=r(51365);class n extends i.A{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,a.Rm)(s)}return r}}(0,s.mV)("debug",(e,t=null)=>new n((0,s.mp)(e),t).toStack())},78879:(e,t,r)=>{r.d(t,{YH:()=>o,hH:()=>n});var i=r(5092),s=r(12106);class a extends i.A{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 n=(0,s.xA)(a).setParameterLength(2),o=e=>new a(e,"uint","float")},79623:(e,t,r)=>{r.d(t,{d:()=>s});var i=r(51365);class s{static{s.prototype.isMatrix3=!0}constructor(e,t,r,i,s,a,n,o,l){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,r,i,s,a,n,o,l)}set(e,t,r,i,s,a,n,o,l){let u=this.elements;return u[0]=e,u[1]=i,u[2]=n,u[3]=t,u[4]=s,u[5]=o,u[6]=r,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let r=e.elements,i=t.elements,s=this.elements,a=r[0],n=r[3],o=r[6],l=r[1],u=r[4],h=r[7],d=r[2],c=r[5],p=r[8],m=i[0],g=i[3],f=i[6],y=i[1],x=i[4],b=i[7],v=i[2],_=i[5],T=i[8];return s[0]=a*m+n*y+o*v,s[3]=a*g+n*x+o*_,s[6]=a*f+n*b+o*T,s[1]=l*m+u*y+h*v,s[4]=l*g+u*x+h*_,s[7]=l*f+u*b+h*T,s[2]=d*m+c*y+p*v,s[5]=d*g+c*x+p*_,s[8]=d*f+c*b+p*T,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],u=e[8];return t*a*u-t*n*l-r*s*u+r*n*o+i*s*l-i*a*o}invert(){let e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],n=e[5],o=e[6],l=e[7],u=e[8],h=u*a-n*l,d=n*o-u*s,c=l*s-a*o,p=t*h+r*d+i*c;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=h*m,e[1]=(i*l-u*r)*m,e[2]=(n*r-i*a)*m,e[3]=d*m,e[4]=(u*t-i*o)*m,e[5]=(i*s-n*t)*m,e[6]=c*m,e[7]=(r*o-l*t)*m,e[8]=(a*t-r*s)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,r,i,s,a,n){let o=Math.cos(s),l=Math.sin(s);return this.set(r*o,r*l,-r*(o*a+l*n)+a+e,-i*l,i*o,-i*(-l*a+o*n)+n+t,0,0,1),this}scale(e,t){return(0,i.mc)("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(a.makeScale(e,t)),this}rotate(e){return(0,i.mc)("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(a.makeRotation(-e)),this}translate(e,t){return(0,i.mc)("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(a.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,r=e.elements;for(let e=0;e<9;e++)if(t[e]!==r[e])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){let r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}let a=new s},79699:(e,t,r)=>{r.d(t,{AZ:()=>_,Hq:()=>x,YZ:()=>p,Yi:()=>A,aC:()=>S,cZ:()=>b,g0:()=>m,sz:()=>v,tW:()=>g,yI:()=>T});var i=r(50782),s=r(88500),a=r(79623),n=r(26990),o=r(96310),l=r(26609),u=r(25756),h=r(51365),d=r(69707);function c(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 p=e=>c(e),m=e=>c(e),g=(...e)=>c(e),f=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),y=new WeakMap;function x(e){return f.get(e)}function b(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)?12:/mat4/.test(e)?16:void(0,h.z3)(`TSL: Unsupported type: ${e}`,new d.A)}function v(e){return/float|int|uint|bool/.test(e)?1:/vec2/.test(e)?2:/vec3/.test(e)||/vec4/.test(e)?4:/mat2/.test(e)?2:/mat3/.test(e)||/mat4/.test(e)?4:void(0,h.z3)(`TSL: Unsupported type: ${e}`,new d.A)}function _(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 T(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 i.Q(...t);if("vec2"===r)return new o.I(...t);if("vec3"===r)return new l.P(...t);if("vec4"===r)return new u.I(...t);if("mat2"===r)return new s.k(...t);else if("mat3"===r)return new a.d(...t);else if("mat4"===r)return new n.k(...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 h;return h=t[0],Uint8Array.from(atob(h),e=>e.charCodeAt(0)).buffer}return null}function S(e){let t=y.get(e);return void 0===t&&(t={},y.set(e,t)),t}function A(e){let t="",r=new Uint8Array(e);for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return btoa(t)}},79907:(e,t,r)=>{r.d(t,{Z:()=>y});var i=r(83965),s=r(2704),a=r(6593),n=r(26990),o=r(93998),l=r(53104),u=r(2945);let h=new n.k,d=new n.k,c=[],p=new a.N,m=new n.k,g=new s.e,f=new o.i;class y extends s.e{constructor(e,t,r){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new i.u(new Float32Array(16*r),
48416),this.instanceColor=null,this.morphTexture=null,this.count=r,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<r;e++)this.setMatrixAt(e,m)}computeBoundingBox(){let e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new a.N),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,h),p.copy(e.boundingBox).applyMatrix4(h),this.boundingBox.union(p)}computeBoundingSphere(){let e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new o.i),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let r=0;r<t;r++)this.getMatrixAt(r,h),f.copy(e.boundingSphere).applyMatrix4(h),this.boundingSphere.union(f)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.morphTexture&&(this.morphTexture=e.morphTexture.clone()),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return null===this.instanceColor?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,16*e)}getMorphAt(e,t){let r=t.morphTargetInfluences,i=this.morphTexture.source.data.data,s=e*(r.length+1)+1;for(let e=0;e<r.length;e++)r[e]=i[s+e]}raycast(e,t){let r=this.matrixWorld,i=this.count;if((g.geometry=this.geometry,g.material=this.material,void 0!==g.material)&&(null===this.boundingSphere&&this.computeBoundingSphere(),f.copy(this.boundingSphere),f.applyMatrix4(r),!1!==e.ray.intersectsSphere(f)))for(let s=0;s<i;s++){this.getMatrixAt(s,h),d.multiplyMatrices(r,h),g.matrixWorld=d,g.raycast(e,c);for(let e=0,r=c.length;e<r;e++){let r=c[e];r.instanceId=s,r.object=this,t.push(r)}c.length=0}}setColorAt(e,t){return null===this.instanceColor&&(this.instanceColor=new i.u(new Float32Array(3*this.instanceMatrix.count).fill(1),3)),t.toArray(this.instanceColor.array,3*e),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,16*e),this}setMorphAt(e,t){let r=t.morphTargetInfluences,i=r.length+1;null===this.morphTexture&&(this.morphTexture=new l.G(new Float32Array(i*this.count),i,this.count,u.VT0,u.RQf));let s=this.morphTexture.source.data.data,a=0;for(let e=0;e<r.length;e++)a+=r[e];let n=this.geometry.morphTargetsRelative?1:1-a,o=i*e;return s[o]=n,s.set(r,o+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null)}}},80904:(e,t,r)=>{r.d(t,{G_:()=>l,ow:()=>o});var i=r(57218),s=r(83815);class a extends i.A{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===a.OBJECT?this.updateType=s.KS.OBJECT:e===a.MATERIAL?this.updateType=s.KS.RENDER:e===a.FRAME?this.updateType=s.KS.FRAME:e===a.BEFORE_OBJECT?this.updateBeforeType=s.KS.OBJECT:e===a.BEFORE_MATERIAL?this.updateBeforeType=s.KS.RENDER:e===a.BEFORE_FRAME&&(this.updateBeforeType=s.KS.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}a.OBJECT="object",a.MATERIAL="material",a.FRAME="frame",a.BEFORE_OBJECT="beforeObject",a.BEFORE_MATERIAL="beforeMaterial",a.BEFORE_FRAME="beforeFrame";let n=(e,t)=>new a(e,t).toStack(),o=e=>n(a.OBJECT,e),l=e=>n(a.FRAME,e)},81951:(e,t,r)=>{r.d(t,{$A:()=>ea,Ay:()=>u,BU:()=>q,Bw:()=>z,DL:()=>eh,F8:()=>w,HQ:()=>V,Ib:()=>$,Ie:()=>y,Ih:()=>ep,NB:()=>X,Om:()=>es,PM:()=>ee,Pu:()=>W,RI:()=>T,RZ:()=>v,Rm:()=>x,S8:()=>A,T9:()=>J,TF:()=>eg,e:()=>em,gn:()=>N,jc:()=>M,jh:()=>ed,jk:()=>Q,mk:()=>S,n7:()=>en,oN:()=>f,p6:()=>b,p8:()=>h,qE:()=>ec,rY:()=>I,tn:()=>D,zH:()=>eo,zW:()=>el,ze:()=>k});var i=r(5092),s=r(98121),a=r(12106),n=r(2945),o=r(51365);class l extends i.A{static get type(){return"MathNode"}constructor(e,t,r=null,i=null){if(super(),(e===l.MAX||e===l.MIN)&&arguments.length>3){let s=new l(e,t,r);for(let t=3;t<arguments.length-1;t++)s=new l(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===l.LENGTH||t===l.DISTANCE||t===l.DOT?"float":t===l.CROSS?"vec3":t===l.ALL||t===l.ANY?"bool":t===l.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){let{aNode:t,bNode:r,method:i}=this,n=null;if(i===l.ONE_MINUS)n=(0,s.jb)(1,t);else if(i===l.RECIPROCAL)n=(0,s.y4)(1,t);else if(i===l.DIFFERENCE)n=D((0,s.jb)(t,r));else if(i===l.TRANSFORM_DIRECTION){let i,o;e.isMatrix(t.getNodeType(e))?(i=t,o=r):(i=r,o=t),n=A((0,s.lK)(i,(0,a.ln)((0,a.eR)(o),0)).xyz)}return null!==n?n: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,u=this.bNode,h=this.cNode,d=e.renderer.coordinateSystem;if(r===l.NEGATE)return e.format("( - "+a.build(e,s)+" )",i,t);{let c=[];return r===l.CROSS?c.push(a.build(e,i),u.build(e,i)):d===n.TdN&&r===l.STEP?c.push(a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":s),u.build(e,s)):d===n.TdN&&(r===l.MIN||r===l.MAX)?c.push(a.build(e,s),u.build(e,1===e.getTypeLength(u.getNodeType(e))?"float":s)):r===l.REFRACT?c.push(a.build(e,s),u.build(e,s),h.build(e,"float")):r===l.MIX?c.push(a.build(e,s),u.build(e,s),h.build(e,1===e.getTypeLength(h.getNodeType(e))?"float":s)):(d===n.i7u&&r===l.ATAN&&null!==u&&(r="atan2"),"fragment"!==e.shaderStage&&(r===l.DFDX||r===l.DFDY)&&((0,o.R8)(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),r="/*"+r+"*/"),c.push(a.build(e,s)),null!==u&&c.push(u.build(e,s)),null!==h&&c.push(h.build(e,s))),e.format(`${e.getMethod(r,i)}( ${c.join(", ")} )`,i,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}l.ALL="all",l.ANY="any",l.RADIANS="radians",l.DEGREES="degrees",l.EXP="exp",l.EXP2="exp2",l.LOG="log",l.LOG2="log2",l.SQRT="sqrt",l.INVERSE_SQRT="inversesqrt",l.FLOOR="floor",l.CEIL="ceil",l.NORMALIZE="normalize",l.FRACT="fract",l.SIN="sin",l.SINH="sinh",l.COS="cos",l.COSH="cosh",l.TAN="tan",l.TANH="tanh",l.ASIN="asin",l.ASINH="asinh",l.ACOS="acos",l.ACOSH="acosh",l.ATAN="atan",l.ATANH="atanh",l.ABS="abs",l.SIGN="sign",l.LENGTH="length",l.NEGATE="negate",l.ONE_MINUS="oneMinus",l.DFDX="dFdx",l.DFDY="dFdy",l.ROUND="round",l.RECIPROCAL="reciprocal",l.TRUNC="trunc",l.FWIDTH="fwidth",l.TRANSPOSE="transpose",l.DETERMINANT="determinant",l.INVERSE="inverse",l.EQUALS="equals",l.MIN="min",l.MAX="max",l.STEP="step",l.REFLECT="reflect",l.DISTANCE="distance",l.DIFFERENCE="difference",l.DOT="dot",l.CROSS="cross",l.POW="pow",l.TRANSFORM_DIRECTION="transformDirection",l.MIX="mix",l.CLAMP="clamp",l.REFRACT="refract",l.SMOOTHSTEP="smoothstep",l.FACEFORWARD="faceforward";let u=l,h=(0,a.fV)(1e-6),d=(0,a.fV)(Math.PI),c=(0,a.xA)(l,l.ALL).setParameterLength(1),p=(0,a.xA)(l,l.ANY).setParameterLength(1),m=(0,a.xA)(l,l.RADIANS).setParameterLength(1),g=(0,a.xA)(l,l.DEGREES).setParameterLength(1),f=(0,a.xA)(l,l.EXP).setParameterLength(1),y=(0,a.xA)(l,l.EXP2).setParameterLength(1),x=(0,a.xA)(l,l.LOG).setParameterLength(1),b=(0,a.xA)(l,l.LOG2).setParameterLength(1),v=(0,a.xA)(l,l.SQRT).setParameterLength(1),_=(0,a.xA)(l,l.INVERSE_SQRT).setParameterLength(1),T=(0,a.xA)(l,l.FLOOR).setParameterLength(1),S=(0,a.xA)(l,l.CEIL).setParameterLength(1),A=(0,a.xA)(l,l.NORMALIZE).setParameterLength(1),M=(0,a.xA)(l,l.FRACT).setParameterLength(1),w=(0,a.xA)(l,l.SIN).setParameterLength(1),R=(0,a.xA)(l,l.SINH).setParameterLength(1),N=(0,a.xA)(l,l.COS).setParameterLength(1),C=(0,a.xA)(l,l.COSH).setParameterLength(1),E=(0,a.xA)(l,l.TAN).setParameterLength(1),F=(0,a.xA)(l,l.TANH).setParameterLength(1),B=(0,a.xA)(l,l.ASIN).setParameterLength(1),P=(0,a.xA)(l,l.ASINH).setParameterLength(1),V=(0,a.xA)(l,l.ACOS).setParameterLength(1),L=(0,a.xA)(l,l.ACOSH).setParameterLength(1),I=(0,a.xA)(l,l.ATAN).setParameterLength(1,2),O=(0,a.xA)(l,l.ATANH).setParameterLength(1),D=(0,a.xA)(l,l.ABS).setParameterLength(1),U=(0,a.xA)(l,l.SIGN).setParameterLength(1),z=(0,a.xA)(l,l.LENGTH).setParameterLength(1),k=(0,a.xA)(l,l.NEGATE).setParameterLength(1),G=(0,a.xA)(l,l.ONE_MINUS).setParameterLength(1),W=(0,a.xA)(l,l.DFDX).setParameterLength(1),$=(0,a.xA)(l,l.DFDY).setParameterLength(1),H=(0,a.xA)(l,l.ROUND).setParameterLength(1),j=(0,a.xA)(l,l.RECIPROCAL).setParameterLength(1),q=(0,a.xA)(l,l.TRUNC).setParameterLength(1),X=(0,a.xA)(l,l.FWIDTH).setParameterLength(1),K=(0,a.xA)(l,l.TRANSPOSE).setParameterLength(1),Y=(0,a.xA)(l,l.DETERMINANT).setParameterLength(1),Z=(0,a.xA)(l,l.INVERSE).setParameterLength(1),Q=(0,a.xA)(l,l.MIN).setParameterLength(2,1/0),J=(0,a.xA)(l,l.MAX).setParameterLength(2,1/0),ee=(0,a.xA)(l,l.STEP).setParameterLength(2),et=(0,a.xA)(l,l.REFLECT).setParameterLength(2),er=(0,a.xA)(l,l.DISTANCE).setParameterLength(2),ei=(0,a.xA)(l,l.DIFFERENCE).setParameterLength(2),es=(0,a.xA)(l,l.DOT).setParameterLength(2),ea=(0,a.xA)(l,l.CROSS).setParameterLength(2),en=(0,a.xA)(l,l.POW).setParameterLength(2),eo=e=>(0,s.lK)(e,e),el=e=>(0,s.lK)(e,e,e,e),eu=(0,a.xA)(l,l.TRANSFORM_DIRECTION).setParameterLength(2),eh=e=>es(e,e),ed=(0,a.xA)(l,l.MIX).setParameterLength(3),ec=(e,t=0,r=1)=>new l(l.CLAMP,(0,a.mp)(e),(0,a.mp)(t),(0,a.mp)(r)),ep=e=>ec(e),em=(0,a.xA)(l,l.REFRACT).setParameterLength(3),eg=(0,a.xA)(l,l.SMOOTHSTEP).setParameterLength(3),ef=(0,a.xA)(l,l.FACEFORWARD).setParameterLength(3),ey=(0,a.Fn)(([e])=>{let t=es(e.xy,(0,a.Zc)(12.9898,78.233));return M(w((0,s.zi)(t,d)).mul(43758.5453))});(0,a.mV)("all",c),(0,a.mV)("any",p),(0,a.mV)("radians",m),(0,a.mV)("degrees",g),(0,a.mV)("exp",f),(0,a.mV)("exp2",y),(0,a.mV)("log",x),(0,a.mV)("log2",b),(0,a.mV)("sqrt",v),(0,a.mV)("inverseSqrt",_),(0,a.mV)("floor",T),(0,a.mV)("ceil",S),(0,a.mV)("normalize",A),(0,a.mV)("fract",M),(0,a.mV)("sin",w),(0,a.mV)("sinh",R),(0,a.mV)("cos",N),(0,a.mV)("cosh",C),(0,a.mV)("tan",E),(0,a.mV)("tanh",F),(0,a.mV)("asin",B),(0,a.mV)("asinh",P),(0,a.mV)("acos",V),(0,a.mV)("acosh",L),(0,a.mV)("atan",I),(0,a.mV)("atanh",O),(0,a.mV)("abs",D),(0,a.mV)("sign",U),(0,a.mV)("length",z),(0,a.mV)("lengthSq",eh),(0,a.mV)("negate",k),(0,a.mV)("oneMinus",G),(0,a.mV)("dFdx",W),(0,a.mV)("dFdy",$),(0,a.mV)("round",H),(0,a.mV)("reciprocal",j),(0,a.mV)("trunc",q),(0,a.mV)("fwidth",X),(0,a.mV)("min",Q),(0,a.mV)("max",J),(0,a.mV)("step",(e,t)=>ee(t,e)),(0,a.mV)("reflect",et),(0,a.mV)("distance",er),(0,a.mV)("dot",es),(0,a.mV)("cross",ea),(0,a.mV)("pow",en),(0,a.mV)("pow2",eo),(0,a.mV)("pow3",e=>(0,s.lK)(e,e,e)),(0,a.mV)("pow4",el),(0,a.mV)("transformDirection",eu),(0,a.mV)("transformNormalByViewMatrix",(e,t)=>A((0,s.lK)(t,(0,a.ln)((0,a.eR)(e),0)).xyz)),(0,a.mV)("transformNormalByInverseViewMatrix",(e,t)=>A((0,a.ln)((0,a.eR)(e),0).mul(t).xyz)),(0,a.mV)("mix",(e,t,r)=>ed(t,r,e)),(0,a.mV)("clamp",ec),(0,a.mV)("refract",em),(0,a.mV)("smoothstep",(e,t,r)=>eg(t,r,e)),(0,a.mV)("faceForward",ef),(0,a.mV)("difference",ei),(0,a.mV)("saturate",ep),(0,a.mV)("cbrt",e=>(0,s.lK)(U(e),en(D(e),1/3))),(0,a.mV)("transpose",K),(0,a.mV)("determinant",Y),(0,a.mV)("inverse",Z),(0,a.mV)("rand",ey)},82196:(e,t,r)=>{r.d(t,{Aj:()=>p,Kj:()=>u,ME:()=>h,Ps:()=>m,ae:()=>d,gY:()=>c,yr:()=>f});var i=r(57218),s=r(13662),a=r(75180),n=r(61296),o=r(64139);class l extends i.A{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===l.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){let{scope:t}=this,r=this.valueNode,i=null;return t===l.DEPTH_BASE?null!==r&&(i=g().assign(r)):t===l.DEPTH?i=e.isPerspectiveCamera?d(n.tX.z,a.Ir,a.xV):u(n.tX.z,a.Ir,a.xV):t===l.LINEAR_DEPTH&&(i=null!==r?e.
484isPerspectiveCamera?u(p(r,a.Ir,a.xV),a.Ir,a.xV):r:u(n.tX.z,a.Ir,a.xV)),i}}l.DEPTH_BASE="depthBase",l.DEPTH="depth",l.LINEAR_DEPTH="linearDepth";let u=(e,t,r)=>e.add(t).div(t.sub(r)),h=(0,s.Fn)(([e,t,r],i)=>!0===i.renderer.reversedDepthBuffer?r.sub(t).mul(e).sub(r):t.sub(r).mul(e).sub(t)),d=(e,t,r)=>t.add(e).mul(r).div(r.sub(t).mul(e)),c=(e,t,r)=>t.mul(e.add(r)).div(e.mul(t.sub(r))),p=(0,s.Fn)(([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))),m=(e,t,r)=>{t=t.max(1e-6).toVar();let i=(0,s.p67)(e.negate().div(t)),a=(0,s.p67)(r.div(t));return i.div(a)},g=(0,s.Hmo)(l,l.DEPTH_BASE),f=(0,s.DSt)(l,l.DEPTH);(0,s.Hmo)(l,l.LINEAR_DEPTH).setParameterLength(0,1),(0,o.z)(),f.assign=e=>g(e)},82590:(e,t,r)=>{r(12106);var i=r(40786),s=(r(83815),r(39848),r(96285),r(66463),r(40641),r(96310));r(2945),i.Ay},82842:(e,t,r)=>{r.d(t,{A:()=>i});let i=(0,r(13662).Fn)(({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)})},83745:(e,t,r)=>{r.d(t,{Q:()=>i});class i{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){let r=this._listeners;return void 0!==r&&void 0!==r[e]&&-1!==r[e].indexOf(t)}removeEventListener(e,t){let r=this._listeners;if(void 0===r)return;let i=r[e];if(void 0!==i){let e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(void 0===t)return;let r=t[e.type];if(void 0!==r){e.target=this;let t=r.slice(0);for(let r=0,i=t.length;r<i;r++)t[r].call(this,e);e.target=null}}}},83815:(e,t,r)=>{r.d(t,{$8:()=>o,Iy:()=>l,KS:()=>s,Xp:()=>n,ez:()=>i,pF:()=>a});let i={VERTEX:"vertex",FRAGMENT:"fragment"},s={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},a={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},n=["setup","analyze","generate"],o=["fragment","vertex","compute"],l=["x","y","z","w"]},83861:(e,t,r)=>{r.d(t,{A:()=>u});var i=r(95944),s=r(82842),a=r(61114),n=r(24481),o=r(41601);class l extends i.A{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=(0,a.P)(0).setGroup(n.sx),this.decayExponentNode=(0,a.P)(2).setGroup(n.sx)}update(e){let{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return(0,o.nR)(this.light)}setupDirect(e){return(({color:e,lightVector:t,cutoffDistance:r,decayExponent:i})=>{let a=t.normalize(),n=t.length(),o=(0,s.A)({lightDistance:n,cutoffDistance:r,decayExponent:i});return{lightDirection:a,lightColor:e.mul(o)}})({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}let u=l},83965:(e,t,r)=>{r.d(t,{u:()=>s});var i=r(18385);class s extends i.TH{constructor(e,t,r,i=1){super(e,t,r),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}},84551:(e,t,r)=>{r.d(t,{b:()=>a});var i=r(27240),s=r(2945);class a extends i.g{constructor(e=[],t=s.hy7,r,i,a,n,o,l,u,h){super(e,t,r,i,a,n,o,l,u,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}},84552:(e,t,r)=>{r.d(t,{S:()=>i});let i=(0,r(12106).Fn)(e=>e.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection")},84774:(e,t,r)=>{r.d(t,{B:()=>R});var i=r(65415),s=r(26609),a=r(26990),n=r(83745),o=r(46956);class l{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!=0}isEnabled(e){return(this.mask&1<<e)!=0}}var u=r(79623),h=r(51166),d=r(51365);let c=0,p=new s.P,m=new i.P,g=new a.k,f=new s.P,y=new s.P,x=new s.P,b=new i.P,v=new s.P(1,0,0),_=new s.P(0,1,0),T=new s.P(0,0,1),S={type:"added"},A={type:"removed"},M={type:"childadded",child:null},w={type:"childremoved",child:null};class R extends n.Q{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:c++}),this.uuid=(0,h.lk)(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=R.DEFAULT_UP.clone();const e=new s.P,t=new o.O,r=new i.P,n=new s.P(1,1,1);t._onChange(function(){r.setFromEuler(t,!1)}),r._onChange(function(){t.setFromQuaternion(r,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new a.k},normalMatrix:{value:new u.d}}),this.matrix=new a.k,this.matrixWorld=new a.k,this.matrixAutoUpdate=R.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=R.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new l,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}
vendor: 4,396 bytes, line 484
484setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return m.setFromAxisAngle(e,t),this.quaternion.multiply(m),this}rotateOnWorldAxis(e,t){return m.setFromAxisAngle(e,t),this.quaternion.premultiply(m),this}rotateX(e){return this.rotateOnAxis(v,e)}rotateY(e){return this.rotateOnAxis(_,e)}rotateZ(e){return this.rotateOnAxis(T,e)}translateOnAxis(e,t){return p.copy(e).applyQuaternion(this.quaternion),this.position.add(p.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(v,e)}translateY(e){return this.translateOnAxis(_,e)}translateZ(e){return this.translateOnAxis(T,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(g.copy(this.matrixWorld).invert())}lookAt(e,t,r){e.isVector3?f.copy(e):f.set(e,t,r);let i=this.parent;this.updateWorldMatrix(!0,!1),y.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?g.lookAt(y,f,this.up):g.lookAt(f,y,this.up),this.quaternion.setFromRotationMatrix(g),i&&(g.extractRotation(i.matrixWorld),m.setFromRotationMatrix(g),this.quaternion.premultiply(m.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(0,d.z3)("Object3D.add: object can't be added as a child of itself.",e):e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(S),M.child=e,this.dispatchEvent(M),M.child=null):(0,d.z3)("Object3D.add: object not an instance of THREE.Object3D.",e),this}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return -1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(A),w.child=e,this.dispatchEvent(w),w.child=null),this}removeFromParent(){let e=this.parent;return null!==e&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),g.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),g.multiply(e.parent.matrixWorld)),e.applyMatrix4(g),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(S),M.child=e,this.dispatchEvent(M),M.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let r=0,i=this.children.length;r<i;r++){let i=this.children[r].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t,r=[]){this[e]===t&&r.push(this);let i=this.children;for(let s=0,a=i.length;s<a;s++)i[s].getObjectsByProperty(e,t,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(y,e,x),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(y,b,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);let t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].traverseVisible(e)}traverseAncestors(e){let t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(null!==e){let t=e.x,r=e.y,i=e.z,s=this.matrix.elements;s[12]+=t-s[0]*t-s[4]*r-s[8]*i,s[13]+=r-s[1]*t-s[5]*r-s[9]*i,s[14]+=i-s[2]*t-s[6]*r-s[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let r=0,i=t.length;r<i;r++)t[r].updateMatrixWorld(e)}updateWorldMatrix(e,t,r=!1){let i=this.parent;if(!0===e&&null!==i&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||r)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix
vendor: 5,473 bytes, line 484
484):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,r=!0),!0===t){let e=this.children;for(let t=0,i=e.length;t<i;t++)e[t].updateWorldMatrix(!1,!0,r)}}toJSON(e){let t=void 0===e||"string"==typeof e,r={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};function s(t,r){return void 0===t[r.uuid]&&(t[r.uuid]=r.toJSON(e)),r.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),!1!==this.static&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),null!==this.pivot&&(i.pivot=this.pivot.toArray()),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),void 0!==this.morphTargetDictionary&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),void 0!==this.morphTargetInfluences&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(e=>({...e})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let r=t.shapes;if(Array.isArray(r))for(let t=0,i=r.length;t<i;t++){let i=r[t];s(e.shapes,i)}else s(e.shapes,r)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(s(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){let t=[];for(let r=0,i=this.material.length;r<i;r++)t.push(s(e.materials,this.material[r]));i.material=t}else i.material=s(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){let r=this.animations[t];i.animations.push(s(e.animations,r))}}if(t){let t=a(e.geometries),i=a(e.materials),s=a(e.textures),n=a(e.images),o=a(e.shapes),l=a(e.skeletons),u=a(e.animations),h=a(e.nodes);t.length>0&&(r.geometries=t),i.length>0&&(r.materials=i),s.length>0&&(r.textures=s),n.length>0&&(r.images=n),o.length>0&&(r.shapes=o),l.length>0&&(r.skeletons=l),u.length>0&&(r.animations=u),h.length>0&&(r.nodes=h)}return r.object=i,r;function a(e){let t=[];for(let r in e){let i=e[r];delete i.metadata,t.push(i)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=null!==e.pivot?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){let r=e.children[t];this.add(r.clone())}return this}}R.DEFAULT_UP=new s.P(0,1,0),R.DEFAULT_MATRIX_AUTO_UPDATE=!0,R.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0},86389:(e,t,r)=>{r.d(t,{Rz:()=>p});var i=r(40786),s=r(351),a=r(13662),n=r(2945),o=r(87275),l=r(84551),u=r(51365);let h=new l.b;class d extends i.Ay{static get type(){return"CubeTextureNode"}
484constructor(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===n.hy7?s.XB:e.mapping===n.xFO?s.L6:((0,u.z3)('CubeTextureNode: Mapping "%s" not supported.',e.mapping),(0,a.eR5)(0,0,0))}setUpdateMatrix(){}setupUV(e,t){let r=this.value;return!0===r.isDepthTexture?e.renderer.coordinateSystem===n.i7u?(0,a.eR5)(t.x,t.y.negate(),t.z):t:(t=o.RS.mul(t),e.renderer.coordinateSystem!==n.i7u&&r.isRenderTargetTexture||(t=(0,a.eR5)(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,!0===this.sampler?"vec3":"ivec3")}}let c=(0,a.Hmo)(d).setParameterLength(1,4).setName("cubeTexture"),p=(e=h,t=null,r=null,i=null)=>{let s;return e&&!0===e.isCubeTextureNode?((s=(0,a.mp$)(e.clone())).referenceNode=e,null!==t&&(s.uvNode=(0,a.mp$)(t)),null!==r&&(s.levelNode=(0,a.mp$)(r)),null!==i&&(s.biasNode=(0,a.mp$)(i))):s=c(e,t,r,i),s}},86467:(e,t,r)=>{r.d(t,{fv:()=>a,kh:()=>n});var i=r(13662),s=r(81951);let a=e=>(0,i.mp$)(e).mul(.5).add(.5),n=e=>(0,i.eR5)(e,(0,s.RZ)((0,s.Ih)((0,i.fVC)(1).sub((0,s.Om)(e,e)))))},87275:(e,t,r)=>{r.d(t,{RS:()=>l,YU:()=>n,st:()=>o});var i=r(26990),s=r(61114);let a=new i.k,n=(0,s.P)(0).onReference(({material:e})=>e).onObjectUpdate(({material:e})=>e.refractionRatio),o=(0,s.P)(1).onReference(({material:e})=>e).onObjectUpdate(function({material:e,scene:t}){return e.envMap?e.envMapIntensity:t.environmentIntensity}),l=(0,s.P)(new i.k).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?a.makeRotationFromEuler(r).transpose():a.identity(),a})},87801:(e,t,r)=>{r.d(t,{Ay:()=>a});var i=r(57218);r(13662);class s extends i.A{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 a=s},87954:(e,t,r)=>{r.d(t,{PC:()=>l});var i=r(57218),s=r(83815),a=r(12106),n=r(37600);class o extends i.A{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=(0,n.T)(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,o=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,i,s,a,o),t.node=(0,n.T)(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation="fragment"===e.shaderStage),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(s.ez.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(s.ez.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 a=this.getNodeType(e),n=e.getPropertyName(i,s.ez.VERTEX);if(e.shaderStage===s.ez.VERTEX){let t=r.node.build(e,a);e.addLineFlowCode(`${n} = ${t}`,this)}else e.flowNodeFromShaderStage(s.ez.VERTEX,r.node,a,n);r[t]=n}return e.getPropertyName(i)}}let l=(0,a.Hm)(o).setParameterLength(1,2);(0,a.mV)("toVarying",l),(0,a.mV)("toVertexStage",e=>l(e))},88500:(e,t,r)=>{r.d(t,{k:()=>i});class i{static{i.prototype.isMatrix2=!0}
484constructor(e,t,r,i){this.elements=[1,0,0,1],void 0!==e&&this.set(e,t,r,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let r=0;r<4;r++)this.elements[r]=e[r+t];return this}set(e,t,r,i){let s=this.elements;return s[0]=e,s[2]=t,s[1]=r,s[3]=i,this}}},88722:(e,t,r)=>{r.d(t,{Pz:()=>v,tf:()=>T});var i=r(13662),s=r(80904),a=r(74872),n=r(61296),o=r(21387),l=r(19793),u=r(6293),h=r(8926),d=r(89670),c=r(95249);class p extends c.e{constructor(e,t,r=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}var m=r(83965),g=r(2945);let f=new WeakMap,y=new WeakMap,x=new WeakMap;function b(e,t){let r,s=Math.max(t.count,1);if(!0===t.isStorageInstancedBufferAttribute)r=(0,h.I)(t,"mat4",s).element(d.cG);else if(16*s*4<=e.getUniformBufferLimit())r=(0,u.r)(t.array,"mat4",s).element(d.cG);else{let e=f.get(t);e||(e=new p(t.array,16,1),f.set(t,e));let s=t.usage===g.Vnu?l.bQ:l.Oc,a=[s(e,"vec4",16,0),s(e,"vec4",16,4),s(e,"vec4",16,8),s(e,"vec4",16,12)];r=(0,i.pBV)(...a)}return r}let v=(0,o.mp)("vec3","vInstanceColor"),_=(0,i.Fn)(([e,t=null],r)=>{let o=!0===e.isStorageInstancedBufferAttribute,u=t&&!0===t.isStorageInstancedBufferAttribute,c=b(r,e),p=null;!o&&16*Math.max(e.count,1)*4>r.getUniformBufferLimit()&&(p=f.get(e));let _=null,T=null;if(t)if(u)_=(0,h.I)(t,"vec3",Math.max(t.count,1)).element(d.cG);else{let e=y.get(t);e||(e=new m.u(t.array,3),y.set(t,e)),T=e;let r=t.usage===g.Vnu?l.bQ:l.Oc;_=(0,i.eR5)(r(e,"vec3",3,0))}(null!==p||null!==T)&&(0,s.G_)(()=>{null!==p&&(p.clearUpdateRanges(),p.updateRanges.push(...e.updateRanges),e.version!==p.version&&(p.version=e.version)),t&&null!==T&&(T.clearUpdateRanges(),T.updateRanges.push(...t.updateRanges),t.version!==T.version&&(T.version=t.version))});let S=c.mul(n.po).xyz;if(n.po.assign(S),r.needsPreviousData()){let t=r.object;(0,s.ow)(({object:t})=>{x.get(t).previousInstanceMatrix.array.set(e.array)});let i=function(e,t,r){let i=x.get(e);if(void 0===i){let s=t.clone();i={previousInstanceMatrix:s,node:b(r,s)},x.set(e,i)}return i.node}(t,e,r);n.DW.assign(i.mul(n.DW).xyz)}if(r.hasGeometryAttribute("normal")){let e=(0,a.qs)(a.xg,c);a.xg.assign(e)}null!==_&&v.assign(_)},"void"),T=(0,i.Fn)(([e])=>{let{instanceMatrix:t,instanceColor:r}=e;_(t,r)},"void")},88737:(e,t,r)=>{var i=r(57218),s=r(12106);class a extends i.A{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 485`):e.addLineFlowCode(`${t}Barrier()`,this)}}(0,s.Hm)(a)},89039:(e,t,r)=>{r.d(t,{e:()=>o});var i=r(5092),s=r(13662),a=r(81951);class n extends i.A{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(0,s.pmN)(e,i,i.negate(),e).mul(r)}{let e=(0,s.pBV)((0,s.lnd)(1,0,0,0),(0,s.lnd)(0,(0,a.gn)(t.x),(0,a.F8)(t.x).negate(),0),(0,s.lnd)(0,(0,a.F8)(t.x),(0,a.gn)(t.x),0),(0,s.lnd)(0,0,0,1)),i=(0,s.pBV)((0,s.lnd)((0,a.gn)(t.y),0,(0,a.F8)(t.y),0),(0,s.lnd)(0,1,0,0),(0,s.lnd)((0,a.F8)(t.y).negate(),0,(0,a.gn)(t.y),0),(0,s.lnd)(0,0,0,1)),n=(0,s.pBV)((0,s.lnd)((0,a.gn)(t.z),(0,a.F8)(t.z).negate(),0,0),(0,s.lnd)((0,a.F8)(t.z),(0,a.gn)(t.z),0,0),(0,s.lnd)(0,0,1,0),(0,s.lnd)(0,0,0,1));return e.mul(i).mul(n).mul((0,s.lnd)(r,1)).xyz}}}let o=(0,s.Hmo)(n).setParameterLength(2)},89670:(e,t,r)=>{r.d(t,{cG:()=>l,dK:()=>u,hG:()=>o});var i=r(57218),s=r(12106),a=r(87954);class n extends i.A{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===n.VERTEX)t=e.getVertexIndex();else if(i===n.INSTANCE)t=e.getInstanceIndex();else if(i===n.DRAW)t=e.getDrawIndex();else if(i===n.INVOCATION_LOCAL)t=e.getInvocationLocalIndex();
485else if(i===n.INVOCATION_SUBGROUP)t=e.getInvocationSubgroupIndex();else if(i===n.SUBGROUP)t=e.getSubgroupIndex();else throw Error("THREE.IndexNode: Unknown scope: "+i);return"vertex"===e.shaderStage||"compute"===e.shaderStage?t:(0,a.PC)(this).build(e,r)}}n.VERTEX="vertex",n.INSTANCE="instance",n.SUBGROUP="subgroup",n.INVOCATION_LOCAL="invocationLocal",n.INVOCATION_SUBGROUP="invocationSubgroup",n.DRAW="draw";let o=(0,s.DS)(n,n.VERTEX),l=(0,s.DS)(n,n.INSTANCE);n.SUBGROUP,n.INVOCATION_SUBGROUP,n.INVOCATION_LOCAL;let u=(0,s.DS)(n,n.DRAW)},89723:(e,t,r)=>{r.d(t,{P:()=>a});var i=r(27240),s=r(2945);class a extends i.g{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=s.hxR,this.minFilter=s.hxR,this.generateMipmaps=!1,this.needsUpdate=!0}}},89976:(e,t,r)=>{var i=r(33962),s=r(13662),a=r(2945);class n{constructor(e=a.NTi){this.blending=e,this.blendSrc=a.ie2,this.blendDst=a.OuU,this.blendEquation=a.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 o=new n(a.XIg),l=new n(a.pCc);class u extends i.A{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.blendModes={output:l},this.isMRTNode=!0}setBlendMode(e,t){return this.blendModes[e]=t,this}getBlendMode(e){return this.blendModes[e]||o}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=h(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=function(e,t){for(let r=0;r<e.length;r++)if(e[r].name===t)return r;return -1}(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 h=(0,s.Hmo)(u)},90083:(e,t,r)=>{r.d(t,{z:()=>a});var i=r(14508);class s extends i.Ay{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 a=(e,t,r=null)=>new s(e,t,r)},91752:(e,t,r)=>{r.d(t,{v:()=>X});var i=r(5092),s=r(40786),a=r(46362),n=r(61114),o=r(83815),l=r(13662),u=r(2945),h=r(27240),d=r(96285),c=r(57641),p=r(61046),m=r(86389),g=r(39848),f=r(64994),y=r(9404),x=r(50782),b=r(26609),v=r(61806),_=r(18385),T=r(40641),S=r(2704),A=r(2550),M=r(71497),w=r(24946),R=r(51365);let N=[.125,.215,.35,.446,.526,.582],C=new y.q(-1,1,1,-1,0,1),E=new A.u(90,1),F=new x.Q,B=null,P=0,V=0,L=new b.P,I=new WeakMap,O=[3,1,5,0,4,2],D=(0,a.u6)((0,g.uv)(),(0,f.l)("faceIndex")).normalize(),U=(0,l.eR5)(D.x,D.y,D.z);class z{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={}){let{size:a=256,position:n=L,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.');B=this._renderer.getRenderTarget(),P=this._renderer.getActiveCubeFace(),V=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,R.mc)('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)}
485async fromEquirectangularAsync(e,t=null){return(0,R.mc)('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,R.mc)('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=W(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=$(),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(B,P,V),e.scissorTest=!1,this._setViewport(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),B=this._renderer.getRenderTarget(),P=this._renderer.getActiveCubeFace(),V=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 k(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){var t,r,i,o,u,h;let d,c,m,g,f,y,x,T,A,M,w,R,C,E,F;null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=k(e.width,e.height);let{_lodMax:B}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=function(e){let t=[],r=[],i=[],s=e,a=e-4+1+N.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=N[n-e+4-1]:0===n&&(o=0),r.push(o);let l=1/(a-2),u=-l,h=1+l,d=[u,u,h,u,h,h,u,u,h,h,u,h],c=new Float32Array(108),p=new Float32Array(72),m=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=O[e];c.set(i,18*s),p.set(d,12*s);let a=[s,s,s,s,s,s];m.set(a,6*s)}let g=new v.L;g.setAttribute("position",new _.TH(c,3)),g.setAttribute("uv",new _.TH(p,2)),g.setAttribute("faceIndex",new _.TH(m,1)),i.push(new S.e(g,null)),s>4&&s--}return{lodMeshes:i,sizeLods:t,sigmas:r}}(B)),this._blurMaterial=(t=B,r=e.width,i=e.height,d=(0,p.W)(Array(20).fill(0)),c=(0,n.P)(new b.P(0,1,0)),m=(0,n.P)(0),g=(0,l.fVC)(20),f=(0,n.P)(0),y=(0,n.P)(1),x=(0,s.wH)(),T=(0,n.P)(0),A={n:g,latitudinal:f,weights:d,poleAxis:c,outputDirection:U,dTheta:m,samples:y,envMap:x,mipInt:T,CUBEUV_TEXEL_WIDTH:(0,l.fVC)(1/r),CUBEUV_TEXEL_HEIGHT:(0,l.fVC)(1/i),CUBEUV_MAX_MIP:(0,l.fVC)(t)},(M=G("blur")).fragmentNode=(0,a.Ge)({...A,latitudinal:f.equal(1)}),I.set(M,A),M),this._ggxMaterial=(o=B,u=e.width,h=e.height,w=(0,s.wH)(),R=(0,n.P)(0),C=(0,n.P)(0),E={envMap:w,roughness:R,mipInt:C,CUBEUV_TEXEL_WIDTH:(0,l.fVC)(1/u),CUBEUV_TEXEL_HEIGHT:(0,l.fVC)(1/h),CUBEUV_MAX_MIP:(0,l.fVC)(o)},(F=G("ggx")).fragmentNode=(0,a.BK)({...E,N_immutable:U,GGX_SAMPLES:(0,l.Hdr)(512)}),I.set(F,E),F)}}async _compileMaterial(e){let t=new S.e(new v.L,e);await this._renderer.compile(t,C)}_sceneToCubeUV(e,t,r,i,s){E.near=t,E.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(F),o.autoClear=!1,null===this._backgroundBox&&(this._backgroundBox=new S.e(new w.i,new M.V({name:"PMREM.Backgroun
485d",side:u.hsX,depthWrite:!1,depthTest:!1})));let h=this._backgroundBox,d=h.material,c=!1,p=e.background;p?p.isColor&&(d.color.copy(p),e.background=null,c=!0):(d.color.copy(F),c=!0),o.setRenderTarget(i),o.clear(),c&&o.render(h,E);for(let t=0;t<6;t++){let r=t%3;0===r?(E.up.set(0,a[t],0),E.position.set(s.x,s.y,s.z),E.lookAt(s.x+n[t],s.y,s.z)):1===r?(E.up.set(0,0,a[t]),E.position.set(s.x,s.y,s.z),E.lookAt(s.x,s.y+n[t],s.z)):(E.up.set(0,a[t],0),E.position.set(s.x,s.y,s.z),E.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,E)}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=W(e)):null===this._equirectMaterial&&(this._equirectMaterial=$(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,C)}_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=I.get(a),l=r/(this._lodMeshes.length-1),u=t/(this._lodMeshes.length-1),h=Math.sqrt(l*l-u*u),{_lodMax:d}=this,c=this._sizeLods[r],p=3*c*(r>d-4?r-d+4:0),m=4*(this._cubeSize-c);e.texture.frame=(e.texture.frame||0)+1,o.envMap.value=e.texture,o.roughness.value=h*(0+1.25*l),o.mipInt.value=d-t,this._setViewport(s,p,m,3*c,2*c),i.setRenderTarget(s),i.render(n,C),s.texture.frame=(s.texture.frame||0)+1,o.envMap.value=s.texture,o.roughness.value=0,o.mipInt.value=d-r,this._setViewport(e,p,m,3*c,2*c),i.setRenderTarget(e),i.render(n,C)}_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,R.z3)("blur direction must be either latitudinal or longitudinal!");let u=this._lodMeshes[i];u.material=l;let h=I.get(l),d=this._sizeLods[r]-1,c=isFinite(s)?Math.PI/(2*d):2*Math.PI/39,p=s/c,m=isFinite(s)?1+Math.floor(3*p):20;m>20&&(0,R.R8)(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);let g=[],f=0;for(let e=0;e<20;++e){let t=e/p,r=Math.exp(-t*t/2);g.push(r),0===e?f+=r:e<m&&(f+=2*r)}for(let e=0;e<g.length;e++)g[e]=g[e]/f;e.texture.frame=(e.texture.frame||0)+1,h.envMap.value=e.texture,h.samples.value=m,h.weights.array=g,h.latitudinal.value=+("latitudinal"===a),n&&(h.poleAxis.value=n);let{_lodMax:y}=this;h.dTheta.value=c,h.mipInt.value=y-r;let x=this._sizeLods[i],b=4*(this._cubeSize-x);this._setViewport(t,3*x*(i>y-4?i-y+4:0),b,3*x,2*x),o.setRenderTarget(t),o.render(u,C)}_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 k(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 T.O(e,t,i);return s.texture.mapping=u.Om,s.texture.name="PMREM.cubeUv",s.texture.isPMREMTexture=!0,s.scissorTest=!0,s}function G(e){let t=new d.A;return t.depthTest=!1,t.depthWrite=!1,t.blending=u.XIg,t.name=`PMREM_${e}`,t}function W(e){let t=G("cubemap");return t.fragmentNode=(0,m.Rz)(e,U),t}function $(e){let t=G("equirect");return t.fragmentNode=(0,s.wH)(e,(0,c.C)(U),0),t}var H=r(87275);let j=new WeakMap;class q extends i.A{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const i=new h.g;i.isRenderTargetTexture=!0,this._texture=(0,s.wH)(i),this._width=(0,n.P)(0),this._height=(0,n.P)(0),this._maxMip=(0,n.P)(0),this.updateBeforeType=o.KS.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){var t;let r,i={texelWidth:1/(3*Math.max(Math.pow(2,r=Math.log2(t=e.image.height)-2),112)),texelHeight:1/t,maxMip:r};this._texture.value=e,this._width.value=i.texelWidth,this._height.value=i.texelHeight,this._maxMip.value=i.maxMip}updateBefore(e){let t=this._pmrem,r=t?t.pmremVersion:-1,i=this._value;r!==i.pmremVersion&&null!==(t=!0===i.isPMREMTexture||i.mapping===u.Om?i:function(e,t,r){var i,s;let a,n=(i=t,void 0===(a=j.get(i))&&(a=new WeakMap,j.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 z(e.renderer)),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?H.RS.mul((0,l.eR5)(t.x,t.y.negate(),t.z)):H.RS.mul(t);let r=this.levelNode;return null===r&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),(0,a.w6)(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),null!==this._generator&&this._generator.dispose()}}let X=(0,l.Hmo)(q).setParameterLength(1,3)},92222:(e,t,r)=>{r.d(t,{f:()=>o});var i=r(57218),s=r(12106);class a extends i.A{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;
485for(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 n=(0,s.Hm)(a),o=e=>(...t)=>n(e,...t)},92548:(e,t,r)=>{var i=r(5092);r(27300),r(61296),r(13662),r(83815);r(26990);r(61114),r(98121),r(75180),r(24481);new WeakMap;i.A},93410:(e,t,r)=>{r.d(t,{A:()=>i});let i=(0,r(13662).Fn)(e=>e.diffuseColor.mul(1/Math.PI))},93998:(e,t,r)=>{r.d(t,{i:()=>l});var i=r(6593),s=r(26609);let a=new i.N,n=new s.P,o=new s.P;class l{constructor(e=new s.P,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let r=this.center;void 0!==t?r.copy(t):a.setFromPoints(e).getCenter(r);let i=0;for(let t=0,s=e.length;t<s;t++)i=Math.max(i,r.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let r=this.center.distanceToSquared(e);return t.copy(e),r>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?e.makeEmpty():(e.set(this.center,this.center),e.expandByScalar(this.radius)),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;n.subVectors(e,this.center);let t=n.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),r=(e-this.radius)*.5;this.center.addScaledVector(n,r/e),this.radius+=r}return this}union(e){return e.isEmpty()||(this.isEmpty()?this.copy(e):!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(o.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(n.copy(e.center).add(o)),this.expandByPoint(n.copy(e.center).sub(o)))),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}},94018:(e,t,r)=>{r.d(t,{_:()=>n});var i=r(13662),s=r(15907);class a extends s.A{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 n=(0,i.Hmo)(a).setParameterLength(2)},94531:(e,t,r)=>{r.d(t,{az:()=>o});var i=r(57218),s=r(12106),a=r(51365);class n extends i.A{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);
485e.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 o=e=>new n((0,s.mp)(e));(0,s.mV)("cache",function(e,t=!0){return(0,a.R8)('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),o(e).setParent(t)}),(0,s.mV)("isolate",o)},94548:(e,t,r)=>{var i=r(5092),s=r(12106),a=r(51365);class n extends i.A{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),n=this.parameters,o=(t,r)=>{let i=r.type;return"pointer"===i?"&"+t.build(e):t.build(e,i)};if(Array.isArray(n)){if(n.length>i.length)(0,a.z3)("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=i.length;else if(n.length<i.length)for((0,a.z3)("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<i.length;)n.push((0,s.fV)(0));for(let e=0;e<n.length;e++)t.push(o(n[e],i[e]))}else for(let e of i){let r=n[e.name];void 0!==r?t.push(o(r,e)):((0,a.z3)(`TSL: Input '${e.name}' not found in 'Fn()'.`),t.push(o((0,s.fV)(0),e)))}let l=r.build(e,"property");return`${l}( ${t.join(", ")} )`}}(0,s.mV)("call",(e,...t)=>(t=t.length>1||t[0]&&!0===t[0].isNode?(0,s._j)(t):(0,s.RT)(t[0]),new n((0,s.mp)(e),t)))},95080:(e,t,r)=>{r.d(t,{Ay:()=>a});var i=r(87801);r(12106);class s extends i.Ay{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}getNodeFunction(e){let t=e.getDataFromNode(this),r=t.nodeFunction;return void 0===r&&(t.nodeFunction=r=e.parser.parseFunction(this.code)),r}generate(e,t){super.generate(e);let r=this.getNodeFunction(e),i=r.name,s=r.type,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 a=s},95249:(e,t,r)=>{r.d(t,{e:()=>a});var i=r(51166),s=r(2945);class a{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=s.agE,this.updateRanges=[],this.version=0,this.uuid=(0,i.lk)()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,r){e*=this.stride,r*=t.stride;for(let i=0,s=this.stride;i<s;i++)this.array[e+i]=t.array[r+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=(0,i.lk)()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),r=new this.constructor(t,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=(0,i.lk)()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}},95538:(e,t,r)=>{r.d(t,{Ay:()=>c,VM:()=>g,gu:()=>p});var i=r(40786),s=r(83815),a=r(13662),n=r(96621),o=r(96310),l=r(89723),u=r(2945);let h=new o.I;class d extends i.Ay{static get type(){return"ViewportTextureNode"}constructor(e=n.m1,t=null,r=null){let i=null;null===r?((i=new l.P).minFilter=u.$_I,r=i):i=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=i,this.isOutputTextureNode=!0,this.updateBeforeType=s.KS.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(h):s.getDrawingBufferSize?s.getDrawingBufferSize(h):h.set(s.width,s.height);let a=this.getTextureForReference(s);(a.image.width!==h.width||a.image.height!==h.height)&&(a.image.width=h.width,a.image.height=h.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 c=d,p=(0,a.Hmo)(d,null,null,{generateMipmaps:!0}).setParameterLength(0,3),m=p(),g=(e=n.m1,t=null)=>m.sample(e,t)},95944:(e,t,r)=>{r.d(t,{A:()=>p});var i=r(64551),s=r(83815),a=r(61114),n=r(50782),o=r(24481),l=r(56759),u=r(12106),h=r(48214),d=r(61296);class c extends i.A{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new n.Q,this.colorNode=e&&e.colorNode||(0,a.P)(this.color).setGroup(o.sx),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=s.KS.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}
485disposeShadow(){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(0,h.p)(this.light).sub(e.context.positionView||d.tX)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return(0,l.r7)(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?(0,u.mp)(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 p=c},96201:(e,t,r)=>{r.d(t,{V:()=>n});var i=r(40524),s=r(27240),a=r(2945);class n extends s.g{constructor(e,t,r=a.bkx,i,s,n,o=a.hxR,l=a.hxR,u,h=a.zdS,d=1){if(h!==a.zdS&&h!==a.dcC)throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:d},i,s,n,o,l,h,r,u),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new i.k(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}},96285:(e,t,r)=>{r.d(t,{A:()=>I});var i=r(98786),s=r(79699),a=r(21387),n=r(44342),o=r(84552),l=r(74872),u=r(88722),h=r(55301),d=r(90083),c=r(61296),p=r(44268),m=r(46836),g=r(81951),f=r(13662),y=r(48983),x=r(24222),b=r(99209),v=r(82196),_=r(75180),T=r(46537);let S=["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"],A=new WeakMap,M=new WeakMap,w=new WeakMap;class R{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=!0===e.object.isSkinnedMesh,this.refreshUniforms=S,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=w.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}},w.set(e,t)),t}getMaterialData(e){let t=M.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)}M.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);
485if(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;let n=a.index,o=l.indexId,u=l.indexVersion,h=n?n.id:null,d=n?n.version:null;if(o!==h||u!==d)return l.indexId=h,l.indexVersion=d,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=A.get(e);return void 0===r&&(r={renderId:-1,lightsData:[]},A.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 N=(0,f.Fn)(([e])=>(0,f.jcx)((0,f.lKK)(1e4,(0,f.F8e)((0,f.lKK)(17,e.x).add((0,f.lKK)(.1,e.y)))).mul((0,f.WQq)(.1,(0,f.tnl)((0,f.F8e)((0,f.lKK)(13,e.y).add(e.x))))))),C=(0,f.Fn)(([e])=>N((0,f.ZcS)(N(e.xy),e.z))),E=(0,f.Fn)(([e])=>{let t=(0,f.T9B)((0,f.Bw9)((0,f.PuG)(e.xyz)),(0,f.Bw9)((0,f.IbF)(e.xyz))),r=(0,f.fVC)(1).div((0,f.fVC)(.05).mul(t)).toVar("pixScale"),i=(0,f.ZcS)((0,f.IeL)((0,f.RIf)((0,f.p67)(r))),(0,f.IeL)((0,f.mkO)((0,f.p67)(r)))),s=(0,f.ZcS)(C((0,f.RIf)(i.x.mul(e.xyz))),C((0,f.RIf)(i.y.mul(e.xyz)))),a=(0,f.jcx)((0,f.p67)(r)),n=(0,f.WQq)((0,f.lKK)(a.oneMinus(),s.x),(0,f.lKK)(a,s.y)),o=(0,f.jkA)(a,a.oneMinus()),l=(0,f.eR5)(n.mul(n).div((0,f.lKK)(2,o).mul((0,f.jbE)(1,o))),n.sub((0,f.lKK)(.5,o)).div((0,f.jbE)(1,o)),(0,f.jbE)(1,(0,f.jbE)(1,n).mul((0,f.jbE)(1,n)).div((0,f.lKK)(2,o).mul((0,f.jbE)(1,o))))),u=n.lessThan(o.oneMinus()).select(n.lessThan(o).select(l.x,l.y),l.z);return(0,f.qE8)(u,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});var F=r(27300),B=r(7176),P=r(57123),V=r(37600);class L extends i.i{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((0,s.YZ)(t.slice(0,-4)),r.getCacheKey());return this.type+(0,s.g0)(e)}build(e){this.setup(e)}setupObserver(e){return new R(e)}setup(e){let t;e.context.setupNormal=()=>(0,V.T)(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),n=(0,V.T)(this.vertexNode||s,"VERTEX");e.context.clipSpace=n,e.stack.outputNode=n,this.setupHardwareClipping(e),null!==this.geometryNode&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let o=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!==o&&e.stack.addToStack(o);let n=(0,f.lnd)(s,a.YL.a).max(0);t=this.setupOutput(e,n),a.CG.assign(t);let l=null!==this.outputNode;if(l&&(t=this.outputNode),e.context.getOutput&&(t=e.context.getOutput(t,e)),null!==i){let e=r.getMRT(),i=this.mrtNode;null!==e?(l&&a.CG.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=(0,T.di)():e.stack.addToStack((0,T.zE)())}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((0,T.l5)()),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?(0,v.Ps)(c.tX.z,_.Ir,_.xV):(0,v.Kj)(c.tX.z,_.Ir,_.xV))}null!==i&&v.yr.assign(i).toStack()}setupPositionView(){return F.SP.mul(c.po).xyz}setupModelViewProjection(){return _.Kz.mul(c.tX)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),o.S}setupPosition(e){let{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&(0,m.w)(t),!0===t.isSkinnedMesh&&(0,p.e)(t),this.displacementMap){let e=(0,d.z)("displacementMap","texture"),t=(0,d.z)("displacementScale","float"),r=(0,d.z)("displacementBias","float");c.po.addAssign(l.xg.normalize().mul(e.x.mul(t).add(r)))}return t.isBatchedMesh&&(0,h.v)(t),t.isInstancedMesh&&t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&(0,u.tf)(t),null!==this.positionNode&&c.po.assign((0,V.T)(this.positionNode,"POSITION","vec3")),c.po}setupDiffuseColor(e){let{object:t,geometry:r}=e;null!==this.maskNode&&(0,f.lcY)(this.maskNode).not().discard();let i=this.colorNode?(0,f.lnd)(this.colorNode):n.HM;!0===this.vertexColors&&r.hasAttribute("color")&&(i=i.mul((0,B.w)())),t.instanceColor&&(i=u.Pz.mul(i)),t.isBatchedMesh&&t._
485colorsTexture&&(i=h.a.mul(i)),a.YL.assign(i);let s=this.opacityNode?(0,f.fVC)(this.opacityNode):n.nB;a.YL.a.assign(a.YL.a.mul(s));let o=null;(null!==this.alphaTestNode||this.alphaTest>0)&&(o=null!==this.alphaTestNode?(0,f.fVC)(this.alphaTestNode):n.Oe,!0===this.alphaToCoverage?(a.YL.a=(0,g.TF)(o,o.add((0,g.NB)(a.YL.a)),a.YL.a),a.YL.a.lessThanEqual(0).discard()):a.YL.a.lessThanEqual(o).discard()),!0===this.alphaHash&&a.YL.a.lessThan(E(c.po)).discard(),e.isOpaque()&&a.YL.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?(0,f.eR5)(0):a.YL.rgb}setupNormal(){return this.normalNode?(0,f.eR5)(this.normalNode):n.Dc}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?(0,d.z)("envMap","cubeTexture"):(0,d.z)("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new b.A(n.ex)),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 y.A(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;null===t&&e.material.aoMap&&(t=n.CO),e.context.getAO&&(t=e.context.getAO(t,e)),null!==t&&(a.qM.assign(t),e.context.ambientOcclusion=a.qM)}setupLightingModel(){}setupLighting(e){let{material:t}=e,{backdropNode:r,backdropAlphaNode:i,emissiveNode:s}=this,o=!0===this.lights||null!==this.lightsNode,l=!0===this.lights?this.setupMaterialLightings(e):[],u=o?this.lightsNode||e.lightsNode:null,h=this.setupOutgoingLight(e);if(u&&(l.length>0||u.getScope().hasLights)){let t=this.setupLightingModel(e)||null;h=(0,x.i)(u,t,l,r,i)}else null!==r&&(h=(0,f.eR5)(null!==i?(0,g.jh)(h,r,i):r));return(s&&!0===s.isNode||t.emissive&&!0===t.emissive.isColor)&&(a.wg.assign((0,f.eR5)(s||n.vK)),h=h.add(a.wg)),h}setupFog(e,t){let r=e.fogNode;return r&&(a.CG.assign(t),t=(0,f.lnd)(r.toVar())),t}setupPremultipliedAlpha(e,t){return(0,P.I)(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=i.i.prototype.toJSON.call(this,e);for(let{property:t,childNode:i}of(r.inputNodes={},this._getNodeChildren()))r.inputNodes[t]=i.toJSON(e).uuid;function s(e){let t=[];for(let r in e){let i=e[r];delete i.metadata,t.push(i)}return t}if(t){let t=s(e.textures),i=s(e.images),a=s(e.nodes);t.length>0&&(r.textures=t),i.length>0&&(r.images=i),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 I=L},96310:(e,t,r)=>{r.d(t,{I:()=>s});var i=r(51166);class s{static{s.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}
485sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=(0,i.qE)(this.x,e.x,t.x),this.y=(0,i.qE)(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=(0,i.qE)(this.x,e,t),this.y=(0,i.qE)(this.y,e,t),this}clampLength(e,t){let r=this.length();return this.divideScalar(r||1).multiplyScalar((0,i.qE)(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let r=this.dot(e)/t;return Math.acos((0,i.qE)(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,r=this.y-e.y;return t*t+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let r=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}},96621:(e,t,r)=>{let i,s;r.d(t,{Vj:()=>g,es:()=>m,hG:()=>c,m1:()=>p,yT:()=>y});var a=r(57218);r(69707);var n=r(83815),o=r(61114),l=r(13662),u=r(96310),h=r(25756);class d extends a.A{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===d.DPR?"float":this.scope===d.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=n.KS.NONE;return(this.scope===d.SIZE||this.scope===d.VIEWPORT||this.scope===d.DPR)&&(e=n.KS.RENDER),this.updateType=e,e}update({renderer:e}){let t=e.getRenderTarget();this.scope===d.VIEWPORT?null!==t?s.copy(t.viewport):(e.getViewport(s),s.multiplyScalar(e.getPixelRatio())):this.scope===d.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===d.SIZE?(0,o.P)(i||(i=new u.I)):e===d.VIEWPORT?(0,o.P)(s||(s=new h.I)):e===d.DPR?(0,o.P)(1):(0,l.ZcS)(g.div(m)),this._output=t,t}generate(e){if(this.scope===d.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){let r=e.getNodeProperties(m).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}d.COORDINATE="coordinate",d.VIEWPORT="viewport",d.SIZE="size",d.UV="uv",d.DPR="dpr";let c=(0,l.DSt)(d,d.DPR),p=(0,l.DSt)(d,d.UV),m=(0,l.DSt)(d,d.SIZE),g=(0,l.DSt)(d,d.COORDINATE),f=(0,l.DSt)(d,d.VIEWPORT),y=f.zw;f.xy},96798:(e,t,r)=>{r.d(t,{S:()=>n});var i=r(57218),s=r(13662);class a extends i.A{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}let n=(0,s.Hmo)(a).setParameterLength(1)},97553:(e,t,r)=>{var i=r(12106);let s=(0,i.Fn)(([e,t,r,s=(0,i.fV)(0),a=(0,i.fV)(1),n=(0,i.lc)(!1)])=>{let o=e.sub(t).div(r.sub(t));return(0,i.sw)(n)&&(o=o.clamp()),o.mul(a.sub(s)).add(s)});(0,i.mV)("remap",s),(0,i.mV)("remapClamp",function(e,t,r,a=(0,i.fV)(0),n=(0,i.fV)(1)){return s(e,t,r,a,n,!0)})},98121:(e,t,r)=>{r.d(t,{MM:()=>f,WQ:()=>l,jb:()=>u,lK:()=>h,y4:()=>d,zi:()=>c});var i=r(2945),s=r(5092),a=r(12106);let n={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class o extends s.A{static get type(){return"OperatorNode"}constructor(e,t,r,...i){if(super(),i.length>0){let s=new o(e,t,r);for(let t=0;t<i.length-1;t++)s=new o(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(n[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;
485if("~"===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:s,bNode:a}=this,n=this.getNodeType(e,t),o=null,l=null;"void"!==n?(o=s.getNodeType(e),l=a?a.getNodeType(e):null,"<"===r||">"===r||"<="===r||">="===r||"=="===r||"!="===r?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):">>"===r||"<<"===r?(o=n,l=e.changeComponentType(l,"uint")):"%"===r?(o=n,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?"float"===l?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=n):o=e.isMatrix(l)?"float"===o?"float":e.isVector(o)?e.getVectorFromMatrix(l):l=n:l=n):o=l=n;let u=s.build(e,o),h=a?a.build(e,l):null,d=e.getFunctionOperator(r);if("void"!==t){let s=e.renderer.coordinateSystem===i.TdN;if("=="===r||"!="===r||"<"===r||">"===r||"<="===r||">="===r)if(!s)return e.format(`( ${u} ${r} ${h} )`,n,t);else if(e.isVector(o))return e.format(`${this.getOperatorMethod(e,t)}( ${u}, ${h} )`,n,t);else return e.format(`( ${u} ${r} ${h} )`,n,t);if("%"===r)if(e.isInteger(l))return e.format(`( ${u} % ${h} )`,n,t);else return e.format(`${this.getOperatorMethod(e,n)}( ${u}, ${h} )`,n,t);if("!"===r)if(s&&e.isVector(o))return e.format(`not( ${u} )`,t);else return e.format(`( ${r} ${u} )`,o,t);else{if("~"===r)return e.format(`( ${r} ${u} )`,o,t);if(d)return e.format(`${d}( ${u}, ${h} )`,n,t);if(e.isMatrix(o)&&"float"===l)return e.format(`( ${h} ${r} ${u} )`,n,t);if("float"===o&&e.isMatrix(l))return e.format(`${u} ${r} ${h}`,n,t);let i=`( ${u} ${r} ${h} )`;return!s&&"bool"===n&&e.isVector(o)&&e.isVector(l)&&(i=`all${i}`),e.format(i,n,t)}}if("void"!==o)if(d)return e.format(`${d}( ${u}, ${h} )`,n,t);else if(e.isMatrix(o)&&"float"===l)return e.format(`${h} ${r} ${u}`,n,t);else return e.format(`${u} ${r} ${h}`,n,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}let l=(0,a.xA)(o,"+").setParameterLength(2,1/0).setName("add"),u=(0,a.xA)(o,"-").setParameterLength(2,1/0).setName("sub"),h=(0,a.xA)(o,"*").setParameterLength(2,1/0).setName("mul"),d=(0,a.xA)(o,"/").setParameterLength(2,1/0).setName("div"),c=(0,a.xA)(o,"%").setParameterLength(2).setName("mod"),p=(0,a.xA)(o,"==").setParameterLength(2).setName("equal"),m=(0,a.xA)(o,"!=").setParameterLength(2).setName("notEqual"),g=(0,a.xA)(o,"<").setParameterLength(2).setName("lessThan"),f=(0,a.xA)(o,">").setParameterLength(2).setName("greaterThan"),y=(0,a.xA)(o,"<=").setParameterLength(2).setName("lessThanEqual"),x=(0,a.xA)(o,">=").setParameterLength(2).setName("greaterThanEqual"),b=(0,a.xA)(o,"&&").setParameterLength(2,1/0).setName("and"),v=(0,a.xA)(o,"||").setParameterLength(2,1/0).setName("or"),_=(0,a.xA)(o,"!").setParameterLength(1).setName("not"),T=(0,a.xA)(o,"^^").setParameterLength(2).setName("xor"),S=(0,a.xA)(o,"&").setParameterLength(2).setName("bitAnd"),A=(0,a.xA)(o,"~").setParameterLength(1).setName("bitNot"),M=(0,a.xA)(o,"|").setParameterLength(2).setName("bitOr"),w=(0,a.xA)(o,"^").setParameterLength(2).setName("bitXor"),R=(0,a.xA)(o,"<<").setParameterLength(2).setName("shiftLeft"),N=(0,a.xA)(o,">>").setParameterLength(2).setName("shiftRight"),C=(0,a.Fn)(([e])=>(e.addAssign(1),e)),E=(0,a.Fn)(([e])=>(e.subAssign(1),e)),F=(0,a.Fn)(([e])=>{let t=(0,a.Wh)(e).toConst();return e.addAssign(1),t}),B=(0,a.Fn)(([e])=>{let t=(0,a.Wh)(e).toConst();return e.subAssign(1),t});(0,a.mV)("add",l),(0,a.mV)("sub",u),(0,a.mV)("mul",h),(0,a.mV)("div",d),(0,a.mV)("mod",c),(0,a.mV)("equal",p),(0,a.mV)("notEqual",m),(0,a.mV)("lessThan",g),(0,a.mV)("greaterThan",f),(0,a.mV)("lessThanEqual",y),(0,a.mV)("greaterThanEqual",x),(0,a.mV)("and",b),(0,a.mV)("or",v),(0,a.mV)("not",_),(0,a.mV)("xor",T),(0,a.mV)("bitAnd",S),(0,a.mV)("bitNot",A),(0,a.mV)("bitOr",M),(0,a.mV)("bitXor",w),(0,a.mV)("shiftLeft",R),(0,a.mV)("shiftRight",N),(0,a.mV)("incrementBefore",C),(0,a.mV)("decrementBefore",E),(0,a.mV)("increment",F),(0,a.mV)("decrement",B)},98469:(e,t,r)=>{r.d(t,{n:()=>n});var i=r(73705),s=r(24481);
485class a extends i.Ay{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(s.sx)}updateReference(e){return this.reference=null!==this.renderer?this.renderer:e.renderer,this.reference}}let n=(e,t,r=null)=>new a(e,t,r)},98786:(e,t,r)=>{r.d(t,{i:()=>h});var i=r(50782),s=r(83745),a=r(2945),n=r(51166),o=r(51365),l=r(96310);let u=0;class h extends s.Q{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:u++}),this.uuid=(0,n.lk)(),this.name="",this.type="Material",this.blending=a.NTi,this.side=a.hB5,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=a.ie2,this.blendDst=a.OuU,this.blendEquation=a.gO9,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new i.Q(0,0,0),this.blendAlpha=0,this.depthFunc=a.xSv,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=a.sKt,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=a.VVr,this.stencilZFail=a.VVr,this.stencilZPass=a.VVr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let r=e[t];if(void 0===r){(0,o.R8)(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(void 0===i){(0,o.R8)(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector2&&r&&r.isVector2||i&&i.isEuler&&r&&r.isEuler||i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(e){let t=[];for(let r in e){let i=e[r];delete i.metadata,t.push(i)}return t}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),void 0!==this.roughness&&(r.roughness=this.roughness),void 0!==this.metalness&&(r.metalness=this.metalness),void 0!==this.sheen&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(r.shininess=this.shininess),void 0!==this.clearcoat&&(r.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),void 0!==this.dispersion&&(r.dispersion=this.dispersion),void 0!==this.iridescence&&(r.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(r.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(r.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(r.combine=this.combine)),void 0!==this.envMapRotation&&(r.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(r.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(r.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(r.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(r.size=this.size),null!==this.shadowSide&&(r.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==a.NTi&&(r.blending=this.blending),this.side!==a.hB5&&(r.side=this.side),!0===this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),!0===this.transparent&&(r.transparent=!0),this.blendSrc!==a.ie2&&(r.blendSrc=this.blendSrc),this.blendDst!==a.OuU&&(r.blendDst=this.blendDst),this.blendEquation!==a.gO9&&(r.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(r.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&
vendor: 4,923 bytes, line 485
485(r.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==a.xSv&&(r.depthFunc=this.depthFunc),!1===this.depthTest&&(r.depthTest=this.depthTest),!1===this.depthWrite&&(r.depthWrite=this.depthWrite),!1===this.colorWrite&&(r.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==a.sKt&&(r.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(r.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==a.VVr&&(r.stencilFail=this.stencilFail),this.stencilZFail!==a.VVr&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==a.VVr&&(r.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(r.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(r.rotation=this.rotation),!0===this.polygonOffset&&(r.polygonOffset=!0),0!==this.polygonOffsetFactor&&(r.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(r.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(r.linewidth=this.linewidth),void 0!==this.dashSize&&(r.dashSize=this.dashSize),void 0!==this.gapSize&&(r.gapSize=this.gapSize),void 0!==this.scale&&(r.scale=this.scale),!0===this.dithering&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),!0===this.alphaHash&&(r.alphaHash=!0),!0===this.alphaToCoverage&&(r.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(r.premultipliedAlpha=!0),!0===this.forceSinglePass&&(r.forceSinglePass=!0),!1===this.allowOverride&&(r.allowOverride=!1),!0===this.wireframe&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(r.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(r.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(r.flatShading=!0),!1===this.visible&&(r.visible=!1),!1===this.toneMapped&&(r.toneMapped=!1),!1===this.fog&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData),t){let t=i(e.textures),s=i(e.images);t.length>0&&(r.textures=t),s.length>0&&(r.images=s)}return r}fromJSON(e,t){if(void 0!==e.uuid&&(this.uuid=e.uuid),void 0!==e.name&&(this.name=e.name),void 0!==e.color&&void 0!==this.color&&this.color.setHex(e.color),void 0!==e.roughness&&(this.roughness=e.roughness),void 0!==e.metalness&&(this.metalness=e.metalness),void 0!==e.sheen&&(this.sheen=e.sheen),void 0!==e.sheenColor&&(this.sheenColor=new i.Q().setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(this.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==this.emissive&&this.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==this.specular&&this.specular.setHex(e.specular),void 0!==e.specularIntensity&&(this.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==this.specularColor&&this.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(this.shininess=e.shininess),void 0!==e.clearcoat&&(this.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(this.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.dispersion&&(this.dispersion=e.dispersion),void 0!==e.iridescence&&(this.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(this.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(this.transmission=e.transmission),void 0!==e.thickness&&(this.thickness=e.thickness),void 0!==e.attenuationDistance&&(this.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==this.attenuationColor&&this.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(this.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(this.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(this.fog=e.fog),void 0!==e.flatShading&&(this.flatShading=e.flatShading),void 0!==e.blending&&(this.blending=e.blending),void 0!==e.combine&&(this.combine=e.combine),void 0!==e.side&&(this.side=e.side),void 0!==e.shadowSide&&(this.shadowSide=e.shadowSide),void 0!==e.opacity&&(this.opacity=e.opacity),void 0!==e.transparent&&(this.transparent=e.transparent),void 0!==e.alphaTest&&(this.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(this.alphaHash=e.alphaHash),void 0!==e.depthFunc&&(this.depthFunc=e.depthFunc),void 0!==e.depthTest&&(this.depthTest=e.depthTest),void 0!==e.depthWrite&&(this.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(this.colorWrite=e.colorWrite),void 0!==e.blendSrc&&(this.blendSrc=e.blendSrc),void 0!==e.blendDst&&(this.blendDst=e.blendDst),void 0!==e.blendEquation&&(this.blendEquation=e.blendEquation),void 0!==e.blendSrcAlpha&&(this.blendSrcAlpha=e.blendSrcAlpha),void 0!==e.blendDstAlpha&&
485(this.blendDstAlpha=e.blendDstAlpha),void 0!==e.blendEquationAlpha&&(this.blendEquationAlpha=e.blendEquationAlpha),void 0!==e.blendColor&&void 0!==this.blendColor&&this.blendColor.setHex(e.blendColor),void 0!==e.blendAlpha&&(this.blendAlpha=e.blendAlpha),void 0!==e.stencilWriteMask&&(this.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(this.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(this.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(this.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(this.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(this.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(this.stencilZPass=e.stencilZPass),void 0!==e.stencilWrite&&(this.stencilWrite=e.stencilWrite),void 0!==e.wireframe&&(this.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(this.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(this.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(this.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(this.rotation=e.rotation),void 0!==e.linewidth&&(this.linewidth=e.linewidth),void 0!==e.dashSize&&(this.dashSize=e.dashSize),void 0!==e.gapSize&&(this.gapSize=e.gapSize),void 0!==e.scale&&(this.scale=e.scale),void 0!==e.polygonOffset&&(this.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(this.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(this.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(this.dithering=e.dithering),void 0!==e.alphaToCoverage&&(this.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(this.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(this.forceSinglePass=e.forceSinglePass),void 0!==e.allowOverride&&(this.allowOverride=e.allowOverride),void 0!==e.visible&&(this.visible=e.visible),void 0!==e.toneMapped&&(this.toneMapped=e.toneMapped),void 0!==e.userData&&(this.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),void 0!==e.size&&(this.size=e.size),void 0!==e.sizeAttenuation&&(this.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(this.map=t[e.map]||null),void 0!==e.matcap&&(this.matcap=t[e.matcap]||null),void 0!==e.alphaMap&&(this.alphaMap=t[e.alphaMap]||null),void 0!==e.bumpMap&&(this.bumpMap=t[e.bumpMap]||null),void 0!==e.bumpScale&&(this.bumpScale=e.bumpScale),void 0!==e.normalMap&&(this.normalMap=t[e.normalMap]||null),void 0!==e.normalMapType&&(this.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),this.normalScale=new l.I().fromArray(t)}return void 0!==e.displacementMap&&(this.displacementMap=t[e.displacementMap]||null),void 0!==e.displacementScale&&(this.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(this.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(this.roughnessMap=t[e.roughnessMap]||null),void 0!==e.metalnessMap&&(this.metalnessMap=t[e.metalnessMap]||null),void 0!==e.emissiveMap&&(this.emissiveMap=t[e.emissiveMap]||null),void 0!==e.emissiveIntensity&&(this.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(this.specularMap=t[e.specularMap]||null),void 0!==e.specularIntensityMap&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),void 0!==e.specularColorMap&&(this.specularColorMap=t[e.specularColorMap]||null),void 0!==e.envMap&&(this.envMap=t[e.envMap]||null),void 0!==e.envMapRotation&&this.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(this.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(this.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(this.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(this.lightMap=t[e.lightMap]||null),void 0!==e.lightMapIntensity&&(this.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(this.aoMap=t[e.aoMap]||null),void 0!==e.aoMapIntensity&&(this.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(this.gradientMap=t[e.gradientMap]||null),void 0!==e.clearcoatMap&&(this.clearcoatMap=t[e.clearcoatMap]||null),void 0!==e.clearcoatRoughnessMap&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),void 0!==e.clearcoatNormalMap&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),void 0!==e.clearcoatNormalScale&&(this.clearcoatNormalScale=new l.I().fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(this.iridescenceMap=t[e.iridescenceMap]||null),void 0!==e.iridescenceThicknessMap&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),void 0!==e.transmissionMap&&(this.transmissionMap=t[e.transmissionMap]||null),void 0!==e.thicknessMap&&(this.thicknessMap=t[e.thicknessMap]||null),void 0!==e.anisotropyMap&&(this.anisotropyMap=t[e.anisotropyMap]||null),void 0!==e.sheenColorMap&&(this.sheenColorMap=t[e.sheenColorMap]||null),void 0!==e.sheenRoughnessMap&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,r=null;if(null!==t){let e=t.length;r=Array(e);for(let i=0;i!==e;++i)r[i]=t[i].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipSh
485adows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}},99209:(e,t,r)=>{r.d(t,{A:()=>a});var i=r(64551);class s extends i.A{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let a=s},99769:(e,t,r)=>{var i=r(5092),s=r(12106),a=r(98469),n=r(2945),o=r(79699),l=r(51365);class u extends i.A{static get type(){return"ToneMappingNode"}constructor(e,t=h,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return(0,o.tW)(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===n.y_p)return t;let i=null,a=e.renderer.library.getToneMappingFunction(r);return null!==a?i=(0,s.ln)(a(t.rgb,this.exposureNode),t.a):((0,l.z3)("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=t),i}}let h=(0,a.n)("toneMappingExposure","float");(0,s.mV)("toneMapping",(e,t,r)=>new u(t,(0,s.mp)(r),(0,s.mp)(e)))}}]);
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.